From 82a6cc662db8b2ce56337321cd6042093fb03e0d Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Thu, 5 Mar 2026 16:25:52 -0500 Subject: [PATCH 1/9] Fixed boats falling and a TP glitch #266 --- Minecraft.World/Boat.cpp | 17 ++++--- Minecraft.World/LivingEntity.cpp | 76 +++++++++++++++++--------------- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/Minecraft.World/Boat.cpp b/Minecraft.World/Boat.cpp index e39bd7f3e..1811c2094 100644 --- a/Minecraft.World/Boat.cpp +++ b/Minecraft.World/Boat.cpp @@ -87,7 +87,7 @@ Boat::Boat(Level *level, double x, double y, double z) : Entity( level ) double Boat::getRideHeight() { - return bbHeight * 0.0f - 0.3f; + return heightOffset; } bool Boat::hurt(DamageSource *source, float hurtDamage) @@ -283,11 +283,11 @@ void Boat::tick() // 4J Stu - Fix for #9579 - GAMEPLAY: Boats with a player in them slowly sink under the water over time, and with no player in them they float into the sky. // Just make the boats bob up and down rather than any other client-side movement when not receiving packets from server - if (waterPercentage < 1) - { - double bob = waterPercentage * 2 - 1; - yd += 0.04f * bob; - } + if (waterPercentage > 0) + { + double bob = waterPercentage * 2 - 1; + yd += 0.04f * bob; + } else { if (yd < 0) yd /= 2; @@ -307,15 +307,14 @@ void Boat::tick() return; } - if (waterPercentage < 1) + if (waterPercentage > 0) { double bob = waterPercentage * 2 - 1; yd += 0.04f * bob; } else { - if (yd < 0) yd /= 2; - yd += 0.007f; + yd = 0; } diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index ef5658c30..ce702676c 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -1305,42 +1305,46 @@ void LivingEntity::teleportTo(double x, double y, double z) void LivingEntity::findStandUpPosition(shared_ptr vehicle) { - AABB *boundingBox; - double fallbackX = vehicle->x; - double fallbackY = vehicle->bb->y0 + vehicle->bbHeight; - double fallbackZ = vehicle->z; - - for (double xDiff = -1.5; xDiff < 2; xDiff += 1.5) - { - for (double zDiff = -1.5; zDiff < 2; zDiff += 1.5) - { - if (xDiff == 0 && zDiff == 0) - { - continue; - } - - int xToInt = (int) (x + xDiff); - int zToInt = (int) (z + zDiff); - boundingBox = bb->cloneMove(xDiff, 1, zDiff); - - if (level->getTileCubes(boundingBox, true)->empty()) - { - if (level->isTopSolidBlocking(xToInt, (int) y, zToInt)) - { - teleportTo(x + xDiff, y + 1, z + zDiff); - return; - } - else if (level->isTopSolidBlocking(xToInt, (int) y - 1, zToInt) || level->getMaterial(xToInt, (int) y - 1, zToInt) == Material::water) - { - fallbackX = x + xDiff; - fallbackY = y + 1; - fallbackZ = z + zDiff; - } - } - } - } - - teleportTo(fallbackX, fallbackY, fallbackZ); + const double vehicleX = vehicle->x; + const double vehicleY = vehicle->bb->y0 + vehicle->bbHeight; + const double vehicleZ = vehicle->z; + double fallbackX = vehicleX; + double fallbackY = vehicleY; + double fallbackZ = vehicleZ; + const double searchY = vehicleY; + + for (double xDiff = -1.5; xDiff < 2; xDiff += 1.5) + { + for (double zDiff = -1.5; zDiff < 2; zDiff += 1.5) + { + if (xDiff == 0 && zDiff == 0) + { + continue; + } + + const int xToInt = static_cast(vehicleX + xDiff); + const int zToInt = static_cast(vehicleZ + zDiff); + AABB *boundingBox = bb->cloneMove(vehicleX + xDiff - x, searchY + 1 - y, vehicleZ + zDiff - z); + + if (level->getTileCubes(boundingBox, true)->empty()) + { + if (level->isTopSolidBlocking(xToInt, static_cast(searchY), zToInt)) + { + teleportTo(vehicleX + xDiff, searchY + 1, vehicleZ + zDiff); + return; + } + if (level->isTopSolidBlocking(xToInt, static_cast(searchY) - 1, zToInt) || + level->getMaterial(xToInt, static_cast(searchY) - 1, zToInt) == Material::water) + { + fallbackX = vehicleX + xDiff; + fallbackY = searchY + 1; + fallbackZ = vehicleZ + zDiff; + } + } + } + } + + teleportTo(fallbackX, fallbackY, fallbackZ); } bool LivingEntity::shouldShowName() From 5471f91814b5a8fe486ea6c7d22116e0cf9363f8 Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Thu, 5 Mar 2026 17:43:29 -0500 Subject: [PATCH 2/9] Replaced every C-style cast with C++ ones --- Minecraft.Client/AchievementPopup.cpp | 2 +- Minecraft.Client/ArrowRenderer.cpp | 26 +- Minecraft.Client/BatRenderer.cpp | 2 +- Minecraft.Client/BlazeRenderer.cpp | 4 +- Minecraft.Client/BoatModel.cpp | 20 +- Minecraft.Client/BoatRenderer.cpp | 2 +- Minecraft.Client/BreakingItemParticle.cpp | 6 +- Minecraft.Client/BubbleParticle.cpp | 8 +- Minecraft.Client/BufferedImage.cpp | 6 +- Minecraft.Client/ChestRenderer.cpp | 4 +- Minecraft.Client/ChickenModel.cpp | 16 +- Minecraft.Client/Chunk.cpp | 20 +- Minecraft.Client/ClientConnection.cpp | 32 +- Minecraft.Client/ClockTexture.cpp | 4 +- Minecraft.Client/Common/Audio/SoundEngine.cpp | 10 +- .../Common/Colours/ColourTable.cpp | 6 +- Minecraft.Client/Common/Consoles_App.cpp | 76 +-- Minecraft.Client/Common/Consoles_App.h | 2 +- Minecraft.Client/Common/DLC/DLCAudioFile.cpp | 12 +- Minecraft.Client/Common/DLC/DLCManager.cpp | 14 +- Minecraft.Client/Common/DLC/DLCPack.cpp | 14 +- Minecraft.Client/Common/DLC/DLCPack.h | 4 +- Minecraft.Client/Common/DLC/DLCSkinFile.cpp | 6 +- .../GameRules/AddItemRuleDefinition.cpp | 2 +- .../ApplySchematicRuleDefinition.cpp | 8 +- .../GameRules/CompleteAllRuleDefinition.cpp | 2 +- .../GameRules/ConsoleGenerateStructure.cpp | 16 +- .../GameRules/ConsoleGenerateStructure.h | 2 +- .../Common/GameRules/ConsoleSchematicFile.cpp | 28 +- .../Common/GameRules/GameRuleManager.cpp | 12 +- .../GameRules/LevelGenerationOptions.cpp | 12 +- .../Common/GameRules/LevelRuleset.cpp | 2 +- .../Common/GameRules/StartFeature.cpp | 2 +- .../GameRules/UpdatePlayerRuleDefinition.cpp | 2 +- .../XboxStructureActionPlaceContainer.cpp | 2 +- .../Leaderboards/LeaderboardInterface.cpp | 2 +- .../Common/Network/GameNetworkManager.cpp | 10 +- .../Network/PlatformNetworkManagerStub.cpp | 14 +- .../Common/Network/Sony/NetworkPlayerSony.cpp | 6 +- .../Common/Network/Sony/SQRNetworkPlayer.h | 2 +- .../Common/Network/Sony/SonyRemoteStorage.cpp | 20 +- .../Common/Telemetry/TelemetryManager.cpp | 48 +- .../Common/Tutorial/RideEntityTask.cpp | 2 +- Minecraft.Client/Common/Tutorial/StatTask.cpp | 2 +- Minecraft.Client/Common/Tutorial/Tutorial.cpp | 6 +- .../UI/IUIScene_AbstractContainerMenu.cpp | 22 +- .../Common/UI/IUIScene_CraftingMenu.cpp | 2 +- .../Common/UI/IUIScene_CreativeMenu.cpp | 10 +- .../Common/UI/IUIScene_EnchantingMenu.cpp | 2 +- Minecraft.Client/Common/UI/IUIScene_HUD.cpp | 16 +- .../Common/UI/IUIScene_PauseMenu.cpp | 4 +- .../Common/UI/IUIScene_StartGame.cpp | 8 +- Minecraft.Client/Common/UI/UIBitmapFont.cpp | 18 +- .../Common/UI/UIComponent_Chat.cpp | 14 +- .../UI/UIComponent_DebugUIMarketingGuide.cpp | 4 +- .../Common/UI/UIComponent_MenuBackground.cpp | 14 +- .../Common/UI/UIComponent_Panorama.cpp | 6 +- .../Common/UI/UIComponent_Tooltips.cpp | 22 +- .../Common/UI/UIComponent_TutorialPopup.cpp | 24 +- Minecraft.Client/Common/UI/UIControl.cpp | 16 +- Minecraft.Client/Common/UI/UIControl_Base.cpp | 2 +- .../Common/UI/UIControl_ButtonList.cpp | 2 +- .../Common/UI/UIControl_DLCList.cpp | 4 +- .../Common/UI/UIControl_DynamicLabel.cpp | 4 +- .../Common/UI/UIControl_EnchantmentBook.cpp | 4 +- .../Common/UI/UIControl_EnchantmentButton.cpp | 10 +- .../Common/UI/UIControl_HTMLLabel.cpp | 4 +- .../Common/UI/UIControl_MinecraftHorse.cpp | 10 +- .../Common/UI/UIControl_MinecraftPlayer.cpp | 10 +- .../Common/UI/UIControl_PlayerList.cpp | 2 +- .../Common/UI/UIControl_PlayerSkinPreview.cpp | 28 +- .../Common/UI/UIControl_Progress.cpp | 2 +- .../Common/UI/UIControl_SaveList.cpp | 4 +- .../Common/UI/UIControl_Slider.cpp | 2 +- .../Common/UI/UIControl_SpaceIndicatorBar.cpp | 6 +- .../Common/UI/UIControl_TexturePackList.cpp | 4 +- Minecraft.Client/Common/UI/UIController.cpp | 236 ++++---- Minecraft.Client/Common/UI/UIGroup.cpp | 18 +- Minecraft.Client/Common/UI/UIScene.cpp | 18 +- .../UI/UIScene_AbstractContainerMenu.cpp | 12 +- .../Common/UI/UIScene_AnvilMenu.cpp | 8 +- .../Common/UI/UIScene_BeaconMenu.cpp | 6 +- .../Common/UI/UIScene_BrewingStandMenu.cpp | 4 +- .../Common/UI/UIScene_ConnectingProgress.cpp | 4 +- .../Common/UI/UIScene_ContainerMenu.cpp | 4 +- .../Common/UI/UIScene_ControlsMenu.cpp | 12 +- .../Common/UI/UIScene_CraftingMenu.cpp | 18 +- .../Common/UI/UIScene_CreateWorldMenu.cpp | 26 +- .../Common/UI/UIScene_CreativeMenu.cpp | 16 +- .../Common/UI/UIScene_Credits.cpp | 6 +- .../Common/UI/UIScene_DLCMainMenu.cpp | 8 +- .../Common/UI/UIScene_DLCOffersMenu.cpp | 8 +- .../Common/UI/UIScene_DeathMenu.cpp | 8 +- .../UI/UIScene_DebugCreateSchematic.cpp | 8 +- .../Common/UI/UIScene_DebugOverlay.cpp | 18 +- .../Common/UI/UIScene_DebugSetCamera.cpp | 8 +- .../Common/UI/UIScene_DispenserMenu.cpp | 4 +- Minecraft.Client/Common/UI/UIScene_EULA.cpp | 2 +- .../Common/UI/UIScene_EnchantingMenu.cpp | 6 +- .../Common/UI/UIScene_EndPoem.cpp | 6 +- .../Common/UI/UIScene_FireworksMenu.cpp | 4 +- .../Common/UI/UIScene_FullscreenProgress.cpp | 4 +- .../Common/UI/UIScene_FurnaceMenu.cpp | 4 +- Minecraft.Client/Common/UI/UIScene_HUD.cpp | 28 +- .../Common/UI/UIScene_HelpAndOptionsMenu.cpp | 2 +- .../Common/UI/UIScene_HopperMenu.cpp | 4 +- .../Common/UI/UIScene_HorseInventoryMenu.cpp | 4 +- .../Common/UI/UIScene_HowToPlay.cpp | 12 +- .../Common/UI/UIScene_HowToPlayMenu.cpp | 4 +- .../UI/UIScene_InGameHostOptionsMenu.cpp | 2 +- .../Common/UI/UIScene_InGameInfoMenu.cpp | 14 +- .../UI/UIScene_InGamePlayerOptionsMenu.cpp | 12 +- .../UI/UIScene_InGameSaveManagementMenu.cpp | 12 +- .../Common/UI/UIScene_InventoryMenu.cpp | 6 +- .../Common/UI/UIScene_JoinMenu.cpp | 14 +- .../Common/UI/UIScene_Keyboard.cpp | 8 +- .../Common/UI/UIScene_LanguageSelector.cpp | 6 +- .../UI/UIScene_LaunchMoreOptionsMenu.cpp | 22 +- .../Common/UI/UIScene_LeaderboardsMenu.cpp | 26 +- .../Common/UI/UIScene_LoadMenu.cpp | 34 +- .../Common/UI/UIScene_LoadOrJoinMenu.cpp | 50 +- .../Common/UI/UIScene_MainMenu.cpp | 48 +- .../Common/UI/UIScene_MessageBox.cpp | 6 +- .../Common/UI/UIScene_NewUpdateMessage.cpp | 2 +- .../Common/UI/UIScene_PauseMenu.cpp | 18 +- .../Common/UI/UIScene_QuadrantSignin.cpp | 8 +- .../Common/UI/UIScene_SaveMessage.cpp | 2 +- .../Common/UI/UIScene_SettingsAudioMenu.cpp | 4 +- .../Common/UI/UIScene_SettingsControlMenu.cpp | 4 +- .../UI/UIScene_SettingsGraphicsMenu.cpp | 12 +- .../Common/UI/UIScene_SettingsMenu.cpp | 4 +- .../Common/UI/UIScene_SettingsOptionsMenu.cpp | 6 +- .../Common/UI/UIScene_SettingsUIMenu.cpp | 4 +- .../Common/UI/UIScene_SignEntryMenu.cpp | 10 +- .../Common/UI/UIScene_SkinSelectMenu.cpp | 8 +- .../Common/UI/UIScene_TeleportMenu.cpp | 10 +- .../Common/UI/UIScene_TradingMenu.cpp | 8 +- Minecraft.Client/Common/XUI/XUI_Chat.cpp | 2 +- .../Common/XUI/XUI_ConnectingProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_4JEdit.cpp | 6 +- .../Common/XUI/XUI_Ctrl_4JList.cpp | 12 +- .../Common/XUI/XUI_Ctrl_BrewProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_BubblesProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_BurnProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_EnchantButton.cpp | 10 +- .../Common/XUI/XUI_Ctrl_EnchantmentBook.cpp | 10 +- .../XUI/XUI_Ctrl_EnchantmentButtonText.cpp | 18 +- .../Common/XUI/XUI_Ctrl_FireProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp | 10 +- .../XUI/XUI_Ctrl_MinecraftSkinPreview.cpp | 28 +- .../Common/XUI/XUI_Ctrl_MinecraftSlot.cpp | 44 +- .../Common/XUI/XUI_Ctrl_SliderWrapper.cpp | 4 +- .../Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp | 28 +- .../Common/XUI/XUI_Ctrl_SlotList.cpp | 2 +- .../Common/XUI/XUI_Ctrl_SplashPulser.cpp | 8 +- .../Common/XUI/XUI_CustomMessages.h | 4 +- Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp | 20 +- Minecraft.Client/Common/XUI/XUI_Death.cpp | 4 +- .../Common/XUI/XUI_DebugItemEditor.cpp | 2 +- .../Common/XUI/XUI_DebugOverlay.cpp | 12 +- .../Common/XUI/XUI_DebugSetCamera.cpp | 10 +- Minecraft.Client/Common/XUI/XUI_DebugTips.cpp | 2 +- .../Common/XUI/XUI_FullscreenProgress.cpp | 4 +- Minecraft.Client/Common/XUI/XUI_HUD.cpp | 12 +- .../Common/XUI/XUI_HelpAndOptions.cpp | 2 +- .../Common/XUI/XUI_HelpControls.cpp | 10 +- .../Common/XUI/XUI_HelpCredits.cpp | 4 +- .../Common/XUI/XUI_HelpHowToPlay.cpp | 16 +- .../Common/XUI/XUI_HowToPlayMenu.cpp | 8 +- .../Common/XUI/XUI_InGameHostOptions.cpp | 2 +- .../Common/XUI/XUI_InGameInfo.cpp | 8 +- .../Common/XUI/XUI_InGamePlayerOptions.cpp | 10 +- .../Common/XUI/XUI_Leaderboards.cpp | 46 +- .../Common/XUI/XUI_LoadSettings.cpp | 28 +- Minecraft.Client/Common/XUI/XUI_MainMenu.cpp | 24 +- .../Common/XUI/XUI_MultiGameCreate.cpp | 24 +- .../Common/XUI/XUI_MultiGameInfo.cpp | 4 +- .../Common/XUI/XUI_MultiGameJoinLoad.cpp | 60 +-- .../XUI/XUI_MultiGameLaunchMoreOptions.cpp | 2 +- .../Common/XUI/XUI_NewUpdateMessage.cpp | 2 +- Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp | 34 +- Minecraft.Client/Common/XUI/XUI_Reinstall.cpp | 6 +- .../XUI/XUI_Scene_AbstractContainer.cpp | 2 +- .../Common/XUI/XUI_Scene_Anvil.cpp | 12 +- .../Common/XUI/XUI_Scene_Base.cpp | 42 +- .../Common/XUI/XUI_Scene_BrewingStand.cpp | 2 +- .../Common/XUI/XUI_Scene_Container.cpp | 6 +- .../Common/XUI/XUI_Scene_CraftingPanel.cpp | 22 +- .../Common/XUI/XUI_Scene_Enchant.cpp | 2 +- .../Common/XUI/XUI_Scene_Furnace.cpp | 2 +- .../Common/XUI/XUI_Scene_Inventory.cpp | 6 +- .../XUI/XUI_Scene_Inventory_Creative.cpp | 6 +- .../Common/XUI/XUI_Scene_Trading.cpp | 6 +- .../Common/XUI/XUI_Scene_Trap.cpp | 2 +- Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp | 6 +- .../Common/XUI/XUI_SettingsAll.cpp | 2 +- .../Common/XUI/XUI_SettingsAudio.cpp | 6 +- .../Common/XUI/XUI_SettingsControl.cpp | 6 +- .../Common/XUI/XUI_SettingsGraphics.cpp | 6 +- .../Common/XUI/XUI_SettingsOptions.cpp | 6 +- .../Common/XUI/XUI_SettingsUI.cpp | 6 +- Minecraft.Client/Common/XUI/XUI_SignEntry.cpp | 2 +- .../Common/XUI/XUI_SkinSelect.cpp | 6 +- .../Common/XUI/XUI_SocialPost.cpp | 6 +- Minecraft.Client/Common/XUI/XUI_Teleport.cpp | 4 +- Minecraft.Client/Common/XUI/XUI_TextEntry.cpp | 2 +- .../Common/XUI/XUI_TransferToXboxOne.cpp | 18 +- .../Common/XUI/XUI_TrialExitUpsell.cpp | 2 +- .../Common/XUI/XUI_TutorialPopup.cpp | 28 +- Minecraft.Client/Common/XUI/XUI_debug.cpp | 10 +- Minecraft.Client/CompassTexture.cpp | 6 +- Minecraft.Client/CreeperRenderer.cpp | 4 +- Minecraft.Client/CritParticle2.cpp | 4 +- Minecraft.Client/DLCTexturePack.cpp | 16 +- Minecraft.Client/DragonBreathParticle.cpp | 4 +- Minecraft.Client/DragonModel.cpp | 8 +- Minecraft.Client/DripParticle.cpp | 2 +- Minecraft.Client/Durango/ApplicationView.cpp | 6 +- .../Durango/DurangoExtras/DurangoStubs.cpp | 2 +- Minecraft.Client/Durango/Durango_App.cpp | 26 +- Minecraft.Client/Durango/Durango_App.h | 2 +- .../Durango/Durango_Minecraft.cpp | 12 +- .../Durango/Durango_UIController.cpp | 2 +- .../Durango/Iggy/gdraw/gdraw_shared.inl | 10 +- .../DurangoLeaderboardManager.cpp | 10 +- .../Durango/Leaderboards/GameProgress.cpp | 2 +- .../Durango/Network/ChatIntegrationLayer.h | 2 +- .../Durango/Network/DQRNetworkManager.cpp | 32 +- .../DQRNetworkManager_FriendSessions.cpp | 8 +- .../Network/DQRNetworkManager_SendReceive.cpp | 8 +- .../Network/DQRNetworkManager_XRNSEvent.cpp | 8 +- .../Durango/Network/DQRNetworkPlayer.cpp | 2 +- .../Durango/Network/NetworkPlayerDurango.cpp | 4 +- .../Durango/Network/PartyController.cpp | 10 +- .../Network/PlatformNetworkManagerDurango.cpp | 6 +- Minecraft.Client/Durango/Network/base64.cpp | 6 +- .../Durango/Sentient/DurangoTelemetry.cpp | 2 +- Minecraft.Client/Durango/XML/ATGXmlParser.cpp | 36 +- Minecraft.Client/EchantmentTableParticle.cpp | 12 +- Minecraft.Client/EnchantTableRenderer.cpp | 2 +- Minecraft.Client/EnderChestRenderer.cpp | 2 +- Minecraft.Client/EnderCrystalRenderer.cpp | 2 +- Minecraft.Client/EnderDragonRenderer.cpp | 12 +- Minecraft.Client/EnderParticle.cpp | 14 +- Minecraft.Client/EndermanRenderer.cpp | 2 +- Minecraft.Client/EntityRenderDispatcher.cpp | 2 +- Minecraft.Client/EntityRenderer.cpp | 124 ++--- Minecraft.Client/ExperienceOrbRenderer.cpp | 8 +- Minecraft.Client/ExplodeParticle.cpp | 14 +- Minecraft.Client/Extrax64Stubs.cpp | 6 +- Minecraft.Client/FallingTileRenderer.cpp | 4 +- Minecraft.Client/FireballRenderer.cpp | 22 +- Minecraft.Client/FireworksParticles.cpp | 32 +- Minecraft.Client/FishingHookRenderer.cpp | 20 +- Minecraft.Client/FlameParticle.cpp | 6 +- Minecraft.Client/Font.cpp | 6 +- Minecraft.Client/FootstepParticle.cpp | 14 +- Minecraft.Client/GameRenderer.cpp | 80 +-- Minecraft.Client/GhastModel.cpp | 2 +- Minecraft.Client/Gui.cpp | 70 +-- Minecraft.Client/Gui.h | 2 +- Minecraft.Client/GuiComponent.cpp | 26 +- Minecraft.Client/GuiParticle.cpp | 4 +- Minecraft.Client/HugeExplosionParticle.cpp | 10 +- .../HugeExplosionSeedParticle.cpp | 2 +- Minecraft.Client/HumanoidMobRenderer.cpp | 6 +- Minecraft.Client/HumanoidModel.cpp | 4 +- Minecraft.Client/Input.cpp | 6 +- Minecraft.Client/InventoryScreen.cpp | 4 +- Minecraft.Client/ItemFrameRenderer.cpp | 10 +- Minecraft.Client/ItemInHandRenderer.cpp | 18 +- Minecraft.Client/ItemRenderer.cpp | 48 +- Minecraft.Client/ItemSpriteRenderer.cpp | 10 +- Minecraft.Client/JoinMultiplayerScreen.cpp | 2 +- Minecraft.Client/LavaParticle.cpp | 6 +- Minecraft.Client/LavaSlimeModel.cpp | 2 +- Minecraft.Client/LavaSlimeRenderer.cpp | 2 +- Minecraft.Client/LeashKnotRenderer.cpp | 2 +- Minecraft.Client/LevelRenderer.cpp | 228 ++++---- Minecraft.Client/Lighting.cpp | 2 +- Minecraft.Client/LightningBoltRenderer.cpp | 4 +- Minecraft.Client/LivingEntityRenderer.cpp | 32 +- Minecraft.Client/LocalPlayer.cpp | 46 +- Minecraft.Client/MinecartModel.cpp | 24 +- Minecraft.Client/MinecartRenderer.cpp | 6 +- Minecraft.Client/Minecraft.cpp | 64 +-- Minecraft.Client/MinecraftServer.cpp | 16 +- Minecraft.Client/Minimap.cpp | 24 +- Minecraft.Client/MobRenderer.cpp | 18 +- Minecraft.Client/MobSpawnerRenderer.cpp | 4 +- Minecraft.Client/Model.h | 2 +- Minecraft.Client/ModelPart.cpp | 6 +- Minecraft.Client/MultiPlayerChunkCache.cpp | 8 +- Minecraft.Client/MultiPlayerGameMode.cpp | 10 +- Minecraft.Client/MultiPlayerLevel.cpp | 4 +- Minecraft.Client/MultiPlayerLocalPlayer.cpp | 12 +- Minecraft.Client/MushroomCowRenderer.cpp | 2 +- Minecraft.Client/NetherPortalParticle.cpp | 14 +- Minecraft.Client/NoteParticle.cpp | 4 +- Minecraft.Client/OffsettedRenderList.cpp | 6 +- Minecraft.Client/Options.cpp | 4 +- Minecraft.Client/OptionsScreen.cpp | 2 +- .../Orbis/Iggy/gdraw/gdraw_shared.inl | 10 +- .../Orbis/Network/SonyHttp_Orbis.cpp | 8 +- .../Orbis/Network/SonyRemoteStorage_Orbis.cpp | 2 +- .../PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl | 116 ++-- .../PS3/Iggy/gdraw/gdraw_shared.inl | 10 +- Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp | 6 +- .../PS3/Network/SonyRemoteStorage_PS3.cpp | 10 +- Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp | 2 +- .../ChunkUpdate/ChunkRebuildData.cpp | 126 ++--- .../PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h | 20 +- .../SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp | 4 +- .../SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp | 42 +- .../ChunkUpdate/TileRenderer_SPU.cpp | 286 +++++----- .../PSVita/Iggy/gdraw/gdraw_shared.inl | 10 +- .../PSVita/Network/SonyHttp_Vita.cpp | 6 +- .../PSVita/Network/SonyRemoteStorage_Vita.cpp | 4 +- .../PSVita/PSVitaExtras/CustomMap.cpp | 8 +- .../PSVita/PSVitaExtras/CustomSet.cpp | 8 +- .../PSVita/PSVitaExtras/libdivide.h | 56 +- Minecraft.Client/PaintingRenderer.cpp | 2 +- Minecraft.Client/Particle.cpp | 16 +- Minecraft.Client/PauseScreen.cpp | 2 +- Minecraft.Client/PistonPieceRenderer.cpp | 6 +- Minecraft.Client/PlayerChunkMap.cpp | 28 +- Minecraft.Client/PlayerCloudParticle.cpp | 4 +- Minecraft.Client/PlayerConnection.cpp | 20 +- Minecraft.Client/PlayerList.cpp | 30 +- Minecraft.Client/PlayerRenderer.cpp | 18 +- Minecraft.Client/Polygon.cpp | 6 +- Minecraft.Client/PreStitchedTextureMap.cpp | 2 +- Minecraft.Client/QuadrupedModel.cpp | 12 +- Minecraft.Client/RedDustParticle.cpp | 12 +- Minecraft.Client/RemotePlayer.cpp | 6 +- Minecraft.Client/ResourceLocation.h | 2 +- Minecraft.Client/Screen.cpp | 6 +- Minecraft.Client/ScreenSizeCalculator.cpp | 8 +- Minecraft.Client/ScrolledSelectionList.cpp | 4 +- Minecraft.Client/SelectWorldScreen.cpp | 4 +- Minecraft.Client/ServerChunkCache.cpp | 2 +- Minecraft.Client/ServerLevel.cpp | 14 +- Minecraft.Client/ServerLevelListener.cpp | 6 +- Minecraft.Client/ServerPlayer.cpp | 4 +- Minecraft.Client/ServerPlayerGameMode.cpp | 6 +- Minecraft.Client/Settings.cpp | 6 +- Minecraft.Client/SheepRenderer.cpp | 2 +- Minecraft.Client/SignRenderer.cpp | 4 +- Minecraft.Client/SilverfishModel.cpp | 6 +- Minecraft.Client/SkullTileRenderer.cpp | 2 +- Minecraft.Client/SlideButton.cpp | 8 +- Minecraft.Client/SlimeRenderer.cpp | 2 +- Minecraft.Client/SmokeParticle.cpp | 4 +- Minecraft.Client/SnowManRenderer.cpp | 2 +- Minecraft.Client/SnowShovelParticle.cpp | 6 +- Minecraft.Client/SpellParticle.cpp | 2 +- Minecraft.Client/SpiderModel.cpp | 22 +- Minecraft.Client/SquidModel.cpp | 12 +- Minecraft.Client/StatsCounter.cpp | 4 +- Minecraft.Client/StatsScreen.cpp | 4 +- Minecraft.Client/StitchedTexture.cpp | 16 +- Minecraft.Client/SuspendedParticle.cpp | 2 +- Minecraft.Client/SuspendedTownParticle.cpp | 2 +- Minecraft.Client/TakeAnimationParticle.cpp | 2 +- Minecraft.Client/TerrainParticle.cpp | 6 +- Minecraft.Client/Tesselator.cpp | 32 +- Minecraft.Client/TextEditScreen.cpp | 2 +- Minecraft.Client/Texture.cpp | 44 +- Minecraft.Client/TextureHolder.cpp | 6 +- Minecraft.Client/Textures.cpp | 28 +- Minecraft.Client/TheEndPortalRenderer.cpp | 10 +- Minecraft.Client/TileRenderer.cpp | 504 +++++++++--------- Minecraft.Client/Timer.cpp | 22 +- Minecraft.Client/TntRenderer.cpp | 2 +- Minecraft.Client/TrackedEntity.cpp | 36 +- Minecraft.Client/VideoSettingsScreen.cpp | 2 +- Minecraft.Client/VillagerGolemRenderer.cpp | 2 +- Minecraft.Client/VillagerRenderer.cpp | 2 +- Minecraft.Client/WaterDropParticle.cpp | 4 +- .../Iggy/gdraw/gdraw_d3d1x_shared.inl | 66 +-- .../Windows64/Iggy/gdraw/gdraw_shared.inl | 10 +- .../Windows64/KeyboardMouseInput.cpp | 8 +- .../Windows64/Network/WinsockNetLayer.cpp | 44 +- Minecraft.Client/Windows64/Windows64_App.cpp | 2 +- Minecraft.Client/Windows64/Windows64_App.h | 2 +- .../Windows64/Windows64_Minecraft.cpp | 22 +- .../Windows64/Windows64_UIController.cpp | 2 +- Minecraft.Client/WitherBossRenderer.cpp | 2 +- Minecraft.Client/WitherSkullRenderer.cpp | 2 +- Minecraft.Client/Xbox/Audio/SoundEngine.cpp | 18 +- Minecraft.Client/Xbox/Font/XUI_Font.cpp | 22 +- Minecraft.Client/Xbox/Font/XUI_FontData.cpp | 4 +- .../Xbox/Font/XUI_FontRenderer.cpp | 18 +- .../Leaderboards/XboxLeaderboardManager.cpp | 10 +- .../Xbox/Network/NetworkPlayerXbox.cpp | 10 +- .../Network/PlatformNetworkManagerXbox.cpp | 18 +- .../Xbox/Sentient/DynamicConfigurations.cpp | 2 +- .../Xbox/Sentient/Include/SenClientResource.h | 10 +- .../Xbox/Sentient/SentientManager.cpp | 56 +- Minecraft.Client/Xbox/XML/ATGXmlParser.cpp | 36 +- Minecraft.Client/Xbox/Xbox_App.h | 2 +- Minecraft.Client/ZombieRenderer.cpp | 4 +- Minecraft.Client/glWrapper.cpp | 2 +- Minecraft.World/AABB.cpp | 4 +- Minecraft.World/AbstractContainerMenu.cpp | 6 +- Minecraft.World/AbstractContainerMenu.h | 2 +- Minecraft.World/AddEntityPacket.cpp | 6 +- Minecraft.World/AddMobPacket.cpp | 8 +- Minecraft.World/AddPlayerPacket.cpp | 2 +- Minecraft.World/Animal.cpp | 2 +- Minecraft.World/ArmorDyeRecipe.cpp | 22 +- Minecraft.World/Arrow.cpp | 56 +- Minecraft.World/AttributeModifier.cpp | 2 +- Minecraft.World/BaseMobSpawner.cpp | 20 +- Minecraft.World/BaseRailTile.cpp | 2 +- Minecraft.World/BasicTree.cpp | 36 +- Minecraft.World/Bat.cpp | 18 +- Minecraft.World/BeachBiome.cpp | 4 +- Minecraft.World/BeaconTileEntity.cpp | 6 +- Minecraft.World/BedItem.cpp | 2 +- Minecraft.World/Biome.cpp | 8 +- Minecraft.World/BiomeCache.cpp | 4 +- Minecraft.World/BiomeSource.cpp | 8 +- Minecraft.World/Blaze.cpp | 8 +- Minecraft.World/BlockReplacements.cpp | 2 +- Minecraft.World/Boat.cpp | 8 +- Minecraft.World/BottleItem.cpp | 4 +- Minecraft.World/BowItem.cpp | 4 +- Minecraft.World/BreakDoorGoal.cpp | 2 +- Minecraft.World/BrewingStandTile.cpp | 8 +- Minecraft.World/BrewingStandTileEntity.cpp | 4 +- Minecraft.World/BufferedOutputStream.cpp | 2 +- Minecraft.World/ButtonTile.cpp | 2 +- Minecraft.World/ByteArrayOutputStream.cpp | 2 +- Minecraft.World/ByteArrayTag.h | 2 +- Minecraft.World/ByteTag.h | 2 +- Minecraft.World/C4JThread.cpp | 4 +- Minecraft.World/CanyonFeature.cpp | 6 +- Minecraft.World/CaveFeature.cpp | 6 +- Minecraft.World/ChatPacket.cpp | 2 +- Minecraft.World/ChestTile.cpp | 8 +- Minecraft.World/ChestTileEntity.cpp | 6 +- Minecraft.World/ChunkPos.cpp | 4 +- .../ChunkStorageProfileDecorator.cpp | 4 +- Minecraft.World/ChunkTilesUpdatePacket.cpp | 4 +- Minecraft.World/Color.cpp | 42 +- Minecraft.World/CompoundTag.h | 28 +- Minecraft.World/CompressedTileStorage.cpp | 20 +- Minecraft.World/Connection.cpp | 12 +- Minecraft.World/ConsoleSaveFileOriginal.cpp | 46 +- .../ConsoleSaveFileOutputStream.cpp | 2 +- Minecraft.World/ContainerMenu.cpp | 2 +- Minecraft.World/ContainerSetContentPacket.cpp | 2 +- Minecraft.World/ControlledByPlayerGoal.cpp | 4 +- Minecraft.World/Creeper.cpp | 18 +- Minecraft.World/CropTile.cpp | 2 +- Minecraft.World/CustomLevelSource.cpp | 20 +- Minecraft.World/CustomPayloadPacket.cpp | 2 +- Minecraft.World/DataInputStream.cpp | 18 +- Minecraft.World/DataLayer.cpp | 6 +- Minecraft.World/DataOutputStream.cpp | 22 +- Minecraft.World/DaylightDetectorTile.cpp | 2 +- .../DaylightDetectorTileEntity.cpp | 2 +- Minecraft.World/DebugOptionsPacket.cpp | 4 +- Minecraft.World/DesertBiome.cpp | 4 +- Minecraft.World/Dimension.cpp | 8 +- Minecraft.World/Direction.cpp | 2 +- Minecraft.World/DirectoryLevelStorage.cpp | 4 +- Minecraft.World/DisconnectPacket.cpp | 2 +- Minecraft.World/DispenserTile.cpp | 8 +- Minecraft.World/DispenserTileEntity.cpp | 2 +- Minecraft.World/DoorInfo.cpp | 2 +- Minecraft.World/DoorInteractGoal.cpp | 10 +- Minecraft.World/DoubleTag.h | 2 +- Minecraft.World/DragonFireball.cpp | 2 +- Minecraft.World/DungeonFeature.cpp | 6 +- Minecraft.World/DurangoStats.cpp | 12 +- Minecraft.World/DurangoStats.h | 2 +- Minecraft.World/DyePowderItem.cpp | 10 +- Minecraft.World/EnchantedBookItem.cpp | 8 +- Minecraft.World/EnchantmentCategory.cpp | 2 +- Minecraft.World/EnchantmentHelper.cpp | 10 +- Minecraft.World/EnchantmentInstance.cpp | 2 +- Minecraft.World/EnchantmentTableEntity.cpp | 2 +- Minecraft.World/EnderDragon.cpp | 26 +- Minecraft.World/EnderEyeItem.cpp | 2 +- Minecraft.World/EnderMan.cpp | 18 +- Minecraft.World/Entity.cpp | 24 +- Minecraft.World/EntityHorse.cpp | 20 +- Minecraft.World/ExperienceOrb.cpp | 16 +- Minecraft.World/ExplodePacket.cpp | 28 +- Minecraft.World/Explosion.cpp | 4 +- Minecraft.World/EyeOfEnderSignal.cpp | 18 +- Minecraft.World/FallingTile.cpp | 6 +- Minecraft.World/FastNoise.cpp | 12 +- Minecraft.World/File.cpp | 2 +- Minecraft.World/FileHeader.cpp | 12 +- Minecraft.World/FileOutputStream.cpp | 2 +- Minecraft.World/Fireball.cpp | 16 +- Minecraft.World/FireworksChargeItem.cpp | 2 +- Minecraft.World/FireworksRecipe.cpp | 12 +- Minecraft.World/FireworksRocketEntity.cpp | 8 +- Minecraft.World/FishingHook.cpp | 28 +- Minecraft.World/FlatLevelSource.cpp | 4 +- Minecraft.World/FleeSunGoal.cpp | 2 +- Minecraft.World/FlippedIcon.cpp | 4 +- Minecraft.World/FloatTag.h | 2 +- Minecraft.World/FlyingMob.cpp | 2 +- Minecraft.World/FoodConstants.cpp | 4 +- Minecraft.World/FoodItem.h | 2 +- Minecraft.World/FurnaceResultSlot.cpp | 4 +- Minecraft.World/FurnaceTile.cpp | 8 +- Minecraft.World/FurnaceTileEntity.cpp | 12 +- Minecraft.World/GameCommandPacket.cpp | 4 +- Minecraft.World/Ghast.cpp | 12 +- Minecraft.World/HangingEntity.cpp | 12 +- Minecraft.World/HellDimension.cpp | 10 +- Minecraft.World/HellFlatLevelSource.cpp | 18 +- Minecraft.World/HellRandomLevelSource.cpp | 44 +- Minecraft.World/HopperTile.cpp | 8 +- Minecraft.World/HopperTileEntity.cpp | 6 +- Minecraft.World/ImprovedNoise.cpp | 16 +- Minecraft.World/InputStreamReader.cpp | 2 +- Minecraft.World/IntArrayTag.h | 2 +- Minecraft.World/IntCache.cpp | 8 +- Minecraft.World/IntTag.h | 2 +- Minecraft.World/Inventory.cpp | 8 +- Minecraft.World/Item.cpp | 64 +-- Minecraft.World/ItemDispenseBehaviors.cpp | 2 +- Minecraft.World/ItemEntity.cpp | 14 +- Minecraft.World/ItemFrame.cpp | 6 +- Minecraft.World/ItemInstance.cpp | 26 +- Minecraft.World/JavaIntHash.h | 4 +- Minecraft.World/JavaMath.cpp | 2 +- Minecraft.World/LargeCaveFeature.cpp | 4 +- Minecraft.World/LargeHellCaveFeature.cpp | 2 +- Minecraft.World/Layer.cpp | 2 +- Minecraft.World/Level.cpp | 42 +- Minecraft.World/LevelChunk.cpp | 20 +- Minecraft.World/LevelData.cpp | 2 +- Minecraft.World/LevelSoundPacket.cpp | 6 +- Minecraft.World/LightningBolt.cpp | 8 +- Minecraft.World/LiquidTile.cpp | 2 +- Minecraft.World/ListTag.h | 10 +- Minecraft.World/LivingEntity.cpp | 80 +-- Minecraft.World/LoginPacket.cpp | 4 +- Minecraft.World/LongTag.h | 2 +- Minecraft.World/LookAtTradingPlayerGoal.cpp | 2 +- Minecraft.World/LookControl.cpp | 4 +- Minecraft.World/MakeLoveGoal.cpp | 2 +- Minecraft.World/MapItem.cpp | 16 +- Minecraft.World/MapItemSavedData.cpp | 74 +-- .../McRegionLevelStorageSource.cpp | 2 +- Minecraft.World/MegaTreeFeature.cpp | 8 +- Minecraft.World/MenuBackup.cpp | 2 +- Minecraft.World/MerchantRecipeList.cpp | 2 +- Minecraft.World/MilkBucketItem.h | 2 +- Minecraft.World/Minecart.cpp | 18 +- Minecraft.World/MinecartContainer.cpp | 16 +- Minecraft.World/MinecartFurnace.cpp | 8 +- Minecraft.World/MinecartItem.cpp | 2 +- Minecraft.World/MinecartSpawner.cpp | 2 +- Minecraft.World/MinecartTNT.cpp | 2 +- Minecraft.World/Mob.cpp | 18 +- Minecraft.World/MobEffect.cpp | 4 +- Minecraft.World/MobEffectInstance.cpp | 4 +- Minecraft.World/MobSpawner.cpp | 4 +- Minecraft.World/Monster.cpp | 2 +- Minecraft.World/MoveControl.cpp | 4 +- Minecraft.World/MoveEntityPacket.cpp | 2 +- Minecraft.World/MoveEntityPacketSmall.cpp | 4 +- Minecraft.World/Mth.cpp | 18 +- Minecraft.World/MushroomIslandBiome.cpp | 2 +- Minecraft.World/MusicTileEntity.cpp | 2 +- Minecraft.World/NbtIo.cpp | 2 +- Minecraft.World/NetherBridgeFeature.cpp | 2 +- Minecraft.World/NetherBridgePieces.cpp | 68 +-- Minecraft.World/Node.cpp | 6 +- Minecraft.World/NoteBlockTile.cpp | 2 +- Minecraft.World/Ocelot.cpp | 6 +- Minecraft.World/OcelotSitOnTileGoal.cpp | 10 +- Minecraft.World/OldChunkStorage.cpp | 8 +- Minecraft.World/Packet.cpp | 6 +- Minecraft.World/Painting.cpp | 2 +- Minecraft.World/Path.cpp | 8 +- Minecraft.World/PathFinder.cpp | 8 +- Minecraft.World/PathNavigation.cpp | 24 +- Minecraft.World/PathfinderMob.cpp | 8 +- Minecraft.World/PerformanceTimer.cpp | 4 +- Minecraft.World/PerlinSimplexNoise.cpp | 2 +- Minecraft.World/Pig.cpp | 6 +- Minecraft.World/PigZombie.cpp | 2 +- Minecraft.World/PistonBaseTile.cpp | 4 +- Minecraft.World/PistonMovingPiece.cpp | 2 +- Minecraft.World/Player.cpp | 42 +- Minecraft.World/PlayerEnderChestContainer.cpp | 2 +- Minecraft.World/Pos.cpp | 4 +- Minecraft.World/PotionBrewing.cpp | 20 +- Minecraft.World/PotionItem.h | 2 +- Minecraft.World/PreLoginPacket.cpp | 4 +- Minecraft.World/PrimedTnt.cpp | 4 +- Minecraft.World/Random.cpp | 14 +- Minecraft.World/RandomLevelSource.cpp | 26 +- Minecraft.World/Recipes.cpp | 12 +- Minecraft.World/RecordingItem.cpp | 2 +- Minecraft.World/Region.cpp | 6 +- Minecraft.World/RegionFile.cpp | 8 +- Minecraft.World/RemoveMobEffectPacket.cpp | 2 +- Minecraft.World/RespawnPacket.cpp | 2 +- Minecraft.World/SetEntityMotionPacket.cpp | 12 +- Minecraft.World/SetHealthPacket.cpp | 2 +- Minecraft.World/ShapedRecipy.cpp | 2 +- Minecraft.World/ShapelessRecipy.cpp | 2 +- Minecraft.World/SharedMonsterAttributes.cpp | 2 +- Minecraft.World/Sheep.cpp | 16 +- Minecraft.World/ShortTag.h | 2 +- Minecraft.World/SignTileEntity.cpp | 4 +- Minecraft.World/SignUpdatePacket.cpp | 2 +- Minecraft.World/SimplexNoise.cpp | 2 +- Minecraft.World/Skeleton.cpp | 10 +- Minecraft.World/SkullItem.cpp | 2 +- Minecraft.World/SkullTileEntity.cpp | 4 +- Minecraft.World/Slime.cpp | 6 +- Minecraft.World/Socket.cpp | 4 +- Minecraft.World/SparseDataStorage.cpp | 30 +- Minecraft.World/SparseLightStorage.cpp | 32 +- Minecraft.World/Spider.cpp | 8 +- Minecraft.World/Squid.cpp | 4 +- Minecraft.World/Stats.cpp | 14 +- Minecraft.World/StemTile.cpp | 6 +- Minecraft.World/StringHelpers.cpp | 10 +- Minecraft.World/StringTag.h | 2 +- Minecraft.World/StrongholdFeature.cpp | 12 +- Minecraft.World/StrongholdPieces.cpp | 62 +-- Minecraft.World/StructurePiece.cpp | 8 +- Minecraft.World/StructureRecipies.cpp | 2 +- Minecraft.World/SynchedEntityData.cpp | 2 +- Minecraft.World/TakeFlowerGoal.cpp | 2 +- Minecraft.World/TamableAnimal.cpp | 10 +- Minecraft.World/TeleportEntityPacket.cpp | 4 +- .../TextureAndGeometryChangePacket.cpp | 2 +- Minecraft.World/TextureAndGeometryPacket.cpp | 16 +- Minecraft.World/TextureChangePacket.cpp | 4 +- Minecraft.World/TexturePacket.cpp | 4 +- Minecraft.World/TheEndBiome.cpp | 4 +- .../TheEndLevelRandomLevelSource.cpp | 12 +- Minecraft.World/Throwable.cpp | 30 +- Minecraft.World/ThrownExpBottle.cpp | 2 +- Minecraft.World/ThrownPotion.cpp | 4 +- Minecraft.World/Tile.cpp | 102 ++-- Minecraft.World/TileEntityDataPacket.cpp | 2 +- Minecraft.World/TileUpdatePacket.cpp | 2 +- Minecraft.World/ToolRecipies.cpp | 2 +- Minecraft.World/TopSnowTile.cpp | 2 +- Minecraft.World/TripWireTile.cpp | 2 +- .../UpdateGameRuleProgressPacket.cpp | 4 +- Minecraft.World/UpdateMobEffectPacket.cpp | 6 +- Minecraft.World/UseItemPacket.cpp | 6 +- Minecraft.World/Vec3.cpp | 4 +- Minecraft.World/VillageFeature.cpp | 4 +- Minecraft.World/VillagePieces.cpp | 28 +- Minecraft.World/VillageSiege.cpp | 6 +- Minecraft.World/Villager.cpp | 2 +- Minecraft.World/VillagerGolem.cpp | 8 +- Minecraft.World/Villages.cpp | 4 +- Minecraft.World/WaterLilyTile.cpp | 2 +- Minecraft.World/WeighedTreasure.cpp | 4 +- Minecraft.World/WeightedPressurePlateTile.cpp | 2 +- Minecraft.World/Witch.cpp | 4 +- Minecraft.World/WitherBoss.cpp | 12 +- Minecraft.World/WitherSkull.cpp | 4 +- Minecraft.World/Wolf.cpp | 22 +- Minecraft.World/WoolCarpetTile.cpp | 2 +- Minecraft.World/Zombie.cpp | 32 +- Minecraft.World/ZoneIo.cpp | 4 +- Minecraft.World/compression.cpp | 44 +- Minecraft.World/system.cpp | 2 +- 677 files changed, 4318 insertions(+), 4318 deletions(-) diff --git a/Minecraft.Client/AchievementPopup.cpp b/Minecraft.Client/AchievementPopup.cpp index 04f822aba..c10ebde32 100644 --- a/Minecraft.Client/AchievementPopup.cpp +++ b/Minecraft.Client/AchievementPopup.cpp @@ -59,7 +59,7 @@ void AchievementPopup::prepareWindow() glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0, (float)width, (float)height, 0, 1000, 3000); + glOrtho(0, static_cast(width), static_cast(height), 0, 1000, 3000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -2000); diff --git a/Minecraft.Client/ArrowRenderer.cpp b/Minecraft.Client/ArrowRenderer.cpp index 4698cd6e3..a7dd6efdd 100644 --- a/Minecraft.Client/ArrowRenderer.cpp +++ b/Minecraft.Client/ArrowRenderer.cpp @@ -23,7 +23,7 @@ void ArrowRenderer::render(shared_ptr _arrow, double x, double y, double if( ( xRot - xRotO ) > 180.0f ) xRot -= 360.0f; else if( ( xRot - xRotO ) < -180.0f ) xRot += 360.0f; - glTranslatef((float)x, (float)y, (float)z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); glRotatef(yRotO + (yRot - yRotO) * a - 90, 0, 1, 0); glRotatef(xRotO + (xRot - xRotO) * a, 0, 0, 1); @@ -55,19 +55,19 @@ void ArrowRenderer::render(shared_ptr _arrow, double x, double y, double // glNormal3f(ss, 0, 0); // 4J - changed to use tesselator t->begin(); t->normal(1,0,0); - t->vertexUV((float)(-7), (float)( -2), (float)( -2), (float)( u02), (float)( v02)); - t->vertexUV((float)(-7), (float)( -2), (float)( +2), (float)( u12), (float)( v02)); - t->vertexUV((float)(-7), (float)( +2), (float)( +2), (float)( u12), (float)( v12)); - t->vertexUV((float)(-7), (float)( +2), (float)( -2), (float)( u02), (float)( v12)); + t->vertexUV(static_cast(-7), static_cast(-2), static_cast(-2), (float)( u02), (float)( v02)); + t->vertexUV(static_cast(-7), static_cast(-2), static_cast(+2), (float)( u12), (float)( v02)); + t->vertexUV(static_cast(-7), static_cast(+2), static_cast(+2), (float)( u12), (float)( v12)); + t->vertexUV(static_cast(-7), static_cast(+2), static_cast(-2), (float)( u02), (float)( v12)); t->end(); // glNormal3f(-ss, 0, 0); // 4J - changed to use tesselator t->begin(); t->normal(-1,0,0); - t->vertexUV((float)(-7), (float)( +2), (float)( -2), (float)( u02), (float)( v02)); - t->vertexUV((float)(-7), (float)( +2), (float)( +2), (float)( u12), (float)( v02)); - t->vertexUV((float)(-7), (float)( -2), (float)( +2), (float)( u12), (float)( v12)); - t->vertexUV((float)(-7), (float)( -2), (float)( -2), (float)( u02), (float)( v12)); + t->vertexUV(static_cast(-7), static_cast(+2), static_cast(-2), (float)( u02), (float)( v02)); + t->vertexUV(static_cast(-7), static_cast(+2), static_cast(+2), (float)( u12), (float)( v02)); + t->vertexUV(static_cast(-7), static_cast(-2), static_cast(+2), (float)( u12), (float)( v12)); + t->vertexUV(static_cast(-7), static_cast(-2), static_cast(-2), (float)( u02), (float)( v12)); t->end(); for (int i = 0; i < 4; i++) @@ -77,10 +77,10 @@ void ArrowRenderer::render(shared_ptr _arrow, double x, double y, double // glNormal3f(0, 0, ss); // 4J - changed to use tesselator t->begin(); t->normal(0,0,1); - t->vertexUV((float)(-8), (float)( -2), (float)( 0), (float)( u0), (float)( v0)); - t->vertexUV((float)(+8), (float)( -2), (float)( 0), (float)( u1), (float)( v0)); - t->vertexUV((float)(+8), (float)( +2), (float)( 0), (float)( u1), (float)( v1)); - t->vertexUV((float)(-8), (float)( +2), (float)( 0), (float)( u0), (float)( v1)); + t->vertexUV(static_cast(-8), static_cast(-2), static_cast(0), (float)( u0), (float)( v0)); + t->vertexUV(static_cast(+8), static_cast(-2), static_cast(0), (float)( u1), (float)( v0)); + t->vertexUV(static_cast(+8), static_cast(+2), static_cast(0), (float)( u1), (float)( v1)); + t->vertexUV(static_cast(-8), static_cast(+2), static_cast(0), (float)( u0), (float)( v1)); t->end(); } glDisable(GL_RESCALE_NORMAL); diff --git a/Minecraft.Client/BatRenderer.cpp b/Minecraft.Client/BatRenderer.cpp index 629fe014a..97c6412d7 100644 --- a/Minecraft.Client/BatRenderer.cpp +++ b/Minecraft.Client/BatRenderer.cpp @@ -7,7 +7,7 @@ ResourceLocation BatRenderer::BAT_LOCATION = ResourceLocation(TN_MOB_BAT); BatRenderer::BatRenderer() : MobRenderer(new BatModel(), 0.25f) { - modelVersion = ((BatModel *)model)->modelVersion(); + modelVersion = static_cast(model)->modelVersion(); } void BatRenderer::render(shared_ptr _mob, double x, double y, double z, float rot, float a) diff --git a/Minecraft.Client/BlazeRenderer.cpp b/Minecraft.Client/BlazeRenderer.cpp index 8e0da036b..f8426a2f3 100644 --- a/Minecraft.Client/BlazeRenderer.cpp +++ b/Minecraft.Client/BlazeRenderer.cpp @@ -7,7 +7,7 @@ ResourceLocation BlazeRenderer::BLAZE_LOCATION = ResourceLocation(TN_MOB_BLAZE); BlazeRenderer::BlazeRenderer() : MobRenderer(new BlazeModel(), 0.5f) { - modelVersion = ((BlazeModel *) model)->modelVersion(); + modelVersion = static_cast(model)->modelVersion(); } void BlazeRenderer::render(shared_ptr _mob, double x, double y, double z, float rot, float a) @@ -16,7 +16,7 @@ void BlazeRenderer::render(shared_ptr _mob, double x, double y, double z // do some casting around instead shared_ptr mob = dynamic_pointer_cast(_mob); - int modelVersion = ((BlazeModel *) model)->modelVersion(); + int modelVersion = static_cast(model)->modelVersion(); if (modelVersion != this->modelVersion) { this->modelVersion = modelVersion; diff --git a/Minecraft.Client/BoatModel.cpp b/Minecraft.Client/BoatModel.cpp index d0d465e52..5a55e7e84 100644 --- a/Minecraft.Client/BoatModel.cpp +++ b/Minecraft.Client/BoatModel.cpp @@ -14,20 +14,20 @@ BoatModel::BoatModel() : Model() int h = 20; int yOff = 4; - cubes[0]->addBox((float)(-w / 2), (float)(-h / 2 + 2), -3, w, h - 4, 4, 0); - cubes[0]->setPos(0, (float)(0 + yOff), 0); + cubes[0]->addBox(static_cast(-w / 2), static_cast(-h / 2 + 2), -3, w, h - 4, 4, 0); + cubes[0]->setPos(0, static_cast(0 + yOff), 0); - cubes[1]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); - cubes[1]->setPos((float)(-w / 2 + 1), (float)(0 + yOff), 0); + cubes[1]->addBox(static_cast(-w / 2 + 2), static_cast(-d - 1), -1, w - 4, d, 2, 0); + cubes[1]->setPos(static_cast(-w / 2 + 1), static_cast(0 + yOff), 0); - cubes[2]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); - cubes[2]->setPos((float)(+w / 2 - 1), (float)(0 + yOff), 0); + cubes[2]->addBox(static_cast(-w / 2 + 2), static_cast(-d - 1), -1, w - 4, d, 2, 0); + cubes[2]->setPos(static_cast(+w / 2 - 1), static_cast(0 + yOff), 0); - cubes[3]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); - cubes[3]->setPos(0, (float)(0 + yOff), (float)(-h / 2 + 1)); + cubes[3]->addBox(static_cast(-w / 2 + 2), static_cast(-d - 1), -1, w - 4, d, 2, 0); + cubes[3]->setPos(0, static_cast(0 + yOff), static_cast(-h / 2 + 1)); - cubes[4]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); - cubes[4]->setPos(0, (float)(0 + yOff), (float)(+h / 2 - 1)); + cubes[4]->addBox(static_cast(-w / 2 + 2), static_cast(-d - 1), -1, w - 4, d, 2, 0); + cubes[4]->setPos(0, static_cast(0 + yOff), static_cast(+h / 2 - 1)); cubes[0]->xRot = PI / 2; cubes[1]->yRot = PI / 2 * 3; diff --git a/Minecraft.Client/BoatRenderer.cpp b/Minecraft.Client/BoatRenderer.cpp index 4c2e9baf9..c012168a4 100644 --- a/Minecraft.Client/BoatRenderer.cpp +++ b/Minecraft.Client/BoatRenderer.cpp @@ -20,7 +20,7 @@ void BoatRenderer::render(shared_ptr _boat, double x, double y, double z glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); glRotatef(180-rot, 0, 1, 0); float hurt = boat->getHurtTime() - a; diff --git a/Minecraft.Client/BreakingItemParticle.cpp b/Minecraft.Client/BreakingItemParticle.cpp index 51b721f51..2eab8616d 100644 --- a/Minecraft.Client/BreakingItemParticle.cpp +++ b/Minecraft.Client/BreakingItemParticle.cpp @@ -50,9 +50,9 @@ void BreakingItemParticle::render(Tesselator *t, float a, float xa, float ya, fl v1 = tex->getV(((vo + 1) / 4.0f) * SharedConstants::WORLD_RESOLUTION); } - float x = (float) (xo + (this->x - xo) * a - xOff); - float y = (float) (yo + (this->y - yo) * a - yOff); - float z = (float) (zo + (this->z - zo) * a - zOff); + float x = static_cast(xo + (this->x - xo) * a - xOff); + float y = static_cast(yo + (this->y - yo) * a - yOff); + float z = static_cast(zo + (this->z - zo) * a - zOff); float br = SharedConstants::TEXTURE_LIGHTING ? 1 : getBrightness(a); // 4J - change brought forward from 1.8.2 t->color(br * rCol, br * gCol, br * bCol); diff --git a/Minecraft.Client/BubbleParticle.cpp b/Minecraft.Client/BubbleParticle.cpp index 2d1380eb5..29dd12029 100644 --- a/Minecraft.Client/BubbleParticle.cpp +++ b/Minecraft.Client/BubbleParticle.cpp @@ -16,11 +16,11 @@ BubbleParticle::BubbleParticle(Level *level, double x, double y, double z, doubl size = size*(random->nextFloat()*0.6f+0.2f); - xd = xa*0.2f+(float)(Math::random()*2-1)*0.02f; - yd = ya*0.2f+(float)(Math::random()*2-1)*0.02f; - zd = za*0.2f+(float)(Math::random()*2-1)*0.02f; + xd = xa*0.2f+static_cast(Math::random() * 2 - 1)*0.02f; + yd = ya*0.2f+static_cast(Math::random() * 2 - 1)*0.02f; + zd = za*0.2f+static_cast(Math::random() * 2 - 1)*0.02f; - lifetime = (int) (8 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(8 / (Math::random() * 0.8 + 0.2)); } void BubbleParticle::tick() diff --git a/Minecraft.Client/BufferedImage.cpp b/Minecraft.Client/BufferedImage.cpp index 89e37e4f4..0b95c763d 100644 --- a/Minecraft.Client/BufferedImage.cpp +++ b/Minecraft.Client/BufferedImage.cpp @@ -391,9 +391,9 @@ void BufferedImage::preMultiplyAlpha() { cur = curData[i]; alpha = (cur >> 24) & 0xff; - r = ((cur >> 16) & 0xff) * (float)alpha/255; - g = ((cur >> 8) & 0xff) * (float)alpha/255; - b = (cur & 0xff) * (float)alpha/255; + r = ((cur >> 16) & 0xff) * static_cast(alpha)/255; + g = ((cur >> 8) & 0xff) * static_cast(alpha)/255; + b = (cur & 0xff) * static_cast(alpha)/255; curData[i] = (r << 16) | (g << 8) | (b ) | (alpha << 24); } diff --git a/Minecraft.Client/ChestRenderer.cpp b/Minecraft.Client/ChestRenderer.cpp index 97954b55a..5b59eb411 100644 --- a/Minecraft.Client/ChestRenderer.cpp +++ b/Minecraft.Client/ChestRenderer.cpp @@ -54,7 +54,7 @@ void ChestRenderer::render(shared_ptr _chest, double x, double y, d if (dynamic_cast(tile) != NULL && data == 0) { - ((ChestTile *) tile)->recalcLockDir(chest->getLevel(), chest->x, chest->y, chest->z); + static_cast(tile)->recalcLockDir(chest->getLevel(), chest->x, chest->y, chest->z); data = chest->getData(); } @@ -102,7 +102,7 @@ void ChestRenderer::render(shared_ptr _chest, double x, double y, d glEnable(GL_RESCALE_NORMAL); //if( setColor ) glColor4f(1, 1, 1, 1); if( setColor ) glColor4f(1, 1, 1, alpha); - glTranslatef((float) x, (float) y + 1, (float) z + 1); + glTranslatef(static_cast(x), static_cast(y) + 1, static_cast(z) + 1); glScalef(1, -1, -1); glTranslatef(0.5f, 0.5f, 0.5f); diff --git a/Minecraft.Client/ChickenModel.cpp b/Minecraft.Client/ChickenModel.cpp index 98ef93587..14eb61270 100644 --- a/Minecraft.Client/ChickenModel.cpp +++ b/Minecraft.Client/ChickenModel.cpp @@ -8,35 +8,35 @@ ChickenModel::ChickenModel() : Model() int yo = 16; head = new ModelPart(this, 0, 0); head->addBox(-2.0f, -6.0f, -2.0f, 4, 6, 3, 0.0f); // Head - head->setPos(0, (float)(-1 + yo), -4); + head->setPos(0, static_cast(-1 + yo), -4); beak = new ModelPart(this, 14, 0); beak->addBox(-2.0f, -4.0f, -4.0f, 4, 2, 2, 0.0f); // Beak - beak->setPos(0, (float)(-1 + yo), -4); + beak->setPos(0, static_cast(-1 + yo), -4); redThing = new ModelPart(this, 14, 4); redThing->addBox(-1.0f, -2.0f, -3.0f, 2, 2, 2, 0.0f); // Beak - redThing->setPos(0, (float)(-1 + yo), -4); + redThing->setPos(0, static_cast(-1 + yo), -4); body = new ModelPart(this, 0, 9); body->addBox(-3.0f, -4.0f, -3.0f, 6, 8, 6, 0.0f); // Body - body->setPos(0, (float)(0 + yo), 0); + body->setPos(0, static_cast(0 + yo), 0); leg0 = new ModelPart(this, 26, 0); leg0->addBox(-1.0f, 0.0f, -3.0f, 3, 5, 3); // Leg0 - leg0->setPos(-2, (float)(3 + yo), 1); + leg0->setPos(-2, static_cast(3 + yo), 1); leg1 = new ModelPart(this, 26, 0); leg1->addBox(-1.0f, 0.0f, -3.0f, 3, 5, 3); // Leg1 - leg1->setPos(1, (float)(3 + yo), 1); + leg1->setPos(1, static_cast(3 + yo), 1); wing0 = new ModelPart(this, 24, 13); wing0->addBox(0.0f, 0.0f, -3.0f, 1, 4, 6); // Wing0 - wing0->setPos(-4, (float)(-3 + yo), 0); + wing0->setPos(-4, static_cast(-3 + yo), 0); wing1 = new ModelPart(this, 24, 13); wing1->addBox(-1.0f, 0.0f, -3.0f, 1, 4, 6); // Wing1 - wing1->setPos(4, (float)(-3 + yo), 0); + wing1->setPos(4, static_cast(-3 + yo), 0); // 4J added - compile now to avoid random performance hit first time cubes are rendered head->compile(1.0f/16.0f); diff --git a/Minecraft.Client/Chunk.cpp b/Minecraft.Client/Chunk.cpp index 850b79fb3..58ee7f484 100644 --- a/Minecraft.Client/Chunk.cpp +++ b/Minecraft.Client/Chunk.cpp @@ -32,13 +32,13 @@ void Chunk::CreateNewThreadStorage() void Chunk::ReleaseThreadStorage() { - unsigned char *tileIds = (unsigned char *)TlsGetValue(tlsIdx); + unsigned char *tileIds = static_cast(TlsGetValue(tlsIdx)); delete tileIds; } unsigned char *Chunk::GetTileIdsStorage() { - unsigned char *tileIds = (unsigned char *)TlsGetValue(tlsIdx); + unsigned char *tileIds = static_cast(TlsGetValue(tlsIdx)); return tileIds; } #else @@ -148,7 +148,7 @@ void Chunk::setPos(int x, int y, int z) void Chunk::translateToPos() { - glTranslatef((float)xRenderOffs, (float)yRenderOffs, (float)zRenderOffs); + glTranslatef(static_cast(xRenderOffs), static_cast(yRenderOffs), static_cast(zRenderOffs)); } @@ -399,7 +399,7 @@ void Chunk::rebuild() glTranslatef(zs / 2.0f, ys / 2.0f, zs / 2.0f); #endif t->begin(); - t->offset((float)(-this->x), (float)(-this->y), (float)(-this->z)); + t->offset(static_cast(-this->x), static_cast(-this->y), static_cast(-this->z)); } Tile *tile = Tile::tiles[tileId]; @@ -936,17 +936,17 @@ void Chunk::rebuild_SPU() float Chunk::distanceToSqr(shared_ptr player) const { - float xd = (float) (player->x - xm); - float yd = (float) (player->y - ym); - float zd = (float) (player->z - zm); + float xd = static_cast(player->x - xm); + float yd = static_cast(player->y - ym); + float zd = static_cast(player->z - zm); return xd * xd + yd * yd + zd * zd; } float Chunk::squishedDistanceToSqr(shared_ptr player) { - float xd = (float) (player->x - xm); - float yd = (float) (player->y - ym) * 2; - float zd = (float) (player->z - zm); + float xd = static_cast(player->x - xm); + float yd = static_cast(player->y - ym) * 2; + float zd = static_cast(player->z - zm); return xd * xd + yd * yd + zd * zd; } diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index 2270433d3..26d3b379f 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -468,12 +468,12 @@ void ClientConnection::handleAddEntity(shared_ptr packet) break; case AddEntityPacket::ITEM_FRAME: { - int ix=(int) x; - int iy=(int) y; - int iz = (int) z; + int ix=static_cast(x); + int iy=static_cast(y); + int iz = static_cast(z); app.DebugPrintf("ClientConnection ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); } - e = shared_ptr(new ItemFrame(level, (int) x, (int) y, (int) z, packet->data)); + e = shared_ptr(new ItemFrame(level, static_cast(x), static_cast(y), static_cast(z), packet->data)); packet->data = 0; setRot = false; break; @@ -530,7 +530,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) e = shared_ptr(new FireworksRocketEntity(level, x, y, z, nullptr)); break; case AddEntityPacket::LEASH_KNOT: - e = shared_ptr(new LeashFenceKnotEntity(level, (int) x, (int) y, (int) z)); + e = shared_ptr(new LeashFenceKnotEntity(level, static_cast(x), static_cast(y), static_cast(z))); packet->data = 0; break; #ifndef _FINAL_BUILD @@ -804,11 +804,11 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e; if (pktXuid >= WIN64_XUID_BASE && pktXuid < WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS) { - BYTE smallId = (BYTE)(pktXuid - WIN64_XUID_BASE); + BYTE smallId = static_cast(pktXuid - WIN64_XUID_BASE); INetworkPlayer* np = g_NetworkManager.GetPlayerBySmallId(smallId); if (np != NULL) { - NetworkPlayerXbox* npx = (NetworkPlayerXbox*)np; + NetworkPlayerXbox* npx = static_cast(np); IQNetPlayer* qp = npx->GetQNetPlayer(); if (qp != NULL && qp->m_gamertag[0] == 0) { @@ -976,7 +976,7 @@ void ClientConnection::handleRemoveEntity(shared_ptr packe INetworkPlayer* np = g_NetworkManager.GetPlayerByXuid(xuid); if (np != NULL) { - NetworkPlayerXbox* npx = (NetworkPlayerXbox*)np; + NetworkPlayerXbox* npx = static_cast(np); IQNetPlayer* qp = npx->GetQNetPlayer(); if (qp != NULL) { @@ -1727,7 +1727,7 @@ void ClientConnection::handleChat(shared_ptr packet) } else { - message = replaceAll(message,L"{*DESTINATION*}", app.getEntityName((eINSTANCEOF)packet->m_intArgs[0])); + message = replaceAll(message,L"{*DESTINATION*}", app.getEntityName(static_cast(packet->m_intArgs[0]))); } break; case ChatPacket::e_ChatCommandTeleportMe: @@ -1767,7 +1767,7 @@ void ClientConnection::handleChat(shared_ptr packet) } else { - entityName = app.getEntityName((eINSTANCEOF) packet->m_intArgs[0]); + entityName = app.getEntityName(static_cast(packet->m_intArgs[0])); } message = replaceAll(message,L"{*SOURCE*}", entityName); @@ -2744,7 +2744,7 @@ void ClientConnection::handleRespawn(shared_ptr packet) if( minecraft->localgameModes[m_userIndex] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_userIndex]; + TutorialMode *gameMode = static_cast(minecraft->localgameModes[m_userIndex]); gameMode->getTutorial()->showTutorialPopup(false); } @@ -3267,7 +3267,7 @@ void ClientConnection::handleGameEvent(shared_ptr gameEventPack } else if (event == GameEventPacket::WIN_GAME) { - ui.SetWinUserIndex( (BYTE)gameEventPacket->param ); + ui.SetWinUserIndex( static_cast(gameEventPacket->param) ); #ifdef _XBOX @@ -3439,11 +3439,11 @@ void ClientConnection::displayPrivilegeChanges(shared_ptrGetXboxPad(); unsigned int newPrivileges = player->getAllPlayerGamePrivileges(); - Player::EPlayerGamePrivileges priv = (Player::EPlayerGamePrivileges)0; + Player::EPlayerGamePrivileges priv = static_cast(0); bool privOn = false; for(unsigned int i = 0; i < Player::ePlayerGamePrivilege_MAX; ++i) { - priv = (Player::EPlayerGamePrivileges) i; + priv = static_cast(i); if( Player::getPlayerGamePrivilege(newPrivileges,priv) != Player::getPlayerGamePrivilege(oldPrivileges,priv)) { privOn = Player::getPlayerGamePrivilege(newPrivileges,priv); @@ -3579,7 +3579,7 @@ void ClientConnection::handleCustomPayload(shared_ptr custo } #else UIScene *scene = ui.GetTopScene(m_userIndex, eUILayer_Scene); - UIScene_TradingMenu *screen = (UIScene_TradingMenu *)scene; + UIScene_TradingMenu *screen = static_cast(scene); trader = screen->getMerchant(); #endif @@ -3665,7 +3665,7 @@ int ClientConnection::HostDisconnectReturned(void *pParam,int iPad,C4JStorage::E if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) diff --git a/Minecraft.Client/ClockTexture.cpp b/Minecraft.Client/ClockTexture.cpp index 837532fb7..37efc1839 100644 --- a/Minecraft.Client/ClockTexture.cpp +++ b/Minecraft.Client/ClockTexture.cpp @@ -57,7 +57,7 @@ void ClockTexture::cycleFrames() // 4J Stu - We share data with another texture if(m_dataTexture != NULL) { - int newFrame = (int) ((rot + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); + int newFrame = static_cast((rot + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); while (newFrame < 0) { newFrame = (newFrame + m_dataTexture->frames->size()) % m_dataTexture->frames->size(); @@ -70,7 +70,7 @@ void ClockTexture::cycleFrames() } else { - int newFrame = (int) ((rot + 1.0) * frames->size()) % frames->size(); + int newFrame = static_cast((rot + 1.0) * frames->size()) % frames->size(); while (newFrame < 0) { newFrame = (newFrame + frames->size()) % frames->size(); diff --git a/Minecraft.Client/Common/Audio/SoundEngine.cpp b/Minecraft.Client/Common/Audio/SoundEngine.cpp index e9affe6b8..e3e8cee93 100644 --- a/Minecraft.Client/Common/Audio/SoundEngine.cpp +++ b/Minecraft.Client/Common/Audio/SoundEngine.cpp @@ -447,7 +447,7 @@ void SoundEngine::updateMiles() int Playing = 0; while (AIL_enumerate_sound_instances(0, &token, 0, 0, 0, &SoundInfo)) { - AUDIO_INFO* game_data= (AUDIO_INFO*)( SoundInfo.UserBuffer ); + AUDIO_INFO* game_data= static_cast(SoundInfo.UserBuffer); if( SoundInfo.Status == MILESEVENT_SOUND_STATUS_PLAYING ) { @@ -1134,7 +1134,7 @@ int SoundEngine::OpenStreamThreadProc( void* lpParameter ) #ifdef __DISABLE_MILES__ return 0; #endif - SoundEngine *soundEngine = (SoundEngine *)lpParameter; + SoundEngine *soundEngine = static_cast(lpParameter); soundEngine->m_hStream = AIL_open_stream(soundEngine->m_hDriver,soundEngine->m_szStreamName,0); if(soundEngine->m_hStream==0) @@ -1211,9 +1211,9 @@ void SoundEngine::playMusicUpdate() { // It's a mash-up - need to use the DLC path for the music TexturePack *pTexPack=Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexPack; + DLCTexturePack *pDLCTexPack=static_cast(pTexPack); DLCPack *pack = pDLCTexPack->getDLCInfoParentPack(); - DLCAudioFile *dlcAudioFile = (DLCAudioFile *) pack->getFile(DLCManager::e_DLCType_Audio, 0); + DLCAudioFile *dlcAudioFile = static_cast(pack->getFile(DLCManager::e_DLCType_Audio, 0)); app.DebugPrintf("Mashup pack \n"); @@ -1683,7 +1683,7 @@ char *SoundEngine::ConvertSoundPathToName(const wstring& name, bool bConvertSpac { if(c==' ') c='_'; } - buf[i] = (char)c; + buf[i] = static_cast(c); } buf[name.length()] = 0; return buf; diff --git a/Minecraft.Client/Common/Colours/ColourTable.cpp b/Minecraft.Client/Common/Colours/ColourTable.cpp index e4bfe7327..e103c3198 100644 --- a/Minecraft.Client/Common/Colours/ColourTable.cpp +++ b/Minecraft.Client/Common/Colours/ColourTable.cpp @@ -325,7 +325,7 @@ void ColourTable::staticCtor() { for(unsigned int i = eMinecraftColour_NOT_SET; i < eMinecraftColour_COUNT; ++i) { - s_colourNamesMap.insert( unordered_map::value_type( ColourTableElements[i], (eMinecraftColour)i) ); + s_colourNamesMap.insert( unordered_map::value_type( ColourTableElements[i], static_cast(i)) ); } } @@ -366,7 +366,7 @@ void ColourTable::setColour(const wstring &colourName, int value) auto it = s_colourNamesMap.find(colourName); if(it != s_colourNamesMap.end()) { - m_colourValues[(int)it->second] = value; + m_colourValues[static_cast(it->second)] = value; } } @@ -377,5 +377,5 @@ void ColourTable::setColour(const wstring &colourName, const wstring &value) unsigned int ColourTable::getColour(eMinecraftColour id) { - return m_colourValues[(int)id]; + return m_colourValues[static_cast(id)]; } diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 00dedbe15..692e00d87 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -803,7 +803,7 @@ void CMinecraftApp::InitGameSettings() #if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) GameSettingsA[i]=(GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(i); #else - GameSettingsA[i]=(GAME_SETTINGS *)ProfileManager.GetGameDefinedProfileData(i); + GameSettingsA[i]=static_cast(ProfileManager.GetGameDefinedProfileData(i)); #endif // clear the flag to say the settings have changed GameSettingsA[i]->bSettingsChanged=false; @@ -933,7 +933,7 @@ int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C4JStorage::PROFILESETTI int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad) #endif { - CMinecraftApp *pApp=(CMinecraftApp *)pParam; + CMinecraftApp *pApp=static_cast(pParam); // flag the default options to be set @@ -1368,20 +1368,20 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_MusicVolume: if(iPad==ProfileManager.GetPrimaryPad()) { - pMinecraft->options->set(Options::Option::MUSIC,((float)GameSettingsA[iPad]->ucMusicVolume)/100.0f); + pMinecraft->options->set(Options::Option::MUSIC,static_cast(GameSettingsA[iPad]->ucMusicVolume)/100.0f); } break; case eGameSetting_SoundFXVolume: if(iPad==ProfileManager.GetPrimaryPad()) { - pMinecraft->options->set(Options::Option::SOUND,((float)GameSettingsA[iPad]->ucSoundFXVolume)/100.0f); + pMinecraft->options->set(Options::Option::SOUND,static_cast(GameSettingsA[iPad]->ucSoundFXVolume)/100.0f); } break; case eGameSetting_Gamma: if(iPad==ProfileManager.GetPrimaryPad()) { #if defined(_WIN64) || defined(_WINDOWS64) - pMinecraft->options->set(Options::Option::GAMMA, ((float)GameSettingsA[iPad]->ucGamma) / 100.0f); + pMinecraft->options->set(Options::Option::GAMMA, static_cast(GameSettingsA[iPad]->ucGamma) / 100.0f); #else // ucGamma range is 0-100, UpdateGamma is 0 - 32768 float fVal=((float)GameSettingsA[iPad]->ucGamma)*327.68f; @@ -1417,7 +1417,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_Sensitivity_InGame: // 4J-PB - we don't use the options value // tell the input that we've changed the sensitivity - range of the slider is 0 to 200, default is 100 - pMinecraft->options->set(Options::Option::SENSITIVITY,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); + pMinecraft->options->set(Options::Option::SENSITIVITY,static_cast(GameSettingsA[iPad]->ucSensitivity)/100.0f); //InputManager.SetJoypadSensitivity(iPad,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); break; @@ -1697,7 +1697,7 @@ unsigned char CMinecraftApp::GetPlayerFavoriteSkinsPos(int iPad) void CMinecraftApp::SetPlayerFavoriteSkinsPos(int iPad, int iPos) { - GameSettingsA[iPad]->ucCurrentFavoriteSkinPos=(unsigned char)iPos; + GameSettingsA[iPad]->ucCurrentFavoriteSkinPos=static_cast(iPos); GameSettingsA[iPad]->bSettingsChanged = true; } @@ -2644,7 +2644,7 @@ int CMinecraftApp::DisplaySavingMessage(void *pParam, C4JStorage::ESavingMessage void CMinecraftApp::SetActionConfirmed(LPVOID param) { - XuiActionParam *actionInfo = (XuiActionParam *)param; + XuiActionParam *actionInfo = static_cast(param); app.SetAction(actionInfo->iPad, actionInfo->action); } @@ -2800,7 +2800,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::SaveWorldThreadProc; - loadingParams->lpParam = (LPVOID)false; + loadingParams->lpParam = static_cast(false); // 4J-JEV - PS4: Fix for #5708 - [ONLINE] - If the user pulls their network cable out while saving the title will hang. loadingParams->waitForThreadToDelete = true; @@ -2861,7 +2861,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::SaveWorldThreadProc; - loadingParams->lpParam = (LPVOID)true; + loadingParams->lpParam = (LPVOID)(true); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3692,7 +3692,7 @@ void CMinecraftApp::HandleXuiActions(void) if(pTexPack->hasAudio()) { // get the dlc texture pack, and store it - pDLCTexPack=(DLCTexturePack *)pTexPack; + pDLCTexPack=static_cast(pTexPack); } // change to the default texture pack @@ -3745,7 +3745,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::ExitAndJoinFromInviteThreadProc; - loadingParams->lpParam = (LPVOID)&m_InviteData; + loadingParams->lpParam = static_cast(&m_InviteData); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3768,7 +3768,7 @@ void CMinecraftApp::HandleXuiActions(void) g_NetworkManager.SetLocalGame(false); - JoinFromInviteData *inviteData = (JoinFromInviteData *)param; + JoinFromInviteData *inviteData = static_cast(param); // 4J-PB - clear any previous connection errors Minecraft::GetInstance()->clearConnectionFailed(); @@ -3894,7 +3894,7 @@ void CMinecraftApp::HandleXuiActions(void) #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) SetDefaultOptions((C4JStorage::PROFILESETTINGS *)param,i); #else - SetDefaultOptions((C_4JProfile::PROFILESETTINGS *)param,i); + SetDefaultOptions(static_cast(param),i); #endif // if the profile data has been changed, then force a profile write @@ -4312,7 +4312,7 @@ void CMinecraftApp::HandleXuiActions(void) int CMinecraftApp::BannedLevelDialogReturned(void *pParam,int iPad,const C4JStorage::EMessageResult result) { - CMinecraftApp* pApp = (CMinecraftApp*)pParam; + CMinecraftApp* pApp = static_cast(pParam); //Minecraft *pMinecraft=Minecraft::GetInstance(); if(result==C4JStorage::EMessage_ResultAccept) @@ -4721,7 +4721,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CMinecraftApp* pApp = (CMinecraftApp*)pParam; + CMinecraftApp* pApp = static_cast(pParam); Minecraft *pMinecraft=Minecraft::GetInstance(); if(result==C4JStorage::EMessage_ResultAccept) @@ -4793,7 +4793,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CMinecraftApp* pApp = (CMinecraftApp*)pParam; + CMinecraftApp* pApp = static_cast(pParam); Minecraft *pMinecraft=Minecraft::GetInstance(); if(result==C4JStorage::EMessage_ResultAccept) @@ -4851,7 +4851,7 @@ int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageR void CMinecraftApp::ProfileReadErrorCallback(void *pParam) { - CMinecraftApp *pApp=(CMinecraftApp *)pParam; + CMinecraftApp *pApp=static_cast(pParam); int iPrimaryPlayer=ProfileManager.GetPrimaryPad(); pApp->SetAction(iPrimaryPlayer, eAppAction_ProfileReadError); } @@ -4883,7 +4883,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange Minecraft::GetInstance()->user->name = convStringToWstring( ProfileManager.GetGamertag(ProfileManager.GetPrimaryPad())); #endif - CMinecraftApp *pApp=(CMinecraftApp *)pParam; + CMinecraftApp *pApp=static_cast(pParam); // check if the primary player signed out int iPrimaryPlayer=ProfileManager.GetPrimaryPad(); @@ -5058,7 +5058,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, unsigned int uiParam) { - CMinecraftApp* pClass = (CMinecraftApp*)pParam; + CMinecraftApp* pClass = static_cast(pParam); // push these on to the notifications to be handled in qnet's dowork @@ -5247,7 +5247,7 @@ void CMinecraftApp::SetDebugSequence(const char *pchSeq) } int CMinecraftApp::DebugInputCallback(LPVOID pParam) { - CMinecraftApp* pClass = (CMinecraftApp*)pParam; + CMinecraftApp* pClass = static_cast(pParam); //printf("sequence matched\n"); pClass->m_bDebugOptions=!pClass->m_bDebugOptions; @@ -5592,7 +5592,7 @@ void CMinecraftApp::InitTime() // Get the frequency of the timer LARGE_INTEGER qwTicksPerSec; QueryPerformanceFrequency( &qwTicksPerSec ); - m_Time.fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; + m_Time.fSecsPerTick = 1.0f / static_cast(qwTicksPerSec.QuadPart); // Save the start time QueryPerformanceCounter( &m_Time.qwTime ); @@ -5618,8 +5618,8 @@ void CMinecraftApp::UpdateTime() m_Time.qwAppTime.QuadPart += qwDeltaTime.QuadPart; m_Time.qwTime.QuadPart = qwNewTime.QuadPart; - m_Time.fElapsedTime = m_Time.fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); - m_Time.fAppTime = m_Time.fSecsPerTick * ((FLOAT)(m_Time.qwAppTime.QuadPart)); + m_Time.fElapsedTime = m_Time.fSecsPerTick * static_cast(qwDeltaTime.QuadPart); + m_Time.fAppTime = m_Time.fSecsPerTick * static_cast(m_Time.qwAppTime.QuadPart); } @@ -5913,7 +5913,7 @@ void CMinecraftApp::ProcessInvite(DWORD dwUserIndex, DWORD dwLocalUsersMask, con int CMinecraftApp::ExitAndJoinFromInvite(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CMinecraftApp* pApp = (CMinecraftApp*)pParam; + CMinecraftApp* pApp = static_cast(pParam); //Minecraft *pMinecraft=Minecraft::GetInstance(); // buttons are swapped on this menu @@ -5927,7 +5927,7 @@ int CMinecraftApp::ExitAndJoinFromInvite(void *pParam,int iPad,C4JStorage::EMess int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CMinecraftApp *pClass = (CMinecraftApp *)pParam; + CMinecraftApp *pClass = static_cast(pParam); // Exit with or without saving // Decline means save in this dialog if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption) @@ -7487,7 +7487,7 @@ int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4 { #ifndef _XBOX // Inform fullscreen progress scene that it's not being cancelled after all - UIScene_FullscreenProgress *pScene = (UIScene_FullscreenProgress *)ui.FindScene(eUIScene_FullscreenProgress); + UIScene_FullscreenProgress *pScene = static_cast(ui.FindScene(eUIScene_FullscreenProgress)); #ifdef __PS3__ if(pScene!=NULL) #else @@ -7565,7 +7565,7 @@ void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char *ps if(bWriteToTMS) { - DWORD dwDataBytes=(DWORD)(sizeof(BANNEDLISTDATA)*m_vBannedListA[iPad]->size()); + DWORD dwDataBytes=static_cast(sizeof(BANNEDLISTDATA) * m_vBannedListA[iPad]->size()); PBANNEDLISTDATA pBannedList = (BANNEDLISTDATA *)(new CHAR [dwDataBytes]); int iCount=0; for (PBANNEDLISTDATA pData : *m_vBannedListA[iPad] ) @@ -7638,7 +7638,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha } } - DWORD dwDataBytes=(DWORD)(sizeof(BANNEDLISTDATA)*m_vBannedListA[iPad]->size()); + DWORD dwDataBytes=static_cast(sizeof(BANNEDLISTDATA) * m_vBannedListA[iPad]->size()); if(dwDataBytes==0) { // wipe the file @@ -7652,7 +7652,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha { PBANNEDLISTDATA pBannedList = (BANNEDLISTDATA *)(new BYTE [dwDataBytes]); - int iSize=(int)m_vBannedListA[iPad]->size(); + int iSize=static_cast(m_vBannedListA[iPad]->size()); for(int i=0;iat(i); @@ -7706,7 +7706,7 @@ bool CMinecraftApp::AlreadySeenCreditText(const wstring &wstemp) unsigned int CMinecraftApp::GetDLCCreditsCount() { - return (unsigned int)vDLCCredits.size(); + return static_cast(vDLCCredits.size()); } SCreditTextItemDef * CMinecraftApp::GetDLCCredits(int iIndex) @@ -8825,7 +8825,7 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto { #endif - CMinecraftApp* pClass = (CMinecraftApp *) pParam; + CMinecraftApp* pClass = static_cast(pParam); // find the right one in the vector EnterCriticalSection(&pClass->csTMSPPDownloadQueue); @@ -9086,7 +9086,7 @@ void CMinecraftApp::ClearTMSPPFilesRetrieved() int CMinecraftApp::DLCOffersReturned(void *pParam, int iOfferC, DWORD dwType, int iPad) { - CMinecraftApp* pClass = (CMinecraftApp *) pParam; + CMinecraftApp* pClass = static_cast(pParam); // find the right one in the vector EnterCriticalSection(&pClass->csTMSPPDownloadQueue); @@ -9111,10 +9111,10 @@ eDLCContentType CMinecraftApp::Find_eDLCContentType(DWORD dwType) { if(m_dwContentTypeA[i]==dwType) { - return (eDLCContentType)i; + return static_cast(i); } } - return (eDLCContentType)0; + return static_cast(0); } bool CMinecraftApp::DLCContentRetrieved(eDLCMarketplaceType eType) { @@ -9457,18 +9457,18 @@ int CMinecraftApp::GetDLCInfoFullOffersCount() #else int CMinecraftApp::GetDLCInfoTrialOffersCount() { - return (int)DLCInfo_Trial.size(); + return static_cast(DLCInfo_Trial.size()); } int CMinecraftApp::GetDLCInfoFullOffersCount() { - return (int)DLCInfo_Full.size(); + return static_cast(DLCInfo_Full.size()); } #endif int CMinecraftApp::GetDLCInfoTexturesOffersCount() { - return (int)DLCTextures_PackID.size(); + return static_cast(DLCTextures_PackID.size()); } // AUTOSAVE diff --git a/Minecraft.Client/Common/Consoles_App.h b/Minecraft.Client/Common/Consoles_App.h index ec36b7652..0e4d66154 100644 --- a/Minecraft.Client/Common/Consoles_App.h +++ b/Minecraft.Client/Common/Consoles_App.h @@ -625,7 +625,7 @@ class CMinecraftApp virtual void ReleaseSaveThumbnail()=0; virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize)=0; - virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false)=0; + virtual void ReadBannedList(int iPad, eTMSAction action=static_cast(0), bool bCallback=false)=0; private: diff --git a/Minecraft.Client/Common/DLC/DLCAudioFile.cpp b/Minecraft.Client/Common/DLC/DLCAudioFile.cpp index 6faf0c3b3..ff18b540a 100644 --- a/Minecraft.Client/Common/DLC/DLCAudioFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCAudioFile.cpp @@ -40,7 +40,7 @@ DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(const wstring & { if(paramName.compare(wchTypeNamesA[i]) == 0) { - type = (EAudioParameterType)i; + type = static_cast(i); break; } } @@ -87,7 +87,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype, cons { i++; } - int iLast=(int)creditValue.find_last_of(L" ",i); + int iLast=static_cast(creditValue.find_last_of(L" ", i)); switch(XGetLanguage()) { case XC_LANGUAGE_JAPANESE: @@ -96,7 +96,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype, cons iLast = maximumChars; break; default: - iLast=(int)creditValue.find_last_of(L" ",i); + iLast=static_cast(creditValue.find_last_of(L" ", i)); break; } @@ -145,7 +145,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) for(unsigned int i=0;iwchData); + wstring parameterName(static_cast(pParams->wchData)); EAudioParameterType type = getParameterType(parameterName); if( type != e_AudioParamType_Invalid ) { @@ -169,7 +169,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) for(unsigned int i=0;idwType; + EAudioType type = static_cast(pFile->dwType); // Params unsigned int uiParameterCount=*(unsigned int *)pbTemp; pbTemp+=sizeof(int); @@ -182,7 +182,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) if(it != parameterMapping.end() ) { - addParameter(type,(EAudioParameterType)pParams->dwType,(WCHAR *)pParams->wchData); + addParameter(type,static_cast(pParams->dwType),(WCHAR *)pParams->wchData); } pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount); pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index 36f4d7f7e..89da3cebe 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -47,7 +47,7 @@ DLCManager::EDLCParameterType DLCManager::getParameterType(const wstring ¶mN { if(paramName.compare(wchTypeNamesA[i]) == 0) { - type = (EDLCParameterType)i; + type = static_cast(i); break; } } @@ -70,7 +70,7 @@ DWORD DLCManager::getPackCount(EDLCType type /*= e_DLCType_All*/) } else { - packCount = (DWORD)m_packs.size(); + packCount = static_cast(m_packs.size()); } return packCount; } @@ -403,7 +403,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD for(unsigned int i=0;iwchData); + wstring parameterName(static_cast(pParams->wchData)); DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); if( type != DLCManager::e_DLCParamType_Invalid ) { @@ -429,7 +429,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD for(unsigned int i=0;idwType; + DLCManager::EDLCType type = static_cast(pFile->dwType); DLCFile *dlcFile = NULL; DLCPack *dlcTexturePack = NULL; @@ -608,7 +608,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) for(unsigned int i=0;iwchData); + wstring parameterName(static_cast(pParams->wchData)); DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); if( type != DLCManager::e_DLCParamType_Invalid ) { @@ -633,7 +633,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) for(unsigned int i=0;idwType; + DLCManager::EDLCType type = static_cast(pFile->dwType); // Params uiParameterCount=*(unsigned int *)pbTemp; @@ -649,7 +649,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) { if(it->second==e_DLCParamType_PackId) { - wstring wsTemp=(WCHAR *)pParams->wchData; + wstring wsTemp=static_cast(pParams->wchData); std::wstringstream ss; // 4J Stu - numbered using decimal to make it easier for artists/people to number manually ss << std::dec << wsTemp.c_str(); diff --git a/Minecraft.Client/Common/DLC/DLCPack.cpp b/Minecraft.Client/Common/DLC/DLCPack.cpp index ea8a270fd..7986bf6d6 100644 --- a/Minecraft.Client/Common/DLC/DLCPack.cpp +++ b/Minecraft.Client/Common/DLC/DLCPack.cpp @@ -156,7 +156,7 @@ void DLCPack::addParameter(DLCManager::EDLCParameterType type, const wstring &va m_dataPath = value; break; default: - m_parameters[(int)type] = value; + m_parameters[static_cast(type)] = value; break; } } @@ -263,7 +263,7 @@ bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, const wstring &path bool hasFile = false; if(type == DLCManager::e_DLCType_All) { - for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1)) + for(DLCManager::EDLCType currentType = static_cast(0); currentType < DLCManager::e_DLCType_Max; currentType = static_cast(currentType + 1)) { hasFile = doesPackContainFile(currentType,path); if(hasFile) break; @@ -287,7 +287,7 @@ DLCFile *DLCPack::getFile(DLCManager::EDLCType type, DWORD index) DLCFile *file = NULL; if(type == DLCManager::e_DLCType_All) { - for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1)) + for(DLCManager::EDLCType currentType = static_cast(0); currentType < DLCManager::e_DLCType_Max; currentType = static_cast(currentType + 1)) { file = getFile(currentType,index); if(file != NULL) break; @@ -309,7 +309,7 @@ DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const wstring &path) DLCFile *file = NULL; if(type == DLCManager::e_DLCType_All) { - for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1)) + for(DLCManager::EDLCType currentType = static_cast(0); currentType < DLCManager::e_DLCType_Max; currentType = static_cast(currentType + 1)) { file = getFile(currentType,path); if(file != NULL) break; @@ -346,11 +346,11 @@ DWORD DLCPack::getDLCItemsCount(DLCManager::EDLCType type /*= DLCManager::e_DLCT case DLCManager::e_DLCType_All: for(int i = 0; i < DLCManager::e_DLCType_Max; ++i) { - count += getDLCItemsCount((DLCManager::EDLCType)i); + count += getDLCItemsCount(static_cast(i)); } break; default: - count = (DWORD)m_files[(int)type].size(); + count = static_cast(m_files[(int)type].size()); break; }; return count; @@ -425,7 +425,7 @@ void DLCPack::UpdateLanguage() 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"); + DLCLocalisationFile *localisationFile = static_cast(getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc")); StringTable *strTable = localisationFile->getStringTable(); strTable->ReloadStringTable(); } diff --git a/Minecraft.Client/Common/DLC/DLCPack.h b/Minecraft.Client/Common/DLC/DLCPack.h index df1f65f04..14129cbed 100644 --- a/Minecraft.Client/Common/DLC/DLCPack.h +++ b/Minecraft.Client/Common/DLC/DLCPack.h @@ -87,8 +87,8 @@ class DLCPack DWORD getSkinCount() { return getDLCItemsCount(DLCManager::e_DLCType_Skin); } DWORD getSkinIndexAt(const wstring &path, bool &found) { return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found); } - DLCSkinFile *getSkinFile(const wstring &path) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, path); } - DLCSkinFile *getSkinFile(DWORD index) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, index); } + DLCSkinFile *getSkinFile(const wstring &path) { return static_cast(getFile(DLCManager::e_DLCType_Skin, path)); } + DLCSkinFile *getSkinFile(DWORD index) { return static_cast(getFile(DLCManager::e_DLCType_Skin, index)); } bool doesPackContainSkin(const wstring &path) { return doesPackContainFile(DLCManager::e_DLCType_Skin, path); } bool hasPurchasedFile(DLCManager::EDLCType type, const wstring &path); diff --git a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp index c845acd9b..2416c9439 100644 --- a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp @@ -79,7 +79,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring { i++; } - int iLast=(int)creditValue.find_last_of(L" ",i); + int iLast=static_cast(creditValue.find_last_of(L" ", i)); switch(XGetLanguage()) { case XC_LANGUAGE_JAPANESE: @@ -88,7 +88,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring iLast = maximumChars; break; default: - iLast=(int)creditValue.find_last_of(L" ",i); + iLast=static_cast(creditValue.find_last_of(L" ", i)); break; } @@ -178,7 +178,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring int DLCSkinFile::getAdditionalBoxesCount() { - return (int)m_AdditionalBoxes.size(); + return static_cast(m_AdditionalBoxes.size()); } vector *DLCSkinFile::getAdditionalBoxes() { diff --git a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp index 801a29373..012a9f7b6 100644 --- a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp @@ -45,7 +45,7 @@ GameRuleDefinition *AddItemRuleDefinition::addChild(ConsoleGameRules::EGameRuleT if(ruleType == ConsoleGameRules::eGameRuleType_AddEnchantment) { rule = new AddEnchantmentRuleDefinition(); - m_enchantments.push_back((AddEnchantmentRuleDefinition *)rule); + m_enchantments.push_back(static_cast(rule)); } else { diff --git a/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp index a740a2beb..7c2b0d955 100644 --- a/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp @@ -72,20 +72,20 @@ void ApplySchematicRuleDefinition::addAttribute(const wstring &attributeName, co else if(attributeName.compare(L"x") == 0) { m_location->x = _fromString(attributeValue); - if( ((int)abs(m_location->x))%2 != 0) m_location->x -=1; + if( static_cast(abs(m_location->x))%2 != 0) m_location->x -=1; //app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter x=%f\n",m_location->x); } else if(attributeName.compare(L"y") == 0) { m_location->y = _fromString(attributeValue); - if( ((int)abs(m_location->y))%2 != 0) m_location->y -= 1; + if( static_cast(abs(m_location->y))%2 != 0) m_location->y -= 1; if(m_location->y < 0) m_location->y = 0; //app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter y=%f\n",m_location->y); } else if(attributeName.compare(L"z") == 0) { m_location->z = _fromString(attributeValue); - if(((int)abs(m_location->z))%2 != 0) m_location->z -= 1; + if(static_cast(abs(m_location->z))%2 != 0) m_location->z -= 1; //app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter z=%f\n",m_location->z); } else if(attributeName.compare(L"rot") == 0) @@ -95,7 +95,7 @@ void ApplySchematicRuleDefinition::addAttribute(const wstring &attributeName, co while(degrees < 0) degrees += 360; while(degrees >= 360) degrees -= 360; float quad = degrees/90; - degrees = (int)(quad + 0.5f); + degrees = static_cast(quad + 0.5f); switch(degrees) { case 1: diff --git a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp index b928b26cc..65bf79ae3 100644 --- a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp @@ -58,7 +58,7 @@ void CompleteAllRuleDefinition::updateStatus(GameRule *rule) wstring CompleteAllRuleDefinition::generateDescriptionString(const wstring &description, void *data, int dataLength) { - PacketData *values = (PacketData *)data; + PacketData *values = static_cast(data); wstring newDesc = description; newDesc = replaceAll(newDesc,L"{*progress*}",std::to_wstring(values->progress)); newDesc = replaceAll(newDesc,L"{*goal*}",std::to_wstring(values->goal)); diff --git a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp index f505ce7a3..62154cdcd 100644 --- a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp +++ b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp @@ -29,22 +29,22 @@ GameRuleDefinition *ConsoleGenerateStructure::addChild(ConsoleGameRules::EGameRu if(ruleType == ConsoleGameRules::eGameRuleType_GenerateBox) { rule = new XboxStructureActionGenerateBox(); - m_actions.push_back((XboxStructureActionGenerateBox *)rule); + m_actions.push_back(static_cast(rule)); } else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceBlock) { rule = new XboxStructureActionPlaceBlock(); - m_actions.push_back((XboxStructureActionPlaceBlock *)rule); + m_actions.push_back(static_cast(rule)); } else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceContainer) { rule = new XboxStructureActionPlaceContainer(); - m_actions.push_back((XboxStructureActionPlaceContainer *)rule); + m_actions.push_back(static_cast(rule)); } else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceSpawner) { rule = new XboxStructureActionPlaceSpawner(); - m_actions.push_back((XboxStructureActionPlaceSpawner *)rule); + m_actions.push_back(static_cast(rule)); } else { @@ -139,25 +139,25 @@ bool ConsoleGenerateStructure::postProcess(Level *level, Random *random, Boundin { case ConsoleGameRules::eGameRuleType_GenerateBox: { - XboxStructureActionGenerateBox *genBox = (XboxStructureActionGenerateBox *)action; + XboxStructureActionGenerateBox *genBox = static_cast(action); genBox->generateBoxInLevel(this,level,chunkBB); } break; case ConsoleGameRules::eGameRuleType_PlaceBlock: { - XboxStructureActionPlaceBlock *pPlaceBlock = (XboxStructureActionPlaceBlock *)action; + XboxStructureActionPlaceBlock *pPlaceBlock = static_cast(action); pPlaceBlock->placeBlockInLevel(this,level,chunkBB); } break; case ConsoleGameRules::eGameRuleType_PlaceContainer: { - XboxStructureActionPlaceContainer *pPlaceContainer = (XboxStructureActionPlaceContainer *)action; + XboxStructureActionPlaceContainer *pPlaceContainer = static_cast(action); pPlaceContainer->placeContainerInLevel(this,level,chunkBB); } break; case ConsoleGameRules::eGameRuleType_PlaceSpawner: { - XboxStructureActionPlaceSpawner *pPlaceSpawner = (XboxStructureActionPlaceSpawner *)action; + XboxStructureActionPlaceSpawner *pPlaceSpawner = static_cast(action); pPlaceSpawner->placeSpawnerInLevel(this,level,chunkBB); } break; diff --git a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h index 91c4ef357..712a29ab1 100644 --- a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h +++ b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h @@ -36,7 +36,7 @@ class ConsoleGenerateStructure : public GameRuleDefinition, public StructurePiec virtual int getMinY(); - EStructurePiece GetType() { return (EStructurePiece)0; } + EStructurePiece GetType() { return static_cast(0); } void addAdditonalSaveData(CompoundTag *tag) {} void readAdditonalSaveData(CompoundTag *tag) {} }; \ No newline at end of file diff --git a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp index 01a8119e3..15009e5f4 100644 --- a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp +++ b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp @@ -61,7 +61,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis) if (version > XBOX_SCHEMATIC_ORIGINAL_VERSION) // Or later versions { - compressionType = (Compression::ECompressionTypes)dis->readByte(); + compressionType = static_cast(dis->readByte()); } if (version > XBOX_SCHEMATIC_CURRENT_VERSION) @@ -146,14 +146,14 @@ void ConsoleSchematicFile::load(DataInputStream *dis) if( type == eTYPE_PAINTING || type == eTYPE_ITEM_FRAME ) { - x = ((IntTag *) eTag->get(L"TileX") )->data; - y = ((IntTag *) eTag->get(L"TileY") )->data; - z = ((IntTag *) eTag->get(L"TileZ") )->data; + x = static_cast(eTag->get(L"TileX"))->data; + y = static_cast(eTag->get(L"TileY"))->data; + z = static_cast(eTag->get(L"TileZ"))->data; } #ifdef _DEBUG //app.DebugPrintf(1,"Loaded entity type %d at (%f,%f,%f)\n",(int)type,x,y,z); #endif - m_entities.push_back( pair(Vec3::newPermanent(x,y,z),(CompoundTag *)eTag->copy())); + m_entities.push_back( pair(Vec3::newPermanent(x,y,z),static_cast(eTag->copy()))); } } delete tag; @@ -178,7 +178,7 @@ void ConsoleSchematicFile::save_tags(DataOutputStream *dos) tag->put(L"Entities", entityTags); for (auto& it : m_entities ) - entityTags->add( (CompoundTag *)(it).second->copy() ); + entityTags->add( static_cast((it).second->copy()) ); NbtIo::write(tag,dos); delete tag; @@ -186,15 +186,15 @@ void ConsoleSchematicFile::save_tags(DataOutputStream *dos) __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) { - int xStart = static_cast(std::fmax(destinationBox->x0, (double)chunk->x*16)); - int xEnd = static_cast(std::fmin(destinationBox->x1, (double)((xStart >> 4) << 4) + 16)); + int xStart = static_cast(std::fmax(destinationBox->x0, static_cast(chunk->x)*16)); + int xEnd = static_cast(std::fmin(destinationBox->x1, static_cast((xStart >> 4) << 4) + 16)); int yStart = destinationBox->y0; int yEnd = destinationBox->y1; if(yEnd > Level::maxBuildHeight) yEnd = Level::maxBuildHeight; - int zStart = static_cast(std::fmax(destinationBox->z0, (double)chunk->z * 16)); - int zEnd = static_cast(std::fmin(destinationBox->z1, (double)((zStart >> 4) << 4) + 16)); + int zStart = static_cast(std::fmax(destinationBox->z0, static_cast(chunk->z) * 16)); + int zEnd = static_cast(std::fmin(destinationBox->z1, static_cast((zStart >> 4) << 4) + 16)); #ifdef _DEBUG app.DebugPrintf("Range is (%d,%d,%d) to (%d,%d,%d)\n",xStart,yStart,zStart,xEnd-1,yEnd-1,zEnd-1); @@ -442,7 +442,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, Vec3 *pos = Vec3::newTemp(targetX,targetY,targetZ); if( chunkBox->containsIncludingLowerBound(pos) ) { - shared_ptr teCopy = chunk->getTileEntity( (int)targetX & 15, (int)targetY & 15, (int)targetZ & 15 ); + shared_ptr teCopy = chunk->getTileEntity( static_cast(targetX) & 15, static_cast(targetY) & 15, static_cast(targetZ) & 15 ); if ( teCopy != NULL ) { @@ -726,9 +726,9 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l if( e->instanceof(eTYPE_HANGING_ENTITY) ) { - ((IntTag *) eTag->get(L"TileX") )->data -= xStart; - ((IntTag *) eTag->get(L"TileY") )->data -= yStart; - ((IntTag *) eTag->get(L"TileZ") )->data -= zStart; + static_cast(eTag->get(L"TileX"))->data -= xStart; + static_cast(eTag->get(L"TileY"))->data -= yStart; + static_cast(eTag->get(L"TileZ"))->data -= zStart; } entitiesTag->add(eTag); diff --git a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp index f18aa7ae2..9b4d0493c 100644 --- a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp +++ b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp @@ -95,14 +95,14 @@ void GameRuleManager::loadGameRules(DLCPack *pack) if(pack->doesPackContainFile(DLCManager::e_DLCType_LocalisationData,L"languages.loc")) { - DLCLocalisationFile *localisationFile = (DLCLocalisationFile *)pack->getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc"); + DLCLocalisationFile *localisationFile = static_cast(pack->getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc")); strings = localisationFile->getStringTable(); } int gameRulesCount = pack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader); for(int i = 0; i < gameRulesCount; ++i) { - DLCGameRulesHeader *dlcHeader = (DLCGameRulesHeader *)pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i); + DLCGameRulesHeader *dlcHeader = static_cast(pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i)); DWORD dSize; byte *dData = dlcHeader->getData(dSize); @@ -120,7 +120,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack) gameRulesCount = pack->getDLCItemsCount(DLCManager::e_DLCType_GameRules); for (int i = 0; i < gameRulesCount; ++i) { - DLCGameRulesFile *dlcFile = (DLCGameRulesFile *)pack->getFile(DLCManager::e_DLCType_GameRules, i); + DLCGameRulesFile *dlcFile = static_cast(pack->getFile(DLCManager::e_DLCType_GameRules, i)); DWORD dSize; byte *dData = dlcFile->getData(dSize); @@ -182,7 +182,7 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT compr_content(new BYTE[compr_len], compr_len); dis.read(compr_content); - Compression::getCompression()->SetDecompressionType( (Compression::ECompressionTypes)compression_type ); + Compression::getCompression()->SetDecompressionType( static_cast(compression_type) ); Compression::getCompression()->DecompressLZXRLE( content.data, &content.length, compr_content.data, compr_content.length); Compression::getCompression()->SetDecompressionType( SAVE_FILE_PLATFORM_LOCAL ); @@ -469,13 +469,13 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT tagsAndAtts.push_back( contentDis->readUTF() ); unordered_map tagIdMap; - for(int type = (int)ConsoleGameRules::eGameRuleType_Root; type < (int)ConsoleGameRules::eGameRuleType_Count; ++type) + for(int type = (int)ConsoleGameRules::eGameRuleType_Root; type < static_cast(ConsoleGameRules::eGameRuleType_Count); ++type) { for(UINT i = 0; i < numStrings; ++i) { if(tagsAndAtts[i].compare(wchTagNameA[type]) == 0) { - tagIdMap.insert( unordered_map::value_type(i, (ConsoleGameRules::EGameRuleType)type) ); + tagIdMap.insert( unordered_map::value_type(i, static_cast(type)) ); break; } } diff --git a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp index e49ee293d..7232e9c65 100644 --- a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp +++ b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp @@ -145,22 +145,22 @@ GameRuleDefinition *LevelGenerationOptions::addChild(ConsoleGameRules::EGameRule if(ruleType == ConsoleGameRules::eGameRuleType_ApplySchematic) { rule = new ApplySchematicRuleDefinition(this); - m_schematicRules.push_back((ApplySchematicRuleDefinition *)rule); + m_schematicRules.push_back(static_cast(rule)); } else if(ruleType == ConsoleGameRules::eGameRuleType_GenerateStructure) { rule = new ConsoleGenerateStructure(); - m_structureRules.push_back((ConsoleGenerateStructure *)rule); + m_structureRules.push_back(static_cast(rule)); } else if(ruleType == ConsoleGameRules::eGameRuleType_BiomeOverride) { rule = new BiomeOverride(); - m_biomeOverrides.push_back((BiomeOverride *)rule); + m_biomeOverrides.push_back(static_cast(rule)); } else if(ruleType == ConsoleGameRules::eGameRuleType_StartFeature) { rule = new StartFeature(); - m_features.push_back((StartFeature *)rule); + m_features.push_back(static_cast(rule)); } else { @@ -485,7 +485,7 @@ void LevelGenerationOptions::loadBaseSaveData() int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask) { - LevelGenerationOptions *lgo = (LevelGenerationOptions *)pParam; + LevelGenerationOptions *lgo = static_cast(pParam); lgo->m_bLoadingData = false; if(dwErr!=ERROR_SUCCESS) { @@ -499,7 +499,7 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD int gameRulesCount = lgo->m_parentDLCPack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader); for(int i = 0; i < gameRulesCount; ++i) { - DLCGameRulesHeader *dlcFile = (DLCGameRulesHeader *) lgo->m_parentDLCPack->getFile(DLCManager::e_DLCType_GameRulesHeader, i); + DLCGameRulesHeader *dlcFile = static_cast(lgo->m_parentDLCPack->getFile(DLCManager::e_DLCType_GameRulesHeader, i)); if (!dlcFile->getGrfPath().empty()) { diff --git a/Minecraft.Client/Common/GameRules/LevelRuleset.cpp b/Minecraft.Client/Common/GameRules/LevelRuleset.cpp index 658abe91f..b6525b73d 100644 --- a/Minecraft.Client/Common/GameRules/LevelRuleset.cpp +++ b/Minecraft.Client/Common/GameRules/LevelRuleset.cpp @@ -30,7 +30,7 @@ GameRuleDefinition *LevelRuleset::addChild(ConsoleGameRules::EGameRuleType ruleT if(ruleType == ConsoleGameRules::eGameRuleType_NamedArea) { rule = new NamedAreaRuleDefinition(); - m_areas.push_back((NamedAreaRuleDefinition *)rule); + m_areas.push_back(static_cast(rule)); } else { diff --git a/Minecraft.Client/Common/GameRules/StartFeature.cpp b/Minecraft.Client/Common/GameRules/StartFeature.cpp index 904bce734..c2ad23505 100644 --- a/Minecraft.Client/Common/GameRules/StartFeature.cpp +++ b/Minecraft.Client/Common/GameRules/StartFeature.cpp @@ -47,7 +47,7 @@ void StartFeature::addAttribute(const wstring &attributeName, const wstring &att else if(attributeName.compare(L"feature") == 0) { int value = _fromString(attributeValue); - m_feature = (StructureFeature::EFeatureTypes)value; + m_feature = static_cast(value); app.DebugPrintf("StartFeature: Adding parameter feature=%d\n",m_feature); } else diff --git a/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp index ec218c7a9..038ba5c78 100644 --- a/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp @@ -69,7 +69,7 @@ GameRuleDefinition *UpdatePlayerRuleDefinition::addChild(ConsoleGameRules::EGame if(ruleType == ConsoleGameRules::eGameRuleType_AddItem) { rule = new AddItemRuleDefinition(); - m_items.push_back((AddItemRuleDefinition *)rule); + m_items.push_back(static_cast(rule)); } else { diff --git a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp index fa68ef6a4..cd26ad451 100644 --- a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp +++ b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp @@ -37,7 +37,7 @@ GameRuleDefinition *XboxStructureActionPlaceContainer::addChild(ConsoleGameRules if(ruleType == ConsoleGameRules::eGameRuleType_AddItem) { rule = new AddItemRuleDefinition(); - m_items.push_back((AddItemRuleDefinition *)rule); + m_items.push_back(static_cast(rule)); } else { diff --git a/Minecraft.Client/Common/Leaderboards/LeaderboardInterface.cpp b/Minecraft.Client/Common/Leaderboards/LeaderboardInterface.cpp index 07463517a..e93613c18 100644 --- a/Minecraft.Client/Common/Leaderboards/LeaderboardInterface.cpp +++ b/Minecraft.Client/Common/Leaderboards/LeaderboardInterface.cpp @@ -6,7 +6,7 @@ LeaderboardInterface::LeaderboardInterface(LeaderboardManager *man) m_manager = man; m_pending = false; - m_filter = (LeaderboardManager::EFilterMode) -1; + m_filter = static_cast(-1); m_callback = NULL; m_difficulty = 0; m_type = LeaderboardManager::eStatsType_UNDEFINED; diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp index dbae30103..f8d1f0dad 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp @@ -197,7 +197,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame __int64 seed = 0; if(lpParameter != NULL) { - NetworkGameInitData *param = (NetworkGameInitData *)lpParameter; + NetworkGameInitData *param = static_cast(lpParameter); seed = param->seed; app.setLevelGenerationOptions(param->levelGen); @@ -744,7 +744,7 @@ CGameNetworkManager::eJoinGameResult CGameNetworkManager::JoinGame(FriendSession // Make sure that the Primary Pad is in by default localUsersMask |= GetLocalPlayerMask( ProfileManager.GetPrimaryPad() ); - return (eJoinGameResult)(s_pPlatformNetworkManager->JoinGame( searchResult, localUsersMask, primaryUserIndex )); + return static_cast(s_pPlatformNetworkManager->JoinGame(searchResult, localUsersMask, primaryUserIndex)); } void CGameNetworkManager::CancelJoinGame(LPVOID lpParam) @@ -762,7 +762,7 @@ bool CGameNetworkManager::LeaveGame(bool bMigrateHost) int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContinue, int iPad) { - INVITE_INFO * pInviteInfo = (INVITE_INFO *)pParam; + INVITE_INFO * pInviteInfo = static_cast(pParam); if(bContinue==true) { @@ -932,7 +932,7 @@ int CGameNetworkManager::ServerThreadProc( void* lpParameter ) __int64 seed = 0; if(lpParameter != NULL) { - NetworkGameInitData *param = (NetworkGameInitData *)lpParameter; + NetworkGameInitData *param = static_cast(lpParameter); seed = param->seed; app.SetGameHostOption(eGameHostOption_All,param->settings); @@ -988,7 +988,7 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc( void* lpParam ) // Xbox should always be online when receiving invites - on PS3 we need to check & ask the user to sign in #if !defined(__PS3__) && !defined(__PSVITA__) - JoinFromInviteData *inviteData = (JoinFromInviteData *)lpParam; + JoinFromInviteData *inviteData = static_cast(lpParam); app.SetAction(inviteData->dwUserIndex, eAppAction_JoinFromInvite, lpParam); #else if(ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())) diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp index 85531e472..0f79fd855 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp @@ -23,7 +23,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer ) bool createFakeSocket = false; bool localPlayer = false; - NetworkPlayerXbox *networkPlayer = (NetworkPlayerXbox *)addNetworkPlayer(pQNetPlayer); + NetworkPlayerXbox *networkPlayer = static_cast(addNetworkPlayer(pQNetPlayer)); if( pQNetPlayer->IsLocal() ) { @@ -540,7 +540,7 @@ void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pN int CPlatformNetworkManagerStub::RemovePlayerOnSocketClosedThreadProc( void* lpParam ) { - INetworkPlayer *pNetworkPlayer = (INetworkPlayer *)lpParam; + INetworkPlayer *pNetworkPlayer = static_cast(lpParam); Socket *socket = pNetworkPlayer->GetSocket(); @@ -667,7 +667,7 @@ wstring CPlatformNetworkManagerStub::GatherRTTStats() for(unsigned int i = 0; i < GetPlayerCount(); ++i) { - IQNetPlayer *pQNetPlayer = ((NetworkPlayerXbox *)GetPlayerByIndex( i ))->GetQNetPlayer(); + IQNetPlayer *pQNetPlayer = static_cast(GetPlayerByIndex(i))->GetQNetPlayer(); if(!pQNetPlayer->IsLocal()) { @@ -711,7 +711,7 @@ void CPlatformNetworkManagerStub::SearchForGames() size_t nameLen = wcslen(lanSessions[i].hostName); info->displayLabel = new wchar_t[nameLen + 1]; wcscpy_s(info->displayLabel, nameLen + 1, lanSessions[i].hostName); - info->displayLabelLength = (unsigned char)nameLen; + info->displayLabelLength = static_cast(nameLen); info->displayLabelViewableStartIndex = 0; info->data.netVersion = lanSessions[i].netVersion; @@ -726,7 +726,7 @@ void CPlatformNetworkManagerStub::SearchForGames() info->data.playerCount = lanSessions[i].playerCount; info->data.maxPlayers = lanSessions[i].maxPlayers; - info->sessionId = (SessionID)((unsigned __int64)inet_addr(lanSessions[i].hostIP) | ((unsigned __int64)lanSessions[i].hostPort << 32)); + info->sessionId = (SessionID)(static_cast(inet_addr(lanSessions[i].hostIP)) | (static_cast(lanSessions[i].hostPort) << 32)); friendsSessions[0].push_back(info); } @@ -766,7 +766,7 @@ void CPlatformNetworkManagerStub::SearchForGames() size_t nameLen = wcslen(label); info->displayLabel = new wchar_t[nameLen+1]; wcscpy_s(info->displayLabel, nameLen + 1, label); - info->displayLabelLength = (unsigned char)nameLen; + info->displayLabelLength = static_cast(nameLen); info->displayLabelViewableStartIndex = 0; info->data.isReadyToJoin = true; info->data.isJoinable = true; @@ -780,7 +780,7 @@ void CPlatformNetworkManagerStub::SearchForGames() std::fclose(file); } - m_searchResultsCount[0] = (int)friendsSessions[0].size(); + m_searchResultsCount[0] = static_cast(friendsSessions[0].size()); if (m_SessionsUpdatedCallback != NULL) m_SessionsUpdatedCallback(m_pSearchParam); diff --git a/Minecraft.Client/Common/Network/Sony/NetworkPlayerSony.cpp b/Minecraft.Client/Common/Network/Sony/NetworkPlayerSony.cpp index a7a4628b1..9b44418f7 100644 --- a/Minecraft.Client/Common/Network/Sony/NetworkPlayerSony.cpp +++ b/Minecraft.Client/Common/Network/Sony/NetworkPlayerSony.cpp @@ -16,12 +16,12 @@ unsigned char NetworkPlayerSony::GetSmallId() void NetworkPlayerSony::SendData(INetworkPlayer *player, const void *pvData, int dataSize, bool lowPriority, bool ack) { // TODO - handle priority - m_sqrPlayer->SendData( ((NetworkPlayerSony *)player)->m_sqrPlayer, pvData, dataSize, ack ); + m_sqrPlayer->SendData( static_cast(player)->m_sqrPlayer, pvData, dataSize, ack ); } bool NetworkPlayerSony::IsSameSystem(INetworkPlayer *player) { - return m_sqrPlayer->IsSameSystem(((NetworkPlayerSony *)player)->m_sqrPlayer); + return m_sqrPlayer->IsSameSystem(static_cast(player)->m_sqrPlayer); } int NetworkPlayerSony::GetOutstandingAckCount() @@ -133,5 +133,5 @@ int NetworkPlayerSony::GetTimeSinceLastChunkPacket_ms() } __int64 currentTime = System::currentTimeMillis(); - return (int)( currentTime - m_lastChunkPacketTime ); + return static_cast(currentTime - m_lastChunkPacketTime); } diff --git a/Minecraft.Client/Common/Network/Sony/SQRNetworkPlayer.h b/Minecraft.Client/Common/Network/Sony/SQRNetworkPlayer.h index d0efe635d..397e2c008 100644 --- a/Minecraft.Client/Common/Network/Sony/SQRNetworkPlayer.h +++ b/Minecraft.Client/Common/Network/Sony/SQRNetworkPlayer.h @@ -63,7 +63,7 @@ class SQRNetworkPlayer public: DataPacketHeader() : m_dataSize(0), m_ackFlags(e_flag_AckUnknown) {} DataPacketHeader(int dataSize, AckFlags ackFlags) : m_dataSize(dataSize), m_ackFlags(ackFlags) { } - AckFlags GetAckFlags() { return (AckFlags)m_ackFlags;} + AckFlags GetAckFlags() { return static_cast(m_ackFlags);} int GetDataSize() { return m_dataSize; } }; diff --git a/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.cpp b/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.cpp index 4468d163a..6ea168c3e 100644 --- a/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.cpp +++ b/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.cpp @@ -39,13 +39,13 @@ static SceRemoteStorageStatus statParams; void SonyRemoteStorage::SetRetrievedDescData() { DescriptionData* pDescDataTest = (DescriptionData*)m_remoteFileInfo->fileDescription; - ESavePlatform testPlatform = (ESavePlatform)MAKE_FOURCC(pDescDataTest->m_platform[0], pDescDataTest->m_platform[1], pDescDataTest->m_platform[2], pDescDataTest->m_platform[3]); + ESavePlatform testPlatform = static_cast(MAKE_FOURCC(pDescDataTest->m_platform[0], pDescDataTest->m_platform[1], pDescDataTest->m_platform[2], pDescDataTest->m_platform[3])); if(testPlatform == SAVE_FILE_PLATFORM_NONE) { // new version of the descData DescriptionData_V2* pDescData2 = (DescriptionData_V2*)m_remoteFileInfo->fileDescription; m_retrievedDescData.m_descDataVersion = GetU32FromHexBytes(pDescData2->m_descDataVersion); - m_retrievedDescData.m_savePlatform = (ESavePlatform)MAKE_FOURCC(pDescData2->m_platform[0], pDescData2->m_platform[1], pDescData2->m_platform[2], pDescData2->m_platform[3]); + m_retrievedDescData.m_savePlatform = static_cast(MAKE_FOURCC(pDescData2->m_platform[0], pDescData2->m_platform[1], pDescData2->m_platform[2], pDescData2->m_platform[3])); m_retrievedDescData.m_seed = GetU64FromHexBytes(pDescData2->m_seed); m_retrievedDescData.m_hostOptions = GetU32FromHexBytes(pDescData2->m_hostOptions); m_retrievedDescData.m_texturePack = GetU32FromHexBytes(pDescData2->m_texturePack); @@ -58,7 +58,7 @@ void SonyRemoteStorage::SetRetrievedDescData() // old version,copy the data across to the new version DescriptionData* pDescData = (DescriptionData*)m_remoteFileInfo->fileDescription; m_retrievedDescData.m_descDataVersion = 1; - m_retrievedDescData.m_savePlatform = (ESavePlatform)MAKE_FOURCC(pDescData->m_platform[0], pDescData->m_platform[1], pDescData->m_platform[2], pDescData->m_platform[3]); + m_retrievedDescData.m_savePlatform = static_cast(MAKE_FOURCC(pDescData->m_platform[0], pDescData->m_platform[1], pDescData->m_platform[2], pDescData->m_platform[3])); m_retrievedDescData.m_seed = GetU64FromHexBytes(pDescData->m_seed); m_retrievedDescData.m_hostOptions = GetU32FromHexBytes(pDescData->m_hostOptions); m_retrievedDescData.m_texturePack = GetU32FromHexBytes(pDescData->m_texturePack); @@ -73,7 +73,7 @@ void SonyRemoteStorage::SetRetrievedDescData() void getSaveInfoReturnCallback(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code) { - SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam; + SonyRemoteStorage* pRemoteStorage = static_cast(lpParam); app.DebugPrintf("remoteStorageGetInfoCallback err : 0x%08x\n", error_code); if(error_code == 0) { @@ -99,7 +99,7 @@ void getSaveInfoReturnCallback(LPVOID lpParam, SonyRemoteStorage::Status s, int static void getSaveInfoInitCallback(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code) { - SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam; + SonyRemoteStorage* pRemoteStorage = static_cast(lpParam); if(error_code != 0) { app.DebugPrintf("getSaveInfoInitCallback err : 0x%08x\n", error_code); @@ -143,7 +143,7 @@ bool SonyRemoteStorage::getSaveData( const char* localDirname, CallbackFunc cb, static void setSaveDataInitCallback(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code) { - SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam; + SonyRemoteStorage* pRemoteStorage = static_cast(lpParam); if(error_code != 0) { app.DebugPrintf("setSaveDataInitCallback err : 0x%08x\n", error_code); @@ -244,7 +244,7 @@ bool SonyRemoteStorage::setData( PSAVE_INFO info, CallbackFunc cb, LPVOID lpPara int SonyRemoteStorage::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) { - SonyRemoteStorage *pClass= (SonyRemoteStorage *)lpParam; + SonyRemoteStorage *pClass= static_cast(lpParam); if(pClass->m_bAborting) { @@ -277,7 +277,7 @@ int SonyRemoteStorage::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThum int SonyRemoteStorage::setDataThread(void* lpParam) { - SonyRemoteStorage* pClass = (SonyRemoteStorage*)lpParam; + SonyRemoteStorage* pClass = static_cast(lpParam); pClass->m_startTime = System::currentTimeMillis(); pClass->setDataInternal(); return 0; @@ -322,8 +322,8 @@ int SonyRemoteStorage::getDataProgress() __int64 time = System::currentTimeMillis(); int elapsedSecs = (time - m_startTime) / 1000; - float estimatedTransfered = float(elapsedSecs * transferRatePerSec); - int progVal = m_dataProgress + (estimatedTransfered / float(totalSize)) * 100; + float estimatedTransfered = static_cast(elapsedSecs * transferRatePerSec); + int progVal = m_dataProgress + (estimatedTransfered / static_cast(totalSize)) * 100; if(progVal > nextChunk) return nextChunk; if(progVal > 99) diff --git a/Minecraft.Client/Common/Telemetry/TelemetryManager.cpp b/Minecraft.Client/Common/Telemetry/TelemetryManager.cpp index 4b04b19c1..cc47e9287 100644 --- a/Minecraft.Client/Common/Telemetry/TelemetryManager.cpp +++ b/Minecraft.Client/Common/Telemetry/TelemetryManager.cpp @@ -148,7 +148,7 @@ This should be tracked independently of saved games (restoring a save should not */ INT CTelemetryManager::GetSecondsSinceInitialize() { - return (INT)(app.getAppTime() - m_initialiseTime); + return static_cast(app.getAppTime() - m_initialiseTime); } /* @@ -171,15 +171,15 @@ INT CTelemetryManager::GetMode(DWORD dwUserId) if (gameType->isSurvival()) { - mode = (INT)eTelem_ModeId_Survival; + mode = static_cast(eTelem_ModeId_Survival); } else if (gameType->isCreative()) { - mode = (INT)eTelem_ModeId_Creative; + mode = static_cast(eTelem_ModeId_Creative); } else { - mode = (INT)eTelem_ModeId_Undefined; + mode = static_cast(eTelem_ModeId_Undefined); } } return mode; @@ -198,11 +198,11 @@ INT CTelemetryManager::GetSubMode(DWORD dwUserId) if(Minecraft::GetInstance()->isTutorial()) { - subMode = (INT)eTelem_SubModeId_Tutorial; + subMode = static_cast(eTelem_SubModeId_Tutorial); } else { - subMode = (INT)eTelem_SubModeId_Normal; + subMode = static_cast(eTelem_SubModeId_Normal); } return subMode; @@ -220,7 +220,7 @@ INT CTelemetryManager::GetLevelId(DWORD dwUserId) { INT levelId = (INT)eTelem_LevelId_Undefined; - levelId = (INT)eTelem_LevelId_PlayerGeneratedLevel; + levelId = static_cast(eTelem_LevelId_PlayerGeneratedLevel); return levelId; } @@ -242,13 +242,13 @@ INT CTelemetryManager::GetSubLevelId(DWORD dwUserId) switch(pMinecraft->localplayers[dwUserId]->dimension) { case 0: - subLevelId = (INT)eTelem_SubLevelId_Overworld; + subLevelId = static_cast(eTelem_SubLevelId_Overworld); break; case -1: - subLevelId = (INT)eTelem_SubLevelId_Nether; + subLevelId = static_cast(eTelem_SubLevelId_Nether); break; case 1: - subLevelId = (INT)eTelem_SubLevelId_End; + subLevelId = static_cast(eTelem_SubLevelId_End); break; }; } @@ -272,7 +272,7 @@ Helps differentiate level attempts when a play plays the same mode/level - espec */ INT CTelemetryManager::GetLevelInstanceID() { - return (INT)m_levelInstanceID; + return static_cast(m_levelInstanceID); } /* @@ -314,19 +314,19 @@ INT CTelemetryManager::GetSingleOrMultiplayer() if(app.GetLocalPlayerCount() == 1 && g_NetworkManager.GetOnlinePlayerCount() == 0) { - singleOrMultiplayer = (INT)eSen_SingleOrMultiplayer_Single_Player; + singleOrMultiplayer = static_cast(eSen_SingleOrMultiplayer_Single_Player); } else if(app.GetLocalPlayerCount() > 1 && g_NetworkManager.GetOnlinePlayerCount() == 0) { - singleOrMultiplayer = (INT)eSen_SingleOrMultiplayer_Multiplayer_Local; + singleOrMultiplayer = static_cast(eSen_SingleOrMultiplayer_Multiplayer_Local); } else if(app.GetLocalPlayerCount() == 1 && g_NetworkManager.GetOnlinePlayerCount() > 0) { - singleOrMultiplayer = (INT)eSen_SingleOrMultiplayer_Multiplayer_Live; + singleOrMultiplayer = static_cast(eSen_SingleOrMultiplayer_Multiplayer_Live); } else if(app.GetLocalPlayerCount() > 1 && g_NetworkManager.GetOnlinePlayerCount() > 0) { - singleOrMultiplayer = (INT)eSen_SingleOrMultiplayer_Multiplayer_Both_Local_and_Live; + singleOrMultiplayer = static_cast(eSen_SingleOrMultiplayer_Multiplayer_Both_Local_and_Live); } return singleOrMultiplayer; @@ -343,16 +343,16 @@ INT CTelemetryManager::GetDifficultyLevel(INT diff) switch(diff) { case 0: - difficultyLevel = (INT)eSen_DifficultyLevel_Easiest; + difficultyLevel = static_cast(eSen_DifficultyLevel_Easiest); break; case 1: - difficultyLevel = (INT)eSen_DifficultyLevel_Easier; + difficultyLevel = static_cast(eSen_DifficultyLevel_Easier); break; case 2: - difficultyLevel = (INT)eSen_DifficultyLevel_Normal; + difficultyLevel = static_cast(eSen_DifficultyLevel_Normal); break; case 3: - difficultyLevel = (INT)eSen_DifficultyLevel_Harder; + difficultyLevel = static_cast(eSen_DifficultyLevel_Harder); break; } @@ -372,11 +372,11 @@ INT CTelemetryManager::GetLicense() if(ProfileManager.IsFullVersion()) { - license = (INT)eSen_License_Full_Purchased_Title; + license = static_cast(eSen_License_Full_Purchased_Title); } else { - license = (INT)eSen_License_Trial_or_Demo; + license = static_cast(eSen_License_Trial_or_Demo); } return license; } @@ -411,15 +411,15 @@ INT CTelemetryManager::GetAudioSettings(DWORD dwUserId) if(volume == 0) { - audioSettings = (INT)eSen_AudioSettings_Off; + audioSettings = static_cast(eSen_AudioSettings_Off); } else if(volume == DEFAULT_VOLUME_LEVEL) { - audioSettings = (INT)eSen_AudioSettings_On_Default; + audioSettings = static_cast(eSen_AudioSettings_On_Default); } else { - audioSettings = (INT)eSen_AudioSettings_On_CustomSetting; + audioSettings = static_cast(eSen_AudioSettings_On_CustomSetting); } } return audioSettings; diff --git a/Minecraft.Client/Common/Tutorial/RideEntityTask.cpp b/Minecraft.Client/Common/Tutorial/RideEntityTask.cpp index 29fe592d5..29b776453 100644 --- a/Minecraft.Client/Common/Tutorial/RideEntityTask.cpp +++ b/Minecraft.Client/Common/Tutorial/RideEntityTask.cpp @@ -23,7 +23,7 @@ bool RideEntityTask::isCompleted() void RideEntityTask::onRideEntity(shared_ptr entity) { - if (entity->instanceof((eINSTANCEOF) m_eType)) + if (entity->instanceof(static_cast(m_eType))) { bIsCompleted = true; } diff --git a/Minecraft.Client/Common/Tutorial/StatTask.cpp b/Minecraft.Client/Common/Tutorial/StatTask.cpp index 5f8b215e3..e06db393c 100644 --- a/Minecraft.Client/Common/Tutorial/StatTask.cpp +++ b/Minecraft.Client/Common/Tutorial/StatTask.cpp @@ -20,6 +20,6 @@ bool StatTask::isCompleted() return true; Minecraft *minecraft = Minecraft::GetInstance(); - bIsCompleted = minecraft->stats[ProfileManager.GetPrimaryPad()]->getTotalValue( stat ) >= (unsigned int)targetValue; + bIsCompleted = minecraft->stats[ProfileManager.GetPrimaryPad()]->getTotalValue( stat ) >= static_cast(targetValue); return bIsCompleted; } \ No newline at end of file diff --git a/Minecraft.Client/Common/Tutorial/Tutorial.cpp b/Minecraft.Client/Common/Tutorial/Tutorial.cpp index 60feba11e..e46555cd9 100644 --- a/Minecraft.Client/Common/Tutorial/Tutorial.cpp +++ b/Minecraft.Client/Common/Tutorial/Tutorial.cpp @@ -1173,7 +1173,7 @@ void Tutorial::debugResetPlayerSavedProgress(int iPad) #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(iPad); #else - GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)ProfileManager.GetGameDefinedProfileData(iPad); + GAME_SETTINGS *pGameSettings = static_cast(ProfileManager.GetGameDefinedProfileData(iPad)); #endif ZeroMemory( pGameSettings->ucTutorialCompletion, TUTORIAL_PROFILE_STORAGE_BYTES ); pGameSettings->uiSpecialTutorialBitmask = 0; @@ -1202,7 +1202,7 @@ void Tutorial::setCompleted( int completableId ) #if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(m_iPad); #else - GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)ProfileManager.GetGameDefinedProfileData(m_iPad); + GAME_SETTINGS *pGameSettings = static_cast(ProfileManager.GetGameDefinedProfileData(m_iPad)); #endif int arrayIndex = completableIndex >> 3; int bitIndex = 7 - (completableIndex % 8); @@ -1235,7 +1235,7 @@ bool Tutorial::getCompleted( int completableId ) #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(m_iPad); #else - GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)ProfileManager.GetGameDefinedProfileData(m_iPad); + GAME_SETTINGS *pGameSettings = static_cast(ProfileManager.GetGameDefinedProfileData(m_iPad)); #endif int arrayIndex = completableIndex >> 3; int bitIndex = 7 - (completableIndex % 8); diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp index 882584211..41dc28c87 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -296,8 +296,8 @@ void IUIScene_AbstractContainerMenu::onMouseTick() int iPad = getPad(); bool bStickInput = false; - float fInputX = InputManager.GetJoypadStick_LX( iPad, false )*((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InMenu)/100.0f); // apply the sensitivity - float fInputY = InputManager.GetJoypadStick_LY( iPad, false )*((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InMenu)/100.0f); // apply the sensitivity + float fInputX = InputManager.GetJoypadStick_LX( iPad, false )*(static_cast(app.GetGameSettings(iPad, eGameSetting_Sensitivity_InMenu))/100.0f); // apply the sensitivity + float fInputY = InputManager.GetJoypadStick_LY( iPad, false )*(static_cast(app.GetGameSettings(iPad, eGameSetting_Sensitivity_InMenu))/100.0f); // apply the sensitivity #ifdef __ORBIS__ // should have sensitivity for the touchpad @@ -406,7 +406,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() if ( m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_SCALING ) { ++m_iConsectiveInputTicks; - fInputScale = ( (float)( m_iConsectiveInputTicks) / (float)(MAX_INPUT_TICKS_FOR_SCALING) ); + fInputScale = ( static_cast(m_iConsectiveInputTicks) / static_cast((MAX_INPUT_TICKS_FOR_SCALING)) ); } #ifdef TAP_DETECTION else if ( m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_TAPPING ) @@ -494,11 +494,11 @@ void IUIScene_AbstractContainerMenu::onMouseTick() if (winW > 0 && winH > 0) { - float scaleX = (float)getMovieWidth() / (float)winW; - float scaleY = (float)getMovieHeight() / (float)winH; + float scaleX = static_cast(getMovieWidth()) / static_cast(winW); + float scaleY = static_cast(getMovieHeight()) / static_cast(winH); - vPointerPos.x += (float)deltaX * scaleX; - vPointerPos.y += (float)deltaY * scaleY; + vPointerPos.x += static_cast(deltaX) * scaleX; + vPointerPos.y += static_cast(deltaY) * scaleY; } if (deltaX != 0 || deltaY != 0) @@ -527,7 +527,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() } else if ( eSectionUnderPointer == eSectionNone ) { - ESceneSection eSection = ( ESceneSection )( iSection ); + ESceneSection eSection = static_cast(iSection); // Get position of this section. UIVec2D sectionPos; @@ -1309,9 +1309,9 @@ void IUIScene_AbstractContainerMenu::onMouseTick() } vPointerPos.x = floor(vPointerPos.x); - vPointerPos.x += ( (int)vPointerPos.x%2); + vPointerPos.x += ( static_cast(vPointerPos.x)%2); vPointerPos.y = floor(vPointerPos.y); - vPointerPos.y += ( (int)vPointerPos.y%2); + vPointerPos.y += ( static_cast(vPointerPos.y)%2); m_pointerPos = vPointerPos; adjustPointerForSafeZone(); @@ -1525,7 +1525,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b message->m_iAuxVal = item->getAuxValue(); message->m_forceDisplay = true; - TutorialMode *gameMode = (TutorialMode *)Minecraft::GetInstance()->localgameModes[iPad]; + TutorialMode *gameMode = static_cast(Minecraft::GetInstance()->localgameModes[iPad]); gameMode->getTutorial()->setMessage(NULL, message); ui.PlayUISFX(eSFX_Press); } diff --git a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp index fc012be3f..e0d8472a1 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp @@ -620,7 +620,7 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() */ RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - int iRecipeC=(int)recipes->size(); + int iRecipeC=static_cast(recipes->size()); auto itRecipe = recipes->begin(); // dump out the recipe products diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 0d3f7dace..efe19ce9d 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -1040,7 +1040,7 @@ bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, BOOL qu { m_menu->getSlot(i)->set(nullptr); // call this function to synchronize multiplayer item bar - pMinecraft->localgameModes[iPad]->handleCreativeModeItemAdd(nullptr, i - (int)m_menu->slots.size() + 9 + InventoryMenu::USE_ROW_SLOT_START); + pMinecraft->localgameModes[iPad]->handleCreativeModeItemAdd(nullptr, i - static_cast(m_menu->slots.size()) + 9 + InventoryMenu::USE_ROW_SLOT_START); } } return true; @@ -1082,8 +1082,8 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction) // Fall through intentional case ACTION_MENU_RIGHT_SCROLL: { - ECreativeInventoryTabs tab = (ECreativeInventoryTabs)(m_curTab + dir); - if (tab < 0) tab = (ECreativeInventoryTabs)(eCreativeInventoryTab_COUNT - 1); + ECreativeInventoryTabs tab = static_cast(m_curTab + dir); + if (tab < 0) tab = static_cast(eCreativeInventoryTab_COUNT - 1); if (tab >= eCreativeInventoryTab_COUNT) tab = eCreativeInventoryTab_BuildingBlocks; switchTab(tab); ui.PlayUISFX(eSFX_Focus); @@ -1188,7 +1188,7 @@ void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, int bu m_menu->clicked(currentIndex, buttonNum, quickKeyHeld?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, pMinecraft->localplayers[getPad()]); shared_ptr newItem = m_menu->getSlot(currentIndex)->getItem(); // call this function to synchronize multiplayer item bar - pMinecraft->localgameModes[getPad()]->handleCreativeModeItemAdd(newItem, currentIndex - (int)m_menu->slots.size() + 9 + InventoryMenu::USE_ROW_SLOT_START); + pMinecraft->localgameModes[getPad()]->handleCreativeModeItemAdd(newItem, currentIndex - static_cast(m_menu->slots.size()) + 9 + InventoryMenu::USE_ROW_SLOT_START); if(m_bCarryingCreativeItem) { @@ -1370,7 +1370,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector > *lis expTags->add(expTag); fireTag->put(FireworksItem::TAG_EXPLOSIONS, expTags); - fireTag->putByte(FireworksItem::TAG_FLIGHT, (byte) sulphur); + fireTag->putByte(FireworksItem::TAG_FLIGHT, static_cast(sulphur)); itemTag->put(FireworksItem::TAG_FIREWORKS, fireTag); diff --git a/Minecraft.Client/Common/UI/IUIScene_EnchantingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_EnchantingMenu.cpp index c73f7dc5c..fbbf7c24f 100644 --- a/Minecraft.Client/Common/UI/IUIScene_EnchantingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_EnchantingMenu.cpp @@ -181,5 +181,5 @@ bool IUIScene_EnchantingMenu::IsSectionSlotList( ESceneSection eSection ) EnchantmentMenu *IUIScene_EnchantingMenu::getMenu() { - return (EnchantmentMenu *)m_menu; + return static_cast(m_menu); } \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp index 03adbd2c2..294816ed6 100644 --- a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp @@ -146,8 +146,8 @@ void IUIScene_HUD::updateFrameTick() { if(uiOpacityTimer<10) { - float fStep=(80.0f-(float)ucAlpha)/10.0f; - fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + float fStep=(80.0f-static_cast(ucAlpha))/10.0f; + fVal=0.01f*(80.0f-((10.0f-static_cast(uiOpacityTimer))*fStep)); } else { @@ -156,7 +156,7 @@ void IUIScene_HUD::updateFrameTick() } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } } else @@ -166,7 +166,7 @@ void IUIScene_HUD::updateFrameTick() { ucAlpha=15; } - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } SetOpacity(fVal); @@ -198,7 +198,7 @@ void IUIScene_HUD::renderPlayerHealth() bool bHasPoison = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::poison); bool bHasWither = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::wither); AttributeInstance *maxHealthAttribute = pMinecraft->localplayers[iPad]->getAttribute(SharedMonsterAttributes::MAX_HEALTH); - float maxHealth = (float)maxHealthAttribute->getValue(); + float maxHealth = static_cast(maxHealthAttribute->getValue()); float totalAbsorption = pMinecraft->localplayers[iPad]->getAbsorptionAmount(); // Update armour @@ -242,8 +242,8 @@ void IUIScene_HUD::renderPlayerHealth() if (pMinecraft->localplayers[iPad]->isUnderLiquid(Material::water)) { ShowAir(true); - int count = (int) ceil((pMinecraft->localplayers[iPad]->getAirSupply() - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY); - int extra = (int) ceil((pMinecraft->localplayers[iPad]->getAirSupply()) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count; + int count = static_cast(ceil((pMinecraft->localplayers[iPad]->getAirSupply() - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY)); + int extra = static_cast(ceil((pMinecraft->localplayers[iPad]->getAirSupply()) * 10.0f / Player::TOTAL_AIR_SUPPLY)) - count; SetAir(count, extra); } else @@ -254,7 +254,7 @@ void IUIScene_HUD::renderPlayerHealth() else if(riding->instanceof(eTYPE_LIVINGENTITY) ) { shared_ptr living = dynamic_pointer_cast(riding); - int riderCurrentHealth = (int) ceil(living->getHealth()); + int riderCurrentHealth = static_cast(ceil(living->getHealth())); float maxRiderHealth = living->getMaxHealth(); SetRidingHorse(true, pMinecraft->localplayers[iPad]->isRidingJumpable(), maxRiderHealth); diff --git a/Minecraft.Client/Common/UI/IUIScene_PauseMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_PauseMenu.cpp index ab1767d4f..852928785 100644 --- a/Minecraft.Client/Common/UI/IUIScene_PauseMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_PauseMenu.cpp @@ -52,7 +52,7 @@ int IUIScene_PauseMenu::ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStor if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) @@ -352,7 +352,7 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4 int IUIScene_PauseMenu::SaveWorldThreadProc( LPVOID lpParameter ) { - bool bAutosave=(bool)lpParameter; + bool bAutosave=static_cast(lpParameter); if(bAutosave) { app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_AutoSaveGame); diff --git a/Minecraft.Client/Common/UI/IUIScene_StartGame.cpp b/Minecraft.Client/Common/UI/IUIScene_StartGame.cpp index d3a9e8f08..08be958aa 100644 --- a/Minecraft.Client/Common/UI/IUIScene_StartGame.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_StartGame.cpp @@ -123,7 +123,7 @@ void IUIScene_StartGame::HandleDLCMountingComplete() void IUIScene_StartGame::handleSelectionChanged(F64 selectedId) { - m_iSetTexturePackDescription = (int)selectedId; + m_iSetTexturePackDescription = static_cast(selectedId); if(!m_texturePackDescDisplayed) { @@ -254,7 +254,7 @@ void IUIScene_StartGame::UpdateCurrentTexturePack(int iSlot) int IUIScene_StartGame::TrialTexturePackWarningReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - IUIScene_StartGame* pScene = (IUIScene_StartGame*)pParam; + IUIScene_StartGame* pScene = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { @@ -269,7 +269,7 @@ int IUIScene_StartGame::TrialTexturePackWarningReturned(void *pParam,int iPad,C4 int IUIScene_StartGame::UnlockTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - IUIScene_StartGame* pScene = (IUIScene_StartGame*)pParam; + IUIScene_StartGame* pScene = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { @@ -311,7 +311,7 @@ int IUIScene_StartGame::UnlockTexturePackReturned(void *pParam,int iPad,C4JStora int IUIScene_StartGame::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - IUIScene_StartGame *pClass = (IUIScene_StartGame *)pParam; + IUIScene_StartGame *pClass = static_cast(pParam); #ifdef _XBOX diff --git a/Minecraft.Client/Common/UI/UIBitmapFont.cpp b/Minecraft.Client/Common/UI/UIBitmapFont.cpp index afc2b1392..98c19dc87 100644 --- a/Minecraft.Client/Common/UI/UIBitmapFont.cpp +++ b/Minecraft.Client/Common/UI/UIBitmapFont.cpp @@ -53,42 +53,42 @@ void UIAbstractBitmapFont::registerFont() IggyFontMetrics * RADLINK UIAbstractBitmapFont::GetFontMetrics_Callback(void *user_context,IggyFontMetrics *metrics) { - return ((UIAbstractBitmapFont *) user_context)->GetFontMetrics(metrics); + return static_cast(user_context)->GetFontMetrics(metrics); } S32 RADLINK UIAbstractBitmapFont::GetCodepointGlyph_Callback(void *user_context,U32 codepoint) { - return ((UIAbstractBitmapFont *) user_context)->GetCodepointGlyph(codepoint); + return static_cast(user_context)->GetCodepointGlyph(codepoint); } IggyGlyphMetrics * RADLINK UIAbstractBitmapFont::GetGlyphMetrics_Callback(void *user_context,S32 glyph,IggyGlyphMetrics *metrics) { - return ((UIAbstractBitmapFont *) user_context)->GetGlyphMetrics(glyph,metrics); + return static_cast(user_context)->GetGlyphMetrics(glyph,metrics); } rrbool RADLINK UIAbstractBitmapFont::IsGlyphEmpty_Callback(void *user_context,S32 glyph) { - return ((UIAbstractBitmapFont *) user_context)->IsGlyphEmpty(glyph); + return static_cast(user_context)->IsGlyphEmpty(glyph); } F32 RADLINK UIAbstractBitmapFont::GetKerningForGlyphPair_Callback(void *user_context,S32 first_glyph,S32 second_glyph) { - return ((UIAbstractBitmapFont *) user_context)->GetKerningForGlyphPair(first_glyph,second_glyph); + return static_cast(user_context)->GetKerningForGlyphPair(first_glyph,second_glyph); } rrbool RADLINK UIAbstractBitmapFont::CanProvideBitmap_Callback(void *user_context,S32 glyph,F32 pixel_scale) { - return ((UIAbstractBitmapFont *) user_context)->CanProvideBitmap(glyph,pixel_scale); + return static_cast(user_context)->CanProvideBitmap(glyph,pixel_scale); } rrbool RADLINK UIAbstractBitmapFont::GetGlyphBitmap_Callback(void *user_context,S32 glyph,F32 pixel_scale,IggyBitmapCharacter *bitmap) { - return ((UIAbstractBitmapFont *) user_context)->GetGlyphBitmap(glyph,pixel_scale,bitmap); + return static_cast(user_context)->GetGlyphBitmap(glyph,pixel_scale,bitmap); } void RADLINK UIAbstractBitmapFont::FreeGlyphBitmap_Callback(void *user_context,S32 glyph,F32 pixel_scale,IggyBitmapCharacter *bitmap) { - return ((UIAbstractBitmapFont *) user_context)->FreeGlyphBitmap(glyph,pixel_scale,bitmap); + return static_cast(user_context)->FreeGlyphBitmap(glyph,pixel_scale,bitmap); } UIBitmapFont::UIBitmapFont( SFontData &sfontdata ) @@ -321,7 +321,7 @@ rrbool UIBitmapFont::GetGlyphBitmap(S32 glyph,F32 pixel_scale,IggyBitmapCharacte // 4J-PB - this was chopping off the top of the characters, so accented ones were losing a couple of pixels at the top // DaveK has reduced the height of the accented capitalised characters, and we've dropped this from 0.65 to 0.64 - bitmap->top_left_y = -((S32) m_cFontData->getFontData()->m_uiGlyphHeight) * m_cFontData->getFontData()->m_fAscent; + bitmap->top_left_y = -static_cast(m_cFontData->getFontData()->m_uiGlyphHeight) * m_cFontData->getFontData()->m_fAscent; bitmap->oversample = 0; bitmap->point_sample = true; diff --git a/Minecraft.Client/Common/UI/UIComponent_Chat.cpp b/Minecraft.Client/Common/UI/UIComponent_Chat.cpp index 98b4f1654..49999255f 100644 --- a/Minecraft.Client/Common/UI/UIComponent_Chat.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_Chat.cpp @@ -96,15 +96,15 @@ void UIComponent_Chat::render(S32 width, S32 height, C4JRender::eViewportType vi { case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - yPos = (S32)(ui.getScreenHeight() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); - yPos = (S32)(ui.getScreenHeight() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; } ui.setupRenderPosition(xPos, yPos); @@ -118,14 +118,14 @@ void UIComponent_Chat::render(S32 width, S32 height, C4JRender::eViewportType vi { case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - tileHeight = (S32)(ui.getScreenHeight()); + tileHeight = static_cast(ui.getScreenHeight()); break; case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - tileWidth = (S32)(ui.getScreenWidth()); + tileWidth = static_cast(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - tileWidth = (S32)(ui.getScreenWidth()); + tileWidth = static_cast(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: diff --git a/Minecraft.Client/Common/UI/UIComponent_DebugUIMarketingGuide.cpp b/Minecraft.Client/Common/UI/UIComponent_DebugUIMarketingGuide.cpp index 240429bc5..3aab5b983 100644 --- a/Minecraft.Client/Common/UI/UIComponent_DebugUIMarketingGuide.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_DebugUIMarketingGuide.cpp @@ -10,7 +10,7 @@ UIComponent_DebugUIMarketingGuide::UIComponent_DebugUIMarketingGuide(int iPad, v IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; - value[0].number = (F64)0; // WIN64 + value[0].number = static_cast(0); // WIN64 #if defined _XBOX value[0].number = (F64)1; #elif defined _DURANGO @@ -22,7 +22,7 @@ UIComponent_DebugUIMarketingGuide::UIComponent_DebugUIMarketingGuide(int iPad, v #elif defined __PSVITA__ value[0].number = (F64)5; #elif defined _WINDOWS64 - value[0].number = (F64)0; + value[0].number = static_cast(0); #endif IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetPlatform , 1 , value ); } diff --git a/Minecraft.Client/Common/UI/UIComponent_MenuBackground.cpp b/Minecraft.Client/Common/UI/UIComponent_MenuBackground.cpp index d3a4c4c00..1718e8cb8 100644 --- a/Minecraft.Client/Common/UI/UIComponent_MenuBackground.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_MenuBackground.cpp @@ -42,15 +42,15 @@ void UIComponent_MenuBackground::render(S32 width, S32 height, C4JRender::eViewp { case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - yPos = (S32)(ui.getScreenHeight() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); - yPos = (S32)(ui.getScreenHeight() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; } ui.setupRenderPosition(xPos, yPos); @@ -64,14 +64,14 @@ void UIComponent_MenuBackground::render(S32 width, S32 height, C4JRender::eViewp { case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - tileHeight = (S32)(ui.getScreenHeight()); + tileHeight = static_cast(ui.getScreenHeight()); break; case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - tileWidth = (S32)(ui.getScreenWidth()); + tileWidth = static_cast(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - tileWidth = (S32)(ui.getScreenWidth()); + tileWidth = static_cast(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: diff --git a/Minecraft.Client/Common/UI/UIComponent_Panorama.cpp b/Minecraft.Client/Common/UI/UIComponent_Panorama.cpp index cb6443a17..6a0065034 100644 --- a/Minecraft.Client/Common/UI/UIComponent_Panorama.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_Panorama.cpp @@ -85,10 +85,10 @@ void UIComponent_Panorama::render(S32 width, S32 height, C4JRender::eViewportTyp switch( viewport ) { case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - yPos = (S32)(ui.getScreenHeight() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); break; } ui.setupRenderPosition(xPos, yPos); @@ -99,7 +99,7 @@ void UIComponent_Panorama::render(S32 width, S32 height, C4JRender::eViewportTyp S32 tileXStart = 0; S32 tileYStart = 0; S32 tileWidth = width; - S32 tileHeight = (S32)(ui.getScreenHeight()); + S32 tileHeight = static_cast(ui.getScreenHeight()); IggyPlayerSetDisplaySize( getMovie(), m_movieWidth, m_movieHeight ); diff --git a/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp b/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp index 255740c9a..9b672939d 100644 --- a/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp @@ -154,8 +154,8 @@ void UIComponent_Tooltips::tick() { if(uiOpacityTimer<10) { - float fStep=(80.0f-(float)ucAlpha)/10.0f; - fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + float fStep=(80.0f-static_cast(ucAlpha))/10.0f; + fVal=0.01f*(80.0f-((10.0f-static_cast(uiOpacityTimer))*fStep)); } else { @@ -164,7 +164,7 @@ void UIComponent_Tooltips::tick() } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } } else @@ -174,7 +174,7 @@ void UIComponent_Tooltips::tick() { ucAlpha=15; } - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } setOpacity(fVal); @@ -206,15 +206,15 @@ void UIComponent_Tooltips::render(S32 width, S32 height, C4JRender::eViewportTyp { case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - yPos = (S32)(ui.getScreenHeight() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); - yPos = (S32)(ui.getScreenHeight() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; } ui.setupRenderPosition(xPos, yPos); @@ -228,14 +228,14 @@ void UIComponent_Tooltips::render(S32 width, S32 height, C4JRender::eViewportTyp { case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - tileHeight = (S32)(ui.getScreenHeight()); + tileHeight = static_cast(ui.getScreenHeight()); break; case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - tileWidth = (S32)(ui.getScreenWidth()); + tileWidth = static_cast(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - tileWidth = (S32)(ui.getScreenWidth()); + tileWidth = static_cast(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: diff --git a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp index 3b4eb097f..01f124bd8 100644 --- a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp @@ -219,13 +219,13 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, m_iconItem = nullptr; wstring openTag(L"{*ICON*}"); wstring closeTag(L"{*/ICON*}"); - int iconTagStartPos = (int)temp.find(openTag); - int iconStartPos = iconTagStartPos + (int)openTag.length(); - if( iconTagStartPos > 0 && iconStartPos < (int)temp.length() ) + int iconTagStartPos = static_cast(temp.find(openTag)); + int iconStartPos = iconTagStartPos + static_cast(openTag.length()); + if( iconTagStartPos > 0 && iconStartPos < static_cast(temp.length()) ) { - int iconEndPos = (int)temp.find( closeTag, iconStartPos ); + int iconEndPos = static_cast(temp.find(closeTag, iconStartPos)); - if(iconEndPos > iconStartPos && iconEndPos < (int)temp.length() ) + if(iconEndPos > iconStartPos && iconEndPos < static_cast(temp.length()) ) { wstring id = temp.substr(iconStartPos, iconEndPos - iconStartPos); @@ -479,20 +479,20 @@ void UIComponent_TutorialPopup::render(S32 width, S32 height, C4JRender::eViewpo switch( viewport ) { case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - xPos = (S32)(ui.getScreenWidth() / 2); - yPos = (S32)(ui.getScreenHeight() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - yPos = (S32)(ui.getScreenHeight() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); - yPos = (S32)(ui.getScreenHeight() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; } //Adjust for safezone @@ -538,7 +538,7 @@ void UIComponent_TutorialPopup::setupIconHolder(EIcons icon) IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; - value[0].number = (F64)icon; + value[0].number = static_cast(icon); IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetupIconHolder , 1 , value ); m_iconType = icon; diff --git a/Minecraft.Client/Common/UI/UIControl.cpp b/Minecraft.Client/Common/UI/UIControl.cpp index be267ada6..cbbbf7cac 100644 --- a/Minecraft.Client/Common/UI/UIControl.cpp +++ b/Minecraft.Client/Common/UI/UIControl.cpp @@ -34,10 +34,10 @@ bool UIControl::setupControl(UIScene *scene, IggyValuePath *parent, const string IggyValueGetF64RS( getIggyValuePath() , m_nameWidth , NULL , &fwidth ); IggyValueGetF64RS( getIggyValuePath() , m_nameHeight , NULL , &fheight ); - m_x = (S32)fx; - m_y = (S32)fy; - m_width = (S32)Math::round(fwidth); - m_height = (S32)Math::round(fheight); + m_x = static_cast(fx); + m_y = static_cast(fy); + m_width = static_cast(Math::round(fwidth)); + m_height = static_cast(Math::round(fheight)); return res; } @@ -49,10 +49,10 @@ void UIControl::UpdateControl() IggyValueGetF64RS( getIggyValuePath() , m_nameYPos , NULL , &fy ); IggyValueGetF64RS( getIggyValuePath() , m_nameWidth , NULL , &fwidth ); IggyValueGetF64RS( getIggyValuePath() , m_nameHeight , NULL , &fheight ); - m_x = (S32)fx; - m_y = (S32)fy; - m_width = (S32)Math::round(fwidth); - m_height = (S32)Math::round(fheight); + m_x = static_cast(fx); + m_y = static_cast(fy); + m_width = static_cast(Math::round(fwidth)); + m_height = static_cast(Math::round(fheight)); } void UIControl::ReInit() diff --git a/Minecraft.Client/Common/UI/UIControl_Base.cpp b/Minecraft.Client/Common/UI/UIControl_Base.cpp index 7a4a24e5e..743aaa92b 100644 --- a/Minecraft.Client/Common/UI/UIControl_Base.cpp +++ b/Minecraft.Client/Common/UI/UIControl_Base.cpp @@ -90,7 +90,7 @@ void UIControl_Base::setAllPossibleLabels(int labelCount, wchar_t labels[][256]) for(unsigned int i = 0; i < labelCount; ++i) { - stringVal[i].string = (IggyUTF16 *)labels[i]; + stringVal[i].string = static_cast(labels[i]); stringVal[i].length = wcslen(labels[i]); value[i].type = IGGY_DATATYPE_string_UTF16; value[i].string16 = stringVal[i]; diff --git a/Minecraft.Client/Common/UI/UIControl_ButtonList.cpp b/Minecraft.Client/Common/UI/UIControl_ButtonList.cpp index 68a3d655a..9591be9cf 100644 --- a/Minecraft.Client/Common/UI/UIControl_ButtonList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_ButtonList.cpp @@ -82,7 +82,7 @@ void UIControl_ButtonList::addItem(const string &label, int data) IggyStringUTF8 stringVal; stringVal.string = (char*)label.c_str(); - stringVal.length = (S32)label.length(); + stringVal.length = static_cast(label.length()); value[0].type = IGGY_DATATYPE_string_UTF8; value[0].string8 = stringVal; diff --git a/Minecraft.Client/Common/UI/UIControl_DLCList.cpp b/Minecraft.Client/Common/UI/UIControl_DLCList.cpp index 35e6b08a4..39f8ff39a 100644 --- a/Minecraft.Client/Common/UI/UIControl_DLCList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_DLCList.cpp @@ -20,7 +20,7 @@ void UIControl_DLCList::addItem(const string &label, bool showTick, int iId) IggyStringUTF8 stringVal; stringVal.string = (char*)label.c_str(); - stringVal.length = (S32)label.length(); + stringVal.length = static_cast(label.length()); value[0].type = IGGY_DATATYPE_string_UTF8; value[0].string8 = stringVal; @@ -41,7 +41,7 @@ void UIControl_DLCList::addItem(const wstring &label, bool showTick, int iId) IggyStringUTF16 stringVal; stringVal.string = (IggyUTF16 *)label.c_str(); - stringVal.length = (S32)label.length(); + stringVal.length = static_cast(label.length()); value[0].type = IGGY_DATATYPE_string_UTF16; value[0].string16 = stringVal; diff --git a/Minecraft.Client/Common/UI/UIControl_DynamicLabel.cpp b/Minecraft.Client/Common/UI/UIControl_DynamicLabel.cpp index fa29a1375..ab2d5a44a 100644 --- a/Minecraft.Client/Common/UI/UIControl_DynamicLabel.cpp +++ b/Minecraft.Client/Common/UI/UIControl_DynamicLabel.cpp @@ -79,7 +79,7 @@ S32 UIControl_DynamicLabel::GetRealWidth() S32 iRealWidth = m_width; if(result.type == IGGY_DATATYPE_number) { - iRealWidth = (S32)result.number; + iRealWidth = static_cast(result.number); } return iRealWidth; } @@ -92,7 +92,7 @@ S32 UIControl_DynamicLabel::GetRealHeight() S32 iRealHeight = m_height; if(result.type == IGGY_DATATYPE_number) { - iRealHeight = (S32)result.number; + iRealHeight = static_cast(result.number); } return iRealHeight; } \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIControl_EnchantmentBook.cpp b/Minecraft.Client/Common/UI/UIControl_EnchantmentBook.cpp index 9664dbf4f..b8b41c3d0 100644 --- a/Minecraft.Client/Common/UI/UIControl_EnchantmentBook.cpp +++ b/Minecraft.Client/Common/UI/UIControl_EnchantmentBook.cpp @@ -73,7 +73,7 @@ void UIControl_EnchantmentBook::render(IggyCustomDrawCallbackRegion *region) { // Share the model the the EnchantTableRenderer - EnchantTableRenderer *etr = (EnchantTableRenderer*)TileEntityRenderDispatcher::instance->getRenderer(eTYPE_ENCHANTMENTTABLEENTITY); + EnchantTableRenderer *etr = static_cast(TileEntityRenderDispatcher::instance->getRenderer(eTYPE_ENCHANTMENTTABLEENTITY)); if(etr != NULL) { model = etr->bookModel; @@ -96,7 +96,7 @@ void UIControl_EnchantmentBook::render(IggyCustomDrawCallbackRegion *region) void UIControl_EnchantmentBook::tickBook() { - UIScene_EnchantingMenu *m_containerScene = (UIScene_EnchantingMenu *)m_parentScene; + UIScene_EnchantingMenu *m_containerScene = static_cast(m_parentScene); EnchantmentMenu *menu = m_containerScene->getMenu(); shared_ptr current = menu->getSlot(0)->getItem(); if (!ItemInstance::matches(current, last)) diff --git a/Minecraft.Client/Common/UI/UIControl_EnchantmentButton.cpp b/Minecraft.Client/Common/UI/UIControl_EnchantmentButton.cpp index f1e2735ae..156f98156 100644 --- a/Minecraft.Client/Common/UI/UIControl_EnchantmentButton.cpp +++ b/Minecraft.Client/Common/UI/UIControl_EnchantmentButton.cpp @@ -55,7 +55,7 @@ void UIControl_EnchantmentButton::tick() void UIControl_EnchantmentButton::render(IggyCustomDrawCallbackRegion *region) { - UIScene_EnchantingMenu *enchantingScene = (UIScene_EnchantingMenu *)m_parentScene; + UIScene_EnchantingMenu *enchantingScene = static_cast(m_parentScene); EnchantmentMenu *menu = enchantingScene->getMenu(); float width = region->x1 - region->x0; @@ -108,7 +108,7 @@ void UIControl_EnchantmentButton::render(IggyCustomDrawCallbackRegion *region) if (pMinecraft->localplayers[enchantingScene->getPad()]->experienceLevel < cost && !pMinecraft->localplayers[enchantingScene->getPad()]->abilities.instabuild) { col = m_textDisabledColour; - font->drawWordWrap(m_enchantmentString, 0, 0, (float)m_width/ss, col, (float)m_height/ss); + font->drawWordWrap(m_enchantmentString, 0, 0, static_cast(m_width)/ss, col, static_cast(m_height)/ss); font = pMinecraft->font; //col = (0x80ff20 & 0xfefefe) >> 1; //font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col); @@ -120,7 +120,7 @@ void UIControl_EnchantmentButton::render(IggyCustomDrawCallbackRegion *region) //col = 0xffff80; col = m_textFocusColour; } - font->drawWordWrap(m_enchantmentString, 0, 0, (float)m_width/ss, col, (float)m_height/ss); + font->drawWordWrap(m_enchantmentString, 0, 0, static_cast(m_width)/ss, col, static_cast(m_height)/ss); font = pMinecraft->font; //col = 0x80ff20; //font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col); @@ -137,7 +137,7 @@ void UIControl_EnchantmentButton::render(IggyCustomDrawCallbackRegion *region) void UIControl_EnchantmentButton::updateState() { - UIScene_EnchantingMenu *enchantingScene = (UIScene_EnchantingMenu *)m_parentScene; + UIScene_EnchantingMenu *enchantingScene = static_cast(m_parentScene); EnchantmentMenu *menu = enchantingScene->getMenu(); EState state = eState_Inactive; @@ -182,7 +182,7 @@ void UIControl_EnchantmentButton::updateState() IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; - value[0].number = (int)state; + value[0].number = static_cast(state); IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcChangeState , 1 , value ); if(out == IGGY_RESULT_SUCCESS) m_lastState = state; diff --git a/Minecraft.Client/Common/UI/UIControl_HTMLLabel.cpp b/Minecraft.Client/Common/UI/UIControl_HTMLLabel.cpp index 8b7eb9a1f..1e2e85993 100644 --- a/Minecraft.Client/Common/UI/UIControl_HTMLLabel.cpp +++ b/Minecraft.Client/Common/UI/UIControl_HTMLLabel.cpp @@ -84,7 +84,7 @@ S32 UIControl_HTMLLabel::GetRealWidth() S32 iRealWidth = m_width; if(result.type == IGGY_DATATYPE_number) { - iRealWidth = (S32)result.number; + iRealWidth = static_cast(result.number); } return iRealWidth; } @@ -97,7 +97,7 @@ S32 UIControl_HTMLLabel::GetRealHeight() S32 iRealHeight = m_height; if(result.type == IGGY_DATATYPE_number) { - iRealHeight = (S32)result.number; + iRealHeight = static_cast(result.number); } return iRealHeight; } \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIControl_MinecraftHorse.cpp b/Minecraft.Client/Common/UI/UIControl_MinecraftHorse.cpp index 457e20286..25fc0316d 100644 --- a/Minecraft.Client/Common/UI/UIControl_MinecraftHorse.cpp +++ b/Minecraft.Client/Common/UI/UIControl_MinecraftHorse.cpp @@ -27,10 +27,10 @@ UIControl_MinecraftHorse::UIControl_MinecraftHorse() Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); } void UIControl_MinecraftHorse::render(IggyCustomDrawCallbackRegion *region) @@ -49,7 +49,7 @@ void UIControl_MinecraftHorse::render(IggyCustomDrawCallbackRegion *region) glTranslatef(xo, yo - (height / 7.5f), 50.0f); //UIScene_InventoryMenu *containerMenu = (UIScene_InventoryMenu *)m_parentScene; - UIScene_HorseInventoryMenu *containerMenu = (UIScene_HorseInventoryMenu *)m_parentScene; + UIScene_HorseInventoryMenu *containerMenu = static_cast(m_parentScene); shared_ptr entityHorse = containerMenu->m_horse; diff --git a/Minecraft.Client/Common/UI/UIControl_MinecraftPlayer.cpp b/Minecraft.Client/Common/UI/UIControl_MinecraftPlayer.cpp index d0625bce8..ae65ac2b5 100644 --- a/Minecraft.Client/Common/UI/UIControl_MinecraftPlayer.cpp +++ b/Minecraft.Client/Common/UI/UIControl_MinecraftPlayer.cpp @@ -19,10 +19,10 @@ UIControl_MinecraftPlayer::UIControl_MinecraftPlayer() Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); } void UIControl_MinecraftPlayer::render(IggyCustomDrawCallbackRegion *region) @@ -49,7 +49,7 @@ void UIControl_MinecraftPlayer::render(IggyCustomDrawCallbackRegion *region) glScalef(-ss, ss, ss); glRotatef(180, 0, 0, 1); - UIScene_InventoryMenu *containerMenu = (UIScene_InventoryMenu *)m_parentScene; + UIScene_InventoryMenu *containerMenu = static_cast(m_parentScene); float oybr = pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot; float oyr = pMinecraft->localplayers[containerMenu->getPad()]->yRot; diff --git a/Minecraft.Client/Common/UI/UIControl_PlayerList.cpp b/Minecraft.Client/Common/UI/UIControl_PlayerList.cpp index 41534dc23..0703919fb 100644 --- a/Minecraft.Client/Common/UI/UIControl_PlayerList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_PlayerList.cpp @@ -21,7 +21,7 @@ void UIControl_PlayerList::addItem(const wstring &label, int iPlayerIcon, int iV IggyStringUTF16 stringVal; stringVal.string = (IggyUTF16*)label.c_str(); - stringVal.length = (S32)label.length(); + stringVal.length = static_cast(label.length()); value[0].type = IGGY_DATATYPE_string_UTF16; value[0].string16 = stringVal; diff --git a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp index d74bd185c..b03c858f5 100644 --- a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp +++ b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp @@ -23,10 +23,10 @@ UIControl_PlayerSkinPreview::UIControl_PlayerSkinPreview() Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); m_customTextureUrl = L"default"; m_backupTexture = TN_MOB_CHAR; @@ -167,7 +167,7 @@ void UIControl_PlayerSkinPreview::SetFacing(ESkinPreviewFacing facing, bool bAni void UIControl_PlayerSkinPreview::CycleNextAnimation() { - m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation + 1); + m_currentAnimation = static_cast(m_currentAnimation + 1); if(m_currentAnimation >= e_SkinPreviewAnimation_Count) m_currentAnimation = e_SkinPreviewAnimation_Walking; m_swingTime = 0.0f; @@ -175,8 +175,8 @@ void UIControl_PlayerSkinPreview::CycleNextAnimation() void UIControl_PlayerSkinPreview::CyclePreviousAnimation() { - m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation - 1); - if(m_currentAnimation < e_SkinPreviewAnimation_Walking) m_currentAnimation = (ESkinPreviewAnimations)(e_SkinPreviewAnimation_Count - 1); + m_currentAnimation = static_cast(m_currentAnimation - 1); + if(m_currentAnimation < e_SkinPreviewAnimation_Walking) m_currentAnimation = static_cast(e_SkinPreviewAnimation_Count - 1); m_swingTime = 0.0f; } @@ -210,7 +210,7 @@ void UIControl_PlayerSkinPreview::render(IggyCustomDrawCallbackRegion *region) Lighting::turnOn(); //glRotatef(-45 - 90, 0, 1, 0); - glRotatef(-(float)m_xRot, 1, 0, 0); + glRotatef(-static_cast(m_xRot), 1, 0, 0); // 4J Stu - Turning on hideGui while we do this stops the name rendering in split-screen bool wasHidingGui = pMinecraft->options->hideGui; @@ -257,7 +257,7 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou glPushMatrix(); glDisable(GL_CULL_FACE); - HumanoidModel *model = (HumanoidModel *)renderer->getModel(); + HumanoidModel *model = static_cast(renderer->getModel()); //getAttackAnim(mob, a); //if (armor != NULL) armor->attackTime = model->attackTime; @@ -292,7 +292,7 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou { m_swingTime = 0; } - model->attackTime = m_swingTime / (float) (Player::SWING_DURATION * 3); + model->attackTime = m_swingTime / static_cast(Player::SWING_DURATION * 3); break; default: break; @@ -306,7 +306,7 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou //setupPosition(mob, x, y, z); // is equivalent to - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); //float bob = getBob(mob, a); #ifdef SKIN_PREVIEW_BOB_ANIM @@ -383,11 +383,11 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou double xa = sin(yr * PI / 180); double za = -cos(yr * PI / 180); - float flap = (float) yd * 10; + float flap = static_cast(yd) * 10; if (flap < -6) flap = -6; if (flap > 32) flap = 32; - float lean = (float) (xd * xa + zd * za) * 100; - float lean2 = (float) (xd * za - zd * xa) * 100; + float lean = static_cast(xd * xa + zd * za) * 100; + float lean2 = static_cast(xd * za - zd * xa) * 100; if (lean < 0) lean = 0; //float pow = 1;//mob->oBob + (bob - mob->oBob) * a; diff --git a/Minecraft.Client/Common/UI/UIControl_Progress.cpp b/Minecraft.Client/Common/UI/UIControl_Progress.cpp index 78e7c1d0c..20dc1ff7e 100644 --- a/Minecraft.Client/Common/UI/UIControl_Progress.cpp +++ b/Minecraft.Client/Common/UI/UIControl_Progress.cpp @@ -53,7 +53,7 @@ void UIControl_Progress::setProgress(int current) { m_current = current; - float percent = (float)((m_current-m_min))/(m_max-m_min); + float percent = static_cast((m_current - m_min))/(m_max-m_min); if(percent != m_lastPercent) { diff --git a/Minecraft.Client/Common/UI/UIControl_SaveList.cpp b/Minecraft.Client/Common/UI/UIControl_SaveList.cpp index f83454d73..5ae9c8f05 100644 --- a/Minecraft.Client/Common/UI/UIControl_SaveList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_SaveList.cpp @@ -52,7 +52,7 @@ void UIControl_SaveList::addItem(const string &label, const wstring &iconName, i IggyStringUTF8 stringVal; stringVal.string = (char*)label.c_str(); - stringVal.length = (S32)label.length(); + stringVal.length = static_cast(label.length()); value[0].type = IGGY_DATATYPE_string_UTF8; value[0].string8 = stringVal; @@ -74,7 +74,7 @@ void UIControl_SaveList::addItem(const wstring &label, const wstring &iconName, IggyStringUTF16 stringVal; stringVal.string = (IggyUTF16*)label.c_str(); - stringVal.length = (S32)label.length(); + stringVal.length = static_cast(label.length()); value[0].type = IGGY_DATATYPE_string_UTF16; value[0].string16 = stringVal; diff --git a/Minecraft.Client/Common/UI/UIControl_Slider.cpp b/Minecraft.Client/Common/UI/UIControl_Slider.cpp index c21680029..7f8a8180f 100644 --- a/Minecraft.Client/Common/UI/UIControl_Slider.cpp +++ b/Minecraft.Client/Common/UI/UIControl_Slider.cpp @@ -97,7 +97,7 @@ S32 UIControl_Slider::GetRealWidth() S32 iRealWidth = m_width; if(result.type == IGGY_DATATYPE_number) { - iRealWidth = (S32)result.number; + iRealWidth = static_cast(result.number); } return iRealWidth; } diff --git a/Minecraft.Client/Common/UI/UIControl_SpaceIndicatorBar.cpp b/Minecraft.Client/Common/UI/UIControl_SpaceIndicatorBar.cpp index 74683a62e..5d6b8d57d 100644 --- a/Minecraft.Client/Common/UI/UIControl_SpaceIndicatorBar.cpp +++ b/Minecraft.Client/Common/UI/UIControl_SpaceIndicatorBar.cpp @@ -63,7 +63,7 @@ void UIControl_SpaceIndicatorBar::reset() void UIControl_SpaceIndicatorBar::addSave(__int64 size) { - float startPercent = (float)((m_currentTotal-m_min))/(m_max-m_min); + float startPercent = static_cast((m_currentTotal - m_min))/(m_max-m_min); m_sizeAndOffsets.push_back( pair<__int64, float>(size, startPercent) ); @@ -90,7 +90,7 @@ void UIControl_SpaceIndicatorBar::setSaveSize(__int64 size) { m_currentSave = size; - float percent = (float)((m_currentSave-m_min))/(m_max-m_min); + float percent = static_cast((m_currentSave - m_min))/(m_max-m_min); IggyDataValue result; IggyDataValue value[1]; @@ -101,7 +101,7 @@ void UIControl_SpaceIndicatorBar::setSaveSize(__int64 size) void UIControl_SpaceIndicatorBar::setTotalSize(__int64 size) { - float percent = (float)((m_currentTotal-m_min))/(m_max-m_min); + float percent = static_cast((m_currentTotal - m_min))/(m_max-m_min); IggyDataValue result; IggyDataValue value[1]; diff --git a/Minecraft.Client/Common/UI/UIControl_TexturePackList.cpp b/Minecraft.Client/Common/UI/UIControl_TexturePackList.cpp index 02336e004..8e81ac28b 100644 --- a/Minecraft.Client/Common/UI/UIControl_TexturePackList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_TexturePackList.cpp @@ -125,7 +125,7 @@ bool UIControl_TexturePackList::CanTouchTrigger(S32 iX, S32 iY) S32 bCanTouchTrigger = false; if(result.type == IGGY_DATATYPE_boolean) { - bCanTouchTrigger = (bool)result.boolval; + bCanTouchTrigger = static_cast(result.boolval); } return bCanTouchTrigger; } @@ -138,7 +138,7 @@ S32 UIControl_TexturePackList::GetRealHeight() S32 iRealHeight = m_height; if(result.type == IGGY_DATATYPE_number) { - iRealHeight = (S32)result.number; + iRealHeight = static_cast(result.number); } return iRealHeight; } diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 5375b784d..8d558d4a8 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -65,7 +65,7 @@ static UIControl_Slider *FindSliderById(UIScene *pScene, int sliderId) { UIControl *ctrl = (*controls)[i]; if (ctrl && ctrl->getControlType() == UIControl::eSlider && ctrl->getId() == sliderId) - return (UIControl_Slider *)ctrl; + return static_cast(ctrl); } return NULL; } @@ -147,7 +147,7 @@ __int64 UIController::iggyAllocCount = 0; static unordered_map allocations; static void * RADLINK AllocateFunction ( void * alloc_callback_user_data , size_t size_requested , size_t * size_returned ) { - UIController *controller = (UIController *)alloc_callback_user_data; + UIController *controller = static_cast(alloc_callback_user_data); EnterCriticalSection(&controller->m_Allocatorlock); #ifdef EXCLUDE_IGGY_ALLOCATIONS_FROM_HEAP_INSPECTOR void *alloc = __real_malloc(size_requested); @@ -164,7 +164,7 @@ static void * RADLINK AllocateFunction ( void * alloc_callback_user_data , size_ static void RADLINK DeallocateFunction ( void * alloc_callback_user_data , void * ptr ) { - UIController *controller = (UIController *)alloc_callback_user_data; + UIController *controller = static_cast(alloc_callback_user_data); EnterCriticalSection(&controller->m_Allocatorlock); size_t size = allocations[ptr]; UIController::iggyAllocCount -= size; @@ -267,7 +267,7 @@ void UIController::SetSysUIShowing(bool bVal) void UIController::SetSystemUIShowing(LPVOID lpParam,bool bVal) { - UIController *pClass=(UIController *)lpParam; + UIController *pClass=static_cast(lpParam); pClass->SetSysUIShowing(bVal); } @@ -307,7 +307,7 @@ void UIController::postInit() for(unsigned int i = 0; i < eUIGroup_COUNT; ++i) { - m_groups[i] = new UIGroup((EUIGroup)i,i-1); + m_groups[i] = new UIGroup(static_cast(i),i-1); } @@ -689,7 +689,7 @@ void UIController::StartReloadSkinThread() int UIController::reloadSkinThreadProc(void* lpParam) { EnterCriticalSection(&ms_reloadSkinCS); // MGH - added to prevent crash loading Iggy movies while the skins were being reloaded - UIController *controller = (UIController *)lpParam; + UIController *controller = static_cast(lpParam); // Load new skin controller->loadSkins(); @@ -802,8 +802,8 @@ void UIController::tickInput() Iggy *movie = pScene->getMovie(); int rawMouseX = g_KBMInput.GetMouseX(); int rawMouseY = g_KBMInput.GetMouseY(); - F32 mouseX = (F32)rawMouseX; - F32 mouseY = (F32)rawMouseY; + F32 mouseX = static_cast(rawMouseX); + F32 mouseY = static_cast(rawMouseY); extern HWND g_hWnd; if (g_hWnd) @@ -814,8 +814,8 @@ void UIController::tickInput() int winH = rc.bottom - rc.top; if (winW > 0 && winH > 0) { - mouseX = mouseX * (m_fScreenWidth / (F32)winW); - mouseY = mouseY * (m_fScreenHeight / (F32)winH); + mouseX = mouseX * (m_fScreenWidth / static_cast(winW)); + mouseY = mouseY * (m_fScreenHeight / static_cast(winH)); } } @@ -861,8 +861,8 @@ void UIController::tickInput() pScene->GetParentLayer()->getRenderDimensions(displayWidth, displayHeight); if (displayWidth > 0 && displayHeight > 0) { - sceneMouseX = mouseX * ((F32)pScene->getRenderWidth() / (F32)displayWidth); - sceneMouseY = mouseY * ((F32)pScene->getRenderHeight() / (F32)displayHeight); + sceneMouseX = mouseX * (static_cast(pScene->getRenderWidth()) / static_cast(displayWidth)); + sceneMouseY = mouseY * (static_cast(pScene->getRenderHeight()) / static_cast(displayHeight)); } } @@ -896,7 +896,7 @@ void UIController::tickInput() if (!ctrl || ctrl->getControlType() != UIControl::eSlider || !ctrl->getVisible()) continue; - UIControl_Slider *pSlider = (UIControl_Slider *)ctrl; + UIControl_Slider *pSlider = static_cast(ctrl); pSlider->UpdateControl(); S32 cx = pSlider->getXPos() + panelOffsetX; S32 cy = pSlider->getYPos() + panelOffsetY; @@ -925,7 +925,7 @@ void UIController::tickInput() S32 sliderWidth = pSlider->GetRealWidth(); if (sliderWidth > 0) { - float fNewSliderPos = (sceneMouseX - (float)sliderX) / (float)sliderWidth; + float fNewSliderPos = (sceneMouseX - static_cast(sliderX)) / static_cast(sliderWidth); if (fNewSliderPos < 0.0f) fNewSliderPos = 0.0f; if (fNewSliderPos > 1.0f) fNewSliderPos = 1.0f; pSlider->SetSliderTouchPos(fNewSliderPos); @@ -1347,7 +1347,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) bool handled = false; // Send the key to the fullscreen group first - m_groups[(int)eUIGroup_Fullscreen]->handleInput(iPad, key, repeat, pressed, released, handled); + m_groups[static_cast(eUIGroup_Fullscreen)]->handleInput(iPad, key, repeat, pressed, released, handled); if(!handled) { // If it's not been handled yet, then pass the event onto the players specific group @@ -1358,7 +1358,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) rrbool RADLINK UIController::ExternalFunctionCallback( void * user_callback_data , Iggy * player , IggyExternalFunctionCallUTF16 * call) { - UIScene *scene = (UIScene *)IggyPlayerGetUserdata(player); + UIScene *scene = static_cast(IggyPlayerGetUserdata(player)); if(scene != NULL) { @@ -1425,25 +1425,25 @@ void UIController::getRenderDimensions(C4JRender::eViewportType viewport, S32 &w switch( viewport ) { case C4JRender::VIEWPORT_TYPE_FULLSCREEN: - width = (S32)(getScreenWidth()); - height = (S32)(getScreenHeight()); + width = static_cast(getScreenWidth()); + height = static_cast(getScreenHeight()); break; case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - width = (S32)(getScreenWidth() / 2); - height = (S32)(getScreenHeight() / 2); + width = static_cast(getScreenWidth() / 2); + height = static_cast(getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - width = (S32)(getScreenWidth() / 2); - height = (S32)(getScreenHeight() / 2); + width = static_cast(getScreenWidth() / 2); + height = static_cast(getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - width = (S32)(getScreenWidth() / 2); - height = (S32)(getScreenHeight() / 2); + width = static_cast(getScreenWidth() / 2); + height = static_cast(getScreenHeight() / 2); break; } } @@ -1459,30 +1459,30 @@ void UIController::setupRenderPosition(C4JRender::eViewportType viewport) switch( viewport ) { case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - xPos = (S32)(getScreenWidth() / 4); + xPos = static_cast(getScreenWidth() / 4); break; case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - xPos = (S32)(getScreenWidth() / 4); - yPos = (S32)(getScreenHeight() / 2); + xPos = static_cast(getScreenWidth() / 4); + yPos = static_cast(getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: - yPos = (S32)(getScreenHeight() / 4); + yPos = static_cast(getScreenHeight() / 4); break; case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - xPos = (S32)(getScreenWidth() / 2); - yPos = (S32)(getScreenHeight() / 4); + xPos = static_cast(getScreenWidth() / 2); + yPos = static_cast(getScreenHeight() / 4); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - xPos = (S32)(getScreenWidth() / 2); + xPos = static_cast(getScreenWidth() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - yPos = (S32)(getScreenHeight() / 2); + yPos = static_cast(getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - xPos = (S32)(getScreenWidth() / 2); - yPos = (S32)(getScreenHeight() / 2); + xPos = static_cast(getScreenWidth() / 2); + yPos = static_cast(getScreenHeight() / 2); break; } m_tileOriginX = xPos; @@ -1547,8 +1547,8 @@ void UIController::setupCustomDrawMatrices(UIScene *scene, CustomDrawData *custo Minecraft *pMinecraft=Minecraft::GetInstance(); // Clear just the region required for this control. - float sceneWidth = (float)scene->getRenderWidth(); - float sceneHeight = (float)scene->getRenderHeight(); + float sceneWidth = static_cast(scene->getRenderWidth()); + float sceneHeight = static_cast(scene->getRenderHeight()); LONG left, right, top, bottom; #ifdef __PS3__ @@ -1578,8 +1578,8 @@ void UIController::setupCustomDrawMatrices(UIScene *scene, CustomDrawData *custo Minecraft *pMinecraft=Minecraft::GetInstance(); if(pMinecraft != NULL) { - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fScreenHeight=(float)pMinecraft->height_phys; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fScreenHeight=static_cast(pMinecraft->height_phys); m_bScreenWidthSetup = true; } } @@ -1623,7 +1623,7 @@ void UIController::endCustomDrawGameStateAndMatrices() void RADLINK UIController::CustomDrawCallback(void *user_callback_data, Iggy *player, IggyCustomDrawCallbackRegion *region) { - UIScene *scene = (UIScene *)IggyPlayerGetUserdata(player); + UIScene *scene = static_cast(IggyPlayerGetUserdata(player)); if(scene != NULL) { @@ -1670,7 +1670,7 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void * #endif *destroy_callback_data = (void *)id; - app.DebugPrintf("Found substitution texture %ls (%d) - %dx%d\n", (wchar_t *)texture_name, id, image.getWidth(), image.getHeight()); + app.DebugPrintf("Found substitution texture %ls (%d) - %dx%d\n", static_cast(texture_name), id, image.getWidth(), image.getHeight()); return ui.getSubstitutionTexture(id); } else @@ -1680,7 +1680,7 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void * } else { - app.DebugPrintf("Could not find substitution texture %ls\n", (wchar_t *)texture_name); + app.DebugPrintf("Could not find substitution texture %ls\n", static_cast(texture_name)); return NULL; } } @@ -1691,7 +1691,7 @@ void RADLINK UIController::TextureSubstitutionDestroyCallback ( void * user_call { // Orbis complains about casting a pointer to an int LONGLONG llVal=(LONGLONG)destroy_callback_data; - int id=(int)llVal; + int id=static_cast(llVal); app.DebugPrintf("Destroying iggy texture %d\n", id); ui.destroySubstitutionTexture(user_callback_data, handle); @@ -1791,7 +1791,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI if( ( iPad != 255 ) && ( iPad >= 0 ) ) { menuDisplayedPad = iPad; - group = (EUIGroup)(iPad+1); + group = static_cast(iPad + 1); } else group = eUIGroup_Fullscreen; } @@ -1806,7 +1806,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI EnterCriticalSection(&m_navigationLock); SetMenuDisplayed(menuDisplayedPad,true); - bool success = m_groups[(int)group]->NavigateToScene(iPad, scene, initData, layer); + bool success = m_groups[static_cast(group)]->NavigateToScene(iPad, scene, initData, layer); if(success && group == eUIGroup_Fullscreen) setFullscreenMenuDisplayed(true); LeaveCriticalSection(&m_navigationLock); @@ -1821,18 +1821,18 @@ bool UIController::NavigateBack(int iPad, bool forceUsePad, EUIScene eScene, EUI bool navComplete = false; if( app.GetGameStarted() ) { - bool navComplete = m_groups[(int)eUIGroup_Fullscreen]->NavigateBack(iPad, eScene, eLayer); + bool navComplete = m_groups[static_cast(eUIGroup_Fullscreen)]->NavigateBack(iPad, eScene, eLayer); if(!navComplete && ( iPad != 255 ) && ( iPad >= 0 ) ) { - EUIGroup group = (EUIGroup)(iPad+1); - navComplete = m_groups[(int)group]->NavigateBack(iPad, eScene, eLayer); - if(!m_groups[(int)group]->GetMenuDisplayed())SetMenuDisplayed(iPad,false); + EUIGroup group = static_cast(iPad + 1); + navComplete = m_groups[static_cast(group)]->NavigateBack(iPad, eScene, eLayer); + if(!m_groups[static_cast(group)]->GetMenuDisplayed())SetMenuDisplayed(iPad,false); } // 4J-PB - autosave in fullscreen doesn't clear the menuDisplayed flag else { - if(!m_groups[(int)eUIGroup_Fullscreen]->GetMenuDisplayed()) + if(!m_groups[static_cast(eUIGroup_Fullscreen)]->GetMenuDisplayed()) { setFullscreenMenuDisplayed(false); for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) @@ -1844,8 +1844,8 @@ bool UIController::NavigateBack(int iPad, bool forceUsePad, EUIScene eScene, EUI } else { - navComplete = m_groups[(int)eUIGroup_Fullscreen]->NavigateBack(iPad, eScene, eLayer); - if(!m_groups[(int)eUIGroup_Fullscreen]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false); + navComplete = m_groups[static_cast(eUIGroup_Fullscreen)]->NavigateBack(iPad, eScene, eLayer); + if(!m_groups[static_cast(eUIGroup_Fullscreen)]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false); } return navComplete; } @@ -1870,7 +1870,7 @@ void UIController::NavigateToHomeMenu() if(pTexPack->hasAudio()) { // get the dlc texture pack, and store it - pDLCTexPack=(DLCTexturePack *)pTexPack; + pDLCTexPack=static_cast(pTexPack); } // change to the default texture pack @@ -1925,7 +1925,7 @@ UIScene *UIController::GetTopScene(int iPad, EUILayer layer, EUIGroup group) // If the game isn't running treat as user 0, otherwise map index directly from pad if( ( iPad != 255 ) && ( iPad >= 0 ) ) { - group = (EUIGroup)(iPad+1); + group = static_cast(iPad + 1); } else group = eUIGroup_Fullscreen; } @@ -1935,7 +1935,7 @@ UIScene *UIController::GetTopScene(int iPad, EUILayer layer, EUIGroup group) group = eUIGroup_Fullscreen; } } - return m_groups[(int)group]->GetTopScene(layer); + return m_groups[static_cast(group)]->GetTopScene(layer); } size_t UIController::RegisterForCallbackId(UIScene *scene) @@ -1983,7 +1983,7 @@ void UIController::LeaveCallbackIdCriticalSection() void UIController::CloseAllPlayersScenes() { - m_groups[(int)eUIGroup_Fullscreen]->getTooltips()->SetTooltips(-1); + m_groups[static_cast(eUIGroup_Fullscreen)]->getTooltips()->SetTooltips(-1); for(unsigned int i = 0; i < eUIGroup_COUNT; ++i) { //m_bCloseAllScenes[i] = true; @@ -2006,7 +2006,7 @@ void UIController::CloseUIScenes(int iPad, bool forceIPad) if( app.GetGameStarted() || forceIPad ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else @@ -2014,22 +2014,22 @@ void UIController::CloseUIScenes(int iPad, bool forceIPad) group = eUIGroup_Fullscreen; } - m_groups[(int)group]->closeAllScenes(); - m_groups[(int)group]->getTooltips()->SetTooltips(-1); + m_groups[static_cast(group)]->closeAllScenes(); + m_groups[static_cast(group)]->getTooltips()->SetTooltips(-1); // This should cause the popup to dissappear TutorialPopupInfo popupInfo; - if(m_groups[(int)group]->getTutorialPopup()) m_groups[(int)group]->getTutorialPopup()->SetTutorialDescription(&popupInfo); + if(m_groups[static_cast(group)]->getTutorialPopup()) m_groups[static_cast(group)]->getTutorialPopup()->SetTutorialDescription(&popupInfo); if(group==eUIGroup_Fullscreen) setFullscreenMenuDisplayed(false); - SetMenuDisplayed((group == eUIGroup_Fullscreen ? XUSER_INDEX_ANY : iPad), m_groups[(int)group]->GetMenuDisplayed()); + SetMenuDisplayed((group == eUIGroup_Fullscreen ? XUSER_INDEX_ANY : iPad), m_groups[static_cast(group)]->GetMenuDisplayed()); } void UIController::setFullscreenMenuDisplayed(bool displayed) { // Show/hide the tooltips for the fullscreen group - m_groups[(int)eUIGroup_Fullscreen]->showComponent(ProfileManager.GetPrimaryPad(),eUIComponent_Tooltips,eUILayer_Tooltips,displayed); + m_groups[static_cast(eUIGroup_Fullscreen)]->showComponent(ProfileManager.GetPrimaryPad(),eUIComponent_Tooltips,eUILayer_Tooltips,displayed); // Show/hide tooltips for the other layers for(unsigned int i = (eUIGroup_Fullscreen+1); i < eUIGroup_COUNT; ++i) @@ -2044,14 +2044,14 @@ bool UIController::IsPauseMenuDisplayed(int iPad) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - return m_groups[(int)group]->IsPauseMenuDisplayed(); + return m_groups[static_cast(group)]->IsPauseMenuDisplayed(); } bool UIController::IsContainerMenuDisplayed(int iPad) @@ -2060,14 +2060,14 @@ bool UIController::IsContainerMenuDisplayed(int iPad) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - return m_groups[(int)group]->IsContainerMenuDisplayed(); + return m_groups[static_cast(group)]->IsContainerMenuDisplayed(); } bool UIController::IsIgnorePlayerJoinMenuDisplayed(int iPad) @@ -2076,14 +2076,14 @@ bool UIController::IsIgnorePlayerJoinMenuDisplayed(int iPad) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - return m_groups[(int)group]->IsIgnorePlayerJoinMenuDisplayed(); + return m_groups[static_cast(group)]->IsIgnorePlayerJoinMenuDisplayed(); } bool UIController::IsIgnoreAutosaveMenuDisplayed(int iPad) @@ -2092,14 +2092,14 @@ bool UIController::IsIgnoreAutosaveMenuDisplayed(int iPad) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - return m_groups[(int)eUIGroup_Fullscreen]->IsIgnoreAutosaveMenuDisplayed() || (group != eUIGroup_Fullscreen && m_groups[(int)group]->IsIgnoreAutosaveMenuDisplayed()); + return m_groups[static_cast(eUIGroup_Fullscreen)]->IsIgnoreAutosaveMenuDisplayed() || (group != eUIGroup_Fullscreen && m_groups[static_cast(group)]->IsIgnoreAutosaveMenuDisplayed()); } void UIController::SetIgnoreAutosaveMenuDisplayed(int iPad, bool displayed) @@ -2113,14 +2113,14 @@ bool UIController::IsSceneInStack(int iPad, EUIScene eScene) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - return m_groups[(int)group]->IsSceneInStack(eScene); + return m_groups[static_cast(group)]->IsSceneInStack(eScene); } bool UIController::GetMenuDisplayed(int iPad) @@ -2201,14 +2201,14 @@ void UIController::SetTooltipText( unsigned int iPad, unsigned int tooltip, int if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->SetTooltipText(tooltip, iTextID); + if(m_groups[static_cast(group)]->getTooltips()) m_groups[static_cast(group)]->getTooltips()->SetTooltipText(tooltip, iTextID); } void UIController::SetEnableTooltips( unsigned int iPad, BOOL bVal ) @@ -2217,14 +2217,14 @@ void UIController::SetEnableTooltips( unsigned int iPad, BOOL bVal ) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->SetEnableTooltips(bVal); + if(m_groups[static_cast(group)]->getTooltips()) m_groups[static_cast(group)]->getTooltips()->SetEnableTooltips(bVal); } void UIController::ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ) @@ -2233,14 +2233,14 @@ void UIController::ShowTooltip( unsigned int iPad, unsigned int tooltip, bool sh if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->ShowTooltip(tooltip,show); + if(m_groups[static_cast(group)]->getTooltips()) m_groups[static_cast(group)]->getTooltips()->ShowTooltip(tooltip,show); } void UIController::SetTooltips( unsigned int iPad, int iA, int iB, int iX, int iY, int iLT, int iRT, int iLB, int iRB, int iLS, int iRS, int iBack, bool forceUpdate) @@ -2262,14 +2262,14 @@ void UIController::SetTooltips( unsigned int iPad, int iA, int iB, int iX, int i if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->SetTooltips(iA, iB, iX, iY, iLT, iRT, iLB, iRB, iLS, iRS, iBack, forceUpdate); + if(m_groups[static_cast(group)]->getTooltips()) m_groups[static_cast(group)]->getTooltips()->SetTooltips(iA, iB, iX, iY, iLT, iRT, iLB, iRB, iLS, iRS, iBack, forceUpdate); } void UIController::EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable ) @@ -2278,14 +2278,14 @@ void UIController::EnableTooltip( unsigned int iPad, unsigned int tooltip, bool if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->EnableTooltip(tooltip,enable); + if(m_groups[static_cast(group)]->getTooltips()) m_groups[static_cast(group)]->getTooltips()->EnableTooltip(tooltip,enable); } void UIController::RefreshTooltips(unsigned int iPad) @@ -2304,7 +2304,7 @@ void UIController::AnimateKeyPress(int iPad, int iAction, bool bRepeat, bool bPr if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else @@ -2312,7 +2312,7 @@ void UIController::AnimateKeyPress(int iPad, int iAction, bool bRepeat, bool bPr group = eUIGroup_Fullscreen; } bool handled = false; - if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->handleInput(iPad, iAction, bRepeat, bPressed, bReleased, handled); + if(m_groups[static_cast(group)]->getTooltips()) m_groups[static_cast(group)]->getTooltips()->handleInput(iPad, iAction, bRepeat, bPressed, bReleased, handled); } void UIController::OverrideSFX(int iPad, int iAction,bool bVal) @@ -2322,7 +2322,7 @@ void UIController::OverrideSFX(int iPad, int iAction,bool bVal) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else @@ -2330,7 +2330,7 @@ void UIController::OverrideSFX(int iPad, int iAction,bool bVal) group = eUIGroup_Fullscreen; } bool handled = false; - if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->overrideSFX(iPad, iAction,bVal); + if(m_groups[static_cast(group)]->getTooltips()) m_groups[static_cast(group)]->getTooltips()->overrideSFX(iPad, iAction,bVal); } void UIController::PlayUISFX(ESoundEffect eSound) @@ -2352,13 +2352,13 @@ void UIController::DisplayGamertag(unsigned int iPad, bool show) { show = false; } - EUIGroup group = (EUIGroup)(iPad+1); - if(m_groups[(int)group]->getHUD()) m_groups[(int)group]->getHUD()->ShowDisplayName(show); + EUIGroup group = static_cast(iPad + 1); + if(m_groups[static_cast(group)]->getHUD()) m_groups[static_cast(group)]->getHUD()->ShowDisplayName(show); // Update TutorialPopup in Splitscreen if no container is displayed (to make sure the Popup does not overlap with the Gamertag!) - if(app.GetLocalPlayerCount() > 1 && m_groups[(int)group]->getTutorialPopup() && !m_groups[(int)group]->IsContainerMenuDisplayed()) + if(app.GetLocalPlayerCount() > 1 && m_groups[static_cast(group)]->getTutorialPopup() && !m_groups[static_cast(group)]->IsContainerMenuDisplayed()) { - m_groups[(int)group]->getTutorialPopup()->UpdateTutorialPopup(); + m_groups[static_cast(group)]->getTutorialPopup()->UpdateTutorialPopup(); } } @@ -2369,7 +2369,7 @@ void UIController::SetSelectedItem(unsigned int iPad, const wstring &name) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else @@ -2377,7 +2377,7 @@ void UIController::SetSelectedItem(unsigned int iPad, const wstring &name) group = eUIGroup_Fullscreen; } bool handled = false; - if(m_groups[(int)group]->getHUD()) m_groups[(int)group]->getHUD()->SetSelectedLabel(name); + if(m_groups[static_cast(group)]->getHUD()) m_groups[static_cast(group)]->getHUD()->SetSelectedLabel(name); } void UIController::UpdateSelectedItemPos(unsigned int iPad) @@ -2430,7 +2430,7 @@ void UIController::HandleInventoryUpdated(int iPad) EUIGroup group = eUIGroup_Fullscreen; if( app.GetGameStarted() && ( iPad != 255 ) && ( iPad >= 0 ) ) { - group = (EUIGroup)(iPad+1); + group = static_cast(iPad + 1); } m_groups[group]->HandleMessage(eUIMessage_InventoryUpdated, NULL); @@ -2452,14 +2452,14 @@ void UIController::SetTutorial(int iPad, Tutorial *tutorial) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - if(m_groups[(int)group]->getTutorialPopup()) m_groups[(int)group]->getTutorialPopup()->SetTutorial(tutorial); + if(m_groups[static_cast(group)]->getTutorialPopup()) m_groups[static_cast(group)]->getTutorialPopup()->SetTutorial(tutorial); } void UIController::SetTutorialDescription(int iPad, TutorialPopupInfo *info) @@ -2468,7 +2468,7 @@ void UIController::SetTutorialDescription(int iPad, TutorialPopupInfo *info) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else @@ -2476,11 +2476,11 @@ void UIController::SetTutorialDescription(int iPad, TutorialPopupInfo *info) group = eUIGroup_Fullscreen; } - if(m_groups[(int)group]->getTutorialPopup()) + if(m_groups[static_cast(group)]->getTutorialPopup()) { // tutorial popup needs to know if a container menu is being displayed - m_groups[(int)group]->getTutorialPopup()->SetContainerMenuVisible(m_groups[(int)group]->IsContainerMenuDisplayed()); - m_groups[(int)group]->getTutorialPopup()->SetTutorialDescription(info); + m_groups[static_cast(group)]->getTutorialPopup()->SetContainerMenuVisible(m_groups[static_cast(group)]->IsContainerMenuDisplayed()); + m_groups[static_cast(group)]->getTutorialPopup()->SetTutorialDescription(info); } } @@ -2488,9 +2488,9 @@ void UIController::SetTutorialDescription(int iPad, TutorialPopupInfo *info) void UIController::RemoveInteractSceneReference(int iPad, UIScene *scene) { EUIGroup group; - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; - if(m_groups[(int)group]->getTutorialPopup()) m_groups[(int)group]->getTutorialPopup()->RemoveInteractSceneReference(scene); + if(m_groups[static_cast(group)]->getTutorialPopup()) m_groups[static_cast(group)]->getTutorialPopup()->RemoveInteractSceneReference(scene); } #endif @@ -2500,14 +2500,14 @@ void UIController::SetTutorialVisible(int iPad, bool visible) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else { group = eUIGroup_Fullscreen; } - if(m_groups[(int)group]->getTutorialPopup()) m_groups[(int)group]->getTutorialPopup()->SetVisible(visible); + if(m_groups[static_cast(group)]->getTutorialPopup()) m_groups[static_cast(group)]->getTutorialPopup()->SetVisible(visible); } bool UIController::IsTutorialVisible(int iPad) @@ -2516,7 +2516,7 @@ bool UIController::IsTutorialVisible(int iPad) if( app.GetGameStarted() ) { // If the game isn't running treat as user 0, otherwise map index directly from pad - if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1); + if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast(iPad + 1); else group = eUIGroup_Fullscreen; } else @@ -2524,7 +2524,7 @@ bool UIController::IsTutorialVisible(int iPad) group = eUIGroup_Fullscreen; } bool visible = false; - if(m_groups[(int)group]->getTutorialPopup()) visible = m_groups[(int)group]->getTutorialPopup()->IsVisible(); + if(m_groups[static_cast(group)]->getTutorialPopup()) visible = m_groups[static_cast(group)]->getTutorialPopup()->IsVisible(); return visible; } @@ -2544,7 +2544,7 @@ void UIController::UpdatePlayerBasePositions() { DisplayGamertag(idx,true); } - m_groups[idx+1]->SetViewportType((C4JRender::eViewportType)pMinecraft->localplayers[idx]->m_iScreenSection); + m_groups[idx+1]->SetViewportType(static_cast(pMinecraft->localplayers[idx]->m_iScreenSection)); } else { @@ -2577,7 +2577,7 @@ void UIController::ShowOtherPlayersBaseScene(unsigned int iPad, bool show) void UIController::ShowTrialTimer(bool show) { - if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showTrialTimer(show); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->showTrialTimer(show); } void UIController::SetTrialTimerLimitSecs(unsigned int uiSeconds) @@ -2589,7 +2589,7 @@ void UIController::UpdateTrialTimer(unsigned int iPad) { WCHAR wcTime[20]; - DWORD dwTimeTicks=(DWORD)app.getTrialTimer(); + DWORD dwTimeTicks=static_cast(app.getTrialTimer()); if(dwTimeTicks>m_dwTrialTimerLimitSecs) { @@ -2608,11 +2608,11 @@ void UIController::UpdateTrialTimer(unsigned int iPad) int iMins=dwTimeTicks/60; int iSeconds=dwTimeTicks%60; swprintf( wcTime, 20, L"%d:%02d",iMins,iSeconds); - if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->setTrialTimer(wcTime); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->setTrialTimer(wcTime); } else { - if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->setTrialTimer(L""); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->setTrialTimer(L""); } // are we out of time? @@ -2631,7 +2631,7 @@ void UIController::UpdateTrialTimer(unsigned int iPad) void UIController::ReduceTrialTimerValue() { - DWORD dwTimeTicks=(int)app.getTrialTimer(); + DWORD dwTimeTicks=static_cast(app.getTrialTimer()); if(dwTimeTicks>m_dwTrialTimerLimitSecs) { @@ -2643,7 +2643,7 @@ void UIController::ReduceTrialTimerValue() void UIController::ShowAutosaveCountdownTimer(bool show) { - if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showTrialTimer(show); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->showTrialTimer(show); } void UIController::UpdateAutosaveCountdownTimer(unsigned int uiSeconds) @@ -2651,7 +2651,7 @@ void UIController::UpdateAutosaveCountdownTimer(unsigned int uiSeconds) #if !(defined(_XBOX_ONE) || defined(__ORBIS__)) WCHAR wcAutosaveCountdown[100]; swprintf( wcAutosaveCountdown, 100, app.GetString(IDS_AUTOSAVE_COUNTDOWN),uiSeconds); - if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->setTrialTimer(wcAutosaveCountdown); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->setTrialTimer(wcAutosaveCountdown); #endif } @@ -2668,12 +2668,12 @@ void UIController::ShowSavingMessage(unsigned int iPad, C4JStorage::ESavingMessa show = true; break; } - if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showSaveIcon(show); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->showSaveIcon(show); } void UIController::ShowPlayerDisplayname(bool show) { - if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showPlayerDisplayName(show); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->showPlayerDisplayName(show); } void UIController::SetWinUserIndex(unsigned int iPad) @@ -2692,7 +2692,7 @@ void UIController::ShowUIDebugConsole(bool show) if(show) { - m_uiDebugConsole = (UIComponent_DebugUIConsole *)m_groups[eUIGroup_Fullscreen]->addComponent(0, eUIComponent_DebugUIConsole, eUILayer_Debug); + m_uiDebugConsole = static_cast(m_groups[eUIGroup_Fullscreen]->addComponent(0, eUIComponent_DebugUIConsole, eUILayer_Debug)); } else { @@ -2708,7 +2708,7 @@ void UIController::ShowUIDebugMarketingGuide(bool show) if(show) { - m_uiDebugMarketingGuide = (UIComponent_DebugUIMarketingGuide *)m_groups[eUIGroup_Fullscreen]->addComponent(0, eUIComponent_DebugUIMarketingGuide, eUILayer_Debug); + m_uiDebugMarketingGuide = static_cast(m_groups[eUIGroup_Fullscreen]->addComponent(0, eUIComponent_DebugUIMarketingGuide, eUILayer_Debug)); } else { @@ -2731,13 +2731,13 @@ bool UIController::PressStartPlaying(unsigned int iPad) void UIController::ShowPressStart(unsigned int iPad) { m_iPressStartQuadrantsMask|=1<getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showPressStart(iPad, true); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->showPressStart(iPad, true); } void UIController::HidePressStart() { ClearPressStart(); - if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showPressStart(0, false); + if(m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast(eUIGroup_Fullscreen)]->getPressStartToPlay()->showPressStart(0, false); } void UIController::ClearPressStart() diff --git a/Minecraft.Client/Common/UI/UIGroup.cpp b/Minecraft.Client/Common/UI/UIGroup.cpp index e8bb9fe66..769fd83d6 100644 --- a/Minecraft.Client/Common/UI/UIGroup.cpp +++ b/Minecraft.Client/Common/UI/UIGroup.cpp @@ -23,22 +23,22 @@ UIGroup::UIGroup(EUIGroup group, int iPad) #endif } - m_tooltips = (UIComponent_Tooltips *)m_layers[(int)eUILayer_Tooltips]->addComponent(0, eUIComponent_Tooltips); + m_tooltips = (UIComponent_Tooltips *)m_layers[static_cast(eUILayer_Tooltips)]->addComponent(0, eUIComponent_Tooltips); m_tutorialPopup = NULL; m_hud = NULL; m_pressStartToPlay = NULL; if(m_group != eUIGroup_Fullscreen) { - m_tutorialPopup = (UIComponent_TutorialPopup *)m_layers[(int)eUILayer_Popup]->addComponent(m_iPad, eUIComponent_TutorialPopup); + m_tutorialPopup = (UIComponent_TutorialPopup *)m_layers[static_cast(eUILayer_Popup)]->addComponent(m_iPad, eUIComponent_TutorialPopup); - m_hud = (UIScene_HUD *)m_layers[(int)eUILayer_HUD]->addComponent(m_iPad, eUIScene_HUD); + m_hud = (UIScene_HUD *)m_layers[static_cast(eUILayer_HUD)]->addComponent(m_iPad, eUIScene_HUD); //m_layers[(int)eUILayer_Chat]->addComponent(m_iPad, eUIComponent_Chat); } else { - m_pressStartToPlay = (UIComponent_PressStartToPlay *)m_layers[(int)eUILayer_Tooltips]->addComponent(0, eUIComponent_PressStartToPlay); + m_pressStartToPlay = (UIComponent_PressStartToPlay *)m_layers[static_cast(eUILayer_Tooltips)]->addComponent(0, eUIComponent_PressStartToPlay); } // 4J Stu - Pre-allocate this for cached rendering in scenes. It's horribly slow to do dynamically, but we should only need one @@ -65,7 +65,7 @@ void UIGroup::ReloadAll() if(highestRenderable < eUILayer_Fullscreen) highestRenderable = eUILayer_Fullscreen; for(; highestRenderable >= 0; --highestRenderable) { - if(highestRenderable < eUILayer_COUNT) m_layers[highestRenderable]->ReloadAll(highestRenderable != (int)eUILayer_Fullscreen); + if(highestRenderable < eUILayer_COUNT) m_layers[highestRenderable]->ReloadAll(highestRenderable != static_cast(eUILayer_Fullscreen)); } } @@ -127,7 +127,7 @@ void UIGroup::getRenderDimensions(S32 &width, S32 &height) // NAVIGATION bool UIGroup::NavigateToScene(int iPad, EUIScene scene, void *initData, EUILayer layer) { - bool succeeded = m_layers[(int)layer]->NavigateToScene(iPad, scene, initData); + bool succeeded = m_layers[static_cast(layer)]->NavigateToScene(iPad, scene, initData); updateStackStates(); return succeeded; } @@ -153,7 +153,7 @@ void UIGroup::closeAllScenes() { if(pMinecraft != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); // This just allows it to be shown gameMode->getTutorial()->showTutorialPopup(true); @@ -163,14 +163,14 @@ void UIGroup::closeAllScenes() for(unsigned int i = 0; i < eUILayer_COUNT; ++i) { // Ignore the error layer - if(i != (int)eUILayer_Error) m_layers[i]->closeAllScenes(); + if(i != static_cast(eUILayer_Error)) m_layers[i]->closeAllScenes(); } updateStackStates(); } UIScene *UIGroup::GetTopScene(EUILayer layer) { - return m_layers[(int)layer]->GetTopScene(); + return m_layers[static_cast(layer)]->GetTopScene(); } bool UIGroup::GetMenuDisplayed() diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp index 6ef6d0e82..e736d25cb 100644 --- a/Minecraft.Client/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Common/UI/UIScene.cpp @@ -728,7 +728,7 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt if (pop > 0) { glPushMatrix(); - float squeeze = 1 + pop / (float) Inventory::POP_TIME_DURATION; + float squeeze = 1 + pop / static_cast(Inventory::POP_TIME_DURATION); float sx = x; float sy = y; float sxoffs = 8 * scaleX; @@ -757,15 +757,15 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt { glPushMatrix(); glScalef(scaleX, scaleY, 1.0f); - int iX= (int)(0.5f+((float)x)/scaleX); - int iY= (int)(0.5f+((float)y)/scaleY); + int iX= static_cast(0.5f + ((float)x) / scaleX); + int iY= static_cast(0.5f + ((float)y) / scaleY); m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, item, iX, iY, fAlpha); glPopMatrix(); } else { - m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, item, (int)x, (int)y, fAlpha); + m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, item, static_cast(x), static_cast(y), fAlpha); } } @@ -902,7 +902,7 @@ void UIScene::sendInputToMovie(int key, bool repeat, bool pressed, bool released } IggyEvent keyEvent; // 4J Stu - Keyloc is always standard as we don't care about shift/alt - IggyMakeEventKey( &keyEvent, pressed?IGGY_KEYEVENT_Down:IGGY_KEYEVENT_Up, (IggyKeycode)iggyKeyCode, IGGY_KEYLOC_Standard ); + IggyMakeEventKey( &keyEvent, pressed?IGGY_KEYEVENT_Down:IGGY_KEYEVENT_Up, static_cast(iggyKeyCode), IGGY_KEYLOC_Standard ); IggyEventResult result; IggyPlayerDispatchEventRS ( swf , &keyEvent , &result ); @@ -1191,8 +1191,8 @@ bool UIScene::hasRegisteredSubstitutionTexture(const wstring &textureName) void UIScene::_handleFocusChange(F64 controlId, F64 childId) { - m_iFocusControl = (int)controlId; - m_iFocusChild = (int)childId; + m_iFocusControl = static_cast(controlId); + m_iFocusChild = static_cast(childId); handleFocusChange(controlId, childId); ui.PlayUISFX(eSFX_Focus); @@ -1200,8 +1200,8 @@ void UIScene::_handleFocusChange(F64 controlId, F64 childId) void UIScene::_handleInitFocus(F64 controlId, F64 childId) { - m_iFocusControl = (int)controlId; - m_iFocusChild = (int)childId; + m_iFocusControl = static_cast(controlId); + m_iFocusChild = static_cast(childId); //handleInitFocus(controlId, childId); handleFocusChange(controlId, childId); diff --git a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp index 6b196c1b8..a354ba7ae 100644 --- a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp @@ -51,7 +51,7 @@ void UIScene_AbstractContainerMenu::handleDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } @@ -187,8 +187,8 @@ void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex) IggyEvent mouseEvent; S32 width, height; m_parentLayer->getRenderDimensions(width, height); - S32 x = m_pointerPos.x*((float)width/m_movieWidth); - S32 y = m_pointerPos.y*((float)height/m_movieHeight); + S32 x = m_pointerPos.x*(static_cast(width)/m_movieWidth); + S32 y = m_pointerPos.y*(static_cast(height)/m_movieHeight); IggyMakeEventMouseMove( &mouseEvent, x, y); IggyEventResult result; @@ -212,8 +212,8 @@ void UIScene_AbstractContainerMenu::tick() S32 width, height; m_parentLayer->getRenderDimensions(width, height); - S32 x = (S32)(m_pointerPos.x * ((float)width / m_movieWidth)); - S32 y = (S32)(m_pointerPos.y * ((float)height / m_movieHeight)); + S32 x = static_cast(m_pointerPos.x * ((float)width / m_movieWidth)); + S32 y = static_cast(m_pointerPos.y * ((float)height / m_movieHeight)); IggyMakeEventMouseMove( &mouseEvent, x, y); @@ -265,7 +265,7 @@ void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *reg } else { - swscanf((wchar_t*)region->name,L"slot_%d",&slotId); + swscanf(static_cast(region->name),L"slot_%d",&slotId); if (slotId == -1) { app.DebugPrintf("This is not the control we are looking for\n"); diff --git a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp index c810ad455..79117bb43 100644 --- a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp @@ -16,13 +16,13 @@ UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void *_initData, UILayer *parentL m_labelAnvil.init( app.GetString(IDS_REPAIR_AND_NAME) ); - AnvilScreenInput *initData = (AnvilScreenInput *)_initData; + AnvilScreenInput *initData = static_cast(_initData); m_inventory = initData->inventory; Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Anvil_Menu, this); } @@ -309,7 +309,7 @@ UIControl *UIScene_AnvilMenu::getSection(ESceneSection eSection) int UIScene_AnvilMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) { // 4J HEG - No reason to set value if keyboard was cancelled - UIScene_AnvilMenu *pClass=(UIScene_AnvilMenu *)lpParam; + UIScene_AnvilMenu *pClass=static_cast(lpParam); pClass->setIgnoreInput(false); if (bRes) @@ -342,7 +342,7 @@ void UIScene_AnvilMenu::handleEditNamePressed() break; } #else - InputManager.RequestKeyboard(app.GetString(IDS_TITLE_RENAME),m_textInputAnvil.getLabel(),(DWORD)m_iPad,30,&UIScene_AnvilMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_TITLE_RENAME),m_textInputAnvil.getLabel(),static_cast(m_iPad),30,&UIScene_AnvilMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); #endif } diff --git a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp index e70397d68..64e0fdd8b 100644 --- a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp @@ -21,12 +21,12 @@ UIScene_BeaconMenu::UIScene_BeaconMenu(int iPad, void *_initData, UILayer *paren m_buttonsPowers[eControl_Secondary1].setVisible(false); m_buttonsPowers[eControl_Secondary2].setVisible(false); - BeaconScreenInput *initData = (BeaconScreenInput *)_initData; + BeaconScreenInput *initData = static_cast(_initData); Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Beacon_Menu, this); } @@ -328,7 +328,7 @@ void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion *region) shared_ptr item = nullptr; int slotId = -1; - swscanf((wchar_t*)region->name,L"slot_%d",&slotId); + swscanf(static_cast(region->name),L"slot_%d",&slotId); if(slotId >= 0 && slotId >= m_menu->getSize() ) { diff --git a/Minecraft.Client/Common/UI/UIScene_BrewingStandMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BrewingStandMenu.cpp index 8563054c6..4df5fa039 100644 --- a/Minecraft.Client/Common/UI/UIScene_BrewingStandMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_BrewingStandMenu.cpp @@ -14,7 +14,7 @@ UIScene_BrewingStandMenu::UIScene_BrewingStandMenu(int iPad, void *_initData, UI m_progressBrewingArrow.init(L"",0,0,PotionBrewing::BREWING_TIME_SECONDS * SharedConstants::TICKS_PER_SECOND,0); m_progressBrewingBubbles.init(L"",0,0,30,0); - BrewingScreenInput *initData = (BrewingScreenInput *)_initData; + BrewingScreenInput *initData = static_cast(_initData); m_brewingStand = initData->brewingStand; m_labelBrewingStand.init( m_brewingStand->getName() ); @@ -22,7 +22,7 @@ UIScene_BrewingStandMenu::UIScene_BrewingStandMenu(int iPad, void *_initData, UI Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Brewing_Menu, this); } diff --git a/Minecraft.Client/Common/UI/UIScene_ConnectingProgress.cpp b/Minecraft.Client/Common/UI/UIScene_ConnectingProgress.cpp index 968072a8e..a387fb294 100644 --- a/Minecraft.Client/Common/UI/UIScene_ConnectingProgress.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ConnectingProgress.cpp @@ -15,7 +15,7 @@ UIScene_ConnectingProgress::UIScene_ConnectingProgress(int iPad, void *_initData m_progressBar.setVisible( false ); m_labelTip.setVisible( false ); - ConnectionProgressParams *param = (ConnectionProgressParams *)_initData; + ConnectionProgressParams *param = static_cast(_initData); if( param->stringId >= 0 ) { @@ -245,7 +245,7 @@ void UIScene_ConnectingProgress::handleInput(int iPad, int key, bool repeat, boo void UIScene_ConnectingProgress::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Confirm: if(m_showingButton) diff --git a/Minecraft.Client/Common/UI/UIScene_ContainerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_ContainerMenu.cpp index 9e48a57b2..7a3051eff 100644 --- a/Minecraft.Client/Common/UI/UIScene_ContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ContainerMenu.cpp @@ -13,7 +13,7 @@ UIScene_ContainerMenu::UIScene_ContainerMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene_AbstractContainerMenu(iPad, parentLayer) { - ContainerScreenInput *initData = (ContainerScreenInput *)_initData; + ContainerScreenInput *initData = static_cast(_initData); m_bLargeChest = (initData->container->getContainerSize() > 3*9)?true:false; // Setup all the Iggy references we need for this scene @@ -26,7 +26,7 @@ UIScene_ContainerMenu::UIScene_ContainerMenu(int iPad, void *_initData, UILayer Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Container_Menu, this); } diff --git a/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp index 575672485..07db23904 100644 --- a/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp @@ -13,7 +13,7 @@ UIScene_ControlsMenu::UIScene_ControlsMenu(int iPad, void *initData, UILayer *pa IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; #if defined(_XBOX) || defined(_WIN64) - value[0].number = (F64)0; + value[0].number = static_cast(0); #elif defined(_DURANGO) value[0].number = (F64)1; #elif defined(__PS3__) @@ -84,7 +84,7 @@ UIScene_ControlsMenu::UIScene_ControlsMenu(int iPad, void *initData, UILayer *pa IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; - value[0].number = (F64)m_iCurrentNavigatedControlsLayout; + value[0].number = static_cast(m_iCurrentNavigatedControlsLayout); IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetControllerLayout , 1 , value ); } @@ -180,7 +180,7 @@ void UIScene_ControlsMenu::handleInput(int iPad, int key, bool repeat, bool pres void UIScene_ControlsMenu::handleCheckboxToggled(F64 controlId, bool selected) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_InvertLook: app.SetGameSettings(m_iPad,eGameSetting_ControlInvertLook,(unsigned char)( selected ) ); @@ -194,13 +194,13 @@ void UIScene_ControlsMenu::handleCheckboxToggled(F64 controlId, bool selected) void UIScene_ControlsMenu::handlePress(F64 controlId, F64 childId) { - int control = (int)controlId; + int control = static_cast(controlId); switch(control) { case eControl_Button0: case eControl_Button1: case eControl_Button2: - app.SetGameSettings(m_iPad,eGameSetting_ControlScheme,(unsigned char)control); + app.SetGameSettings(m_iPad,eGameSetting_ControlScheme,static_cast(control)); LPWSTR layoutString = new wchar_t[ 128 ]; swprintf( layoutString, 128, L"%ls : %ls", app.GetString( IDS_CURRENT_LAYOUT ),app.GetString(m_iSchemeTextA[control])); #ifdef __ORBIS__ @@ -216,7 +216,7 @@ void UIScene_ControlsMenu::handlePress(F64 controlId, F64 childId) void UIScene_ControlsMenu::handleFocusChange(F64 controlId, F64 childId) { - int control = (int)controlId; + int control = static_cast(controlId); switch(control) { case eControl_Button0: diff --git a/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp index 66d8c41ee..676feb989 100644 --- a/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp @@ -14,7 +14,7 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p { m_bIgnoreKeyPresses = false; - CraftingPanelScreenInput* initData = (CraftingPanelScreenInput*)_initData; + CraftingPanelScreenInput* initData = static_cast(_initData); m_iContainerType=initData->iContainerType; m_pPlayer=initData->player; m_bSplitscreen=initData->bSplitscreen; @@ -111,7 +111,7 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); if(m_iContainerType==RECIPE_TYPE_2x2) { @@ -192,7 +192,7 @@ void UIScene_CraftingMenu::handleDestroy() if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } @@ -443,7 +443,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) float alpha = 1.0f; bool decorations = true; bool inventoryItem = false; - swscanf((wchar_t*)region->name,L"slot_%d",&slotId); + swscanf(static_cast(region->name),L"slot_%d",&slotId); if (slotId == -1) { app.DebugPrintf("This is not the control we are looking for\n"); @@ -471,7 +471,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) if(m_vSlotsInfo[iIndex].show) { item = m_vSlotsInfo[iIndex].item; - alpha = ((float)m_vSlotsInfo[iIndex].alpha)/31.0f; + alpha = static_cast(m_vSlotsInfo[iIndex].alpha)/31.0f; } } else if(slotId >= CRAFTING_H_SLOT_START && slotId < (CRAFTING_H_SLOT_START + m_iCraftablesMaxHSlotC) ) @@ -481,7 +481,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) if(m_hSlotsInfo[iIndex].show) { item = m_hSlotsInfo[iIndex].item; - alpha = ((float)m_hSlotsInfo[iIndex].alpha)/31.0f; + alpha = static_cast(m_hSlotsInfo[iIndex].alpha)/31.0f; } } else if(slotId >= CRAFTING_INGREDIENTS_LAYOUT_START && slotId < (CRAFTING_INGREDIENTS_LAYOUT_START + m_iIngredientsMaxSlotC) ) @@ -490,7 +490,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) if(m_ingredientsSlotsInfo[iIndex].show) { item = m_ingredientsSlotsInfo[iIndex].item; - alpha = ((float)m_ingredientsSlotsInfo[iIndex].alpha)/31.0f; + alpha = static_cast(m_ingredientsSlotsInfo[iIndex].alpha)/31.0f; } } else if(slotId >= CRAFTING_INGREDIENTS_DESCRIPTION_START && slotId < (CRAFTING_INGREDIENTS_DESCRIPTION_START + 4) ) @@ -499,7 +499,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) if(m_ingredientsInfo[iIndex].show) { item = m_ingredientsInfo[iIndex].item; - alpha = ((float)m_ingredientsInfo[iIndex].alpha)/31.0f; + alpha = static_cast(m_ingredientsInfo[iIndex].alpha)/31.0f; } } else if(slotId == CRAFTING_OUTPUT_SLOT_START ) @@ -507,7 +507,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) if(m_craftingOutputSlotInfo.show) { item = m_craftingOutputSlotInfo.item; - alpha = ((float)m_craftingOutputSlotInfo.alpha)/31.0f; + alpha = static_cast(m_craftingOutputSlotInfo.alpha)/31.0f; } } diff --git a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp index 2bd06bc63..241af7bb2 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp @@ -317,7 +317,7 @@ void UIScene_CreateWorldMenu::tick() m_iDirectEditCooldown = 4; // absorb the matching ACTION_MENU_OK that follows m_editWorldName.setLabel(m_worldName.c_str()); } - else if ((int)m_worldName.length() < 25) + else if (static_cast(m_worldName.length()) < 25) { m_worldName += ch; changed = true; @@ -470,7 +470,7 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId) //CD - Added for audio ui.PlayUISFX(eSFX_Press); - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_EditWorldName: { @@ -519,7 +519,7 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId) break; case eControl_TexturePackList: { - UpdateCurrentTexturePack((int)childId); + UpdateCurrentTexturePack(static_cast(childId)); } break; case eControl_NewWorld: @@ -615,7 +615,7 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() { // texture pack hasn't been set yet, so check what it will be TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexturePack; + DLCTexturePack *pDLCTexPack=static_cast(pTexturePack); m_pDLCPack=pDLCTexPack->getDLCInfoParentPack(); // do we have a license? @@ -686,8 +686,8 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() void UIScene_CreateWorldMenu::handleSliderMove(F64 sliderId, F64 currentValue) { WCHAR TempString[256]; - int value = (int)currentValue; - switch((int)sliderId) + int value = static_cast(currentValue); + switch(static_cast(sliderId)) { case eControl_Difficulty: m_sliderDifficulty.handleSliderMove(value); @@ -801,7 +801,7 @@ void UIScene_CreateWorldMenu::handleGainFocus(bool navBack) int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bool bRes) { - UIScene_CreateWorldMenu *pClass=(UIScene_CreateWorldMenu *)lpParam; + UIScene_CreateWorldMenu *pClass=static_cast(lpParam); pClass->m_bIgnoreInput=false; // 4J HEG - No reason to set value if keyboard was cancelled if (bRes) @@ -1173,7 +1173,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD if (wSeed.length() != 0) { __int64 value = 0; - unsigned int len = (unsigned int)wSeed.length(); + unsigned int len = static_cast(wSeed.length()); //Check if the input string contains a numerical value bool isNumber = true; @@ -1247,8 +1247,8 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD app.SetGameHostOption(eGameHostOption_WasntSaveOwner, false); #ifdef _LARGE_WORLDS app.SetGameHostOption(eGameHostOption_WorldSize, pClass->m_MoreOptionsParams.worldSize+1 ); // 0 is GAME_HOST_OPTION_WORLDSIZE_UNKNOWN - pClass->m_MoreOptionsParams.currentWorldSize = (EGameHostOptionWorldSize)(pClass->m_MoreOptionsParams.worldSize+1); - pClass->m_MoreOptionsParams.newWorldSize = (EGameHostOptionWorldSize)(pClass->m_MoreOptionsParams.worldSize+1); + pClass->m_MoreOptionsParams.currentWorldSize = static_cast(pClass->m_MoreOptionsParams.worldSize + 1); + pClass->m_MoreOptionsParams.newWorldSize = static_cast(pClass->m_MoreOptionsParams.worldSize + 1); #endif g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); @@ -1290,7 +1290,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); // Reset the autosave time app.SetAutosaveTimerTime(); @@ -1308,7 +1308,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD int UIScene_CreateWorldMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu*)pParam; + UIScene_CreateWorldMenu* pClass = static_cast(pParam); if(bContinue==true) { @@ -1416,7 +1416,7 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void *pParam,bool bContinu int UIScene_CreateWorldMenu::ConfirmCreateReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu*)pParam; + UIScene_CreateWorldMenu* pClass = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { diff --git a/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp index 0895cdffe..902b987c4 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp @@ -19,7 +19,7 @@ UIScene_CreativeMenu::UIScene_CreativeMenu(int iPad, void *_initData, UILayer *p // Setup all the Iggy references we need for this scene initialiseMovie(); - InventoryScreenInput *initData = (InventoryScreenInput *)_initData; + InventoryScreenInput *initData = static_cast(_initData); shared_ptr creativeContainer = shared_ptr(new SimpleContainer( 0, L"", false, TabSpec::MAX_SIZE )); itemPickerMenu = new ItemPickerMenu(creativeContainer, initData->player->inventory); @@ -44,7 +44,7 @@ UIScene_CreativeMenu::UIScene_CreativeMenu(int iPad, void *_initData, UILayer *p Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Creative_Inventory_Menu, this); } @@ -144,7 +144,7 @@ void UIScene_CreativeMenu::handleOtherClicked(int iPad, ESceneSection eSection, case eSectionInventoryCreativeTab_6: case eSectionInventoryCreativeTab_7: { - ECreativeInventoryTabs tab = (ECreativeInventoryTabs)((int)eCreativeInventoryTab_BuildingBlocks + (int)eSection - (int)eSectionInventoryCreativeTab_0); + ECreativeInventoryTabs tab = static_cast((int)eCreativeInventoryTab_BuildingBlocks + (int)eSection - (int)eSectionInventoryCreativeTab_0); if(tab != m_curTab) { switchTab(tab); @@ -193,8 +193,8 @@ void UIScene_CreativeMenu::handleInput(int iPad, int key, bool repeat, bool pres // Fall through intentional case VK_PAD_RSHOULDER: { - ECreativeInventoryTabs tab = (ECreativeInventoryTabs)(m_curTab + dir); - if (tab < 0) tab = (ECreativeInventoryTabs)(eCreativeInventoryTab_COUNT - 1); + ECreativeInventoryTabs tab = static_cast(m_curTab + dir); + if (tab < 0) tab = static_cast(eCreativeInventoryTab_COUNT - 1); if (tab >= eCreativeInventoryTab_COUNT) tab = eCreativeInventoryTab_BuildingBlocks; switchTab(tab); ui.PlayUISFX(eSFX_Focus); @@ -220,7 +220,7 @@ void UIScene_CreativeMenu::updateTabHighlightAndText(ECreativeInventoryTabs tab) IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; - value[0].number = (F64)tab; + value[0].number = static_cast(tab); IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcSetActiveTab , 1 , value ); @@ -468,10 +468,10 @@ void UIScene_CreativeMenu::updateScrollCurrentPage(int currentPage, int pageCoun IggyDataValue value[2]; value[0].type = IGGY_DATATYPE_number; - value[0].number = (F64)pageCount; + value[0].number = static_cast(pageCount); value[1].type = IGGY_DATATYPE_number; - value[1].number = (F64)currentPage - 1; + value[1].number = static_cast(currentPage) - 1; IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcSetScrollBar , 2 , value ); } \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIScene_Credits.cpp b/Minecraft.Client/Common/UI/UIScene_Credits.cpp index 75ddf92ff..187bf689a 100644 --- a/Minecraft.Client/Common/UI/UIScene_Credits.cpp +++ b/Minecraft.Client/Common/UI/UIScene_Credits.cpp @@ -597,7 +597,7 @@ void UIScene_Credits::tick() { if ( pDef->m_iStringID[0] == CREDIT_ICON ) { - addImage((ECreditIcons)pDef->m_iStringID[1]); + addImage(static_cast(pDef->m_iStringID[1])); } else // using additional translated string. { @@ -670,7 +670,7 @@ void UIScene_Credits::setNextLabel(const wstring &label, ECreditTextTypes size) value[0].string16 = stringVal; value[1].type = IGGY_DATATYPE_number; - value[1].number = (int)size; + value[1].number = static_cast(size); value[2].type = IGGY_DATATYPE_boolean; value[2].boolval = (m_iCurrDefIndex == (m_iNumTextDefs - 1)); @@ -684,7 +684,7 @@ void UIScene_Credits::addImage(ECreditIcons icon) IggyDataValue value[2]; value[0].type = IGGY_DATATYPE_number; - value[0].number = (int)icon; + value[0].number = static_cast(icon); value[1].type = IGGY_DATATYPE_boolean; value[1].boolval = (m_iCurrDefIndex == (m_iNumTextDefs - 1)); diff --git a/Minecraft.Client/Common/UI/UIScene_DLCMainMenu.cpp b/Minecraft.Client/Common/UI/UIScene_DLCMainMenu.cpp index 77ffdffd9..6d705765e 100644 --- a/Minecraft.Client/Common/UI/UIScene_DLCMainMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DLCMainMenu.cpp @@ -121,11 +121,11 @@ void UIScene_DLCMainMenu::handleInput(int iPad, int key, bool repeat, bool press void UIScene_DLCMainMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_OffersList: { - int iIndex = (int)childId; + int iIndex = static_cast(childId); DLCOffersParam *param = new DLCOffersParam(); param->iPad = m_iPad; @@ -134,7 +134,7 @@ void UIScene_DLCMainMenu::handlePress(F64 controlId, F64 childId) // Xbox One will have requested the marketplace content - there is only that type #ifndef _XBOX_ONE - app.AddDLCRequest((eDLCMarketplaceType)iIndex, true); + app.AddDLCRequest(static_cast(iIndex), true); #endif killTimer(PLAYER_ONLINE_TIMER_ID); ui.NavigateToScene(m_iPad, eUIScene_DLCOffersMenu, param); @@ -166,7 +166,7 @@ void UIScene_DLCMainMenu::handleTimerComplete(int id) int UIScene_DLCMainMenu::ExitDLCMainMenu(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_DLCMainMenu* pClass = (UIScene_DLCMainMenu*)pParam; + UIScene_DLCMainMenu* pClass = static_cast(pParam); #if defined __ORBIS__ || defined __PSVITA__ app.GetCommerce()->HidePsStoreIcon(); diff --git a/Minecraft.Client/Common/UI/UIScene_DLCOffersMenu.cpp b/Minecraft.Client/Common/UI/UIScene_DLCOffersMenu.cpp index c109ed62b..cd9f6d6ca 100644 --- a/Minecraft.Client/Common/UI/UIScene_DLCOffersMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DLCOffersMenu.cpp @@ -16,7 +16,7 @@ UIScene_DLCOffersMenu::UIScene_DLCOffersMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { m_bProductInfoShown=false; - DLCOffersParam *param=(DLCOffersParam *)initData; + DLCOffersParam *param=static_cast(initData); m_iProductInfoIndex=param->iType; m_iCurrentDLC=0; m_iTotalDLC=0; @@ -103,7 +103,7 @@ void UIScene_DLCOffersMenu::handleTimerComplete(int id) int UIScene_DLCOffersMenu::ExitDLCOffersMenu(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_DLCOffersMenu* pClass = (UIScene_DLCOffersMenu*)pParam; + UIScene_DLCOffersMenu* pClass = static_cast(pParam); #if defined __ORBIS__ || defined __PSVITA__ app.GetCommerce()->HidePsStoreIcon(); @@ -217,7 +217,7 @@ void UIScene_DLCOffersMenu::handleInput(int iPad, int key, bool repeat, bool pre void UIScene_DLCOffersMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_OffersList: { @@ -263,7 +263,7 @@ void UIScene_DLCOffersMenu::handlePress(F64 controlId, F64 childId) int iIndex = (int)childId; StorageManager.InstallOffer(1,StorageManager.GetOffer(iIndex).wszProductID,NULL,NULL); #else - int iIndex = (int)childId; + int iIndex = static_cast(childId); ULONGLONG ullIndexA[1]; ullIndexA[0]=StorageManager.GetOffer(iIndex).qwOfferID; diff --git a/Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp b/Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp index 8f0f4c110..7d02367ab 100644 --- a/Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp @@ -20,7 +20,7 @@ UIScene_DeathMenu::UIScene_DeathMenu(int iPad, void *initData, UILayer *parentLa Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); // This just allows it to be shown gameMode->getTutorial()->showTutorialPopup(false); @@ -32,7 +32,7 @@ UIScene_DeathMenu::~UIScene_DeathMenu() Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); // This just allows it to be shown gameMode->getTutorial()->showTutorialPopup(true); @@ -81,7 +81,7 @@ void UIScene_DeathMenu::handleInput(int iPad, int key, bool repeat, bool pressed void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Respawn: m_bIgnoreInput = true; @@ -106,7 +106,7 @@ void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) int playTime = -1; if( pMinecraft->localplayers[m_iPad] != NULL ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Failed); diff --git a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp index 2a8ac9f8e..2372aa36b 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp @@ -67,7 +67,7 @@ void UIScene_DebugCreateSchematic::handleInput(int iPad, int key, bool repeat, b void UIScene_DebugCreateSchematic::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Create: { @@ -112,7 +112,7 @@ void UIScene_DebugCreateSchematic::handlePress(F64 controlId, F64 childId) case eControl_EndX: case eControl_EndY: case eControl_EndZ: - m_keyboardCallbackControl = (eControls)((int)controlId); + m_keyboardCallbackControl = static_cast((int)controlId); InputManager.RequestKeyboard(L"Enter something",L"",(DWORD)0,25,&UIScene_DebugCreateSchematic::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); break; }; @@ -120,7 +120,7 @@ void UIScene_DebugCreateSchematic::handlePress(F64 controlId, F64 childId) void UIScene_DebugCreateSchematic::handleCheckboxToggled(F64 controlId, bool selected) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_SaveMobs: m_data->bSaveMobs = selected; @@ -136,7 +136,7 @@ void UIScene_DebugCreateSchematic::handleCheckboxToggled(F64 controlId, bool sel int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) { - UIScene_DebugCreateSchematic *pClass=(UIScene_DebugCreateSchematic *)lpParam; + UIScene_DebugCreateSchematic *pClass=static_cast(lpParam); uint16_t pchText[128]; ZeroMemory(pchText, 128 * sizeof(uint16_t) ); diff --git a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp index af86d4b81..86b515c35 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp @@ -23,11 +23,11 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa Minecraft *pMinecraft = Minecraft::GetInstance(); WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", (int)pMinecraft->gameRenderer->GetFovVal()); - m_sliderFov.init(TempString,eControl_FOV,0,100,(int)pMinecraft->gameRenderer->GetFovVal()); + swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", static_cast(pMinecraft->gameRenderer->GetFovVal())); + m_sliderFov.init(TempString,eControl_FOV,0,100,static_cast(pMinecraft->gameRenderer->GetFovVal())); float currentTime = pMinecraft->level->getLevelData()->getGameTime() % 24000; - swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); + swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", static_cast(currentTime)); m_sliderTime.init(TempString,eControl_Time,0,240,currentTime/100); m_buttonRain.init(L"Toggle Rain",eControl_Rain); @@ -140,7 +140,7 @@ void UIScene_DebugOverlay::customDraw(IggyCustomDrawCallbackRegion *region) if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; int itemId = -1; - swscanf((wchar_t*)region->name,L"item_%d",&itemId); + swscanf(static_cast(region->name),L"item_%d",&itemId); if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || Item::items[itemId] == NULL) { app.DebugPrintf("This is not the control we are looking for\n"); @@ -181,7 +181,7 @@ void UIScene_DebugOverlay::handleInput(int iPad, int key, bool repeat, bool pres void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Items: { @@ -252,7 +252,7 @@ void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId) void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue) { - switch((int)sliderId) + switch(static_cast(sliderId)) { case eControl_Time: { @@ -266,17 +266,17 @@ void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue) WCHAR TempString[256]; float currentTime = currentValue * 100; - swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); + swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", static_cast(currentTime)); m_sliderTime.setLabel(TempString); } break; case eControl_FOV: { Minecraft *pMinecraft = Minecraft::GetInstance(); - pMinecraft->gameRenderer->SetFovVal((float)currentValue); + pMinecraft->gameRenderer->SetFovVal(static_cast(currentValue)); WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", (int)currentValue); + swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", static_cast(currentValue)); m_sliderFov.setLabel(TempString); } break; diff --git a/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp b/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp index dd5a429f0..de200868e 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp @@ -88,7 +88,7 @@ void UIScene_DebugSetCamera::handleInput(int iPad, int key, bool repeat, bool pr void UIScene_DebugSetCamera::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Teleport: app.SetXuiServerAction( ProfileManager.GetPrimaryPad(), @@ -100,7 +100,7 @@ void UIScene_DebugSetCamera::handlePress(F64 controlId, F64 childId) case eControl_CamZ: case eControl_YRot: case eControl_Elevation: - m_keyboardCallbackControl = (eControls)((int)controlId); + m_keyboardCallbackControl = static_cast((int)controlId); InputManager.RequestKeyboard(L"Enter something",L"",(DWORD)0,25,&UIScene_DebugSetCamera::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); break; }; @@ -108,7 +108,7 @@ void UIScene_DebugSetCamera::handlePress(F64 controlId, F64 childId) void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId, bool selected) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_LockPlayer: app.SetFreezePlayers(selected); @@ -118,7 +118,7 @@ void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId, bool selected) int UIScene_DebugSetCamera::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) { - UIScene_DebugSetCamera *pClass=(UIScene_DebugSetCamera *)lpParam; + UIScene_DebugSetCamera *pClass=static_cast(lpParam); uint16_t pchText[2048];//[128]; ZeroMemory(pchText, 2048/*128*/ * sizeof(uint16_t) ); InputManager.GetText(pchText); diff --git a/Minecraft.Client/Common/UI/UIScene_DispenserMenu.cpp b/Minecraft.Client/Common/UI/UIScene_DispenserMenu.cpp index 97cf842a9..f7fe65d69 100644 --- a/Minecraft.Client/Common/UI/UIScene_DispenserMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DispenserMenu.cpp @@ -10,14 +10,14 @@ UIScene_DispenserMenu::UIScene_DispenserMenu(int iPad, void *_initData, UILayer // Setup all the Iggy references we need for this scene initialiseMovie(); - TrapScreenInput *initData = (TrapScreenInput *)_initData; + TrapScreenInput *initData = static_cast(_initData); m_labelDispenser.init(initData->trap->getName()); Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Trap_Menu, this); } diff --git a/Minecraft.Client/Common/UI/UIScene_EULA.cpp b/Minecraft.Client/Common/UI/UIScene_EULA.cpp index 3177344df..492657b03 100644 --- a/Minecraft.Client/Common/UI/UIScene_EULA.cpp +++ b/Minecraft.Client/Common/UI/UIScene_EULA.cpp @@ -132,7 +132,7 @@ void UIScene_EULA::handleInput(int iPad, int key, bool repeat, bool pressed, boo void UIScene_EULA::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Confirm: //CD - Added for audio diff --git a/Minecraft.Client/Common/UI/UIScene_EnchantingMenu.cpp b/Minecraft.Client/Common/UI/UIScene_EnchantingMenu.cpp index 27459ccc1..ced0c45a2 100644 --- a/Minecraft.Client/Common/UI/UIScene_EnchantingMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_EnchantingMenu.cpp @@ -14,14 +14,14 @@ UIScene_EnchantingMenu::UIScene_EnchantingMenu(int iPad, void *_initData, UILaye m_enchantButton[1].init(1); m_enchantButton[2].init(2); - EnchantingScreenInput *initData = (EnchantingScreenInput *)_initData; + EnchantingScreenInput *initData = static_cast(_initData); m_labelEnchant.init( initData->name.empty() ? app.GetString(IDS_ENCHANT) : initData->name ); Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Enchanting_Menu, this); } @@ -264,7 +264,7 @@ void UIScene_EnchantingMenu::customDraw(IggyCustomDrawCallbackRegion *region) else { int slotId = -1; - swscanf((wchar_t*)region->name,L"slot_Button%d",&slotId); + swscanf(static_cast(region->name),L"slot_Button%d",&slotId); if(slotId >= 0) { // Setup GDraw, normal game render states and matrices diff --git a/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp b/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp index 2f43cada2..f06343fe5 100644 --- a/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp +++ b/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp @@ -191,7 +191,7 @@ void UIScene_EndPoem::handleDestroy() void UIScene_EndPoem::handleRequestMoreData(F64 startIndex, bool up) { - m_requestedLabel = (int)startIndex; + m_requestedLabel = static_cast(startIndex); } void UIScene_EndPoem::updateNoise() @@ -221,13 +221,13 @@ void UIScene_EndPoem::updateNoise() { if (ui.UsingBitmapFont()) { - randomChar = SharedConstants::acceptableLetters[random->nextInt((int)SharedConstants::acceptableLetters.length())]; + randomChar = SharedConstants::acceptableLetters[random->nextInt(static_cast(SharedConstants::acceptableLetters.length()))]; } else { // 4J-JEV: It'd be nice to avoid null characters when using asian languages. static wstring acceptableLetters = L"!\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_'|}~"; - randomChar = acceptableLetters[ random->nextInt((int)acceptableLetters.length()) ]; + randomChar = acceptableLetters[ random->nextInt(static_cast(acceptableLetters.length())) ]; } wstring randomCharStr = L""; diff --git a/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp b/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp index 1d24f989b..533c280f0 100644 --- a/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp @@ -11,14 +11,14 @@ UIScene_FireworksMenu::UIScene_FireworksMenu(int iPad, void *_initData, UILayer // Setup all the Iggy references we need for this scene initialiseMovie(); - FireworksScreenInput *initData = (FireworksScreenInput *)_initData; + FireworksScreenInput *initData = static_cast(_initData); m_labelFireworks.init(app.GetString(IDS_HOW_TO_PLAY_MENU_FIREWORKS)); Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Fireworks_Menu, this); } diff --git a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp index fb17bda44..66a2c5ee8 100644 --- a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp @@ -27,7 +27,7 @@ UIScene_FullscreenProgress::UIScene_FullscreenProgress(int iPad, void *initData, m_buttonConfirm.init( app.GetString( IDS_CONFIRM_OK ), eControl_Confirm ); m_buttonConfirm.setVisible(false); - LoadingInputParams *params = (LoadingInputParams *)initData; + LoadingInputParams *params = static_cast(initData); m_CompletionData = params->completionData; m_iPad=params->completionData->iPad; @@ -298,7 +298,7 @@ void UIScene_FullscreenProgress::handleInput(int iPad, int key, bool repeat, boo void UIScene_FullscreenProgress::handlePress(F64 controlId, F64 childId) { - if(m_threadCompleted && (int)controlId == eControl_Confirm) + if(m_threadCompleted && static_cast(controlId) == eControl_Confirm) { // This assumes all buttons can only be pressed with the A button ui.AnimateKeyPress(m_iPad, ACTION_MENU_A, false, true, false); diff --git a/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp b/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp index 392221a6f..3be86b109 100644 --- a/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp @@ -10,7 +10,7 @@ UIScene_FurnaceMenu::UIScene_FurnaceMenu(int iPad, void *_initData, UILayer *par // Setup all the Iggy references we need for this scene initialiseMovie(); - FurnaceScreenInput *initData = (FurnaceScreenInput *)_initData; + FurnaceScreenInput *initData = static_cast(_initData); m_furnace = initData->furnace; m_labelFurnace.init(m_furnace->getName()); @@ -23,7 +23,7 @@ UIScene_FurnaceMenu::UIScene_FurnaceMenu(int iPad, void *_initData, UILayer *par Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Furnace_Menu, this); } diff --git a/Minecraft.Client/Common/UI/UIScene_HUD.cpp b/Minecraft.Client/Common/UI/UIScene_HUD.cpp index c3d52cf9b..0e80c1f99 100644 --- a/Minecraft.Client/Common/UI/UIScene_HUD.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HUD.cpp @@ -158,7 +158,7 @@ void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion *region) if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; int slot = -1; - swscanf((wchar_t*)region->name,L"slot_%d",&slot); + swscanf(static_cast(region->name),L"slot_%d",&slot); if (slot == -1) { app.DebugPrintf("This is not the control we are looking for\n"); @@ -180,8 +180,8 @@ void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion *region) { if(uiOpacityTimer<10) { - float fStep=(80.0f-(float)ucAlpha)/10.0f; - fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + float fStep=(80.0f-static_cast(ucAlpha))/10.0f; + fVal=0.01f*(80.0f-((10.0f-static_cast(uiOpacityTimer))*fStep)); } else { @@ -190,12 +190,12 @@ void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion *region) } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } customDrawSlotControl(region,m_iPad,item,fVal,item->isFoil(),true); } @@ -679,15 +679,15 @@ void UIScene_HUD::render(S32 width, S32 height, C4JRender::eViewportType viewpor { case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - yPos = (S32)(ui.getScreenHeight() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - xPos = (S32)(ui.getScreenWidth() / 2); - yPos = (S32)(ui.getScreenHeight() / 2); + xPos = static_cast(ui.getScreenWidth() / 2); + yPos = static_cast(ui.getScreenHeight() / 2); break; } ui.setupRenderPosition(xPos, yPos); @@ -701,14 +701,14 @@ void UIScene_HUD::render(S32 width, S32 height, C4JRender::eViewportType viewpor { case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - tileHeight = (S32)(ui.getScreenHeight()); + tileHeight = static_cast(ui.getScreenHeight()); break; case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - tileWidth = (S32)(ui.getScreenWidth()); + tileWidth = static_cast(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - tileWidth = (S32)(ui.getScreenWidth()); + tileWidth = static_cast(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: @@ -796,11 +796,11 @@ void UIScene_HUD::repositionHud() { case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - height = (S32)(ui.getScreenHeight()); + height = static_cast(ui.getScreenHeight()); break; case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - width = (S32)(ui.getScreenWidth()); + width = static_cast(ui.getScreenWidth()); break; } diff --git a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp index a0d631723..304b9197b 100644 --- a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp @@ -207,7 +207,7 @@ void UIScene_HelpAndOptionsMenu::handleInput(int iPad, int key, bool repeat, boo void UIScene_HelpAndOptionsMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case BUTTON_HAO_CHANGESKIN: ui.NavigateToScene(m_iPad, eUIScene_SkinSelectMenu); diff --git a/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp index f0f6db18a..d651ecdb8 100644 --- a/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp @@ -10,14 +10,14 @@ UIScene_HopperMenu::UIScene_HopperMenu(int iPad, void *_initData, UILayer *paren // Setup all the Iggy references we need for this scene initialiseMovie(); - HopperScreenInput *initData = (HopperScreenInput *)_initData; + HopperScreenInput *initData = static_cast(_initData); m_labelDispenser.init(initData->hopper->getName()); Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Hopper_Menu, this); } diff --git a/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp index ab98e30f9..290085f70 100644 --- a/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp @@ -11,7 +11,7 @@ UIScene_HorseInventoryMenu::UIScene_HorseInventoryMenu(int iPad, void *_initData // Setup all the Iggy references we need for this scene initialiseMovie(); - HorseScreenInput *initData = (HorseScreenInput *)_initData; + HorseScreenInput *initData = static_cast(_initData); m_labelHorse.init( initData->container->getName() ); m_inventory = initData->inventory; @@ -20,7 +20,7 @@ UIScene_HorseInventoryMenu::UIScene_HorseInventoryMenu(int iPad, void *_initData Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Horse_Menu, this); } diff --git a/Minecraft.Client/Common/UI/UIScene_HowToPlay.cpp b/Minecraft.Client/Common/UI/UIScene_HowToPlay.cpp index e33e24fe7..204c31a48 100644 --- a/Minecraft.Client/Common/UI/UIScene_HowToPlay.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HowToPlay.cpp @@ -136,7 +136,7 @@ UIScene_HowToPlay::UIScene_HowToPlay(int iPad, void *initData, UILayer *parentLa // 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 ); - EHowToPlayPage eStartPage = ( EHowToPlayPage )( ( uiInitData >> 16 ) & 0xFFF ); // Ignores MSB which is set to 1! + EHowToPlayPage eStartPage = static_cast((uiInitData >> 16) & 0xFFF); // Ignores MSB which is set to 1! TelemetryManager->RecordMenuShown(m_iPad, eUIScene_HowToPlay, (ETelemetry_HowToPlay_SubMenuId)eStartPage); @@ -216,10 +216,10 @@ void UIScene_HowToPlay::handleInput(int iPad, int key, bool repeat, bool pressed if(pressed) { // Next page - int iNextPage = ( int )( m_eCurrPage ) + 1; + int iNextPage = static_cast(m_eCurrPage) + 1; if ( iNextPage != eHowToPlay_NumPages ) { - StartPage( ( EHowToPlayPage )( iNextPage ) ); + StartPage( static_cast(iNextPage) ); ui.PlayUISFX(eSFX_Press); } handled = true; @@ -229,7 +229,7 @@ void UIScene_HowToPlay::handleInput(int iPad, int key, bool repeat, bool pressed if(pressed) { // Previous page - int iPrevPage = ( int )( m_eCurrPage ) - 1; + int iPrevPage = static_cast(m_eCurrPage) - 1; // 4J Stu - Add back for future platforms #if 0 @@ -247,7 +247,7 @@ void UIScene_HowToPlay::handleInput(int iPad, int key, bool repeat, bool pressed { if ( iPrevPage >= 0 ) { - StartPage( ( EHowToPlayPage )( iPrevPage ) ); + StartPage( static_cast(iPrevPage) ); ui.PlayUISFX(eSFX_Press); } @@ -318,7 +318,7 @@ void UIScene_HowToPlay::StartPage( EHowToPlayPage ePage ) IggyStringUTF16 * stringVal = new IggyStringUTF16[paragraphs.size()]; value[0].type = IGGY_DATATYPE_number; - value[0].number = gs_pageToFlashMapping[(int)ePage]; + value[0].number = gs_pageToFlashMapping[static_cast(ePage)]; for(unsigned int i = 0; i < paragraphs.size(); ++i) { diff --git a/Minecraft.Client/Common/UI/UIScene_HowToPlayMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HowToPlayMenu.cpp index 92e8bdef8..80492d914 100644 --- a/Minecraft.Client/Common/UI/UIScene_HowToPlayMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HowToPlayMenu.cpp @@ -191,13 +191,13 @@ void UIScene_HowToPlayMenu::handleInput(int iPad, int key, bool repeat, bool pre void UIScene_HowToPlayMenu::handlePress(F64 controlId, F64 childId) { - if( (int)controlId == eControl_Buttons) + if( static_cast(controlId) == eControl_Buttons) { //CD - Added for audio ui.PlayUISFX(eSFX_Press); unsigned int uiInitData; - uiInitData = ( ( 1 << 31 ) | ( m_uiHTPSceneA[(int)childId] << 16 ) | ( short )( m_iPad ) ); + uiInitData = ( ( 1 << 31 ) | ( m_uiHTPSceneA[static_cast(childId)] << 16 ) | static_cast(m_iPad) ); ui.NavigateToScene(m_iPad, eUIScene_HowToPlay, ( void* )( uiInitData ) ); } } diff --git a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp index 68ac537ee..72f9e4fd2 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp @@ -153,7 +153,7 @@ void UIScene_InGameHostOptionsMenu::handlePress(F64 controlId, F64 childId) TeleportMenuInitData *initData = new TeleportMenuInitData(); initData->iPad = m_iPad; initData->teleportToPlayer = false; - if( (int)controlId == eControl_TeleportToPlayer ) + if( static_cast(controlId) == eControl_TeleportToPlayer ) { initData->teleportToPlayer = true; } diff --git a/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp index 57acf3458..74291b1a7 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp @@ -327,14 +327,14 @@ void UIScene_InGameInfoMenu::handleInput(int iPad, int key, bool repeat, bool pr void UIScene_InGameInfoMenu::handlePress(F64 controlId, F64 childId) { - app.DebugPrintf("Pressed = %d, %d\n", (int)controlId, (int)childId); - switch((int)controlId) + app.DebugPrintf("Pressed = %d, %d\n", static_cast(controlId), static_cast(childId)); + switch(static_cast(controlId)) { case eControl_GameOptions: ui.NavigateToScene(m_iPad,eUIScene_InGameHostOptionsMenu); break; case eControl_GamePlayers: - int currentSelection = (int)childId; + int currentSelection = static_cast(childId); INetworkPlayer *selectedPlayer = g_NetworkManager.GetPlayerBySmallId(m_players[currentSelection]->m_smallId); Minecraft *pMinecraft = Minecraft::GetInstance(); @@ -377,10 +377,10 @@ void UIScene_InGameInfoMenu::handlePress(F64 controlId, F64 childId) void UIScene_InGameInfoMenu::handleFocusChange(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_GamePlayers: - m_playerList.updateChildFocus( (int) childId ); + m_playerList.updateChildFocus( static_cast(childId) ); }; updateTooltips(); } @@ -389,7 +389,7 @@ void UIScene_InGameInfoMenu::OnPlayerChanged(void *callbackParam, INetworkPlayer { app.DebugPrintf(" Player \"%ls\" %s (smallId: %d)\n", pPlayer->GetOnlineName(), leaving ? "leaving" : "joining", pPlayer->GetSmallId()); - UIScene_InGameInfoMenu *scene = (UIScene_InGameInfoMenu *)callbackParam; + UIScene_InGameInfoMenu *scene = static_cast(callbackParam); bool playerFound = false; int foundIndex = 0; for(int i = 0; i < scene->m_players.size(); ++i) @@ -439,7 +439,7 @@ void UIScene_InGameInfoMenu::OnPlayerChanged(void *callbackParam, INetworkPlayer int UIScene_InGameInfoMenu::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - BYTE smallId = *(BYTE *)pParam; + BYTE smallId = *static_cast(pParam); delete pParam; if(result==C4JStorage::EMessage_ResultAccept) diff --git a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp index d7196849f..8872b0f3a 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp @@ -17,7 +17,7 @@ UIScene_InGamePlayerOptionsMenu::UIScene_InGamePlayerOptionsMenu(int iPad, void m_bShouldNavBack = false; - InGamePlayerOptionsInitData *initData = (InGamePlayerOptionsInitData *)_initData; + InGamePlayerOptionsInitData *initData = static_cast(_initData); m_networkSmallId = initData->networkSmallId; m_playerPrivileges = initData->playerPrivileges; @@ -428,7 +428,7 @@ void UIScene_InGamePlayerOptionsMenu::handleInput(int iPad, int key, bool repeat void UIScene_InGamePlayerOptionsMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Kick: { @@ -446,7 +446,7 @@ void UIScene_InGamePlayerOptionsMenu::handlePress(F64 controlId, F64 childId) int UIScene_InGamePlayerOptionsMenu::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - BYTE smallId = *(BYTE *)pParam; + BYTE smallId = *static_cast(pParam); delete pParam; if(result==C4JStorage::EMessage_ResultAccept) @@ -470,9 +470,9 @@ int UIScene_InGamePlayerOptionsMenu::KickPlayerReturned(void *pParam,int iPad,C4 void UIScene_InGamePlayerOptionsMenu::OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving) { app.DebugPrintf("UIScene_InGamePlayerOptionsMenu::OnPlayerChanged"); - UIScene_InGamePlayerOptionsMenu *scene = (UIScene_InGamePlayerOptionsMenu *)callbackParam; + UIScene_InGamePlayerOptionsMenu *scene = static_cast(callbackParam); - UIScene_InGameInfoMenu *infoScene = (UIScene_InGameInfoMenu *)scene->getBackScene(); + UIScene_InGameInfoMenu *infoScene = static_cast(scene->getBackScene()); if(infoScene != NULL) UIScene_InGameInfoMenu::OnPlayerChanged(infoScene,pPlayer,leaving); if(leaving && pPlayer != NULL && pPlayer->GetSmallId() == scene->m_networkSmallId) @@ -497,7 +497,7 @@ void UIScene_InGamePlayerOptionsMenu::resetCheatCheckboxes() void UIScene_InGamePlayerOptionsMenu::handleCheckboxToggled(F64 controlId, bool selected) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Op: // flag that the moderator state has changed diff --git a/Minecraft.Client/Common/UI/UIScene_InGameSaveManagementMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameSaveManagementMenu.cpp index fa2c7e613..561899897 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameSaveManagementMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameSaveManagementMenu.cpp @@ -8,7 +8,7 @@ int UIScene_InGameSaveManagementMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) { - UIScene_InGameSaveManagementMenu *pClass= (UIScene_InGameSaveManagementMenu *)lpParam; + UIScene_InGameSaveManagementMenu *pClass= static_cast(lpParam); app.DebugPrintf("Received data for save thumbnail\n"); @@ -418,12 +418,12 @@ void UIScene_InGameSaveManagementMenu::handleInput(int iPad, int key, bool repea void UIScene_InGameSaveManagementMenu::handleInitFocus(F64 controlId, F64 childId) { - app.DebugPrintf(app.USER_SR, "UIScene_InGameSaveManagementMenu::handleInitFocus - %d , %d\n", (int)controlId, (int)childId); + app.DebugPrintf(app.USER_SR, "UIScene_InGameSaveManagementMenu::handleInitFocus - %d , %d\n", static_cast(controlId), static_cast(childId)); } void UIScene_InGameSaveManagementMenu::handleFocusChange(F64 controlId, F64 childId) { - app.DebugPrintf(app.USER_SR, "UIScene_InGameSaveManagementMenu::handleFocusChange - %d , %d\n", (int)controlId, (int)childId); + app.DebugPrintf(app.USER_SR, "UIScene_InGameSaveManagementMenu::handleFocusChange - %d , %d\n", static_cast(controlId), static_cast(childId)); m_iSaveListIndex = childId; if(m_bSavesDisplayed) m_bUpdateSaveSize = true; updateTooltips(); @@ -431,7 +431,7 @@ void UIScene_InGameSaveManagementMenu::handleFocusChange(F64 controlId, F64 chil void UIScene_InGameSaveManagementMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_SavesList: { @@ -452,7 +452,7 @@ void UIScene_InGameSaveManagementMenu::handlePress(F64 controlId, F64 childId) int UIScene_InGameSaveManagementMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_InGameSaveManagementMenu* pClass = (UIScene_InGameSaveManagementMenu*)pParam; + UIScene_InGameSaveManagementMenu* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) @@ -477,7 +477,7 @@ int UIScene_InGameSaveManagementMenu::DeleteSaveDialogReturned(void *pParam,int int UIScene_InGameSaveManagementMenu::DeleteSaveDataReturned(LPVOID lpParam,bool bRes) { - UIScene_InGameSaveManagementMenu* pClass = (UIScene_InGameSaveManagementMenu*)lpParam; + UIScene_InGameSaveManagementMenu* pClass = static_cast(lpParam); if(bRes) { diff --git a/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp index 4a9dab43d..f2bdbd177 100644 --- a/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp @@ -23,17 +23,17 @@ UIScene_InventoryMenu::UIScene_InventoryMenu(int iPad, void *_initData, UILayer // Setup all the Iggy references we need for this scene initialiseMovie(); - InventoryScreenInput *initData = (InventoryScreenInput *)_initData; + InventoryScreenInput *initData = static_cast(_initData); Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[initData->iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Inventory_Menu, this); } - InventoryMenu *menu = (InventoryMenu *)initData->player->inventoryMenu; + InventoryMenu *menu = static_cast(initData->player->inventoryMenu); initData->player->awardStat(GenericStats::openInventory(),GenericStats::param_openInventory()); diff --git a/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp index c036f7bf9..c25a10855 100644 --- a/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp @@ -16,7 +16,7 @@ UIScene_JoinMenu::UIScene_JoinMenu(int iPad, void *_initData, UILayer *parentLay // Setup all the Iggy references we need for this scene initialiseMovie(); - JoinMenuInitData *initData = (JoinMenuInitData *)_initData; + JoinMenuInitData *initData = static_cast(_initData); m_selectedSession = initData->selectedSession; m_friendInfoUpdatedOK = false; m_friendInfoUpdatedERROR = false; @@ -224,7 +224,7 @@ void UIScene_JoinMenu::tick() void UIScene_JoinMenu::friendSessionUpdated(bool success, void *pParam) { - UIScene_JoinMenu *scene = (UIScene_JoinMenu *)pParam; + UIScene_JoinMenu *scene = static_cast(pParam); ui.NavigateBack(scene->m_iPad); if( success ) { @@ -238,7 +238,7 @@ void UIScene_JoinMenu::friendSessionUpdated(bool success, void *pParam) int UIScene_JoinMenu::ErrorDialogReturned(void *pParam, int iPad, const C4JStorage::EMessageResult) { - UIScene_JoinMenu *scene = (UIScene_JoinMenu *)pParam; + UIScene_JoinMenu *scene = static_cast(pParam); ui.NavigateBack(scene->m_iPad); return 0; @@ -301,7 +301,7 @@ void UIScene_JoinMenu::handleInput(int iPad, int key, bool repeat, bool pressed, void UIScene_JoinMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_JoinGame: { @@ -324,10 +324,10 @@ void UIScene_JoinMenu::handlePress(F64 controlId, F64 childId) void UIScene_JoinMenu::handleFocusChange(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_GamePlayers: - m_buttonListPlayers.updateChildFocus( (int) childId ); + m_buttonListPlayers.updateChildFocus( static_cast(childId) ); }; updateTooltips(); } @@ -370,7 +370,7 @@ void UIScene_JoinMenu::StartSharedLaunchFlow() int UIScene_JoinMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - UIScene_JoinMenu* pClass = (UIScene_JoinMenu*)ui.GetSceneFromCallbackId((size_t)pParam); + UIScene_JoinMenu* pClass = static_cast(ui.GetSceneFromCallbackId((size_t)pParam)); if(pClass) { diff --git a/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp b/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp index 9e46a42e9..15de62bfc 100644 --- a/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp +++ b/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp @@ -28,7 +28,7 @@ UIScene_Keyboard::UIScene_Keyboard(int iPad, void *initData, UILayer *parentLaye m_bPCMode = false; if (initData) { - UIKeyboardInitData* kbData = (UIKeyboardInitData*)initData; + UIKeyboardInitData* kbData = static_cast(initData); m_win64Callback = kbData->callback; m_win64CallbackParam = kbData->lpParam; if (kbData->title) titleText = kbData->title; @@ -105,7 +105,7 @@ UIScene_Keyboard::UIScene_Keyboard(int iPad, void *initData, UILayer *parentLaye }; IggyName nameVisible = registerFastName(L"visible"); IggyValuePath* root = IggyPlayerRootPath(getMovie()); - for (int i = 0; i < (int)(sizeof(s_keyNames) / sizeof(s_keyNames[0])); ++i) + for (int i = 0; i < static_cast(sizeof(s_keyNames) / sizeof(s_keyNames[0])); ++i) { IggyValuePath keyPath; if (IggyValuePathMakeNameRef(&keyPath, root, s_keyNames[i])) @@ -186,7 +186,7 @@ void UIScene_Keyboard::tick() m_bKeyboardDonePressed = true; } } - else if ((int)m_win64TextBuffer.length() < m_win64MaxChars) + else if (static_cast(m_win64TextBuffer.length()) < m_win64MaxChars) { m_win64TextBuffer += ch; changed = true; @@ -275,7 +275,7 @@ void UIScene_Keyboard::handleInput(int iPad, int key, bool repeat, bool pressed, void UIScene_Keyboard::handlePress(F64 controlId, F64 childId) { - if((int)controlId == 0) + if(static_cast(controlId) == 0) { // Done has been pressed. At this point we can query for the input string and pass it on to wherever it is needed. // we can not query for m_KeyboardTextInput.getLabel() here because we're in an iggy callback so we need to wait a frame. diff --git a/Minecraft.Client/Common/UI/UIScene_LanguageSelector.cpp b/Minecraft.Client/Common/UI/UIScene_LanguageSelector.cpp index e9dc7eb92..4950f3229 100644 --- a/Minecraft.Client/Common/UI/UIScene_LanguageSelector.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LanguageSelector.cpp @@ -112,14 +112,14 @@ void UIScene_LanguageSelector::handleInput(int iPad, int key, bool repeat, bool void UIScene_LanguageSelector::handlePress(F64 controlId, F64 childId) { - if( (int)controlId == eControl_Buttons ) + if( static_cast(controlId) == eControl_Buttons ) { //CD - Added for audio ui.PlayUISFX(eSFX_Press); int newLanguage, newLocale; - newLanguage = uiLangMap[(int)childId]; - newLocale = uiLocaleMap[(int)childId]; + newLanguage = uiLangMap[static_cast(childId)]; + newLocale = uiLocaleMap[static_cast(childId)]; app.SetMinecraftLanguage(m_iPad, newLanguage); app.SetMinecraftLocale(m_iPad, newLocale); diff --git a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index d6f89832c..c48cab3ac 100644 --- a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -20,7 +20,7 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu(int iPad, void *ini // Setup all the Iggy references we need for this scene initialiseMovie(); - m_params = (LaunchMoreOptionsMenuInitData *)initData; + m_params = static_cast(initData); m_labelWorldOptions.init(app.GetString(IDS_WORLD_OPTIONS)); @@ -116,9 +116,9 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu(int iPad, void *ini if(m_params->currentWorldSize != e_worldSize_Unknown) { m_labelWorldResize.init(app.GetString(IDS_INCREASE_WORLD_SIZE)); - int min= int(m_params->currentWorldSize)-1; + int min= static_cast(m_params->currentWorldSize)-1; int max=3; - int curr = int(m_params->newWorldSize)-1; + int curr = static_cast(m_params->newWorldSize)-1; m_sliderWorldResize.init(app.GetString(m_iWorldSizeTitleA[curr]),eControl_WorldResize,min,max,curr); m_checkboxes[eLaunchCheckbox_WorldResizeType].init(app.GetString(IDS_INCREASE_WORLD_SIZE_OVERWRITE_EDGES),eLaunchCheckbox_WorldResizeType,m_params->newWorldSizeOverwriteEdges); } @@ -349,7 +349,7 @@ void UIScene_LaunchMoreOptionsMenu::handleCheckboxToggled(F64 controlId, bool se //CD - Added for audio ui.PlayUISFX(eSFX_Press); - switch((EControls)((int)controlId)) + switch(static_cast((int)controlId)) { case eLaunchCheckbox_Online: m_params->bOnlineGame = selected; @@ -423,7 +423,7 @@ void UIScene_LaunchMoreOptionsMenu::handleCheckboxToggled(F64 controlId, bool se void UIScene_LaunchMoreOptionsMenu::handleFocusChange(F64 controlId, F64 childId) { int stringId = 0; - switch((int)controlId) + switch(static_cast(controlId)) { case eLaunchCheckbox_Online: stringId = IDS_GAMEOPTION_ONLINE; @@ -544,7 +544,7 @@ void UIScene_LaunchMoreOptionsMenu::handleTimerComplete(int id) int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(LPVOID lpParam,bool bRes) { - UIScene_LaunchMoreOptionsMenu *pClass=(UIScene_LaunchMoreOptionsMenu *)lpParam; + UIScene_LaunchMoreOptionsMenu *pClass=static_cast(lpParam); pClass->m_bIgnoreInput=false; // 4J HEG - No reason to set value if keyboard was cancelled if (bRes) @@ -568,7 +568,7 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId) { if(m_bIgnoreInput) return; - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_EditSeed: { @@ -598,8 +598,8 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId) void UIScene_LaunchMoreOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - int value = (int)currentValue; - switch((int)sliderId) + int value = static_cast(currentValue); + switch(static_cast(sliderId)) { case eControl_WorldSize: #ifdef _LARGE_WORLDS @@ -610,11 +610,11 @@ void UIScene_LaunchMoreOptionsMenu::handleSliderMove(F64 sliderId, F64 currentVa break; case eControl_WorldResize: #ifdef _LARGE_WORLDS - EGameHostOptionWorldSize changedSize = EGameHostOptionWorldSize(value+1); + EGameHostOptionWorldSize changedSize = static_cast(value + 1); if(changedSize >= m_params->currentWorldSize) { m_sliderWorldResize.handleSliderMove(value); - m_params->newWorldSize = EGameHostOptionWorldSize(value+1); + m_params->newWorldSize = static_cast(value + 1); m_sliderWorldResize.setLabel(app.GetString(m_iWorldSizeTitleA[value])); } #endif diff --git a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp index 12b219053..59268cb86 100644 --- a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp @@ -438,7 +438,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) } else { - m_newEntryIndex = (unsigned int)startIndex; + m_newEntryIndex = static_cast(startIndex); // m_newReadSize = min((int)READ_SIZE, (int)m_leaderboard.m_totalEntryCount-(startIndex-1)); } @@ -462,7 +462,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) { m_interface.ReadStats_TopRank( this, - m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard, + m_currentDifficulty, static_cast(m_currentLeaderboard), m_newEntryIndex, m_newReadSize ); } @@ -472,7 +472,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) PlayerUID uid; ProfileManager.GetXUID(ProfileManager.GetPrimaryPad(),&uid, true); m_interface.ReadStats_MyScore( this, - m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard, + m_currentDifficulty, static_cast(m_currentLeaderboard), uid /*ignored on PS3*/, m_newReadSize ); @@ -483,7 +483,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) PlayerUID uid; ProfileManager.GetXUID(ProfileManager.GetPrimaryPad(),&uid, true); m_interface.ReadStats_Friends( this, - m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard, + m_currentDifficulty, static_cast(m_currentLeaderboard), uid /*ignored on PS3*/, m_newEntryIndex, m_newReadSize ); @@ -558,7 +558,7 @@ bool UIScene_LeaderboardsMenu::RetrieveStats() else { m_leaderboard.m_entries[entryIndex].m_columns[i] = UINT_MAX; - swprintf(m_leaderboard.m_entries[entryIndex].m_wcColumns[i], 12, L"%.1fkm", ((float)m_leaderboard.m_entries[entryIndex].m_columns[i])/100.f/1000.f); + swprintf(m_leaderboard.m_entries[entryIndex].m_wcColumns[i], 12, L"%.1fkm", static_cast(m_leaderboard.m_entries[entryIndex].m_columns[i])/100.f/1000.f); } } @@ -781,7 +781,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(LeaderboardManager::ReadScor else if(iDigitC<8) { // km with a .X - swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%.1fkm", ((float)leaderboardEntry->m_columns[i])/1000.f); + swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%.1fkm", static_cast(leaderboardEntry->m_columns[i])/1000.f); #ifdef _DEBUG //app.DebugPrintf("Display - %.1fkm\n", ((float)leaderboardEntry->m_columns[i])/1000.f); #endif @@ -789,7 +789,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(LeaderboardManager::ReadScor else { // bigger than that, so no decimal point - swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%.0fkm", ((float)leaderboardEntry->m_columns[i])/1000.f); + swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%.0fkm", static_cast(leaderboardEntry->m_columns[i])/1000.f); #ifdef _DEBUG //app.DebugPrintf("Display - %.0fkm\n", ((float)leaderboardEntry->m_columns[i])/1000.f); #endif @@ -964,7 +964,7 @@ int UIScene_LeaderboardsMenu::SetLeaderboardTitleIcons() void UIScene_LeaderboardsMenu::customDraw(IggyCustomDrawCallbackRegion *region) { int slotId = -1; - swscanf((wchar_t*)region->name,L"slot_%d",&slotId); + swscanf(static_cast(region->name),L"slot_%d",&slotId); if (slotId == -1) { //app.DebugPrintf("This is not the control we are looking for\n"); @@ -979,14 +979,14 @@ void UIScene_LeaderboardsMenu::customDraw(IggyCustomDrawCallbackRegion *region) void UIScene_LeaderboardsMenu::handleSelectionChanged(F64 selectedId) { ui.PlayUISFX(eSFX_Focus); - m_newSel = (int)selectedId; + m_newSel = static_cast(selectedId); updateTooltips(); } // Handle a request from Iggy for more data void UIScene_LeaderboardsMenu::handleRequestMoreData(F64 startIndex, bool up) { - unsigned int item = (int)startIndex; + unsigned int item = static_cast(startIndex); if( m_leaderboard.m_totalEntryCount > 0 && (item+1) < GetEntryStartIndex() ) { @@ -995,7 +995,7 @@ void UIScene_LeaderboardsMenu::handleRequestMoreData(F64 startIndex, bool up) int readIndex = (GetEntryStartIndex() + 1) - READ_SIZE; if( readIndex <= 0 ) readIndex = 1; - assert( readIndex >= 1 && readIndex <= (int)m_leaderboard.m_totalEntryCount ); + assert( readIndex >= 1 && readIndex <= static_cast(m_leaderboard.m_totalEntryCount)); ReadStats(readIndex); } } @@ -1004,7 +1004,7 @@ void UIScene_LeaderboardsMenu::handleRequestMoreData(F64 startIndex, bool up) if( LeaderboardManager::Instance()->isIdle() ) { int readIndex = (GetEntryStartIndex() + 1) + m_leaderboard.m_entries.size(); - assert( readIndex >= 1 && readIndex <= (int)m_leaderboard.m_totalEntryCount ); + assert( readIndex >= 1 && readIndex <= static_cast(m_leaderboard.m_totalEntryCount)); ReadStats(readIndex); } } @@ -1033,7 +1033,7 @@ void UIScene_LeaderboardsMenu::handleTimerComplete(int id) int UIScene_LeaderboardsMenu::ExitLeaderboards(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_LeaderboardsMenu* pClass = (UIScene_LeaderboardsMenu*)pParam; + UIScene_LeaderboardsMenu* pClass = static_cast(pParam); pClass->navigateBack(); diff --git a/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp index ed3c8137e..51a3bb610 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp @@ -34,7 +34,7 @@ int UIScene_LoadMenu::m_iDifficultyTitleSettingA[4]= int UIScene_LoadMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) { - UIScene_LoadMenu *pClass= (UIScene_LoadMenu *)ui.GetSceneFromCallbackId((size_t)lpParam); + UIScene_LoadMenu *pClass= static_cast(ui.GetSceneFromCallbackId((size_t)lpParam)); if(pClass) { @@ -64,7 +64,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye // Setup all the Iggy references we need for this scene initialiseMovie(); - LoadMenuInitData *params = (LoadMenuInitData *)initData; + LoadMenuInitData *params = static_cast(initData); m_labelGameName.init(app.GetString(IDS_WORLD_NAME)); m_labelSeed.init(L""); @@ -477,7 +477,7 @@ void UIScene_LoadMenu::tick() m_MoreOptionsParams.bTNT = app.GetGameHostOption(uiHostOptions,eGameHostOption_TNT)>0?TRUE:FALSE; m_MoreOptionsParams.bHostPrivileges = app.GetGameHostOption(uiHostOptions,eGameHostOption_CheatsEnabled)>0?TRUE:FALSE; m_MoreOptionsParams.bDisableSaving = app.GetGameHostOption(uiHostOptions,eGameHostOption_DisableSaving)>0?TRUE:FALSE; - m_MoreOptionsParams.currentWorldSize = (EGameHostOptionWorldSize)app.GetGameHostOption(uiHostOptions,eGameHostOption_WorldSize); + m_MoreOptionsParams.currentWorldSize = static_cast(app.GetGameHostOption(uiHostOptions, eGameHostOption_WorldSize)); m_MoreOptionsParams.newWorldSize = m_MoreOptionsParams.currentWorldSize; m_MoreOptionsParams.bMobGriefing = app.GetGameHostOption(uiHostOptions, eGameHostOption_MobGriefing); @@ -696,7 +696,7 @@ void UIScene_LoadMenu::handlePress(F64 controlId, F64 childId) //CD - Added for audio ui.PlayUISFX(eSFX_Press); - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_GameMode: switch(m_iGameModeId) @@ -725,7 +725,7 @@ void UIScene_LoadMenu::handlePress(F64 controlId, F64 childId) break; case eControl_TexturePackList: { - UpdateCurrentTexturePack((int)childId); + UpdateCurrentTexturePack(static_cast(childId)); } break; case eControl_LoadWorld: @@ -821,7 +821,7 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() { // texture pack hasn't been set yet, so check what it will be TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexturePack; + DLCTexturePack *pDLCTexPack=static_cast(pTexturePack); m_pDLCPack=pDLCTexPack->getDLCInfoParentPack(); // do we have a license? @@ -946,8 +946,8 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() void UIScene_LoadMenu::handleSliderMove(F64 sliderId, F64 currentValue) { WCHAR TempString[256]; - int value = (int)currentValue; - switch((int)sliderId) + int value = static_cast(currentValue); + switch(static_cast(sliderId)) { case eControl_Difficulty: m_sliderDifficulty.handleSliderMove(value); @@ -1182,7 +1182,7 @@ void UIScene_LoadMenu::LaunchGame(void) int UIScene_LoadMenu::CheckResetNetherReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; + UIScene_LoadMenu* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) @@ -1206,7 +1206,7 @@ int UIScene_LoadMenu::CheckResetNetherReturned(void *pParam,int iPad,C4JStorage: int UIScene_LoadMenu::ConfirmLoadReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; + UIScene_LoadMenu* pClass = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { @@ -1246,7 +1246,7 @@ int UIScene_LoadMenu::ConfirmLoadReturned(void *pParam,int iPad,C4JStorage::EMes int UIScene_LoadMenu::LoadDataComplete(void *pParam) { - UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; + UIScene_LoadMenu* pClass = static_cast(pParam); if(!pClass->m_bIsCorrupt) { @@ -1484,7 +1484,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) int UIScene_LoadMenu::LoadSaveDataReturned(void *pParam,bool bIsCorrupt, bool bIsOwner) { - UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; + UIScene_LoadMenu* pClass = static_cast(pParam); pClass->m_bIsCorrupt=bIsCorrupt; @@ -1520,13 +1520,13 @@ int UIScene_LoadMenu::LoadSaveDataReturned(void *pParam,bool bIsCorrupt, bool bI int UIScene_LoadMenu::TrophyDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; + UIScene_LoadMenu* pClass = static_cast(pParam); return LoadDataComplete(pClass); } int UIScene_LoadMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; + UIScene_LoadMenu* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) @@ -1543,7 +1543,7 @@ int UIScene_LoadMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage: int UIScene_LoadMenu::DeleteSaveDataReturned(void *pParam,bool bSuccess) { - UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; + UIScene_LoadMenu* pClass = static_cast(pParam); app.SetCorruptSaveDeleted(true); pClass->navigateBack(); @@ -1642,7 +1642,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocal LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); // Reset the autosave time app.SetAutosaveTimerTime(); @@ -1676,7 +1676,7 @@ void UIScene_LoadMenu::checkStateAndStartGame() int UIScene_LoadMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; + UIScene_LoadMenu* pClass = static_cast(pParam); if(bContinue==true) { diff --git a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp index 8664aca12..ed49a701b 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp @@ -42,7 +42,7 @@ static wstring ReadLevelNameFromSaveFile(const wstring& filePath) char buf[128] = {}; if (fgets(buf, sizeof(buf), fr)) { - int len = (int)strlen(buf); + int len = static_cast(strlen(buf)); while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r' || buf[len-1] == ' ')) buf[--len] = '\0'; fclose(fr); @@ -172,7 +172,7 @@ C4JStorage::SAVETRANSFER_FILE_DETAILS UIScene_LoadOrJoinMenu::m_debugTransferDet int UIScene_LoadOrJoinMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) { - UIScene_LoadOrJoinMenu *pClass= (UIScene_LoadOrJoinMenu *)lpParam; + UIScene_LoadOrJoinMenu *pClass= static_cast(lpParam); app.DebugPrintf("Received data for save thumbnail\n"); @@ -1015,7 +1015,7 @@ void UIScene_LoadOrJoinMenu::GetSaveInfo() if( savesDir.exists() ) { m_saves = savesDir.listFiles(); - uiSaveC = (unsigned int)m_saves->size(); + uiSaveC = static_cast(m_saves->size()); } // add the New Game and Tutorial after the saves list is retrieved, if there are any saves @@ -1353,7 +1353,7 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, bool pr int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bool bRes) { // 4J HEG - No reason to set value if keyboard was cancelled - UIScene_LoadOrJoinMenu *pClass=(UIScene_LoadOrJoinMenu *)lpParam; + UIScene_LoadOrJoinMenu *pClass=static_cast(lpParam); pClass->m_bIgnoreInput=false; if (bRes) { @@ -1378,7 +1378,7 @@ int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,boo // Convert the ui16Text input to a wide string wchar_t wNewName[128] = {}; for (int k = 0; k < 127 && ui16Text[k]; k++) - wNewName[k] = (wchar_t)ui16Text[k]; + wNewName[k] = static_cast(ui16Text[k]); // Convert to narrow for storage and in-memory update char narrowName[128] = {}; @@ -1422,18 +1422,18 @@ int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,boo } void UIScene_LoadOrJoinMenu::handleInitFocus(F64 controlId, F64 childId) { - app.DebugPrintf(app.USER_SR, "UIScene_LoadOrJoinMenu::handleInitFocus - %d , %d\n", (int)controlId, (int)childId); + app.DebugPrintf(app.USER_SR, "UIScene_LoadOrJoinMenu::handleInitFocus - %d , %d\n", static_cast(controlId), static_cast(childId)); } void UIScene_LoadOrJoinMenu::handleFocusChange(F64 controlId, F64 childId) { - app.DebugPrintf(app.USER_SR, "UIScene_LoadOrJoinMenu::handleFocusChange - %d , %d\n", (int)controlId, (int)childId); + app.DebugPrintf(app.USER_SR, "UIScene_LoadOrJoinMenu::handleFocusChange - %d , %d\n", static_cast(controlId), static_cast(childId)); - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_GamesList: m_iGameListIndex = childId; - m_buttonListGames.updateChildFocus( (int) childId ); + m_buttonListGames.updateChildFocus( static_cast(childId) ); break; case eControl_SavesList: m_iSaveListIndex = childId; @@ -1455,18 +1455,18 @@ void UIScene_LoadOrJoinMenu::remoteStorageGetSaveCallback(LPVOID lpParam, SonyRe void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_SavesList: { m_bIgnoreInput=true; - int lGenID = (int)childId - 1; + int lGenID = static_cast(childId) - 1; //CD - Added for audio ui.PlayUISFX(eSFX_Press); - if((int)childId == JOIN_LOAD_CREATE_BUTTON_INDEX) + if(static_cast(childId) == JOIN_LOAD_CREATE_BUTTON_INDEX) { app.SetTutorialMode( false ); @@ -1524,17 +1524,17 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) if(app.DebugSettingsOn() && app.GetLoadSavesFromFolderEnabled()) { - LoadSaveFromDisk(m_saves->at((int)childId-m_iDefaultButtonsC)); + LoadSaveFromDisk(m_saves->at(static_cast(childId)-m_iDefaultButtonsC)); } else { LoadMenuInitData *params = new LoadMenuInitData(); params->iPad = m_iPad; // need to get the iIndex from the list item, since the position in the list doesn't correspond to the GetSaveGameInfo list because of sorting - params->iSaveGameInfoIndex=m_saveDetails[((int)childId)-m_iDefaultButtonsC].saveId; + params->iSaveGameInfoIndex=m_saveDetails[static_cast(childId)-m_iDefaultButtonsC].saveId; //params->pbSaveRenamed=&m_bSaveRenamed; params->levelGen = NULL; - params->saveDetails = &m_saveDetails[ ((int)childId)-m_iDefaultButtonsC ]; + params->saveDetails = &m_saveDetails[ static_cast(childId)-m_iDefaultButtonsC ]; #ifdef _XBOX_ONE // On XB1, saves might need syncing, in which case inform the user so they can decide whether they want to wait for this to happen @@ -1568,7 +1568,7 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) ui.PlayUISFX(eSFX_Press); { - int nIndex = (int)childId; + int nIndex = static_cast(childId); m_iGameListIndex = nIndex; CheckAndJoinGame(nIndex); } @@ -1818,7 +1818,7 @@ void UIScene_LoadOrJoinMenu::LoadLevelGen(LevelGenerationOptions *levelGen) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1834,7 +1834,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesListCallback(LPVOID pParam) { if(pParam != NULL) { - UIScene_LoadOrJoinMenu *pScene = (UIScene_LoadOrJoinMenu *)pParam; + UIScene_LoadOrJoinMenu *pScene = static_cast(pParam); pScene->UpdateGamesList(); } } @@ -1879,7 +1879,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() // Update the xui list displayed unsigned int xuiListSize = m_buttonListGames.getItemCount(); - unsigned int filteredListSize = (unsigned int)m_currentSessions->size(); + unsigned int filteredListSize = static_cast(m_currentSessions->size()); BOOL gamesListHasFocus = DoesGamesListHaveFocus(); @@ -2170,7 +2170,7 @@ void UIScene_LoadOrJoinMenu::LoadSaveFromDisk(File *saveFile, ESavePlatform save LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -2276,7 +2276,7 @@ static bool Win64_DeleteSaveDirectory(const wchar_t* wPath) int UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam; + UIScene_LoadOrJoinMenu* pClass = static_cast(pParam); // results switched for this dialog // Check that we have a valid save selected (can get a bad index if the save list has been refreshed) @@ -2322,7 +2322,7 @@ int UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JSt int UIScene_LoadOrJoinMenu::DeleteSaveDataReturned(LPVOID lpParam,bool bRes) { ui.EnterCallbackIdCriticalSection(); - UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)ui.GetSceneFromCallbackId((size_t)lpParam); + UIScene_LoadOrJoinMenu* pClass = static_cast(ui.GetSceneFromCallbackId((size_t)lpParam)); if(pClass) { @@ -2342,7 +2342,7 @@ int UIScene_LoadOrJoinMenu::DeleteSaveDataReturned(LPVOID lpParam,bool bRes) int UIScene_LoadOrJoinMenu::RenameSaveDataReturned(LPVOID lpParam,bool bRes) { - UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParam; + UIScene_LoadOrJoinMenu* pClass = static_cast(lpParam); if(bRes) { @@ -2374,7 +2374,7 @@ void UIScene_LoadOrJoinMenu::LoadRemoteFileFromDisk(char* remoteFilename) int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam; + UIScene_LoadOrJoinMenu* pClass = static_cast(pParam); // results switched for this dialog // EMessage_ResultAccept means cancel @@ -2545,7 +2545,7 @@ int UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack(void *pParam,bool bCon int UIScene_LoadOrJoinMenu::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_LoadOrJoinMenu *pClass = (UIScene_LoadOrJoinMenu *)pParam; + UIScene_LoadOrJoinMenu *pClass = static_cast(pParam); // Exit with or without saving if(result==C4JStorage::EMessage_ResultAccept) diff --git a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp index fe743adc2..d8d6d66ae 100644 --- a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp @@ -12,7 +12,7 @@ Random *UIScene_MainMenu::random = new Random(); -EUIScene UIScene_MainMenu::eNavigateWhenReady = (EUIScene) -1; +EUIScene UIScene_MainMenu::eNavigateWhenReady = static_cast(-1); UIScene_MainMenu::UIScene_MainMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { @@ -33,29 +33,29 @@ UIScene_MainMenu::UIScene_MainMenu(int iPad, void *initData, UILayer *parentLaye m_bIgnorePress=false; - m_buttons[(int)eControl_PlayGame].init(IDS_PLAY_GAME,eControl_PlayGame); + m_buttons[static_cast(eControl_PlayGame)].init(IDS_PLAY_GAME,eControl_PlayGame); #ifdef _XBOX_ONE if(!ProfileManager.IsFullVersion()) m_buttons[(int)eControl_PlayGame].setLabel(IDS_PLAY_TRIAL_GAME); app.SetReachedMainMenu(); #endif - m_buttons[(int)eControl_Leaderboards].init(IDS_LEADERBOARDS,eControl_Leaderboards); - m_buttons[(int)eControl_Achievements].init( (UIString)IDS_ACHIEVEMENTS,eControl_Achievements); - m_buttons[(int)eControl_HelpAndOptions].init(IDS_HELP_AND_OPTIONS,eControl_HelpAndOptions); + m_buttons[static_cast(eControl_Leaderboards)].init(IDS_LEADERBOARDS,eControl_Leaderboards); + m_buttons[static_cast(eControl_Achievements)].init( (UIString)IDS_ACHIEVEMENTS,eControl_Achievements); + m_buttons[static_cast(eControl_HelpAndOptions)].init(IDS_HELP_AND_OPTIONS,eControl_HelpAndOptions); if(ProfileManager.IsFullVersion()) { m_bTrialVersion=false; - m_buttons[(int)eControl_UnlockOrDLC].init(IDS_DOWNLOADABLECONTENT,eControl_UnlockOrDLC); + m_buttons[static_cast(eControl_UnlockOrDLC)].init(IDS_DOWNLOADABLECONTENT,eControl_UnlockOrDLC); } else { m_bTrialVersion=true; - m_buttons[(int)eControl_UnlockOrDLC].init(IDS_UNLOCK_FULL_GAME,eControl_UnlockOrDLC); + m_buttons[static_cast(eControl_UnlockOrDLC)].init(IDS_UNLOCK_FULL_GAME,eControl_UnlockOrDLC); } #ifndef _DURANGO - m_buttons[(int)eControl_Exit].init(app.GetString(IDS_EXIT_GAME),eControl_Exit); + m_buttons[static_cast(eControl_Exit)].init(app.GetString(IDS_EXIT_GAME),eControl_Exit); #else m_buttons[(int)eControl_XboxHelp].init(IDS_XBOX_HELP_APP, eControl_XboxHelp); #endif @@ -182,7 +182,7 @@ void UIScene_MainMenu::handleGainFocus(bool navBack) if(navBack && ProfileManager.IsFullVersion()) { // Replace the Unlock Full Game with Downloadable Content - m_buttons[(int)eControl_UnlockOrDLC].setLabel(IDS_DOWNLOADABLECONTENT); + m_buttons[static_cast(eControl_UnlockOrDLC)].setLabel(IDS_DOWNLOADABLECONTENT); } #if TO_BE_IMPLEMENTED @@ -196,7 +196,7 @@ void UIScene_MainMenu::handleGainFocus(bool navBack) #ifdef __PSVITA__ int splashIndex = eSplashRandomStart + 2 + random->nextInt( (int)m_splashes.size() - (eSplashRandomStart + 2) ); #else - int splashIndex = eSplashRandomStart + 1 + random->nextInt( (int)m_splashes.size() - (eSplashRandomStart + 1) ); + int splashIndex = eSplashRandomStart + 1 + random->nextInt( static_cast(m_splashes.size()) - (eSplashRandomStart + 1) ); #endif // Override splash text on certain dates @@ -308,7 +308,7 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = NULL; #endif - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_PlayGame: #ifdef __ORBIS__ @@ -466,10 +466,10 @@ void UIScene_MainMenu::customDrawSplash(IggyCustomDrawCallbackRegion *region) // 4J Stu - Move this to the ctor when the main menu is not the first scene we navigate to ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); // Setup GDraw, normal game render states and matrices @@ -513,7 +513,7 @@ void UIScene_MainMenu::customDrawSplash(IggyCustomDrawCallbackRegion *region) int UIScene_MainMenu::MustSignInReturned(void *pParam, int iPad, C4JStorage::EMessageResult result) { - UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; + UIScene_MainMenu* pClass = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { @@ -643,7 +643,7 @@ int UIScene_MainMenu::HelpAndOptions_SignInReturned(void *pParam,bool bContinue, int UIScene_MainMenu::HelpAndOptions_SignInReturned(void *pParam,bool bContinue,int iPad) #endif { - UIScene_MainMenu *pClass = (UIScene_MainMenu *)pParam; + UIScene_MainMenu *pClass = static_cast(pParam); if(bContinue) { @@ -714,7 +714,7 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void *pParam, bool bContinue, in int UIScene_MainMenu::CreateLoad_SignInReturned(void *pParam, bool bContinue, int iPad) #endif { - UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; + UIScene_MainMenu* pClass = static_cast(pParam); if(bContinue) { @@ -916,7 +916,7 @@ int UIScene_MainMenu::Leaderboards_SignInReturned(void *pParam,bool bContinue,in int UIScene_MainMenu::Leaderboards_SignInReturned(void *pParam,bool bContinue,int iPad) #endif { - UIScene_MainMenu *pClass = (UIScene_MainMenu *)pParam; + UIScene_MainMenu *pClass = static_cast(pParam); if(bContinue) { @@ -986,7 +986,7 @@ int UIScene_MainMenu::Achievements_SignInReturned(void *pParam,bool bContinue,in int UIScene_MainMenu::Achievements_SignInReturned(void *pParam,bool bContinue,int iPad) #endif { - UIScene_MainMenu *pClass = (UIScene_MainMenu *)pParam; + UIScene_MainMenu *pClass = static_cast(pParam); if (bContinue) { @@ -1020,7 +1020,7 @@ int UIScene_MainMenu::UnlockFullGame_SignInReturned(void *pParam,bool bContinue, int UIScene_MainMenu::UnlockFullGame_SignInReturned(void *pParam,bool bContinue,int iPad) #endif { - UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; + UIScene_MainMenu* pClass = static_cast(pParam); if (bContinue) { @@ -1898,7 +1898,7 @@ void UIScene_MainMenu::tick() { app.DebugPrintf("[MainMenu] Navigating away from MainMenu.\n"); ui.NavigateToScene(lockedProfile, eNavigateWhenReady); - eNavigateWhenReady = (EUIScene) -1; + eNavigateWhenReady = static_cast(-1); } #ifdef _DURANGO else @@ -2110,7 +2110,7 @@ void UIScene_MainMenu::LoadTrial(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -2129,7 +2129,7 @@ void UIScene_MainMenu::LoadTrial(void) void UIScene_MainMenu::handleUnlockFullVersion() { - m_buttons[(int)eControl_UnlockOrDLC].setLabel(IDS_DOWNLOADABLECONTENT,true); + m_buttons[static_cast(eControl_UnlockOrDLC)].setLabel(IDS_DOWNLOADABLECONTENT,true); } diff --git a/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp b/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp index 6b8dc552e..52a878e8b 100644 --- a/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp +++ b/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp @@ -7,7 +7,7 @@ UIScene_MessageBox::UIScene_MessageBox(int iPad, void *initData, UILayer *parent // Setup all the Iggy references we need for this scene initialiseMovie(); - MessageBoxInfo *param = (MessageBoxInfo *)initData; + MessageBoxInfo *param = static_cast(initData); m_buttonCount = param->uiOptionC; @@ -84,7 +84,7 @@ void UIScene_MessageBox::handleReload() value[0].number = m_buttonCount; value[1].type = IGGY_DATATYPE_number; - value[1].number = (F64)getControlFocus(); + value[1].number = static_cast(getControlFocus()); IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcInit , 2 , value ); out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , NULL ); @@ -120,7 +120,7 @@ void UIScene_MessageBox::handleInput(int iPad, int key, bool repeat, bool presse void UIScene_MessageBox::handlePress(F64 controlId, F64 childId) { C4JStorage::EMessageResult result = C4JStorage::EMessage_Cancelled; - switch((int)controlId) + switch(static_cast(controlId)) { case 0: result = C4JStorage::EMessage_ResultAccept; diff --git a/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp b/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp index 998679cab..c3136deb9 100644 --- a/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp +++ b/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp @@ -100,7 +100,7 @@ void UIScene_NewUpdateMessage::handleInput(int iPad, int key, bool repeat, bool void UIScene_NewUpdateMessage::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Confirm: { diff --git a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp index 6f502db86..772971370 100644 --- a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp @@ -103,7 +103,7 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); // This just allows it to be shown gameMode->getTutorial()->showTutorialPopup(false); @@ -116,7 +116,7 @@ UIScene_PauseMenu::~UIScene_PauseMenu() Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); // This just allows it to be shown gameMode->getTutorial()->showTutorialPopup(true); @@ -506,7 +506,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { if(m_bIgnoreInput) return; - switch((int)controlId) + switch(static_cast(controlId)) { case BUTTON_PAUSE_RESUMEGAME: if( m_iPad == ProfileManager.GetPrimaryPad() && g_NetworkManager.IsLocalGame() ) @@ -656,7 +656,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) int playTime = -1; if( pMinecraft->localplayers[m_iPad] != NULL ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } #if defined(_XBOX_ONE) || defined(__ORBIS__) @@ -725,7 +725,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) int playTime = -1; if( pMinecraft->localplayers[m_iPad] != NULL ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited); @@ -743,7 +743,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) int playTime = -1; if( pMinecraft->localplayers[m_iPad] != NULL ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } // adjust the trial time played @@ -761,7 +761,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) int playTime = -1; if( pMinecraft->localplayers[m_iPad] != NULL ) { - playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited); @@ -839,7 +839,7 @@ void UIScene_PauseMenu::PerformActionSaveGame() if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); m_pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); @@ -1003,7 +1003,7 @@ int UIScene_PauseMenu::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage:: int UIScene_PauseMenu::SaveGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam); + UIScene_PauseMenu* pClass = static_cast(ui.GetSceneFromCallbackId((size_t)pParam)); if(pClass) pClass->SetIgnoreInput(false); if(bContinue==true) diff --git a/Minecraft.Client/Common/UI/UIScene_QuadrantSignin.cpp b/Minecraft.Client/Common/UI/UIScene_QuadrantSignin.cpp index 0cb6cf2bd..445c6ffcd 100644 --- a/Minecraft.Client/Common/UI/UIScene_QuadrantSignin.cpp +++ b/Minecraft.Client/Common/UI/UIScene_QuadrantSignin.cpp @@ -11,7 +11,7 @@ UIScene_QuadrantSignin::UIScene_QuadrantSignin(int iPad, void *_initData, UILaye // Setup all the Iggy references we need for this scene initialiseMovie(); - m_signInInfo = *((SignInInfo *)_initData); + m_signInInfo = *static_cast(_initData); m_bIgnoreInput = false; @@ -167,7 +167,7 @@ int UIScene_QuadrantSignin::SignInReturned(void *pParam,bool bContinue, int iPad { app.DebugPrintf("SignInReturned for pad %d\n", iPad); - UIScene_QuadrantSignin *pClass = (UIScene_QuadrantSignin *)pParam; + UIScene_QuadrantSignin *pClass = static_cast(pParam); #ifdef _XBOX_ONE if(bContinue && pClass->m_signInInfo.requireOnline && ProfileManager.IsSignedIn(iPad)) @@ -264,7 +264,7 @@ void UIScene_QuadrantSignin::setControllerState(int iPad, EControllerStatus stat value[0].number = iPad; value[1].type = IGGY_DATATYPE_number; - value[1].number = (int)state; + value[1].number = static_cast(state); IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetControllerStatus , 2 , value ); } @@ -272,7 +272,7 @@ void UIScene_QuadrantSignin::setControllerState(int iPad, EControllerStatus stat int UIScene_QuadrantSignin::AvatarReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) { - UIScene_QuadrantSignin *pClass = (UIScene_QuadrantSignin *)lpParam; + UIScene_QuadrantSignin *pClass = static_cast(lpParam); app.DebugPrintf(app.USER_SR,"AvatarReturned callback\n"); if(pbThumbnail != NULL) { diff --git a/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp b/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp index b58f86fda..98bcab7e0 100644 --- a/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp @@ -101,7 +101,7 @@ void UIScene_SaveMessage::handleInput(int iPad, int key, bool repeat, bool press void UIScene_SaveMessage::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Confirm: diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp index 6d892d703..c1b38fa04 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp @@ -93,8 +93,8 @@ void UIScene_SettingsAudioMenu::handleInput(int iPad, int key, bool repeat, bool void UIScene_SettingsAudioMenu::handleSliderMove(F64 sliderId, F64 currentValue) { WCHAR TempString[256]; - int value = (int)currentValue; - switch((int)sliderId) + int value = static_cast(currentValue); + switch(static_cast(sliderId)) { case eControl_Music: m_sliderMusic.handleSliderMove(value); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsControlMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsControlMenu.cpp index d5447f779..3a81775dc 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsControlMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsControlMenu.cpp @@ -93,8 +93,8 @@ void UIScene_SettingsControlMenu::handleInput(int iPad, int key, bool repeat, bo void UIScene_SettingsControlMenu::handleSliderMove(F64 sliderId, F64 currentValue) { WCHAR TempString[256]; - int value = (int)currentValue; - switch((int)sliderId) + int value = static_cast(currentValue); + switch(static_cast(sliderId)) { case eControl_SensitivityInGame: m_sliderSensitivityInGame.handleSliderMove(value); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp index 0a76a5e5d..be92bd62d 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp @@ -19,7 +19,7 @@ namespace int fovToSliderValue(float fov) { - int clampedFov = clampFov((int)(fov + 0.5f)); + int clampedFov = clampFov(static_cast(fov + 0.5f)); return ((clampedFov - FOV_MIN) * FOV_SLIDER_MAX) / (FOV_MAX - FOV_MIN); } @@ -49,9 +49,9 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),app.GetGameSettings(m_iPad,eGameSetting_Gamma)); m_sliderGamma.init(TempString,eControl_Gamma,0,100,app.GetGameSettings(m_iPad,eGameSetting_Gamma)); - int initialFov = clampFov((int)(pMinecraft->gameRenderer->GetFovVal() + 0.5f)); + int initialFov = clampFov(static_cast(pMinecraft->gameRenderer->GetFovVal() + 0.5f)); swprintf((WCHAR*)TempString, 256, L"FOV: %d", initialFov); - m_sliderFOV.init(TempString, eControl_FOV, 0, FOV_SLIDER_MAX, fovToSliderValue((float)initialFov)); + m_sliderFOV.init(TempString, eControl_FOV, 0, FOV_SLIDER_MAX, fovToSliderValue(static_cast(initialFov))); swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity)); m_sliderInterfaceOpacity.init(TempString,eControl_InterfaceOpacity,0,100,app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity)); @@ -164,8 +164,8 @@ void UIScene_SettingsGraphicsMenu::handleInput(int iPad, int key, bool repeat, b void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentValue) { WCHAR TempString[256]; - int value = (int)currentValue; - switch((int)sliderId) + int value = static_cast(currentValue); + switch(static_cast(sliderId)) { case eControl_Gamma: m_sliderGamma.handleSliderMove(value); @@ -181,7 +181,7 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal m_sliderFOV.handleSliderMove(value); Minecraft* pMinecraft = Minecraft::GetInstance(); int fovValue = sliderValueToFov(value); - pMinecraft->gameRenderer->SetFovVal((float)fovValue); + pMinecraft->gameRenderer->SetFovVal(static_cast(fovValue)); WCHAR TempString[256]; swprintf((WCHAR*)TempString, 256, L"FOV: %d", fovValue); m_sliderFOV.setLabel(TempString); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp index 39a0b7c66..4f15d1081 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp @@ -119,7 +119,7 @@ void UIScene_SettingsMenu::handlePress(F64 controlId, F64 childId) //CD - Added for audio ui.PlayUISFX(eSFX_Press); - switch((int)controlId) + switch(static_cast(controlId)) { case BUTTON_ALL_OPTIONS: ui.NavigateToScene(m_iPad, eUIScene_SettingsOptionsMenu); @@ -151,7 +151,7 @@ void UIScene_SettingsMenu::handlePress(F64 controlId, F64 childId) int UIScene_SettingsMenu::ResetDefaultsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_SettingsMenu* pClass = (UIScene_SettingsMenu*)pParam; + UIScene_SettingsMenu* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp index 6898d489a..6780e05bc 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp @@ -243,7 +243,7 @@ void UIScene_SettingsOptionsMenu::handlePress(F64 controlId, F64 childId) //CD - Added for audio ui.PlayUISFX(eSFX_Press); - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Languages: m_bNavigateToLanguageSelector = true; @@ -378,8 +378,8 @@ void UIScene_SettingsOptionsMenu::handleReload() void UIScene_SettingsOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - int value = (int)currentValue; - switch((int)sliderId) + int value = static_cast(currentValue); + switch(static_cast(sliderId)) { case eControl_Autosave: m_sliderAutosave.handleSliderMove(value); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsUIMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsUIMenu.cpp index 917012d6b..5a515c4b3 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsUIMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsUIMenu.cpp @@ -146,8 +146,8 @@ void UIScene_SettingsUIMenu::handleInput(int iPad, int key, bool repeat, bool pr void UIScene_SettingsUIMenu::handleSliderMove(F64 sliderId, F64 currentValue) { WCHAR TempString[256]; - int value = (int)currentValue; - switch((int)sliderId) + int value = static_cast(currentValue); + switch(static_cast(sliderId)) { case eControl_UISize: m_sliderUISize.handleSliderMove(value); diff --git a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp index c29bac2d3..74e7e2dcb 100644 --- a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp @@ -13,7 +13,7 @@ UIScene_SignEntryMenu::UIScene_SignEntryMenu(int iPad, void *_initData, UILayer // Setup all the Iggy references we need for this scene initialiseMovie(); - SignEntryScreenInput* initData = (SignEntryScreenInput*)_initData; + SignEntryScreenInput* initData = static_cast(_initData); m_sign = initData->sign; m_bConfirmed = false; @@ -143,7 +143,7 @@ void UIScene_SignEntryMenu::handleInput(int iPad, int key, bool repeat, bool pre int UIScene_SignEntryMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) { // 4J HEG - No reason to set value if keyboard was cancelled - UIScene_SignEntryMenu *pClass=(UIScene_SignEntryMenu *)lpParam; + UIScene_SignEntryMenu *pClass=static_cast(lpParam); pClass->m_bIgnoreInput = false; if (bRes) { @@ -157,7 +157,7 @@ int UIScene_SignEntryMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) void UIScene_SignEntryMenu::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) + switch(static_cast(controlId)) { case eControl_Confirm: { @@ -169,7 +169,7 @@ void UIScene_SignEntryMenu::handlePress(F64 controlId, F64 childId) case eControl_Line3: case eControl_Line4: { - m_iEditingLine = (int)controlId; + m_iEditingLine = static_cast(controlId); m_bIgnoreInput = true; #ifdef _XBOX_ONE // 4J-PB - Xbox One uses the Windows virtual keyboard, and doesn't have the Xbox 360 Latin keyboard type, so we can't restrict the input set to alphanumeric. The closest we get is the emailSmtpAddress type. @@ -186,7 +186,7 @@ void UIScene_SignEntryMenu::handlePress(F64 controlId, F64 childId) break; } #else - InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),m_textInputLines[m_iEditingLine].getLabel(),(DWORD)m_iPad,15,&UIScene_SignEntryMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Alphabet); + InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),m_textInputLines[m_iEditingLine].getLabel(),static_cast(m_iPad),15,&UIScene_SignEntryMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Alphabet); #endif } break; diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp index d4f26ae71..168c96b64 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp @@ -599,7 +599,7 @@ void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) void UIScene_SkinSelectMenu::customDraw(IggyCustomDrawCallbackRegion *region) { int characterId = -1; - swscanf((wchar_t*)region->name,L"Character%d",&characterId); + swscanf(static_cast(region->name),L"Character%d",&characterId); if (characterId == -1) { app.DebugPrintf("Invalid character to render found\n"); @@ -1099,7 +1099,7 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(m_originalSkinId); if( ugcSkinIndex == 0 ) { - m_skinIndex = (EDefaultSkins) defaultSkinIndex; + m_skinIndex = static_cast(defaultSkinIndex); } } break; @@ -1563,7 +1563,7 @@ void UIScene_SkinSelectMenu::showNotOnlineDialog(int iPad) int UIScene_SkinSelectMenu::UnlockSkinReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_SkinSelectMenu* pScene = (UIScene_SkinSelectMenu*)pParam; + UIScene_SkinSelectMenu* pScene = static_cast(pParam); if ( (result == C4JStorage::EMessage_ResultAccept) && ProfileManager.IsSignedIn(iPad) @@ -1642,7 +1642,7 @@ int UIScene_SkinSelectMenu::UnlockSkinReturned(void *pParam,int iPad,C4JStorage: int UIScene_SkinSelectMenu::RenableInput(LPVOID lpVoid, int, int) { - ((UIScene_SkinSelectMenu*) lpVoid)->m_bIgnoreInput = false; + static_cast(lpVoid)->m_bIgnoreInput = false; return 0; } diff --git a/Minecraft.Client/Common/UI/UIScene_TeleportMenu.cpp b/Minecraft.Client/Common/UI/UIScene_TeleportMenu.cpp index f6916d133..5d49196c9 100644 --- a/Minecraft.Client/Common/UI/UIScene_TeleportMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_TeleportMenu.cpp @@ -12,7 +12,7 @@ UIScene_TeleportMenu::UIScene_TeleportMenu(int iPad, void *initData, UILayer *pa // Setup all the Iggy references we need for this scene initialiseMovie(); - TeleportMenuInitData *initParam = (TeleportMenuInitData *)initData; + TeleportMenuInitData *initParam = static_cast(initData); m_teleportToPlayer = initParam->teleportToPlayer; @@ -250,11 +250,11 @@ void UIScene_TeleportMenu::handleInput(int iPad, int key, bool repeat, bool pres void UIScene_TeleportMenu::handlePress(F64 controlId, F64 childId) { - app.DebugPrintf("Pressed = %d, %d\n", (int)controlId, (int)childId); - switch((int)controlId) + app.DebugPrintf("Pressed = %d, %d\n", static_cast(controlId), static_cast(childId)); + switch(static_cast(controlId)) { case eControl_GamePlayers: - int currentSelection = (int)childId; + int currentSelection = static_cast(childId); INetworkPlayer *selectedPlayer = g_NetworkManager.GetPlayerBySmallId( m_players[ currentSelection ] ); INetworkPlayer *thisPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(m_iPad); @@ -275,7 +275,7 @@ void UIScene_TeleportMenu::handlePress(F64 controlId, F64 childId) void UIScene_TeleportMenu::OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving) { - UIScene_TeleportMenu *scene = (UIScene_TeleportMenu *)callbackParam; + UIScene_TeleportMenu *scene = static_cast(callbackParam); bool playerFound = false; int foundIndex = 0; for(int i = 0; i < scene->m_playersCount; ++i) diff --git a/Minecraft.Client/Common/UI/UIScene_TradingMenu.cpp b/Minecraft.Client/Common/UI/UIScene_TradingMenu.cpp index 0a35c8e5b..d806c49ff 100644 --- a/Minecraft.Client/Common/UI/UIScene_TradingMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_TradingMenu.cpp @@ -25,13 +25,13 @@ UIScene_TradingMenu::UIScene_TradingMenu(int iPad, void *_initData, UILayer *par m_labelRequest1.init(L""); m_labelRequest2.init(L""); - TradingScreenInput *initData = (TradingScreenInput *)_initData; + TradingScreenInput *initData = static_cast(_initData); m_merchant = initData->trader; Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Trading_Menu, this); } @@ -89,7 +89,7 @@ void UIScene_TradingMenu::handleDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } @@ -159,7 +159,7 @@ void UIScene_TradingMenu::customDraw(IggyCustomDrawCallbackRegion *region) shared_ptr item = nullptr; int slotId = -1; - swscanf((wchar_t*)region->name,L"slot_%d",&slotId); + swscanf(static_cast(region->name),L"slot_%d",&slotId); if(slotId < MerchantMenu::USE_ROW_SLOT_END) { diff --git a/Minecraft.Client/Common/XUI/XUI_Chat.cpp b/Minecraft.Client/Common/XUI/XUI_Chat.cpp index 3e3faa773..a1c43c63f 100644 --- a/Minecraft.Client/Common/XUI/XUI_Chat.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Chat.cpp @@ -5,7 +5,7 @@ HRESULT CScene_Chat::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); MapChildControls(); diff --git a/Minecraft.Client/Common/XUI/XUI_ConnectingProgress.cpp b/Minecraft.Client/Common/XUI/XUI_ConnectingProgress.cpp index 9a82a7b3b..ab99c00dc 100644 --- a/Minecraft.Client/Common/XUI/XUI_ConnectingProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_ConnectingProgress.cpp @@ -12,7 +12,7 @@ //---------------------------------------------------------------------------------- HRESULT CScene_ConnectingProgress::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - ConnectionProgressParams *param = (ConnectionProgressParams *)pInitData->pvInitData; + ConnectionProgressParams *param = static_cast(pInitData->pvInitData); m_iPad = param->iPad; MapChildControls(); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JEdit.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JEdit.cpp index cc3afeca4..65118fa5d 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JEdit.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JEdit.cpp @@ -127,7 +127,7 @@ HRESULT CXuiCtrl4JEdit::OnChar(XUIMessageChar* pInputData, BOOL& rfHandled) XuiSendMessage( hBaseObj, &xuiMsg ); rfHandled = TRUE; - SendNotifyValueChanged((int)pInputData->wch); + SendNotifyValueChanged(static_cast(pInputData->wch)); return hr; } @@ -185,14 +185,14 @@ HRESULT CXuiCtrl4JEdit::SendNotifyValueChanged(int iValue) int CXuiCtrl4JEdit::KeyboardReturned(void *pParam,bool bSet) { - CXuiCtrl4JEdit* pClass = (CXuiCtrl4JEdit*)pParam; + CXuiCtrl4JEdit* pClass = static_cast(pParam); HRESULT hr = S_OK; if(bSet) { pClass->SetText(pClass->wchText); // need to move the caret to the end of the newly set text - XuiEditSetCaretPosition(pClass->m_hObj, (int)wcsnlen(pClass->wchText, 50)); + XuiEditSetCaretPosition(pClass->m_hObj, static_cast(wcsnlen(pClass->wchText, 50))); pClass->SendNotifyValueChanged(10); // 10 for a return } diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JList.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JList.cpp index 4c615979c..15695fd6d 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JList.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JList.cpp @@ -22,13 +22,13 @@ void CXuiCtrl4JList::AddData( const LIST_ITEM_INFO& ItemInfo , int iSortListFrom if(ItemInfo.pwszText) { - dwLen1=(int)wcslen(ItemInfo.pwszText)*sizeof(WCHAR); + dwLen1=static_cast(wcslen(ItemInfo.pwszText))*sizeof(WCHAR); dwBytes+=dwLen1+sizeof(WCHAR); } if(ItemInfo.pwszImage) { - dwLen2=(int)(wcslen(ItemInfo.pwszImage))*sizeof(WCHAR); + dwLen2=static_cast(wcslen(ItemInfo.pwszImage))*sizeof(WCHAR); dwBytes+=dwLen2+sizeof(WCHAR); } @@ -59,11 +59,11 @@ void CXuiCtrl4JList::AddData( const LIST_ITEM_INFO& ItemInfo , int iSortListFrom // need to remember the original index of this addition before it gets sorted - this will get used to load the game if(iSortListFromIndex!=-1) { - pItemInfo->iIndex=(int)m_vListData.size()-iSortListFromIndex; + pItemInfo->iIndex=static_cast(m_vListData.size())-iSortListFromIndex; } else { - pItemInfo->iIndex=(int)m_vListData.size(); + pItemInfo->iIndex=static_cast(m_vListData.size()); } // added to force a sort order for DLC @@ -110,7 +110,7 @@ void CXuiCtrl4JList::RemoveAllData( ) { EnterCriticalSection(&m_AccessListData); - int iSize=(int)m_vListData.size(); + int iSize=static_cast(m_vListData.size()); for(int i=0;icItems = (int)m_vListData.size(); + pGetItemCountData->cItems = static_cast(m_vListData.size()); bHandled = TRUE; return S_OK; } diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_BrewProgress.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_BrewProgress.cpp index 074b7300b..69f775d49 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_BrewProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_BrewProgress.cpp @@ -12,7 +12,7 @@ int CXuiCtrlBrewProgress::GetValue() if( pvUserData != NULL ) { - BrewingStandTileEntity *pBrewingStandTileEntity = (BrewingStandTileEntity *)pvUserData; + BrewingStandTileEntity *pBrewingStandTileEntity = static_cast(pvUserData); return pBrewingStandTileEntity->getBrewTime(); } diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_BubblesProgress.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_BubblesProgress.cpp index cc5d996f3..981f49960 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_BubblesProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_BubblesProgress.cpp @@ -10,7 +10,7 @@ int CXuiCtrlBubblesProgress::GetValue() if( pvUserData != NULL ) { - BrewingStandTileEntity *pBrewingStandTileEntity = (BrewingStandTileEntity *)pvUserData; + BrewingStandTileEntity *pBrewingStandTileEntity = static_cast(pvUserData); int value = 0; int bubbleStep = (pBrewingStandTileEntity->getBrewTime() / 2) % 7; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_BurnProgress.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_BurnProgress.cpp index 8e514094c..b618f8c6d 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_BurnProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_BurnProgress.cpp @@ -12,7 +12,7 @@ int CXuiCtrlBurnProgress::GetValue() if( pvUserData != NULL ) { - FurnaceTileEntity *pFurnaceTileEntity = (FurnaceTileEntity *)pvUserData; + FurnaceTileEntity *pFurnaceTileEntity = static_cast(pvUserData); // TODO This param is a magic number in Java but we should really define it somewhere with a name // I think it is the number of states of the progress display (ie the max value) diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp index 6c7876c9f..050fcdc41 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp @@ -15,10 +15,10 @@ HRESULT CXuiCtrlEnchantmentButton::OnInit(XUIMessageInit* pInitData, BOOL& rfHan Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); HXUIOBJ parent = m_hObj; HXUICLASS hcInventoryClass = XuiFindClass( L"CXuiSceneEnchant" ); @@ -34,7 +34,7 @@ HRESULT CXuiCtrlEnchantmentButton::OnInit(XUIMessageInit* pInitData, BOOL& rfHan VOID *pObj; XuiObjectFromHandle( parent, &pObj ); - m_containerScene = (CXuiSceneEnchant *)pObj; + m_containerScene = static_cast(pObj); m_index = 0; m_lastCost = 0; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp index 8a56a0ead..584cbe661 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp @@ -30,10 +30,10 @@ CXuiCtrlEnchantmentBook::CXuiCtrlEnchantmentBook() : Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); model = NULL; @@ -66,7 +66,7 @@ HRESULT CXuiCtrlEnchantmentBook::OnInit(XUIMessageInit* pInitData, BOOL& rfHandl VOID *pObj; XuiObjectFromHandle( parent, &pObj ); - m_containerScene = (CXuiSceneEnchant *)pObj; + m_containerScene = static_cast(pObj); last = nullptr; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp index 60156a0af..a7700e79c 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp @@ -25,10 +25,10 @@ HRESULT CXuiCtrlEnchantmentButtonText::OnInit(XUIMessageInit* pInitData, BOOL& r Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); HXUIOBJ parent = m_hObj; HXUICLASS hcInventoryClass = XuiFindClass( L"CXuiCtrlEnchantmentButton" ); @@ -44,7 +44,7 @@ HRESULT CXuiCtrlEnchantmentButtonText::OnInit(XUIMessageInit* pInitData, BOOL& r VOID *pObj; XuiObjectFromHandle( parent, &pObj ); - m_parentControl = (CXuiCtrlEnchantmentButton *)pObj; + m_parentControl = static_cast(pObj); m_lastCost = 0; m_enchantmentString = L""; @@ -75,10 +75,10 @@ HRESULT CXuiCtrlEnchantmentButtonText::OnRender(XUIMessageRender *pRenderData, B // Annoyingly, XUI renders everything to a z of 0 so if we want to render anything that needs the z-buffer on top of it, then we need to clear it. // Clear just the region required for this control. D3DRECT clearRect; - clearRect.x1 = (int)(matrix._41) - 2; - clearRect.y1 = (int)(matrix._42) - 2; - clearRect.x2 = (int)(matrix._41 + ( bwidth * matrix._11 )) + 2; - clearRect.y2 = (int)(matrix._42 + ( bheight * matrix._22 )) + 2; + clearRect.x1 = static_cast(matrix._41) - 2; + clearRect.y1 = static_cast(matrix._42) - 2; + clearRect.x2 = static_cast(matrix._41 + (bwidth * matrix._11)) + 2; + clearRect.y2 = static_cast(matrix._42 + (bheight * matrix._22)) + 2; RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &clearRect); // glClear(GL_DEPTH_BUFFER_BIT); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_FireProgress.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_FireProgress.cpp index b125af39c..35b9d534e 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_FireProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_FireProgress.cpp @@ -12,7 +12,7 @@ int CXuiCtrlFireProgress::GetValue() if( pvUserData != NULL ) { - FurnaceTileEntity *pFurnaceTileEntity = (FurnaceTileEntity *)pvUserData; + FurnaceTileEntity *pFurnaceTileEntity = static_cast(pvUserData); // TODO This param is a magic number in Java but we should really define it somewhere with a name // I think it is the number of states of the progress display (ie the max value) diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp index 02ee7c938..7af2ea389 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp @@ -22,10 +22,10 @@ CXuiCtrlMinecraftPlayer::CXuiCtrlMinecraftPlayer() : Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); } //----------------------------------------------------------------------------- @@ -47,7 +47,7 @@ HRESULT CXuiCtrlMinecraftPlayer::OnInit(XUIMessageInit* pInitData, BOOL& rfHandl VOID *pObj; XuiObjectFromHandle( parent, &pObj ); - m_containerScene = (CXuiSceneInventory *)pObj; + m_containerScene = static_cast(pObj); m_iPad = m_containerScene->getPad(); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp index 0acd250f2..ffa386a06 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp @@ -30,10 +30,10 @@ CXuiCtrlMinecraftSkinPreview::CXuiCtrlMinecraftSkinPreview() : Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); m_customTextureUrl = L"default"; m_backupTexture = TN_MOB_CHAR; @@ -137,7 +137,7 @@ void CXuiCtrlMinecraftSkinPreview::SetFacing(ESkinPreviewFacing facing, bool bAn void CXuiCtrlMinecraftSkinPreview::CycleNextAnimation() { - m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation + 1); + m_currentAnimation = static_cast(m_currentAnimation + 1); if(m_currentAnimation >= e_SkinPreviewAnimation_Count) m_currentAnimation = e_SkinPreviewAnimation_Walking; m_swingTime = 0.0f; @@ -145,8 +145,8 @@ void CXuiCtrlMinecraftSkinPreview::CycleNextAnimation() void CXuiCtrlMinecraftSkinPreview::CyclePreviousAnimation() { - m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation - 1); - if(m_currentAnimation < e_SkinPreviewAnimation_Walking) m_currentAnimation = (ESkinPreviewAnimations)(e_SkinPreviewAnimation_Count - 1); + m_currentAnimation = static_cast(m_currentAnimation - 1); + if(m_currentAnimation < e_SkinPreviewAnimation_Walking) m_currentAnimation = static_cast(e_SkinPreviewAnimation_Count - 1); m_swingTime = 0.0f; } @@ -241,7 +241,7 @@ HRESULT CXuiCtrlMinecraftSkinPreview::OnRender(XUIMessageRender *pRenderData, BO Lighting::turnOn(); //glRotatef(-45 - 90, 0, 1, 0); - glRotatef(-(float)m_xRot, 1, 0, 0); + glRotatef(-static_cast(m_xRot), 1, 0, 0); // 4J Stu - Turning on hideGui while we do this stops the name rendering in split-screen bool wasHidingGui = pMinecraft->options->hideGui; @@ -294,7 +294,7 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do glPushMatrix(); glDisable(GL_CULL_FACE); - HumanoidModel *model = (HumanoidModel *)renderer->getModel(); + HumanoidModel *model = static_cast(renderer->getModel()); //getAttackAnim(mob, a); //if (armor != NULL) armor->attackTime = model->attackTime; @@ -329,7 +329,7 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do { m_swingTime = 0; } - model->attackTime = m_swingTime / (float) (Player::SWING_DURATION * 3); + model->attackTime = m_swingTime / static_cast(Player::SWING_DURATION * 3); break; default: break; @@ -343,7 +343,7 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do //setupPosition(mob, x, y, z); // is equivalent to - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); //float bob = getBob(mob, a); #ifdef SKIN_PREVIEW_BOB_ANIM @@ -415,11 +415,11 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do double xa = sin(yr * PI / 180); double za = -cos(yr * PI / 180); - float flap = (float) yd * 10; + float flap = static_cast(yd) * 10; if (flap < -6) flap = -6; if (flap > 32) flap = 32; - float lean = (float) (xd * xa + zd * za) * 100; - float lean2 = (float) (xd * za - zd * xa) * 100; + float lean = static_cast(xd * xa + zd * za) * 100; + float lean2 = static_cast(xd * za - zd * xa) * 100; if (lean < 0) lean = 0; //float pow = 1;//mob->oBob + (bob - mob->oBob) * a; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp index 84273eb57..a61ca6459 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp @@ -62,8 +62,8 @@ CXuiCtrlMinecraftSlot::CXuiCtrlMinecraftSlot() : if(pMinecraft != NULL) { - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fScreenHeight=(float)pMinecraft->height_phys; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fScreenHeight=static_cast(pMinecraft->height_phys); m_bScreenWidthSetup = true; } } @@ -114,9 +114,9 @@ HRESULT CXuiCtrlMinecraftSlot::OnGetSourceImage(XUIMessageGetSourceImage* pData, m_item = MsgGetSlotItem.item; m_iID = m_item->id; m_iPad = GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField); - m_fAlpha = ((float)GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/31.0f; + m_fAlpha = static_cast(GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/31.0f; m_bDecorations = GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField); - m_fScale = ((float)GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/10.0f; + m_fScale = static_cast(GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/10.0f; } else { @@ -128,10 +128,10 @@ HRESULT CXuiCtrlMinecraftSlot::OnGetSourceImage(XUIMessageGetSourceImage* pData, // 4J Stu - Some parent controls may overide this, others will leave it as what we passed in m_iPad = GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField); - m_fAlpha = ((float)GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/31.0f; + m_fAlpha = static_cast(GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/31.0f; m_bDecorations = GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField); m_iCount = GET_SLOTDISPLAY_COUNT_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField); - m_fScale = ((float)GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/10.0f; + m_fScale = static_cast(GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/10.0f; m_popTime = GET_SLOTDISPLAY_POPTIME_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField); m_iAuxVal = GET_SLOTDISPLAY_AUXVAL_FROM_ITEM_BITMASK(MsgGetSlotItem.iItemBitField); @@ -217,18 +217,18 @@ HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHa // Annoyingly, XUI renders everything to a z of 0 so if we want to render anything that needs the z-buffer on top of it, then we need to clear it. // Clear just the region required for this control. D3DRECT clearRect; - clearRect.x1 = (int)(matrix._41) - 2; - clearRect.y1 = (int)(matrix._42) - 2; - clearRect.x2 = (int)(matrix._41 + ( bwidth * matrix._11 )) + 2; - clearRect.y2 = (int)(matrix._42 + ( bheight * matrix._22 )) + 2; + clearRect.x1 = static_cast(matrix._41) - 2; + clearRect.y1 = static_cast(matrix._42) - 2; + clearRect.x2 = static_cast(matrix._41 + (bwidth * matrix._11)) + 2; + clearRect.y2 = static_cast(matrix._42 + (bheight * matrix._22)) + 2; if(!m_bScreenWidthSetup) { Minecraft *pMinecraft=Minecraft::GetInstance(); if(pMinecraft != NULL) { - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fScreenHeight=(float)pMinecraft->height_phys; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fScreenHeight=static_cast(pMinecraft->height_phys); m_bScreenWidthSetup = true; } } @@ -261,14 +261,14 @@ HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHa if (pop > 0) { glPushMatrix(); - float squeeze = 1 + pop / (float) Inventory::POP_TIME_DURATION; + float squeeze = 1 + pop / static_cast(Inventory::POP_TIME_DURATION); float sx = x; float sy = y; float sxoffs = 8 * scaleX; float syoffs = 12 * scaleY; - glTranslatef((float)(sx + sxoffs), (float)(sy + syoffs), 0); + glTranslatef(static_cast(sx + sxoffs), static_cast(sy + syoffs), 0); glScalef(1 / squeeze, (squeeze + 1) / 2, 1); - glTranslatef((float)-(sx + sxoffs), (float)-(sy + syoffs), 0); + glTranslatef(static_cast(-(sx + sxoffs)), static_cast(-(sy + syoffs)), 0); } m_pItemRenderer->renderAndDecorateItem(pMinecraft->font, pMinecraft->textures, m_item, x, y,scaleX,scaleY,m_fAlpha,m_isFoil,false); @@ -284,15 +284,15 @@ HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHa { glPushMatrix(); glScalef(scaleX, scaleY, 1.0f); - int iX= (int)(0.5f+((float)x)/scaleX); - int iY= (int)(0.5f+((float)y)/scaleY); + int iX= static_cast(0.5f + ((float)x) / scaleX); + int iY= static_cast(0.5f + ((float)y) / scaleY); m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, m_item, iX, iY, m_fAlpha); glPopMatrix(); } else { - m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, m_item, (int)x, (int)y, m_fAlpha); + m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, m_item, static_cast(x), static_cast(y), m_fAlpha); } } @@ -329,9 +329,9 @@ void CXuiCtrlMinecraftSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, i m_iAuxVal = 0; m_iCount=iCount; - m_fScale = (float)(iScale)/10.0f; + m_fScale = static_cast(iScale)/10.0f; //m_uiAlpha=uiAlpha; - m_fAlpha =((float)(uiAlpha)) / 255.0f; + m_fAlpha =static_cast(uiAlpha) / 255.0f; m_bDecorations = bDecorations; // mif(bDecorations) m_iDecorations=1; // else m_iDecorations=0; @@ -348,8 +348,8 @@ void CXuiCtrlMinecraftSlot::SetIcon(int iPad, shared_ptr item, int m_item = item; m_isFoil = item->isFoil(); m_iPad = iPad; - m_fScale = (float)(iScale)/10.0f; - m_fAlpha =((float)(uiAlpha)) / 31; + m_fScale = static_cast(iScale)/10.0f; + m_fAlpha =static_cast(uiAlpha) / 31; m_bDecorations = bDecorations; m_bDirty = TRUE; XuiElementSetShow(m_hObj,bShow); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_SliderWrapper.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_SliderWrapper.cpp index a4e9f6be3..d52d560e7 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_SliderWrapper.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_SliderWrapper.cpp @@ -10,11 +10,11 @@ HRESULT CXuiCtrlSliderWrapper::OnInit( XUIMessageInit* pInitData, BOOL& bHandled XuiElementGetChildById(m_hObj,L"FocusSink",&hObjChild); XuiObjectFromHandle( hObjChild, &pObj ); - m_pFocusSink = (CXuiControl *)pObj; + m_pFocusSink = static_cast(pObj); XuiElementGetChildById(m_hObj,L"XuiSlider",&hObjChild); XuiObjectFromHandle( hObjChild, &pObj ); - m_pSlider = (CXuiSlider *)pObj; + m_pSlider = static_cast(pObj); m_sliderActive = false; m_bDisplayVal=true; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp index f8ceeb69d..5c820fb5f 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp @@ -12,7 +12,7 @@ HRESULT CXuiCtrlSlotItemCtrlBase::OnInit( HXUIOBJ hObj, XUIMessageInit* pInitDat { HRESULT hr = S_OK; SlotControlUserDataContainer* pvUserData = new SlotControlUserDataContainer(); - hr = XuiElementSetUserData(hObj, (void *)pvUserData ); + hr = XuiElementSetUserData(hObj, static_cast(pvUserData) ); // 4J WESTY : Pointer Prototype : Added to support prototype only. m_bSkipDefaultNavigation = false; @@ -41,7 +41,7 @@ HRESULT CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem(HXUIOBJ hObj, Cust void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); if( pUserDataContainer->slot != NULL ) { @@ -64,7 +64,7 @@ HRESULT CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem(HXUIOBJ hObj, Cust // 11 bits - auxval // 6 bits - count // 6 bits - scale - pData->iDataBitField = MAKE_SLOTDISPLAY_DATA_BITMASK(pUserDataContainer->m_iPad, (int)(31*pUserDataContainer->m_fAlpha),true,item->GetCount(),7,item->popTime); + pData->iDataBitField = MAKE_SLOTDISPLAY_DATA_BITMASK(pUserDataContainer->m_iPad, static_cast(31 * pUserDataContainer->m_fAlpha),true,item->GetCount(),7,item->popTime); } else { @@ -82,7 +82,7 @@ void CXuiCtrlSlotItemCtrlBase::SetSlot( HXUIOBJ hObj, Slot* slot ) void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); pUserDataContainer->slot = slot; } @@ -92,7 +92,7 @@ void CXuiCtrlSlotItemCtrlBase::SetUserIndex( HXUIOBJ hObj, int iPad ) void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); pUserDataContainer->m_iPad = iPad; } @@ -102,7 +102,7 @@ void CXuiCtrlSlotItemCtrlBase::SetAlpha( HXUIOBJ hObj, float fAlpha ) void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); pUserDataContainer->m_fAlpha = fAlpha; } @@ -111,7 +111,7 @@ bool CXuiCtrlSlotItemCtrlBase::isEmpty( HXUIOBJ hObj ) { void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); if(pUserDataContainer->slot != NULL) { @@ -130,7 +130,7 @@ wstring CXuiCtrlSlotItemCtrlBase::GetItemDescription( HXUIOBJ hObj, vector(pvUserData); if(pUserDataContainer->slot != NULL) { @@ -181,7 +181,7 @@ shared_ptr CXuiCtrlSlotItemCtrlBase::getItemInstance( HXUIOBJ hObj { void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); if(pUserDataContainer->slot != NULL) { @@ -200,7 +200,7 @@ Slot *CXuiCtrlSlotItemCtrlBase::getSlot( HXUIOBJ hObj ) { void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); return pUserDataContainer->slot; } @@ -254,7 +254,7 @@ int CXuiCtrlSlotItemCtrlBase::GetObjectCount( HXUIOBJ hObj ) { void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); int iCount = 0; @@ -294,7 +294,7 @@ bool CXuiCtrlSlotItemCtrlBase::IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj // Get the info on this item. void* pvThisUserData; XuiElementGetUserData( hThisObj, &pvThisUserData ); - SlotControlUserDataContainer* pThisUserDataContainer = (SlotControlUserDataContainer*)pvThisUserData; + SlotControlUserDataContainer* pThisUserDataContainer = static_cast(pvThisUserData); if(pThisUserDataContainer->slot != NULL) { @@ -322,7 +322,7 @@ bool CXuiCtrlSlotItemCtrlBase::IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj // Get the info on other item. void* pvOtherUserData; XuiElementGetUserData( hOtherObj, &pvOtherUserData ); - SlotControlUserDataContainer* pOtherUserDataContainer = (SlotControlUserDataContainer*)pvOtherUserData; + SlotControlUserDataContainer* pOtherUserDataContainer = static_cast(pvOtherUserData); if(pOtherUserDataContainer->slot != NULL) { @@ -363,7 +363,7 @@ int CXuiCtrlSlotItemCtrlBase::GetEmptyStackSpace( HXUIOBJ hObj ) void* pvUserData; XuiElementGetUserData( hObj, &pvUserData ); - SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData; + SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); int iCount = 0; int iMaxStackSize = 0; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotList.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotList.cpp index 7e51c8850..67accbe25 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotList.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotList.cpp @@ -226,6 +226,6 @@ void CXuiCtrlSlotList::GetCXuiCtrlSlotItem(int itemIndex, CXuiCtrlSlotItemListIt HXUIOBJ itemControl = this->GetItemControl(itemIndex); VOID *pObj; XuiObjectFromHandle( itemControl, &pObj ); - *CXuiCtrlSlotItem = (CXuiCtrlSlotItemListItem *)pObj; + *CXuiCtrlSlotItem = static_cast(pObj); } diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_SplashPulser.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_SplashPulser.cpp index 2e9717107..874edc6f0 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_SplashPulser.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_SplashPulser.cpp @@ -20,10 +20,10 @@ CXuiCtrlSplashPulser::CXuiCtrlSplashPulser() : Minecraft *pMinecraft=Minecraft::GetInstance(); ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); - m_fScreenWidth=(float)pMinecraft->width_phys; - m_fRawWidth=(float)ssc.rawWidth; - m_fScreenHeight=(float)pMinecraft->height_phys; - m_fRawHeight=(float)ssc.rawHeight; + m_fScreenWidth=static_cast(pMinecraft->width_phys); + m_fRawWidth=static_cast(ssc.rawWidth); + m_fScreenHeight=static_cast(pMinecraft->height_phys); + m_fRawHeight=static_cast(ssc.rawHeight); } //----------------------------------------------------------------------------- diff --git a/Minecraft.Client/Common/XUI/XUI_CustomMessages.h b/Minecraft.Client/Common/XUI/XUI_CustomMessages.h index 888f8ad00..cd5e28652 100644 --- a/Minecraft.Client/Common/XUI/XUI_CustomMessages.h +++ b/Minecraft.Client/Common/XUI/XUI_CustomMessages.h @@ -39,7 +39,7 @@ CustomMessage_GetSlotItem_Struct; static __declspec(noinline) void CustomMessage_GetSlotItem(XUIMessage *pMsg, CustomMessage_GetSlotItem_Struct* pData, int iDataBitField, int iItemBitField) { XuiMessage(pMsg,XM_GETSLOTITEM_MESSAGE); - _XuiMessageExtra(pMsg,(XUIMessageData*) pData, sizeof(*pData)); + _XuiMessageExtra(pMsg,static_cast(pData), sizeof(*pData)); pData->item = nullptr; pData->iDataBitField = iDataBitField; pData->iItemBitField = iItemBitField; @@ -68,7 +68,7 @@ CustomMessage_Splitscreenplayer_Struct; static __declspec(noinline) void CustomMessage_Splitscreenplayer(XUIMessage *pMsg, CustomMessage_Splitscreenplayer_Struct* pData, bool bJoining) { XuiMessage(pMsg,XM_SPLITSCREENPLAYER_MESSAGE); - _XuiMessageExtra(pMsg,(XUIMessageData*) pData, sizeof(*pData)); + _XuiMessageExtra(pMsg,static_cast(pData), sizeof(*pData)); pData->bJoining = bJoining; } diff --git a/Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp b/Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp index bd05ca146..e65f5a923 100644 --- a/Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp @@ -24,7 +24,7 @@ HRESULT CScene_DLCMain::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - iPad = *(int *) pInitData->pvInitData; + iPad = *static_cast(pInitData->pvInitData); MapChildControls(); @@ -39,7 +39,7 @@ HRESULT CScene_DLCMain::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) VOID *pObj; XuiObjectFromHandle( xList, &pObj ); - list = (CXuiCtrl4JList *) pObj; + list = static_cast(pObj); ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK ); @@ -162,7 +162,7 @@ HRESULT CScene_DLCMain::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNo param->iType = iIndex; // promote the DLC content request type - app.AddDLCRequest((eDLCMarketplaceType)iIndex, true); + app.AddDLCRequest(static_cast(iIndex), true); app.NavigateToScene(iPad,eUIScene_DLCOffersMenu, param); } return S_OK; @@ -182,7 +182,7 @@ HRESULT CScene_DLCMain::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) //---------------------------------------------------------------------------------- HRESULT CScene_DLCOffers::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - DLCOffersParam *param = (DLCOffersParam *) pInitData->pvInitData; + DLCOffersParam *param = static_cast(pInitData->pvInitData); m_iPad = param->iPad; m_iType = param->iType; m_iOfferC = app.GetDLCOffersCount(); @@ -226,7 +226,7 @@ HRESULT CScene_DLCOffers::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) m_hXuiBrush=NULL; XuiObjectFromHandle( m_List, &pObj ); - m_pOffersList = (CXuiCtrl4JList *)pObj; + m_pOffersList = static_cast(pObj); m_bAllDLCContentRetrieved=false; XuiElementInitUserFocus(m_hObj,ProfileManager.GetPrimaryPad(),TRUE); @@ -242,7 +242,7 @@ HRESULT CScene_DLCOffers::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) // Is the DLC we're looking for available? if(!m_bDLCRequiredIsRetrieved) { - if(app.DLCContentRetrieved((eDLCMarketplaceType)m_iType)) + if(app.DLCContentRetrieved(static_cast(m_iType))) { m_bDLCRequiredIsRetrieved=true; @@ -301,7 +301,7 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) // can't trust the offer type - partnernet is giving avatar items the CONTENT type //if(Offer.dwOfferType==app.GetDLCContentType((eDLCContentType)m_iType)) - if(pDLC->eDLCType==(eDLCContentType)m_iType) + if(pDLC->eDLCType==static_cast(m_iType)) { if(xOffer.fUserHasPurchased) { @@ -362,7 +362,7 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) // can't trust the offer type - partnernet is giving avatar items the CONTENT type //if(Offer.dwOfferType==app.GetDLCContentType((eDLCContentType)m_iType)) - if(pDLC->eDLCType==(eDLCContentType)m_iType) + if(pDLC->eDLCType==static_cast(m_iType)) { wstring wstrTemp=xOffer.wszOfferName; @@ -395,7 +395,7 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) // store the offer index pListInfo[iCount].iData=i; - pListInfo[iCount].iSortIndex=(int)pDLC->uiSortIndex; + pListInfo[iCount].iSortIndex=static_cast(pDLC->uiSortIndex); #ifdef _DEBUG app.DebugPrintf("Adding "); OutputDebugStringW(pListInfo[iCount].pwszText); @@ -791,7 +791,7 @@ HRESULT CScene_DLCOffers::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled) // Is the DLC we're looking for available? if(!m_bDLCRequiredIsRetrieved) { - if(app.DLCContentRetrieved((eDLCMarketplaceType)m_iType)) + if(app.DLCContentRetrieved(static_cast(m_iType))) { m_bDLCRequiredIsRetrieved=true; diff --git a/Minecraft.Client/Common/XUI/XUI_Death.cpp b/Minecraft.Client/Common/XUI/XUI_Death.cpp index 83275c14c..e4c786f26 100644 --- a/Minecraft.Client/Common/XUI/XUI_Death.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Death.cpp @@ -26,7 +26,7 @@ //---------------------------------------------------------------------------------- HRESULT CScene_Death::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); m_bIgnoreInput = false; @@ -107,7 +107,7 @@ HRESULT CScene_Death::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNoti int playTime = -1; if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) { - playTime = (int)pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed); diff --git a/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp b/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp index 6b96a4e31..e4565acbf 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp @@ -14,7 +14,7 @@ HRESULT CScene_DebugItemEditor::OnInit( XUIMessageInit *pInitData, BOOL &bHandle { MapChildControls(); - ItemEditorInput *initData = (ItemEditorInput *)pInitData->pvInitData; + ItemEditorInput *initData = static_cast(pInitData->pvInitData); m_iPad = initData->iPad; m_slot = initData->slot; m_menu = initData->menu; diff --git a/Minecraft.Client/Common/XUI/XUI_DebugOverlay.cpp b/Minecraft.Client/Common/XUI/XUI_DebugOverlay.cpp index e6db6a805..7c3d491ca 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugOverlay.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugOverlay.cpp @@ -102,7 +102,7 @@ HRESULT CScene_DebugOverlay::OnInit( XUIMessageInit *pInitData, BOOL &bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); m_setTime.SetValue( pMinecraft->level->getLevelData()->getTime() % 24000 ); - m_setFov.SetValue( (int)pMinecraft->gameRenderer->GetFovVal()); + m_setFov.SetValue( static_cast(pMinecraft->gameRenderer->GetFovVal())); XuiSetTimer(m_hObj,0,DEBUG_OVERLAY_UPDATE_TIME_PERIOD); @@ -266,7 +266,7 @@ HRESULT CScene_DebugOverlay::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotify if( hObjSource == m_setFov ) { Minecraft *pMinecraft = Minecraft::GetInstance(); - pMinecraft->gameRenderer->SetFovVal((float)pNotifyValueChangedData->nValue); + pMinecraft->gameRenderer->SetFovVal(static_cast(pNotifyValueChangedData->nValue)); } return S_OK; } @@ -277,7 +277,7 @@ HRESULT CScene_DebugOverlay::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled ) if(pMinecraft->level != NULL) { m_setTime.SetValue( pMinecraft->level->getLevelData()->getTime() % 24000 ); - m_setFov.SetValue( (int)pMinecraft->gameRenderer->GetFovVal()); + m_setFov.SetValue( static_cast(pMinecraft->gameRenderer->GetFovVal())); } return S_OK; } @@ -286,9 +286,9 @@ void CScene_DebugOverlay::SetSpawnToPlayerPos() { Minecraft *pMinecraft = Minecraft::GetInstance(); - pMinecraft->level->getLevelData()->setXSpawn((int)pMinecraft->player->x); - pMinecraft->level->getLevelData()->setYSpawn((int)pMinecraft->player->y); - pMinecraft->level->getLevelData()->setZSpawn((int)pMinecraft->player->z); + pMinecraft->level->getLevelData()->setXSpawn(static_cast(pMinecraft->player->x)); + pMinecraft->level->getLevelData()->setYSpawn(static_cast(pMinecraft->player->y)); + pMinecraft->level->getLevelData()->setZSpawn(static_cast(pMinecraft->player->z)); } #ifndef _CONTENT_PACKAGE diff --git a/Minecraft.Client/Common/XUI/XUI_DebugSetCamera.cpp b/Minecraft.Client/Common/XUI/XUI_DebugSetCamera.cpp index f6335191b..90046c4e9 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugSetCamera.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugSetCamera.cpp @@ -43,12 +43,12 @@ HRESULT CScene_DebugSetCamera::OnInit( XUIMessageInit *pInitData, BOOL &bHandled m_yRot.SetKeyboardType(C_4JInput::EKeyboardMode_Full); m_elevation.SetKeyboardType(C_4JInput::EKeyboardMode_Full); - m_camX.SetText((CONST WCHAR *) std::to_wstring(currentPosition->m_camX).c_str()); - m_camY.SetText((CONST WCHAR *) std::to_wstring(currentPosition->m_camY + 1.62).c_str()); - m_camZ.SetText((CONST WCHAR *) std::to_wstring(currentPosition->m_camZ).c_str()); + m_camX.SetText(static_cast(std::to_wstring(currentPosition->m_camX).c_str())); + m_camY.SetText(static_cast(std::to_wstring(currentPosition->m_camY + 1.62).c_str())); + m_camZ.SetText(static_cast(std::to_wstring(currentPosition->m_camZ).c_str())); - m_yRot.SetText((CONST WCHAR *) std::to_wstring(currentPosition->m_yRot).c_str()); - m_elevation.SetText((CONST WCHAR *) std::to_wstring(currentPosition->m_elev).c_str()); + m_yRot.SetText(static_cast(std::to_wstring(currentPosition->m_yRot).c_str())); + m_elevation.SetText(static_cast(std::to_wstring(currentPosition->m_elev).c_str())); //fpp = new FreezePlayerParam(); //fpp->player = playerNo; diff --git a/Minecraft.Client/Common/XUI/XUI_DebugTips.cpp b/Minecraft.Client/Common/XUI/XUI_DebugTips.cpp index aaa3b06f6..e8091bcb3 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugTips.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugTips.cpp @@ -9,7 +9,7 @@ //---------------------------------------------------------------------------------- HRESULT CScene_DebugTips::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); m_bIgnoreInput = false; diff --git a/Minecraft.Client/Common/XUI/XUI_FullscreenProgress.cpp b/Minecraft.Client/Common/XUI/XUI_FullscreenProgress.cpp index f66c0d70c..bfa953e89 100644 --- a/Minecraft.Client/Common/XUI/XUI_FullscreenProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_FullscreenProgress.cpp @@ -18,7 +18,7 @@ HRESULT CScene_FullscreenProgress::OnInit( XUIMessageInit* pInitData, BOOL& bHan m_buttonConfirm.SetText( app.GetString( IDS_CONFIRM_OK ) ); - LoadingInputParams *params = (LoadingInputParams *)pInitData->pvInitData; + LoadingInputParams *params = static_cast(pInitData->pvInitData); m_CompletionData = params->completionData; m_iPad=params->completionData->iPad; @@ -201,7 +201,7 @@ HRESULT CScene_FullscreenProgress::OnTransitionStart( XUIMessageTransition *pTra HRESULT CScene_FullscreenProgress::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled ) { int code = thread->GetExitCode(); - DWORD exitcode = *((DWORD *)&code); + DWORD exitcode = *static_cast(&code); //app.DebugPrintf("CScene_FullscreenProgress Timer %d\n",pTimer->nId); diff --git a/Minecraft.Client/Common/XUI/XUI_HUD.cpp b/Minecraft.Client/Common/XUI/XUI_HUD.cpp index 286f06a70..90b929686 100644 --- a/Minecraft.Client/Common/XUI/XUI_HUD.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HUD.cpp @@ -10,7 +10,7 @@ HRESULT CXuiSceneHud::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); MapChildControls(); @@ -145,7 +145,7 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() if (pMinecraft->localgameModes[m_iPad]->canHurtPlayer()) { int xpNeededForNextLevel = pMinecraft->localplayers[m_iPad]->getXpNeededForNextLevel(); - int progress = (int)(pMinecraft->localplayers[m_iPad]->experienceProgress *xpNeededForNextLevel); + int progress = static_cast(pMinecraft->localplayers[m_iPad]->experienceProgress * xpNeededForNextLevel); m_ExperienceProgress.SetShow(TRUE); m_ExperienceProgress.SetRange(0,xpNeededForNextLevel); @@ -257,7 +257,7 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() float yo = 0; if (iHealth <= 4) { - yo = (float)m_random.nextInt(2) * (iGuiScale+1); + yo = static_cast(m_random.nextInt(2)) * (iGuiScale+1); } if (icon == heartOffsetIndex) { @@ -359,7 +359,7 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() { if ((m_tickCount % (food * 3 + 1)) == 0) { - yo = (float)(m_random.nextInt(3) - 1) * (iGuiScale+1); + yo = static_cast(m_random.nextInt(3) - 1) * (iGuiScale+1); } } @@ -391,8 +391,8 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() if (pMinecraft->localplayers[m_iPad]->isUnderLiquid(Material::water)) { m_airGroup.SetShow(TRUE); - int count = (int) ceil((pMinecraft->localplayers[m_iPad]->getAirSupply() - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY); - int extra = (int) ceil((pMinecraft->localplayers[m_iPad]->getAirSupply()) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count; + int count = static_cast(ceil((pMinecraft->localplayers[m_iPad]->getAirSupply() - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY)); + int extra = static_cast(ceil((pMinecraft->localplayers[m_iPad]->getAirSupply()) * 10.0f / Player::TOTAL_AIR_SUPPLY)) - count; for (int icon = 0; icon < 10; icon++) { // Air bubbles diff --git a/Minecraft.Client/Common/XUI/XUI_HelpAndOptions.cpp b/Minecraft.Client/Common/XUI/XUI_HelpAndOptions.cpp index 9ba49e9d4..ce5750ede 100644 --- a/Minecraft.Client/Common/XUI/XUI_HelpAndOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HelpAndOptions.cpp @@ -12,7 +12,7 @@ //---------------------------------------------------------------------------------- HRESULT CScene_HelpAndOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); bool bNotInGame=(Minecraft::GetInstance()->level==NULL); MapChildControls(); diff --git a/Minecraft.Client/Common/XUI/XUI_HelpControls.cpp b/Minecraft.Client/Common/XUI/XUI_HelpControls.cpp index e7a8b0ca0..5e72a8d1e 100644 --- a/Minecraft.Client/Common/XUI/XUI_HelpControls.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HelpControls.cpp @@ -91,7 +91,7 @@ HRESULT CScene_Controls::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) XuiControlSetText(m_SouthPaw,app.GetString(IDS_SOUTHPAW)); XuiControlSetText(m_InvertLook,app.GetString(IDS_INVERT_LOOK)); - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); bool bSplitscreen=(app.GetLocalPlayerCount()>1); @@ -165,7 +165,7 @@ HRESULT CScene_Controls::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) // fill out the layouts list VOID *pObj; XuiObjectFromHandle( m_SchemeList, &pObj ); - m_pLayoutList = (CXuiCtrl4JList *)pObj; + m_pLayoutList = static_cast(pObj); CXuiCtrl4JList::LIST_ITEM_INFO ListInfo[3]; ZeroMemory(ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)*3); @@ -532,18 +532,18 @@ HRESULT CScene_Controls::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pN if ( hObjPressed == m_InvertLook.m_hObj ) { BOOL bIsChecked = m_InvertLook.IsChecked(); - app.SetGameSettings(m_iPad,eGameSetting_ControlInvertLook,(unsigned char)( bIsChecked ) ); + app.SetGameSettings(m_iPad,eGameSetting_ControlInvertLook,static_cast(bIsChecked) ); } else if ( hObjPressed == m_SouthPaw.m_hObj ) { BOOL bIsChecked = m_SouthPaw.IsChecked(); - app.SetGameSettings(m_iPad,eGameSetting_ControlSouthPaw,(unsigned char)( bIsChecked ) ); + app.SetGameSettings(m_iPad,eGameSetting_ControlSouthPaw,static_cast(bIsChecked) ); PositionAllText(m_iPad); } else if( hObjPressed == m_SchemeList) { // check what's been selected - app.SetGameSettings(m_iPad,eGameSetting_ControlScheme,(unsigned char)m_SchemeList.GetCurSel()); + app.SetGameSettings(m_iPad,eGameSetting_ControlScheme,static_cast(m_SchemeList.GetCurSel())); LPWSTR layoutString = new wchar_t[ 128 ]; swprintf( layoutString, 128, L"%ls : %ls", app.GetString( IDS_CURRENT_LAYOUT ),app.GetString(m_iSchemeTextA[m_SchemeList.GetCurSel()]) ); diff --git a/Minecraft.Client/Common/XUI/XUI_HelpCredits.cpp b/Minecraft.Client/Common/XUI/XUI_HelpCredits.cpp index 4a6ce55f8..18435716c 100644 --- a/Minecraft.Client/Common/XUI/XUI_HelpCredits.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HelpCredits.cpp @@ -386,7 +386,7 @@ static const int gs_aNumTextElements[ eNumTextTypes ] = //---------------------------------------------------------------------------------- HRESULT CScene_Credits::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - int iPad = *(int *)pInitData->pvInitData; + int iPad = *static_cast(pInitData->pvInitData); MapChildControls(); @@ -441,7 +441,7 @@ HRESULT CScene_Credits::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) VOID* pTextObj; XuiObjectFromHandle( text, &pTextObj ); - m_aTextTypes[ i ].m_appTextElements[ j ] = (CXuiControl *)pTextObj; + m_aTextTypes[ i ].m_appTextElements[ j ] = static_cast(pTextObj); m_aTextTypes[ i ].m_appTextElements[ j ]->SetShow( false ); } } diff --git a/Minecraft.Client/Common/XUI/XUI_HelpHowToPlay.cpp b/Minecraft.Client/Common/XUI/XUI_HelpHowToPlay.cpp index 5c750d030..b2d57f883 100644 --- a/Minecraft.Client/Common/XUI/XUI_HelpHowToPlay.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HelpHowToPlay.cpp @@ -39,12 +39,12 @@ static SHowToPlayPageDef gs_aPageDefs[ eHowToPlay_NumPages ] = HRESULT CScene_HowToPlay::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { // 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 )( pInitData->pvInitData ); + size_t uiInitData = static_cast(pInitData->pvInitData); - m_iPad = ( int )( ( short )( uiInitData & 0xFFFF ) ); - EHowToPlayPage eStartPage = ( EHowToPlayPage )( ( uiInitData >> 16 ) & 0xFFF ); // Ignores MSB which is set to 1! + m_iPad = static_cast((short)(uiInitData & 0xFFFF)); + EHowToPlayPage eStartPage = static_cast((uiInitData >> 16) & 0xFFF); // Ignores MSB which is set to 1! - TelemetryManager->RecordMenuShown(m_iPad, eUIScene_HowToPlay, (ETelemetry_HowToPlay_SubMenuId)eStartPage); + TelemetryManager->RecordMenuShown(m_iPad, eUIScene_HowToPlay, static_cast(eStartPage)); MapChildControls(); @@ -116,10 +116,10 @@ HRESULT CScene_HowToPlay::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled case VK_PAD_A: { // Next page - int iNextPage = ( int )( m_eCurrPage ) + 1; + int iNextPage = static_cast(m_eCurrPage) + 1; if ( iNextPage != eHowToPlay_NumPages ) { - StartPage( ( EHowToPlayPage )( iNextPage ) ); + StartPage( static_cast(iNextPage) ); CXuiSceneBase::PlayUISFX(eSFX_Press); } rfHandled = TRUE; @@ -128,10 +128,10 @@ HRESULT CScene_HowToPlay::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled case VK_PAD_X: { // Next page - int iPrevPage = ( int )( m_eCurrPage ) - 1; + int iPrevPage = static_cast(m_eCurrPage) - 1; if ( iPrevPage >= 0 ) { - StartPage( ( EHowToPlayPage )( iPrevPage ) ); + StartPage( static_cast(iPrevPage) ); CXuiSceneBase::PlayUISFX(eSFX_Press); } rfHandled = TRUE; diff --git a/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp b/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp index 14046f203..8e5d21c44 100644 --- a/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp @@ -65,7 +65,7 @@ unsigned int CScene_HowToPlayMenu::m_uiHTPSceneA[]= //---------------------------------------------------------------------------------- HRESULT CScene_HowToPlayMenu::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); bool bSplitscreen= app.GetLocalPlayerCount()>1; @@ -131,7 +131,7 @@ HRESULT CScene_HowToPlayMenu::OnGetSourceDataText(XUIMessageGetSourceText *pGetS { if( pGetSourceTextData->bItemData ) { - if( pGetSourceTextData->iItem < (int)eHTPButton_Max ) + if( pGetSourceTextData->iItem < static_cast(eHTPButton_Max) ) { pGetSourceTextData->szText = app.GetString(m_uiHTPButtonNameA[pGetSourceTextData->iItem]);//m_Buttons[pGetSourceTextData->iItem].GetText(); pGetSourceTextData->bDisplay = TRUE; @@ -173,7 +173,7 @@ HRESULT CScene_HowToPlayMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPres // 4J-PB - now using a list for all resolutions //if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) || app.GetLocalPlayerCount()>1) { - if(hObjPressed==m_ButtonList && m_ButtonList.TreeHasFocus() && (m_ButtonList.GetItemCount() > 0) && (m_ButtonList.GetCurSel() < (int)eHTPButton_Max) ) + if(hObjPressed==m_ButtonList && m_ButtonList.TreeHasFocus() && (m_ButtonList.GetItemCount() > 0) && (m_ButtonList.GetCurSel() < static_cast(eHTPButton_Max)) ) { uiButtonCounter=m_ButtonList.GetCurSel(); } @@ -186,7 +186,7 @@ HRESULT CScene_HowToPlayMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPres // Determine which button was pressed, // and call the appropriate function. - uiInitData = ( ( 1 << 31 ) | ( m_uiHTPSceneA[uiButtonCounter] << 16 ) | ( short )( m_iPad ) ); + uiInitData = ( ( 1 << 31 ) | ( m_uiHTPSceneA[uiButtonCounter] << 16 ) | static_cast(m_iPad) ); if(app.GetLocalPlayerCount()>1) { app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_HowToPlay, ( void* )( uiInitData ) ); diff --git a/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp b/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp index f05617451..71125b685 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp @@ -12,7 +12,7 @@ //---------------------------------------------------------------------------------- HRESULT CScene_InGameHostOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); MapChildControls(); diff --git a/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp b/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp index 4839013c9..7bd71336f 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp @@ -25,7 +25,7 @@ HRESULT CScene_InGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { m_bIgnoreKeyPresses=true; - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); MapChildControls(); @@ -142,7 +142,7 @@ HRESULT CScene_InGameInfo::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandle INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId(m_players[playersList.GetCurSel()]); if( player != NULL ) { - PlayerUID xuid = ((NetworkPlayerXbox *)player)->GetUID(); + PlayerUID xuid = static_cast(player)->GetUID(); if( xuid != INVALID_XUID ) hr = XShowGamerCardUI(pInputData->UserIndex, xuid); } @@ -268,7 +268,7 @@ HRESULT CScene_InGameInfo::OnNotifySetFocus( HXUIOBJ hObjSource, XUINotifyFocus void CScene_InGameInfo::OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving) { - CScene_InGameInfo *scene = (CScene_InGameInfo *)callbackParam; + CScene_InGameInfo *scene = static_cast(callbackParam); bool playerFound = false; for(int i = 0; i < scene->m_playersCount; ++i) @@ -520,7 +520,7 @@ HRESULT CScene_InGameInfo::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL int CScene_InGameInfo::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - BYTE smallId = *(BYTE *)pParam; + BYTE smallId = *static_cast(pParam); delete pParam; if(result==C4JStorage::EMessage_ResultAccept) diff --git a/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp b/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp index 156cd0925..bb3419678 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp @@ -16,9 +16,9 @@ //---------------------------------------------------------------------------------- HRESULT CScene_InGamePlayerOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); - InGamePlayerOptionsInitData *initData = (InGamePlayerOptionsInitData *)pInitData->pvInitData; + InGamePlayerOptionsInitData *initData = static_cast(pInitData->pvInitData); m_iPad = initData->iPad; m_networkSmallId = initData->networkSmallId; m_playerPrivileges = initData->playerPrivileges; @@ -330,7 +330,7 @@ HRESULT CScene_InGamePlayerOptions::OnControlNavigate(XUIMessageControlNavigate int CScene_InGamePlayerOptions::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - BYTE smallId = *(BYTE *)pParam; + BYTE smallId = *static_cast(pParam); delete pParam; if(result==C4JStorage::EMessage_ResultAccept) @@ -353,13 +353,13 @@ int CScene_InGamePlayerOptions::KickPlayerReturned(void *pParam,int iPad,C4JStor void CScene_InGamePlayerOptions::OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving) { - CScene_InGamePlayerOptions *scene = (CScene_InGamePlayerOptions *)callbackParam; + CScene_InGamePlayerOptions *scene = static_cast(callbackParam); HXUIOBJ hBackScene = scene->GetBackScene(); CScene_InGameInfo* infoScene; VOID *pObj; XuiObjectFromHandle( hBackScene, &pObj ); - infoScene = (CScene_InGameInfo *)pObj; + infoScene = static_cast(pObj); if(infoScene != NULL) CScene_InGameInfo::OnPlayerChanged(infoScene,pPlayer,leaving); if(leaving && pPlayer != NULL && pPlayer->GetSmallId() == scene->m_networkSmallId) diff --git a/Minecraft.Client/Common/XUI/XUI_Leaderboards.cpp b/Minecraft.Client/Common/XUI/XUI_Leaderboards.cpp index 428b3e88a..35fa6250c 100644 --- a/Minecraft.Client/Common/XUI/XUI_Leaderboards.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Leaderboards.cpp @@ -75,7 +75,7 @@ const CScene_Leaderboards::LeaderboardDescriptor CScene_Leaderboards::LEADERBOAR HRESULT CScene_Leaderboards::OnInit(XUIMessageInit *pInitData, BOOL &bHandled) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); MapChildControls(); m_bReady=false; @@ -143,13 +143,13 @@ void CScene_Leaderboards::Reposition(int iNumber) D3DXVECTOR3 vPos; fIconSize=(m_fTitleIconXPositions[6]-m_fTitleIconXPositions[0])/6.0f; - fNewIconIncrement=(fIconSize*7.0f)/(float)iNumber; + fNewIconIncrement=(fIconSize*7.0f)/static_cast(iNumber); // reposition the title icons based on the number there are for(int i=0;iGetPosition(&vPos); - vPos.x=m_fTitleIconXPositions[0]+(((float)i)*fNewIconIncrement)+(fNewIconIncrement-fIconSize)/2.0f; + vPos.x=m_fTitleIconXPositions[0]+(static_cast(i)*fNewIconIncrement)+(fNewIconIncrement-fIconSize)/2.0f; m_pHTitleIconSlots[i]->SetPosition(&vPos); } } @@ -161,14 +161,14 @@ void CScene_Leaderboards::RepositionText(int iNumber) D3DXVECTOR3 vPos; fTextSize=(m_fTextXPositions[6]-m_fTextXPositions[0])/6.0f; - fNewTextIncrement=(fTextSize*7.0f)/(float)iNumber; + fNewTextIncrement=(fTextSize*7.0f)/static_cast(iNumber); // reposition the title icons based on the number there are for(int i=0;i(i)*fNewTextIncrement); XuiElementSetPosition(m_hTextEntryA[i],&vPos); // and change the size float fWidth,fHeight; @@ -222,7 +222,7 @@ void CScene_Leaderboards::UpdateTooltips() int iTooltipGamerCardOrProfile=-1; if( m_leaderboard.m_currentEntryCount > 0 ) { - unsigned int selection = (unsigned int)m_listGamers.GetCurSel(); + unsigned int selection = static_cast(m_listGamers.GetCurSel()); // if the selected user is me, don't show Send Friend Request, and show the gamer profile, not the gamer card @@ -368,7 +368,7 @@ HRESULT CScene_Leaderboards::OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandl else { m_newTop = m_listGamers.GetTopItem() + 10; - if( m_newTop+10 > (int)m_leaderboard.m_totalEntryCount ) + if( m_newTop+10 > static_cast(m_leaderboard.m_totalEntryCount) ) { m_newTop = m_leaderboard.m_totalEntryCount - 10; if( m_newTop < 0 ) @@ -426,7 +426,7 @@ HRESULT CScene_Leaderboards::OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandl //Show gamercard if( m_leaderboard.m_currentEntryCount > 0 ) { - unsigned int selection = (unsigned int)m_listGamers.GetCurSel(); + unsigned int selection = static_cast(m_listGamers.GetCurSel()); if( selection >= m_leaderboard.m_entryStartIndex-1 && selection < (m_leaderboard.m_entryStartIndex+m_leaderboard.m_currentEntryCount-1) ) { @@ -448,7 +448,7 @@ HRESULT CScene_Leaderboards::OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandl { if( m_leaderboard.m_currentEntryCount > 0 ) { - unsigned int selection = (unsigned int)m_listGamers.GetCurSel(); + unsigned int selection = static_cast(m_listGamers.GetCurSel()); if( selection >= m_leaderboard.m_entryStartIndex-1 && selection < (m_leaderboard.m_entryStartIndex+m_leaderboard.m_currentEntryCount-1) ) { @@ -547,7 +547,7 @@ void CScene_Leaderboards::ReadStats(int startIndex) } else { - m_newEntryIndex = (unsigned int)startIndex; + m_newEntryIndex = static_cast(startIndex); m_newReadSize = min((int)READ_SIZE, (int)m_leaderboard.m_totalEntryCount-(startIndex-1)); } @@ -574,20 +574,20 @@ void CScene_Leaderboards::ReadStats(int startIndex) { case LeaderboardManager::eFM_TopRank: LeaderboardManager::Instance()->ReadStats_TopRank( this, - m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard, + m_currentDifficulty, static_cast(m_currentLeaderboard), m_newEntryIndex, m_newReadSize ); break; case LeaderboardManager::eFM_MyScore: LeaderboardManager::Instance()->ReadStats_MyScore( this, - m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard, + m_currentDifficulty, static_cast(m_currentLeaderboard), INVALID_XUID/*ignored*/, m_newReadSize ); break; case LeaderboardManager::eFM_Friends: LeaderboardManager::Instance()->ReadStats_Friends( this, - m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard, + m_currentDifficulty, static_cast(m_currentLeaderboard), INVALID_XUID /*ignored*/, 0 /*ignored*/, 0 /*ignored*/ ); @@ -660,7 +660,7 @@ bool CScene_Leaderboards::RetrieveStats() else { m_leaderboard.m_entries[entryIndex].m_columns[i] = UINT_MAX; - swprintf(m_leaderboard.m_entries[entryIndex].m_wcColumns[i], 12, L"%.1fkm", ((float)m_leaderboard.m_entries[entryIndex].m_columns[i])/100.f/1000.f); + swprintf(m_leaderboard.m_entries[entryIndex].m_wcColumns[i], 12, L"%.1fkm", static_cast(m_leaderboard.m_entries[entryIndex].m_columns[i])/100.f/1000.f); } } @@ -822,7 +822,7 @@ HRESULT CScene_Leaderboards::OnGetSourceDataText(XUIMessageGetSourceText *pGetSo int readIndex = m_leaderboard.m_entryStartIndex - READ_SIZE; if( readIndex <= 0 ) readIndex = 1; - assert( readIndex >= 1 && readIndex <= (int)m_leaderboard.m_totalEntryCount ); + assert( readIndex >= 1 && readIndex <= static_cast(m_leaderboard.m_totalEntryCount)); ReadStats(readIndex); } } @@ -831,7 +831,7 @@ HRESULT CScene_Leaderboards::OnGetSourceDataText(XUIMessageGetSourceText *pGetSo if( LeaderboardManager::Instance()->isIdle() ) { int readIndex = m_leaderboard.m_entryStartIndex + m_leaderboard.m_currentEntryCount; - assert( readIndex >= 1 && readIndex <= (int)m_leaderboard.m_totalEntryCount ); + assert( readIndex >= 1 && readIndex <= static_cast(m_leaderboard.m_totalEntryCount)); ReadStats(readIndex); } } @@ -850,7 +850,7 @@ HRESULT CScene_Leaderboards::OnGetSourceDataText(XUIMessageGetSourceText *pGetSo } else if( pGetSourceTextData->iData >= 3 && pGetSourceTextData->iData <= 9 ) { - if( m_leaderboard.m_numColumns <= (unsigned int)(pGetSourceTextData->iData-3) ) + if( m_leaderboard.m_numColumns <= static_cast(pGetSourceTextData->iData - 3) ) pGetSourceTextData->szText = L""; else pGetSourceTextData->szText = m_leaderboard.m_entries[index].m_wcColumns[pGetSourceTextData->iData-3]; @@ -914,7 +914,7 @@ void CScene_Leaderboards::PopulateLeaderboard(bool noResults) hr=XuiElementGetChildById(visual,m_TitleIconNameA[i],&button); XuiObjectFromHandle( button, &pObj ); - m_pHTitleIconSlots[i] = (CXuiCtrlCraftIngredientSlot *)pObj; + m_pHTitleIconSlots[i] = static_cast(pObj); // store the default position, since we'll be repositioning these depending on how many are valid for each board m_pHTitleIconSlots[i]->GetPosition(&vPos); @@ -1088,24 +1088,24 @@ void CScene_Leaderboards::CopyLeaderboardEntry(PXUSER_STATS_ROW statsRow, Leader else if(iDigitC<8) { // km with a .X - swprintf_s(leaderboardEntry->m_wcColumns[i], 12, L"%.1fkm", ((float)leaderboardEntry->m_columns[i])/1000.f); + swprintf_s(leaderboardEntry->m_wcColumns[i], 12, L"%.1fkm", static_cast(leaderboardEntry->m_columns[i])/1000.f); #ifdef _DEBUG - app.DebugPrintf("Display - %.1fkm\n", ((float)leaderboardEntry->m_columns[i])/1000.f); + app.DebugPrintf("Display - %.1fkm\n", static_cast(leaderboardEntry->m_columns[i])/1000.f); #endif } else { // bigger than that, so no decimal point - swprintf_s(leaderboardEntry->m_wcColumns[i], 12, L"%.0fkm", ((float)leaderboardEntry->m_columns[i])/1000.f); + swprintf_s(leaderboardEntry->m_wcColumns[i], 12, L"%.0fkm", static_cast(leaderboardEntry->m_columns[i])/1000.f); #ifdef _DEBUG - app.DebugPrintf("Display - %.0fkm\n", ((float)leaderboardEntry->m_columns[i])/1000.f); + app.DebugPrintf("Display - %.0fkm\n", static_cast(leaderboardEntry->m_columns[i])/1000.f); #endif } } } //Is the player - if( statsRow->xuid == ((XboxLeaderboardManager*)LeaderboardManager::Instance())->GetMyXUID() ) + if( statsRow->xuid == static_cast(LeaderboardManager::Instance())->GetMyXUID() ) { leaderboardEntry->m_bPlayer = true; leaderboardEntry->m_bOnline = false; diff --git a/Minecraft.Client/Common/XUI/XUI_LoadSettings.cpp b/Minecraft.Client/Common/XUI/XUI_LoadSettings.cpp index 7f32ff89e..55e967887 100644 --- a/Minecraft.Client/Common/XUI/XUI_LoadSettings.cpp +++ b/Minecraft.Client/Common/XUI/XUI_LoadSettings.cpp @@ -49,7 +49,7 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl WCHAR TempString[256]; - m_params = (LoadMenuInitData *)pInitData->pvInitData; + m_params = static_cast(pInitData->pvInitData); m_MoreOptionsParams.bGenerateOptions=FALSE; m_MoreOptionsParams.bPVP = TRUE; @@ -276,7 +276,7 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl if(dwImageBytes > 0 && pbImageData) { ListInfo.fEnabled = TRUE; - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp; + DLCTexturePack *pDLCTexPack=static_cast(tp); if(pDLCTexPack) { int id=pDLCTexPack->getDLCParentPackId(); @@ -469,7 +469,7 @@ HRESULT CScene_LoadGameSettings::LaunchGame(void) int CScene_LoadGameSettings::CheckResetNetherReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam; + CScene_LoadGameSettings* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) @@ -703,7 +703,7 @@ HRESULT CScene_LoadGameSettings::OnFontRendererChange() int CScene_LoadGameSettings::ConfirmLoadReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam; + CScene_LoadGameSettings* pClass = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { @@ -840,7 +840,7 @@ int CScene_LoadGameSettings::Progress(void *pParam,float fProgress) int CScene_LoadGameSettings::LoadSaveDataReturned(void *pParam,bool bContinue) { - CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam; + CScene_LoadGameSettings* pClass = static_cast(pParam); if(bContinue==true) { @@ -903,7 +903,7 @@ int CScene_LoadGameSettings::LoadSaveDataReturned(void *pParam,bool bContinue) int CScene_LoadGameSettings::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam; + CScene_LoadGameSettings* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) @@ -921,7 +921,7 @@ int CScene_LoadGameSettings::DeleteSaveDialogReturned(void *pParam,int iPad,C4JS int CScene_LoadGameSettings::DeleteSaveDataReturned(void *pParam,bool bSuccess) { - CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam; + CScene_LoadGameSettings* pClass = static_cast(pParam); app.SetCorruptSaveDeleted(true); app.NavigateBack(pClass->m_iPad); @@ -983,7 +983,7 @@ void CScene_LoadGameSettings::StartGameFromSave(CScene_LoadGameSettings* pClass, LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); // Reset the autosave timer app.SetAutosaveTimerTime(); @@ -1000,7 +1000,7 @@ void CScene_LoadGameSettings::StartGameFromSave(CScene_LoadGameSettings* pClass, int CScene_LoadGameSettings::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - CScene_LoadGameSettings* pClass = (CScene_LoadGameSettings*)pParam; + CScene_LoadGameSettings* pClass = static_cast(pParam); if(bContinue==true) { @@ -1082,7 +1082,7 @@ HRESULT CScene_LoadGameSettings::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINo if(hObjSource==m_SliderDifficulty.GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_Difficulty,pNotifyValueChanged->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[pNotifyValueChanged->nValue])); + swprintf( static_cast(TempString), 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[pNotifyValueChanged->nValue])); m_SliderDifficulty.SetText(TempString); } return S_OK; @@ -1150,7 +1150,7 @@ HRESULT CScene_LoadGameSettings::OnTransitionEnd( XUIMessageTransition *pTransit int CScene_LoadGameSettings::UnlockTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_LoadGameSettings* pScene = (CScene_LoadGameSettings*)pParam; + CScene_LoadGameSettings* pScene = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { @@ -1482,7 +1482,7 @@ void CScene_LoadGameSettings::LoadLevelGen(LevelGenerationOptions *levelGen) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); // Reset the autosave timer app.SetAutosaveTimerTime(); @@ -1540,7 +1540,7 @@ HRESULT CScene_LoadGameSettings::OnCustomMessage_DLCMountingComplete() ListInfo.fEnabled = TRUE; hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp; + DLCTexturePack *pDLCTexPack=static_cast(tp); if(pDLCTexPack) { int id=pDLCTexPack->getDLCParentPackId(); @@ -1635,7 +1635,7 @@ HRESULT CScene_LoadGameSettings::OnCustomMessage_DLCMountingComplete() int CScene_LoadGameSettings::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_LoadGameSettings *pClass = (CScene_LoadGameSettings *)pParam; + CScene_LoadGameSettings *pClass = static_cast(pParam); #ifdef _XBOX pClass->m_currentTexturePackIndex = pClass->m_pTexturePacksList->GetCurSel(); // Exit with or without saving diff --git a/Minecraft.Client/Common/XUI/XUI_MainMenu.cpp b/Minecraft.Client/Common/XUI/XUI_MainMenu.cpp index 7b9c1a56e..b5f722eb1 100644 --- a/Minecraft.Client/Common/XUI/XUI_MainMenu.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MainMenu.cpp @@ -325,7 +325,7 @@ HRESULT CScene_Main::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO) { // 4J-PB - remove the "hobo humping" message legal (Sony) say we can't have - pretty sure Microsoft would say the same if they noticed it. - int splashIndex = eSplashRandomStart + 1 + random->nextInt( (int)m_splashes.size() - (eSplashRandomStart + 1) ); + int splashIndex = eSplashRandomStart + 1 + random->nextInt( static_cast(m_splashes.size()) - (eSplashRandomStart + 1) ); // Override splash text on certain dates SYSTEMTIME LocalSysTime; @@ -457,7 +457,7 @@ HRESULT CScene_Main::OnKeyDown(XUIMessageInput *pInputData, BOOL& bHandled) int CScene_Main::SignInReturned(void *pParam,bool bContinue) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); if(bContinue==true) { @@ -470,7 +470,7 @@ int CScene_Main::SignInReturned(void *pParam,bool bContinue) int CScene_Main::DeviceSelectReturned(void *pParam,bool bContinue) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); //HRESULT hr; if(bContinue==true) @@ -506,7 +506,7 @@ int CScene_Main::DeviceSelectReturned(void *pParam,bool bContinue) int CScene_Main::CreateLoad_OfflineProfileReturned(void *pParam,bool bContinue, int iPad) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); if(bContinue==true) { @@ -555,7 +555,7 @@ int CScene_Main::CreateLoad_OfflineProfileReturned(void *pParam,bool bContinue, int CScene_Main::CreateLoad_SignInReturned(void *pParam,bool bContinue, int iPad) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); if(bContinue==true) { @@ -662,7 +662,7 @@ int CScene_Main::CreateLoad_SignInReturned(void *pParam,bool bContinue, int iPad int CScene_Main::MustSignInReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { @@ -787,7 +787,7 @@ int CScene_Main::Achievements_SignInReturned(void *pParam,bool bContinue,int iPa } int CScene_Main::HelpAndOptions_SignInReturned(void *pParam,bool bContinue,int iPad) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); if(bContinue==true) { @@ -834,7 +834,7 @@ int CScene_Main::HelpAndOptions_SignInReturned(void *pParam,bool bContinue,int i int CScene_Main::UnlockFullGame_SignInReturned(void *pParam,bool bContinue,int iPad) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); if(bContinue==true) { @@ -915,7 +915,7 @@ void CScene_Main::LoadTrial(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1228,7 +1228,7 @@ void CScene_Main::RunUnlockOrDLC(int iPad) int CScene_Main::TMSReadFileListReturned(void *pParam,int iPad,C4JStorage::PTMSPP_FILE_LIST pTmsFileList) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); // push the file details in to a unordered map if they are not already in there // for(int i=0;iiCount;i++) @@ -1240,7 +1240,7 @@ int CScene_Main::TMSReadFileListReturned(void *pParam,int iPad,C4JStorage::PTMSP int CScene_Main::TMSFileWriteReturned(void *pParam,int iPad,int iResult) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); // push the file details in to a unordered map if they are not already in there // for(int i=0;iiCount;i++) @@ -1252,7 +1252,7 @@ int CScene_Main::TMSFileWriteReturned(void *pParam,int iPad,int iResult) int CScene_Main::TMSFileReadReturned(void *pParam,int iPad,C4JStorage::PTMSPP_FILEDATA pData) { - CScene_Main* pClass = (CScene_Main*)pParam; + CScene_Main* pClass = static_cast(pParam); // push the file details in to a unordered map if they are not already in there // for(int i=0;iiCount;i++) diff --git a/Minecraft.Client/Common/XUI/XUI_MultiGameCreate.cpp b/Minecraft.Client/Common/XUI/XUI_MultiGameCreate.cpp index b3608b068..4034f3c20 100644 --- a/Minecraft.Client/Common/XUI/XUI_MultiGameCreate.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MultiGameCreate.cpp @@ -52,7 +52,7 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle XuiControlSetText(m_labelRandomSeed,app.GetString(IDS_CREATE_NEW_WORLD_RANDOM_SEED)); XuiControlSetText(m_pTexturePacksList->m_hObj,app.GetString(IDS_DLC_MENU_TEXTUREPACKS)); - CreateWorldMenuInitData *params = (CreateWorldMenuInitData *)pInitData->pvInitData; + CreateWorldMenuInitData *params = static_cast(pInitData->pvInitData); m_MoreOptionsParams.bGenerateOptions=TRUE; m_MoreOptionsParams.bStructures=TRUE; @@ -139,7 +139,7 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle wstring wWorldName = m_EditWorldName.GetText(); // set the caret to the end of the default text - m_EditWorldName.SetCaretPosition((int)wWorldName.length()); + m_EditWorldName.SetCaretPosition(static_cast(wWorldName.length())); // In the dashboard, there's room for about 30 W characters on two lines before they go over the top of things m_EditWorldName.SetTextLimit(25); @@ -190,7 +190,7 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle if(dwImageBytes > 0 && pbImageData) { ListInfo.fEnabled = TRUE; - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp; + DLCTexturePack *pDLCTexPack=static_cast(tp); if(pDLCTexPack) { int id=pDLCTexPack->getDLCParentPackId(); @@ -522,7 +522,7 @@ HRESULT CScene_MultiGameCreate::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPr int CScene_MultiGameCreate::UnlockTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameCreate* pScene = (CScene_MultiGameCreate*)pParam; + CScene_MultiGameCreate* pScene = static_cast(pParam); #ifdef _XBOX if(result==C4JStorage::EMessage_ResultAccept) { @@ -558,7 +558,7 @@ int CScene_MultiGameCreate::UnlockTexturePackReturned(void *pParam,int iPad,C4JS int CScene_MultiGameCreate::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameCreate* pScene = (CScene_MultiGameCreate*)pParam; + CScene_MultiGameCreate* pScene = static_cast(pParam); pScene->m_bIgnoreInput = false; pScene->SetShow( TRUE ); bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pScene->m_MoreOptionsParams.bOnlineGame; @@ -634,7 +634,7 @@ HRESULT CScene_MultiGameCreate::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINot else if(hObjSource==m_SliderDifficulty.GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_Difficulty,pValueChangedData->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[pValueChangedData->nValue])); + swprintf( static_cast(TempString), 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[pValueChangedData->nValue])); m_SliderDifficulty.SetText(TempString); } @@ -754,7 +754,7 @@ HRESULT CScene_MultiGameCreate::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled int CScene_MultiGameCreate::ConfirmCreateReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameCreate* pClass = (CScene_MultiGameCreate*)pParam; + CScene_MultiGameCreate* pClass = static_cast(pParam); if(result==C4JStorage::EMessage_ResultAccept) { @@ -808,7 +808,7 @@ int CScene_MultiGameCreate::ConfirmCreateReturned(void *pParam,int iPad,C4JStora int CScene_MultiGameCreate::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - CScene_MultiGameCreate* pClass = (CScene_MultiGameCreate*)pParam; + CScene_MultiGameCreate* pClass = static_cast(pParam); if(bContinue==true) { @@ -909,7 +909,7 @@ void CScene_MultiGameCreate::CreateGame(CScene_MultiGameCreate* pClass, DWORD dw if (wSeed.length() != 0) { __int64 value = 0; - unsigned int len = (unsigned int)wSeed.length(); + unsigned int len = static_cast(wSeed.length()); //Check if the input string contains a numerical value bool isNumber = true; @@ -979,7 +979,7 @@ void CScene_MultiGameCreate::CreateGame(CScene_MultiGameCreate* pClass, DWORD dw LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); // Reset the autosave time app.SetAutosaveTimerTime(); @@ -1217,7 +1217,7 @@ void CScene_MultiGameCreate::UpdateCurrentTexturePack() int CScene_MultiGameCreate::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameCreate *pClass = (CScene_MultiGameCreate *)pParam; + CScene_MultiGameCreate *pClass = static_cast(pParam); pClass->m_currentTexturePackIndex = pClass->m_pTexturePacksList->GetCurSel(); // Exit with or without saving // Decline means install full version of the texture pack in this dialog @@ -1295,7 +1295,7 @@ HRESULT CScene_MultiGameCreate::OnCustomMessage_DLCMountingComplete() ListInfo.fEnabled = TRUE; hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp; + DLCTexturePack *pDLCTexPack=static_cast(tp); if(pDLCTexPack) { int id=pDLCTexPack->getDLCParentPackId(); diff --git a/Minecraft.Client/Common/XUI/XUI_MultiGameInfo.cpp b/Minecraft.Client/Common/XUI/XUI_MultiGameInfo.cpp index bbfa243b2..671b9e8ee 100644 --- a/Minecraft.Client/Common/XUI/XUI_MultiGameInfo.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MultiGameInfo.cpp @@ -31,7 +31,7 @@ HRESULT CScene_MultiGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled XuiControlSetText(m_labelTNTOn,app.GetString(IDS_LABEL_TNT)); XuiControlSetText(m_labelFireOn,app.GetString(IDS_LABEL_FIRE_SPREADS)); - JoinMenuInitData *initData = (JoinMenuInitData *)pInitData->pvInitData; + JoinMenuInitData *initData = static_cast(pInitData->pvInitData); m_selectedSession = initData->selectedSession; m_iPad = initData->iPad; // 4J-PB - don't delete this - it's part of the joinload structure @@ -237,7 +237,7 @@ HRESULT CScene_MultiGameInfo::OnNotifyKillFocus(HXUIOBJ hObjSource, XUINotifyFoc int CScene_MultiGameInfo::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - CScene_MultiGameInfo* pClass = (CScene_MultiGameInfo*)pParam; + CScene_MultiGameInfo* pClass = static_cast(pParam); if(bContinue==true) { diff --git a/Minecraft.Client/Common/XUI/XUI_MultiGameJoinLoad.cpp b/Minecraft.Client/Common/XUI/XUI_MultiGameJoinLoad.cpp index c5e2fe9af..83cb240f6 100644 --- a/Minecraft.Client/Common/XUI/XUI_MultiGameJoinLoad.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MultiGameJoinLoad.cpp @@ -36,7 +36,7 @@ HRESULT CScene_MultiGameJoinLoad::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); m_bReady=false; MapChildControls(); @@ -95,10 +95,10 @@ HRESULT CScene_MultiGameJoinLoad::OnInit( XUIMessageInit* pInitData, BOOL& bHand VOID *pObj; XuiObjectFromHandle( m_SavesList, &pObj ); - m_pSavesList = (CXuiCtrl4JList *)pObj; + m_pSavesList = static_cast(pObj); XuiObjectFromHandle( m_GamesList, &pObj ); - m_pGamesList = (CXuiCtrl4JList *)pObj; + m_pGamesList = static_cast(pObj); // block input if we're waiting for DLC to install, and wipe the saves list. The end of dlc mounting custom message will fill the list again if(app.StartInstallDLCProcess(m_iPad)==true) @@ -326,7 +326,7 @@ HRESULT CScene_MultiGameJoinLoad::GetSaveInfo( ) if( savesDir.exists() ) { m_saves = savesDir.listFiles(); - uiSaveC = (unsigned int)m_saves->size(); + uiSaveC = static_cast(m_saves->size()); } // add the New Game and Tutorial after the saves list is retrieved, if there are any saves @@ -415,7 +415,7 @@ HRESULT CScene_MultiGameJoinLoad::OnDestroy() int CScene_MultiGameJoinLoad::DeviceRemovedDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) @@ -543,7 +543,7 @@ HRESULT CScene_MultiGameJoinLoad::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotify CreateWorldMenuInitData *params = new CreateWorldMenuInitData(); params->iPad = m_iPad; - app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_CreateWorldMenu,(void *)params); + app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_CreateWorldMenu,static_cast(params)); } else if(info.iData >= 0) { @@ -1113,7 +1113,7 @@ void CScene_MultiGameJoinLoad::UpdateGamesListCallback(LPVOID lpParam) { if(lpParam != NULL) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad *) lpParam; + CScene_MultiGameJoinLoad* pClass = static_cast(lpParam); // check this there's no save transfer in progress if(!pClass->m_bSaveTransferInProgress) { @@ -1213,7 +1213,7 @@ void CScene_MultiGameJoinLoad::UpdateGamesList() // Update the xui list displayed unsigned int xuiListSize = m_pGamesList->GetItemCount(); - unsigned int filteredListSize = (unsigned int)currentSessions.size(); + unsigned int filteredListSize = static_cast(currentSessions.size()); BOOL gamesListHasFocus = m_pGamesList->TreeHasFocus(); @@ -1528,7 +1528,7 @@ void CScene_MultiGameJoinLoad::SearchForGameCallback(void *param, DWORD dwNumRes int CScene_MultiGameJoinLoad::DeviceSelectReturned(void *pParam,bool bContinue) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); //HRESULT hr; if(bContinue==true) @@ -1814,7 +1814,7 @@ int CScene_MultiGameJoinLoad::LoadSaveDataReturned(void *pParam,bool bContinue) int CScene_MultiGameJoinLoad::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); if(bContinue==true) { @@ -1866,7 +1866,7 @@ void CScene_MultiGameJoinLoad::StartGameFromSave(CScene_MultiGameJoinLoad* pClas int CScene_MultiGameJoinLoad::DeleteSaveDataReturned(void *pParam,bool bSuccess) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); if(bSuccess==true) { @@ -1924,7 +1924,7 @@ void CScene_MultiGameJoinLoad::LoadLevelGen(LevelGenerationOptions *levelGen) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1974,7 +1974,7 @@ void CScene_MultiGameJoinLoad::LoadSaveFromDisk(File *saveFile) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1988,7 +1988,7 @@ void CScene_MultiGameJoinLoad::LoadSaveFromDisk(File *saveFile) int CScene_MultiGameJoinLoad::DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultDecline) { @@ -2013,7 +2013,7 @@ int CScene_MultiGameJoinLoad::DeleteSaveDialogReturned(void *pParam,int iPad,C4J int CScene_MultiGameJoinLoad::SaveTransferDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); // results switched for this dialog if(result==C4JStorage::EMessage_ResultAccept) { @@ -2039,7 +2039,7 @@ int CScene_MultiGameJoinLoad::SaveTransferDialogReturned(void *pParam,int iPad,C int CScene_MultiGameJoinLoad::UploadSaveForXboxOneThreadProc( LPVOID lpParameter ) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad *) lpParameter; + CScene_MultiGameJoinLoad* pClass = static_cast(lpParameter); Minecraft *pMinecraft = Minecraft::GetInstance(); pMinecraft->progressRenderer->progressStart(IDS_SAVE_TRANSFER_TITLE); @@ -2178,7 +2178,7 @@ void CScene_MultiGameJoinLoad::UploadFile(CScene_MultiGameJoinLoad *pClass, char C4JStorage::TMS_FILETYPE_BINARY, C4JStorage::TMS_UGCTYPE_NONE, filename, - (CHAR *)data, + static_cast(data), size, &CScene_MultiGameJoinLoad::TransferComplete,pClass, 0, &CScene_MultiGameJoinLoad::Progress,pClass); @@ -2219,7 +2219,7 @@ bool CScene_MultiGameJoinLoad::WaitForTransferComplete( CScene_MultiGameJoinLoad } Sleep(50); // update the progress - pMinecraft->progressRenderer->progressStagePercentage((unsigned int)(pClass->m_fProgress*100.0f)); + pMinecraft->progressRenderer->progressStagePercentage(static_cast(pClass->m_fProgress * 100.0f)); } // was there a transfer error? @@ -2229,7 +2229,7 @@ bool CScene_MultiGameJoinLoad::WaitForTransferComplete( CScene_MultiGameJoinLoad int CScene_MultiGameJoinLoad::SaveOptionsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); // results switched for this dialog // EMessage_ResultAccept means cancel @@ -2261,7 +2261,7 @@ int CScene_MultiGameJoinLoad::SaveOptionsDialogReturned(void *pParam,int iPad,C4 int CScene_MultiGameJoinLoad::LoadSaveDataReturned(void *pParam,bool bContinue) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); if(bContinue==true) { @@ -2310,7 +2310,7 @@ int CScene_MultiGameJoinLoad::LoadSaveDataReturned(void *pParam,bool bContinue) int CScene_MultiGameJoinLoad::Progress(void *pParam,float fProgress) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); app.DebugPrintf("Progress - %f\n",fProgress); pClass->m_fProgress=fProgress; @@ -2319,7 +2319,7 @@ int CScene_MultiGameJoinLoad::Progress(void *pParam,float fProgress) int CScene_MultiGameJoinLoad::TransferComplete(void *pParam,int iPad, int iResult) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); delete [] pClass->m_pbSaveTransferData; pClass->m_pbSaveTransferData = NULL; @@ -2343,14 +2343,14 @@ int CScene_MultiGameJoinLoad::TransferComplete(void *pParam,int iPad, int iResul int CScene_MultiGameJoinLoad::DeleteComplete(void *pParam,int iPad, int iResult) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); pClass->m_bTransferComplete=true; return 0; } int CScene_MultiGameJoinLoad::KeyboardReturned(void *pParam,bool bSet) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); HRESULT hr = S_OK; // if the user has left the name empty, treat this as backing out @@ -2386,7 +2386,7 @@ int CScene_MultiGameJoinLoad::KeyboardReturned(void *pParam,bool bSet) int CScene_MultiGameJoinLoad::LoadSaveDataForRenameReturned(void *pParam,bool bContinue) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); #ifdef _XBOX if(bContinue==true) { @@ -2428,7 +2428,7 @@ int CScene_MultiGameJoinLoad::LoadSaveDataForRenameReturned(void *pParam,bool bC int CScene_MultiGameJoinLoad::CopySaveReturned(void *pParam,bool bResult) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad*)pParam; + CScene_MultiGameJoinLoad* pClass = static_cast(pParam); #ifdef _XBOX if(bResult) { @@ -2450,7 +2450,7 @@ int CScene_MultiGameJoinLoad::CopySaveReturned(void *pParam,bool bResult) int CScene_MultiGameJoinLoad::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_MultiGameJoinLoad *pClass = (CScene_MultiGameJoinLoad *)pParam; + CScene_MultiGameJoinLoad *pClass = static_cast(pParam); // Exit with or without saving // Decline means install full version of the texture pack in this dialog @@ -2510,7 +2510,7 @@ HRESULT CScene_MultiGameJoinLoad::OnCustomMessage_DLCMountingComplete() VOID *pObj; XuiObjectFromHandle( m_SavesList, &pObj ); - m_pSavesList = (CXuiCtrl4JList *)pObj; + m_pSavesList = static_cast(pObj); m_iChangingSaveGameInfoIndex = 0; @@ -2738,7 +2738,7 @@ int CScene_MultiGameJoinLoad::GetSavesInfoCallback(LPVOID lpParam,const bool) void CScene_MultiGameJoinLoad::CancelSaveUploadCallback(LPVOID lpParam) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad *) lpParam; + CScene_MultiGameJoinLoad* pClass = static_cast(lpParam); StorageManager.TMSPP_CancelWriteFileWithProgress(pClass->m_iPad); @@ -2755,7 +2755,7 @@ void CScene_MultiGameJoinLoad::CancelSaveUploadCallback(LPVOID lpParam) void CScene_MultiGameJoinLoad::SaveUploadCompleteCallback(LPVOID lpParam) { - CScene_MultiGameJoinLoad* pClass = (CScene_MultiGameJoinLoad *) lpParam; + CScene_MultiGameJoinLoad* pClass = static_cast(lpParam); pClass->m_bSaveTransferInProgress=false; // change back to the normal title group id diff --git a/Minecraft.Client/Common/XUI/XUI_MultiGameLaunchMoreOptions.cpp b/Minecraft.Client/Common/XUI/XUI_MultiGameLaunchMoreOptions.cpp index 086561110..69f474d58 100644 --- a/Minecraft.Client/Common/XUI/XUI_MultiGameLaunchMoreOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MultiGameLaunchMoreOptions.cpp @@ -28,7 +28,7 @@ HRESULT CScene_MultiGameLaunchMoreOptions::OnInit( XUIMessageInit* pInitData, BO XuiControlSetText(m_CheckboxFlatWorld,app.GetString(IDS_SUPERFLAT_WORLD)); XuiControlSetText(m_CheckboxBonusChest,app.GetString(IDS_BONUS_CHEST)); - m_params = (LaunchMoreOptionsMenuInitData *)pInitData->pvInitData; + m_params = static_cast(pInitData->pvInitData); if(m_params->bGenerateOptions) { diff --git a/Minecraft.Client/Common/XUI/XUI_NewUpdateMessage.cpp b/Minecraft.Client/Common/XUI/XUI_NewUpdateMessage.cpp index 49b524ffe..fa6da21e0 100644 --- a/Minecraft.Client/Common/XUI/XUI_NewUpdateMessage.cpp +++ b/Minecraft.Client/Common/XUI/XUI_NewUpdateMessage.cpp @@ -8,7 +8,7 @@ HRESULT CScene_NewUpdateMessage::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *) pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); m_bIsSD=!RenderManager.IsHiDef() && !RenderManager.IsWidescreen(); MapChildControls(); diff --git a/Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp b/Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp index 4de74d1f2..f6d71b07b 100644 --- a/Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp +++ b/Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp @@ -31,7 +31,7 @@ HRESULT UIScene_PauseMenu::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { m_bIgnoreInput=true; - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); bool bUserisClientSide = ProfileManager.IsSignedInLive(m_iPad); app.DebugPrintf("PAUSE PRESS PROCESSING - ipad = %d, UIScene_PauseMenu::OnInit\n",m_iPad); @@ -247,7 +247,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); m_pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); @@ -256,7 +256,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* // upsell ULONGLONG ullOfferID_Full; // get the dlc texture pack - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullOfferID_Full); @@ -319,7 +319,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* int playTime = -1; if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) { - playTime = (int)pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } if(StorageManager.GetSaveDisabled()) @@ -359,7 +359,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* int playTime = -1; if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) { - playTime = (int)pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Exited); @@ -377,7 +377,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* int playTime = -1; if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) { - playTime = (int)pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } // adjust the trial time played @@ -394,7 +394,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* int playTime = -1; if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) { - playTime = (int)pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer(); + playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Exited); @@ -623,7 +623,7 @@ int UIScene_PauseMenu::DeviceSelectReturned(void *pParam,bool bContinue) return 0; } - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; + UIScene_PauseMenu* pClass = static_cast(pParam); bool bIsisPrimaryHost=g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad()==pClass->m_iPad); bool bDisplayBanTip = !g_NetworkManager.IsLocalGame() && !bIsisPrimaryHost && !ProfileManager.IsGuest(pClass->m_iPad); bool bUserisClientSide = ProfileManager.IsSignedInLive(pClass->m_iPad); @@ -721,7 +721,7 @@ int UIScene_PauseMenu::DeviceRemovedDialogReturned(void *pParam,int iPad,C4JStor // Has someone pulled the ethernet cable and caused the pause menu to be closed before this callback returns? if(app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; + UIScene_PauseMenu* pClass = static_cast(pParam); // use the device select returned function to wipe the saves list and change the tooltip pClass->DeviceSelectReturned(pClass,true); @@ -732,7 +732,7 @@ int UIScene_PauseMenu::DeviceRemovedDialogReturned(void *pParam,int iPad,C4JStor // Change device if(app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; + UIScene_PauseMenu* pClass = static_cast(pParam); StorageManager.SetSaveDevice(&UIScene_PauseMenu::DeviceSelectReturned,pClass,true); } } @@ -770,7 +770,7 @@ void UIScene_PauseMenu::ShowScene(bool show) int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_PauseMenu* pScene = (UIScene_PauseMenu*)pParam; + UIScene_PauseMenu* pScene = static_cast(pParam); //pScene->m_bIgnoreInput = false; pScene->ShowScene( true ); @@ -782,7 +782,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); // get the dlc texture pack - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); // Need to get the parent packs id, since this may be one of many child packs with their own ids app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullIndexA[0]); @@ -804,7 +804,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J int UIScene_PauseMenu::ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_PauseMenu *pClass = (UIScene_PauseMenu *)pParam; + UIScene_PauseMenu *pClass = static_cast(pParam); // Exit with or without saving // Decline means save in this dialog if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption) @@ -815,7 +815,7 @@ int UIScene_PauseMenu::ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStora if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) @@ -890,7 +890,7 @@ int UIScene_PauseMenu::ExitGameDeclineSaveReturned(void *pParam,int iPad,C4JStor // has someone disconnected the ethernet here, causing the pause menu to shut? if(ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())) { - IUIScene_PauseMenu* pClass = (IUIScene_PauseMenu*)pParam; + IUIScene_PauseMenu* pClass = static_cast(pParam); UINT uiIDA[3]; // you cancelled the save on exit after choosing exit and save? You go back to the Exit choices then. uiIDA[0]=IDS_CONFIRM_CANCEL; @@ -927,7 +927,7 @@ int UIScene_PauseMenu::ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage: // has someone disconnected the ethernet here, causing the pause menu to shut? if(ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; + UIScene_PauseMenu* pClass = static_cast(pParam); UINT uiIDA[3]; // you cancelled the save on exit after choosing exit and save? You go back to the Exit choices then. uiIDA[0]=IDS_CONFIRM_CANCEL; @@ -971,7 +971,7 @@ int UIScene_PauseMenu::ExitGameDialogReturned(void *pParam,int iPad,C4JStorage:: int UIScene_PauseMenu::SaveWorldThreadProc( LPVOID lpParameter ) { - bool bAutosave=(bool)lpParameter; + bool bAutosave=static_cast(lpParameter); if(bAutosave) { app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_AutoSaveGame); diff --git a/Minecraft.Client/Common/XUI/XUI_Reinstall.cpp b/Minecraft.Client/Common/XUI/XUI_Reinstall.cpp index c1e06c0d1..5f8b585cd 100644 --- a/Minecraft.Client/Common/XUI/XUI_Reinstall.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Reinstall.cpp @@ -26,7 +26,7 @@ HRESULT CScene_Reinstall::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { // We'll only be in this menu from the main menu, not in game - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); m_bIgnoreInput=false; MapChildControls(); @@ -283,7 +283,7 @@ HRESULT CScene_Reinstall::OnTransitionStart( XUIMessageTransition *pTransition, int CScene_Reinstall::DeviceSelectReturned(void *pParam,bool bContinue) { - CScene_Reinstall* pClass = (CScene_Reinstall*)pParam; + CScene_Reinstall* pClass = static_cast(pParam); if(!StorageManager.GetSaveDeviceSelected(pClass->m_iPad)) { @@ -300,7 +300,7 @@ int CScene_Reinstall::DeviceSelectReturned(void *pParam,bool bContinue) int CScene_Reinstall::DeviceSelectReturned_AndReinstall(void *pParam,bool bContinue) { - CScene_Reinstall* pClass = (CScene_Reinstall*)pParam; + CScene_Reinstall* pClass = static_cast(pParam); if(!StorageManager.GetSaveDeviceSelected(pClass->m_iPad)) { diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_AbstractContainer.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_AbstractContainer.cpp index 03e783f42..1ccc031cd 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_AbstractContainer.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_AbstractContainer.cpp @@ -113,7 +113,7 @@ void CXuiSceneAbstractContainer::PlatformInitialize(int iPad, int startIndex) // Disable the default navigation behaviour for all slot lsit items (prevent old style cursor navigation). for ( int iSection = m_eFirstSection; iSection < m_eMaxSection; ++iSection ) { - ESceneSection eSection = ( ESceneSection )( iSection ); + ESceneSection eSection = static_cast(iSection); if(!IsSectionSlotList(eSection)) continue; diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp index 4a8617b47..a10c101b0 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp @@ -28,7 +28,7 @@ HRESULT CXuiSceneAnvil::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); - AnvilScreenInput* initData = (AnvilScreenInput*)pInitData->pvInitData; + AnvilScreenInput* initData = static_cast(pInitData->pvInitData); m_iPad=initData->iPad; m_bSplitscreen=initData->bSplitscreen; m_inventory = initData->inventory; @@ -42,7 +42,7 @@ HRESULT CXuiSceneAnvil::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Anvil_Menu, this); } @@ -69,7 +69,7 @@ HRESULT CXuiSceneAnvil::OnDestroy() if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } @@ -89,8 +89,8 @@ HRESULT CXuiSceneAnvil::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValue // strip leading spaces wstring b; - int start = (int)newValue.find_first_not_of(L" "); - int end = (int)newValue.find_last_not_of(L" "); + int start = static_cast(newValue.find_first_not_of(L" ")); + int end = static_cast(newValue.find_last_not_of(L" ")); if( start == wstring::npos ) { @@ -99,7 +99,7 @@ HRESULT CXuiSceneAnvil::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValue } else { - if( end == wstring::npos ) end = (int)newValue.size()-1; + if( end == wstring::npos ) end = static_cast(newValue.size())-1; b = newValue.substr(start,(end-start)+1); newValue=b; } diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp index 03782c79c..217e68f90 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp @@ -401,7 +401,7 @@ void CXuiSceneBase::_TickAllBaseScenes() if(uiOpacityTimer < (SharedConstants::TICKS_PER_SECOND * 1) ) { float fStep=(80.0f)/10.0f; - float fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + float fVal=0.01f*(80.0f-((10.0f-static_cast(uiOpacityTimer))*fStep)); XuiElementSetOpacity(m_selectedItemA[i],fVal); XuiElementSetOpacity(m_selectedItemSmallA[i],fVal); @@ -441,8 +441,8 @@ void CXuiSceneBase::_TickAllBaseScenes() { if(uiOpacityTimer<10) { - float fStep=(80.0f-(float)ucAlpha)/10.0f; - fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + float fStep=(80.0f-static_cast(ucAlpha))/10.0f; + fVal=0.01f*(80.0f-((10.0f-static_cast(uiOpacityTimer))*fStep)); } else { @@ -451,7 +451,7 @@ void CXuiSceneBase::_TickAllBaseScenes() } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } } else @@ -461,7 +461,7 @@ void CXuiSceneBase::_TickAllBaseScenes() { ucAlpha=15; } - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } XuiElementSetOpacity(app.GetCurrentHUDScene(i),fVal); @@ -627,8 +627,8 @@ HRESULT CXuiSceneBase::_ShowTooltip( unsigned int iPad, unsigned int tooltip, bo { if(uiOpacityTimer<10) { - float fStep=(80.0f-(float)ucAlpha)/10.0f; - fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + float fStep=(80.0f-static_cast(ucAlpha))/10.0f; + fVal=0.01f*(80.0f-((10.0f-static_cast(uiOpacityTimer))*fStep)); } else { @@ -637,7 +637,7 @@ HRESULT CXuiSceneBase::_ShowTooltip( unsigned int iPad, unsigned int tooltip, bo } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } } else @@ -647,7 +647,7 @@ HRESULT CXuiSceneBase::_ShowTooltip( unsigned int iPad, unsigned int tooltip, bo { ucAlpha=15; } - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } m_Buttons[iPad][tooltip].SetOpacity(fVal); @@ -678,8 +678,8 @@ HRESULT CXuiSceneBase::_ShowTooltip( unsigned int iPad, unsigned int tooltip, bo { if(uiOpacityTimer<10) { - float fStep=(80.0f-(float)ucAlpha)/10.0f; - fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + float fStep=(80.0f-static_cast(ucAlpha))/10.0f; + fVal=0.01f*(80.0f-((10.0f-static_cast(uiOpacityTimer))*fStep)); } else { @@ -688,12 +688,12 @@ HRESULT CXuiSceneBase::_ShowTooltip( unsigned int iPad, unsigned int tooltip, bo } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } XuiElementSetOpacity(m_hGamerTagA[iPad],fVal); } @@ -701,7 +701,7 @@ HRESULT CXuiSceneBase::_ShowTooltip( unsigned int iPad, unsigned int tooltip, bo if(iPad==ProfileManager.GetPrimaryPad()) { unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity); - XuiElementSetOpacity(m_hEmptyQuadrantLogo,0.01f*(float)ucAlpha); + XuiElementSetOpacity(m_hEmptyQuadrantLogo,0.01f*static_cast(ucAlpha)); } } } @@ -976,7 +976,7 @@ HRESULT CXuiSceneBase::_UpdateTrialTimer(unsigned int iPad) { WCHAR wcTime[20]; - DWORD dwTimeTicks=(DWORD)app.getTrialTimer(); + DWORD dwTimeTicks=static_cast(app.getTrialTimer()); if(dwTimeTicks>m_dwTrialTimerLimitSecs) { @@ -1014,7 +1014,7 @@ HRESULT CXuiSceneBase::_UpdateTrialTimer(unsigned int iPad) void CXuiSceneBase::_ReduceTrialTimerValue() { - DWORD dwTimeTicks=(int)app.getTrialTimer(); + DWORD dwTimeTicks=static_cast(app.getTrialTimer()); if(dwTimeTicks>m_dwTrialTimerLimitSecs) { @@ -1512,7 +1512,7 @@ void CXuiSceneBase::_SetEmptyQuadrantLogo(int iPad,EBaseScenePosition ePos) if(ProfileManager.GetLockedProfile()!=-1) { unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity); - XuiElementSetOpacity(m_hEmptyQuadrantLogo,0.01f*(float)ucAlpha); + XuiElementSetOpacity(m_hEmptyQuadrantLogo,0.01f*static_cast(ucAlpha)); } XuiElementSetPosition(m_hEmptyQuadrantLogo, &pos ); @@ -1638,8 +1638,8 @@ HRESULT CXuiSceneBase::_DisplayGamertag( unsigned int iPad, BOOL bDisplay ) { if(uiOpacityTimer<10) { - float fStep=(80.0f-(float)ucAlpha)/10.0f; - fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + float fStep=(80.0f-static_cast(ucAlpha))/10.0f; + fVal=0.01f*(80.0f-((10.0f-static_cast(uiOpacityTimer))*fStep)); } else { @@ -1648,12 +1648,12 @@ HRESULT CXuiSceneBase::_DisplayGamertag( unsigned int iPad, BOOL bDisplay ) } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } } else { - fVal=0.01f*(float)ucAlpha; + fVal=0.01f*static_cast(ucAlpha); } XuiElementSetOpacity(m_hGamerTagA[iPad],0.01f*fVal); } diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_BrewingStand.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_BrewingStand.cpp index cf6009661..51a019cfd 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_BrewingStand.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_BrewingStand.cpp @@ -24,7 +24,7 @@ HRESULT CXuiSceneBrewingStand::OnInit( XUIMessageInit* pInitData, BOOL& bHandled Minecraft *pMinecraft = Minecraft::GetInstance(); - BrewingScreenInput* initData = (BrewingScreenInput*)pInitData->pvInitData; + BrewingScreenInput* initData = static_cast(pInitData->pvInitData); m_iPad=initData->iPad; m_bSplitscreen=initData->bSplitscreen; diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Container.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Container.cpp index 39b836d2c..70eb7c3cf 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Container.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Container.cpp @@ -29,7 +29,7 @@ HRESULT CXuiSceneContainer::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); - ContainerScreenInput* initData = (ContainerScreenInput*)pInitData->pvInitData; + ContainerScreenInput* initData = static_cast(pInitData->pvInitData); XuiControlSetText(m_ChestText,app.GetString(initData->container->getName())); @@ -75,9 +75,9 @@ HRESULT CXuiSceneContainer::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) // to get it into actual back buffer coordinates, and we need those to remain whole numbers to avoid issues with point sampling if(!RenderManager.IsHiDef()) { - int iY = (int)(vPos.y); + int iY = static_cast(vPos.y); iY &= 0xfffffffe; - vPos.y = (float)iY; + vPos.y = static_cast(iY); } this->SetPosition( &vPos ); diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_CraftingPanel.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_CraftingPanel.cpp index a5dc65849..cea213939 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_CraftingPanel.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_CraftingPanel.cpp @@ -40,7 +40,7 @@ HRESULT CXuiSceneCraftingPanel::OnInit( XUIMessageInit* pInitData, BOOL& bHandle D3DXVECTOR3 vec; VOID *pObj; - CraftingPanelScreenInput* pCraftingPanelData = (CraftingPanelScreenInput*)pInitData->pvInitData; + CraftingPanelScreenInput* pCraftingPanelData = static_cast(pInitData->pvInitData); m_iContainerType=pCraftingPanelData->iContainerType; m_pPlayer=pCraftingPanelData->player; m_iPad=pCraftingPanelData->iPad; @@ -89,12 +89,12 @@ HRESULT CXuiSceneCraftingPanel::OnInit( XUIMessageInit* pInitData, BOOL& bHandle for(int i=0;i(pObj); } XuiObjectFromHandle( m_hCraftOutput, &pObj ); - m_pCraftingOutput = (CXuiCtrlCraftIngredientSlot *)pObj; - m_pGroupA=(Recipy::_eGroupType *)&m_GroupTypeMapping9GridA; - m_pGroupTabA=(CXuiSceneCraftingPanel::_eGroupTab *)&m_GroupTabBkgMapping3x3A; + m_pCraftingOutput = static_cast(pObj); + m_pGroupA=static_cast(&m_GroupTypeMapping9GridA); + m_pGroupTabA=static_cast(&m_GroupTabBkgMapping3x3A); m_iCraftablesMaxHSlotC=m_iMaxHSlot3x3C; @@ -102,7 +102,7 @@ HRESULT CXuiSceneCraftingPanel::OnInit( XUIMessageInit* pInitData, BOOL& bHandle for(int i=0;i<4;i++) { XuiObjectFromHandle( m_hCraftIngredientDescA[i], &pObj ); - m_pCraftIngredientDescA[i] = (CXuiCtrlCraftIngredientSlot *)pObj; + m_pCraftIngredientDescA[i] = static_cast(pObj); } } else @@ -113,13 +113,13 @@ HRESULT CXuiSceneCraftingPanel::OnInit( XUIMessageInit* pInitData, BOOL& bHandle for(int i=0;i(pObj); } XuiObjectFromHandle( m_hCraftOutput, &pObj ); - m_pCraftingOutput = (CXuiCtrlCraftIngredientSlot *)pObj; - m_pGroupA=(Recipy::_eGroupType *)&m_GroupTypeMapping4GridA; - m_pGroupTabA=(CXuiSceneCraftingPanel::_eGroupTab *)&m_GroupTabBkgMapping2x2A; + m_pCraftingOutput = static_cast(pObj); + m_pGroupA=static_cast(&m_GroupTypeMapping4GridA); + m_pGroupTabA=static_cast(&m_GroupTabBkgMapping2x2A); m_iCraftablesMaxHSlotC=m_iMaxHSlot2x2C; @@ -127,7 +127,7 @@ HRESULT CXuiSceneCraftingPanel::OnInit( XUIMessageInit* pInitData, BOOL& bHandle for(int i=0;i<4;i++) { XuiObjectFromHandle( m_hCraftIngredientDescA[i], &pObj ); - m_pCraftIngredientDescA[i] = (CXuiCtrlCraftIngredientSlot *)pObj; + m_pCraftIngredientDescA[i] = static_cast(pObj); } } diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Enchant.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Enchant.cpp index 5b3c72261..6e5159b20 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Enchant.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Enchant.cpp @@ -30,7 +30,7 @@ HRESULT CXuiSceneEnchant::OnInit( XUIMessageInit *pInitData, BOOL &bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); - EnchantingScreenInput *initData = (EnchantingScreenInput *) pInitData->pvInitData; + EnchantingScreenInput *initData = static_cast(pInitData->pvInitData); m_iPad=initData->iPad; m_bSplitscreen=initData->bSplitscreen; diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Furnace.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Furnace.cpp index 832d6b4ce..54f3591b9 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Furnace.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Furnace.cpp @@ -26,7 +26,7 @@ HRESULT CXuiSceneFurnace::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); - FurnaceScreenInput* initData = (FurnaceScreenInput*)pInitData->pvInitData; + FurnaceScreenInput* initData = static_cast(pInitData->pvInitData); m_iPad=initData->iPad; m_bSplitscreen=initData->bSplitscreen; diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory.cpp index 6024b8d6e..a5532fefc 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory.cpp @@ -23,7 +23,7 @@ HRESULT CXuiSceneInventory::OnInit( XUIMessageInit *pInitData, BOOL &bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); - InventoryScreenInput *initData = (InventoryScreenInput *)pInitData->pvInitData; + InventoryScreenInput *initData = static_cast(pInitData->pvInitData); m_iPad=initData->iPad; m_bSplitscreen=initData->bSplitscreen; @@ -81,7 +81,7 @@ HRESULT CXuiSceneInventory::OnDestroy() if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } @@ -161,7 +161,7 @@ void CXuiSceneInventory::updateEffectsDisplay() vector *activeEffects = player->getActiveEffects(); // Work out how to arrange the effects - int effectCount = (int)activeEffects->size(); + int effectCount = static_cast(activeEffects->size()); // Total size of all effects + spacing, minus spacing for the last effect float fHeight = (effectCount * m_effectDisplaySpacing) - (m_effectDisplaySpacing - m_effectDisplayHeight); diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp index 0793fc9e0..415d7b51e 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp @@ -33,7 +33,7 @@ HRESULT CXuiSceneInventoryCreative::OnInit( XUIMessageInit *pInitData, BOOL &bHa Minecraft *pMinecraft = Minecraft::GetInstance(); - InventoryScreenInput *initData = (InventoryScreenInput *)pInitData->pvInitData; + InventoryScreenInput *initData = static_cast(pInitData->pvInitData); m_iPad=initData->iPad; m_bSplitscreen=initData->bSplitscreen; @@ -139,10 +139,10 @@ CXuiControl* CXuiSceneInventoryCreative::GetSectionControl( ESceneSection eSecti switch( eSection ) { case eSectionInventoryCreativeUsing: - return (CXuiControl *)m_useRowControl; + return static_cast(m_useRowControl); break; case eSectionInventoryCreativeSelector: - return (CXuiControl *)m_containerControl; + return static_cast(m_containerControl); break; default: assert( false ); diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Trading.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Trading.cpp index 8738e683e..b6f3df50e 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Trading.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Trading.cpp @@ -27,7 +27,7 @@ HRESULT CXuiSceneTrading::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); - TradingScreenInput* initData = (TradingScreenInput *)pInitData->pvInitData; + TradingScreenInput* initData = static_cast(pInitData->pvInitData); m_iPad=initData->iPad; m_bSplitscreen=initData->bSplitscreen; m_merchant = initData->trader; @@ -41,7 +41,7 @@ HRESULT CXuiSceneTrading::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Trading_Menu, this); } @@ -81,7 +81,7 @@ HRESULT CXuiSceneTrading::OnDestroy() if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Trap.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Trap.cpp index 99dc6e4c4..4453185ea 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Trap.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Trap.cpp @@ -22,7 +22,7 @@ HRESULT CXuiSceneTrap::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); - TrapScreenInput* initData = (TrapScreenInput*)pInitData->pvInitData; + TrapScreenInput* initData = static_cast(pInitData->pvInitData); m_iPad=initData->iPad; m_bSplitscreen=initData->bSplitscreen; diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp index 19e6b0161..9c491be67 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp @@ -21,7 +21,7 @@ const float CScene_Win::PLAYER_SCROLL_SPEED = 3.0f; //---------------------------------------------------------------------------------- HRESULT CScene_Win::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); m_bIgnoreInput = false; @@ -57,13 +57,13 @@ HRESULT CScene_Win::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) noNoiseString = app.FormatHTMLString(m_iPad, noNoiseString, 0xff000000); Random random(8124371); - int found=(int)noNoiseString.find_first_of(L"{"); + int found=static_cast(noNoiseString.find_first_of(L"{")); int length; while (found!=string::npos) { length = random.nextInt(4) + 3; m_noiseLengths.push_back(length); - found=(int)noNoiseString.find_first_of(L"{",found+1); + found=static_cast(noNoiseString.find_first_of(L"{", found + 1)); } Minecraft *pMinecraft = Minecraft::GetInstance(); diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsAll.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsAll.cpp index c6dc7118f..26219376e 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsAll.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsAll.cpp @@ -10,7 +10,7 @@ HRESULT CScene_SettingsAll::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { //WCHAR TempString[256]; - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsAudio.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsAudio.cpp index 0f0fe2e30..f654a3764 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsAudio.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsAudio.cpp @@ -7,7 +7,7 @@ HRESULT CScene_SettingsAudio::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { WCHAR TempString[256]; - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); @@ -86,13 +86,13 @@ HRESULT CScene_SettingsAudio::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotif if(hObjSource==m_SliderA[SLIDER_SETTINGS_MUSIC].GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_MusicVolume,pNotifyValueChanged->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_MUSIC ),pNotifyValueChanged->nValue); + swprintf( static_cast(TempString), 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_MUSIC ),pNotifyValueChanged->nValue); m_SliderA[SLIDER_SETTINGS_MUSIC].SetText(TempString); } else if(hObjSource==m_SliderA[SLIDER_SETTINGS_SOUND].GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_SoundFXVolume,pNotifyValueChanged->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SOUND ),pNotifyValueChanged->nValue); + swprintf( static_cast(TempString), 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SOUND ),pNotifyValueChanged->nValue); m_SliderA[SLIDER_SETTINGS_SOUND].SetText(TempString); } diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsControl.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsControl.cpp index 7e2835a27..7bedc2fa2 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsControl.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsControl.cpp @@ -10,7 +10,7 @@ HRESULT CScene_SettingsControl::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { WCHAR TempString[256]; - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); @@ -66,13 +66,13 @@ HRESULT CScene_SettingsControl::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINot if(hObjSource==m_SliderA[SLIDER_SETTINGS_SENSITIVITY_INGAME].GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_Sensitivity_InGame,pNotifyValueChanged->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INGAME ),pNotifyValueChanged->nValue); + swprintf( static_cast(TempString), 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INGAME ),pNotifyValueChanged->nValue); m_SliderA[SLIDER_SETTINGS_SENSITIVITY_INGAME].SetText(TempString); } else if(hObjSource==m_SliderA[SLIDER_SETTINGS_SENSITIVITY_INMENU].GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_Sensitivity_InMenu,pNotifyValueChanged->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INMENU ),pNotifyValueChanged->nValue); + swprintf( static_cast(TempString), 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INMENU ),pNotifyValueChanged->nValue); m_SliderA[SLIDER_SETTINGS_SENSITIVITY_INMENU].SetText(TempString); } diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsGraphics.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsGraphics.cpp index 48a933e27..3ce414c57 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsGraphics.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsGraphics.cpp @@ -10,7 +10,7 @@ HRESULT CScene_SettingsGraphics::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { WCHAR TempString[256]; - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); bool bIsPrimaryPad=(ProfileManager.GetPrimaryPad()==m_iPad); @@ -139,13 +139,13 @@ HRESULT CScene_SettingsGraphics::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINo if(hObjSource==m_SliderA[SLIDER_SETTINGS_GAMMA].GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_Gamma,pNotifyValueChanged->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),pNotifyValueChanged->nValue); + swprintf( static_cast(TempString), 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),pNotifyValueChanged->nValue); m_SliderA[SLIDER_SETTINGS_GAMMA].SetText(TempString); } else if(hObjSource==m_SliderA[SLIDER_SETTINGS_INTERFACE_OPACITY].GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_InterfaceOpacity,pNotifyValueChanged->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),pNotifyValueChanged->nValue); + swprintf( static_cast(TempString), 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),pNotifyValueChanged->nValue); m_SliderA[SLIDER_SETTINGS_INTERFACE_OPACITY].SetText(TempString); } diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsOptions.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsOptions.cpp index 526847c7c..f8fb5ae98 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsOptions.cpp @@ -26,7 +26,7 @@ int CScene_SettingsOptions::m_iDifficultyTitleSettingA[4]= HRESULT CScene_SettingsOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { WCHAR TempString[256]; - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; @@ -274,14 +274,14 @@ HRESULT CScene_SettingsOptions::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINot else { app.SetAutosaveTimerTime(); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d %ls", app.GetString( IDS_SLIDER_AUTOSAVE ),pNotifyValueChanged->nValue*15, app.GetString( IDS_MINUTES )); + swprintf( static_cast(TempString), 256, L"%ls: %d %ls", app.GetString( IDS_SLIDER_AUTOSAVE ),pNotifyValueChanged->nValue*15, app.GetString( IDS_MINUTES )); } m_SliderA[SLIDER_SETTINGS_AUTOSAVE].SetText(TempString); } else if(hObjSource==m_SliderA[SLIDER_SETTINGS_DIFFICULTY].GetSlider() ) { app.SetGameSettings(m_iPad,eGameSetting_Difficulty,pNotifyValueChanged->nValue); - swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[pNotifyValueChanged->nValue])); + swprintf( static_cast(TempString), 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[pNotifyValueChanged->nValue])); m_SliderA[SLIDER_SETTINGS_DIFFICULTY].SetText(TempString); wstring wsText=app.GetString(m_iDifficultySettingA[pNotifyValueChanged->nValue]); diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsUI.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsUI.cpp index da95d084d..1dc837757 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsUI.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsUI.cpp @@ -10,7 +10,7 @@ HRESULT CScene_SettingsUI::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { WCHAR TempString[256]; - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; @@ -115,7 +115,7 @@ HRESULT CScene_SettingsUI::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyVa // slider is 1 to 3 // is this different from the current value? - swprintf( (WCHAR *)TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZE ),pNotifyValueChanged->nValue); + swprintf( static_cast(TempString), 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZE ),pNotifyValueChanged->nValue); m_SliderA[SLIDER_SETTINGS_UISIZE].SetText(TempString); if(pNotifyValueChanged->nValue != app.GetGameSettings(m_iPad,eGameSetting_UISize)+1) { @@ -126,7 +126,7 @@ HRESULT CScene_SettingsUI::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyVa } else if(hObjSource==m_SliderA[SLIDER_SETTINGS_UISIZESPLITSCREEN].GetSlider() ) { - swprintf( (WCHAR *)TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZESPLITSCREEN ),pNotifyValueChanged->nValue); + swprintf( static_cast(TempString), 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZESPLITSCREEN ),pNotifyValueChanged->nValue); m_SliderA[SLIDER_SETTINGS_UISIZESPLITSCREEN].SetText(TempString); if(pNotifyValueChanged->nValue != app.GetGameSettings(m_iPad,eGameSetting_UISizeSplitscreen)+1) diff --git a/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp b/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp index 378ac147b..32336cb72 100644 --- a/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp @@ -15,7 +15,7 @@ HRESULT CScene_SignEntry::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) XuiControlSetText(m_ButtonDone,app.GetString(IDS_DONE)); XuiControlSetText(m_labelEditSign,app.GetString(IDS_EDIT_SIGN_MESSAGE)); - SignEntryScreenInput* initData = (SignEntryScreenInput*)pInitData->pvInitData; + SignEntryScreenInput* initData = static_cast(pInitData->pvInitData); m_sign = initData->sign; CXuiSceneBase::ShowDarkOverlay( initData->iPad, TRUE ); diff --git a/Minecraft.Client/Common/XUI/XUI_SkinSelect.cpp b/Minecraft.Client/Common/XUI/XUI_SkinSelect.cpp index ee7066108..b2f2f0a39 100644 --- a/Minecraft.Client/Common/XUI/XUI_SkinSelect.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SkinSelect.cpp @@ -26,7 +26,7 @@ WCHAR *CScene_SkinSelect::wchDefaultNamesA[]= //---------------------------------------------------------------------------------- HRESULT CScene_SkinSelect::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); m_bIgnoreInput=false; @@ -1021,7 +1021,7 @@ void CScene_SkinSelect::handlePackIndexChanged() DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(m_originalSkinId); if( ugcSkinIndex == 0 ) { - m_skinIndex = (EDefaultSkins) defaultSkinIndex; + m_skinIndex = static_cast(defaultSkinIndex); } } break; @@ -1311,7 +1311,7 @@ void CScene_SkinSelect::updateClipping() int CScene_SkinSelect::UnlockSkinReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CScene_SkinSelect* pScene = (CScene_SkinSelect*)pParam; + CScene_SkinSelect* pScene = static_cast(pParam); #ifdef _XBOX if(result==C4JStorage::EMessage_ResultAccept) { diff --git a/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp b/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp index f237e7d87..26dd220b7 100644 --- a/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp @@ -21,7 +21,7 @@ //---------------------------------------------------------------------------------- HRESULT CScene_SocialPost::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad = *(int *)pInitData->pvInitData; + m_iPad = *static_cast(pInitData->pvInitData); MapChildControls(); @@ -48,8 +48,8 @@ HRESULT CScene_SocialPost::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) wstring wDesc = m_EditDesc.GetText(); // set the caret to the end of the default text - m_EditCaption.SetCaretPosition((int)wCaption.length()); - m_EditDesc.SetCaretPosition((int)wDesc.length()); + m_EditCaption.SetCaretPosition(static_cast(wCaption.length())); + m_EditDesc.SetCaretPosition(static_cast(wDesc.length())); BOOL bHasAllText = /*( wTitle.length()!=0) && */(wCaption.length()!=0) && (wDesc.length()!=0); diff --git a/Minecraft.Client/Common/XUI/XUI_Teleport.cpp b/Minecraft.Client/Common/XUI/XUI_Teleport.cpp index 1d6ac3bf6..5b13a376e 100644 --- a/Minecraft.Client/Common/XUI/XUI_Teleport.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Teleport.cpp @@ -21,7 +21,7 @@ //---------------------------------------------------------------------------------- HRESULT CScene_Teleport::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - TeleportMenuInitData *initParam = (TeleportMenuInitData *)pInitData->pvInitData; + TeleportMenuInitData *initParam = static_cast(pInitData->pvInitData); m_iPad = initParam->iPad; m_teleportToPlayer = initParam->teleportToPlayer; @@ -125,7 +125,7 @@ HRESULT CScene_Teleport::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pN void CScene_Teleport::OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving) { - CScene_Teleport *scene = (CScene_Teleport *)callbackParam; + CScene_Teleport *scene = static_cast(callbackParam); bool playerFound = false; for(int i = 0; i < scene->m_playersCount; ++i) diff --git a/Minecraft.Client/Common/XUI/XUI_TextEntry.cpp b/Minecraft.Client/Common/XUI/XUI_TextEntry.cpp index 0369928b4..5eff65e8e 100644 --- a/Minecraft.Client/Common/XUI/XUI_TextEntry.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TextEntry.cpp @@ -24,7 +24,7 @@ HRESULT CScene_TextEntry::Init_Commands() HRESULT CScene_TextEntry::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { MapChildControls(); - XuiTextInputParams *params = (XuiTextInputParams *)pInitData->pvInitData; + XuiTextInputParams *params = static_cast(pInitData->pvInitData); m_iPad=params->iPad; m_wchInitialChar=params->wch; delete params; diff --git a/Minecraft.Client/Common/XUI/XUI_TransferToXboxOne.cpp b/Minecraft.Client/Common/XUI/XUI_TransferToXboxOne.cpp index 5a2e67b42..07304e604 100644 --- a/Minecraft.Client/Common/XUI/XUI_TransferToXboxOne.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TransferToXboxOne.cpp @@ -16,7 +16,7 @@ HRESULT CScene_TransferToXboxOne::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { m_iX=-1; - m_params = (LoadMenuInitData *)pInitData->pvInitData; + m_params = static_cast(pInitData->pvInitData); m_iPad=m_params->iPad; @@ -26,7 +26,7 @@ HRESULT CScene_TransferToXboxOne::OnInit( XUIMessageInit* pInitData, BOOL& bHand VOID *pObj; XuiObjectFromHandle( m_SavesSlotList, &pObj ); - m_pSavesSlotList = (CXuiCtrl4JList *)pObj; + m_pSavesSlotList = static_cast(pObj); m_pbImageData=NULL; m_dwImageBytes=0; @@ -86,7 +86,7 @@ HRESULT CScene_TransferToXboxOne::OnInit( XUIMessageInit* pInitData, BOOL& bHand //---------------------------------------------------------------------------------- int CScene_TransferToXboxOne::TMSPPWriteReturned(LPVOID pParam,int iPad,int iUserData) { - CScene_TransferToXboxOne* pClass = (CScene_TransferToXboxOne *) pParam; + CScene_TransferToXboxOne* pClass = static_cast(pParam); pClass->m_bWaitingForWrite=false; return 0; @@ -97,7 +97,7 @@ int CScene_TransferToXboxOne::TMSPPWriteReturned(LPVOID pParam,int iPad,int iUse //---------------------------------------------------------------------------------- int CScene_TransferToXboxOne::TMSPPDeleteReturned(LPVOID pParam,int iPad,int iUserData) { - CScene_TransferToXboxOne* pClass = (CScene_TransferToXboxOne *) pParam; + CScene_TransferToXboxOne* pClass = static_cast(pParam); pClass->m_SavesSlotListTimer.SetShow(FALSE); pClass->m_bIgnoreInput=false; @@ -129,7 +129,7 @@ int CScene_TransferToXboxOne::TMSPPDeleteReturned(LPVOID pParam,int iPad,int iUs //---------------------------------------------------------------------------------- int CScene_TransferToXboxOne::TMSPPSlotListReturned(LPVOID pParam,int iPad,int iUserData,C4JStorage::PTMSPP_FILEDATA pFileData, LPCSTR szFilename) { - CScene_TransferToXboxOne* pClass = (CScene_TransferToXboxOne *) pParam; + CScene_TransferToXboxOne* pClass = static_cast(pParam); unsigned int uiSlotListFileSlots=*((unsigned int *)pFileData->pbData); pClass->m_pbSlotListFile=pFileData->pbData; pClass->m_uiSlotListFileBytes=pFileData->dwSize; @@ -323,7 +323,7 @@ HRESULT CScene_TransferToXboxOne::BuildSlotFile(int iIndexBeingUpdated,PBYTE pbI LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CScene_TransferToXboxOne::UploadSaveForXboxOneThreadProc; - loadingParams->lpParam = (LPVOID)this; + loadingParams->lpParam = static_cast(this); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -342,7 +342,7 @@ int CScene_TransferToXboxOne::UploadSaveForXboxOneThreadProc( LPVOID lpParameter { HRESULT hr = S_OK; char szFilename[32]; - CScene_TransferToXboxOne* pClass = (CScene_TransferToXboxOne *) lpParameter; + CScene_TransferToXboxOne* pClass = static_cast(lpParameter); Minecraft *pMinecraft = Minecraft::GetInstance(); unsigned int uiComplete=0; pClass->m_bWaitingForWrite=true; @@ -415,7 +415,7 @@ int CScene_TransferToXboxOne::UploadSaveForXboxOneThreadProc( LPVOID lpParameter for(int i=0;i<(pClass->m_uiStorageLength/uiChunkSize)+1;i++) { sprintf( szFilename, "XboxOne/Slot%.2d%.2d", pClass->m_uiSlotID,i ); - PCHAR pchData=((PCHAR)pClass->m_pvSaveMem)+i*uiChunkSize; + PCHAR pchData=static_cast(pClass->m_pvSaveMem)+i*uiChunkSize; pClass->m_bWaitingForWrite=true; if(uiBytesLeft>=uiChunkSize) @@ -461,7 +461,7 @@ int CScene_TransferToXboxOne::UploadSaveForXboxOneThreadProc( LPVOID lpParameter int CScene_TransferToXboxOne::LoadSaveDataReturned(void *pParam,bool bContinue) { - CScene_TransferToXboxOne* pClass = (CScene_TransferToXboxOne*)pParam; + CScene_TransferToXboxOne* pClass = static_cast(pParam); if(bContinue==true) { diff --git a/Minecraft.Client/Common/XUI/XUI_TrialExitUpsell.cpp b/Minecraft.Client/Common/XUI/XUI_TrialExitUpsell.cpp index 511210999..d99df9985 100644 --- a/Minecraft.Client/Common/XUI/XUI_TrialExitUpsell.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TrialExitUpsell.cpp @@ -19,7 +19,7 @@ WCHAR *CScene_TrialExitUpsell::wchImages[]= //---------------------------------------------------------------------------------- HRESULT CScene_TrialExitUpsell::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); MapChildControls(); diff --git a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp index 98951d81a..9fe644e06 100644 --- a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp @@ -14,7 +14,7 @@ HRESULT CScene_TutorialPopup::OnInit( XUIMessageInit* pInitData, BOOL& bHandled { HRESULT hr = S_OK; - tutorial = (Tutorial *)pInitData->pvInitData; + tutorial = static_cast(pInitData->pvInitData); m_iPad = tutorial->getPad(); MapChildControls(); @@ -241,7 +241,7 @@ HRESULT CScene_TutorialPopup::_SetDescription(CXuiScene *interactScene, LPCWSTR SetBounds(fWidth, fHeight + heightDiff); m_description.GetBounds(&fWidth,&fHeight); - m_description.SetBounds(fWidth, (float)(contentDims.nPageHeight + heightDiff)); + m_description.SetBounds(fWidth, static_cast(contentDims.nPageHeight + heightDiff)); } return hr; } @@ -298,13 +298,13 @@ wstring CScene_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWS { wstring openTag(L"{*ICON*}"); wstring closeTag(L"{*/ICON*}"); - int iconTagStartPos = (int)temp.find(openTag); - int iconStartPos = iconTagStartPos + (int)openTag.length(); - if( iconTagStartPos > 0 && iconStartPos < (int)temp.length() ) + int iconTagStartPos = static_cast(temp.find(openTag)); + int iconStartPos = iconTagStartPos + static_cast(openTag.length()); + if( iconTagStartPos > 0 && iconStartPos < static_cast(temp.length()) ) { - int iconEndPos = (int)temp.find( closeTag, iconStartPos ); + int iconEndPos = static_cast(temp.find(closeTag, iconStartPos)); - if(iconEndPos > iconStartPos && iconEndPos < (int)temp.length() ) + if(iconEndPos > iconStartPos && iconEndPos < static_cast(temp.length()) ) { wstring id = temp.substr(iconStartPos, iconEndPos - iconStartPos); @@ -443,13 +443,13 @@ wstring CScene_TutorialPopup::_SetImage(wstring &desc) wstring openTag(L"{*IMAGE*}"); wstring closeTag(L"{*/IMAGE*}"); - int imageTagStartPos = (int)desc.find(openTag); - int imageStartPos = imageTagStartPos + (int)openTag.length(); - if( imageTagStartPos > 0 && imageStartPos < (int)desc.length() ) + int imageTagStartPos = static_cast(desc.find(openTag)); + int imageStartPos = imageTagStartPos + static_cast(openTag.length()); + if( imageTagStartPos > 0 && imageStartPos < static_cast(desc.length()) ) { - int imageEndPos = (int)desc.find( closeTag, imageStartPos ); + int imageEndPos = static_cast(desc.find(closeTag, imageStartPos)); - if(imageEndPos > imageStartPos && imageEndPos < (int)desc.length() ) + if(imageEndPos > imageStartPos && imageEndPos < static_cast(desc.length()) ) { wstring id = desc.substr(imageStartPos, imageEndPos - imageStartPos); m_image.SetImagePath( id.c_str() ); @@ -564,7 +564,7 @@ HRESULT CScene_TutorialPopup::SetSceneVisible(int iPad, bool show) if( XuiClassDerivesFrom( objClass, thisClass ) ) { CScene_TutorialPopup *pThis; - hr = XuiObjectFromHandle(hObj, (void **) &pThis); + hr = XuiObjectFromHandle(hObj, static_cast(&pThis)); if (FAILED(hr)) return hr; @@ -593,7 +593,7 @@ bool CScene_TutorialPopup::IsSceneVisible(int iPad) if( XuiClassDerivesFrom( objClass, thisClass ) ) { CScene_TutorialPopup *pThis; - hr = XuiObjectFromHandle(hObj, (void **) &pThis); + hr = XuiObjectFromHandle(hObj, static_cast(&pThis)); if (FAILED(hr)) return false; diff --git a/Minecraft.Client/Common/XUI/XUI_debug.cpp b/Minecraft.Client/Common/XUI/XUI_debug.cpp index 61b818a07..9aee38882 100644 --- a/Minecraft.Client/Common/XUI/XUI_debug.cpp +++ b/Minecraft.Client/Common/XUI/XUI_debug.cpp @@ -50,7 +50,7 @@ LPCWSTR CScene_Debug::m_DebugButtonTextA[eDebugButton_Max+1]= //---------------------------------------------------------------------------------- HRESULT CScene_Debug::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_iPad=*(int *)pInitData->pvInitData; + m_iPad=*static_cast(pInitData->pvInitData); // set text and enable any debug options required int iCheckboxIndex=0; @@ -89,7 +89,7 @@ HRESULT CScene_Debug::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) XuiCreateObject( XUI_CLASS_CHECKBOX, &m_DebugCheckboxDataA[iCheckboxIndex].hXuiObj ); XuiObjectFromHandle( m_DebugCheckboxDataA[iCheckboxIndex].hXuiObj, &m_DebugCheckboxDataA[iCheckboxIndex].pvData ); - pCheckbox = (CXuiCheckbox *)m_DebugCheckboxDataA[iCheckboxIndex].pvData; + pCheckbox = static_cast(m_DebugCheckboxDataA[iCheckboxIndex].pvData); //m_phXuiObjA[iElementIndex] = pCheckbox->m_hObj; pCheckbox->SetText(m_DebugCheckboxTextA[iCheckboxIndex]); pCheckbox->SetShow(TRUE); @@ -139,7 +139,7 @@ HRESULT CScene_Debug::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) XuiCreateObject( XUI_CLASS_BUTTON, &m_DebugButtonDataA[iButtonIndex].hXuiObj ); XuiObjectFromHandle( m_DebugButtonDataA[iButtonIndex].hXuiObj, &m_DebugButtonDataA[iButtonIndex].pvData ); - pButton = (CXuiControl *)m_DebugButtonDataA[iButtonIndex].pvData; + pButton = static_cast(m_DebugButtonDataA[iButtonIndex].pvData); //m_phXuiObjA[iElementIndex] = pCheckbox->m_hObj; pButton->SetText(m_DebugButtonTextA[iButtonIndex]); pButton->SetShow(TRUE); @@ -171,7 +171,7 @@ HRESULT CScene_Debug::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) for(int i=0;i(m_DebugCheckboxDataA[i].pvData); pCheckbox->SetCheck( (uiDebugBitmask&(1<(m_DebugCheckboxDataA[i].pvData); uiDebugBitmask|=pCheckbox->IsChecked()?(1<x - x; double za = spawnPos->z - z; delete spawnPos; - yRot = (int)yRot % 360; + yRot = static_cast(yRot) % 360; rott = -((yRot - 90) * PI / 180 - atan2(za, xa)); if (!level->dimension->isNaturalDimension()) { @@ -80,7 +80,7 @@ void CompassTexture::updateFromPosition(Level *level, double x, double z, double // 4J Stu - We share data with another texture if(m_dataTexture != NULL) { - int newFrame = (int) (((rot / (PI * 2)) + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); + int newFrame = static_cast(((rot / (PI * 2)) + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); while (newFrame < 0) { newFrame = (newFrame + m_dataTexture->frames->size()) % m_dataTexture->frames->size(); @@ -93,7 +93,7 @@ void CompassTexture::updateFromPosition(Level *level, double x, double z, double } else { - int newFrame = (int) (((rot / (PI * 2)) + 1.0) * frames->size()) % frames->size(); + int newFrame = static_cast(((rot / (PI * 2)) + 1.0) * frames->size()) % frames->size(); while (newFrame < 0) { newFrame = (newFrame + frames->size()) % frames->size(); diff --git a/Minecraft.Client/CreeperRenderer.cpp b/Minecraft.Client/CreeperRenderer.cpp index a9d16314f..bcec52150 100644 --- a/Minecraft.Client/CreeperRenderer.cpp +++ b/Minecraft.Client/CreeperRenderer.cpp @@ -34,9 +34,9 @@ int CreeperRenderer::getOverlayColor(shared_ptr mob, float br, flo float step = creeper->getSwelling(a); - if ((int) (step * 10) % 2 == 0) return 0; + if (static_cast(step * 10) % 2 == 0) return 0; - int _a = (int) (step * 0.2f * 255) + 25; // 4J - added 25 here as our entities are rendered with alpha test still enabled, and so anything less is invisible + int _a = static_cast(step * 0.2f * 255) + 25; // 4J - added 25 here as our entities are rendered with alpha test still enabled, and so anything less is invisible if (_a < 0) _a = 0; if (_a > 255) _a = 255; diff --git a/Minecraft.Client/CritParticle2.cpp b/Minecraft.Client/CritParticle2.cpp index 363e8f08d..fe64b91e4 100644 --- a/Minecraft.Client/CritParticle2.cpp +++ b/Minecraft.Client/CritParticle2.cpp @@ -11,12 +11,12 @@ void CritParticle2::_init(double xa, double ya, double za, float scale) yd += ya * 0.4; zd += za * 0.4; - rCol = gCol = bCol = (float) (Math::random() * 0.3f + 0.6f); + rCol = gCol = bCol = static_cast(Math::random() * 0.3f + 0.6f); size *= 0.75f; size *= scale; oSize = size; - lifetime = (int) (6 / (Math::random() * 0.8 + 0.6)); + lifetime = static_cast(6 / (Math::random() * 0.8 + 0.6)); lifetime *= scale; noPhysics = false; diff --git a/Minecraft.Client/DLCTexturePack.cpp b/Minecraft.Client/DLCTexturePack.cpp index 553128d96..752b1cc27 100644 --- a/Minecraft.Client/DLCTexturePack.cpp +++ b/Minecraft.Client/DLCTexturePack.cpp @@ -36,7 +36,7 @@ DLCTexturePack::DLCTexturePack(DWORD id, DLCPack *pack, TexturePack *fallback) : if(m_dlcInfoPack->doesPackContainFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc")) { - DLCLocalisationFile *localisationFile = (DLCLocalisationFile *)m_dlcInfoPack->getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc"); + DLCLocalisationFile *localisationFile = static_cast(m_dlcInfoPack->getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc")); m_stringTable = localisationFile->getStringTable(); } @@ -51,7 +51,7 @@ void DLCTexturePack::loadIcon() { if(m_dlcInfoPack->doesPackContainFile(DLCManager::e_DLCType_Texture, L"icon.png")) { - DLCTextureFile *textureFile = (DLCTextureFile *)m_dlcInfoPack->getFile(DLCManager::e_DLCType_Texture, L"icon.png"); + DLCTextureFile *textureFile = static_cast(m_dlcInfoPack->getFile(DLCManager::e_DLCType_Texture, L"icon.png")); m_iconData = textureFile->getData(m_iconSize); } else @@ -64,7 +64,7 @@ void DLCTexturePack::loadComparison() { if(m_dlcInfoPack->doesPackContainFile(DLCManager::e_DLCType_Texture, L"comparison.png")) { - DLCTextureFile *textureFile = (DLCTextureFile *)m_dlcInfoPack->getFile(DLCManager::e_DLCType_Texture, L"comparison.png"); + DLCTextureFile *textureFile = static_cast(m_dlcInfoPack->getFile(DLCManager::e_DLCType_Texture, L"comparison.png")); m_comparisonData = textureFile->getData(m_comparisonSize); } } @@ -166,7 +166,7 @@ void DLCTexturePack::loadColourTable() // Load the game colours if(m_dlcDataPack != NULL && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_ColourTable, L"colours.col")) { - DLCColourTableFile *colourFile = (DLCColourTableFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_ColourTable, L"colours.col"); + DLCColourTableFile *colourFile = static_cast(m_dlcDataPack->getFile(DLCManager::e_DLCType_ColourTable, L"colours.col")); m_colourTable = colourFile->getColourTable(); m_bUsingDefaultColourTable = false; } @@ -274,7 +274,7 @@ wstring DLCTexturePack::getFilePath(DWORD packId, wstring filename, bool bAddDat int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask) { - DLCTexturePack *texturePack = (DLCTexturePack *)pParam; + DLCTexturePack *texturePack = static_cast(pParam); texturePack->m_bLoadingData = false; if(dwErr!=ERROR_SUCCESS) { @@ -347,7 +347,7 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen int gameRulesCount = pack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader); for(int i = 0; i < gameRulesCount; ++i) { - DLCGameRulesHeader *dlcFile = (DLCGameRulesHeader *) pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i); + DLCGameRulesHeader *dlcFile = static_cast(pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i)); if (!dlcFile->getGrfPath().empty()) { @@ -469,7 +469,7 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen //DLCPack *pack = texturePack->m_dlcInfoPack->GetParentPack(); if(pack->getDLCItemsCount(DLCManager::e_DLCType_Audio)>0) { - DLCAudioFile *dlcFile = (DLCAudioFile *) pack->getFile(DLCManager::e_DLCType_Audio, 0); + DLCAudioFile *dlcFile = static_cast(pack->getFile(DLCManager::e_DLCType_Audio, 0)); texturePack->setHasAudio(true); // init the streaming sound ids for this texture pack int iOverworldStart, iNetherStart, iEndStart; @@ -589,7 +589,7 @@ wstring DLCTexturePack::getXuiRootPath() wstring path = L""; if(m_dlcDataPack != NULL && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")) { - DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp"); + DLCUIDataFile *dataFile = static_cast(m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")); DWORD dwSize = 0; PBYTE pbData = dataFile->getData(dwSize); diff --git a/Minecraft.Client/DragonBreathParticle.cpp b/Minecraft.Client/DragonBreathParticle.cpp index 0d0f75f33..3fd90806b 100644 --- a/Minecraft.Client/DragonBreathParticle.cpp +++ b/Minecraft.Client/DragonBreathParticle.cpp @@ -24,8 +24,8 @@ void DragonBreathParticle::init(Level *level, double x, double y, double z, doub size *= scale; oSize = size; - lifetime = (int) (20 / (Math::random() * 0.8 + 0.2)); - lifetime = (int) (lifetime * scale); + lifetime = static_cast(20 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(lifetime * scale); noPhysics = false; m_bHasHitGround = false; diff --git a/Minecraft.Client/DragonModel.cpp b/Minecraft.Client/DragonModel.cpp index 9e0499a9f..f1f36743a 100644 --- a/Minecraft.Client/DragonModel.cpp +++ b/Minecraft.Client/DragonModel.cpp @@ -159,7 +159,7 @@ void DragonModel::render(shared_ptr entity, float time, float r, float b rr = (float) Mth::cos(i * 0.45f + roff) * 0.15f; neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) * PI / 180.0f * rotScale; // 4J replaced "p[0] - start[0] with call to getHeadPartYRotDiff - neck->xRot = rr + (float) (dragon->getHeadPartYOffset(i, start, p)) * PI / 180.0f * rotScale * 5.0f; // 4J replaced "p[1] - start[1]" with call to getHeadPartYOffset + neck->xRot = rr + static_cast(dragon->getHeadPartYOffset(i, start, p)) * PI / 180.0f * rotScale * 5.0f; // 4J replaced "p[1] - start[1]" with call to getHeadPartYOffset neck->zRot = -rotWrap(p[0] - rot) * PI / 180.0f * rotScale; neck->y = yy; @@ -176,7 +176,7 @@ void DragonModel::render(shared_ptr entity, float time, float r, float b head->x = xx; dragon->getLatencyPos(p, 0, a); head->yRot = rotWrap(dragon->getHeadPartYRotDiff(6, start, p)) * PI / 180.0f * 1; // 4J replaced "p[0] - start[0] with call to getHeadPartYRotDiff - head->xRot = (float) (dragon->getHeadPartYOffset(6, start, p)) * PI / 180.0f * rotScale * 5.0f; // 4J Added + head->xRot = static_cast(dragon->getHeadPartYOffset(6, start, p)) * PI / 180.0f * rotScale * 5.0f; // 4J Added head->zRot = -rotWrap(p[0] - rot) * PI / 180 * 1; head->render(scale,usecompiled); glPushMatrix(); @@ -226,7 +226,7 @@ void DragonModel::render(shared_ptr entity, float time, float r, float b dragon->getLatencyPos(p, 12 + i, a); rr += Mth::sin(i * 0.45f + roff) * 0.05f; neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) * PI / 180; - neck->xRot = rr + (float) (p[1] - start[1]) * PI / 180 * rotScale * 5; + neck->xRot = rr + static_cast(p[1] - start[1]) * PI / 180 * rotScale * 5; neck->zRot = rotWrap(p[0] - rot) * PI / 180 * rotScale; neck->y = yy; neck->z = zz; @@ -244,5 +244,5 @@ float DragonModel::rotWrap(double d) d -= 360; while (d < -180) d += 360; - return (float) d; + return static_cast(d); } \ No newline at end of file diff --git a/Minecraft.Client/DripParticle.cpp b/Minecraft.Client/DripParticle.cpp index 9463976e6..d7202b078 100644 --- a/Minecraft.Client/DripParticle.cpp +++ b/Minecraft.Client/DripParticle.cpp @@ -30,7 +30,7 @@ DripParticle::DripParticle(Level *level, double x, double y, double z, Material this->material = material; stuckTime = 40; - lifetime = (int) (64 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(64 / (Math::random() * 0.8 + 0.2)); xd = yd = zd = 0; } diff --git a/Minecraft.Client/Durango/ApplicationView.cpp b/Minecraft.Client/Durango/ApplicationView.cpp index 2af864960..6c1959381 100644 --- a/Minecraft.Client/Durango/ApplicationView.cpp +++ b/Minecraft.Client/Durango/ApplicationView.cpp @@ -22,7 +22,7 @@ ApplicationView::ApplicationView() XALLOC_ATTRIBUTES ExpandAllocAttributes( _In_ LONGLONG dwAttributes ) { XALLOC_ATTRIBUTES attr; - attr = *((XALLOC_ATTRIBUTES *)&dwAttributes); + attr = *static_cast(&dwAttributes); return attr; } @@ -247,7 +247,7 @@ void ApplicationView::OnSuspending(Platform::Object^ sender, SuspendingEventArgs LARGE_INTEGER qwTicksPerSec, qwTime, qwNewTime, qwDeltaTime; float fElapsedTime = 0.0f; QueryPerformanceFrequency( &qwTicksPerSec ); - float fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; + float fSecsPerTick = 1.0f / static_cast(qwTicksPerSec.QuadPart); // Save the start time QueryPerformanceCounter( &qwTime ); @@ -275,7 +275,7 @@ void ApplicationView::OnSuspending(Platform::Object^ sender, SuspendingEventArgs QueryPerformanceCounter( &qwNewTime ); qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; - fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); + fElapsedTime = fSecsPerTick * static_cast(qwDeltaTime.QuadPart); app.DebugPrintf("Entire suspend process: Elapsed time %f\n", fElapsedTime); } diff --git a/Minecraft.Client/Durango/DurangoExtras/DurangoStubs.cpp b/Minecraft.Client/Durango/DurangoExtras/DurangoStubs.cpp index 81b9d7cf1..463756bc9 100644 --- a/Minecraft.Client/Durango/DurangoExtras/DurangoStubs.cpp +++ b/Minecraft.Client/Durango/DurangoExtras/DurangoStubs.cpp @@ -32,7 +32,7 @@ DWORD XGetLanguage() WCHAR wchLocaleName[LOCALE_NAME_MAX_LENGTH]; GetUserDefaultLocaleName(wchLocaleName,LOCALE_NAME_MAX_LENGTH); - eMCLang eLang=(eMCLang)app.get_eMCLang(wchLocaleName); + eMCLang eLang=static_cast(app.get_eMCLang(wchLocaleName)); #ifdef _DEBUG app.DebugPrintf("XGetLanguage() ==> '%ls'\n", wchLocaleName); diff --git a/Minecraft.Client/Durango/Durango_App.cpp b/Minecraft.Client/Durango/Durango_App.cpp index 59ac8ba0b..e58a57c12 100644 --- a/Minecraft.Client/Durango/Durango_App.cpp +++ b/Minecraft.Client/Durango/Durango_App.cpp @@ -221,7 +221,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImage(WCHAR *wchName,PBYTE *ppbImageData,D if(*pdwBytes!=0) { DWORD dwBytesRead; - PBYTE pbImageData=(PBYTE)malloc(*pdwBytes); + PBYTE pbImageData=static_cast(malloc(*pdwBytes)); if(ReadFile(hFile,pbImageData,*pdwBytes,&dwBytesRead,NULL)==FALSE) { @@ -299,7 +299,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); // Reset the autosave time app.SetAutosaveTimerTime(); @@ -454,9 +454,9 @@ bool CConsoleMinecraftApp::TMSPP_ReadBannedList(int iPad,eTMSAction NextAction) int CConsoleMinecraftApp::Callback_TMSPPReadBannedList(void *pParam,int iPad, int iUserData, LPVOID lpvData,WCHAR *wchFilename) { app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPReadBannedList\n"); - C4JStorage::PTMSPP_FILEDATA pFileData=(C4JStorage::PTMSPP_FILEDATA)lpvData; + C4JStorage::PTMSPP_FILEDATA pFileData=static_cast(lpvData); - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + CConsoleMinecraftApp* pClass = static_cast(pParam); if(pFileData) { @@ -486,7 +486,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadBannedList(void *pParam,int iPad, in } // change the state to the next action - pClass->SetTMSAction(iPad,(eTMSAction)iUserData); + pClass->SetTMSAction(iPad,static_cast(iUserData)); return 0; } @@ -555,11 +555,11 @@ void CConsoleMinecraftApp::TMSPP_RetrieveFileList(int iPad,C4JStorage::eGlobalSt int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad, int iUserData, LPVOID lpvData, WCHAR *wchFilename) { - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + CConsoleMinecraftApp* pClass = static_cast(pParam); app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList\n"); if(lpvData!=NULL) { - vector *pvTmsFileDetails=(vector *)lpvData; + vector *pvTmsFileDetails=static_cast *>(lpvData); if(pvTmsFileDetails->size()>0) { @@ -578,7 +578,7 @@ int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad, } } // change the state to the next action - pClass->SetTMSAction(iPad,(eTMSAction)iUserData); + pClass->SetTMSAction(iPad,static_cast(iUserData)); return 0; } @@ -586,8 +586,8 @@ int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad, int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int iUserData, LPVOID lpvData ,WCHAR *pwchFilename) { app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPReadDLCFile\n"); - C4JStorage::PTMSPP_FILEDATA pFileData= (C4JStorage::PTMSPP_FILEDATA)lpvData; - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + C4JStorage::PTMSPP_FILEDATA pFileData= static_cast(lpvData); + CConsoleMinecraftApp* pClass = static_cast(pParam); #ifdef WRITE_DLCINFO if(0) @@ -698,14 +698,14 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i } // change the state to the next action - pClass->SetTMSAction(iPad,(eTMSAction)iUserData); + pClass->SetTMSAction(iPad,static_cast(iUserData)); return 0; } void CConsoleMinecraftApp::Callback_SaveGameIncomplete(void *pParam, C4JStorage::ESaveIncompleteType saveIncompleteType) { - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + CConsoleMinecraftApp* pClass = static_cast(pParam); if ( saveIncompleteType == C4JStorage::ESaveIncomplete_OutOfQuota || saveIncompleteType == C4JStorage::ESaveIncomplete_OutOfLocalStorage ) @@ -740,7 +740,7 @@ void CConsoleMinecraftApp::Callback_SaveGameIncomplete(void *pParam, C4JStorage: int CConsoleMinecraftApp::Callback_SaveGameIncompleteMessageBoxReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam; + CConsoleMinecraftApp* pClass = static_cast(pParam); switch(result) { diff --git a/Minecraft.Client/Durango/Durango_App.h b/Minecraft.Client/Durango/Durango_App.h index 6e0212329..4ae2a020c 100644 --- a/Minecraft.Client/Durango/Durango_App.h +++ b/Minecraft.Client/Durango/Durango_App.h @@ -37,7 +37,7 @@ class CConsoleMinecraftApp : public CMinecraftApp virtual int GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT=eFileExtensionType_PNG); // BANNED LEVEL LIST - virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {} + virtual void ReadBannedList(int iPad, eTMSAction action=static_cast(0), bool bCallback=false) {} // TMS++ void TMSPP_RetrieveFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,eTMSAction NextAction); diff --git a/Minecraft.Client/Durango/Durango_Minecraft.cpp b/Minecraft.Client/Durango/Durango_Minecraft.cpp index a563c9f3e..b8487aec9 100644 --- a/Minecraft.Client/Durango/Durango_Minecraft.cpp +++ b/Minecraft.Client/Durango/Durango_Minecraft.cpp @@ -582,7 +582,7 @@ void oldWinMainInit() app.ReadLocalDLCList(); // initialise the storage manager with a default save display name, a Minimum save size, and a callback for displaying the saving message - StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app, app.UpdateProductId,SERVICE_CONFIG_ID,TITLE_PRODUCT_ID); + StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,static_cast(&app), app.UpdateProductId,SERVICE_CONFIG_ID,TITLE_PRODUCT_ID); StorageManager.SetMaxSaves(99); @@ -595,21 +595,21 @@ void oldWinMainInit() app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, &app.uiGameDefinedDataChangedBitmask); - StorageManager.SetDefaultImages((PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); + StorageManager.SetDefaultImages(static_cast(baSaveThumbnail.data), baSaveThumbnail.length); // Set function to be called if a save game operation can't complete due to running out of storage space etc. - StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); + StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, static_cast(&app)); // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); // Set a callback for the default player options to be set - when there is no profile data for the player - StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); - StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app); + StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,static_cast(&app)); + StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,static_cast(&app)); // Set a callback to deal with old profile versions needing updated to new versions - StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); + StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,static_cast(&app)); g_NetworkManager.Initialise(); diff --git a/Minecraft.Client/Durango/Durango_UIController.cpp b/Minecraft.Client/Durango/Durango_UIController.cpp index 446ab87e3..7c9313e61 100644 --- a/Minecraft.Client/Durango/Durango_UIController.cpp +++ b/Minecraft.Client/Durango/Durango_UIController.cpp @@ -169,7 +169,7 @@ GDrawTexture *ConsoleUIController::getSubstitutionTexture(int textureId) ID3D11ShaderResourceView *tex = RenderManager.TextureGetTexture(textureId); ID3D11Resource *resource; tex->GetResource(&resource); - ID3D11Texture2D *tex2d = (ID3D11Texture2D *)resource; + ID3D11Texture2D *tex2d = static_cast(resource); D3D11_TEXTURE2D_DESC desc; tex2d->GetDesc(&desc); GDrawTexture *gdrawTex = gdraw_D3D11_WrappedTextureCreate(tex); diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl index a60fa520c..11a197e67 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl @@ -368,7 +368,7 @@ static void gdraw_HandleTransitionInsertBefore(GDrawHandle *t, GDrawHandleState { check_lists(t->cache); assert(t->state != GDRAW_HANDLE_STATE_sentinel); // sentinels should never get here! - assert(t->state != (U32) new_state); // code should never call "transition" if it's not transitioning! + assert(t->state != static_cast(new_state)); // code should never call "transition" if it's not transitioning! // unlink from prev state t->prev->next = t->next; t->next->prev = t->prev; @@ -773,7 +773,7 @@ static GDrawTexture *gdraw_BlurPass(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRe if (!g->TextureDrawBufferBegin(draw_bounds, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats)) return r->tex[0]; - c->BlurPass(r, taps, data, draw_bounds, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, draw_bounds, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -825,7 +825,7 @@ static GDrawTexture *gdraw_BlurPassDownsample(GDrawFunctions *g, GDrawBlurInfo * assert(clamp[0] <= clamp[2]); assert(clamp[1] <= clamp[3]); - c->BlurPass(r, taps, data, &z, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, &z, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -837,7 +837,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR GDrawTexture *t; F32 data[MAX_TAPS][4]; S32 off_axis = 1-axis; - S32 w = ((S32) ceil((blur_width-1)/2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 + S32 w = static_cast(ceil((blur_width - 1) / 2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 F32 edge_weight = 1 - (w - blur_width)/2; // 3 => 0 => 1; 1.2 => 1.8 => 0.9 => 0.1 F32 inverse_weight = 1.0f / blur_width; @@ -944,7 +944,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR // max coverage is 25 samples, or a filter width of 13. with 7 taps, we sample // 13 samples in one pass, max coverage is 13*13 samples or (13*13-1)/2 width, // which is ((2T-1)*(2T-1)-1)/2 or (4T^2 - 4T + 1 -1)/2 or 2T^2 - 2T or 2T*(T-1) - S32 w_mip = (S32) ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS)); + S32 w_mip = static_cast(ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS))); S32 downsample = w_mip; F32 sample_spacing = texel; if (downsample < 2) downsample = 2; diff --git a/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp b/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp index 46b046068..e1d056a7d 100644 --- a/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp +++ b/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp @@ -428,7 +428,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperationDisplayName->Data(), - LeaderboardManager::filterNames[ (int) filter ].c_str(), + LeaderboardManager::filterNames[ static_cast(filter) ].c_str(), lastResult->Rows->Size, lastResult->TotalRowCount, readCount ); @@ -480,10 +480,10 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperationGamertag->Data(); m_scores[index].m_rank = row->Rank; - m_scores[index].m_uid = PlayerUID(row->XboxUserId->Data()); + m_scores[index].m_uid = static_cast(row->XboxUserId->Data()); // 4J-JEV: Added to help determine if this player's score is hidden due to their privacy settings. - m_scores[index].m_totalScore = (unsigned long) _fromString(row->Values->GetAt(0)->Data()); + m_scores[index].m_totalScore = static_cast(_fromString(row->Values->GetAt(0)->Data())); m_xboxUserIds->Append(row->XboxUserId); } @@ -493,7 +493,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation xuids = vector(); for(int i = 0; i < lastResult->Rows->Size; i++) { - xuids.push_back(PlayerUID(lastResult->Rows->GetAt(i)->XboxUserId->Data())); + xuids.push_back(static_cast(lastResult->Rows->GetAt(i)->XboxUserId->Data())); } m_waitingForProfiles = true; ProfileManager.GetProfiles(xuids, &GetProfilesCallback, this); @@ -579,7 +579,7 @@ void DurangoLeaderboardManager::updateStatsInfo(int userIndex, int difficulty, E void DurangoLeaderboardManager::GetProfilesCallback(LPVOID param, std::vector profiles) { - DurangoLeaderboardManager *dlm = (DurangoLeaderboardManager *)param; + DurangoLeaderboardManager *dlm = static_cast(param); app.DebugPrintf("[LeaderboardManager] GetProfilesCallback, profiles.size() == %d.\n", profiles.size()); diff --git a/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp b/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp index dd07f3e96..18f4328c5 100644 --- a/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp +++ b/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp @@ -103,5 +103,5 @@ void GameProgress::updatePlayer(int iPad) float GameProgress::calcGameProgress(int achievementsUnlocked) { - return (float) achievementsUnlocked / 0.60f; + return static_cast(achievementsUnlocked) / 0.60f; } \ No newline at end of file diff --git a/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h b/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h index 80b4e10a3..f81a0f1f1 100644 --- a/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h +++ b/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h @@ -238,7 +238,7 @@ class ChatIntegrationLayer __in ChatPacketType chatPacketType ); Concurrency::critical_section m_chatPacketStatsLock; - int m_chatVoicePacketsStatistic[2][(int)Microsoft::Xbox::GameChat::ChatMessageType::InvalidMessage+1]; + int m_chatVoicePacketsStatistic[2][static_cast(Microsoft::Xbox::GameChat::ChatMessageType::InvalidMessage)+1]; }; std::shared_ptr GetChatIntegrationLayer(); \ No newline at end of file diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp index 8d502d232..a054a716d 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp @@ -515,7 +515,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex) pPlayer->SetSmallId(smallId); pPlayer->SetName(ProfileManager.GetUser(userIndex)->DisplayInfo->Gamertag->Data()); pPlayer->SetDisplayName(ProfileManager.GetDisplayName(userIndex)); - pPlayer->SetUID(PlayerUID(ProfileManager.GetUser(userIndex)->XboxUserId->Data())); + pPlayer->SetUID(static_cast(ProfileManager.GetUser(userIndex)->XboxUserId->Data())); // Also add to the party so that our friends can find us. The host will get notified of this additional player in the party, but we should ignore since we're already in the session m_partyController->AddLocalUsersToParty(1 << userIndex, ProfileManager.GetUser(0)); @@ -550,7 +550,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex) pPlayer->SetSmallId(m_currentSmallId++); pPlayer->SetName(ProfileManager.GetUser(userIndex)->DisplayInfo->Gamertag->Data()); pPlayer->SetDisplayName(ProfileManager.GetDisplayName(userIndex)); - pPlayer->SetUID(PlayerUID(ProfileManager.GetUser(userIndex)->XboxUserId->Data())); + pPlayer->SetUID(static_cast(ProfileManager.GetUser(userIndex)->XboxUserId->Data())); // TODO - could this add fail? if(AddRoomSyncPlayer( pPlayer, 0, userIndex)) @@ -1326,11 +1326,11 @@ void DQRNetworkManager::HandleSessionChange(MXSM::MultiplayerSession^ multiplaye { // 4J-JEV: This id is needed to link stats together. // I thought setting the value from here would be less intrusive than adding an accessor. - ((DurangoStats*)GenericStats::getInstance())->setMultiplayerCorrelationId(multiplayerSession->MultiplayerCorrelationId); + static_cast(GenericStats::getInstance())->setMultiplayerCorrelationId(multiplayerSession->MultiplayerCorrelationId); } else { - ((DurangoStats*)GenericStats::getInstance())->setMultiplayerCorrelationId( nullptr ); + static_cast(GenericStats::getInstance())->setMultiplayerCorrelationId( nullptr ); } m_multiplayerSession = multiplayerSession; @@ -1403,7 +1403,7 @@ bool DQRNetworkManager::IsPlayerInSession( Platform::String^ xboxUserId, MXSM::M { Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson); Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId"); - *smallId = (int)(customValue->GetNumber()) & 255; + *smallId = static_cast(customValue->GetNumber()) & 255; } catch (Platform::COMException^ ex) { @@ -1745,7 +1745,7 @@ void DQRNetworkManager::SendSmallId(bool reliableAndSequential, int playerMask) { Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson); Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId"); - smallId = (BYTE)(customValue->GetNumber()); + smallId = static_cast(customValue->GetNumber()); bFound = true; } catch (Platform::COMException^ ex) @@ -1797,7 +1797,7 @@ int DQRNetworkManager::GetSessionIndexForSmallId(unsigned char smallId) { Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson); Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId"); - smallIdMember = (BYTE)(customValue->GetNumber()); + smallIdMember = static_cast(customValue->GetNumber()); } catch (Platform::COMException^ ex) { @@ -1830,7 +1830,7 @@ int DQRNetworkManager::GetSessionIndexAndSmallIdForHost(unsigned char *smallId) } if( smallIdMember > 255 ) { - *smallId = (BYTE)(smallIdMember); + *smallId = static_cast(smallIdMember); return i; } } @@ -1877,7 +1877,7 @@ Platform::String^ DQRNetworkManager::GetNextSmallIdAsJsonString() int DQRNetworkManager::_HostGameThreadProc( void* lpParameter ) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast(lpParameter); return pDQR->HostGameThreadProc(); } @@ -2190,7 +2190,7 @@ int DQRNetworkManager::HostGameThreadProc() pPlayer->SetSmallId(smallId); pPlayer->SetName(user->DisplayInfo->Gamertag->Data()); pPlayer->SetDisplayName(displayName); - pPlayer->SetUID(PlayerUID(user->XboxUserId->Data())); + pPlayer->SetUID(static_cast(user->XboxUserId->Data())); AddRoomSyncPlayer( pPlayer, localSessionAddress, i); @@ -2208,7 +2208,7 @@ int DQRNetworkManager::HostGameThreadProc() int DQRNetworkManager::_LeaveRoomThreadProc( void* lpParameter ) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast(lpParameter); return pDQR->LeaveRoomThreadProc(); } @@ -2311,7 +2311,7 @@ int DQRNetworkManager::LeaveRoomThreadProc() int DQRNetworkManager::_TidyUpJoinThreadProc( void* lpParameter ) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast(lpParameter); return pDQR->TidyUpJoinThreadProc(); } @@ -2416,7 +2416,7 @@ int DQRNetworkManager::TidyUpJoinThreadProc() int DQRNetworkManager::_UpdateCustomSessionDataThreadProc( void* lpParameter ) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast(lpParameter); return pDQR->UpdateCustomSessionDataThreadProc(); } @@ -2491,7 +2491,7 @@ int DQRNetworkManager::UpdateCustomSessionDataThreadProc() int DQRNetworkManager::_CheckInviteThreadProc(void* lpParameter) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast(lpParameter); return pDQR->CheckInviteThreadProc(); } @@ -3026,8 +3026,8 @@ void DQRNetworkManager::RequestDisplayName(DQRNetworkPlayer *player) void DQRNetworkManager::GetProfileCallback(LPVOID pParam, Microsoft::Xbox::Services::Social::XboxUserProfile^ profile) { - DQRNetworkManager *dqnm = (DQRNetworkManager *)pParam; - dqnm->SetDisplayName(PlayerUID(profile->XboxUserId->Data()), profile->GameDisplayName->Data()); + DQRNetworkManager *dqnm = static_cast(pParam); + dqnm->SetDisplayName(static_cast(profile->XboxUserId->Data()), profile->GameDisplayName->Data()); } // Set player display name diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp index 3a14a2d59..86d37a6e0 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp @@ -71,7 +71,7 @@ void DQRNetworkManager::FriendPartyManagerGetSessionInfo(int idx, SessionSearchR int DQRNetworkManager::_GetFriendsThreadProc(void* lpParameter) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast(lpParameter); return pDQR->GetFriendsThreadProc(); } @@ -410,7 +410,7 @@ int DQRNetworkManager::GetFriendsThreadProc() for( int j = 0; j < nameResolveVector[i]->Size; j++ ) { m_sessionSearchResults[i].m_playerNames[j] = nameResolveVector[i]->GetAt(j)->GameDisplayName->Data(); - m_sessionSearchResults[i].m_playerXuids[j] = PlayerUID(nameResolveVector[i]->GetAt(j)->XboxUserId->Data()); + m_sessionSearchResults[i].m_playerXuids[j] = static_cast(nameResolveVector[i]->GetAt(j)->XboxUserId->Data()); } m_sessionSearchResults[i].m_playerCount = nameResolveVector[i]->Size; m_sessionSearchResults[i].m_usedSlotCount = newSessionVector[i]->Members->Size; @@ -556,7 +556,7 @@ bool DQRNetworkManager::IsSessionFriendsOfFriends(MXSM::MultiplayerSession^ sess if (result) { - friendsOfFriends = app.GetGameHostOption(((GameSessionData *)gameSessionData)->m_uiGameHostSettings, eGameHostOption_FriendsOfFriends); + friendsOfFriends = app.GetGameHostOption(static_cast(gameSessionData)->m_uiGameHostSettings, eGameHostOption_FriendsOfFriends); } free(gameSessionData); @@ -577,7 +577,7 @@ bool DQRNetworkManager::GetGameSessionData(MXSM::MultiplayerSession^ session, vo Platform::String ^customValueString = customValue->GetString(); if( customValueString ) { - base64_decode( customValueString, (unsigned char *)gameSessionData, sizeof(GameSessionData) ); + base64_decode( customValueString, static_cast(gameSessionData), sizeof(GameSessionData) ); return true; } } diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp index 9232d0959..9494683d4 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp @@ -113,7 +113,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, case DQRConnectionInfo::ConnectionState_InternalAssignSmallId2: case DQRConnectionInfo::ConnectionState_InternalAssignSmallId3: { - int channel = ((int)connectionInfo->m_internalDataState) - DQRConnectionInfo::ConnectionState_InternalAssignSmallId0; + int channel = static_cast(connectionInfo->m_internalDataState) - DQRConnectionInfo::ConnectionState_InternalAssignSmallId0; if( ( connectionInfo->m_smallIdReadMask & ( 1 << channel ) ) && ( !connectionInfo->m_channelActive[channel] ) ) { @@ -137,7 +137,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, DQRNetworkPlayer *pPlayer = new DQRNetworkPlayer(this, DQRNetworkPlayer::DNP_TYPE_REMOTE, true, 0, sessionAddress); pPlayer->SetSmallId(byte); - pPlayer->SetUID(PlayerUID(m_multiplayerSession->Members->GetAt(sessionIndex)->XboxUserId->Data())); + pPlayer->SetUID(static_cast(m_multiplayerSession->Members->GetAt(sessionIndex)->XboxUserId->Data())); HostGamertagResolveDetails *resolveDetails = new HostGamertagResolveDetails(); resolveDetails->m_pPlayer = pPlayer; @@ -371,7 +371,7 @@ void DQRNetworkManager::SendBytesChat(unsigned int address, BYTE *bytes, int byt void DQRNetworkManager::SendBytes(int smallId, BYTE *bytes, int byteCount) { EnterCriticalSection(&m_csSendBytes); - unsigned char *tempSendBuffer = (unsigned char *)malloc(8191 + 2); + unsigned char *tempSendBuffer = static_cast(malloc(8191 + 2)); BYTE *data = bytes; BYTE *dataEnd = bytes + byteCount; @@ -381,7 +381,7 @@ void DQRNetworkManager::SendBytes(int smallId, BYTE *bytes, int byteCount) // blocks of this size. do { - int bytesToSend = (int)(dataEnd - data); + int bytesToSend = static_cast(dataEnd - data); if( bytesToSend > 8191 ) bytesToSend = 8191; // Send header with data sending mode - see full comment in DQRNetworkManagerEventHandlers::DataReceivedHandler diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp index c985a191f..29daa23e6 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp @@ -84,7 +84,7 @@ void DQRNetworkManagerEventHandlers::DataReceivedHandler(Platform::Object^ sessi } rtsMessage.m_sessionAddress = args->SessionAddress; rtsMessage.m_dataSize = args->Data->Length; - rtsMessage.m_pucData = (unsigned char *)malloc(rtsMessage.m_dataSize); + rtsMessage.m_pucData = static_cast(malloc(rtsMessage.m_dataSize)); memcpy( rtsMessage.m_pucData, args->Data->Data, rtsMessage.m_dataSize ); m_pDQRNet->m_RTSMessageQueueIncoming.push(rtsMessage); LeaveCriticalSection(&m_pDQRNet->m_csRTSMessageQueueIncoming); @@ -311,7 +311,7 @@ void DQRNetworkManager::Process_RTS_MESSAGE_DATA_RECEIVED(RTS_Message &message) break; case DQRConnectionInfo::ConnectionState_ReadBytes: // At this stage we can send up to connectionInfo->m_bytesRemaining bytes, or the number of bytes that we have remaining in the data received, whichever is lowest. - int bytesInBuffer = (int)(pEndByte - pNextByte); + int bytesInBuffer = static_cast(pEndByte - pNextByte); int bytesToReceive = ( ( connectionInfo->m_bytesRemaining < bytesInBuffer ) ? connectionInfo->m_bytesRemaining : bytesInBuffer ); if( connectionInfo->m_internalFlag ) @@ -438,7 +438,7 @@ void DQRNetworkManager::Process_RTS_MESSAGE_STATUS_TERMINATED(RTS_Message &messa int DQRNetworkManager::_RTSDoWorkThread(void* lpParameter) { - DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter; + DQRNetworkManager *pDQR = static_cast(lpParameter); return pDQR->RTSDoWorkThread(); } @@ -636,7 +636,7 @@ void DQRNetworkManager::RTS_SendData(unsigned char *pucData, unsigned int dataSi EnterCriticalSection(&m_csRTSMessageQueueOutgoing); RTS_Message message; message.m_eType = eRTSMessageType::RTS_MESSAGE_SEND_DATA; - message.m_pucData = (unsigned char *)malloc(dataSize); + message.m_pucData = static_cast(malloc(dataSize)); memcpy(message.m_pucData, pucData, dataSize); message.m_dataSize = dataSize; message.m_sessionAddress = sessionAddress; diff --git a/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp b/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp index e2d82a902..a8140764c 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp @@ -97,7 +97,7 @@ bool DQRNetworkPlayer::HasVoice() Microsoft::Xbox::GameChat::ChatUser^ chatUser = m_manager->m_chat->GetChatUserByXboxUserId(ref new Platform::String(m_UID.toString().c_str())); if( chatUser == nullptr ) return false; - if( ((int)chatUser->ParticipantType) & ((int)Windows::Xbox::Chat::ChatParticipantTypes::Talker) ) + if( static_cast(chatUser->ParticipantType) & static_cast(Windows::Xbox::Chat::ChatParticipantTypes::Talker) ) { return true; } diff --git a/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp b/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp index fd2181df9..bfb3c9a84 100644 --- a/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp +++ b/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp @@ -14,12 +14,12 @@ unsigned char NetworkPlayerDurango::GetSmallId() void NetworkPlayerDurango::SendData(INetworkPlayer *player, const void *pvData, int dataSize, bool lowPriority) { - m_dqrPlayer->SendData( ((NetworkPlayerDurango *)player)->m_dqrPlayer, pvData, dataSize ); + m_dqrPlayer->SendData( static_cast(player)->m_dqrPlayer, pvData, dataSize ); } bool NetworkPlayerDurango::IsSameSystem(INetworkPlayer *player) { - return m_dqrPlayer->IsSameSystem(((NetworkPlayerDurango *)player)->m_dqrPlayer); + return m_dqrPlayer->IsSameSystem(static_cast(player)->m_dqrPlayer); } int NetworkPlayerDurango::GetSendQueueSizeBytes( INetworkPlayer *player, bool lowPriority ) diff --git a/Minecraft.Client/Durango/Network/PartyController.cpp b/Minecraft.Client/Durango/Network/PartyController.cpp index 753a71aca..4e1a7e611 100644 --- a/Minecraft.Client/Durango/Network/PartyController.cpp +++ b/Minecraft.Client/Durango/Network/PartyController.cpp @@ -103,7 +103,7 @@ void PartyController::RefreshPartyView() } catch ( Platform::Exception^ ex ) { - if( ex->HResult != (int)Windows::Xbox::Multiplayer::PartyErrorStatus::EmptyParty ) + if( ex->HResult != static_cast(Windows::Xbox::Multiplayer::PartyErrorStatus::EmptyParty) ) { // LogCommentWithError( L"GetPartyView failed", ex->HResult ); } @@ -577,7 +577,7 @@ void PartyController::OnPartyRosterChanged( PartyRosterChangedEventArgs^ eventAr // Still a party, find out who left for( int i = 0; i < eventArgs->RemovedMembers->Size; i++ ) { - DQRNetworkPlayer *player = m_pDQRNet->GetPlayerByXuid(PlayerUID(eventArgs->RemovedMembers->GetAt(i)->Data())); + DQRNetworkPlayer *player = m_pDQRNet->GetPlayerByXuid(static_cast(eventArgs->RemovedMembers->GetAt(i)->Data())); if( player ) { if( player->IsLocal() ) @@ -639,7 +639,7 @@ void PartyController::AddAvailableGamePlayers(IVectorView^ availabl { bFoundLocal = true; // Check that they aren't in the game already (don't see how this could be the case anyway) - if( m_pDQRNet->GetPlayerByXuid( PlayerUID(player->XboxUserId->Data()) ) == NULL ) + if( m_pDQRNet->GetPlayerByXuid( static_cast(player->XboxUserId->Data()) ) == NULL ) { // And check whether they are signed in yet or not int userIdx = -1; @@ -838,7 +838,7 @@ void PartyController::OnGameSessionReady( GameSessionReadyEventArgs^ eventArgs ) if( !isAJoiningXuid ) // Isn't someone we are actively trying to join { if( (!bInSession) || // If not in a game session at all - ( ( m_pDQRNet->GetState() == DQRNetworkManager::DNM_INT_STATE_PLAYING ) && ( m_pDQRNet->GetPlayerByXuid( PlayerUID(memberXUID->Data()) ) == NULL ) ) // Or we're fully in, and this player isn't in it + ( ( m_pDQRNet->GetState() == DQRNetworkManager::DNM_INT_STATE_PLAYING ) && ( m_pDQRNet->GetPlayerByXuid( static_cast(memberXUID->Data()) ) == NULL ) ) // Or we're fully in, and this player isn't in it ) { for( int j = 4; j < 12; j++ ) // Final check that we have a gamepad for this xuid so that we might possibly be able to pair someone up @@ -1201,5 +1201,5 @@ double PartyController::GetTimeBetweenInSeconds(Windows::Foundation::DateTime dt { const uint64 tickPerSecond = 10000000i64; uint64 deltaTime = dt2.UniversalTime - dt1.UniversalTime; - return (double)deltaTime / (double)tickPerSecond; + return static_cast(deltaTime) / static_cast(tickPerSecond); } \ No newline at end of file diff --git a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp index 925a37a8e..7171895a1 100644 --- a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp +++ b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp @@ -87,7 +87,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl bool createFakeSocket = false; bool localPlayer = false; - NetworkPlayerDurango *networkPlayer = (NetworkPlayerDurango *)addNetworkPlayer(pDQRPlayer); + NetworkPlayerDurango *networkPlayer = static_cast(addNetworkPlayer(pDQRPlayer)); // Request full display name for this player m_pDQRNet->RequestDisplayName(pDQRPlayer); @@ -628,7 +628,7 @@ void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer int CPlatformNetworkManagerDurango::RemovePlayerOnSocketClosedThreadProc( void* lpParam ) { - INetworkPlayer *pNetworkPlayer = (INetworkPlayer *)lpParam; + INetworkPlayer *pNetworkPlayer = static_cast(lpParam); Socket *socket = pNetworkPlayer->GetSocket(); @@ -794,7 +794,7 @@ vector *CPlatformNetworkManagerDurango::GetSessionList(int vector *filteredList = new vector(); for( int i = 0; i < m_searchResultsCount; i++ ) { - GameSessionData *gameSessionData = (GameSessionData *)m_pSearchResults[i].m_extData; + GameSessionData *gameSessionData = static_cast(m_pSearchResults[i].m_extData); if( ( gameSessionData->netVersion == MINECRAFT_NET_VERSION ) && ( gameSessionData->isReadyToJoin ) ) { diff --git a/Minecraft.Client/Durango/Network/base64.cpp b/Minecraft.Client/Durango/Network/base64.cpp index c5af745c4..c916725f1 100644 --- a/Minecraft.Client/Durango/Network/base64.cpp +++ b/Minecraft.Client/Durango/Network/base64.cpp @@ -109,13 +109,13 @@ void base64_decode(Platform::String ^encoded_string, unsigned char *output, unsi while (in_len-- && ( encoded_string->Data()[in_] != L'=') && is_base64(encoded_string->Data()[in_])) { - char_array_4[i++] = (unsigned char)(encoded_string->Data()[in_]); + char_array_4[i++] = static_cast(encoded_string->Data()[in_]); in_++; if (i ==4) { for (i = 0; i <4; i++) { - char_array_4[i] = (unsigned char )base64_chars.find(char_array_4[i]); + char_array_4[i] = static_cast(base64_chars.find(char_array_4[i])); } char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); @@ -140,7 +140,7 @@ void base64_decode(Platform::String ^encoded_string, unsigned char *output, unsi for (j = 0; j <4; j++) { - char_array_4[j] = (unsigned char )base64_chars.find(char_array_4[j]); + char_array_4[j] = static_cast(base64_chars.find(char_array_4[j])); } char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); diff --git a/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp b/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp index 2386a3484..25ca46b28 100644 --- a/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp +++ b/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp @@ -968,7 +968,7 @@ bool CDurangoTelemetryManager::RecordUnBanLevel(int iPad) DurangoStats *CDurangoTelemetryManager::durangoStats() { - return (DurangoStats*) GenericStats::getInstance(); + return static_cast(GenericStats::getInstance()); } wstring CDurangoTelemetryManager::guid2str(LPCGUID guid) diff --git a/Minecraft.Client/Durango/XML/ATGXmlParser.cpp b/Minecraft.Client/Durango/XML/ATGXmlParser.cpp index fc5aed08a..dea8c1859 100644 --- a/Minecraft.Client/Durango/XML/ATGXmlParser.cpp +++ b/Minecraft.Client/Durango/XML/ATGXmlParser.cpp @@ -69,8 +69,8 @@ VOID XMLParser::FillBuffer() } m_dwCharsConsumed += NChars; - __int64 iProgress = m_dwCharsTotal ? (( (__int64)m_dwCharsConsumed * 1000 ) / (__int64)m_dwCharsTotal) : 0; - m_pISAXCallback->SetParseProgress( (DWORD)iProgress ); + __int64 iProgress = m_dwCharsTotal ? (( static_cast<__int64>(m_dwCharsConsumed) * 1000 ) / static_cast<__int64>(m_dwCharsTotal)) : 0; + m_pISAXCallback->SetParseProgress( static_cast(iProgress) ); m_pReadBuf[ NChars ] = '\0'; m_pReadBuf[ NChars + 1] = '\0'; @@ -198,7 +198,7 @@ HRESULT XMLParser::ConvertEscape() if( FAILED( hr = AdvanceName() ) ) return hr; - EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal ); + EntityRefLen = static_cast(m_pWritePtr - pEntityRefVal); m_pWritePtr = pEntityRefVal; if ( EntityRefLen == 0 ) @@ -497,8 +497,8 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - if( FAILED( m_pISAXCallback->ElementEnd( pEntityRefVal, - (UINT) ( m_pWritePtr - pEntityRefVal ) ) ) ) + if( FAILED( m_pISAXCallback->ElementEnd( pEntityRefVal, + static_cast(m_pWritePtr - pEntityRefVal)) ) ) return E_ABORT; if( FAILED( hr = ConsumeSpace() ) ) @@ -541,7 +541,7 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal ); + EntityRefLen = static_cast(m_pWritePtr - pEntityRefVal); if( FAILED( hr = ConsumeSpace() ) ) return hr; @@ -566,7 +566,7 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - Attributes[ NumAttrs ].NameLen = (UINT)( m_pWritePtr - Attributes[ NumAttrs ].strName ); + Attributes[ NumAttrs ].NameLen = static_cast(m_pWritePtr - Attributes[NumAttrs].strName); if( FAILED( hr = ConsumeSpace() ) ) return hr; @@ -588,8 +588,8 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceAttrVal() ) ) return hr; - Attributes[ NumAttrs ].ValueLen = (UINT)( m_pWritePtr - - Attributes[ NumAttrs ].strValue ); + Attributes[ NumAttrs ].ValueLen = static_cast(m_pWritePtr - + Attributes[NumAttrs].strValue); ++NumAttrs; @@ -663,13 +663,13 @@ HRESULT XMLParser::AdvanceCDATA() if( m_pWritePtr - m_pWriteBuf >= XML_WRITE_BUFFER_SIZE ) { - if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), TRUE ) ) ) + if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, static_cast(m_pWritePtr - m_pWriteBuf), TRUE ) ) ) return E_ABORT; m_pWritePtr = m_pWriteBuf; } } - if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, static_cast(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; m_pWritePtr = m_pWriteBuf; @@ -782,9 +782,9 @@ HRESULT XMLParser::MainParseLoop() { if( FAILED( AdvanceCharacter( TRUE ) ) ) { - if ( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) ) + if ( ( static_cast(m_pWritePtr - m_pWriteBuf) != 0 ) && ( !bWhiteSpaceOnly ) ) { - if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, static_cast(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; bWhiteSpaceOnly = TRUE; @@ -798,9 +798,9 @@ HRESULT XMLParser::MainParseLoop() if( m_Ch == '<' ) { - if( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) ) + if( ( static_cast(m_pWritePtr - m_pWriteBuf) != 0 ) && ( !bWhiteSpaceOnly ) ) { - if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, static_cast(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; bWhiteSpaceOnly = TRUE; @@ -837,8 +837,8 @@ HRESULT XMLParser::MainParseLoop() { if( !bWhiteSpaceOnly ) { - if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, - ( UINT ) ( m_pWritePtr - m_pWriteBuf ), + if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, + static_cast(m_pWritePtr - m_pWriteBuf), TRUE ) ) ) { return E_ABORT; @@ -893,7 +893,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) { LARGE_INTEGER iFileSize; GetFileSizeEx( m_hFile, &iFileSize ); - m_dwCharsTotal = (DWORD)iFileSize.QuadPart; + m_dwCharsTotal = static_cast(iFileSize.QuadPart); m_dwCharsConsumed = 0; hr = MainParseLoop(); } diff --git a/Minecraft.Client/EchantmentTableParticle.cpp b/Minecraft.Client/EchantmentTableParticle.cpp index 5af7ef365..95bd3dbc7 100644 --- a/Minecraft.Client/EchantmentTableParticle.cpp +++ b/Minecraft.Client/EchantmentTableParticle.cpp @@ -21,22 +21,22 @@ EchantmentTableParticle::EchantmentTableParticle(Level *level, double x, double oSize = size = random->nextFloat() * 0.5f + 0.2f; - lifetime = (int) (Math::random() * 10) + 30; + lifetime = static_cast(Math::random() * 10) + 30; noPhysics = true; - setMiscTex( (int) (Math::random() * 26 + 1 + 14 * 16) ); + setMiscTex( static_cast(Math::random() * 26 + 1 + 14 * 16) ); } int EchantmentTableParticle::getLightColor(float a) { int br = Particle::getLightColor(a); - float pos = age / (float) lifetime; + float pos = age / static_cast(lifetime); pos = pos * pos; pos = pos * pos; int br1 = (br) & 0xff; int br2 = (br >> 16) & 0xff; - br2 += (int) (pos * 15 * 16); + br2 += static_cast(pos * 15 * 16); if (br2 > 15 * 16) br2 = 15 * 16; return br1 | br2 << 16; } @@ -44,7 +44,7 @@ int EchantmentTableParticle::getLightColor(float a) float EchantmentTableParticle::getBrightness(float a) { float br = Particle::getBrightness(a); - float pos = age / (float) lifetime; + float pos = age / static_cast(lifetime); pos = pos * pos; pos = pos * pos; return br * (1 - pos) + pos; @@ -56,7 +56,7 @@ void EchantmentTableParticle::tick() yo = y; zo = z; - float pos = age / (float) lifetime; + float pos = age / static_cast(lifetime); pos = 1 - pos; diff --git a/Minecraft.Client/EnchantTableRenderer.cpp b/Minecraft.Client/EnchantTableRenderer.cpp index ff539fcd5..e188529b9 100644 --- a/Minecraft.Client/EnchantTableRenderer.cpp +++ b/Minecraft.Client/EnchantTableRenderer.cpp @@ -28,7 +28,7 @@ void EnchantTableRenderer::render(shared_ptr _table, double x, doubl #endif glPushMatrix(); - glTranslatef((float) x + 0.5f, (float) y + 12 / 16.0f, (float) z + 0.5f); + glTranslatef(static_cast(x) + 0.5f, static_cast(y) + 12 / 16.0f, static_cast(z) + 0.5f); float tt = table->time + a; diff --git a/Minecraft.Client/EnderChestRenderer.cpp b/Minecraft.Client/EnderChestRenderer.cpp index 52fdede94..71804a5a1 100644 --- a/Minecraft.Client/EnderChestRenderer.cpp +++ b/Minecraft.Client/EnderChestRenderer.cpp @@ -23,7 +23,7 @@ void EnderChestRenderer::render(shared_ptr _chest, double x, double glEnable(GL_RESCALE_NORMAL); //glColor4f(1, 1, 1, 1); if( setColor ) glColor4f(1, 1, 1, alpha); - glTranslatef((float) x, (float) y + 1, (float) z + 1); + glTranslatef(static_cast(x), static_cast(y) + 1, static_cast(z) + 1); glScalef(1, -1, -1); glTranslatef(0.5f, 0.5f, 0.5f); diff --git a/Minecraft.Client/EnderCrystalRenderer.cpp b/Minecraft.Client/EnderCrystalRenderer.cpp index d2eba5e83..2dde12467 100644 --- a/Minecraft.Client/EnderCrystalRenderer.cpp +++ b/Minecraft.Client/EnderCrystalRenderer.cpp @@ -25,7 +25,7 @@ void EnderCrystalRenderer::render(shared_ptr _crystal, double x, double float tt = crystal->time + a; glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); bindTexture(&ENDER_CRYSTAL_LOCATION); float hh = sin(tt * 0.2f) / 2 + 0.5f; hh = hh * hh + hh; diff --git a/Minecraft.Client/EnderDragonRenderer.cpp b/Minecraft.Client/EnderDragonRenderer.cpp index 4119e5b9f..a0d66cb3e 100644 --- a/Minecraft.Client/EnderDragonRenderer.cpp +++ b/Minecraft.Client/EnderDragonRenderer.cpp @@ -13,7 +13,7 @@ ResourceLocation EnderDragonRenderer::DRAGON_LOCATION = ResourceLocation(TN_MOB_ EnderDragonRenderer::EnderDragonRenderer() : MobRenderer(new DragonModel(0), 0.5f) { - dragonModel = (DragonModel *) model; + dragonModel = static_cast(model); setArmor(model); // TODO: Make second constructor that assigns this. } @@ -96,9 +96,9 @@ void EnderDragonRenderer::render(shared_ptr _mob, double x, double y, do float hh = sin(tt * 0.2f) / 2 + 0.5f; hh = (hh * hh + hh) * 0.2f; - float xd = (float) (mob->nearestCrystal->x - mob->x - (mob->xo - mob->x) * (1 - a)); - float yd = (float) (hh + mob->nearestCrystal->y - 1 - mob->y - (mob->yo - mob->y) * (1 - a)); - float zd = (float) (mob->nearestCrystal->z - mob->z - (mob->zo - mob->z) * (1 - a)); + float xd = static_cast(mob->nearestCrystal->x - mob->x - (mob->xo - mob->x) * (1 - a)); + float yd = static_cast(hh + mob->nearestCrystal->y - 1 - mob->y - (mob->yo - mob->y) * (1 - a)); + float zd = static_cast(mob->nearestCrystal->z - mob->z - (mob->zo - mob->z) * (1 - a)); float sdd = sqrt(xd * xd + zd * zd); float dd = sqrt(xd * xd + yd * yd + zd * zd); @@ -107,7 +107,7 @@ void EnderDragonRenderer::render(shared_ptr _mob, double x, double y, do glColor4f(1, 1, 1, 1); glPushMatrix(); - glTranslatef((float) x, (float) y + 2, (float) z); + glTranslatef(static_cast(x), static_cast(y) + 2, static_cast(z)); glRotatef((float) (-atan2(zd, xd)) * 180.0f / PI - 90.0f, 0, 1, 0); glRotatef((float) (-atan2(sdd, yd)) * 180.0f / PI - 90.0f, 1, 0, 0); @@ -202,7 +202,7 @@ void EnderDragonRenderer::additionalRendering(shared_ptr _mob, flo t->begin(GL_TRIANGLE_FAN); float dist = random.nextFloat() * 20 + 5 + overDrive * 10; float w = random.nextFloat() * 2 + 1 + overDrive * 2; - t->color(0xffffff, (int) (255 * (1 - overDrive))); + t->color(0xffffff, static_cast(255 * (1 - overDrive))); t->vertex(0, 0, 0); t->color(0xff00ff, 0); t->vertex(-0.866 * w, dist, -0.5f * w); diff --git a/Minecraft.Client/EnderParticle.cpp b/Minecraft.Client/EnderParticle.cpp index 3889bf920..ee1a9c356 100644 --- a/Minecraft.Client/EnderParticle.cpp +++ b/Minecraft.Client/EnderParticle.cpp @@ -28,14 +28,14 @@ EnderParticle::EnderParticle(Level *level, double x, double y, double z, double oSize = size = random->nextFloat()*0.2f+0.5f; - lifetime = (int) (Math::random()*10) + 40; + lifetime = static_cast(Math::random() * 10) + 40; noPhysics = true; - setMiscTex((int)(Math::random()*8)); + setMiscTex(static_cast(Math::random() * 8)); } void EnderParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) { - float s = (age + a) / (float) lifetime; + float s = (age + a) / static_cast(lifetime); s = 1-s; s = s*s; s = 1-s; @@ -48,13 +48,13 @@ int EnderParticle::getLightColor(float a) { int br = Particle::getLightColor(a); - float pos = age/(float)lifetime; + float pos = age/static_cast(lifetime); pos = pos*pos; pos = pos*pos; int br1 = (br) & 0xff; int br2 = (br >> 16) & 0xff; - br2 += (int) (pos * 15 * 16); + br2 += static_cast(pos * 15 * 16); if (br2 > 15 * 16) br2 = 15 * 16; return br1 | br2 << 16; } @@ -62,7 +62,7 @@ int EnderParticle::getLightColor(float a) float EnderParticle::getBrightness(float a) { float br = Particle::getBrightness(a); - float pos = age/(float)lifetime; + float pos = age/static_cast(lifetime); pos = pos*pos; pos = pos*pos; return br*(1-pos)+pos; @@ -74,7 +74,7 @@ void EnderParticle::tick() yo = y; zo = z; - float pos = age/(float)lifetime; + float pos = age/static_cast(lifetime); float a = pos; pos = -pos+pos*pos*2; // pos = pos*pos; diff --git a/Minecraft.Client/EndermanRenderer.cpp b/Minecraft.Client/EndermanRenderer.cpp index f6e5220a4..fc2b8952d 100644 --- a/Minecraft.Client/EndermanRenderer.cpp +++ b/Minecraft.Client/EndermanRenderer.cpp @@ -10,7 +10,7 @@ ResourceLocation EndermanRenderer::ENDERMAN_LOCATION = ResourceLocation(TN_MOB_E EndermanRenderer::EndermanRenderer() : MobRenderer(new EndermanModel(), 0.5f) { - model = (EndermanModel *) MobRenderer::model; + model = static_cast(MobRenderer::model); this->setArmor(model); } diff --git a/Minecraft.Client/EntityRenderDispatcher.cpp b/Minecraft.Client/EntityRenderDispatcher.cpp index 5bb98eadb..abfc2993e 100644 --- a/Minecraft.Client/EntityRenderDispatcher.cpp +++ b/Minecraft.Client/EntityRenderDispatcher.cpp @@ -222,7 +222,7 @@ void EntityRenderDispatcher::prepare(Level *level, Textures *textures, Font *fon int data = level->getData(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); int direction = data & 3; - playerRotY = (float)(direction * 90 + 180); + playerRotY = static_cast(direction * 90 + 180); playerRotX = 0; } } else { diff --git a/Minecraft.Client/EntityRenderer.cpp b/Minecraft.Client/EntityRenderer.cpp index 9aa4ad7d9..4ead9f4a9 100644 --- a/Minecraft.Client/EntityRenderer.cpp +++ b/Minecraft.Client/EntityRenderer.cpp @@ -89,7 +89,7 @@ void EntityRenderer::renderFlame(shared_ptr e, double x, double y, doubl Icon *fire2 = Tile::fire->getTextureLayer(1); glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); float s = e->bbWidth * 1.4f; glScalef(s, s, s); @@ -102,11 +102,11 @@ void EntityRenderer::renderFlame(shared_ptr e, double x, double y, doubl float xo = 0.0f; float h = e->bbHeight / s; - float yo = (float) (e->y - e->bb->y0); + float yo = static_cast(e->y - e->bb->y0); glRotatef(-entityRenderDispatcher->playerRotY, 0, 1, 0); - glTranslatef(0, 0, -0.3f + ((int) h) * 0.02f); + glTranslatef(0, 0, -0.3f + static_cast(h) * 0.02f); glColor4f(1, 1, 1, 1); float zo = 0; int ss = 0; @@ -238,7 +238,7 @@ void EntityRenderer::renderTileShadow(Tile *tt, double x, double y, double z, in if (a < 0) return; if (a > 1) a = 1; - t->color(1.0f, 1.0f, 1.0f, (float) a); + t->color(1.0f, 1.0f, 1.0f, static_cast(a)); // glColor4f(1, 1, 1, (float) a); double x0 = xt + tt->getShapeX0() + xo; @@ -247,20 +247,20 @@ void EntityRenderer::renderTileShadow(Tile *tt, double x, double y, double z, in double z0 = zt + tt->getShapeZ0() + zo; double z1 = zt + tt->getShapeZ1() + zo; - float u0 = (float) ((x - (x0)) / 2 / r + 0.5f); - float u1 = (float) ((x - (x1)) / 2 / r + 0.5f); - float v0 = (float) ((z - (z0)) / 2 / r + 0.5f); - float v1 = (float) ((z - (z1)) / 2 / r + 0.5f); + float u0 = static_cast((x - (x0)) / 2 / r + 0.5f); + float u1 = static_cast((x - (x1)) / 2 / r + 0.5f); + float v0 = static_cast((z - (z0)) / 2 / r + 0.5f); + float v1 = static_cast((z - (z1)) / 2 / r + 0.5f); // u0 = 0; // v0 = 0; // u1 = 1; // v1 = 1; - t->vertexUV((float)(x0), (float)( y0), (float)( z0), (float)( u0), (float)( v0)); - t->vertexUV((float)(x0), (float)( y0), (float)( z1), (float)( u0), (float)( v1)); - t->vertexUV((float)(x1), (float)( y0), (float)( z1), (float)( u1), (float)( v1)); - t->vertexUV((float)(x1), (float)( y0), (float)( z0), (float)( u1), (float)( v0)); + t->vertexUV(static_cast(x0), static_cast(y0), static_cast(z0), (float)( u0), (float)( v0)); + t->vertexUV(static_cast(x0), static_cast(y0), static_cast(z1), (float)( u0), (float)( v1)); + t->vertexUV(static_cast(x1), static_cast(y0), static_cast(z1), (float)( u1), (float)( v1)); + t->vertexUV(static_cast(x1), static_cast(y0), static_cast(z0), (float)( u1), (float)( v0)); } void EntityRenderer::render(AABB *bb, double xo, double yo, double zo) @@ -269,42 +269,42 @@ void EntityRenderer::render(AABB *bb, double xo, double yo, double zo) Tesselator *t = Tesselator::getInstance(); glColor4f(1, 1, 1, 1); t->begin(); - t->offset((float)xo, (float)yo, (float)zo); + t->offset(static_cast(xo), static_cast(yo), static_cast(zo)); t->normal(0, 0, -1); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z0)); t->normal(0, 0, 1); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z1)); t->normal(0, -1, 0); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z1)); t->normal(0, 1, 0); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z0)); t->normal(-1, 0, 0); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z0)); t->normal(1, 0, 0); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z1)); t->offset(0, 0, 0); t->end(); glEnable(GL_TEXTURE_2D); @@ -315,30 +315,30 @@ void EntityRenderer::renderFlat(AABB *bb) { Tesselator *t = Tesselator::getInstance(); t->begin(); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x0), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x0), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z0)); - t->vertex((float)(bb->x1), (float)( bb->y1), (float)( bb->z1)); - t->vertex((float)(bb->x1), (float)( bb->y0), (float)( bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x0), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x0), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z0)); + t->vertex(static_cast(bb->x1), static_cast(bb->y1), static_cast(bb->z1)); + t->vertex(static_cast(bb->x1), static_cast(bb->y0), static_cast(bb->z1)); t->end(); } @@ -385,7 +385,7 @@ void EntityRenderer::postRender(shared_ptr entity, double x, double y, d if (bRenderPlayerShadow && entityRenderDispatcher->options->fancyGraphics && shadowRadius > 0 && !entity->isInvisible()) { double dist = entityRenderDispatcher->distanceToSqr(entity->x, entity->y, entity->z); - float pow = (float) ((1 - dist / (16.0f * 16.0f)) * shadowStrength); + float pow = static_cast((1 - dist / (16.0f * 16.0f)) * shadowStrength); if (pow > 0) { renderShadow(entity, x, y, z, pow, a); diff --git a/Minecraft.Client/ExperienceOrbRenderer.cpp b/Minecraft.Client/ExperienceOrbRenderer.cpp index c0eae7560..691efadec 100644 --- a/Minecraft.Client/ExperienceOrbRenderer.cpp +++ b/Minecraft.Client/ExperienceOrbRenderer.cpp @@ -20,7 +20,7 @@ void ExperienceOrbRenderer::render(shared_ptr _orb, double x, double y, { shared_ptr orb = dynamic_pointer_cast(_orb); glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); int icon = orb->getIcon(); bindTexture(orb); // 4J was L"/item/xporb.png" @@ -50,9 +50,9 @@ void ExperienceOrbRenderer::render(shared_ptr _orb, double x, double y, } float br = 255.0f; float rr = (orb->tickCount + a) / 2; - int rc = (int) ((Mth::sin(rr + 0 * PI * 2 / 3) + 1) * 0.5f * br); - int gc = (int) (br); - int bc = (int) ((Mth::sin(rr + 2 * PI * 2 / 3) + 1) * 0.1f * br); + int rc = static_cast((Mth::sin(rr + 0 * PI * 2 / 3) + 1) * 0.5f * br); + int gc = static_cast(br); + int bc = static_cast((Mth::sin(rr + 2 * PI * 2 / 3) + 1) * 0.1f * br); int col = rc << 16 | gc << 8 | bc; glRotatef(180 - entityRenderDispatcher->playerRotY, 0, 1, 0); glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); diff --git a/Minecraft.Client/ExplodeParticle.cpp b/Minecraft.Client/ExplodeParticle.cpp index fa950a03a..e9d4687bc 100644 --- a/Minecraft.Client/ExplodeParticle.cpp +++ b/Minecraft.Client/ExplodeParticle.cpp @@ -5,9 +5,9 @@ ExplodeParticle::ExplodeParticle(Level *level, double x, double y, double z, double xa, double ya, double za) : Particle(level, x, y, z, xa, ya, za) { - xd = xa+(float)(Math::random()*2-1)*0.05f; - yd = ya+(float)(Math::random()*2-1)*0.05f; - zd = za+(float)(Math::random()*2-1)*0.05f; + xd = xa+static_cast(Math::random() * 2 - 1)*0.05f; + yd = ya+static_cast(Math::random() * 2 - 1)*0.05f; + zd = za+static_cast(Math::random() * 2 - 1)*0.05f; //rCol = gCol = bCol = random->nextFloat()*.3f+.7; @@ -21,16 +21,16 @@ ExplodeParticle::ExplodeParticle(Level *level, double x, double y, double z, dou size = random->nextFloat()*random->nextFloat()*6+1; - lifetime = (int)(16/(random->nextFloat()*0.8+0.2))+2; + lifetime = static_cast(16 / (random->nextFloat() * 0.8 + 0.2))+2; // noPhysics = true; } void ExplodeParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) { // 4J - don't render explosion particles that are less than 3 metres away, to try and avoid large particles that are causing us problems with photosensitivity testing - float x = (float) (xo + (this->x - xo) * a - xOff); - float y = (float) (yo + (this->y - yo) * a - yOff); - float z = (float) (zo + (this->z - zo) * a - zOff); + float x = static_cast(xo + (this->x - xo) * a - xOff); + float y = static_cast(yo + (this->y - yo) * a - yOff); + float z = static_cast(zo + (this->z - zo) * a - zOff); float distSq = (x*x + y*y + z*z); if( distSq < (3.0f * 3.0f) ) return; diff --git a/Minecraft.Client/Extrax64Stubs.cpp b/Minecraft.Client/Extrax64Stubs.cpp index 29865e400..5b620f052 100644 --- a/Minecraft.Client/Extrax64Stubs.cpp +++ b/Minecraft.Client/Extrax64Stubs.cpp @@ -309,7 +309,7 @@ void IQNet::ClientJoinGame() for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++) { - m_player[i].m_smallId = (BYTE)i; + m_player[i].m_smallId = static_cast(i); m_player[i].m_isRemote = true; m_player[i].m_isHostPlayer = false; m_player[i].m_gamertag[0] = 0; @@ -323,7 +323,7 @@ void IQNet::EndGame() s_playerCount = 1; for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++) { - m_player[i].m_smallId = (BYTE)i; + m_player[i].m_smallId = static_cast(i); m_player[i].m_isRemote = false; m_player[i].m_isHostPlayer = false; m_player[i].m_gamertag[0] = 0; @@ -505,7 +505,7 @@ void C_4JProfile::Initialise(DWORD dwTitleID, ZeroMemory(profileData[i], sizeof(byte) * iGameDefinedDataSizeX4 / 4); // Set some sane initial values! - GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)profileData[i]; + GAME_SETTINGS* pGameSettings = static_cast(profileData[i]); pGameSettings->ucMenuSensitivity = 100; //eGameSetting_Sensitivity_InMenu pGameSettings->ucInterfaceOpacity = 80; //eGameSetting_Sensitivity_InMenu pGameSettings->usBitmaskValues |= 0x0200; //eGameSetting_DisplaySplitscreenGamertags - on diff --git a/Minecraft.Client/FallingTileRenderer.cpp b/Minecraft.Client/FallingTileRenderer.cpp index 2d9f5daea..c46b83c5c 100644 --- a/Minecraft.Client/FallingTileRenderer.cpp +++ b/Minecraft.Client/FallingTileRenderer.cpp @@ -22,7 +22,7 @@ void FallingTileRenderer::render(shared_ptr _tile, double x, double y, d if (level->getTile(floor(tile->x), floor(tile->y), floor(tile->z)) != tile->tile) { glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); bindTexture(tile); // 4J was L"/terrain.png" Tile *tt = Tile::tiles[tile->tile]; @@ -37,7 +37,7 @@ void FallingTileRenderer::render(shared_ptr _tile, double x, double y, d Tesselator *t = Tesselator::getInstance(); t->begin(); t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f, -Mth::floor(tile->z) - 0.5f); - tileRenderer->tesselateAnvilInWorld((AnvilTile *) tt, Mth::floor(tile->x), Mth::floor(tile->y), Mth::floor(tile->z), tile->data); + tileRenderer->tesselateAnvilInWorld(static_cast(tt), Mth::floor(tile->x), Mth::floor(tile->y), Mth::floor(tile->z), tile->data); t->offset(0, 0, 0); t->end(); } diff --git a/Minecraft.Client/FireballRenderer.cpp b/Minecraft.Client/FireballRenderer.cpp index 3b1ab924f..24e59ff48 100644 --- a/Minecraft.Client/FireballRenderer.cpp +++ b/Minecraft.Client/FireballRenderer.cpp @@ -20,7 +20,7 @@ void FireballRenderer::render(shared_ptr _fireball, double x, double y, glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); glEnable(GL_RESCALE_NORMAL); float s = scale; glScalef(s / 1.0f, s / 1.0f, s / 1.0f); @@ -43,10 +43,10 @@ void FireballRenderer::render(shared_ptr _fireball, double x, double y, glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); t->begin(); t->normal(0, 1, 0); - t->vertexUV((float)(0 - xo), (float)( 0 - yo), (float)( 0), (float)( u0), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 0 - yo), (float)( 0), (float)( u1), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 1 - yo), (float)( 0), (float)( u1), (float)( v0)); - t->vertexUV((float)(0 - xo), (float)( 1 - yo), (float)( 0), (float)( u0), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 0 - yo), static_cast(0), (float)( u0), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 0 - yo), static_cast(0), (float)( u1), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 1 - yo), static_cast(0), (float)( u1), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 1 - yo), static_cast(0), (float)( u0), (float)( v0)); t->end(); glDisable(GL_RESCALE_NORMAL); @@ -61,7 +61,7 @@ void FireballRenderer::renderFlame(shared_ptr e, double x, double y, dou Icon *tex = Tile::fire->getTextureLayer(0); glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); float s = e->bbWidth * 1.4f; glScalef(s, s, s); @@ -75,7 +75,7 @@ void FireballRenderer::renderFlame(shared_ptr e, double x, double y, dou // float yo = 0.0f; float h = e->bbHeight / s; - float yo = (float) (e->y - e->bb->y0); + float yo = static_cast(e->y - e->bb->y0); //glRotatef(-entityRenderDispatcher->playerRotY, 0, 1, 0); @@ -99,10 +99,10 @@ void FireballRenderer::renderFlame(shared_ptr e, double x, double y, dou u1 = u0; u0 = tmp; - t->vertexUV((float)(0 - xo), (float)( 0 - yo), (float)( 0), (float)( u1), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 0 - yo), (float)( 0), (float)( u0), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 1.4f - yo), (float)( 0), (float)( u0), (float)( v0)); - t->vertexUV((float)(0 - xo), (float)( 1.4f - yo), (float)( 0), (float)( u1), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 0 - yo), static_cast(0), (float)( u1), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 0 - yo), static_cast(0), (float)( u0), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 1.4f - yo), static_cast(0), (float)( u0), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 1.4f - yo), static_cast(0), (float)( u1), (float)( v0)); t->end(); glPopMatrix(); diff --git a/Minecraft.Client/FireworksParticles.cpp b/Minecraft.Client/FireworksParticles.cpp index fd19b0114..9fdaebb92 100644 --- a/Minecraft.Client/FireworksParticles.cpp +++ b/Minecraft.Client/FireworksParticles.cpp @@ -17,7 +17,7 @@ FireworksParticles::FireworksStarter::FireworksStarter(Level *level, double x, d if (infoTag != NULL) { - explosions = (ListTag *)infoTag->getList(FireworksItem::TAG_EXPLOSIONS)->copy(); + explosions = static_cast *>(infoTag->getList(FireworksItem::TAG_EXPLOSIONS)->copy()); if (explosions->size() == 0) { explosions = NULL; @@ -186,9 +186,9 @@ void FireworksParticles::FireworksStarter::tick() } { int rgb = colors[0]; - float r = (float) ((rgb & 0xff0000) >> 16) / 255.0f; - float g = (float) ((rgb & 0x00ff00) >> 8) / 255.0f; - float b = (float) ((rgb & 0x0000ff) >> 0) / 255.0f; + float r = static_cast((rgb & 0xff0000) >> 16) / 255.0f; + float g = static_cast((rgb & 0x00ff00) >> 8) / 255.0f; + float b = static_cast((rgb & 0x0000ff) >> 0) / 255.0f; shared_ptr fireworksOverlayParticle = shared_ptr(new FireworksParticles::FireworksOverlayParticle(level, x, y, z)); fireworksOverlayParticle->setColor(r, g, b); fireworksOverlayParticle->setAlpha(0.99f); // 4J added @@ -365,18 +365,18 @@ void FireworksParticles::FireworksSparkParticle::setFlicker(bool flicker) void FireworksParticles::FireworksSparkParticle::setColor(int rgb) { - float r = (float) ((rgb & 0xff0000) >> 16) / 255.0f; - float g = (float) ((rgb & 0x00ff00) >> 8) / 255.0f; - float b = (float) ((rgb & 0x0000ff) >> 0) / 255.0f; + float r = static_cast((rgb & 0xff0000) >> 16) / 255.0f; + float g = static_cast((rgb & 0x00ff00) >> 8) / 255.0f; + float b = static_cast((rgb & 0x0000ff) >> 0) / 255.0f; float scale = 1.0f; Particle::setColor(r * scale, g * scale, b * scale); } void FireworksParticles::FireworksSparkParticle::setFadeColor(int rgb) { - fadeR = (float) ((rgb & 0xff0000) >> 16) / 255.0f; - fadeG = (float) ((rgb & 0x00ff00) >> 8) / 255.0f; - fadeB = (float) ((rgb & 0x0000ff) >> 0) / 255.0f; + fadeR = static_cast((rgb & 0xff0000) >> 16) / 255.0f; + fadeG = static_cast((rgb & 0x00ff00) >> 8) / 255.0f; + fadeB = static_cast((rgb & 0x0000ff) >> 0) / 255.0f; hasFade = true; } @@ -407,7 +407,7 @@ void FireworksParticles::FireworksSparkParticle::tick() if (age++ >= lifetime) remove(); if (age > lifetime / 2) { - setAlpha(1.0f - (((float) age - lifetime / 2) / (float) lifetime)); + setAlpha(1.0f - ((static_cast(age) - lifetime / 2) / static_cast(lifetime))); if (hasFade) { @@ -475,12 +475,12 @@ void FireworksParticles::FireworksOverlayParticle::render(Tesselator *t, float a float u1 = u0 + 32.0f / 128.0f; float v0 = 16.0f / 128.0f; float v1 = v0 + 32.0f / 128.0f; - float r = 7.1f * sin(((float) age + a - 1.0f) * .25f * PI); - alpha = 0.6f - ((float) age + a - 1.0f) * .25f * .5f; + float r = 7.1f * sin((static_cast(age) + a - 1.0f) * .25f * PI); + alpha = 0.6f - (static_cast(age) + a - 1.0f) * .25f * .5f; - float x = (float) (xo + (this->x - xo) * a - xOff); - float y = (float) (yo + (this->y - yo) * a - yOff); - float z = (float) (zo + (this->z - zo) * a - zOff); + float x = static_cast(xo + (this->x - xo) * a - xOff); + float y = static_cast(yo + (this->y - yo) * a - yOff); + float z = static_cast(zo + (this->z - zo) * a - zOff); t->color(rCol, gCol, bCol, alpha); diff --git a/Minecraft.Client/FishingHookRenderer.cpp b/Minecraft.Client/FishingHookRenderer.cpp index 9d60a9ace..6a55468db 100644 --- a/Minecraft.Client/FishingHookRenderer.cpp +++ b/Minecraft.Client/FishingHookRenderer.cpp @@ -17,7 +17,7 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); glEnable(GL_RESCALE_NORMAL); glScalef(1 / 2.0f, 1 / 2.0f, 1 / 2.0f); int xi = 1; @@ -39,10 +39,10 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); t->begin(); t->normal(0, 1, 0); - t->vertexUV((float)(0 - xo), (float)( 0 - yo), (float)( 0), (float)( u0), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 0 - yo), (float)( 0), (float)( u1), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 1 - yo), (float)( 0), (float)( u1), (float)( v0)); - t->vertexUV((float)(0 - xo), (float)( 1 - yo), (float)( 0), (float)( u0), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 0 - yo), static_cast(0), (float)( u0), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 0 - yo), static_cast(0), (float)( u1), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 1 - yo), static_cast(0), (float)( u1), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 1 - yo), static_cast(0), (float)( u0), (float)( v0)); t->end(); glDisable(GL_RESCALE_NORMAL); @@ -82,9 +82,9 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d double yh = hook->yo + (hook->y - hook->yo) * a + 4 / 16.0f; double zh = hook->zo + (hook->z - hook->zo) * a; - double xa = (float) (xp - xh); - double ya = (float) (yp - yh); - double za = (float) (zp - zh); + double xa = static_cast(xp - xh); + double ya = static_cast(yp - yh); + double za = static_cast(zp - zh); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); @@ -93,8 +93,8 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d int steps = 16; for (int i = 0; i <= steps; i++) { - float aa = i / (float) steps; - t->vertex((float)(x + xa * aa), (float)( y + ya * (aa * aa + aa) * 0.5 + 4 / 16.0f), (float)( z + za * aa)); + float aa = i / static_cast(steps); + t->vertex(static_cast(x + xa * aa), static_cast(y + ya * (aa * aa + aa) * 0.5 + 4 / 16.0f), static_cast(z + za * aa)); } t->end(); glEnable(GL_LIGHTING); diff --git a/Minecraft.Client/FlameParticle.cpp b/Minecraft.Client/FlameParticle.cpp index eb12dbfda..a242f7147 100644 --- a/Minecraft.Client/FlameParticle.cpp +++ b/Minecraft.Client/FlameParticle.cpp @@ -15,14 +15,14 @@ FlameParticle::FlameParticle(Level *level, double x, double y, double z, double oSize = size; rCol = gCol = bCol = 1.0f; - lifetime = (int)(8/(Math::random()*0.8+0.2))+4; + lifetime = static_cast(8 / (Math::random() * 0.8 + 0.2))+4; noPhysics = true; setMiscTex(48); } void FlameParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) { - float s = (age + a) / (float) lifetime; + float s = (age + a) / static_cast(lifetime); size = oSize * (1 - s*s*0.5f); Particle::render(t, a, xa, ya, za, xa2, za2); } @@ -37,7 +37,7 @@ int FlameParticle::getLightColor(float a) int br1 = (br) & 0xff; int br2 = (br >> 16) & 0xff; - br1 += (int) (l * 15 * 16); + br1 += static_cast(l * 15 * 16); if (br1 > 15 * 16) br1 = 15 * 16; return br1 | br2 << 16; } diff --git a/Minecraft.Client/Font.cpp b/Minecraft.Client/Font.cpp index 8a90711bf..cb2f56324 100644 --- a/Minecraft.Client/Font.cpp +++ b/Minecraft.Client/Font.cpp @@ -167,7 +167,7 @@ void Font::renderCharacter(wchar_t c) t->end(); #endif - xPos += (float) charWidths[c]; + xPos += static_cast(charWidths[c]); } void Font::drawShadow(const wstring& str, int x, int y, int color) @@ -201,7 +201,7 @@ void Font::draw(const wstring &str, bool dropShadow) bool noise = false; wstring cleanStr = sanitize(str); - for (int i = 0; i < (int)cleanStr.length(); ++i) + for (int i = 0; i < static_cast(cleanStr.length()); ++i) { // Map character wchar_t c = cleanStr.at(i); @@ -467,7 +467,7 @@ void Font::setBidirectional(bool bidirectional) bool Font::AllCharactersValid(const wstring &str) { - for (int i = 0; i < (int)str.length(); ++i) + for (int i = 0; i < static_cast(str.length()); ++i) { wchar_t c = str.at(i); diff --git a/Minecraft.Client/FootstepParticle.cpp b/Minecraft.Client/FootstepParticle.cpp index 300575eb1..b2bfc9893 100644 --- a/Minecraft.Client/FootstepParticle.cpp +++ b/Minecraft.Client/FootstepParticle.cpp @@ -31,9 +31,9 @@ void FootstepParticle::render(Tesselator *t, float a, float xa, float ya, float glDisable(GL_LIGHTING); float r = 2 / 16.0f; - float xx = (float) (x - xOff); - float yy = (float) (y - yOff); - float zz = (float) (z - zOff); + float xx = static_cast(x - xOff); + float yy = static_cast(y - yOff); + float zz = static_cast(z - zOff); float br = level->getBrightness(Mth::floor(x), Mth::floor(y), Mth::floor(z)); @@ -43,10 +43,10 @@ void FootstepParticle::render(Tesselator *t, float a, float xa, float ya, float t->begin(); t->color(br, br, br, alpha); - t->vertexUV((float)(xx - r), (float)( yy), (float)( zz + r), (float)( 0), (float)( 1)); - t->vertexUV((float)(xx + r), (float)( yy), (float)( zz + r), (float)( 1), (float)( 1)); - t->vertexUV((float)(xx + r), (float)( yy), (float)( zz - r), (float)( 1), (float)( 0)); - t->vertexUV((float)(xx - r), (float)( yy), (float)( zz - r), (float)( 0), (float)( 0)); + t->vertexUV((float)(xx - r), (float)( yy), (float)( zz + r), static_cast(0), static_cast(1)); + t->vertexUV((float)(xx + r), (float)( yy), (float)( zz + r), static_cast(1), static_cast(1)); + t->vertexUV((float)(xx + r), (float)( yy), (float)( zz - r), static_cast(1), static_cast(0)); + t->vertexUV((float)(xx - r), (float)( yy), (float)( zz - r), static_cast(0), static_cast(0)); t->end(); glDisable(GL_BLEND); diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index 390f114de..be2b5f0c1 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -230,7 +230,7 @@ void GameRenderer::tick(bool first) // 4J - add bFirst darkenWorldAmountO = darkenWorldAmount; if (BossMobGuiInfo::darkenWorld) { - darkenWorldAmount += 1.0f / ((float) SharedConstants::TICKS_PER_SECOND * 1); + darkenWorldAmount += 1.0f / (static_cast(SharedConstants::TICKS_PER_SECOND) * 1); if (darkenWorldAmount > 1) { darkenWorldAmount = 1; @@ -239,7 +239,7 @@ void GameRenderer::tick(bool first) // 4J - add bFirst } else if (darkenWorldAmount > 0) { - darkenWorldAmount -= 1.0f / ((float) SharedConstants::TICKS_PER_SECOND * 4); + darkenWorldAmount -= 1.0f / (static_cast(SharedConstants::TICKS_PER_SECOND) * 4); } if( mc->player != mc->localplayers[ProfileManager.GetPrimaryPad()] ) return; // 4J added for split screen - only do rest of processing for once per frame @@ -475,7 +475,7 @@ void GameRenderer::moveCameraToPlayer(float a) int data = mc->level->getData(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); int direction = data & 3; - glRotatef((float)direction * 90,0.0f, 1.0f, 0.0f); + glRotatef(static_cast(direction) * 90,0.0f, 1.0f, 0.0f); } glRotatef(player->yRotO + (player->yRot - player->yRotO) * a + 180, 0, -1, 0); glRotatef(player->xRotO + (player->xRot - player->xRotO) * a, -1, 0, 0); @@ -493,7 +493,7 @@ void GameRenderer::moveCameraToPlayer(float a) float rotationY = thirdRotationO + (thirdRotation - thirdRotationO) * a; float xRot = thirdTiltO + (thirdTilt - thirdTiltO) * a; - glTranslatef(0, 0, (float) -cameraDist); + glTranslatef(0, 0, static_cast(-cameraDist)); glRotatef(xRot, 1, 0, 0); glRotatef(rotationY, 0, 1, 0); } @@ -522,9 +522,9 @@ void GameRenderer::moveCameraToPlayer(float a) for (int i = 0; i < 8; i++) { - float xo = (float)((i & 1) * 2 - 1); - float yo = (float)(((i >> 1) & 1) * 2 - 1); - float zo = (float)(((i >> 2) & 1) * 2 - 1); + float xo = static_cast((i & 1) * 2 - 1); + float yo = static_cast(((i >> 1) & 1) * 2 - 1); + float zo = static_cast(((i >> 2) & 1) * 2 - 1); xo *= 0.1f; yo *= 0.1f; @@ -540,7 +540,7 @@ void GameRenderer::moveCameraToPlayer(float a) } } - glTranslatef(0, 0, (float) -cameraDist); + glTranslatef(0, 0, static_cast(-cameraDist)); } } else @@ -595,7 +595,7 @@ void GameRenderer::getFovAndAspect(float& fov, float& aspect, float a, bool appl { // 4J - split out aspect ratio and fov here so we can adjust for viewports - we might need to revisit these as // they are maybe be too generous for performance. - aspect = mc->width / (float) mc->height; + aspect = mc->width / static_cast(mc->height); fov = getFov(a, applyEffects); if( ( mc->player->m_iScreenSection == C4JRender::VIEWPORT_TYPE_SPLIT_TOP ) || @@ -614,7 +614,7 @@ void GameRenderer::getFovAndAspect(float& fov, float& aspect, float a, bool appl void GameRenderer::setupCamera(float a, int eye) { - renderDistance = (float)(16 * 16 >> (mc->options->viewDistance)); + renderDistance = static_cast(16 * 16 >> (mc->options->viewDistance)); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -627,7 +627,7 @@ void GameRenderer::setupCamera(float a, int eye) if (zoom != 1) { - glTranslatef((float) zoom_x, (float) -zoom_y, 0); + glTranslatef(static_cast(zoom_x), static_cast(-zoom_y), 0); glScaled(zoom, zoom, 1); } gluPerspective(fov, aspect, 0.05f, renderDistance * 2); @@ -710,7 +710,7 @@ void GameRenderer::renderItemInHand(float a, int eye) if (zoom != 1) { - glTranslatef((float) zoom_x, (float) -zoom_y, 0); + glTranslatef(static_cast(zoom_x), static_cast(-zoom_y), 0); glScaled(zoom, zoom, 1); } gluPerspective(fov, aspect, 0.05f, renderDistance * 2); @@ -822,8 +822,8 @@ void GameRenderer::turnOnLightLayer(double alpha) // 4J - change brought forward from 1.8.2 void GameRenderer::tickLightTexture() { - blrt += (float)((Math::random() - Math::random()) * Math::random() * Math::random()); - blgt += (float)((Math::random() - Math::random()) * Math::random() * Math::random()); + blrt += static_cast((Math::random() - Math::random()) * Math::random() * Math::random()); + blgt += static_cast((Math::random() - Math::random()) * Math::random() * Math::random()); blrt *= 0.9; blgt *= 0.9; blr += (blrt - blr) * 1; @@ -1649,7 +1649,7 @@ void GameRenderer::tickRain() double rainPosZ = 0; int rainPosSamples = 0; - int rainCount = (int) (100 * rainLevel * rainLevel); + int rainCount = static_cast(100 * rainLevel * rainLevel); if (mc->options->particles == 1) { rainCount >>= 1; @@ -1864,11 +1864,11 @@ void GameRenderer::renderSnowAndRain(float a) t->begin(); } float ra = (((_tick) & 511) + a) / 512.0f; - float uo = random->nextFloat() + time * 0.01f * (float) random->nextGaussian(); - float vo = random->nextFloat() + time * (float) random->nextGaussian() * 0.001f; + float uo = random->nextFloat() + time * 0.01f * static_cast(random->nextGaussian()); + float vo = random->nextFloat() + time * static_cast(random->nextGaussian()) * 0.001f; double xd = (x + 0.5f) - player->x; double zd = (z + 0.5f) - player->z; - float dd = (float) sqrt(xd * xd + zd * zd) / r; + float dd = static_cast(sqrt(xd * xd + zd * zd)) / r; float br = 1; t->offset(-xo * 1, -yo * 1, -zo * 1); #ifdef __PSVITA__ @@ -1910,7 +1910,7 @@ void GameRenderer::setupGuiScreen(int forceScale /*=-1*/) glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0, (float)ssc.rawWidth, (float)ssc.rawHeight, 0, 1000, 3000); + glOrtho(0, static_cast(ssc.rawWidth), static_cast(ssc.rawHeight), 0, 1000, 3000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -2000); @@ -1922,22 +1922,22 @@ void GameRenderer::setupClearColor(float a) shared_ptr player = mc->cameraTargetPlayer; float whiteness = 1.0f / (4 - mc->options->viewDistance); - whiteness = 1 - (float) pow((double)whiteness, 0.25); + whiteness = 1 - static_cast(pow((double)whiteness, 0.25)); Vec3 *skyColor = level->getSkyColor(mc->cameraTargetPlayer, a); - float sr = (float) skyColor->x; - float sg = (float) skyColor->y; - float sb = (float) skyColor->z; + float sr = static_cast(skyColor->x); + float sg = static_cast(skyColor->y); + float sb = static_cast(skyColor->z); Vec3 *fogColor = level->getFogColor(a); - fr = (float) fogColor->x; - fg = (float) fogColor->y; - fb = (float) fogColor->z; + fr = static_cast(fogColor->x); + fg = static_cast(fogColor->y); + fb = static_cast(fogColor->z); if (mc->options->viewDistance < 2) { Vec3 *sunAngle = Mth::sin(level->getSunAngle(a)) > 0 ? Vec3::newTemp(-1, 0, 0) : Vec3::newTemp(1, 0, 0); - float d = (float) player->getViewVector(a)->dot(sunAngle); + float d = static_cast(player->getViewVector(a)->dot(sunAngle)); if (d < 0) d = 0; if (d > 0) { @@ -1978,9 +1978,9 @@ void GameRenderer::setupClearColor(float a) if (isInClouds) { Vec3 *cc = level->getCloudColor(a); - fr = (float) cc->x; - fg = (float) cc->y; - fb = (float) cc->z; + fr = static_cast(cc->x); + fg = static_cast(cc->y); + fb = static_cast(cc->z); } else if (t != 0 && Tile::tiles[t]->material == Material::water) { @@ -1991,9 +1991,9 @@ void GameRenderer::setupClearColor(float a) byte greenComponent = ((colour>>8)&0xFF); byte blueComponent = ((colour)&0xFF); - fr = (float)redComponent/256 + clearness;//0.02f; - fg = (float)greenComponent/256 + clearness;//0.02f; - fb = (float)blueComponent/256 + clearness;//0.2f; + fr = static_cast(redComponent)/256 + clearness;//0.02f; + fg = static_cast(greenComponent)/256 + clearness;//0.02f; + fb = static_cast(blueComponent)/256 + clearness;//0.2f; } else if (t != 0 && Tile::tiles[t]->material == Material::lava) { @@ -2002,9 +2002,9 @@ void GameRenderer::setupClearColor(float a) byte greenComponent = ((colour>>8)&0xFF); byte blueComponent = ((colour)&0xFF); - fr = (float)redComponent/256;//0.6f; - fg = (float)greenComponent/256;//0.1f; - fb = (float)blueComponent/256;//0.00f; + fr = static_cast(redComponent)/256;//0.6f; + fg = static_cast(greenComponent)/256;//0.1f; + fb = static_cast(blueComponent)/256;//0.00f; } float brr = fogBrO + (fogBr - fogBrO) * a; @@ -2019,7 +2019,7 @@ void GameRenderer::setupClearColor(float a) int duration = player->getEffect(MobEffect::blindness)->getDuration(); if (duration < 20) { - yy = yy * (1.0f - (float) duration / 20.0f); + yy = yy * (1.0f - static_cast(duration) / 20.0f); } else { @@ -2124,7 +2124,7 @@ void GameRenderer::setupFog(int i, float alpha) int duration = player->getEffect(MobEffect::blindness)->getDuration(); if (duration < 20) { - distance = 5.0f + (renderDistance - 5.0f) * (1.0f - (float) duration / 20.0f); + distance = 5.0f + (renderDistance - 5.0f) * (1.0f - static_cast(duration) / 20.0f); } glFogi(GL_FOG_MODE, GL_LINEAR); @@ -2179,7 +2179,7 @@ void GameRenderer::setupFog(int i, float alpha) { if (yy < 0) yy = 0; yy = yy * yy; - float dist = 100 * (float) yy; + float dist = 100 * static_cast(yy); if (dist < 5) dist = 5; if (distance > dist) distance = dist; } @@ -2206,7 +2206,7 @@ void GameRenderer::setupFog(int i, float alpha) } */ - if (mc->level->dimension->isFoggyAt((int) player->x, (int) player->z)) + if (mc->level->dimension->isFoggyAt(static_cast(player->x), static_cast(player->z))) { glFogf(GL_FOG_START, distance * 0.05f); glFogf(GL_FOG_END, min(distance, 16 * 16 * .75f) * .5f); diff --git a/Minecraft.Client/GhastModel.cpp b/Minecraft.Client/GhastModel.cpp index 14277c438..0a482e628 100644 --- a/Minecraft.Client/GhastModel.cpp +++ b/Minecraft.Client/GhastModel.cpp @@ -23,7 +23,7 @@ GhastModel::GhastModel() : Model() tentacles[i]->x = xo; tentacles[i]->z = yo; - tentacles[i]->y = (float)(31 + yoffs); + tentacles[i]->y = static_cast(31 + yoffs); } // 4J added - compile now to avoid random performance hit first time cubes are rendered diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index 1199c138e..44315340b 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -87,7 +87,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) int quickSelectHeight=22; float fScaleFactorWidth=1.0f,fScaleFactorHeight=1.0f; bool bTwoPlayerSplitscreen=false; - currentGuiScaleFactor = (float) guiScale; // Keep static copy of scale so we know how gui coordinates map to physical pixels - this is also affected by the viewport + currentGuiScaleFactor = static_cast(guiScale); // Keep static copy of scale so we know how gui coordinates map to physical pixels - this is also affected by the viewport switch(guiScale) { @@ -117,7 +117,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) iSafezoneYHalf = splitYOffset; iSafezoneTopYHalf = screenHeight/10; fScaleFactorWidth=0.5f; - iWidthOffset=(int)((float)screenWidth*(1.0f - fScaleFactorWidth)); + iWidthOffset=static_cast((float)screenWidth * (1.0f - fScaleFactorWidth)); iTooltipsYOffset=44; bTwoPlayerSplitscreen=true; currentGuiScaleFactor *= 0.5f; @@ -127,7 +127,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) iSafezoneYHalf = splitYOffset + screenHeight/10;// 5% (need to treat the whole screen is 2x this screen) iSafezoneTopYHalf = 0; fScaleFactorWidth=0.5f; - iWidthOffset=(int)((float)screenWidth*(1.0f - fScaleFactorWidth)); + iWidthOffset=static_cast((float)screenWidth * (1.0f - fScaleFactorWidth)); iTooltipsYOffset=44; bTwoPlayerSplitscreen=true; currentGuiScaleFactor *= 0.5f; @@ -697,7 +697,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) #endif glPushMatrix(); - glTranslatef((float)xo, (float)yo, 50); + glTranslatef(static_cast(xo), static_cast(yo), 50); float ss = 12; glScalef(-ss, ss, ss); glRotatef(180, 0, 0, 1); @@ -806,14 +806,14 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) glDisable(GL_DEPTH_TEST); glDisable(GL_ALPHA_TEST); int timer = minecraft->player->getSleepTimer(); - float amount = (float) timer / (float) Player::SLEEP_DURATION; + float amount = static_cast(timer) / static_cast(Player::SLEEP_DURATION); if (amount > 1) { // waking up - amount = 1.0f - ((float) (timer - Player::SLEEP_DURATION) / (float) Player::WAKE_UP_DURATION); + amount = 1.0f - (static_cast(timer - Player::SLEEP_DURATION) / static_cast(Player::WAKE_UP_DURATION)); } - int color = (int) (220.0f * amount) << 24 | (0x101020); + int color = static_cast(220.0f * amount) << 24 | (0x101020); fill(0, 0, screenWidth/fScaleFactorWidth, screenHeight/fScaleFactorHeight, color); glEnable(GL_ALPHA_TEST); glEnable(GL_DEPTH_TEST); @@ -825,9 +825,9 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) glDisable(GL_DEPTH_TEST); glDisable(GL_ALPHA_TEST); int timer = minecraft->player->getDeathFadeTimer(); - float amount = (float) timer / (float) Player::DEATHFADE_DURATION; + float amount = static_cast(timer) / static_cast(Player::DEATHFADE_DURATION); - int color = (int) (220.0f * amount) << 24 | (0x200000); + int color = static_cast(220.0f * amount) << 24 | (0x200000); fill(0, 0, screenWidth/fScaleFactorWidth, screenHeight/fScaleFactorHeight, color); glEnable(GL_ALPHA_TEST); glEnable(GL_DEPTH_TEST); @@ -875,7 +875,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) wfeature[pFeatureData->eTerrainFeature] += itemInfo; } - for( int i = eTerrainFeature_Stronghold; i < (int) eTerrainFeature_Count; i++ ) + for( int i = eTerrainFeature_Stronghold; i < static_cast(eTerrainFeature_Count); i++ ) { font->drawShadow(wfeature[i], iSafezoneXHalf + 2, iYPos, 0xffffff); iYPos+=10; @@ -1135,10 +1135,10 @@ void Gui::renderPumpkin(int w, int h) MemSect(0); Tesselator *t = Tesselator::getInstance(); t->begin(); - t->vertexUV((float)(0), (float)( h), (float)( -90), (float)( 0), (float)( 1)); - t->vertexUV((float)(w), (float)( h), (float)( -90), (float)( 1), (float)( 1)); - t->vertexUV((float)(w), (float)( 0), (float)( -90), (float)( 1), (float)( 0)); - t->vertexUV((float)(0), (float)( 0), (float)( -90), (float)( 0), (float)( 0)); + t->vertexUV(static_cast(0), static_cast(h), static_cast(-90), static_cast(0), static_cast(1)); + t->vertexUV(static_cast(w), static_cast(h), static_cast(-90), static_cast(1), static_cast(1)); + t->vertexUV(static_cast(w), static_cast(0), static_cast(-90), static_cast(1), static_cast(0)); + t->vertexUV(static_cast(0), static_cast(0), static_cast(-90), static_cast(0), static_cast(0)); t->end(); glDepthMask(true); glEnable(GL_DEPTH_TEST); @@ -1199,10 +1199,10 @@ void Gui::renderTp(float br, int w, int h) float v1 = slot->getV1(); Tesselator *t = Tesselator::getInstance(); t->begin(); - t->vertexUV((float)(0), (float)( h), (float)( -90), (float)( u0), (float)( v1)); - t->vertexUV((float)(w), (float)( h), (float)( -90), (float)( u1), (float)( v1)); - t->vertexUV((float)(w), (float)( 0), (float)( -90), (float)( u1), (float)( v0)); - t->vertexUV((float)(0), (float)( 0), (float)( -90), (float)( u0), (float)( v0)); + t->vertexUV(static_cast(0), static_cast(h), static_cast(-90), (float)( u0), (float)( v1)); + t->vertexUV(static_cast(w), static_cast(h), static_cast(-90), (float)( u1), (float)( v1)); + t->vertexUV(static_cast(w), static_cast(0), static_cast(-90), (float)( u1), (float)( v0)); + t->vertexUV(static_cast(0), static_cast(0), static_cast(-90), (float)( u0), (float)( v0)); t->end(); glDepthMask(true); glEnable(GL_DEPTH_TEST); @@ -1220,10 +1220,10 @@ void Gui::renderSlot(int slot, int x, int y, float a) if (pop > 0) { glPushMatrix(); - float squeeze = 1 + pop / (float) Inventory::POP_TIME_DURATION; - glTranslatef((float)(x + 8), (float)(y + 12), 0); + float squeeze = 1 + pop / static_cast(Inventory::POP_TIME_DURATION); + glTranslatef(static_cast(x + 8), static_cast(y + 12), 0); glScalef(1 / squeeze, (squeeze + 1) / 2, 1); - glTranslatef((float)-(x + 8), (float)-(y + 12), 0); + glTranslatef(static_cast(-(x + 8)), static_cast(-(y + 12)), 0); } itemRenderer->renderAndDecorateItem(minecraft->font, minecraft->textures, item, x, y); @@ -1362,7 +1362,7 @@ void Gui::addMessage(const wstring& _string,int iPad,bool bIsDeathMessage) { i++; } - int iLast=(int)string.find_last_of(L" ",i); + int iLast=static_cast(string.find_last_of(L" ", i)); switch(XGetLanguage()) { case XC_LANGUAGE_JAPANESE: @@ -1371,7 +1371,7 @@ void Gui::addMessage(const wstring& _string,int iPad,bool bIsDeathMessage) iLast = maximumChars; break; default: - iLast=(int)string.find_last_of(L" ",i); + iLast=static_cast(string.find_last_of(L" ", i)); break; } @@ -1431,7 +1431,7 @@ float Gui::getOpacity(int iPad, DWORD index) float Gui::getJukeboxOpacity(int iPad) { float t = overlayMessageTime - lastTickA; - int alpha = (int) (t * 256 / 20); + int alpha = static_cast(t * 256 / 20); if (alpha > 255) alpha = 255; alpha /= 255; @@ -1465,7 +1465,7 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64 *dataA, float dataASc glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0, (float)minecraft->width, (float)height, 0, 1000, 3000); + glOrtho(0, static_cast(minecraft->width), static_cast(height), 0, 1000, 3000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -2000); @@ -1496,8 +1496,8 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64 *dataA, float dataASc __int64 aVal = dataA[i] / dataAScale; - t->vertex((float)(xScale*i + 0.5f), (float)( height - aVal + 0.5f), (float)( 0)); - t->vertex((float)(xScale*i + 0.5f), (float)( height + 0.5f), (float)( 0)); + t->vertex((float)(xScale*i + 0.5f), (float)( height - aVal + 0.5f), static_cast(0)); + t->vertex((float)(xScale*i + 0.5f), (float)( height + 0.5f), static_cast(0)); } if( dataB != NULL ) @@ -1513,8 +1513,8 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64 *dataA, float dataASc __int64 bVal = dataB[i] / dataBScale; - t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height - bVal + 0.5f), (float)( 0)); - t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height + 0.5f), (float)( 0)); + t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height - bVal + 0.5f), static_cast(0)); + t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height + 0.5f), static_cast(0)); } } t->end(); @@ -1529,7 +1529,7 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, __int glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0, (float)minecraft->width, (float)height, 0, 1000, 3000); + glOrtho(0, static_cast(minecraft->width), static_cast(height), 0, 1000, 3000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -2000); @@ -1558,15 +1558,15 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, __int if( thisVal > 0 ) { - float vary = (float)source/dataSources; + float vary = static_cast(source)/dataSources; int fColour = floor(vary * 0xffffff); int colour = 0xff000000 + fColour; //printf("Colour is %x\n", colour); t->color(colour); - t->vertex((float)(i + 0.5f), (float)( height - topVal - thisVal + 0.5f), (float)( 0)); - t->vertex((float)(i + 0.5f), (float)( height - topVal + 0.5f), (float)( 0)); + t->vertex((float)(i + 0.5f), (float)( height - topVal - thisVal + 0.5f), static_cast(0)); + t->vertex((float)(i + 0.5f), (float)( height - topVal + 0.5f), static_cast(0)); topVal += thisVal; } @@ -1577,8 +1577,8 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, __int { t->color(0xff000000); - t->vertex((float)(0 + 0.5f), (float)( height - (horiz*100) + 0.5f), (float)( 0)); - t->vertex((float)(dataLength + 0.5f), (float)( height - (horiz*100) + 0.5f), (float)( 0)); + t->vertex((float)(0 + 0.5f), (float)( height - (horiz*100) + 0.5f), static_cast(0)); + t->vertex((float)(dataLength + 0.5f), (float)( height - (horiz*100) + 0.5f), static_cast(0)); } } t->end(); diff --git a/Minecraft.Client/Gui.h b/Minecraft.Client/Gui.h index 9352308f3..b6b15b13c 100644 --- a/Minecraft.Client/Gui.h +++ b/Minecraft.Client/Gui.h @@ -59,7 +59,7 @@ class Gui : public GuiComponent void displayClientMessage(int messageId, int iPad); // 4J Added - DWORD getMessagesCount(int iPad) { return (int)guiMessages[iPad].size(); } + DWORD getMessagesCount(int iPad) { return static_cast(guiMessages[iPad].size()); } wstring getMessage(int iPad, DWORD index) { return guiMessages[iPad].at(index).string; } float getOpacity(int iPad, DWORD index); diff --git a/Minecraft.Client/GuiComponent.cpp b/Minecraft.Client/GuiComponent.cpp index 92abf36db..5986c05d6 100644 --- a/Minecraft.Client/GuiComponent.cpp +++ b/Minecraft.Client/GuiComponent.cpp @@ -48,10 +48,10 @@ void GuiComponent::fill(int x0, int y0, int x1, int y1, int col) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(r, g, b, a); t->begin(); - t->vertex((float)(x0), (float)( y1), (float)( 0)); - t->vertex((float)(x1), (float)( y1), (float)( 0)); - t->vertex((float)(x1), (float)( y0), (float)( 0)); - t->vertex((float)(x0), (float)( y0), (float)( 0)); + t->vertex(static_cast(x0), static_cast(y1), static_cast(0)); + t->vertex(static_cast(x1), static_cast(y1), static_cast(0)); + t->vertex(static_cast(x1), static_cast(y0), static_cast(0)); + t->vertex(static_cast(x0), static_cast(y0), static_cast(0)); t->end(); glEnable(GL_TEXTURE_2D); glDisable(GL_BLEND); @@ -77,11 +77,11 @@ void GuiComponent::fillGradient(int x0, int y0, int x1, int y1, int col1, int co Tesselator *t = Tesselator::getInstance(); t->begin(); t->color(r1, g1, b1, a1); - t->vertex((float)(x1), (float)( y0), blitOffset); - t->vertex((float)(x0), (float)( y0), blitOffset); + t->vertex(static_cast(x1), static_cast(y0), blitOffset); + t->vertex(static_cast(x0), static_cast(y0), blitOffset); t->color(r2, g2, b2, a2); - t->vertex((float)(x0), (float)( y1), blitOffset); - t->vertex((float)(x1), (float)( y1), blitOffset); + t->vertex(static_cast(x0), static_cast(y1), blitOffset); + t->vertex(static_cast(x1), static_cast(y1), blitOffset); t->end(); glShadeModel(GL_FLAT); @@ -117,16 +117,16 @@ void GuiComponent::blit(int x, int y, int sx, int sy, int w, int h) const float extraShift = 0.75f; // 4J - subtracting extraShift (actual screen pixels, so need to compensate for physical & game width) from each x & y coordinate to compensate for centre of pixels in directx vs openGL - float dx = ( extraShift * (float)Minecraft::GetInstance()->width ) / (float)Minecraft::GetInstance()->width_phys; + float dx = ( extraShift * static_cast(Minecraft::GetInstance()->width) ) / static_cast(Minecraft::GetInstance()->width_phys); // 4J - Also factor in the scaling from gui coordinate space to the screen. This varies based on user-selected gui scale, and whether we are in a viewport mode or not dx /= Gui::currentGuiScaleFactor; float dy = extraShift / Gui::currentGuiScaleFactor; // Ensure that the x/y, width and height are actually pixel aligned at our current scale factor - in particular, for split screen mode with the default (3X) // scale, we have an overall scale factor of 3 * 0.5 = 1.5, and so any odd pixels won't align - float fx = (floorf((float)x * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; - float fy = (floorf((float)y * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; - float fw = (floorf((float)w * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; - float fh = (floorf((float)h * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; + float fx = (floorf(static_cast(x) * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; + float fy = (floorf(static_cast(y) * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; + float fw = (floorf(static_cast(w) * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; + float fh = (floorf(static_cast(h) * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; t->vertexUV(fx + 0 - dx, fy + fh - dy, (float)( blitOffset), (float)( (sx + 0) * us), (float)( (sy + h) * vs)); t->vertexUV(fx + fw - dx, fy + fh - dy, (float)( blitOffset), (float)( (sx + w) * us), (float)( (sy + h) * vs)); diff --git a/Minecraft.Client/GuiParticle.cpp b/Minecraft.Client/GuiParticle.cpp index 25859c707..1e6bcc708 100644 --- a/Minecraft.Client/GuiParticle.cpp +++ b/Minecraft.Client/GuiParticle.cpp @@ -24,7 +24,7 @@ GuiParticle::GuiParticle(double x, double y, double xa, double ya) friction = 1.0 / (random->nextDouble() * 0.05 + 1.01); - lifeTime = (int) (10.0 / (random->nextDouble() * 2 + 0.1)); + lifeTime = static_cast(10.0 / (random->nextDouble() * 2 + 0.1)); } void GuiParticle::tick(GuiParticles *guiParticles) @@ -37,7 +37,7 @@ void GuiParticle::tick(GuiParticles *guiParticles) ya += 0.1; if (++life > lifeTime) remove(); - a = 2 - (life / (double) lifeTime) * 2; + a = 2 - (life / static_cast(lifeTime)) * 2; if (a > 1) a = 1; a = a * a; a *= 0.5; diff --git a/Minecraft.Client/HugeExplosionParticle.cpp b/Minecraft.Client/HugeExplosionParticle.cpp index 2a104c19e..276b1d160 100644 --- a/Minecraft.Client/HugeExplosionParticle.cpp +++ b/Minecraft.Client/HugeExplosionParticle.cpp @@ -25,12 +25,12 @@ HugeExplosionParticle::HugeExplosionParticle(Textures *textures, Level *level, d gCol = g * br; bCol = b * br; - size = 1 - (float) xa * 0.5f; + size = 1 - static_cast(xa) * 0.5f; } void HugeExplosionParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) { - int tex = (int) ((life + a) * 15 / lifeTime); + int tex = static_cast((life + a) * 15 / lifeTime); if (tex > 15) return; textures->bindTexture(&EXPLOSION_LOCATION); @@ -41,9 +41,9 @@ void HugeExplosionParticle::render(Tesselator *t, float a, float xa, float ya, f float r = 2.0f * size; - float x = (float) (xo + (this->x - xo) * a - xOff); - float y = (float) (yo + (this->y - yo) * a - yOff); - float z = (float) (zo + (this->z - zo) * a - zOff); + float x = static_cast(xo + (this->x - xo) * a - xOff); + float y = static_cast(yo + (this->y - yo) * a - yOff); + float z = static_cast(zo + (this->z - zo) * a - zOff); // 4J - don't render explosion particles that are less than 3 metres away, to try and avoid large particles that are causing us problems with photosensitivity testing float distSq = (x*x + y*y + z*z); diff --git a/Minecraft.Client/HugeExplosionSeedParticle.cpp b/Minecraft.Client/HugeExplosionSeedParticle.cpp index 7514cc44f..67d68d460 100644 --- a/Minecraft.Client/HugeExplosionSeedParticle.cpp +++ b/Minecraft.Client/HugeExplosionSeedParticle.cpp @@ -24,7 +24,7 @@ void HugeExplosionSeedParticle::tick() double xx = x + (random->nextDouble() - random->nextDouble()) * 4; double yy = y + (random->nextDouble() - random->nextDouble()) * 4; double zz = z + (random->nextDouble() - random->nextDouble()) * 4; - level->addParticle(eParticleType_largeexplode, xx, yy, zz, life / (float) lifeTime, 0, 0); + level->addParticle(eParticleType_largeexplode, xx, yy, zz, life / static_cast(lifeTime), 0, 0); } Minecraft::GetInstance()->animateTickLevel = NULL; life++; diff --git a/Minecraft.Client/HumanoidMobRenderer.cpp b/Minecraft.Client/HumanoidMobRenderer.cpp index 5329f2d9c..2d513875c 100644 --- a/Minecraft.Client/HumanoidMobRenderer.cpp +++ b/Minecraft.Client/HumanoidMobRenderer.cpp @@ -126,9 +126,9 @@ int HumanoidMobRenderer::prepareArmor(shared_ptr _mob, int layer, if (armorItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH) { int color = armorItem->getColor(itemInstance); - float red = (float) ((color >> 16) & 0xFF) / 0xFF; - float green = (float) ((color >> 8) & 0xFF) / 0xFF; - float blue = (float) (color & 0xFF) / 0xFF; + float red = static_cast((color >> 16) & 0xFF) / 0xFF; + float green = static_cast((color >> 8) & 0xFF) / 0xFF; + float blue = static_cast(color & 0xFF) / 0xFF; glColor3f(brightness * red, brightness * green, brightness * blue); if (itemInstance->isEnchanted()) return 0x1f; diff --git a/Minecraft.Client/HumanoidModel.cpp b/Minecraft.Client/HumanoidModel.cpp index 05d132fae..1e76f45a6 100644 --- a/Minecraft.Client/HumanoidModel.cpp +++ b/Minecraft.Client/HumanoidModel.cpp @@ -37,7 +37,7 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) if(pNewBox) { - if((pNewBox->getfU()!=(int)pBox->fU) || (pNewBox->getfV()!=(int)pBox->fV)) + if((pNewBox->getfU()!=static_cast(pBox->fU)) || (pNewBox->getfV()!=static_cast(pBox->fV))) { app.DebugPrintf("HumanoidModel::AddOrRetrievePart - Box geometry was found, but with different uvs\n"); pNewBox=NULL; @@ -47,7 +47,7 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) { //app.DebugPrintf("HumanoidModel::AddOrRetrievePart - Adding box to model part\n"); - pNewBox = new ModelPart(this, (int)pBox->fU, (int)pBox->fV); + pNewBox = new ModelPart(this, static_cast(pBox->fU), static_cast(pBox->fV)); pNewBox->visible=false; pNewBox->addHumanoidBox(pBox->fX, pBox->fY, pBox->fZ, pBox->fW, pBox->fH, pBox->fD, 0); // 4J-PB - don't compile here, since the lighting isn't set up. It'll be compiled on first use. diff --git a/Minecraft.Client/Input.cpp b/Minecraft.Client/Input.cpp index 1fd676836..cbcd317f6 100644 --- a/Minecraft.Client/Input.cpp +++ b/Minecraft.Client/Input.cpp @@ -137,9 +137,9 @@ void Input::tick(LocalPlayer *player) float ty = 0.0f; if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_RIGHT) ) - tx = InputManager.GetJoypadStick_RX(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look + tx = InputManager.GetJoypadStick_RX(iPad)*(static_cast(app.GetGameSettings(iPad, eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_UP) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_DOWN) ) - ty = InputManager.GetJoypadStick_RY(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look + ty = InputManager.GetJoypadStick_RY(iPad)*(static_cast(app.GetGameSettings(iPad, eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look #ifndef _CONTENT_PACKAGE if (app.GetFreezePlayers()) tx = ty = 0.0f; @@ -166,7 +166,7 @@ void Input::tick(LocalPlayer *player) #ifdef _WINDOWS64 if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive()) { - float mouseSensitivity = ((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame)) / 100.0f; + float mouseSensitivity = static_cast(app.GetGameSettings(iPad, eGameSetting_Sensitivity_InGame)) / 100.0f; float mouseLookScale = 5.0f; float mx = g_KBMInput.GetLookX(mouseSensitivity * mouseLookScale); float my = g_KBMInput.GetLookY(mouseSensitivity * mouseLookScale); diff --git a/Minecraft.Client/InventoryScreen.cpp b/Minecraft.Client/InventoryScreen.cpp index 726a5e8dc..b6728533c 100644 --- a/Minecraft.Client/InventoryScreen.cpp +++ b/Minecraft.Client/InventoryScreen.cpp @@ -31,8 +31,8 @@ void InventoryScreen::renderLabels() void InventoryScreen::render(int xm, int ym, float a) { AbstractContainerScreen::render(xm, ym, a); - this->xMouse = (float)xm; - this->yMouse = (float)ym; + this->xMouse = static_cast(xm); + this->yMouse = static_cast(ym); } void InventoryScreen::renderBg(float a) diff --git a/Minecraft.Client/ItemFrameRenderer.cpp b/Minecraft.Client/ItemFrameRenderer.cpp index 2d7493ecb..54633deb3 100644 --- a/Minecraft.Client/ItemFrameRenderer.cpp +++ b/Minecraft.Client/ItemFrameRenderer.cpp @@ -33,15 +33,15 @@ void ItemFrameRenderer::render(shared_ptr _itemframe, double x, double shared_ptr itemFrame = dynamic_pointer_cast(_itemframe); glPushMatrix(); - float xOffs = (float) (itemFrame->x - x) - 0.5f; - float yOffs = (float) (itemFrame->y - y) - 0.5f; - float zOffs = (float) (itemFrame->z - z) - 0.5f; + float xOffs = static_cast(itemFrame->x - x) - 0.5f; + float yOffs = static_cast(itemFrame->y - y) - 0.5f; + float zOffs = static_cast(itemFrame->z - z) - 0.5f; int xt = itemFrame->xTile + Direction::STEP_X[itemFrame->dir]; int yt = itemFrame->yTile; int zt = itemFrame->zTile + Direction::STEP_Z[itemFrame->dir]; - glTranslatef((float) xt - xOffs, (float) yt - yOffs, (float) zt - zOffs); + glTranslatef(static_cast(xt) - xOffs, static_cast(yt) - yOffs, static_cast(zt) - zOffs); drawFrame(itemFrame); drawItem(itemFrame); @@ -168,7 +168,7 @@ void ItemFrameRenderer::drawItem(shared_ptr entity) double compassRotA = ct->rota; ct->rot = 0; ct->rota = 0; - ct->updateFromPosition(entity->level, entity->x, entity->z, Mth::wrapDegrees( (float)(180 + entity->dir * 90) ), false, true); + ct->updateFromPosition(entity->level, entity->x, entity->z, Mth::wrapDegrees( static_cast(180 + entity->dir * 90) ), false, true); ct->rot = compassRot; ct->rota = compassRotA; } diff --git a/Minecraft.Client/ItemInHandRenderer.cpp b/Minecraft.Client/ItemInHandRenderer.cpp index 782537051..b7aa4f8b5 100644 --- a/Minecraft.Client/ItemInHandRenderer.cpp +++ b/Minecraft.Client/ItemInHandRenderer.cpp @@ -481,13 +481,13 @@ void ItemInHandRenderer::render(float a) glPushMatrix(); glTranslatef(-0.0f, -0.6f, 1.1f * flip); - glRotatef((float)(-45 * flip), 1, 0, 0); + glRotatef(static_cast(-45 * flip), 1, 0, 0); glRotatef(-90, 0, 0, 1); glRotatef(59, 0, 0, 1); - glRotatef((float)(-65 * flip), 0, 1, 0); + glRotatef(static_cast(-65 * flip), 0, 1, 0); EntityRenderer *er = EntityRenderDispatcher::instance->getRenderer(minecraft->player); - PlayerRenderer *playerRenderer = (PlayerRenderer *) er; + PlayerRenderer *playerRenderer = static_cast(er); float ss = 1; glScalef(ss, ss, ss); @@ -530,10 +530,10 @@ void ItemInHandRenderer::render(float a) t->begin(); int vo = 7; t->normal(0,0,-1); - t->vertexUV((float)(0 - vo), (float)( 128 + vo), (float)( 0), (float)( 0), (float)( 1)); - t->vertexUV((float)(128 + vo), (float)( 128 + vo), (float)( 0), (float)( 1), (float)( 1)); - t->vertexUV((float)(128 + vo), (float)( 0 - vo), (float)( 0), (float)( 1), (float)( 0)); - t->vertexUV((float)(0 - vo), (float)( 0 - vo), (float)( 0), (float)( 0), (float)( 0)); + t->vertexUV(static_cast(0 - vo), static_cast(128 + vo), static_cast(0), static_cast(0), static_cast(1)); + t->vertexUV(static_cast(128 + vo), static_cast(128 + vo), static_cast(0), static_cast(1), static_cast(1)); + t->vertexUV(static_cast(128 + vo), static_cast(0 - vo), static_cast(0), static_cast(1), static_cast(0)); + t->vertexUV(static_cast(0 - vo), static_cast(0 - vo), static_cast(0), static_cast(0), static_cast(0)); t->end(); shared_ptr data = Item::map->getSavedData(item, minecraft->level); @@ -617,7 +617,7 @@ void ItemInHandRenderer::render(float a) glRotatef(-8, 1, 0, 0); glTranslatef(-0.9f, 0.2f, 0.0f); float timeHeld = (item->getUseDuration() - (player->getUseItemDuration() - a + 1)); - float pow = timeHeld / (float) (BowItem::MAX_DRAW_DURATION); + float pow = timeHeld / static_cast(BowItem::MAX_DRAW_DURATION); pow = ((pow * pow) + pow * 2) / 3; if (pow > 1) pow = 1; if (pow > 0.1f) @@ -706,7 +706,7 @@ void ItemInHandRenderer::render(float a) glTranslatef(5.6f, 0, 0); EntityRenderer *er = EntityRenderDispatcher::instance->getRenderer(minecraft->player); - PlayerRenderer *playerRenderer = (PlayerRenderer *) er; + PlayerRenderer *playerRenderer = static_cast(er); float ss = 1; glScalef(ss, ss, ss); MemSect(31); diff --git a/Minecraft.Client/ItemRenderer.cpp b/Minecraft.Client/ItemRenderer.cpp index 6fb7e633d..849195a65 100644 --- a/Minecraft.Client/ItemRenderer.cpp +++ b/Minecraft.Client/ItemRenderer.cpp @@ -77,7 +77,7 @@ void ItemRenderer::render(shared_ptr _itemEntity, double x, double y, do if (itemEntity->getItem()->count > 20) count = 4; if (itemEntity->getItem()->count > 40) count = 5; - glTranslatef((float) x, (float) y + bob, (float) z); + glTranslatef(static_cast(x), static_cast(y) + bob, static_cast(z)); glEnable(GL_RESCALE_NORMAL); Tile *tile = Tile::tiles[item->id]; @@ -332,10 +332,10 @@ void ItemRenderer::renderItemBillboard(shared_ptr entity, Icon *icon glColor4f(red, green, blue, 1); t->begin(); t->normal(0, 1, 0); - t->vertexUV((float)(0 - xo), (float)( 0 - yo), (float)( 0), (float)( u0), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 0 - yo), (float)( 0), (float)( u1), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 1 - yo), (float)( 0), (float)( u1), (float)( v0)); - t->vertexUV((float)(0 - xo), (float)( 1 - yo), (float)( 0), (float)( u0), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 0 - yo), static_cast(0), (float)( u0), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 0 - yo), static_cast(0), (float)( u1), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 1 - yo), static_cast(0), (float)( u1), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 1 - yo), static_cast(0), (float)( u0), (float)( v0)); t->end(); glPopMatrix(); @@ -416,7 +416,7 @@ void ItemRenderer::renderGuiItem(Font *font, Textures *textures, shared_ptr(x), static_cast(y), fillingIcon, 16, 16); } } glEnable(GL_LIGHTING); @@ -462,7 +462,7 @@ void ItemRenderer::renderGuiItem(Font *font, Textures *textures, shared_ptr(x), static_cast(y), itemIcon, 16, 16); } glEnable(GL_LIGHTING); PIXEndNamedEvent(); @@ -475,7 +475,7 @@ void ItemRenderer::renderGuiItem(Font *font, Textures *textures, shared_ptr item, int x, int y) { - renderGuiItem(font, textures, item, (float)x, (float)y, 1.0f, 1.0f ); + renderGuiItem(font, textures, item, static_cast(x), static_cast(y), 1.0f, 1.0f ); } // 4J - this used to take x and y as ints, and no scale, alpha or foil - but this interface is now implemented as a wrapper round this more fully featured one @@ -535,7 +535,7 @@ void ItemRenderer::renderAndDecorateItem(Font *font, Textures *textures, const s // 4J - original interface, now just a wrapper for preceding overload void ItemRenderer::renderAndDecorateItem(Font *font, Textures *textures, const shared_ptr item, int x, int y) { - renderAndDecorateItem( font, textures, item, (float)x, (float)y, 1.0f, 1.0f, item->isFoil() ); + renderAndDecorateItem( font, textures, item, static_cast(x), static_cast(y), 1.0f, 1.0f, item->isFoil() ); } // 4J - a few changes here to get x, y, w, h in as floats (for xui rendering accuracy), and to align @@ -546,8 +546,8 @@ void ItemRenderer::blitGlint(int id, float x, float y, float w, float h) float vs = 1.0f / 64.0f / 4; // 4J - calculate what the pixel coordinates will be in final screen coordinates - float sfx = (float)Minecraft::GetInstance()->width / (float)Minecraft::GetInstance()->width_phys; - float sfy = (float)Minecraft::GetInstance()->height / (float)Minecraft::GetInstance()->height_phys; + float sfx = static_cast(Minecraft::GetInstance()->width) / static_cast(Minecraft::GetInstance()->width_phys); + float sfy = static_cast(Minecraft::GetInstance()->height) / static_cast(Minecraft::GetInstance()->height_phys); float xx0 = x * sfx; float xx1 = ( x + w ) * sfx; float yy0 = y * sfy; @@ -617,15 +617,15 @@ void ItemRenderer::renderGuiItemDecorations(Font *font, Textures *textures, shar MemSect(0); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); - font->drawShadow(amount, x + 19 - 2 - font->width(amount), y + 6 + 3, 0xffffff |(((unsigned int)(fAlpha * 0xff))<<24)); + font->drawShadow(amount, x + 19 - 2 - font->width(amount), y + 6 + 3, 0xffffff |(static_cast(fAlpha * 0xff)<<24)); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); } if (item->isDamaged()) { - int p = (int) Math::round(13.0 - (double) item->getDamageValue() * 13.0 / (double) item->getMaxDamage()); - int cc = (int) Math::round(255.0 - (double) item->getDamageValue() * 255.0 / (double) item->getMaxDamage()); + int p = static_cast(Math::round(13.0 - (double)item->getDamageValue() * 13.0 / (double)item->getMaxDamage())); + int cc = static_cast(Math::round(255.0 - (double)item->getDamageValue() * 255.0 / (double)item->getMaxDamage())); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glDisable(GL_TEXTURE_2D); @@ -676,10 +676,10 @@ void ItemRenderer::fillRect(Tesselator *t, int x, int y, int w, int h, int c) { t->begin(); t->color(c); - t->vertex((float)(x + 0), (float)( y + 0), (float)( 0)); - t->vertex((float)(x + 0), (float)( y + h), (float)( 0)); - t->vertex((float)(x + w), (float)( y + h), (float)( 0)); - t->vertex((float)(x + w), (float)( y + 0), (float)( 0)); + t->vertex(static_cast(x + 0), static_cast(y + 0), static_cast(0)); + t->vertex(static_cast(x + 0), static_cast(y + h), static_cast(0)); + t->vertex(static_cast(x + w), static_cast(y + h), static_cast(0)); + t->vertex(static_cast(x + w), static_cast(y + 0), static_cast(0)); t->end(); } @@ -693,8 +693,8 @@ void ItemRenderer::blit(float x, float y, int sx, int sy, float w, float h) t->begin(); // 4J - calculate what the pixel coordinates will be in final screen coordinates - float sfx = (float)Minecraft::GetInstance()->width / (float)Minecraft::GetInstance()->width_phys; - float sfy = (float)Minecraft::GetInstance()->height / (float)Minecraft::GetInstance()->height_phys; + float sfx = static_cast(Minecraft::GetInstance()->width) / static_cast(Minecraft::GetInstance()->width_phys); + float sfy = static_cast(Minecraft::GetInstance()->height) / static_cast(Minecraft::GetInstance()->height_phys); float xx0 = x * sfx; float xx1 = ( x + w ) * sfx; float yy0 = y * sfy; @@ -716,7 +716,7 @@ void ItemRenderer::blit(float x, float y, int sx, int sy, float w, float h) float yy1f = yy1 / sfy; // 4J - subtracting 0.5f (actual screen pixels, so need to compensate for physical & game width) from each x & y coordinate to compensate for centre of pixels in directx vs openGL - float f = ( 0.5f * (float)Minecraft::GetInstance()->width ) / (float)Minecraft::GetInstance()->width_phys; + float f = ( 0.5f * static_cast(Minecraft::GetInstance()->width) ) / static_cast(Minecraft::GetInstance()->width_phys); t->vertexUV(xx0f, yy1f, (float)( blitOffset), (float)( (sx + 0) * us), (float)( (sy + 16) * vs)); t->vertexUV(xx1f, yy1f, (float)( blitOffset), (float)( (sx + 16) * us), (float)( (sy + 16) * vs)); @@ -731,8 +731,8 @@ void ItemRenderer::blit(float x, float y, Icon *tex, float w, float h) t->begin(); // 4J - calculate what the pixel coordinates will be in final screen coordinates - float sfx = (float)Minecraft::GetInstance()->width / (float)Minecraft::GetInstance()->width_phys; - float sfy = (float)Minecraft::GetInstance()->height / (float)Minecraft::GetInstance()->height_phys; + float sfx = static_cast(Minecraft::GetInstance()->width) / static_cast(Minecraft::GetInstance()->width_phys); + float sfy = static_cast(Minecraft::GetInstance()->height) / static_cast(Minecraft::GetInstance()->height_phys); float xx0 = x * sfx; float xx1 = ( x + w ) * sfx; float yy0 = y * sfy; @@ -754,7 +754,7 @@ void ItemRenderer::blit(float x, float y, Icon *tex, float w, float h) float yy1f = yy1 / sfy; // 4J - subtracting 0.5f (actual screen pixels, so need to compensate for physical & game width) from each x & y coordinate to compensate for centre of pixels in directx vs openGL - float f = ( 0.5f * (float)Minecraft::GetInstance()->width ) / (float)Minecraft::GetInstance()->width_phys; + float f = ( 0.5f * static_cast(Minecraft::GetInstance()->width) ) / static_cast(Minecraft::GetInstance()->width_phys); t->vertexUV(xx0f, yy1f, blitOffset, tex->getU0(true), tex->getV1(true)); t->vertexUV(xx1f, yy1f, blitOffset, tex->getU1(true), tex->getV1(true)); diff --git a/Minecraft.Client/ItemSpriteRenderer.cpp b/Minecraft.Client/ItemSpriteRenderer.cpp index 5f1c7089b..b8a4a3770 100644 --- a/Minecraft.Client/ItemSpriteRenderer.cpp +++ b/Minecraft.Client/ItemSpriteRenderer.cpp @@ -29,7 +29,7 @@ void ItemSpriteRenderer::render(shared_ptr e, double x, double y, double glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); glEnable(GL_RESCALE_NORMAL); glScalef(1 / 2.0f, 1 / 2.0f, 1 / 2.0f); bindTexture(e); @@ -72,10 +72,10 @@ void ItemSpriteRenderer::renderIcon(Tesselator *t, Icon *icon) glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); t->begin(); t->normal(0, 1, 0); - t->vertexUV((float)(0 - xo), (float)( 0 - yo), (float)( 0), (float)( u0), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( 0 - yo), (float)( 0), (float)( u1), (float)( v1)); - t->vertexUV((float)(r - xo), (float)( r - yo), (float)( 0), (float)( u1), (float)( v0)); - t->vertexUV((float)(0 - xo), (float)( r - yo), (float)( 0), (float)( u0), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( 0 - yo), static_cast(0), (float)( u0), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( 0 - yo), static_cast(0), (float)( u1), (float)( v1)); + t->vertexUV((float)(r - xo), (float)( r - yo), static_cast(0), (float)( u1), (float)( v0)); + t->vertexUV((float)(0 - xo), (float)( r - yo), static_cast(0), (float)( u0), (float)( v0)); t->end(); } diff --git a/Minecraft.Client/JoinMultiplayerScreen.cpp b/Minecraft.Client/JoinMultiplayerScreen.cpp index a98e7bee1..7ef19663c 100644 --- a/Minecraft.Client/JoinMultiplayerScreen.cpp +++ b/Minecraft.Client/JoinMultiplayerScreen.cpp @@ -55,7 +55,7 @@ void JoinMultiplayerScreen::buttonClicked(Button *button) vector parts = stringSplit(ip,L'L'); if (ip[0]==L'[') { - int pos = (int)ip.find(L"]"); + int pos = static_cast(ip.find(L"]")); if (pos != wstring::npos) { wstring path = ip.substr(1, pos); diff --git a/Minecraft.Client/LavaParticle.cpp b/Minecraft.Client/LavaParticle.cpp index ac0608e59..0ff9b1b06 100644 --- a/Minecraft.Client/LavaParticle.cpp +++ b/Minecraft.Client/LavaParticle.cpp @@ -15,7 +15,7 @@ LavaParticle::LavaParticle(Level *level, double x, double y, double z) : Particl size *= (random->nextFloat() * 2 + 0.2f); oSize = size; - lifetime = (int) (16 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(16 / (Math::random() * 0.8 + 0.2)); noPhysics = false; setMiscTex(49); } @@ -40,7 +40,7 @@ float LavaParticle::getBrightness(float a) void LavaParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) { - float s = (age + a) / (float) lifetime; + float s = (age + a) / static_cast(lifetime); size = oSize * (1 - s*s); Particle::render(t, a, xa, ya, za, xa2, za2); } @@ -52,7 +52,7 @@ void LavaParticle::tick() zo = z; if (age++ >= lifetime) remove(); - float odds = age / (float) lifetime; + float odds = age / static_cast(lifetime); if (random->nextFloat() > odds) level->addParticle(eParticleType_smoke, x, y, z, xd, yd, zd); yd -= 0.03; diff --git a/Minecraft.Client/LavaSlimeModel.cpp b/Minecraft.Client/LavaSlimeModel.cpp index 052850f81..0f9d6a435 100644 --- a/Minecraft.Client/LavaSlimeModel.cpp +++ b/Minecraft.Client/LavaSlimeModel.cpp @@ -22,7 +22,7 @@ LavaSlimeModel::LavaSlimeModel() v = 19; } bodyCubes[i] = new ModelPart(this, u, v); - bodyCubes[i]->addBox(-4.0f, 16.0f + (float)i, -4.0f, 8, 1, 8); + bodyCubes[i]->addBox(-4.0f, 16.0f + static_cast(i), -4.0f, 8, 1, 8); } insideCube = new ModelPart(this, 0, 16); diff --git a/Minecraft.Client/LavaSlimeRenderer.cpp b/Minecraft.Client/LavaSlimeRenderer.cpp index e828a353b..3d5858eae 100644 --- a/Minecraft.Client/LavaSlimeRenderer.cpp +++ b/Minecraft.Client/LavaSlimeRenderer.cpp @@ -7,7 +7,7 @@ ResourceLocation LavaSlimeRenderer::MAGMACUBE_LOCATION = ResourceLocation(TN_MOB LavaSlimeRenderer::LavaSlimeRenderer() : MobRenderer(new LavaSlimeModel(), .25f) { - this->modelVersion = ((LavaSlimeModel *) model)->getModelVersion(); + this->modelVersion = static_cast(model)->getModelVersion(); } ResourceLocation *LavaSlimeRenderer::getTextureLocation(shared_ptr mob) diff --git a/Minecraft.Client/LeashKnotRenderer.cpp b/Minecraft.Client/LeashKnotRenderer.cpp index b210379fc..3c58ce522 100644 --- a/Minecraft.Client/LeashKnotRenderer.cpp +++ b/Minecraft.Client/LeashKnotRenderer.cpp @@ -19,7 +19,7 @@ void LeashKnotRenderer::render(shared_ptr entity, double x, double y, do glPushMatrix(); glDisable(GL_CULL_FACE); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); float scale = 1 / 16.0f; glEnable(GL_RESCALE_NORMAL); diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index 051ad8921..109fab3f5 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -184,16 +184,16 @@ LevelRenderer::LevelRenderer(Minecraft *mc, Textures *textures) float yy; int s = 64; int d = 256 / s + 2; - yy = (float) 16; + yy = static_cast(16); for (int xx = -s * d; xx <= s * d; xx += s) { for (int zz = -s * d; zz <= s * d; zz += s) { t->begin(); - t->vertex((float)(xx + 0), (float)( yy), (float)( zz + 0)); - t->vertex((float)(xx + s), (float)( yy), (float)( zz + 0)); - t->vertex((float)(xx + s), (float)( yy), (float)( zz + s)); - t->vertex((float)(xx + 0), (float)( yy), (float)( zz + s)); + t->vertex(static_cast(xx + 0), (float)( yy), static_cast(zz + 0)); + t->vertex(static_cast(xx + s), (float)( yy), static_cast(zz + 0)); + t->vertex(static_cast(xx + s), (float)( yy), static_cast(zz + s)); + t->vertex(static_cast(xx + 0), (float)( yy), static_cast(zz + s)); t->end(); } } @@ -201,16 +201,16 @@ LevelRenderer::LevelRenderer(Minecraft *mc, Textures *textures) darkList = starList + 2; glNewList(darkList, GL_COMPILE); - yy = -(float) 16; + yy = -static_cast(16); t->begin(); for (int xx = -s * d; xx <= s * d; xx += s) { for (int zz = -s * d; zz <= s * d; zz += s) { - t->vertex((float)(xx + s), (float)( yy), (float)( zz + 0)); - t->vertex((float)(xx + 0), (float)( yy), (float)( zz + 0)); - t->vertex((float)(xx + 0), (float)( yy), (float)( zz + s)); - t->vertex((float)(xx + s), (float)( yy), (float)( zz + s)); + t->vertex(static_cast(xx + s), (float)( yy), static_cast(zz + 0)); + t->vertex(static_cast(xx + 0), (float)( yy), static_cast(zz + 0)); + t->vertex(static_cast(xx + 0), (float)( yy), static_cast(zz + s)); + t->vertex(static_cast(xx + s), (float)( yy), static_cast(zz + s)); } } t->end(); @@ -312,7 +312,7 @@ void LevelRenderer::renderStars() double yo = _yo; double zo = _zo * ySin + _xo * yCos; - t->vertex((float)(xp + xo), (float)( yp + yo), (float)( zp + zo)); + t->vertex(static_cast(xp + xo), static_cast(yp + yo), static_cast(zp + zo)); } } } @@ -427,7 +427,7 @@ void LevelRenderer::allChanged(int playerIndex) lastViewDistance = mc->options->viewDistance; // Calculate size of area we can render based on number of players we need to render for - int dist = (int)sqrtf( (float)PLAYER_RENDER_AREA / (float)activePlayers() ); + int dist = static_cast(sqrtf((float)PLAYER_RENDER_AREA / (float)activePlayers())); // AP - poor little Vita just can't cope with such a big area #ifdef __PSVITA__ @@ -531,7 +531,7 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a) mc->gameRenderer->turnOnLightLayer(a); // 4J - brought forward from 1.8.2 vector > entities = level[playerIndex]->getAllEntities(); - totalEntities = (int)entities.size(); + totalEntities = static_cast(entities.size()); for (auto& entity : level[playerIndex]->globalEntities) { @@ -729,7 +729,7 @@ int LevelRenderer::render(shared_ptr player, int layer, double alp } Lighting::turnOff(); - int count = renderChunks(0, (int)chunks[playerIndex].length, layer, alpha); + int count = renderChunks(0, static_cast(chunks[playerIndex].length), layer, alpha); return count; @@ -765,7 +765,7 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) double zOff = player->zOld + (player->z - player->zOld) * alpha; glPushMatrix(); - glTranslatef((float)-xOff, (float)-yOff, (float)-zOff); + glTranslatef(static_cast(-xOff), static_cast(-yOff), static_cast(-zOff)); #ifdef __PSVITA__ // AP - also set the camera position so we can work out if a chunk is fogged or not @@ -990,9 +990,9 @@ void LevelRenderer::renderSky(float alpha) int playerIndex = mc->player->GetXboxPad(); Vec3 *sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha); - float sr = (float) sc->x; - float sg = (float) sc->y; - float sb = (float) sc->z; + float sr = static_cast(sc->x); + float sg = static_cast(sc->y); + float sb = static_cast(sc->z); if (mc->options->anaglyph3d) { @@ -1055,7 +1055,7 @@ void LevelRenderer::renderSky(float alpha) t->begin(GL_TRIANGLE_FAN); t->color(r, g, b, c[3]); - t->vertex((float)(0), (float)( 100), (float)( 0)); + t->vertex(static_cast(0), static_cast(100), static_cast(0)); int steps = 16; t->color(c[0], c[1], c[2], 0.0f); for (int i = 0; i <= steps; i++) @@ -1089,10 +1089,10 @@ void LevelRenderer::renderSky(float alpha) textures->bindTexture(&SUN_LOCATION); MemSect(0); t->begin(); - t->vertexUV((float)(-ss), (float)( 100), (float)( -ss), (float)( 0), (float)( 0)); - t->vertexUV((float)(+ss), (float)( 100), (float)( -ss), (float)( 1), (float)( 0)); - t->vertexUV((float)(+ss), (float)( 100), (float)( +ss), (float)( 1), (float)( 1)); - t->vertexUV((float)(-ss), (float)( 100), (float)( +ss), (float)( 0), (float)( 1)); + t->vertexUV((float)(-ss), static_cast(100), (float)( -ss), static_cast(0), static_cast(0)); + t->vertexUV((float)(+ss), static_cast(100), (float)( -ss), static_cast(1), static_cast(0)); + t->vertexUV((float)(+ss), static_cast(100), (float)( +ss), static_cast(1), static_cast(1)); + t->vertexUV((float)(-ss), static_cast(100), (float)( +ss), static_cast(0), static_cast(1)); t->end(); ss = 20; @@ -1137,7 +1137,7 @@ void LevelRenderer::renderSky(float alpha) if (yy < 0) { glPushMatrix(); - glTranslatef(0, -(float) (-12), 0); + glTranslatef(0, -static_cast(-12), 0); glCallList(darkList); glPopMatrix(); @@ -1188,7 +1188,7 @@ void LevelRenderer::renderSky(float alpha) glColor3f(sr, sg, sb); } glPushMatrix(); - glTranslatef(0, -(float) (yy - 16), 0); + glTranslatef(0, -static_cast(yy - 16), 0); glCallList(darkList); glPopMatrix(); glEnable(GL_TEXTURE_2D); @@ -1209,9 +1209,9 @@ void LevelRenderer::renderHaloRing(float alpha) int playerIndex = mc->player->GetXboxPad(); Vec3 *sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha); - float sr = (float) sc->x; - float sg = (float) sc->y; - float sb = (float) sc->z; + float sr = static_cast(sc->x); + float sg = static_cast(sc->y); + float sb = static_cast(sc->z); // Rough lumninance calculation float Y = (sr+sr+sb+sg+sg+sg)/6; @@ -1274,7 +1274,7 @@ void LevelRenderer::renderClouds(float alpha) } } glDisable(GL_CULL_FACE); - float yOffs = (float) (mc->cameraTargetPlayer->yOld + (mc->cameraTargetPlayer->y - mc->cameraTargetPlayer->yOld) * alpha); + float yOffs = static_cast(mc->cameraTargetPlayer->yOld + (mc->cameraTargetPlayer->y - mc->cameraTargetPlayer->yOld) * alpha); int s = 32; int d = 256 / s; Tesselator *t = Tesselator::getInstance(); @@ -1284,9 +1284,9 @@ void LevelRenderer::renderClouds(float alpha) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Vec3 *cc = level[playerIndex]->getCloudColor(alpha); - float cr = (float) cc->x; - float cg = (float) cc->y; - float cb = (float) cc->z; + float cr = static_cast(cc->x); + float cg = static_cast(cc->y); + float cb = static_cast(cc->z); if (mc->options->anaglyph3d) { @@ -1312,8 +1312,8 @@ void LevelRenderer::renderClouds(float alpha) zo -= zOffs * 2048; float yy = (float) (level[playerIndex]->dimension->getCloudHeight() - yOffs + 0.33f); - float uo = (float) (xo * scale); - float vo = (float) (zo * scale); + float uo = static_cast(xo * scale); + float vo = static_cast(zo * scale); t->begin(); t->color(cr, cg, cb, 0.8f); @@ -1321,10 +1321,10 @@ void LevelRenderer::renderClouds(float alpha) { for (int zz = -s * d; zz < +s * d; zz += s) { - t->vertexUV((float)(xx + 0), (float)( yy), (float)( zz + s), (float)( (xx + 0) * scale + uo), (float)( (zz + s) * scale + vo)); - t->vertexUV((float)(xx + s), (float)( yy), (float)( zz + s), (float)( (xx + s) * scale + uo), (float)( (zz + s) * scale + vo)); - t->vertexUV((float)(xx + s), (float)( yy), (float)( zz + 0), (float)( (xx + s) * scale + uo), (float)( (zz + 0) * scale + vo)); - t->vertexUV((float)(xx + 0), (float)( yy), (float)( zz + 0), (float)( (xx + 0) * scale + uo), (float)( (zz + 0) * scale + vo)); + t->vertexUV(static_cast(xx + 0), (float)( yy), static_cast(zz + s), (float)( (xx + 0) * scale + uo), (float)( (zz + s) * scale + vo)); + t->vertexUV(static_cast(xx + s), (float)( yy), static_cast(zz + s), (float)( (xx + s) * scale + uo), (float)( (zz + s) * scale + vo)); + t->vertexUV(static_cast(xx + s), (float)( yy), static_cast(zz + 0), (float)( (xx + s) * scale + uo), (float)( (zz + 0) * scale + vo)); + t->vertexUV(static_cast(xx + 0), (float)( yy), static_cast(zz + 0), (float)( (xx + 0) * scale + uo), (float)( (zz + 0) * scale + vo)); } } t->end(); @@ -1371,13 +1371,13 @@ void LevelRenderer::createCloudMesh() { for( int xt = 0; xt < D; xt++ ) { - float u = (((float) xt ) + 0.5f ) / 256.0f; - float v = (((float) zt ) + 0.5f ) / 256.0f; - float x0 = (float)xt; + float u = (static_cast(xt) + 0.5f ) / 256.0f; + float v = (static_cast(zt) + 0.5f ) / 256.0f; + float x0 = static_cast(xt); float x1 = x0 + 1.0f; float y0 = 0; float y1 = h; - float z0 = (float)zt; + float z0 = static_cast(zt); float z1 = z0 + 1.0f; t->color(0.7f, 0.7f, 0.7f, 0.8f); t->normal(0, -1, 0); @@ -1396,13 +1396,13 @@ void LevelRenderer::createCloudMesh() { for( int xt = 0; xt < D; xt++ ) { - float u = (((float) xt ) + 0.5f ) / 256.0f; - float v = (((float) zt ) + 0.5f ) / 256.0f; - float x0 = (float)xt; + float u = (static_cast(xt) + 0.5f ) / 256.0f; + float v = (static_cast(zt) + 0.5f ) / 256.0f; + float x0 = static_cast(xt); float x1 = x0 + 1.0f; float y0 = 0; float y1 = h; - float z0 = (float)zt; + float z0 = static_cast(zt); float z1 = z0 + 1.0f; t->color(1.0f, 1.0f, 1.0f, 0.8f); t->normal(0, 1, 0); @@ -1421,13 +1421,13 @@ void LevelRenderer::createCloudMesh() { for( int xt = 0; xt < D; xt++ ) { - float u = (((float) xt ) + 0.5f ) / 256.0f; - float v = (((float) zt ) + 0.5f ) / 256.0f; - float x0 = (float)xt; + float u = (static_cast(xt) + 0.5f ) / 256.0f; + float v = (static_cast(zt) + 0.5f ) / 256.0f; + float x0 = static_cast(xt); float x1 = x0 + 1.0f; float y0 = 0; float y1 = h; - float z0 = (float)zt; + float z0 = static_cast(zt); float z1 = z0 + 1.0f; t->color(0.9f, 0.9f, 0.9f, 0.8f); t->normal(-1, 0, 0); @@ -1446,13 +1446,13 @@ void LevelRenderer::createCloudMesh() { for( int xt = 0; xt < D; xt++ ) { - float u = (((float) xt ) + 0.5f ) / 256.0f; - float v = (((float) zt ) + 0.5f ) / 256.0f; - float x0 = (float)xt; + float u = (static_cast(xt) + 0.5f ) / 256.0f; + float v = (static_cast(zt) + 0.5f ) / 256.0f; + float x0 = static_cast(xt); float x1 = x0 + 1.0f; float y0 = 0; float y1 = h; - float z0 = (float)zt; + float z0 = static_cast(zt); float z1 = z0 + 1.0f; t->color(0.9f, 0.9f, 0.9f, 0.8f); t->normal(1, 0, 0); @@ -1471,13 +1471,13 @@ void LevelRenderer::createCloudMesh() { for( int xt = 0; xt < D; xt++ ) { - float u = (((float) xt ) + 0.5f ) / 256.0f; - float v = (((float) zt ) + 0.5f ) / 256.0f; - float x0 = (float)xt; + float u = (static_cast(xt) + 0.5f ) / 256.0f; + float v = (static_cast(zt) + 0.5f ) / 256.0f; + float x0 = static_cast(xt); float x1 = x0 + 1.0f; float y0 = 0; float y1 = h; - float z0 = (float)zt; + float z0 = static_cast(zt); float z1 = z0 + 1.0f; t->color(0.8f, 0.8f, 0.8f, 0.8f); t->normal(-1, 0, 0); @@ -1496,13 +1496,13 @@ void LevelRenderer::createCloudMesh() { for( int xt = 0; xt < D; xt++ ) { - float u = (((float) xt ) + 0.5f ) / 256.0f; - float v = (((float) zt ) + 0.5f ) / 256.0f; - float x0 = (float)xt; + float u = (static_cast(xt) + 0.5f ) / 256.0f; + float v = (static_cast(zt) + 0.5f ) / 256.0f; + float x0 = static_cast(xt); float x1 = x0 + 1.0f; float y0 = 0; float y1 = h; - float z0 = (float)zt; + float z0 = static_cast(zt); float z1 = z0 + 1.0f; t->color(0.8f, 0.8f, 0.8f, 0.8f); t->normal(1, 0, 0); @@ -1527,7 +1527,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) // 4J - most of our viewports are now rendered with no clip planes but using stencilling to limit the area drawn to. Clouds have a relatively large fill area compared to // the number of vertices that they have, and so enabling clipping here to try and reduce fill rate cost. RenderManager.StateSetEnableViewportClipPlanes(true); - float yOffs = (float) (mc->cameraTargetPlayer->yOld + (mc->cameraTargetPlayer->y - mc->cameraTargetPlayer->yOld) * alpha); + float yOffs = static_cast(mc->cameraTargetPlayer->yOld + (mc->cameraTargetPlayer->y - mc->cameraTargetPlayer->yOld) * alpha); Tesselator *t = Tesselator::getInstance(); int playerIndex = mc->player->GetXboxPad(); @@ -1577,9 +1577,9 @@ void LevelRenderer::renderAdvancedClouds(float alpha) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Vec3 *cc = level[playerIndex]->getCloudColor(alpha); - float cr = (float) cc->x; - float cg = (float) cc->y; - float cb = (float) cc->z; + float cr = static_cast(cc->x); + float cg = static_cast(cc->y); + float cb = static_cast(cc->z); if (mc->options->anaglyph3d) { @@ -1592,19 +1592,19 @@ void LevelRenderer::renderAdvancedClouds(float alpha) cb = cbb; } - float uo = (float) (xo * 0); - float vo = (float) (zo * 0); + float uo = static_cast(xo * 0); + float vo = static_cast(zo * 0); float scale = 1 / 256.0f; - uo = (float) (Mth::floor(xo)) * scale; - vo = (float) (Mth::floor(zo)) * scale; + uo = static_cast(Mth::floor(xo)) * scale; + vo = static_cast(Mth::floor(zo)) * scale; // 4J - keep our UVs +ve - there's a small bug in the xbox GPU that incorrectly rounds small -ve UVs (between -1/(64*size) and 0) up to 0, which leaves gaps in our clouds... while( uo < 1.0f ) uo += 1.0f; while( vo < 1.0f ) vo += 1.0f; - float xoffs = (float) (xo - Mth::floor(xo)); - float zoffs = (float) (zo - Mth::floor(zo)); + float xoffs = static_cast(xo - Mth::floor(xo)); + float zoffs = static_cast(zo - Mth::floor(zo)); int D = 8; @@ -1634,8 +1634,8 @@ void LevelRenderer::renderAdvancedClouds(float alpha) // 4J - reimplemented the clouds with full cube-per-texel geometry to get rid of seams. This is a huge amount more quads to render, so // now using command buffers to render each section to cut CPU hit. #if 1 - float xx = (float)(xPos * D); - float zz = (float)(zPos * D); + float xx = static_cast(xPos * D); + float zz = static_cast(zPos * D); float xp = xx - xoffs; float zp = zz - zoffs; @@ -1828,7 +1828,7 @@ bool LevelRenderer::updateDirtyChunks() } throttle++; */ - PIXAddNamedCounter(((float)memAlloc)/(1024.0f*1024.0f),"Command buffer allocations"); + PIXAddNamedCounter(static_cast(memAlloc)/(1024.0f*1024.0f),"Command buffer allocations"); bool onlyRebuild = ( memAlloc >= MAX_COMMANDBUFFER_ALLOCATIONS ); EnterCriticalSection(&m_csDirtyChunks); @@ -1930,9 +1930,9 @@ bool LevelRenderer::updateDirtyChunks() if( chunks[p].data == NULL ) continue; if( level[p] == NULL ) continue; if( chunks[p].length != xChunks * zChunks * CHUNK_Y_COUNT ) continue; - int px = (int)player->x; - int py = (int)player->y; - int pz = (int)player->z; + int px = static_cast(player->x); + int py = static_cast(player->y); + int pz = static_cast(player->z); // app.DebugPrintf("!! %d %d %d, %d %d %d {%d,%d} ",px,py,pz,stackChunkDirty,nonStackChunkDirty,onlyRebuild, xChunks, zChunks); @@ -2221,7 +2221,7 @@ void LevelRenderer::renderDestroyAnimation(Tesselator *t, shared_ptr pla // so just add on a little bit of y to fix this. hacky hacky t->offset((float)-xo, (float)-yo + 0.01f,(float) -zo); #else - t->offset((float)-xo, (float)-yo,(float) -zo); + t->offset(static_cast(-xo), static_cast(-yo),static_cast(-zo)); #endif t->noColor(); @@ -2298,30 +2298,30 @@ void LevelRenderer::render(AABB *b) Tesselator *t = Tesselator::getInstance(); t->begin(GL_LINE_STRIP); - t->vertex((float)(b->x0), (float)( b->y0), (float)( b->z0)); - t->vertex((float)(b->x1), (float)( b->y0), (float)( b->z0)); - t->vertex((float)(b->x1), (float)( b->y0), (float)( b->z1)); - t->vertex((float)(b->x0), (float)( b->y0), (float)( b->z1)); - t->vertex((float)(b->x0), (float)( b->y0), (float)( b->z0)); + t->vertex(static_cast(b->x0), static_cast(b->y0), static_cast(b->z0)); + t->vertex(static_cast(b->x1), static_cast(b->y0), static_cast(b->z0)); + t->vertex(static_cast(b->x1), static_cast(b->y0), static_cast(b->z1)); + t->vertex(static_cast(b->x0), static_cast(b->y0), static_cast(b->z1)); + t->vertex(static_cast(b->x0), static_cast(b->y0), static_cast(b->z0)); t->end(); t->begin(GL_LINE_STRIP); - t->vertex((float)(b->x0), (float)( b->y1), (float)( b->z0)); - t->vertex((float)(b->x1), (float)( b->y1), (float)( b->z0)); - t->vertex((float)(b->x1), (float)( b->y1), (float)( b->z1)); - t->vertex((float)(b->x0), (float)( b->y1), (float)( b->z1)); - t->vertex((float)(b->x0), (float)( b->y1), (float)( b->z0)); + t->vertex(static_cast(b->x0), static_cast(b->y1), static_cast(b->z0)); + t->vertex(static_cast(b->x1), static_cast(b->y1), static_cast(b->z0)); + t->vertex(static_cast(b->x1), static_cast(b->y1), static_cast(b->z1)); + t->vertex(static_cast(b->x0), static_cast(b->y1), static_cast(b->z1)); + t->vertex(static_cast(b->x0), static_cast(b->y1), static_cast(b->z0)); t->end(); t->begin(GL_LINES); - t->vertex((float)(b->x0), (float)( b->y0), (float)( b->z0)); - t->vertex((float)(b->x0), (float)( b->y1), (float)( b->z0)); - t->vertex((float)(b->x1), (float)( b->y0), (float)( b->z0)); - t->vertex((float)(b->x1), (float)( b->y1), (float)( b->z0)); - t->vertex((float)(b->x1), (float)( b->y0), (float)( b->z1)); - t->vertex((float)(b->x1), (float)( b->y1), (float)( b->z1)); - t->vertex((float)(b->x0), (float)( b->y0), (float)( b->z1)); - t->vertex((float)(b->x0), (float)( b->y1), (float)( b->z1)); + t->vertex(static_cast(b->x0), static_cast(b->y0), static_cast(b->z0)); + t->vertex(static_cast(b->x0), static_cast(b->y1), static_cast(b->z0)); + t->vertex(static_cast(b->x1), static_cast(b->y0), static_cast(b->z0)); + t->vertex(static_cast(b->x1), static_cast(b->y1), static_cast(b->z0)); + t->vertex(static_cast(b->x1), static_cast(b->y0), static_cast(b->z1)); + t->vertex(static_cast(b->x1), static_cast(b->y1), static_cast(b->z1)); + t->vertex(static_cast(b->x0), static_cast(b->y0), static_cast(b->z1)); + t->vertex(static_cast(b->x0), static_cast(b->y1), static_cast(b->z1)); t->end(); } @@ -2527,7 +2527,7 @@ void LevelRenderer::cull(Culler *culler, float a) #endif // __PS3__ - FrustumCuller *fc = (FrustumCuller *)culler; + FrustumCuller *fc = static_cast(culler); FrustumData *fd = fc->frustum; float fdraw[6 * 4]; for( int i = 0; i < 6; i++ ) @@ -2535,10 +2535,10 @@ void LevelRenderer::cull(Culler *culler, float a) double fx = fd->m_Frustum[i][0]; double fy = fd->m_Frustum[i][1]; double fz = fd->m_Frustum[i][2]; - fdraw[i * 4 + 0] = (float)fx; - fdraw[i * 4 + 1] = (float)fy; - fdraw[i * 4 + 2] = (float)fz; - fdraw[i * 4 + 3] = (float)(fd->m_Frustum[i][3] + ( fx * -fc->xOff ) + ( fy * - fc->yOff ) + ( fz * -fc->zOff )); + fdraw[i * 4 + 0] = static_cast(fx); + fdraw[i * 4 + 1] = static_cast(fy); + fdraw[i * 4 + 2] = static_cast(fz); + fdraw[i * 4 + 3] = static_cast(fd->m_Frustum[i][3] + (fx * -fc->xOff) + (fy * -fc->yOff) + (fz * -fc->zOff)); } ClipChunk *pClipChunk = chunks[playerIndex].data; @@ -2577,7 +2577,7 @@ void LevelRenderer::playStreamingMusic(const wstring& name, int x, int y, int z) { mc->gui->setNowPlaying(L"C418 - " + name); } - mc->soundEngine->playStreaming(name, (float) x, (float) y, (float) z, 1, 1); + mc->soundEngine->playStreaming(name, static_cast(x), static_cast(y), static_cast(z), 1, 1); } void LevelRenderer::playSound(int iSound, double x, double y, double z, float volume, float pitch, float fSoundClipDist) @@ -2777,8 +2777,8 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle } else { - float fStart=((float)(cStart&0xFF)); - float fDiff=(float)((cEnd-cStart)&0xFF); + float fStart=static_cast(cStart & 0xFF); + float fDiff=static_cast((cEnd - cStart) & 0xFF); float fCol = (fStart + (Math::random() * fDiff))/255.0f; particle->setColor( fCol, fCol, fCol ); @@ -2810,12 +2810,12 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle break; case eParticleType_mobSpell: particle = shared_ptr(new SpellParticle(lev, x, y, z, 0, 0, 0)); - particle->setColor((float) xa, (float) ya, (float) za); + particle->setColor(static_cast(xa), static_cast(ya), static_cast(za)); break; case eParticleType_mobSpellAmbient: particle = shared_ptr(new SpellParticle(lev, x, y, z, 0, 0, 0)); particle->setAlpha(0.15f); - particle->setColor((float) xa, (float) ya, (float) za); + particle->setColor(static_cast(xa), static_cast(ya), static_cast(za)); break; case eParticleType_spell: particle = shared_ptr( new SpellParticle(lev, x, y, z, xa, ya, za) ); @@ -2863,7 +2863,7 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle particle = shared_ptr( new SmokeParticle(lev, x, y, z, xa, ya, za, 2.5f) ); break; case eParticleType_reddust: - particle = shared_ptr( new RedDustParticle(lev, x, y, z, (float) xa, (float) ya, (float) za) ); + particle = shared_ptr( new RedDustParticle(lev, x, y, z, static_cast(xa), static_cast(ya), static_cast(za)) ); break; case eParticleType_snowballpoof: particle = shared_ptr( new BreakingItemParticle(lev, x, y, z, Item::snowBall, textures) ); @@ -3110,9 +3110,9 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y int colorValue = Item::potion->getColor(data); - float red = (float) ((colorValue >> 16) & 0xff) / 255.0f; - float green = (float) ((colorValue >> 8) & 0xff) / 255.0f; - float blue = (float) ((colorValue >> 0) & 0xff) / 255.0f; + float red = static_cast((colorValue >> 16) & 0xff) / 255.0f; + float green = static_cast((colorValue >> 8) & 0xff) / 255.0f; + float blue = static_cast((colorValue >> 0) & 0xff) / 255.0f; ePARTICLE_TYPE particleName = eParticleType_spell; if (Item::potion->hasInstantenousEffects(data)) @@ -3133,7 +3133,7 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y { float randBrightness = 0.75f + random->nextFloat() * 0.25f; spellParticle->setColor(red * randBrightness, green * randBrightness, blue * randBrightness); - spellParticle->setPower((float) dist); + spellParticle->setPower(static_cast(dist)); } } level[playerIndex]->playLocalSound(x + 0.5, y + 0.5, z + 0.5, eSoundType_RANDOM_GLASS, 1, level[playerIndex]->random->nextFloat() * 0.1f + 0.9f, false); @@ -3159,7 +3159,7 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y if (acidParticle != NULL) { float randBrightness = 0.75f + random->nextFloat() * 0.25f; - acidParticle->setPower((float) dist); + acidParticle->setPower(static_cast(dist)); } } level[playerIndex]->playLocalSound(x + 0.5, y + 0.5, z + 0.5, eSoundType_RANDOM_EXPLODE, 1, level[playerIndex]->random->nextFloat() * 0.1f + 0.9f); @@ -3550,7 +3550,7 @@ void LevelRenderer::DestroyedTileManager::destroyingTileAt( Level *level, int x, // ones, so make a temporary list and then copy over RecentTile *recentTile = new RecentTile(x, y, z, level); - AABB *box = AABB::newTemp((float)x, (float)y, (float)z, (float)(x+1), (float)(y+1), (float)(z+1)); + AABB *box = AABB::newTemp(static_cast(x), static_cast(y), static_cast(z), static_cast(x + 1), static_cast(y + 1), static_cast(z + 1)); Tile *tile = Tile::tiles[level->getTile(x, y, z)]; if (tile != NULL) diff --git a/Minecraft.Client/Lighting.cpp b/Minecraft.Client/Lighting.cpp index 50529d516..ef9feaa14 100644 --- a/Minecraft.Client/Lighting.cpp +++ b/Minecraft.Client/Lighting.cpp @@ -44,7 +44,7 @@ void Lighting::turnOn() FloatBuffer *Lighting::getBuffer(double a, double b, double c, double d) { - return getBuffer((float) a, (float) b, (float) c, (float) d); + return getBuffer(static_cast(a), static_cast(b), static_cast(c), static_cast(d)); } FloatBuffer *Lighting::getBuffer(float a, float b, float c, float d) diff --git a/Minecraft.Client/LightningBoltRenderer.cpp b/Minecraft.Client/LightningBoltRenderer.cpp index d02ea7f71..46b628dfb 100644 --- a/Minecraft.Client/LightningBoltRenderer.cpp +++ b/Minecraft.Client/LightningBoltRenderer.cpp @@ -79,8 +79,8 @@ void LightningBoltRenderer::render(shared_ptr _bolt, double x, double y, if (i == 1 || i == 2) xx2 += rr2 * 2; if (i == 2 || i == 3) zz2 += rr2 * 2; - t->vertex((float)(xx2 + xo0), (float)( y + (h) * 16), (float)( zz2 + zo0)); - t->vertex((float)(xx1 + xo1), (float)( y + (h + 1) * 16), (float)( zz1 + zo1)); + t->vertex(static_cast(xx2 + xo0), static_cast(y + (h) * 16), static_cast(zz2 + zo0)); + t->vertex(static_cast(xx1 + xo1), static_cast(y + (h + 1) * 16), static_cast(zz1 + zo1)); } diff --git a/Minecraft.Client/LivingEntityRenderer.cpp b/Minecraft.Client/LivingEntityRenderer.cpp index 757948a37..f713c20e5 100644 --- a/Minecraft.Client/LivingEntityRenderer.cpp +++ b/Minecraft.Client/LivingEntityRenderer.cpp @@ -259,7 +259,7 @@ void LivingEntityRenderer::renderModel(shared_ptr mob, float wp, f void LivingEntityRenderer::setupPosition(shared_ptr mob, double x, double y, double z) { - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); } void LivingEntityRenderer::setupRotations(shared_ptr mob, float bob, float bodyRot, float a) @@ -405,7 +405,7 @@ void LivingEntityRenderer::renderName(shared_ptr mob, double x, do Font *font = getFont(); glPushMatrix(); - glTranslatef((float) x + 0, (float) y + mob->bbHeight + 0.5f, (float) z); + glTranslatef(static_cast(x) + 0, static_cast(y) + mob->bbHeight + 0.5f, static_cast(z)); glNormal3f(0, 1, 0); glRotatef(-entityRenderDispatcher->playerRotY, 0, 1, 0); @@ -595,10 +595,10 @@ void LivingEntityRenderer::renderNameTag(shared_ptr mob, const wst { t->color(0.0f, 0.0f, 0.0f, 0.25f); } - t->vertex((float)(-w - 1), (float)( -1 + offs), (float)( 0)); - t->vertex((float)(-w - 1), (float)( +8 + offs + 1), (float)( 0)); - t->vertex((float)(+w + 1), (float)( +8 + offs + 1), (float)( 0)); - t->vertex((float)(+w + 1), (float)( -1 + offs), (float)( 0)); + t->vertex(static_cast(-w - 1), static_cast(-1 + offs), static_cast(0)); + t->vertex(static_cast(-w - 1), static_cast(+8 + offs + 1), static_cast(0)); + t->vertex(static_cast(+w + 1), static_cast(+8 + offs + 1), static_cast(0)); + t->vertex(static_cast(+w + 1), static_cast(-1 + offs), static_cast(0)); t->end(); glEnable(GL_DEPTH_TEST); @@ -607,11 +607,11 @@ void LivingEntityRenderer::renderNameTag(shared_ptr mob, const wst glLineWidth(2.0f); t->begin(GL_LINE_STRIP); t->color(color, 255 * textOpacity); - t->vertex((float)(-w - 1), (float)( -1 + offs), (float)( 0)); - t->vertex((float)(-w - 1), (float)( +8 + offs + 1), (float)( 0)); - t->vertex((float)(+w + 1), (float)( +8 + offs + 1), (float)( 0)); - t->vertex((float)(+w + 1), (float)( -1 + offs), (float)( 0)); - t->vertex((float)(-w - 1), (float)( -1 + offs), (float)( 0)); + t->vertex(static_cast(-w - 1), static_cast(-1 + offs), static_cast(0)); + t->vertex(static_cast(-w - 1), static_cast(+8 + offs + 1), static_cast(0)); + t->vertex(static_cast(+w + 1), static_cast(+8 + offs + 1), static_cast(0)); + t->vertex(static_cast(+w + 1), static_cast(-1 + offs), static_cast(0)); + t->vertex(static_cast(-w - 1), static_cast(-1 + offs), static_cast(0)); t->end(); glDepthFunc(GL_LEQUAL); glDepthMask(false); @@ -632,10 +632,10 @@ void LivingEntityRenderer::renderNameTag(shared_ptr mob, const wst t->begin(); int w = font->width(playerName) / 2; t->color(color, 255); - t->vertex((float)(-w - 1), (float)( -1 + offs), (float)( 0)); - t->vertex((float)(-w - 1), (float)( +8 + offs), (float)( 0)); - t->vertex((float)(+w + 1), (float)( +8 + offs), (float)( 0)); - t->vertex((float)(+w + 1), (float)( -1 + offs), (float)( 0)); + t->vertex(static_cast(-w - 1), static_cast(-1 + offs), static_cast(0)); + t->vertex(static_cast(-w - 1), static_cast(+8 + offs), static_cast(0)); + t->vertex(static_cast(+w + 1), static_cast(+8 + offs), static_cast(0)); + t->vertex(static_cast(+w + 1), static_cast(-1 + offs), static_cast(0)); t->end(); glDepthFunc(GL_LEQUAL); glEnable(GL_TEXTURE_2D); @@ -645,7 +645,7 @@ void LivingEntityRenderer::renderNameTag(shared_ptr mob, const wst if( textOpacity > 0.0f ) { - int textColor = ( ( (int)(textOpacity*255) << 24 ) | 0xffffff ); + int textColor = ( ( static_cast(textOpacity * 255) << 24 ) | 0xffffff ); font->draw(playerName, -font->width(playerName) / 2, offs, textColor); } diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index 77306621f..c0050075c 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -420,11 +420,11 @@ void LocalPlayer::aiStep() jumpRidingTicks++; if (jumpRidingTicks < 10) { - jumpRidingScale = (float) jumpRidingTicks * .1f; + jumpRidingScale = static_cast(jumpRidingTicks) * .1f; } else { - jumpRidingScale = .8f + (2.f / ((float) (jumpRidingTicks - 9))) * .1f; + jumpRidingScale = .8f + (2.f / static_cast(jumpRidingTicks - 9)) * .1f; } } } @@ -458,9 +458,9 @@ void LocalPlayer::aiStep() #ifdef _DEBUG_MENUS_ENABLED if(abilities.debugflying) { - flyX = (float)viewVector->x * input->ya; - flyY = (float)viewVector->y * input->ya; - flyZ = (float)viewVector->z * input->ya; + flyX = static_cast(viewVector->x) * input->ya; + flyY = static_cast(viewVector->y) * input->ya; + flyZ = static_cast(viewVector->z) * input->ya; } else #endif @@ -468,11 +468,11 @@ void LocalPlayer::aiStep() if( isSprinting() ) { // Accelrate up to full speed if we are sprinting, moving in the direction of the view vector - flyX = (float)viewVector->x * input->ya; - flyY = (float)viewVector->y * input->ya; - flyZ = (float)viewVector->z * input->ya; + flyX = static_cast(viewVector->x) * input->ya; + flyY = static_cast(viewVector->y) * input->ya; + flyZ = static_cast(viewVector->z) * input->ya; - float scale = ((float)(SPRINT_DURATION - sprintTime))/10.0f; + float scale = static_cast(SPRINT_DURATION - sprintTime)/10.0f; scale = scale * scale; if ( scale > 1.0f ) scale = 1.0f; flyX *= scale; @@ -575,7 +575,7 @@ float LocalPlayer::getFieldOfViewModifier() if (isUsingItem() && getUseItem()->id == Item::bow->id) { int ticksHeld = getTicksUsingItem(); - float scale = (float) ticksHeld / BowItem::MAX_DRAW_DURATION; + float scale = static_cast(ticksHeld) / BowItem::MAX_DRAW_DURATION; if (scale > 1) { scale = 1; @@ -785,7 +785,7 @@ void LocalPlayer::hurtTo(float newHealth, ETelemetryChallenges damageSource) if( this->getHealth() <= 0) { - int deathTime = (int)(level->getGameTime() % Level::TICKS_PER_DAY)/1000; + int deathTime = static_cast(level->getGameTime() % Level::TICKS_PER_DAY)/1000; int carriedId = inventory->getSelected() == NULL ? 0 : inventory->getSelected()->id; TelemetryManager->RecordPlayerDiedOrFailed(GetXboxPad(), 0, y, 0, 0, carriedId, 0, damageSource); @@ -835,7 +835,7 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param) if (stat->isAchievement()) { - Achievement *ach = (Achievement *) stat; + Achievement *ach = static_cast(stat); // 4J-PB - changed to attempt to award everytime - the award may need a storage device, so needs a primary player, and the player may not have been a primary player when they first 'got' the award // so let the award manager figure it out //if (!minecraft->stats[m_iPad]->hasTaken(ach)) @@ -861,7 +861,7 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param) } // 4J-JEV: To stop spamming trophies. - unsigned long long achBit = ((unsigned long long)1) << ach->getAchievementID(); + unsigned long long achBit = static_cast(1) << ach->getAchievementID(); if ( !(achBit & m_awardedThisSession) ) { ProfileManager.Award(m_iPad, ach->getAchievementID()); @@ -1248,7 +1248,7 @@ void LocalPlayer::onCrafted(shared_ptr item) { if( minecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(minecraft->localgameModes[m_iPad]); gameMode->getTutorial()->onCrafted(item); } } @@ -1270,8 +1270,8 @@ void LocalPlayer::mapPlayerChunk(const unsigned int flagTileType) int cx = this->xChunk; int cz = this->zChunk; - int pZ = ((int) floor(this->z)) %16; - int pX = ((int) floor(this->x)) %16; + int pZ = static_cast(floor(this->z)) %16; + int pX = static_cast(floor(this->x)) %16; cout<<"player in chunk ("<x<<","<y<<","<z<<")\n"; @@ -1359,9 +1359,9 @@ bool LocalPlayer::creativeModeHandleMouseClick(int button, bool buttonPressed) } // Get distance from last click point in each axis - float dX = (float)x - lastClickX; - float dY = (float)y - lastClickY; - float dZ = (float)z - lastClickZ; + float dX = static_cast(x) - lastClickX; + float dY = static_cast(y) - lastClickY; + float dZ = static_cast(z) - lastClickZ; bool newClick = false; float ddx = dX - lastClickdX; @@ -1467,9 +1467,9 @@ bool LocalPlayer::creativeModeHandleMouseClick(int button, bool buttonPressed) else { // First click - just record position & handle - lastClickX = (float)x; - lastClickY = (float)y; - lastClickZ = (float)z; + lastClickX = static_cast(x); + lastClickY = static_cast(y); + lastClickZ = static_cast(z); // If we actually placed an item, then move into the init state as we are going to be doing the special creative mode auto repeat bool itemPlaced = handleMouseClick(button); // If we're sprinting or riding, don't auto-repeat at all. With auto repeat on, we can quickly place fires causing photosensitivity issues due to rapid flashing @@ -1713,7 +1713,7 @@ void LocalPlayer::handleCollectItem(shared_ptr item) } } } - TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(minecraft->localgameModes[m_iPad]); gameMode->getTutorial()->onTake(item, itemCountAnyAux, itemCountThisAux); } diff --git a/Minecraft.Client/MinecartModel.cpp b/Minecraft.Client/MinecartModel.cpp index 8a1ce0d7f..0cb0764fb 100644 --- a/Minecraft.Client/MinecartModel.cpp +++ b/Minecraft.Client/MinecartModel.cpp @@ -16,23 +16,23 @@ MinecartModel::MinecartModel() : Model() int h = 16; int yOff = 4; - cubes[0]->addBox((float)(-w / 2), (float)(-h / 2), -1, w, h, 2, 0); - cubes[0]->setPos(0, (float)(0 + yOff), 0); + cubes[0]->addBox(static_cast(-w / 2), static_cast(-h / 2), -1, w, h, 2, 0); + cubes[0]->setPos(0, static_cast(0 + yOff), 0); - cubes[5]->addBox((float)(-w / 2 + 1), (float)(-h / 2 + 1), -1, w - 2, h - 2, 1, 0); - cubes[5]->setPos(0, (float)(0 + yOff), 0); + cubes[5]->addBox(static_cast(-w / 2 + 1), static_cast(-h / 2 + 1), -1, w - 2, h - 2, 1, 0); + cubes[5]->setPos(0, static_cast(0 + yOff), 0); - cubes[1]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); - cubes[1]->setPos((float)(-w / 2 + 1), (float)(0 + yOff), 0); + cubes[1]->addBox(static_cast(-w / 2 + 2), static_cast(-d - 1), -1, w - 4, d, 2, 0); + cubes[1]->setPos(static_cast(-w / 2 + 1), static_cast(0 + yOff), 0); - cubes[2]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); - cubes[2]->setPos((float)(+w / 2 - 1), (float)(0 + yOff), 0); + cubes[2]->addBox(static_cast(-w / 2 + 2), static_cast(-d - 1), -1, w - 4, d, 2, 0); + cubes[2]->setPos(static_cast(+w / 2 - 1), static_cast(0 + yOff), 0); - cubes[3]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); - cubes[3]->setPos(0, (float)(0 + yOff), (float)(-h / 2 + 1)); + cubes[3]->addBox(static_cast(-w / 2 + 2), static_cast(-d - 1), -1, w - 4, d, 2, 0); + cubes[3]->setPos(0, static_cast(0 + yOff), static_cast(-h / 2 + 1)); - cubes[4]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); - cubes[4]->setPos(0, (float)(0 + yOff), (float)(+h / 2 - 1)); + cubes[4]->addBox(static_cast(-w / 2 + 2), static_cast(-d - 1), -1, w - 4, d, 2, 0); + cubes[4]->setPos(0, static_cast(0 + yOff), static_cast(+h / 2 - 1)); cubes[0]->xRot = PI / 2; cubes[1]->yRot = PI / 2 * 3; diff --git a/Minecraft.Client/MinecartRenderer.cpp b/Minecraft.Client/MinecartRenderer.cpp index fd907019e..29b97b7ea 100644 --- a/Minecraft.Client/MinecartRenderer.cpp +++ b/Minecraft.Client/MinecartRenderer.cpp @@ -60,11 +60,11 @@ void MinecartRenderer::render(shared_ptr _cart, double x, double y, doub else { dir = dir->normalize(); - rot = (float) (atan2(dir->z, dir->x) * 180 / PI); - xRot = (float) (atan(dir->y) * 73); + rot = static_cast(atan2(dir->z, dir->x) * 180 / PI); + xRot = static_cast(atan(dir->y) * 73); } } - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); glRotatef(180 - rot, 0, 1, 0); glRotatef(-xRot, 0, 0, 1); diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index b197638cf..643a0bef3 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -483,10 +483,10 @@ void Minecraft::blit(int x, int y, int sx, int sy, int w, int h) float vs = 1 / 256.0f; Tesselator *t = Tesselator::getInstance(); t->begin(); - t->vertexUV((float)(x + 0), (float)( y + h), (float)( 0), (float)( (sx + 0) * us), (float)( (sy + h) * vs)); - t->vertexUV((float)(x + w), (float)( y + h), (float)( 0), (float)( (sx + w) * us), (float)( (sy + h) * vs)); - t->vertexUV((float)(x + w), (float)( y + 0), (float)( 0), (float)( (sx + w) * us), (float)( (sy + 0) * vs)); - t->vertexUV((float)(x + 0), (float)( y + 0), (float)( 0), (float)( (sx + 0) * us), (float)( (sy + 0) * vs)); + t->vertexUV(static_cast(x + 0), static_cast(y + h), static_cast(0), (float)( (sx + 0) * us), (float)( (sy + h) * vs)); + t->vertexUV(static_cast(x + w), static_cast(y + h), static_cast(0), (float)( (sx + w) * us), (float)( (sy + h) * vs)); + t->vertexUV(static_cast(x + w), static_cast(y + 0), static_cast(0), (float)( (sx + w) * us), (float)( (sy + 0) * vs)); + t->vertexUV(static_cast(x + 0), static_cast(y + 0), static_cast(0), (float)( (sx + 0) * us), (float)( (sy + 0) * vs)); t->end(); } @@ -1198,7 +1198,7 @@ void Minecraft::applyFrameMouseLook() g_KBMInput.ConsumeMouseDelta(rawDx, rawDy); if (rawDx == 0.0f && rawDy == 0.0f) continue; - float mouseSensitivity = ((float)app.GetGameSettings(iPad, eGameSetting_Sensitivity_InGame)) / 100.0f; + float mouseSensitivity = static_cast(app.GetGameSettings(iPad, eGameSetting_Sensitivity_InGame)) / 100.0f; float mdx = rawDx * mouseSensitivity; float mdy = -rawDy * mouseSensitivity; if (app.GetGameSettings(iPad, eGameSetting_ControlInvertLook)) @@ -1279,7 +1279,7 @@ void Minecraft::run_middle() if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack(); @@ -1910,7 +1910,7 @@ void Minecraft::run_middle() if( setLocalPlayerIdx(i) ) { PIXBeginNamedEvent(0,"Game render player idx %d",i); - RenderManager.StateSetViewport((C4JRender::eViewportType)player->m_iScreenSection); + RenderManager.StateSetViewport(static_cast(player->m_iScreenSection)); gameRenderer->render(timer->a, bFirst); bFirst = false; PIXEndNamedEvent(); @@ -1938,7 +1938,7 @@ void Minecraft::run_middle() if( unoccupiedQuadrant > -1 ) { // render a logo - RenderManager.StateSetViewport((C4JRender::eViewportType)(C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT + unoccupiedQuadrant)); + RenderManager.StateSetViewport(static_cast(C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT + unoccupiedQuadrant)); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); @@ -2097,7 +2097,7 @@ void Minecraft::renderFpsMeter(__int64 tickTime) glMatrixMode(GL_PROJECTION); glEnable(GL_COLOR_MATERIAL); glLoadIdentity(); - glOrtho(0, (float)width, (float)height, 0, 1000, 3000); + glOrtho(0, static_cast(width), static_cast(height), 0, 1000, 3000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -2000); @@ -2108,16 +2108,16 @@ void Minecraft::renderFpsMeter(__int64 tickTime) t->begin(GL_QUADS); int hh1 = (int) (nsPer60Fps / 200000); t->color(0x20000000); - t->vertex((float)(0), (float)( height - hh1), (float)( 0)); - t->vertex((float)(0), (float)( height), (float)( 0)); - t->vertex((float)(Minecraft::frameTimes_length), (float)( height), (float)( 0)); - t->vertex((float)(Minecraft::frameTimes_length), (float)( height - hh1), (float)( 0)); + t->vertex(static_cast(0), static_cast(height - hh1), static_cast(0)); + t->vertex(static_cast(0), static_cast(height), static_cast(0)); + t->vertex(static_cast(Minecraft::frameTimes_length), static_cast(height), static_cast(0)); + t->vertex(static_cast(Minecraft::frameTimes_length), static_cast(height - hh1), static_cast(0)); t->color(0x20200000); - t->vertex((float)(0), (float)( height - hh1 * 2), (float)( 0)); - t->vertex((float)(0), (float)( height - hh1), (float)( 0)); - t->vertex((float)(Minecraft::frameTimes_length), (float)( height - hh1), (float)( 0)); - t->vertex((float)(Minecraft::frameTimes_length), (float)( height - hh1 * 2), (float)( 0)); + t->vertex(static_cast(0), static_cast(height - hh1 * 2), static_cast(0)); + t->vertex(static_cast(0), static_cast(height - hh1), static_cast(0)); + t->vertex(static_cast(Minecraft::frameTimes_length), static_cast(height - hh1), static_cast(0)); + t->vertex(static_cast(Minecraft::frameTimes_length), static_cast(height - hh1 * 2), static_cast(0)); t->end(); __int64 totalTime = 0; @@ -2125,13 +2125,13 @@ void Minecraft::renderFpsMeter(__int64 tickTime) { totalTime += Minecraft::frameTimes[i]; } - int hh = (int) (totalTime / 200000 / Minecraft::frameTimes_length); + int hh = static_cast(totalTime / 200000 / Minecraft::frameTimes_length); t->begin(GL_QUADS); t->color(0x20400000); - t->vertex((float)(0), (float)( height - hh), (float)( 0)); - t->vertex((float)(0), (float)( height), (float)( 0)); - t->vertex((float)(Minecraft::frameTimes_length), (float)( height), (float)( 0)); - t->vertex((float)(Minecraft::frameTimes_length), (float)( height - hh), (float)( 0)); + t->vertex(static_cast(0), static_cast(height - hh), static_cast(0)); + t->vertex(static_cast(0), static_cast(height), static_cast(0)); + t->vertex(static_cast(Minecraft::frameTimes_length), static_cast(height), static_cast(0)); + t->vertex(static_cast(Minecraft::frameTimes_length), static_cast(height - hh), static_cast(0)); t->end(); t->begin(GL_LINES); for (int i = 0; i < Minecraft::frameTimes_length; i++) @@ -2153,16 +2153,16 @@ void Minecraft::renderFpsMeter(__int64 tickTime) __int64 time = Minecraft::frameTimes[i] / 200000; __int64 time2 = Minecraft::tickTimes[i] / 200000; - t->vertex((float)(i + 0.5f), (float)( height - time + 0.5f), (float)( 0)); - t->vertex((float)(i + 0.5f), (float)( height + 0.5f), (float)( 0)); + t->vertex((float)(i + 0.5f), (float)( height - time + 0.5f), static_cast(0)); + t->vertex((float)(i + 0.5f), (float)( height + 0.5f), static_cast(0)); // if (Minecraft.frameTimes[i]>nsPer60Fps) { t->color(0xff000000 + cc * 65536 + cc * 256 + cc * 1); // } else { // t.color(0xff808080 + cc/2 * 256); // } - t->vertex((float)(i + 0.5f), (float)( height - time + 0.5f), (float)( 0)); - t->vertex((float)(i + 0.5f), (float)( height - (time - time2) + 0.5f), (float)( 0)); + t->vertex((float)(i + 0.5f), (float)( height - time + 0.5f), static_cast(0)); + t->vertex((float)(i + 0.5f), (float)( height - (time - time2) + 0.5f), static_cast(0)); } t->end(); @@ -2223,7 +2223,7 @@ void Minecraft::verify() void Minecraft::levelTickUpdateFunc(void* pParam) { - Level* pLevel = (Level*)pParam; + Level* pLevel = static_cast(pParam); pLevel->tick(); } @@ -2499,7 +2499,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case Item::spiderEye_Id: // Check that we are actually hungry so will eat this item { - FoodItem *food = (FoodItem *)itemInstance->getItem(); + FoodItem *food = static_cast(itemInstance->getItem()); if (food != NULL && food->canEat(player)) { *piUse=IDS_TOOLTIPS_EAT; @@ -3329,7 +3329,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case eTYPE_ZOMBIE: { shared_ptr zomb = dynamic_pointer_cast(hitResult->entity); - static GoldenAppleItem *goldapple = (GoldenAppleItem *) Item::apple_gold; + static GoldenAppleItem *goldapple = static_cast(Item::apple_gold); //zomb->hasEffect(MobEffect::weakness) - not present on client. if ( zomb->isVillager() && zomb->isWeakened() && (heldItemId == Item::apple_gold_Id) && !goldapple->isFoil(heldItem) ) @@ -4397,8 +4397,8 @@ void Minecraft::prepareLevel(int title) Pos *spawnPos = level->getSharedSpawnPos(); if (player != NULL) { - spawnPos->x = (int) player->x; - spawnPos->z = (int) player->z; + spawnPos->x = static_cast(player->x); + spawnPos->z = static_cast(player->z); } #if 0 @@ -5008,7 +5008,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad, int int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) #endif { - Minecraft* pMinecraftClass = (Minecraft*)pParam; + Minecraft* pMinecraftClass = static_cast(pParam); if(g_NetworkManager.IsInSession()) { diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index 012ae19bd..f469c8b11 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -767,7 +767,7 @@ int MinecraftServer::runPostUpdate(void* lpParam) { ShutdownManager::HasStarted(ShutdownManager::ePostProcessThread); - MinecraftServer *server = (MinecraftServer *)lpParam; + MinecraftServer *server = static_cast(lpParam); Entity::useSmallIds(); // This thread can end up spawning entities as resources IntCache::CreateNewThreadStorage(); AABB::CreateNewThreadStorage(); @@ -1401,7 +1401,7 @@ void MinecraftServer::Suspend() LARGE_INTEGER qwTicksPerSec, qwTime, qwNewTime, qwDeltaTime; float fElapsedTime = 0.0f; QueryPerformanceFrequency( &qwTicksPerSec ); - float fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; + float fSecsPerTick = 1.0f / static_cast(qwTicksPerSec.QuadPart); // Save the start time QueryPerformanceCounter( &qwTime ); if(m_bLoaded && ProfileManager.IsFullVersion() && (!StorageManager.GetSaveDisabled())) @@ -1428,7 +1428,7 @@ void MinecraftServer::Suspend() QueryPerformanceCounter( &qwNewTime ); qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; - fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); + fElapsedTime = fSecsPerTick * static_cast(qwDeltaTime.QuadPart); // 4J-JEV: Flush stats and call PlayerSessionExit. for (int iPad = 0; iPad < XUSER_MAX_COUNT; iPad++) @@ -1702,7 +1702,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) bool findSeed = false; if(lpParameter != NULL) { - initData = (NetworkGameInitData *)lpParameter; + initData = static_cast(lpParameter); initSettings = app.GetGameHostOption(eGameHostOption_All); findSeed = initData->findSeed; m_texturePackId = initData->texturePackId; @@ -1917,7 +1917,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) case eXuiServerAction_SpawnMob: { shared_ptr player = players->players.at(0); - eINSTANCEOF factory = (eINSTANCEOF)((size_t)param); + eINSTANCEOF factory = static_cast((size_t)param); shared_ptr mob = dynamic_pointer_cast(EntityIO::newByEnumType(factory,player->level )); mob->moveTo(player->x+1, player->y, player->z+1, player->level->random->nextFloat() * 360, 0); mob->setDespawnProtected(); // 4J added, default to being protected against despawning (has to be done after initial position is set) @@ -1963,7 +1963,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) if( !s_bServerHalted ) { - ConsoleSchematicFile::XboxSchematicInitParam *initData = (ConsoleSchematicFile::XboxSchematicInitParam *)param; + ConsoleSchematicFile::XboxSchematicInitParam *initData = static_cast(param); #ifdef _XBOX File targetFileDir(File::pathRoot + File::pathSeparator + L"Schematics"); #else @@ -1989,7 +1989,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) case eXuiServerAction_SetCameraLocation: #ifndef _CONTENT_PACKAGE { - DebugSetCameraPosition *pos = (DebugSetCameraPosition *)param; + DebugSetCameraPosition *pos = static_cast(param); app.DebugPrintf( "DEBUG: Player=%i\n", pos->player ); app.DebugPrintf( "DEBUG: Teleporting to pos=(%f.2, %f.2, %f.2), looking at=(%f.2,%f.2)\n", @@ -2122,7 +2122,7 @@ void MinecraftServer::tick() static __int64 stc = 0; __int64 st0 = System::currentTimeMillis(); PIXBeginNamedEvent(0,"Level tick %d",i); - ((Level *)level)->tick(); + static_cast(level)->tick(); __int64 st1 = System::currentTimeMillis(); PIXEndNamedEvent(); PIXBeginNamedEvent(0,"Update lights %d",i); diff --git a/Minecraft.Client/Minimap.cpp b/Minecraft.Client/Minimap.cpp index 65c6d5f2c..9e07dbdf2 100644 --- a/Minecraft.Client/Minimap.cpp +++ b/Minecraft.Client/Minimap.cpp @@ -133,10 +133,10 @@ void Minimap::render(shared_ptr player, Textures *textures, shared_ptrvertexUV((float)(x + 0 + vo), (float)( y + h - vo), (float)( Offset), (float)( 0), (float)( 1)); - t->vertexUV((float)(x + w - vo), (float)( y + h - vo), (float)( Offset), (float)( 1), (float)( 1)); - t->vertexUV((float)(x + w - vo), (float)( y + 0 + vo), (float)( Offset), (float)( 1), (float)( 0)); - t->vertexUV((float)(x + 0 + vo), (float)( y + 0 + vo), (float)( Offset), (float)( 0), (float)( 0)); + t->vertexUV((float)(x + 0 + vo), (float)( y + h - vo), (float)( Offset), static_cast(0), static_cast(1)); + t->vertexUV((float)(x + w - vo), (float)( y + h - vo), (float)( Offset), static_cast(1), static_cast(1)); + t->vertexUV((float)(x + w - vo), (float)( y + 0 + vo), (float)( Offset), static_cast(1), static_cast(0)); + t->vertexUV((float)(x + 0 + vo), (float)( y + 0 + vo), (float)( Offset), static_cast(0), static_cast(0)); t->end(); glEnable(GL_ALPHA_TEST); glDisable(GL_BLEND); @@ -182,10 +182,10 @@ void Minimap::render(shared_ptr player, Textures *textures, shared_ptrbegin(); - t->vertexUV((float)(-1), (float)( +1), (float)( 0), (float)( u0), (float)( v0)); - t->vertexUV((float)(+1), (float)( +1), (float)( 0), (float)( u1), (float)( v0)); - t->vertexUV((float)(+1), (float)( -1), (float)( 0), (float)( u1), (float)( v1)); - t->vertexUV((float)(-1), (float)( -1), (float)( 0), (float)( u0), (float)( v1)); + t->vertexUV(static_cast(-1), static_cast(+1), static_cast(0), (float)( u0), (float)( v0)); + t->vertexUV(static_cast(+1), static_cast(+1), static_cast(0), (float)( u1), (float)( v0)); + t->vertexUV(static_cast(+1), static_cast(-1), static_cast(0), (float)( u1), (float)( v1)); + t->vertexUV(static_cast(-1), static_cast(-1), static_cast(0), (float)( u0), (float)( v1)); t->end(); glPopMatrix(); fIconZ-=0.01f; @@ -218,10 +218,10 @@ void Minimap::render(shared_ptr player, Textures *textures, shared_ptrbegin(); - t->vertexUV((float)(-1), (float)( +1), (float)( 0), (float)( u0), (float)( v0)); - t->vertexUV((float)(+1), (float)( +1), (float)( 0), (float)( u1), (float)( v0)); - t->vertexUV((float)(+1), (float)( -1), (float)( 0), (float)( u1), (float)( v1)); - t->vertexUV((float)(-1), (float)( -1), (float)( 0), (float)( u0), (float)( v1)); + t->vertexUV(static_cast(-1), static_cast(+1), static_cast(0), (float)( u0), (float)( v0)); + t->vertexUV(static_cast(+1), static_cast(+1), static_cast(0), (float)( u1), (float)( v0)); + t->vertexUV(static_cast(+1), static_cast(-1), static_cast(0), (float)( u1), (float)( v1)); + t->vertexUV(static_cast(-1), static_cast(-1), static_cast(0), (float)( u0), (float)( v1)); t->end(); glPopMatrix(); fIconZ-=0.01f; diff --git a/Minecraft.Client/MobRenderer.cpp b/Minecraft.Client/MobRenderer.cpp index ee5125302..4976f8a61 100644 --- a/Minecraft.Client/MobRenderer.cpp +++ b/Minecraft.Client/MobRenderer.cpp @@ -61,9 +61,9 @@ void MobRenderer::renderLeash(shared_ptr entity, double x, double y, double x += rotOffCos; z += rotOffSin; - double dx = (float) (endX - startX); - double dy = (float) (endY - startY); - double dz = (float) (endZ - startZ); + double dx = static_cast(endX - startX); + double dy = static_cast(endY - startY); + double dz = static_cast(endZ - startZ); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); @@ -92,9 +92,9 @@ void MobRenderer::renderLeash(shared_ptr entity, double x, double y, double { tessellator->color(rDarkCol, gDarkCol, bDarkCol, 1.0F); } - float aa = (float) k / (float) steps; - tessellator->vertex(x + (dx * aa) + 0, y + (dy * ((aa * aa) + aa) * 0.5) + ((((float) steps - (float) k) / (steps * 0.75F)) + 0.125F), z + (dz * aa)); - tessellator->vertex(x + (dx * aa) + width, y + (dy * ((aa * aa) + aa) * 0.5) + ((((float) steps - (float) k) / (steps * 0.75F)) + 0.125F) + width, z + (dz * aa)); + float aa = static_cast(k) / static_cast(steps); + tessellator->vertex(x + (dx * aa) + 0, y + (dy * ((aa * aa) + aa) * 0.5) + (((static_cast(steps) - static_cast(k)) / (steps * 0.75F)) + 0.125F), z + (dz * aa)); + tessellator->vertex(x + (dx * aa) + width, y + (dy * ((aa * aa) + aa) * 0.5) + (((static_cast(steps) - static_cast(k)) / (steps * 0.75F)) + 0.125F) + width, z + (dz * aa)); } tessellator->end(); @@ -109,9 +109,9 @@ void MobRenderer::renderLeash(shared_ptr entity, double x, double y, double { tessellator->color(rDarkCol, gDarkCol, bDarkCol, 1.0F); } - float aa = (float) k / (float) steps; - tessellator->vertex(x + (dx * aa) + 0, y + (dy * ((aa * aa) + aa) * 0.5) + ((((float) steps - (float) k) / (steps * 0.75F)) + 0.125F) + width, z + (dz * aa)); - tessellator->vertex(x + (dx * aa) + width, y + (dy * ((aa * aa) + aa) * 0.5) + ((((float) steps - (float) k) / (steps * 0.75F)) + 0.125F), z + (dz * aa) + width); + float aa = static_cast(k) / static_cast(steps); + tessellator->vertex(x + (dx * aa) + 0, y + (dy * ((aa * aa) + aa) * 0.5) + (((static_cast(steps) - static_cast(k)) / (steps * 0.75F)) + 0.125F) + width, z + (dz * aa)); + tessellator->vertex(x + (dx * aa) + width, y + (dy * ((aa * aa) + aa) * 0.5) + (((static_cast(steps) - static_cast(k)) / (steps * 0.75F)) + 0.125F), z + (dz * aa) + width); } tessellator->end(); diff --git a/Minecraft.Client/MobSpawnerRenderer.cpp b/Minecraft.Client/MobSpawnerRenderer.cpp index 02aac27fd..9b6e6a0e2 100644 --- a/Minecraft.Client/MobSpawnerRenderer.cpp +++ b/Minecraft.Client/MobSpawnerRenderer.cpp @@ -16,7 +16,7 @@ void MobSpawnerRenderer::render(shared_ptr _spawner, double x, doubl void MobSpawnerRenderer::render(BaseMobSpawner *spawner, double x, double y, double z, float a) { glPushMatrix(); - glTranslatef((float) x + 0.5f, (float) y, (float) z + 0.5f); + glTranslatef(static_cast(x) + 0.5f, static_cast(y), static_cast(z) + 0.5f); shared_ptr e = spawner->getDisplayEntity(); if (e != NULL) @@ -24,7 +24,7 @@ void MobSpawnerRenderer::render(BaseMobSpawner *spawner, double x, double y, dou e->setLevel(spawner->getLevel()); float s = 7 / 16.0f; glTranslatef(0, 0.4f, 0); - glRotatef((float) (spawner->oSpin + (spawner->spin - spawner->oSpin) * a) * 10, 0, 1, 0); + glRotatef(static_cast(spawner->oSpin + (spawner->spin - spawner->oSpin) * a) * 10, 0, 1, 0); glRotatef(-30, 1, 0, 0); glTranslatef(0, -0.4f, 0); glScalef(s, s, s); diff --git a/Minecraft.Client/Model.h b/Minecraft.Client/Model.h index 5a4b6f2e8..305c5a0a1 100644 --- a/Minecraft.Client/Model.h +++ b/Minecraft.Client/Model.h @@ -23,7 +23,7 @@ class Model virtual void render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) {} virtual void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr entity, unsigned int uiBitmaskOverrideAnim=0) {} virtual void prepareMobModel(shared_ptr mob, float time, float r, float a) {} - virtual ModelPart *getRandomModelPart(Random random) {return cubes.at(random.nextInt((int)cubes.size()));} + virtual ModelPart *getRandomModelPart(Random random) {return cubes.at(random.nextInt(static_cast(cubes.size())));} virtual ModelPart * AddOrRetrievePart(SKIN_BOX *pBox) { return NULL;} void setMapTex(wstring id, int x, int y); diff --git a/Minecraft.Client/ModelPart.cpp b/Minecraft.Client/ModelPart.cpp index c59a821c7..57424bc66 100644 --- a/Minecraft.Client/ModelPart.cpp +++ b/Minecraft.Client/ModelPart.cpp @@ -139,7 +139,7 @@ void ModelPart::addBox(float x0, float y0, float z0, int w, int h, int d, float void ModelPart::addTexBox(float x0, float y0, float z0, int w, int h, int d, int tex) { - cubes.push_back(new Cube(this, xTexOffs, yTexOffs, x0, y0, z0, w, h, d, (float)tex)); + cubes.push_back(new Cube(this, xTexOffs, yTexOffs, x0, y0, z0, w, h, d, static_cast(tex))); } void ModelPart::setPos(float x, float y, float z) @@ -307,8 +307,8 @@ void ModelPart::compile(float scale) ModelPart *ModelPart::setTexSize(int xs, int ys) { - this->xTexSize = (float)xs; - this->yTexSize = (float)ys; + this->xTexSize = static_cast(xs); + this->yTexSize = static_cast(ys); return this; } diff --git a/Minecraft.Client/MultiPlayerChunkCache.cpp b/Minecraft.Client/MultiPlayerChunkCache.cpp index a4c200bed..4a9ca59ae 100644 --- a/Minecraft.Client/MultiPlayerChunkCache.cpp +++ b/Minecraft.Client/MultiPlayerChunkCache.cpp @@ -65,7 +65,7 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level) { if( y >= 3 ) { - ((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15); + static_cast(waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15); } } } @@ -77,11 +77,11 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level) { if( y >= ( level->getSeaLevel() - 1 ) ) { - ((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15); + static_cast(waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15); } else { - ((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,2); + static_cast(waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,2); } } } @@ -294,7 +294,7 @@ void MultiPlayerChunkCache::recreateLogicStructuresForChunk(int chunkX, int chun wstring MultiPlayerChunkCache::gatherStats() { EnterCriticalSection(&m_csLoadCreate); - int size = (int)loadedChunkList.size(); + int size = static_cast(loadedChunkList.size()); LeaveCriticalSection(&m_csLoadCreate); return L"MultiplayerChunkCache: " + std::to_wstring(size); diff --git a/Minecraft.Client/MultiPlayerGameMode.cpp b/Minecraft.Client/MultiPlayerGameMode.cpp index 9c4b07959..7657039c7 100644 --- a/Minecraft.Client/MultiPlayerGameMode.cpp +++ b/Minecraft.Client/MultiPlayerGameMode.cpp @@ -163,7 +163,7 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) destroyingItem = minecraft->player->getCarriedItem(); destroyProgress = 0; destroyTicks = 0; - minecraft->level->destroyTileProgress(minecraft->player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, (int)(destroyProgress * 10) - 1); + minecraft->level->destroyTileProgress(minecraft->player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, static_cast(destroyProgress * 10) - 1); } } @@ -235,7 +235,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) destroyDelay = 5; } - minecraft->level->destroyTileProgress(minecraft->player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, (int)(destroyProgress * 10) - 1); + minecraft->level->destroyTileProgress(minecraft->player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, static_cast(destroyProgress * 10) - 1); } else { @@ -292,9 +292,9 @@ bool MultiPlayerGameMode::useItemOn(shared_ptr player, Level *level, sha { ensureHasSentCarriedItem(); } - float clickX = (float) hit->x - x; - float clickY = (float) hit->y - y; - float clickZ = (float) hit->z - z; + float clickX = static_cast(hit->x) - x; + float clickY = static_cast(hit->y) - y; + float clickZ = static_cast(hit->z) - z; bool didSomething = false; if (!player->isSneaking() || player->getCarriedItem() == NULL) diff --git a/Minecraft.Client/MultiPlayerLevel.cpp b/Minecraft.Client/MultiPlayerLevel.cpp index 86b2914f2..4b74bbf17 100644 --- a/Minecraft.Client/MultiPlayerLevel.cpp +++ b/Minecraft.Client/MultiPlayerLevel.cpp @@ -770,11 +770,11 @@ void MultiPlayerLevel::playLocalSound(double x, double y, double z, int iSound, // exhaggerate sound speed effect by making speed of sound ~= // 40 m/s instead of 300 m/s double delayInSeconds = sqrt(minDistSq) / 40.0; - minecraft->soundEngine->schedule(iSound, (float) x, (float) y, (float) z, volume, pitch, (int) Math::round(delayInSeconds * SharedConstants::TICKS_PER_SECOND)); + minecraft->soundEngine->schedule(iSound, static_cast(x), static_cast(y), static_cast(z), volume, pitch, static_cast(Math::round(delayInSeconds * SharedConstants::TICKS_PER_SECOND))); } else { - minecraft->soundEngine->play(iSound, (float) x, (float) y, (float) z, volume, pitch); + minecraft->soundEngine->play(iSound, static_cast(x), static_cast(y), static_cast(z), volume, pitch); } } } diff --git a/Minecraft.Client/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/MultiPlayerLocalPlayer.cpp index 25bf06bf1..3c3c34310 100644 --- a/Minecraft.Client/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/MultiPlayerLocalPlayer.cpp @@ -213,7 +213,7 @@ void MultiplayerLocalPlayer::completeUsingItem() Minecraft *pMinecraft = Minecraft::GetInstance(); if(useItem != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); Tutorial *tutorial = gameMode->getTutorial(); tutorial->completeUsingItem(useItem); } @@ -225,7 +225,7 @@ void MultiplayerLocalPlayer::onEffectAdded(MobEffectInstance *effect) Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); Tutorial *tutorial = gameMode->getTutorial(); tutorial->onEffectChanged(MobEffect::effects[effect->getId()]); } @@ -238,7 +238,7 @@ void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance *effect, bool doR Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); Tutorial *tutorial = gameMode->getTutorial(); tutorial->onEffectChanged(MobEffect::effects[effect->getId()]); } @@ -251,7 +251,7 @@ void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance *effect) Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); Tutorial *tutorial = gameMode->getTutorial(); tutorial->onEffectChanged(MobEffect::effects[effect->getId()],true); } @@ -324,7 +324,7 @@ bool MultiplayerLocalPlayer::isLocalPlayer() void MultiplayerLocalPlayer::sendRidingJump() { - connection->send(shared_ptr(new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::RIDING_JUMP, (int) (getJumpRidingScale() * 100.0f)))); + connection->send(shared_ptr(new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::RIDING_JUMP, static_cast(getJumpRidingScale() * 100.0f)))); } void MultiplayerLocalPlayer::sendOpenInventory() @@ -372,7 +372,7 @@ void MultiplayerLocalPlayer::ride(shared_ptr e) if( pMinecraft->localgameModes[m_iPad] != NULL ) { - TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; + TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); if(wasRiding && !isRiding) { gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Gameplay); diff --git a/Minecraft.Client/MushroomCowRenderer.cpp b/Minecraft.Client/MushroomCowRenderer.cpp index b5f9ba9f8..277e05d8a 100644 --- a/Minecraft.Client/MushroomCowRenderer.cpp +++ b/Minecraft.Client/MushroomCowRenderer.cpp @@ -42,7 +42,7 @@ void MushroomCowRenderer::additionalRendering(shared_ptr _mob, flo glPopMatrix(); glPushMatrix(); - ((QuadrupedModel *) model)->head->translateTo(1 / 16.0f); + static_cast(model)->head->translateTo(1 / 16.0f); glScalef(1, -1, 1); glTranslatef(0, 0.75f, -0.2f); glRotatef(12, 0, 1, 0); diff --git a/Minecraft.Client/NetherPortalParticle.cpp b/Minecraft.Client/NetherPortalParticle.cpp index 4b70d38f5..9dcdd4ce5 100644 --- a/Minecraft.Client/NetherPortalParticle.cpp +++ b/Minecraft.Client/NetherPortalParticle.cpp @@ -33,14 +33,14 @@ NetherPortalParticle::NetherPortalParticle(Level *level, double x, double y, dou gCol = (g/255.0f)*br; bCol = (b/255.0f)*br; - lifetime = (int) (Math::random()*10) + 40; + lifetime = static_cast(Math::random() * 10) + 40; noPhysics = true; - setMiscTex((int)(Math::random()*8)); + setMiscTex(static_cast(Math::random() * 8)); } void NetherPortalParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) { - float s = (age + a) / (float) lifetime; + float s = (age + a) / static_cast(lifetime); s = 1-s; s = s*s; s = 1-s; @@ -53,13 +53,13 @@ int NetherPortalParticle::getLightColor(float a) { int br = Particle::getLightColor(a); - float pos = age/(float)lifetime; + float pos = age/static_cast(lifetime); pos = pos*pos; pos = pos*pos; int br1 = (br) & 0xff; int br2 = (br >> 16) & 0xff; - br2 += (int) (pos * 15 * 16); + br2 += static_cast(pos * 15 * 16); if (br2 > 15 * 16) br2 = 15 * 16; return br1 | br2 << 16; } @@ -67,7 +67,7 @@ int NetherPortalParticle::getLightColor(float a) float NetherPortalParticle::getBrightness(float a) { float br = Particle::getBrightness(a); - float pos = age/(float)lifetime; + float pos = age/static_cast(lifetime); pos = pos*pos; pos = pos*pos; return br*(1-pos)+pos; @@ -79,7 +79,7 @@ void NetherPortalParticle::tick() yo = y; zo = z; - float pos = age/(float)lifetime; + float pos = age/static_cast(lifetime); float a = pos; pos = -pos+pos*pos*2; // pos = pos*pos; diff --git a/Minecraft.Client/NoteParticle.cpp b/Minecraft.Client/NoteParticle.cpp index 2e2320c8a..6d2a31cdb 100644 --- a/Minecraft.Client/NoteParticle.cpp +++ b/Minecraft.Client/NoteParticle.cpp @@ -22,8 +22,8 @@ void NoteParticle::init(Level *level, double x, double y, double z, double xa, d // 4J-JEV: Added, // There are 24 valid colours for this particle input through the 'xa' field (0.0-1.0). - int note = (int) floor(0.5 + (xa*24.0)) + (int) eMinecraftColour_Particle_Note_00; - unsigned int col = Minecraft::GetInstance()->getColourTable()->getColor( (eMinecraftColour) note ); + int note = static_cast(floor(0.5 + (xa * 24.0))) + static_cast(eMinecraftColour_Particle_Note_00); + unsigned int col = Minecraft::GetInstance()->getColourTable()->getColor( static_cast(note) ); rCol = ( (col>>16)&0xFF )/255.0; gCol = ( (col>>8)&0xFF )/255.0; diff --git a/Minecraft.Client/OffsettedRenderList.cpp b/Minecraft.Client/OffsettedRenderList.cpp index 729d26f92..0a93fa921 100644 --- a/Minecraft.Client/OffsettedRenderList.cpp +++ b/Minecraft.Client/OffsettedRenderList.cpp @@ -20,9 +20,9 @@ void OffsettedRenderList::init(int x, int y, int z, double xOff, double yOff, do this->y = y; this->z = z; - this->xOff = (float) xOff; - this->yOff = (float) yOff; - this->zOff = (float) zOff; + this->xOff = static_cast(xOff); + this->yOff = static_cast(yOff); + this->zOff = static_cast(zOff); } bool OffsettedRenderList::isAt(int x, int y, int z) diff --git a/Minecraft.Client/Options.cpp b/Minecraft.Client/Options.cpp index fac7fe13e..d7e032fc6 100644 --- a/Minecraft.Client/Options.cpp +++ b/Minecraft.Client/Options.cpp @@ -76,7 +76,7 @@ bool Options::Option::isBoolean() const int Options::Option::getId() const { - return (int)(this-options); + return static_cast(this - options); } wstring Options::Option::getCaptionId() const @@ -417,7 +417,7 @@ void Options::load() // 4J - removed try/catch // try { wstring cmds[2]; - int splitpos = (int)line.find(L":"); + int splitpos = static_cast(line.find(L":")); if( splitpos == wstring::npos ) { cmds[0] = line; diff --git a/Minecraft.Client/OptionsScreen.cpp b/Minecraft.Client/OptionsScreen.cpp index b5c2f5e60..197d74763 100644 --- a/Minecraft.Client/OptionsScreen.cpp +++ b/Minecraft.Client/OptionsScreen.cpp @@ -49,7 +49,7 @@ void OptionsScreen::buttonClicked(Button *button) if (!button->active) return; if (button->id < 100 && (dynamic_cast(button) != NULL)) { - options->toggle(((SmallButton *) button)->getOption(), 1); + options->toggle(static_cast(button)->getOption(), 1); button->msg = options->getMessage(Options::Option::getItem(button->id)); } if (button->id == VIDEO_BUTTON_ID) diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl index a6b7dda24..b0bf146dc 100644 --- a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl @@ -368,7 +368,7 @@ static void gdraw_HandleTransitionInsertBefore(GDrawHandle *t, GDrawHandleState { check_lists(t->cache); assert(t->state != GDRAW_HANDLE_STATE_sentinel); // sentinels should never get here! - assert(t->state != (U32) new_state); // code should never call "transition" if it's not transitioning! + assert(t->state != static_cast(new_state)); // code should never call "transition" if it's not transitioning! // unlink from prev state t->prev->next = t->next; t->next->prev = t->prev; @@ -778,7 +778,7 @@ static GDrawTexture *gdraw_BlurPass(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRe if (!g->TextureDrawBufferBegin(draw_bounds, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats)) return r->tex[0]; - c->BlurPass(r, taps, data, draw_bounds, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, draw_bounds, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -830,7 +830,7 @@ static GDrawTexture *gdraw_BlurPassDownsample(GDrawFunctions *g, GDrawBlurInfo * assert(clamp[0] <= clamp[2]); assert(clamp[1] <= clamp[3]); - c->BlurPass(r, taps, data, &z, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, &z, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -842,7 +842,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR GDrawTexture *t; F32 data[MAX_TAPS][4]; S32 off_axis = 1-axis; - S32 w = ((S32) ceil((blur_width-1)/2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 + S32 w = static_cast(ceil((blur_width - 1) / 2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 F32 edge_weight = 1 - (w - blur_width)/2; // 3 => 0 => 1; 1.2 => 1.8 => 0.9 => 0.1 F32 inverse_weight = 1.0f / blur_width; @@ -949,7 +949,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR // max coverage is 25 samples, or a filter width of 13. with 7 taps, we sample // 13 samples in one pass, max coverage is 13*13 samples or (13*13-1)/2 width, // which is ((2T-1)*(2T-1)-1)/2 or (4T^2 - 4T + 1 -1)/2 or 2T^2 - 2T or 2T*(T-1) - S32 w_mip = (S32) ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS)); + S32 w_mip = static_cast(ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS))); S32 downsample = w_mip; F32 sample_spacing = texel; if (downsample < 2) downsample = 2; diff --git a/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp index 7f7c62d68..b9c4a6ed1 100644 --- a/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp +++ b/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp @@ -108,7 +108,7 @@ void SonyHttp_Orbis::printSslCertInfo(int libsslCtxId,SceSslCert *sslCert) app.DebugPrintf("sceSslGetSerialNumber() returns 0x%x\n", ret); } else { - sboData = (SceUChar8*)malloc(sboLen); + sboData = static_cast(malloc(sboLen)); if ( sboData != NULL ) { ret = sceSslGetSerialNumber(libsslCtxId, sslCert, sboData, &sboLen); if (ret < 0){ @@ -141,10 +141,10 @@ SceInt32 SonyHttp_Orbis::sslCallback(int libsslCtxId,unsigned int verifyErr,SceS (void)userArg; app.DebugPrintf("Ssl callback:\n"); - app.DebugPrintf("\tbase tmpl[%x]\n", (*(SceInt32*)(userArg)) ); + app.DebugPrintf("\tbase tmpl[%x]\n", (*static_cast(userArg)) ); if (verifyErr != 0){ - printSslError((SceInt32)SCE_HTTPS_ERROR_CERT, verifyErr); + printSslError(static_cast(SCE_HTTPS_ERROR_CERT), verifyErr); } for (i = 0; i < certNum; i++){ printSslCertInfo(libsslCtxId,sslCert[i]); @@ -202,7 +202,7 @@ bool SonyHttp_Orbis::http_get(const char *targetUrl, void** ppOutData, int* pDat } /* Register SSL callback */ - ret = sceHttpsSetSslCallback(tmplId, sslCallback, (void*)&tmplId); + ret = sceHttpsSetSslCallback(tmplId, sslCallback, static_cast(&tmplId)); if (ret < 0) { app.DebugPrintf("sceHttpsSetSslCallback() error: 0x%08X\n", ret); diff --git a/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp index e248f602c..0af059a90 100644 --- a/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp +++ b/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp @@ -26,7 +26,7 @@ static SceRemoteStorageData s_getDataOutput; void SonyRemoteStorage_Orbis::staticInternalCallback(const SceRemoteStorageEvent event, int32_t retCode, void * userData) { - ((SonyRemoteStorage_Orbis*)userData)->internalCallback(event, retCode); + static_cast(userData)->internalCallback(event, retCode); } void SonyRemoteStorage_Orbis::internalCallback(const SceRemoteStorageEvent event, int32_t retCode) { diff --git a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl index 811f524a9..c8a3b42ea 100644 --- a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl +++ b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl @@ -274,23 +274,23 @@ static int pshader_basic_econst[28] = { static ProgramWithCachedVariableLocations pshader_basic_arr[18] = { { { pshader_basic_0 }, { NULL }, { -1, 7, -1, -1, -1, } }, - { { pshader_basic_1 }, { NULL }, { -1, 7, -1, (int) (intptr_t) (pshader_basic_econst + 0), -1, } }, - { { pshader_basic_2 }, { NULL }, { -1, 7, -1, (int) (intptr_t) (pshader_basic_econst + 0), -1, } }, + { { pshader_basic_1 }, { NULL }, { -1, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 0)), -1, } }, + { { pshader_basic_2 }, { NULL }, { -1, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 0)), -1, } }, { { pshader_basic_3 }, { NULL }, { 0, 7, -1, -1, -1, } }, - { { pshader_basic_4 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 2), -1, } }, - { { pshader_basic_5 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 4), -1, } }, + { { pshader_basic_4 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 2)), -1, } }, + { { pshader_basic_5 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 4)), -1, } }, { { pshader_basic_6 }, { NULL }, { 0, 7, -1, -1, -1, } }, - { { pshader_basic_7 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 6), -1, } }, - { { pshader_basic_8 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 6), -1, } }, + { { pshader_basic_7 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, + { { pshader_basic_8 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, { { pshader_basic_9 }, { NULL }, { 0, 7, -1, -1, -1, } }, - { { pshader_basic_10 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 8), -1, } }, - { { pshader_basic_11 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 10), -1, } }, - { { pshader_basic_12 }, { NULL }, { 0, 7, -1, -1, (int) (intptr_t) (pshader_basic_econst + 12), } }, - { { pshader_basic_13 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 16), (int) (intptr_t) (pshader_basic_econst + 18), } }, - { { pshader_basic_14 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 22), (int) (intptr_t) (pshader_basic_econst + 24), } }, + { { pshader_basic_10 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 8)), -1, } }, + { { pshader_basic_11 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 10)), -1, } }, + { { pshader_basic_12 }, { NULL }, { 0, 7, -1, -1, static_cast((intptr_t)(pshader_basic_econst + 12)), } }, + { { pshader_basic_13 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 16)), static_cast((intptr_t)(pshader_basic_econst + 18)), } }, + { { pshader_basic_14 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 22)), static_cast((intptr_t)(pshader_basic_econst + 24)), } }, { { pshader_basic_15 }, { NULL }, { 0, 7, -1, -1, -1, } }, - { { pshader_basic_16 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 2), -1, } }, - { { pshader_basic_17 }, { NULL }, { 0, 7, -1, (int) (intptr_t) (pshader_basic_econst + 6), -1, } }, + { { pshader_basic_16 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 2)), -1, } }, + { { pshader_basic_17 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, }; static unsigned char pshader_exceptional_blend_1[368] = { @@ -537,18 +537,18 @@ static int pshader_exceptional_blend_econst[4] = { static ProgramWithCachedVariableLocations pshader_exceptional_blend_arr[13] = { { { NULL }, { NULL }, { -1, -1, -1, -1, } }, - { { pshader_exceptional_blend_1 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_2 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_3 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_4 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_5 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_6 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_7 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_8 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_9 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_10 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 0), } }, - { { pshader_exceptional_blend_11 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 2), } }, - { { pshader_exceptional_blend_12 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_exceptional_blend_econst + 2), } }, + { { pshader_exceptional_blend_1 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_2 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_3 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_4 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_5 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_6 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_7 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_8 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_9 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_10 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_11 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 2)), } }, + { { pshader_exceptional_blend_12 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 2)), } }, }; static unsigned char pshader_filter_0[416] = { @@ -1121,34 +1121,34 @@ static int pshader_filter_econst[90] = { }; static ProgramWithCachedVariableLocations pshader_filter_arr[32] = { - { { pshader_filter_0 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 0), (int) (intptr_t) (pshader_filter_econst + 2), -1, (int) (intptr_t) (pshader_filter_econst + 5), (int) (intptr_t) (pshader_filter_econst + 8), -1, } }, - { { pshader_filter_1 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 11), (int) (intptr_t) (pshader_filter_econst + 2), -1, (int) (intptr_t) (pshader_filter_econst + 5), (int) (intptr_t) (pshader_filter_econst + 8), -1, } }, - { { pshader_filter_2 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 13), 2, (int) (intptr_t) (pshader_filter_econst + 16), (int) (intptr_t) (pshader_filter_econst + 5), -1, } }, - { { pshader_filter_3 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 13), 2, (int) (intptr_t) (pshader_filter_econst + 16), (int) (intptr_t) (pshader_filter_econst + 5), -1, } }, - { { pshader_filter_4 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 19), (int) (intptr_t) (pshader_filter_econst + 2), -1, (int) (intptr_t) (pshader_filter_econst + 5), (int) (intptr_t) (pshader_filter_econst + 8), -1, } }, - { { pshader_filter_5 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 11), (int) (intptr_t) (pshader_filter_econst + 2), -1, (int) (intptr_t) (pshader_filter_econst + 5), (int) (intptr_t) (pshader_filter_econst + 8), -1, } }, - { { pshader_filter_6 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 2), 2, (int) (intptr_t) (pshader_filter_econst + 5), (int) (intptr_t) (pshader_filter_econst + 8), -1, } }, - { { pshader_filter_7 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 13), 2, (int) (intptr_t) (pshader_filter_econst + 16), (int) (intptr_t) (pshader_filter_econst + 5), -1, } }, - { { pshader_filter_8 }, { NULL }, { -1, 1, (int) (intptr_t) (pshader_filter_econst + 21), -1, -1, -1, (int) (intptr_t) (pshader_filter_econst + 24), -1, } }, - { { pshader_filter_9 }, { NULL }, { -1, -1, (int) (intptr_t) (pshader_filter_econst + 27), -1, -1, -1, -1, -1, } }, - { { pshader_filter_10 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 2), 2, (int) (intptr_t) (pshader_filter_econst + 5), (int) (intptr_t) (pshader_filter_econst + 8), -1, } }, - { { pshader_filter_11 }, { NULL }, { 0, -1, -1, (int) (intptr_t) (pshader_filter_econst + 29), 2, (int) (intptr_t) (pshader_filter_econst + 32), -1, -1, } }, + { { pshader_filter_0 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 0)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_1 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 11)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_2 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, + { { pshader_filter_3 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, + { { pshader_filter_4 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 19)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_5 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 11)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_6 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 2)), 2, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_7 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, + { { pshader_filter_8 }, { NULL }, { -1, 1, static_cast((intptr_t)(pshader_filter_econst + 21)), -1, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 24)), -1, } }, + { { pshader_filter_9 }, { NULL }, { -1, -1, static_cast((intptr_t)(pshader_filter_econst + 27)), -1, -1, -1, -1, -1, } }, + { { pshader_filter_10 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 2)), 2, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_11 }, { NULL }, { 0, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 29)), 2, static_cast((intptr_t)(pshader_filter_econst + 32)), -1, -1, } }, { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, - { { pshader_filter_16 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 35), (int) (intptr_t) (pshader_filter_econst + 37), -1, (int) (intptr_t) (pshader_filter_econst + 41), (int) (intptr_t) (pshader_filter_econst + 46), (int) (intptr_t) (pshader_filter_econst + 49), } }, - { { pshader_filter_17 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 47), (int) (intptr_t) (pshader_filter_econst + 37), -1, (int) (intptr_t) (pshader_filter_econst + 41), (int) (intptr_t) (pshader_filter_econst + 51), (int) (intptr_t) (pshader_filter_econst + 35), } }, - { { pshader_filter_18 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 37), 2, (int) (intptr_t) (pshader_filter_econst + 54), (int) (intptr_t) (pshader_filter_econst + 59), -1, } }, - { { pshader_filter_19 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 62), 2, (int) (intptr_t) (pshader_filter_econst + 41), (int) (intptr_t) (pshader_filter_econst + 66), -1, } }, - { { pshader_filter_20 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 35), (int) (intptr_t) (pshader_filter_econst + 37), -1, (int) (intptr_t) (pshader_filter_econst + 41), (int) (intptr_t) (pshader_filter_econst + 46), (int) (intptr_t) (pshader_filter_econst + 49), } }, - { { pshader_filter_21 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 47), (int) (intptr_t) (pshader_filter_econst + 37), -1, (int) (intptr_t) (pshader_filter_econst + 41), (int) (intptr_t) (pshader_filter_econst + 51), (int) (intptr_t) (pshader_filter_econst + 35), } }, - { { pshader_filter_22 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 69), 2, (int) (intptr_t) (pshader_filter_econst + 41), (int) (intptr_t) (pshader_filter_econst + 73), -1, } }, - { { pshader_filter_23 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 62), 2, (int) (intptr_t) (pshader_filter_econst + 41), (int) (intptr_t) (pshader_filter_econst + 66), -1, } }, - { { pshader_filter_24 }, { NULL }, { 0, 1, (int) (intptr_t) (pshader_filter_econst + 35), (int) (intptr_t) (pshader_filter_econst + 37), -1, (int) (intptr_t) (pshader_filter_econst + 41), (int) (intptr_t) (pshader_filter_econst + 46), (int) (intptr_t) (pshader_filter_econst + 49), } }, - { { pshader_filter_25 }, { NULL }, { 0, -1, (int) (intptr_t) (pshader_filter_econst + 76), (int) (intptr_t) (pshader_filter_econst + 37), -1, (int) (intptr_t) (pshader_filter_econst + 41), -1, (int) (intptr_t) (pshader_filter_econst + 67), } }, - { { pshader_filter_26 }, { NULL }, { 0, 1, -1, (int) (intptr_t) (pshader_filter_econst + 78), 2, (int) (intptr_t) (pshader_filter_econst + 82), (int) (intptr_t) (pshader_filter_econst + 87), -1, } }, - { { pshader_filter_27 }, { NULL }, { 0, -1, -1, (int) (intptr_t) (pshader_filter_econst + 37), 2, (int) (intptr_t) (pshader_filter_econst + 41), -1, -1, } }, + { { pshader_filter_16 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, + { { pshader_filter_17 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 47)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 51)), static_cast((intptr_t)(pshader_filter_econst + 35)), } }, + { { pshader_filter_18 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 37)), 2, static_cast((intptr_t)(pshader_filter_econst + 54)), static_cast((intptr_t)(pshader_filter_econst + 59)), -1, } }, + { { pshader_filter_19 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 62)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 66)), -1, } }, + { { pshader_filter_20 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, + { { pshader_filter_21 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 47)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 51)), static_cast((intptr_t)(pshader_filter_econst + 35)), } }, + { { pshader_filter_22 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 69)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 73)), -1, } }, + { { pshader_filter_23 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 62)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 66)), -1, } }, + { { pshader_filter_24 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, + { { pshader_filter_25 }, { NULL }, { 0, -1, static_cast((intptr_t)(pshader_filter_econst + 76)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), -1, static_cast((intptr_t)(pshader_filter_econst + 67)), } }, + { { pshader_filter_26 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 78)), 2, static_cast((intptr_t)(pshader_filter_econst + 82)), static_cast((intptr_t)(pshader_filter_econst + 87)), -1, } }, + { { pshader_filter_27 }, { NULL }, { 0, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 37)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), -1, -1, } }, { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, @@ -1562,14 +1562,14 @@ static int pshader_blur_econst[256] = { static ProgramWithCachedVariableLocations pshader_blur_arr[10] = { { { NULL }, { NULL }, { -1, -1, -1, } }, { { NULL }, { NULL }, { -1, -1, -1, } }, - { { pshader_blur_2 }, { NULL }, { 0, (int) (intptr_t) (pshader_blur_econst + 0), (int) (intptr_t) (pshader_blur_econst + 13), } }, - { { pshader_blur_3 }, { NULL }, { 0, (int) (intptr_t) (pshader_blur_econst + 18), (int) (intptr_t) (pshader_blur_econst + 33), } }, - { { pshader_blur_4 }, { NULL }, { 0, (int) (intptr_t) (pshader_blur_econst + 40), (int) (intptr_t) (pshader_blur_econst + 57), } }, - { { pshader_blur_5 }, { NULL }, { 0, (int) (intptr_t) (pshader_blur_econst + 66), (int) (intptr_t) (pshader_blur_econst + 85), } }, - { { pshader_blur_6 }, { NULL }, { 0, (int) (intptr_t) (pshader_blur_econst + 96), (int) (intptr_t) (pshader_blur_econst + 117), } }, - { { pshader_blur_7 }, { NULL }, { 0, (int) (intptr_t) (pshader_blur_econst + 130), (int) (intptr_t) (pshader_blur_econst + 153), } }, - { { pshader_blur_8 }, { NULL }, { 0, (int) (intptr_t) (pshader_blur_econst + 168), (int) (intptr_t) (pshader_blur_econst + 193), } }, - { { pshader_blur_9 }, { NULL }, { 0, (int) (intptr_t) (pshader_blur_econst + 210), (int) (intptr_t) (pshader_blur_econst + 237), } }, + { { pshader_blur_2 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 0)), static_cast((intptr_t)(pshader_blur_econst + 13)), } }, + { { pshader_blur_3 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 18)), static_cast((intptr_t)(pshader_blur_econst + 33)), } }, + { { pshader_blur_4 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 40)), static_cast((intptr_t)(pshader_blur_econst + 57)), } }, + { { pshader_blur_5 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 66)), static_cast((intptr_t)(pshader_blur_econst + 85)), } }, + { { pshader_blur_6 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 96)), static_cast((intptr_t)(pshader_blur_econst + 117)), } }, + { { pshader_blur_7 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 130)), static_cast((intptr_t)(pshader_blur_econst + 153)), } }, + { { pshader_blur_8 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 168)), static_cast((intptr_t)(pshader_blur_econst + 193)), } }, + { { pshader_blur_9 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 210)), static_cast((intptr_t)(pshader_blur_econst + 237)), } }, }; static unsigned char pshader_color_matrix_0[336] = { @@ -1598,7 +1598,7 @@ static int pshader_color_matrix_econst[12] = { }; static ProgramWithCachedVariableLocations pshader_color_matrix_arr[1] = { - { { pshader_color_matrix_0 }, { NULL }, { 0, (int) (intptr_t) (pshader_color_matrix_econst + 0), } }, + { { pshader_color_matrix_0 }, { NULL }, { 0, static_cast((intptr_t)(pshader_color_matrix_econst + 0)), } }, }; static unsigned char vshader_vsps3_0[272] = { diff --git a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_shared.inl index 86293ab6d..639b4c921 100644 --- a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_shared.inl @@ -368,7 +368,7 @@ static void gdraw_HandleTransitionInsertBefore(GDrawHandle *t, GDrawHandleState { check_lists(t->cache); assert(t->state != GDRAW_HANDLE_STATE_sentinel); // sentinels should never get here! - assert(t->state != (U32) new_state); // code should never call "transition" if it's not transitioning! + assert(t->state != static_cast(new_state)); // code should never call "transition" if it's not transitioning! // unlink from prev state t->prev->next = t->next; t->next->prev = t->prev; @@ -778,7 +778,7 @@ static GDrawTexture *gdraw_BlurPass(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRe if (!g->TextureDrawBufferBegin(draw_bounds, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats)) return r->tex[0]; - c->BlurPass(r, taps, data, draw_bounds, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, draw_bounds, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -830,7 +830,7 @@ static GDrawTexture *gdraw_BlurPassDownsample(GDrawFunctions *g, GDrawBlurInfo * assert(clamp[0] <= clamp[2]); assert(clamp[1] <= clamp[3]); - c->BlurPass(r, taps, data, &z, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, &z, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -842,7 +842,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR GDrawTexture *t; F32 data[MAX_TAPS][4]; S32 off_axis = 1-axis; - S32 w = ((S32) ceil((blur_width-1)/2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 + S32 w = static_cast(ceil((blur_width - 1) / 2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 F32 edge_weight = 1 - (w - blur_width)/2; // 3 => 0 => 1; 1.2 => 1.8 => 0.9 => 0.1 F32 inverse_weight = 1.0f / blur_width; @@ -949,7 +949,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR // max coverage is 25 samples, or a filter width of 13. with 7 taps, we sample // 13 samples in one pass, max coverage is 13*13 samples or (13*13-1)/2 width, // which is ((2T-1)*(2T-1)-1)/2 or (4T^2 - 4T + 1 -1)/2 or 2T^2 - 2T or 2T*(T-1) - S32 w_mip = (S32) ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS)); + S32 w_mip = static_cast(ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS))); S32 downsample = w_mip; F32 sample_spacing = texel; if (downsample < 2) downsample = 2; diff --git a/Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp b/Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp index d38a1bc93..5f804051e 100644 --- a/Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp +++ b/Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp @@ -27,7 +27,7 @@ bool SonyHttp_PS3::loadCerts(size_t *numBufPtr, CellHttpsData **caListPtr) int ret = 0; char *buf = NULL; - caList = (CellHttpsData *)malloc(sizeof(CellHttpsData)*2); + caList = static_cast(malloc(sizeof(CellHttpsData) * 2)); if (NULL == caList) { app.DebugPrintf("failed to malloc cert data"); return false; @@ -39,7 +39,7 @@ bool SonyHttp_PS3::loadCerts(size_t *numBufPtr, CellHttpsData **caListPtr) return ret; } - buf = (char*)malloc(size); + buf = static_cast(malloc(size)); if (NULL == buf) { app.DebugPrintf("failed to malloc cert buffer"); free(caList); @@ -244,7 +244,7 @@ void* SonyHttp_PS3::getData(const char* url, int* pDataSize) } int bufferSize = length; - char* buffer = (char*)malloc(bufferSize+1); + char* buffer = static_cast(malloc(bufferSize + 1)); recvd = 0; diff --git a/Minecraft.Client/PS3/Network/SonyRemoteStorage_PS3.cpp b/Minecraft.Client/PS3/Network/SonyRemoteStorage_PS3.cpp index bdd58e17c..a1f6c7fde 100644 --- a/Minecraft.Client/PS3/Network/SonyRemoteStorage_PS3.cpp +++ b/Minecraft.Client/PS3/Network/SonyRemoteStorage_PS3.cpp @@ -86,7 +86,7 @@ int SonyRemoteStorage_PS3::initPreconditions() void SonyRemoteStorage_PS3::staticInternalCallback(const SceRemoteStorageEvent event, int32_t retCode, void * userData) { - ((SonyRemoteStorage_PS3*)userData)->internalCallback(event, retCode); + static_cast(userData)->internalCallback(event, retCode); } void SonyRemoteStorage_PS3::internalCallback(const SceRemoteStorageEvent event, int32_t retCode) @@ -430,20 +430,20 @@ void SonyRemoteStorage_PS3::runCallback() int SonyRemoteStorage_PS3::SaveCompressCallback(LPVOID lpParam,bool bRes) { - SonyRemoteStorage_PS3* pRS = (SonyRemoteStorage_PS3*)lpParam; + SonyRemoteStorage_PS3* pRS = static_cast(lpParam); pRS->m_compressedSaveState = e_state_Idle; return 0; } int SonyRemoteStorage_PS3::LoadCompressCallback(void *pParam,bool bIsCorrupt, bool bIsOwner) { - SonyRemoteStorage_PS3* pRS = (SonyRemoteStorage_PS3*)pParam; + SonyRemoteStorage_PS3* pRS = static_cast(pParam); int origFilesize = StorageManager.GetSaveSize(); void* pOrigSaveData = malloc(origFilesize); unsigned int retFilesize; StorageManager.GetSaveData( pOrigSaveData, &retFilesize ); // check if this save file is already compressed - if(*((int*)pOrigSaveData) != 0) + if(*static_cast(pOrigSaveData) != 0) { app.DebugPrintf("compressing save data\n"); @@ -451,7 +451,7 @@ int SonyRemoteStorage_PS3::LoadCompressCallback(void *pParam,bool bIsCorrupt, bo // We add 4 bytes to the start so that we can signal compressed data // And another 4 bytes to store the decompressed data size unsigned int compLength = origFilesize+8; - byte *compData = (byte *)malloc( compLength ); + byte *compData = static_cast(malloc(compLength)); Compression::UseDefaultThreadStorage(); Compression::getCompression()->Compress(compData+8,&compLength,pOrigSaveData,origFilesize); ZeroMemory(compData,8); diff --git a/Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp b/Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp index 03d916ab4..a07646047 100644 --- a/Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp +++ b/Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp @@ -17,7 +17,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID) } l10n_convert_str( cd, wchString, &src_len, NULL, &dst_len ); - uint8_t *strUtf8=(uint8_t *)malloc(dst_len); + uint8_t *strUtf8=static_cast(malloc(dst_len)); memset(strUtf8,0,dst_len); result = l10n_convert_str( cd, wchString, &src_len, strUtf8, &dst_len ); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp index 1cb5e2eec..9aa7978a2 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp @@ -241,12 +241,12 @@ void ChunkRebuildData::createTileData() m_tileData.signalSource.set(i, Tile::tiles[i]->isSignalSource()); m_tileData.cubeShaped.set(i, Tile::tiles[i]->isCubeShaped()); - m_tileData.xx0[i] = (float)Tile::tiles[i]->getShapeX0(); - m_tileData.yy0[i] = (float)Tile::tiles[i]->getShapeY0(); - m_tileData.zz0[i] = (float)Tile::tiles[i]->getShapeZ0(); - m_tileData.xx1[i] = (float)Tile::tiles[i]->getShapeX1(); - m_tileData.yy1[i] = (float)Tile::tiles[i]->getShapeY1(); - m_tileData.zz1[i] = (float)Tile::tiles[i]->getShapeZ1(); + m_tileData.xx0[i] = static_cast(Tile::tiles[i]->getShapeX0()); + m_tileData.yy0[i] = static_cast(Tile::tiles[i]->getShapeY0()); + m_tileData.zz0[i] = static_cast(Tile::tiles[i]->getShapeZ0()); + m_tileData.xx1[i] = static_cast(Tile::tiles[i]->getShapeX1()); + m_tileData.yy1[i] = static_cast(Tile::tiles[i]->getShapeY1()); + m_tileData.zz1[i] = static_cast(Tile::tiles[i]->getShapeZ1()); Icon* pTex = Tile::tiles[i]->icon; if(pTex) { @@ -269,17 +269,17 @@ void ChunkRebuildData::createTileData() setIconSPUFromIcon(&m_tileData.grass_iconSideOverlay, Tile::grass->iconSideOverlay); // ThinFence - setIconSPUFromIcon(&m_tileData.ironFence_EdgeTexture, ((ThinFenceTile*)Tile::ironFence)->getEdgeTexture()); - setIconSPUFromIcon(&m_tileData.thinGlass_EdgeTexture, ((ThinFenceTile*)Tile::thinGlass)->getEdgeTexture()); + setIconSPUFromIcon(&m_tileData.ironFence_EdgeTexture, static_cast(Tile::ironFence)->getEdgeTexture()); + setIconSPUFromIcon(&m_tileData.thinGlass_EdgeTexture, static_cast(Tile::thinGlass)->getEdgeTexture()); //FarmTile - setIconSPUFromIcon(&m_tileData.farmTile_Dry, ((FarmTile*)Tile::farmland)->iconDry); - setIconSPUFromIcon(&m_tileData.farmTile_Wet, ((FarmTile*)Tile::farmland)->iconWet); + setIconSPUFromIcon(&m_tileData.farmTile_Dry, static_cast(Tile::farmland)->iconDry); + setIconSPUFromIcon(&m_tileData.farmTile_Wet, static_cast(Tile::farmland)->iconWet); // DoorTile for(int i=0;i<8; i++) { - setIconSPUFromIcon(&m_tileData.doorTile_Icons[i], ((DoorTile*)Tile::door_wood)->icons[i]); + setIconSPUFromIcon(&m_tileData.doorTile_Icons[i], static_cast(Tile::door_wood)->icons[i]); // we're not supporting flipped icons, so manually flip here if(i>=4) m_tileData.doorTile_Icons[i].flipHorizontal(); @@ -291,20 +291,20 @@ void ChunkRebuildData::createTileData() // SandStoneTile for(int i=0;i<3; i++) - setIconSPUFromIcon(&m_tileData.sandStone_icons[i], ((SandStoneTile*)Tile::sandStone)->icons[i]); - setIconSPUFromIcon(&m_tileData.sandStone_iconTop, ((SandStoneTile*)Tile::sandStone)->iconTop); - setIconSPUFromIcon(&m_tileData.sandStone_iconBottom, ((SandStoneTile*)Tile::sandStone)->iconBottom); + setIconSPUFromIcon(&m_tileData.sandStone_icons[i], static_cast(Tile::sandStone)->icons[i]); + setIconSPUFromIcon(&m_tileData.sandStone_iconTop, static_cast(Tile::sandStone)->iconTop); + setIconSPUFromIcon(&m_tileData.sandStone_iconBottom, static_cast(Tile::sandStone)->iconBottom); // WoodTile // assert(WoodTile_SPU::WOOD_NAMES_LENGTH == 4); for(int i=0;i<4; i++) - setIconSPUFromIcon(&m_tileData.woodTile_icons[i], ((WoodTile*)Tile::wood)->icons[i]); + setIconSPUFromIcon(&m_tileData.woodTile_icons[i], static_cast(Tile::wood)->icons[i]); // TreeTile // assert(TreeTile_SPU::TREE_NAMES_LENGTH == 4); for(int i=0;i<4; i++) - setIconSPUFromIcon(&m_tileData.treeTile_icons[i], ((TreeTile*)Tile::treeTrunk)->icons[i]); - setIconSPUFromIcon(&m_tileData.treeTile_iconTop, ((TreeTile*)Tile::treeTrunk)->iconTop); + setIconSPUFromIcon(&m_tileData.treeTile_icons[i], static_cast(Tile::treeTrunk)->icons[i]); + setIconSPUFromIcon(&m_tileData.treeTile_iconTop, static_cast(Tile::treeTrunk)->iconTop); // LeafTile for(int i=0;i<2; i++) @@ -313,12 +313,12 @@ void ChunkRebuildData::createTileData() // CropTile for(int i=0;i<8; i++) - setIconSPUFromIcon(&m_tileData.cropTile_icons[i], ((CropTile*)Tile::crops)->icons[i]); + setIconSPUFromIcon(&m_tileData.cropTile_icons[i], static_cast(Tile::crops)->icons[i]); // FurnaceTile - setIconSPUFromIcon(&m_tileData.furnaceTile_iconTop, ((FurnaceTile*)Tile::furnace)->iconTop); - setIconSPUFromIcon(&m_tileData.furnaceTile_iconFront, ((FurnaceTile*)Tile::furnace)->iconFront); - setIconSPUFromIcon(&m_tileData.furnaceTile_iconFront_lit, ((FurnaceTile*)Tile::furnace_lit)->iconFront); + setIconSPUFromIcon(&m_tileData.furnaceTile_iconTop, static_cast(Tile::furnace)->iconTop); + setIconSPUFromIcon(&m_tileData.furnaceTile_iconFront, static_cast(Tile::furnace)->iconFront); + setIconSPUFromIcon(&m_tileData.furnaceTile_iconFront_lit, static_cast(Tile::furnace_lit)->iconFront); //LiquidTile setIconSPUFromIcon(&m_tileData.liquidTile_iconWaterStill, (Tile::water)->icons[0]); @@ -332,64 +332,64 @@ void ChunkRebuildData::createTileData() // Sapling for(int i=0;i<4;i++) - setIconSPUFromIcon(&m_tileData.sapling_icons[i], ((Sapling*)Tile::sapling)->icons[i]); + setIconSPUFromIcon(&m_tileData.sapling_icons[i], static_cast(Tile::sapling)->icons[i]); - m_tileData.glassTile_allowSame = ((GlassTile*)Tile::glass)->allowSame; - m_tileData.iceTile_allowSame = ((IceTile*)Tile::ice)->allowSame; + m_tileData.glassTile_allowSame = static_cast(Tile::glass)->allowSame; + m_tileData.iceTile_allowSame = static_cast(Tile::ice)->allowSame; // DispenserTile - setIconSPUFromIcon(&m_tileData.dispenserTile_iconTop, ((DispenserTile*)Tile::dispenser)->iconTop); - setIconSPUFromIcon(&m_tileData.dispenserTile_iconFront, ((DispenserTile*)Tile::dispenser)->iconFront); - setIconSPUFromIcon(&m_tileData.dispenserTile_iconFrontVertical, ((DispenserTile*)Tile::dispenser)->iconFrontVertical); + setIconSPUFromIcon(&m_tileData.dispenserTile_iconTop, static_cast(Tile::dispenser)->iconTop); + setIconSPUFromIcon(&m_tileData.dispenserTile_iconFront, static_cast(Tile::dispenser)->iconFront); + setIconSPUFromIcon(&m_tileData.dispenserTile_iconFrontVertical, static_cast(Tile::dispenser)->iconFrontVertical); // RailTile - setIconSPUFromIcon(&m_tileData.railTile_iconTurn, ((RailTile*)Tile::rail)->iconTurn); - setIconSPUFromIcon(&m_tileData.railTile_iconTurnGolden, ((RailTile*)Tile::goldenRail)->iconTurn); + setIconSPUFromIcon(&m_tileData.railTile_iconTurn, static_cast(Tile::rail)->iconTurn); + setIconSPUFromIcon(&m_tileData.railTile_iconTurnGolden, static_cast(Tile::goldenRail)->iconTurn); for(int i=0;i<2;i++) - setIconSPUFromIcon(&m_tileData.detectorRailTile_icons[i], ((DetectorRailTile*)Tile::detectorRail)->icons[i]); + setIconSPUFromIcon(&m_tileData.detectorRailTile_icons[i], static_cast(Tile::detectorRail)->icons[i]); // tntTile - setIconSPUFromIcon(&m_tileData.tntTile_iconBottom, ((TntTile*)Tile::tnt)->iconBottom); - setIconSPUFromIcon(&m_tileData.tntTile_iconTop, ((TntTile*)Tile::tnt)->iconTop); + setIconSPUFromIcon(&m_tileData.tntTile_iconBottom, static_cast(Tile::tnt)->iconBottom); + setIconSPUFromIcon(&m_tileData.tntTile_iconTop, static_cast(Tile::tnt)->iconTop); // workbenchTile - setIconSPUFromIcon(&m_tileData.workBench_iconFront, ((WorkbenchTile*)Tile::workBench)->iconFront); - setIconSPUFromIcon(&m_tileData.workBench_iconTop, ((WorkbenchTile*)Tile::workBench)->iconTop); + setIconSPUFromIcon(&m_tileData.workBench_iconFront, static_cast(Tile::workBench)->iconFront); + setIconSPUFromIcon(&m_tileData.workBench_iconTop, static_cast(Tile::workBench)->iconTop); // cactusTile - setIconSPUFromIcon(&m_tileData.cactusTile_iconTop, ((CactusTile*)Tile::cactus)->iconTop); - setIconSPUFromIcon(&m_tileData.cactusTile_iconBottom, ((CactusTile*)Tile::cactus)->iconBottom); + setIconSPUFromIcon(&m_tileData.cactusTile_iconTop, static_cast(Tile::cactus)->iconTop); + setIconSPUFromIcon(&m_tileData.cactusTile_iconBottom, static_cast(Tile::cactus)->iconBottom); // recordPlayer - setIconSPUFromIcon(&m_tileData.recordPlayer_iconTop, ((RecordPlayerTile*)Tile::recordPlayer)->iconTop); + setIconSPUFromIcon(&m_tileData.recordPlayer_iconTop, static_cast(Tile::recordPlayer)->iconTop); // pumpkin - setIconSPUFromIcon(&m_tileData.pumpkinTile_iconTop, ((PumpkinTile*)Tile::pumpkin)->iconTop); - setIconSPUFromIcon(&m_tileData.pumpkinTile_iconFace, ((PumpkinTile*)Tile::pumpkin)->iconFace); - setIconSPUFromIcon(&m_tileData.pumpkinTile_iconFaceLit, ((PumpkinTile*)Tile::litPumpkin)->iconFace); + setIconSPUFromIcon(&m_tileData.pumpkinTile_iconTop, static_cast(Tile::pumpkin)->iconTop); + setIconSPUFromIcon(&m_tileData.pumpkinTile_iconFace, static_cast(Tile::pumpkin)->iconFace); + setIconSPUFromIcon(&m_tileData.pumpkinTile_iconFaceLit, static_cast(Tile::litPumpkin)->iconFace); // cakeTile - setIconSPUFromIcon(&m_tileData.cakeTile_iconTop, ((CakeTile*)Tile::cake)->iconTop); - setIconSPUFromIcon(&m_tileData.cakeTile_iconBottom, ((CakeTile*)Tile::cake)->iconBottom); - setIconSPUFromIcon(&m_tileData.cakeTile_iconInner, ((CakeTile*)Tile::cake)->iconInner); + setIconSPUFromIcon(&m_tileData.cakeTile_iconTop, static_cast(Tile::cake)->iconTop); + setIconSPUFromIcon(&m_tileData.cakeTile_iconBottom, static_cast(Tile::cake)->iconBottom); + setIconSPUFromIcon(&m_tileData.cakeTile_iconInner, static_cast(Tile::cake)->iconInner); // SmoothStoneBrickTile for(int i=0;i<4;i++) - setIconSPUFromIcon(&m_tileData.smoothStoneBrick_icons[i], ((SmoothStoneBrickTile*)Tile::stoneBrickSmooth)->icons[i]); + setIconSPUFromIcon(&m_tileData.smoothStoneBrick_icons[i], static_cast(Tile::stoneBrickSmooth)->icons[i]); // HugeMushroomTile for(int i=0;i<2;i++) - setIconSPUFromIcon(&m_tileData.hugeMushroom_icons[i], ((HugeMushroomTile*)Tile::hugeMushroom1)->icons[i]); - setIconSPUFromIcon(&m_tileData.hugeMushroom_iconStem, ((HugeMushroomTile*)Tile::hugeMushroom1)->iconStem); - setIconSPUFromIcon(&m_tileData.hugeMushroom_iconInside, ((HugeMushroomTile*)Tile::hugeMushroom1)->iconInside); + setIconSPUFromIcon(&m_tileData.hugeMushroom_icons[i], static_cast(Tile::hugeMushroom1)->icons[i]); + setIconSPUFromIcon(&m_tileData.hugeMushroom_iconStem, static_cast(Tile::hugeMushroom1)->iconStem); + setIconSPUFromIcon(&m_tileData.hugeMushroom_iconInside, static_cast(Tile::hugeMushroom1)->iconInside); // MelonTile - setIconSPUFromIcon(&m_tileData.melonTile_iconTop, ((MelonTile*)Tile::melon)->iconTop); + setIconSPUFromIcon(&m_tileData.melonTile_iconTop, static_cast(Tile::melon)->iconTop); // StemTile - setIconSPUFromIcon(&m_tileData.stemTile_iconAngled, ((StemTile*)Tile::melonStem)->iconAngled); + setIconSPUFromIcon(&m_tileData.stemTile_iconAngled, static_cast(Tile::melonStem)->iconAngled); // MycelTile setIconSPUFromIcon(&m_tileData.mycelTile_iconTop, (Tile::mycel)->iconTop); @@ -397,14 +397,14 @@ void ChunkRebuildData::createTileData() // NetherStalkTile for(int i=0;i<3;i++) - setIconSPUFromIcon(&m_tileData.netherStalk_icons[i], ((NetherStalkTile*)Tile::netherStalk)->icons[i]); + setIconSPUFromIcon(&m_tileData.netherStalk_icons[i], static_cast(Tile::netherStalk)->icons[i]); // EnchantmentTableTile - setIconSPUFromIcon(&m_tileData.enchantmentTable_iconTop, ((EnchantmentTableTile*)Tile::enchantTable)->iconTop); - setIconSPUFromIcon(&m_tileData.enchantmentTable_iconBottom, ((EnchantmentTableTile*)Tile::enchantTable)->iconBottom); + setIconSPUFromIcon(&m_tileData.enchantmentTable_iconTop, static_cast(Tile::enchantTable)->iconTop); + setIconSPUFromIcon(&m_tileData.enchantmentTable_iconBottom, static_cast(Tile::enchantTable)->iconBottom); //BrewingStandTile - setIconSPUFromIcon(&m_tileData.brewingStand_iconBase, ((BrewingStandTile*)Tile::brewingStand)->iconBase); + setIconSPUFromIcon(&m_tileData.brewingStand_iconBase, static_cast(Tile::brewingStand)->iconBase); //RedStoneDust setIconSPUFromIcon(&m_tileData.redStoneDust_iconCross, (Tile::redStoneDust)->iconCross); @@ -412,32 +412,32 @@ void ChunkRebuildData::createTileData() setIconSPUFromIcon(&m_tileData.redStoneDust_iconCrossOver, (Tile::redStoneDust)->iconCrossOver); setIconSPUFromIcon(&m_tileData.redStoneDust_iconLineOver, (Tile::redStoneDust)->iconLineOver); - setIconSPUFromIcon(&m_tileData.stoneSlab_iconSide, ((StoneSlabTile*)(Tile::stoneSlab))->iconSide); + setIconSPUFromIcon(&m_tileData.stoneSlab_iconSide, static_cast(Tile::stoneSlab)->iconSide); for(int i=0;i<16;i++) - setIconSPUFromIcon(&m_tileData.clothTile_icons[i], ((ClothTile*)Tile::cloth)->icons[i]); + setIconSPUFromIcon(&m_tileData.clothTile_icons[i], static_cast(Tile::cloth)->icons[i]); // CarrotTile for(int i=0;i<4;i++) - setIconSPUFromIcon(&m_tileData.carrot_icons[i], ((CarrotTile*)Tile::carrots)->icons[i]); + setIconSPUFromIcon(&m_tileData.carrot_icons[i], static_cast(Tile::carrots)->icons[i]); // PotatoTile for(int i=0;i<4;i++) - setIconSPUFromIcon(&m_tileData.potato_icons[i], ((PotatoTile*)Tile::potatoes)->icons[i]); + setIconSPUFromIcon(&m_tileData.potato_icons[i], static_cast(Tile::potatoes)->icons[i]); // AnvilTile for(int i=0;i<3;i++) - setIconSPUFromIcon(&m_tileData.anvil_icons[i], ((AnvilTile*)Tile::anvil)->icons[i]); + setIconSPUFromIcon(&m_tileData.anvil_icons[i], static_cast(Tile::anvil)->icons[i]); // QuartzBlockTile for(int i=0;i<5;i++) - setIconSPUFromIcon(&m_tileData.quartzBlock_icons[i], ((QuartzBlockTile*)Tile::quartzBlock)->icons[i]); + setIconSPUFromIcon(&m_tileData.quartzBlock_icons[i], static_cast(Tile::quartzBlock)->icons[i]); - setIconSPUFromIcon(&m_tileData.quartzBlock_iconChiseledTop, ((QuartzBlockTile*)Tile::quartzBlock)->iconChiseledTop); - setIconSPUFromIcon(&m_tileData.quartzBlock_iconLinesTop, ((QuartzBlockTile*)Tile::quartzBlock)->iconLinesTop); - setIconSPUFromIcon(&m_tileData.quartzBlock_iconTop, ((QuartzBlockTile*)Tile::quartzBlock)->iconTop); - setIconSPUFromIcon(&m_tileData.quartzBlock_iconBottom, ((QuartzBlockTile*)Tile::quartzBlock)->iconBottom); + setIconSPUFromIcon(&m_tileData.quartzBlock_iconChiseledTop, static_cast(Tile::quartzBlock)->iconChiseledTop); + setIconSPUFromIcon(&m_tileData.quartzBlock_iconLinesTop, static_cast(Tile::quartzBlock)->iconLinesTop); + setIconSPUFromIcon(&m_tileData.quartzBlock_iconTop, static_cast(Tile::quartzBlock)->iconTop); + setIconSPUFromIcon(&m_tileData.quartzBlock_iconBottom, static_cast(Tile::quartzBlock)->iconBottom); } // extern int g_lastHitBlockX; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h index f4ba6ccfa..0597c1fc2 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h @@ -24,29 +24,29 @@ class Icon_SPU void set(int16_t _x, int16_t _y, int16_t _w, int16_t _h, int texWidth, int texHeight) { - x0 = (int16_t)(4096 * (float(_x) / texWidth)); - y0 = (int16_t)(4096 * (float(_y) / texHeight)); - x1 = x0 + (int16_t)(4096 * (float(_w) / texWidth)); - y1 = y0 + (int16_t)(4096 * (float(_h) / texHeight)); + x0 = static_cast(4096 * (float(_x) / texWidth)); + y0 = static_cast(4096 * (float(_y) / texHeight)); + x1 = x0 + static_cast(4096 * (float(_w) / texWidth)); + y1 = y0 + static_cast(4096 * (float(_h) / texHeight)); } void flipHorizontal() { int16_t temp = x0; x0 = x1; x1 = temp; } void flipVertical() { int16_t temp = y0; y0 = y1; y1 = temp; } - float getU0() const { return (float(x0) / 4096) + UVAdjust; }//sc_texWidth) + getUAdjust(); } - float getU1() const { return (float(x1) / 4096.0f) - UVAdjust; } //sc_texWidth) - getUAdjust(); } + float getU0() const { return (static_cast(x0) / 4096) + UVAdjust; }//sc_texWidth) + getUAdjust(); } + float getU1() const { return (static_cast(x1) / 4096.0f) - UVAdjust; } //sc_texWidth) - getUAdjust(); } float getU(double offset) const { float diff = getU1() - getU0(); - return getU0() + (diff * ((float) offset / 16));//SharedConstants::WORLD_RESOLUTION)); + return getU0() + (diff * (static_cast(offset) / 16));//SharedConstants::WORLD_RESOLUTION)); } - float getV0() const { return (float(y0) / 4096.0f) + UVAdjust; } //sc_texHeight) + getVAdjust(); } - float getV1() const { return (float(y1) / 4096.0f) - UVAdjust; } //sc_texHeight) - getVAdjust(); } + float getV0() const { return (static_cast(y0) / 4096.0f) + UVAdjust; } //sc_texHeight) + getVAdjust(); } + float getV1() const { return (static_cast(y1) / 4096.0f) - UVAdjust; } //sc_texHeight) - getVAdjust(); } float getV(double offset) const { float diff = getV1() - getV0(); - return getV0() + (diff * ((float) offset / 16)); //SharedConstants::WORLD_RESOLUTION)); + return getV0() + (diff * (static_cast(offset) / 16)); //SharedConstants::WORLD_RESOLUTION)); } // virtual wstring getName() const = 0; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp index 7f13fd4f9..fa075e716 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp @@ -211,12 +211,12 @@ double LiquidTile_SPU::getSlopeAngle(ChunkRebuildData *level, int x, int y, int if (m->getID() == Material_SPU::water_Id) { TileRef_SPU tRef(Tile_SPU::water_Id); - flow = ((LiquidTile_SPU*)tRef.getPtr())->getFlow(level, x, y, z); + flow = static_cast(tRef.getPtr())->getFlow(level, x, y, z); } if (m->getID() == Material_SPU::lava_Id) { TileRef_SPU tRef(Tile_SPU::lava_Id); - flow = ((LiquidTile_SPU*)tRef.getPtr())->getFlow(level, x, y, z); + flow = static_cast(tRef.getPtr())->getFlow(level, x, y, z); } if (flow.x == 0 && flow.z == 0) return -1000; return atan2(flow.z, flow.x) - MATH_PI / 2; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp index 3d1007af1..7772aba9f 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp @@ -68,7 +68,7 @@ typedef unsigned short hfloat; hfloat convertFloatToHFloat(float f) { unsigned int x = *(unsigned int *)&f; - unsigned int sign = (unsigned short)(x >> 31); + unsigned int sign = static_cast(x >> 31); unsigned int mantissa; unsigned int exp; hfloat hf; @@ -90,8 +90,8 @@ hfloat convertFloatToHFloat(float f) // 16-bit half-float representation stores number as Inf mantissa = 0; } - hf = (((hfloat)sign) << 15) | (hfloat)(HALF_FLOAT_MAX_BIASED_EXP) | - (hfloat)(mantissa >> 13); + hf = (static_cast(sign) << 15) | static_cast(HALF_FLOAT_MAX_BIASED_EXP) | + static_cast(mantissa >> 13); } // check if exponent is <= -15 else if (exp <= HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) @@ -101,13 +101,13 @@ hfloat convertFloatToHFloat(float f) exp = (HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP - exp) >> 23; mantissa >>= (14 + exp); - hf = (((hfloat)sign) << 15) | (hfloat)(mantissa); + hf = (static_cast(sign) << 15) | static_cast(mantissa); } else { - hf = (((hfloat)sign) << 15) | - (hfloat)((exp - HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) >> 13) | - (hfloat)(mantissa >> 13); + hf = (static_cast(sign) << 15) | + static_cast((exp - HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) >> 13) | + static_cast(mantissa >> 13); } return hf; @@ -115,8 +115,8 @@ hfloat convertFloatToHFloat(float f) float convertHFloatToFloat(hfloat hf) { - unsigned int sign = (unsigned int)(hf >> 15); - unsigned int mantissa = (unsigned int)(hf & ((1 << 10) - 1)); + unsigned int sign = static_cast(hf >> 15); + unsigned int mantissa = static_cast(hf & ((1 << 10) - 1)); unsigned int exp = (unsigned int)(hf & HALF_FLOAT_MAX_BIASED_EXP); unsigned int f; @@ -329,12 +329,12 @@ void Tesselator_SPU::tex2(int tex2) void Tesselator_SPU::color(float r, float g, float b) { - color((int) (r * 255), (int) (g * 255), (int) (b * 255)); + color(static_cast(r * 255), static_cast(g * 255), static_cast(b * 255)); } void Tesselator_SPU::color(float r, float g, float b, float a) { - color((int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255)); + color(static_cast(r * 255), static_cast(g * 255), static_cast(b * 255), static_cast(a * 255)); } void Tesselator_SPU::color(int r, int g, int b) @@ -539,7 +539,7 @@ void Tesselator_SPU::vertex(float x, float y, float z) // see comments in packCompactQuad() for exact format if( useCompactFormat360 ) { - unsigned int ucol = (unsigned int)col; + unsigned int ucol = static_cast(col); #ifdef _XBOX // Pack as 4:4:4 RGB_ @@ -564,7 +564,7 @@ void Tesselator_SPU::vertex(float x, float y, float z) unsigned short packedcol = ((col & 0xf8000000 ) >> 16 ) | ((col & 0x00fc0000 ) >> 13 ) | ((col & 0x0000f800 ) >> 11 ); - int ipackedcol = ((int)packedcol) & 0xffff; // 0 to 65535 range + int ipackedcol = static_cast(packedcol) & 0xffff; // 0 to 65535 range ipackedcol -= 32768; // -32768 to 32767 range ipackedcol &= 0xffff; @@ -597,12 +597,12 @@ void Tesselator_SPU::vertex(float x, float y, float z) pShortData[7] = ((INT_ROUND(tex2V * (8192.0f/256.0f)))&0xffff); incData(4); #else - pShortData[0] = (((int)((x + xo ) * 1024.0f))&0xffff); - pShortData[1] = (((int)((y + yo ) * 1024.0f))&0xffff); - pShortData[2] = (((int)((z + zo ) * 1024.0f))&0xffff); + pShortData[0] = (static_cast((x + xo) * 1024.0f)&0xffff); + pShortData[1] = (static_cast((y + yo) * 1024.0f)&0xffff); + pShortData[2] = (static_cast((z + zo) * 1024.0f)&0xffff); pShortData[3] = ipackedcol; - pShortData[4] = (((int)(uu * 8192.0f))&0xffff); - pShortData[5] = (((int)(v * 8192.0f))&0xffff); + pShortData[4] = (static_cast(uu * 8192.0f)&0xffff); + pShortData[5] = (static_cast(v * 8192.0f)&0xffff); pShortData[6] = ((int16_t*)&_tex2)[0]; pShortData[7] = ((int16_t*)&_tex2)[1]; incData(4); @@ -723,9 +723,9 @@ void Tesselator_SPU::noColor() void Tesselator_SPU::normal(float x, float y, float z) { hasNormal = true; - byte xx = (byte) (x * 127); - byte yy = (byte) (y * 127); - byte zz = (byte) (z * 127); + byte xx = static_cast(x * 127); + byte yy = static_cast(y * 127); + byte zz = static_cast(z * 127); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp index ab9b2c94c..fd9421af0 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp @@ -270,7 +270,7 @@ bool TileRenderer_SPU::tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int retVal = tesselateStemInWorld( tt, x, y, z ); break; case Tile_SPU::SHAPE_LILYPAD: - retVal = tesselateLilypadInWorld( (WaterlilyTile_SPU*)tt, x, y, z ); + retVal = tesselateLilypadInWorld( static_cast(tt), x, y, z ); break; case Tile_SPU::SHAPE_ROWS: retVal = tesselateRowInWorld( tt, x, y, z ); @@ -279,7 +279,7 @@ bool TileRenderer_SPU::tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int retVal = tesselateTorchInWorld( tt, x, y, z ); break; case Tile_SPU::SHAPE_FIRE: - retVal = tesselateFireInWorld( (FireTile_SPU *)tt, x, y, z ); + retVal = tesselateFireInWorld( static_cast(tt), x, y, z ); break; case Tile_SPU::SHAPE_RED_DUST: retVal = tesselateDustInWorld( tt, x, y, z ); @@ -291,19 +291,19 @@ bool TileRenderer_SPU::tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int retVal = tesselateDoorInWorld( tt, x, y, z ); break; case Tile_SPU::SHAPE_RAIL: - retVal = tesselateRailInWorld( ( RailTile_SPU* )tt, x, y, z ); + retVal = tesselateRailInWorld( static_cast(tt), x, y, z ); break; case Tile_SPU::SHAPE_STAIRS: - retVal = tesselateStairsInWorld( (StairTile_SPU *)tt, x, y, z ); + retVal = tesselateStairsInWorld( static_cast(tt), x, y, z ); break; case Tile_SPU::SHAPE_EGG: - retVal = tesselateEggInWorld((EggTile_SPU*) tt, x, y, z); + retVal = tesselateEggInWorld(static_cast(tt), x, y, z); break; case Tile_SPU::SHAPE_FENCE: - retVal = tesselateFenceInWorld( ( FenceTile_SPU* )tt, x, y, z ); + retVal = tesselateFenceInWorld( static_cast(tt), x, y, z ); break; case Tile_SPU::SHAPE_WALL: - retVal = tesselateWallInWorld( (WallTile_SPU *) tt, x, y, z); + retVal = tesselateWallInWorld( static_cast(tt), x, y, z); break; case Tile_SPU::SHAPE_LEVER: retVal = tesselateLeverInWorld( tt, x, y, z ); @@ -318,7 +318,7 @@ bool TileRenderer_SPU::tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int retVal = tesselateBedInWorld( tt, x, y, z ); break; case Tile_SPU::SHAPE_DIODE: - retVal = tesselateDiodeInWorld( (DiodeTile_SPU *)tt, x, y, z ); + retVal = tesselateDiodeInWorld( static_cast(tt), x, y, z ); break; case Tile_SPU::SHAPE_PISTON_BASE: retVal = tesselatePistonBaseInWorld( tt, x, y, z, false, forceData ); @@ -333,7 +333,7 @@ bool TileRenderer_SPU::tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int retVal = tesselateVineInWorld( tt, x, y, z ); break; case Tile_SPU::SHAPE_FENCE_GATE: - retVal = tesselateFenceGateInWorld( ( FenceGateTile_SPU* )tt, x, y, z ); + retVal = tesselateFenceGateInWorld( static_cast(tt), x, y, z ); break; case Tile_SPU::SHAPE_CAULDRON: retVal = tesselateCauldronInWorld((CauldronTile_SPU* ) tt, x, y, z); @@ -345,7 +345,7 @@ bool TileRenderer_SPU::tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int retVal = tesselateAnvilInWorld((AnvilTile_SPU *) tt, x, y, z); break; case Tile_SPU::SHAPE_BREWING_STAND: - retVal = tesselateBrewingStandInWorld((BrewingStandTile_SPU* ) tt, x, y, z); + retVal = tesselateBrewingStandInWorld(static_cast(tt), x, y, z); break; case Tile_SPU::SHAPE_PORTAL_FRAME: retVal = tesselateAirPortalFrameInWorld((TheEndPortalFrameTile *)tt, x, y, z); @@ -1099,23 +1099,23 @@ bool TileRenderer_SPU::tesselateTorchInWorld( Tile_SPU* tt, int x, int y, int z float h = 0.20f; if ( dir == 1 ) { - tesselateTorch( tt, (float)x - r2, (float)y + h, (float)z, -r, 0.0f, 0 ); + tesselateTorch( tt, static_cast(x) - r2, static_cast(y) + h, static_cast(z), -r, 0.0f, 0 ); } else if ( dir == 2 ) { - tesselateTorch( tt, (float)x + r2, (float)y + h, (float)z, +r, 0.0f, 0 ); + tesselateTorch( tt, static_cast(x) + r2, static_cast(y) + h, static_cast(z), +r, 0.0f, 0 ); } else if ( dir == 3 ) { - tesselateTorch( tt, (float)x, (float)y + h, z - r2, 0.0f, -r, 0 ); + tesselateTorch( tt, static_cast(x), static_cast(y) + h, z - r2, 0.0f, -r, 0 ); } else if ( dir == 4 ) { - tesselateTorch( tt, (float)x, (float)y + h, (float)z + r2, 0.0f, +r, 0 ); + tesselateTorch( tt, static_cast(x), static_cast(y) + h, static_cast(z) + r2, 0.0f, +r, 0 ); } else { - tesselateTorch( tt, (float)x, (float)y, (float)z, 0.0f, 0.0f, 0 ); + tesselateTorch( tt, static_cast(x), static_cast(y), static_cast(z), 0.0f, 0.0f, 0 ); } return true; @@ -2321,15 +2321,15 @@ bool TileRenderer_SPU::tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int float z0_ = z + 0.5f - 0.3f; float z1_ = z + 0.5f + 0.3f; - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + 1), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + 1), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + 0), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + 0), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + 0), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), static_cast(z + 0), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), static_cast(z + 1), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + 1), ( float )( u0 ), ( float )( v0 ) ); tex = secondTex; u0 = tex->getU0(); @@ -2337,15 +2337,15 @@ bool TileRenderer_SPU::tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int u1 = tex->getU1(); v1 = tex->getV1(); - t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 1), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 0), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 0), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); x0 = x + 0.5f - 0.5f; x1 = x + 0.5f + 0.5f; @@ -2357,15 +2357,15 @@ bool TileRenderer_SPU::tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int z0_ = z + 0.5f - 0.4f; z1_ = z + 0.5f + 0.4f; - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + 0), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + 0), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + 1), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + 1), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + 1), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), static_cast(z + 1), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), static_cast(z + 0), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + 0), ( float )( u1 ), ( float )( v0 ) ); tex = firstTex; u0 = tex->getU0(); @@ -2373,15 +2373,15 @@ bool TileRenderer_SPU::tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int u1 = tex->getU1(); v1 = tex->getV1(); - t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 0), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 1), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 0), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); } else { @@ -2425,10 +2425,10 @@ bool TileRenderer_SPU::tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int { t->vertexUV( ( float )( x + 1 - r ), ( float )( y + h + yo ), ( float )( z + 0.0f ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 1 - 0 ), ( float )( y + 0 + yo ), ( float )( z + - 0.0f ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 - 0 ), ( float )( y + 0 + yo ), ( float )( z + - 1.0f ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1 - 0), ( float )( y + 0 + yo ), ( float )( z + + 0.0f ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1 - 0), ( float )( y + 0 + yo ), ( float )( z + + 1.0f ), ( float )( u1 ), ( float )( v1 ) ); t->vertexUV( ( float )( x + 1 - r ), ( float )( y + h + yo ), ( float )( z + 1.0f ), ( float )( u1 ), ( float )( v0 ) ); @@ -2504,14 +2504,14 @@ bool TileRenderer_SPU::tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int if ( ( ( x + y + z ) & 1 ) == 0 ) { - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + - 0 ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + - 0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + - 1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + - 1 ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + + 0), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + + 0), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + + 1), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + + 1), ( float )( u0 ), ( float )( v0 ) ); tex = secondTex; u0 = tex->getU0(); @@ -2523,10 +2523,10 @@ bool TileRenderer_SPU::tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int 1.0f ), ( float )( u1 ), ( float )( v0 ) ); t->vertexUV( ( float )( x1 ), ( float )( y + 0.0f ), ( float )( z + 1.0f ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0.0f ), ( float )( z + - 0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + - 0 ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1 ), ( float )( y + 0.0f ), static_cast(z + + 0), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + + 0), ( float )( u0 ), ( float )( v0 ) ); } else { @@ -2789,15 +2789,15 @@ bool TileRenderer_SPU::tesselateRailInWorld( RailTile_SPU* tt, int x, int y, int float r = 1 / 16.0f; - float x0 = ( float )( x + 1 ); - float x1 = ( float )( x + 1 ); - float x2 = ( float )( x + 0 ); - float x3 = ( float )( x + 0 ); + float x0 = static_cast(x + 1); + float x1 = static_cast(x + 1); + float x2 = static_cast(x + 0); + float x3 = static_cast(x + 0); - float z0 = ( float )( z + 0 ); - float z1 = ( float )( z + 1 ); - float z2 = ( float )( z + 1 ); - float z3 = ( float )( z + 0 ); + float z0 = static_cast(z + 0); + float z1 = static_cast(z + 1); + float z2 = static_cast(z + 1); + float z3 = static_cast(z + 0); float y0 = ( float )( y + r ); float y1 = ( float )( y + r ); @@ -2806,24 +2806,24 @@ bool TileRenderer_SPU::tesselateRailInWorld( RailTile_SPU* tt, int x, int y, int if ( data == 1 || data == 2 || data == 3 || data == 7 ) { - x0 = x3 = ( float )( x + 1 ); - x1 = x2 = ( float )( x + 0 ); - z0 = z1 = ( float )( z + 1 ); - z2 = z3 = ( float )( z + 0 ); + x0 = x3 = static_cast(x + 1); + x1 = x2 = static_cast(x + 0); + z0 = z1 = static_cast(z + 1); + z2 = z3 = static_cast(z + 0); } else if ( data == 8 ) { - x0 = x1 = ( float )( x + 0 ); - x2 = x3 = ( float )( x + 1 ); - z0 = z3 = ( float )( z + 1 ); - z1 = z2 = ( float )( z + 0 ); + x0 = x1 = static_cast(x + 0); + x2 = x3 = static_cast(x + 1); + z0 = z3 = static_cast(z + 1); + z1 = z2 = static_cast(z + 0); } else if ( data == 9 ) { - x0 = x3 = ( float )( x + 0 ); - x1 = x2 = ( float )( x + 1 ); - z0 = z1 = ( float )( z + 0 ); - z2 = z3 = ( float )( z + 1 ); + x0 = x3 = static_cast(x + 0); + x1 = x2 = static_cast(x + 1); + z0 = z1 = static_cast(z + 0); + z2 = z3 = static_cast(z + 1); } if ( data == 2 || data == 4 ) @@ -3555,9 +3555,9 @@ bool TileRenderer_SPU::tesselateCrossInWorld( Tile_SPU* tt, int x, int y, int z } t->color( br * r, br * g, br * b ); - float xt = (float)x; - float yt = (float)y; - float zt = (float)z; + float xt = static_cast(x); + float yt = static_cast(y); + float zt = static_cast(z); if (tt->id == Tile_SPU::tallgrass_Id) { @@ -3575,7 +3575,7 @@ bool TileRenderer_SPU::tesselateCrossInWorld( Tile_SPU* tt, int x, int y, int z bool TileRenderer_SPU::tesselateStemInWorld( Tile_SPU* _tt, int x, int y, int z ) { - StemTile_SPU* tt = ( StemTile_SPU* )_tt; + StemTile_SPU* tt = static_cast(_tt); Tesselator_SPU* t = getTesselator(); float br; @@ -3805,7 +3805,7 @@ bool TileRenderer_SPU::tesselateLilypadInWorld(WaterlilyTile_SPU *tt, int x, int int64_t seed = (x * 3129871) ^ (z * 116129781l) ^ (y); seed = seed * seed * 42317861 + seed * 11; - int dir = (int) ((seed >> 16) & 0x3); + int dir = static_cast((seed >> 16) & 0x3); @@ -4017,7 +4017,7 @@ bool TileRenderer_SPU::tesselateWaterInWorld( Tile_SPU* tt, int x, int y, int z { changed = true; Icon_SPU *tex = getTexture( tt, 1, data ); - float angle = ( float )LiquidTile_SPU::getSlopeAngle( level, x, y, z, m ); + float angle = static_cast(LiquidTile_SPU::getSlopeAngle(level, x, y, z, m)); if ( angle > -999 ) { tex = getTexture( tt, 2, data ); @@ -4112,8 +4112,8 @@ bool TileRenderer_SPU::tesselateWaterInWorld( Tile_SPU* tt, int x, int y, int z { hh0 = ( float )( h0 ); hh1 = ( float )( h3 ); - x0 = ( float )( x ); - x1 = ( float )( x + 1 ); + x0 = static_cast(x); + x1 = static_cast(x + 1); z0 = ( float )( z + offs); z1 = ( float )( z + offs); } @@ -4121,8 +4121,8 @@ bool TileRenderer_SPU::tesselateWaterInWorld( Tile_SPU* tt, int x, int y, int z { hh0 = ( float )( h2 ); hh1 = ( float )( h1 ); - x0 = ( float )( x + 1 ); - x1 = ( float )( x ); + x0 = static_cast(x + 1); + x1 = static_cast(x); z0 = ( float )( z + 1 - offs); z1 = ( float )( z + 1 - offs); } @@ -4132,8 +4132,8 @@ bool TileRenderer_SPU::tesselateWaterInWorld( Tile_SPU* tt, int x, int y, int z hh1 = ( float )( h0 ); x0 = ( float )( x + offs); x1 = ( float )( x + offs); - z0 = ( float )( z + 1 ); - z1 = ( float )( z ); + z0 = static_cast(z + 1); + z1 = static_cast(z); } else { @@ -4141,8 +4141,8 @@ bool TileRenderer_SPU::tesselateWaterInWorld( Tile_SPU* tt, int x, int y, int z hh1 = ( float )( h2 ); x0 = ( float )( x + 1 - offs); x1 = ( float )( x + 1 - offs); - z0 = ( float )( z ); - z1 = ( float )( z + 1 ); + z0 = static_cast(z); + z1 = static_cast(z + 1); } @@ -4172,8 +4172,8 @@ bool TileRenderer_SPU::tesselateWaterInWorld( Tile_SPU* tt, int x, int y, int z t->color( c11 * br * r, c11 * br * g, c11 * br * b ); t->vertexUV( ( float )( x0 ), ( float )( y + hh0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v01 ) ); t->vertexUV( ( float )( x1 ), ( float )( y + hh1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v02 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); } @@ -4786,7 +4786,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c4g *= ll4; c4b *= ll4; - renderFaceDown( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture( tt, level, pX, pY, pZ, 0 ) ); + renderFaceDown( tt, static_cast(pX), static_cast(pY), static_cast(pZ), getTexture( tt, level, pX, pY, pZ, 0 ) ); } if ( faceFlags & 0x02 ) { @@ -4878,7 +4878,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c4b *= ll4; - renderFaceUp( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture( tt, level, pX, pY, pZ, 1 ) ); + renderFaceUp( tt, static_cast(pX), static_cast(pY), static_cast(pZ), getTexture( tt, level, pX, pY, pZ, 1 ) ); } if ( faceFlags & 0x04 ) { @@ -4946,14 +4946,14 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti float _ll2 = (ll00z + ll0Yz + llX0z + llXYz) / 4.0f; float _ll3 = (ll0yz + ll00z + llXyz + llX0z) / 4.0f; float _ll4 = (llxyz + llx0z + ll0yz + ll00z) / 4.0f; - ll1 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll4 * (1.0 - tileShapeY1) - * (1.0 - tileShapeX0)); - ll2 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll2 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll4 * (1.0 - tileShapeY1) - * (1.0 - tileShapeX1)); - ll3 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll2 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll4 * (1.0 - tileShapeY0) - * (1.0 - tileShapeX1)); - ll4 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll4 * (1.0 - tileShapeY0) - * (1.0 - tileShapeX0)); + ll1 = static_cast(_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll4 * (1.0 - tileShapeY1) + * (1.0 - tileShapeX0)); + ll2 = static_cast(_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll2 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll4 * (1.0 - tileShapeY1) + * (1.0 - tileShapeX1)); + ll3 = static_cast(_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll2 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll4 * (1.0 - tileShapeY0) + * (1.0 - tileShapeX1)); + ll4 = static_cast(_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll4 * (1.0 - tileShapeY0) + * (1.0 - tileShapeX0)); int _tc1 = blend(ccx0z, ccxYz, cc0Yz, cc00z); int _tc2 = blend(cc0Yz, ccX0z, ccXYz, cc00z); @@ -4998,7 +4998,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 2); - renderNorth( tt, ( float )pX, ( float )pY, ( float )pZ, tex ); + renderNorth( tt, static_cast(pX), static_cast(pY), static_cast(pZ), tex ); if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() )) { @@ -5015,7 +5015,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c3b *= pBaseBlue; c4b *= pBaseBlue; bool prev = t->setMipmapEnable( false ); // 4J added - this is rendering the little bit of grass at the top of the side of dirt, don't mipmap it - renderNorth( tt, ( float )pX, ( float )pY, ( float )pZ, GrassTile_SPU::getSideTextureOverlay() ); + renderNorth( tt, static_cast(pX), static_cast(pY), static_cast(pZ), GrassTile_SPU::getSideTextureOverlay() ); t->setMipmapEnable( prev ); } } @@ -5082,14 +5082,14 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti float _ll4 = (ll00Z + ll0YZ + llX0Z + llXYZ) / 4.0f; float _ll3 = (ll0yZ + ll00Z + llXyZ + llX0Z) / 4.0f; float _ll2 = (llxyZ + llx0Z + ll0yZ + ll00Z) / 4.0f; - ll1 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll4 * tileShapeY1 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll2 * (1.0 - tileShapeY1) - * (1.0 - tileShapeX0)); - ll2 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll4 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll2 * (1.0 - tileShapeY0) - * (1.0 - tileShapeX0)); - ll3 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll4 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll2 * (1.0 - tileShapeY0) - * (1.0 - tileShapeX1)); - ll4 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll4 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll2 * (1.0 - tileShapeY1) - * (1.0 - tileShapeX1)); + ll1 = static_cast(_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll4 * tileShapeY1 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll2 * (1.0 - tileShapeY1) + * (1.0 - tileShapeX0)); + ll2 = static_cast(_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll4 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll2 * (1.0 - tileShapeY0) + * (1.0 - tileShapeX0)); + ll3 = static_cast(_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll4 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll2 * (1.0 - tileShapeY0) + * (1.0 - tileShapeX1)); + ll4 = static_cast(_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll4 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll2 * (1.0 - tileShapeY1) + * (1.0 - tileShapeX1)); int _tc1 = blend(ccx0Z, ccxYZ, cc0YZ, cc00Z); int _tc4 = blend(cc0YZ, ccX0Z, ccXYZ, cc00Z); @@ -5134,7 +5134,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c4g *= ll4; c4b *= ll4; Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 3); - renderSouth( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture(tt, level, pX, pY, pZ, 3 ) ); + renderSouth( tt, static_cast(pX), static_cast(pY), static_cast(pZ), getTexture(tt, level, pX, pY, pZ, 3 ) ); if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() )) { @@ -5151,7 +5151,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c3b *= pBaseBlue; c4b *= pBaseBlue; bool prev = t->setMipmapEnable( false ); // 4J added - this is rendering the little bit of grass at the top of the side of dirt, don't mipmap it - renderSouth( tt, ( float )pX, ( float )pY, ( float )pZ, GrassTile_SPU::getSideTextureOverlay() ); + renderSouth( tt, static_cast(pX), static_cast(pY), static_cast(pZ), GrassTile_SPU::getSideTextureOverlay() ); t->setMipmapEnable( prev ); } } @@ -5217,14 +5217,14 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti float _ll1 = (llx00 + llx0Z + llxY0 + llxYZ) / 4.0f; float _ll2 = (llx0z + llx00 + llxYz + llxY0) / 4.0f; float _ll3 = (llxyz + llxy0 + llx0z + llx00) / 4.0f; - ll1 = (float) (_ll1 * tileShapeY1 * tileShapeZ1 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY1) - * tileShapeZ1); - ll2 = (float) (_ll1 * tileShapeY1 * tileShapeZ0 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY1) - * tileShapeZ0); - ll3 = (float) (_ll1 * tileShapeY0 * tileShapeZ0 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY0) - * tileShapeZ0); - ll4 = (float) (_ll1 * tileShapeY0 * tileShapeZ1 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY0) - * tileShapeZ1); + ll1 = static_cast(_ll1 * tileShapeY1 * tileShapeZ1 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY1) + * tileShapeZ1); + ll2 = static_cast(_ll1 * tileShapeY1 * tileShapeZ0 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY1) + * tileShapeZ0); + ll3 = static_cast(_ll1 * tileShapeY0 * tileShapeZ0 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY0) + * tileShapeZ0); + ll4 = static_cast(_ll1 * tileShapeY0 * tileShapeZ1 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY0) + * tileShapeZ1); int _tc4 = blend(ccxy0, ccxyZ, ccx0Z, ccx00); int _tc1 = blend(ccx0Z, ccxY0, ccxYZ, ccx00); @@ -5269,7 +5269,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c4g *= ll4; c4b *= ll4; Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 4); - renderWest( tt, ( float )pX, ( float )pY, ( float )pZ, tex ); + renderWest( tt, static_cast(pX), static_cast(pY), static_cast(pZ), tex ); if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() )) { @@ -5286,7 +5286,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c3b *= pBaseBlue; c4b *= pBaseBlue; bool prev = t->setMipmapEnable( false ); // 4J added - this is rendering the little bit of grass at the top of the side of dirt, don't mipmap it - renderWest( tt, ( float )pX, ( float )pY, ( float )pZ, GrassTile_SPU::getSideTextureOverlay() ); + renderWest( tt, static_cast(pX), static_cast(pY), static_cast(pZ), GrassTile_SPU::getSideTextureOverlay() ); t->setMipmapEnable( prev ); } } @@ -5352,14 +5352,14 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti float _ll2 = (llXyz + llXy0 + llX0z + llX00) / 4.0f; float _ll3 = (llX0z + llX00 + llXYz + llXY0) / 4.0f; float _ll4 = (llX00 + llX0Z + llXY0 + llXYZ) / 4.0f; - ll1 = (float) (_ll1 * (1.0 - tileShapeY0) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY0 - * tileShapeZ1); - ll2 = (float) (_ll1 * (1.0 - tileShapeY0) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY0 - * tileShapeZ0); - ll3 = (float) (_ll1 * (1.0 - tileShapeY1) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY1 - * tileShapeZ0); - ll4 = (float) (_ll1 * (1.0 - tileShapeY1) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY1 - * tileShapeZ1); + ll1 = static_cast(_ll1 * (1.0 - tileShapeY0) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY0 + * tileShapeZ1); + ll2 = static_cast(_ll1 * (1.0 - tileShapeY0) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY0 + * tileShapeZ0); + ll3 = static_cast(_ll1 * (1.0 - tileShapeY1) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY1 + * tileShapeZ0); + ll4 = static_cast(_ll1 * (1.0 - tileShapeY1) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY1 + * tileShapeZ1); int _tc1 = blend(ccXy0, ccXyZ, ccX0Z, ccX00); int _tc4 = blend(ccX0Z, ccXY0, ccXYZ, ccX00); @@ -5405,7 +5405,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c4b *= ll4; Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 5); - renderEast( tt, ( float )pX, ( float )pY, ( float )pZ, tex ); + renderEast( tt, static_cast(pX), static_cast(pY), static_cast(pZ), tex ); if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() )) { c1r *= pBaseRed; @@ -5422,7 +5422,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti c4b *= pBaseBlue; bool prev = t->setMipmapEnable( false ); // 4J added - this is rendering the little bit of grass at the top of the side of dirt, don't mipmap it - renderEast( tt, ( float )pX, ( float )pY, ( float )pZ, GrassTile_SPU::getSideTextureOverlay() ); + renderEast( tt, static_cast(pX), static_cast(pY), static_cast(pZ), GrassTile_SPU::getSideTextureOverlay() ); t->setMipmapEnable( prev ); } } @@ -6005,8 +6005,8 @@ int TileRenderer_SPU::blend( int a, int b, int c, int def ) int TileRenderer_SPU::blend(int a, int b, int c, int d, float fa, float fb, float fc, float fd) { - int top = (int) ((float) ((a >> 16) & 0xff) * fa + (float) ((b >> 16) & 0xff) * fb + (float) ((c >> 16) & 0xff) * fc + (float) ((d >> 16) & 0xff) * fd) & 0xff; - int bottom = (int) ((float) (a & 0xff) * fa + (float) (b & 0xff) * fb + (float) (c & 0xff) * fc + (float) (d & 0xff) * fd) & 0xff; + int top = static_cast((float)((a >> 16) & 0xff) * fa + (float)((b >> 16) & 0xff) * fb + (float)((c >> 16) & 0xff) * fc + (float)((d >> 16) & 0xff) * fd) & 0xff; + int bottom = static_cast((float)(a & 0xff) * fa + (float)(b & 0xff) * fb + (float)(c & 0xff) * fc + (float)(d & 0xff) * fd) & 0xff; return (top << 16) | bottom; } diff --git a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_shared.inl index 4fae9c12c..ab78cd93a 100644 --- a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_shared.inl @@ -368,7 +368,7 @@ static void gdraw_HandleTransitionInsertBefore(GDrawHandle *t, GDrawHandleState { check_lists(t->cache); assert(t->state != GDRAW_HANDLE_STATE_sentinel); // sentinels should never get here! - assert(t->state != (U32) new_state); // code should never call "transition" if it's not transitioning! + assert(t->state != static_cast(new_state)); // code should never call "transition" if it's not transitioning! // unlink from prev state t->prev->next = t->next; t->next->prev = t->prev; @@ -777,7 +777,7 @@ static GDrawTexture *gdraw_BlurPass(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRe if (!g->TextureDrawBufferBegin(draw_bounds, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats)) return r->tex[0]; - c->BlurPass(r, taps, data, draw_bounds, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, draw_bounds, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -829,7 +829,7 @@ static GDrawTexture *gdraw_BlurPassDownsample(GDrawFunctions *g, GDrawBlurInfo * assert(clamp[0] <= clamp[2]); assert(clamp[1] <= clamp[3]); - c->BlurPass(r, taps, data, &z, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, &z, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -841,7 +841,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR GDrawTexture *t; F32 data[MAX_TAPS][4]; S32 off_axis = 1-axis; - S32 w = ((S32) ceil((blur_width-1)/2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 + S32 w = static_cast(ceil((blur_width - 1) / 2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 F32 edge_weight = 1 - (w - blur_width)/2; // 3 => 0 => 1; 1.2 => 1.8 => 0.9 => 0.1 F32 inverse_weight = 1.0f / blur_width; @@ -948,7 +948,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR // max coverage is 25 samples, or a filter width of 13. with 7 taps, we sample // 13 samples in one pass, max coverage is 13*13 samples or (13*13-1)/2 width, // which is ((2T-1)*(2T-1)-1)/2 or (4T^2 - 4T + 1 -1)/2 or 2T^2 - 2T or 2T*(T-1) - S32 w_mip = (S32) ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS)); + S32 w_mip = static_cast(ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS))); S32 downsample = w_mip; F32 sample_spacing = texel; if (downsample < 2) downsample = 2; diff --git a/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp index 9110edf55..fd311fa7b 100644 --- a/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp @@ -131,10 +131,10 @@ int SonyHttp_Vita::sslCallback(SceUInt32 verifyErr, SceSslCert * const sslCert[] (void)userArg; app.DebugPrintf("Ssl callback:\n"); - app.DebugPrintf("\tbase tmpl[%x]\n", (SceInt32)userArg); + app.DebugPrintf("\tbase tmpl[%x]\n", static_cast(userArg)); if (verifyErr != 0){ - printSslError((SceInt32)SCE_HTTPS_ERROR_CERT, verifyErr); + printSslError(static_cast(SCE_HTTPS_ERROR_CERT), verifyErr); } for (i = 0; i < certNum; i++){ printSslCertInfo(sslCert[i]); @@ -192,7 +192,7 @@ bool SonyHttp_Vita::http_get(const char *targetUrl, void** ppOutData, int* pData } /* Register SSL callback */ - ret = sceHttpsSetSslCallback(tmplId, sslCallback, (void*)&tmplId); + ret = sceHttpsSetSslCallback(tmplId, sslCallback, static_cast(&tmplId)); if (ret < 0) { app.DebugPrintf("sceHttpsSetSslCallback() error: 0x%08X\n", ret); diff --git a/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp index c103b32fd..ed7fa5ccb 100644 --- a/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp @@ -26,7 +26,7 @@ static SceRemoteStorageData s_getDataOutput; void SonyRemoteStorage_Vita::staticInternalCallback(const SceRemoteStorageEvent event, int32_t retCode, void * userData) { - ((SonyRemoteStorage_Vita*)userData)->internalCallback(event, retCode); + static_cast(userData)->internalCallback(event, retCode); } void SonyRemoteStorage_Vita::internalCallback(const SceRemoteStorageEvent event, int32_t retCode) @@ -299,7 +299,7 @@ bool SonyRemoteStorage_Vita::setDataInternal() snprintf(m_saveFilename, sizeof(m_saveFilename), "%s:%s/GAMEDATA.bin", "savedata0", m_setDataSaveInfo->UTF8SaveFilename); SceFiosSize outSize = sceFiosFileGetSizeSync(NULL, m_saveFilename); - m_uploadSaveSize = (int)outSize; + m_uploadSaveSize = static_cast(outSize); strcpy(m_saveFileDesc, m_setDataSaveInfo->UTF8SaveTitle); m_status = e_setDataInProgress; diff --git a/Minecraft.Client/PSVita/PSVitaExtras/CustomMap.cpp b/Minecraft.Client/PSVita/PSVitaExtras/CustomMap.cpp index 1327a6d6f..9203c30d0 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/CustomMap.cpp +++ b/Minecraft.Client/PSVita/PSVitaExtras/CustomMap.cpp @@ -9,7 +9,7 @@ CustomMap::CustomMap() m_NodePoolIndex = 0; m_HashSize = 1024; - m_HashTable = (SCustomMapNode**) malloc(m_HashSize * sizeof(SCustomMapNode)); + m_HashTable = static_cast(malloc(m_HashSize * sizeof(SCustomMapNode))); clear(); } @@ -115,16 +115,16 @@ void CustomMap::resize() SCustomMapNode **NodePool; if( m_NodePool ) { - NodePool = (SCustomMapNode**) realloc(m_NodePool, m_NodePoolSize * sizeof(SCustomMapNode)); + NodePool = static_cast(realloc(m_NodePool, m_NodePoolSize * sizeof(SCustomMapNode))); } else { - NodePool = (SCustomMapNode**) malloc(m_NodePoolSize * sizeof(SCustomMapNode)); + NodePool = static_cast(malloc(m_NodePoolSize * sizeof(SCustomMapNode))); } for( int i = 0;i < m_NodePoolSize - OldPoolSize;i += 1 ) { - NodePool[i + OldPoolSize] = (SCustomMapNode*) malloc(sizeof(SCustomMapNode)); + NodePool[i + OldPoolSize] = static_cast(malloc(sizeof(SCustomMapNode))); } m_NodePool = NodePool; diff --git a/Minecraft.Client/PSVita/PSVitaExtras/CustomSet.cpp b/Minecraft.Client/PSVita/PSVitaExtras/CustomSet.cpp index 6538a2360..108425931 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/CustomSet.cpp +++ b/Minecraft.Client/PSVita/PSVitaExtras/CustomSet.cpp @@ -9,7 +9,7 @@ CustomSet::CustomSet() m_NodePoolIndex = 0; m_HashSize = 1024; - m_HashTable = (SCustomSetNode**) malloc(m_HashSize * sizeof(SCustomSetNode)); + m_HashTable = static_cast(malloc(m_HashSize * sizeof(SCustomSetNode))); clear(); } @@ -113,16 +113,16 @@ void CustomSet::resize() SCustomSetNode **NodePool; if( m_NodePool ) { - NodePool = (SCustomSetNode**) realloc(m_NodePool, m_NodePoolSize * sizeof(SCustomSetNode)); + NodePool = static_cast(realloc(m_NodePool, m_NodePoolSize * sizeof(SCustomSetNode))); } else { - NodePool = (SCustomSetNode**) malloc(m_NodePoolSize * sizeof(SCustomSetNode)); + NodePool = static_cast(malloc(m_NodePoolSize * sizeof(SCustomSetNode))); } for( int i = 0;i < m_NodePoolSize - OldPoolSize;i += 1 ) { - NodePool[i + OldPoolSize] = (SCustomSetNode*) malloc(sizeof(SCustomSetNode)); + NodePool[i + OldPoolSize] = static_cast(malloc(sizeof(SCustomSetNode))); } m_NodePool = NodePool; diff --git a/Minecraft.Client/PSVita/PSVitaExtras/libdivide.h b/Minecraft.Client/PSVita/PSVitaExtras/libdivide.h index 201030185..e480ed198 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/libdivide.h +++ b/Minecraft.Client/PSVita/PSVitaExtras/libdivide.h @@ -210,7 +210,7 @@ LIBDIVIDE_API __m128i libdivide_s64_do_vector_alg4(__m128i numers, const struct static inline uint32_t libdivide__mullhi_u32(uint32_t x, uint32_t y) { uint64_t xl = x, yl = y; uint64_t rl = xl * yl; - return (uint32_t)(rl >> 32); + return static_cast(rl >> 32); } static uint64_t libdivide__mullhi_u64(uint64_t x, uint64_t y) { @@ -221,12 +221,12 @@ static uint64_t libdivide__mullhi_u64(uint64_t x, uint64_t y) { #else //full 128 bits are x0 * y0 + (x0 * y1 << 32) + (x1 * y0 << 32) + (x1 * y1 << 64) const uint32_t mask = 0xFFFFFFFF; - const uint32_t x0 = (uint32_t)(x & mask), x1 = (uint32_t)(x >> 32); - const uint32_t y0 = (uint32_t)(y & mask), y1 = (uint32_t)(y >> 32); + const uint32_t x0 = static_cast(x & mask), x1 = static_cast(x >> 32); + const uint32_t y0 = static_cast(y & mask), y1 = static_cast(y >> 32); const uint32_t x0y0_hi = libdivide__mullhi_u32(x0, y0); - const uint64_t x0y1 = x0 * (uint64_t)y1; - const uint64_t x1y0 = x1 * (uint64_t)y0; - const uint64_t x1y1 = x1 * (uint64_t)y1; + const uint64_t x0y1 = x0 * static_cast(y1); + const uint64_t x1y0 = x1 * static_cast(y0); + const uint64_t x1y1 = x1 * static_cast(y1); uint64_t temp = x1y0 + x0y0_hi; uint64_t temp_lo = temp & mask, temp_hi = temp >> 32; @@ -242,12 +242,12 @@ static inline int64_t libdivide__mullhi_s64(int64_t x, int64_t y) { #else //full 128 bits are x0 * y0 + (x0 * y1 << 32) + (x1 * y0 << 32) + (x1 * y1 << 64) const uint32_t mask = 0xFFFFFFFF; - const uint32_t x0 = (uint32_t)(x & mask), y0 = (uint32_t)(y & mask); - const int32_t x1 = (int32_t)(x >> 32), y1 = (int32_t)(y >> 32); + const uint32_t x0 = static_cast(x & mask), y0 = static_cast(y & mask); + const int32_t x1 = static_cast(x >> 32), y1 = static_cast(y >> 32); const uint32_t x0y0_hi = libdivide__mullhi_u32(x0, y0); - const int64_t t = x1*(int64_t)y0 + x0y0_hi; - const int64_t w1 = x0*(int64_t)y1 + (t & mask); - return x1*(int64_t)y1 + (t >> 32) + (w1 >> 32); + const int64_t t = x1*static_cast(y0) + x0y0_hi; + const int64_t w1 = x0*static_cast(y1) + (t & mask); + return x1*static_cast(y1) + (t >> 32) + (w1 >> 32); #endif } @@ -398,7 +398,7 @@ static inline int32_t libdivide__count_trailing_zeros64(uint64_t val) { /* Pretty good way to count trailing zeros. Note that this hangs for val = 0! */ uint32_t lo = val & 0xFFFFFFFF; if (lo != 0) return libdivide__count_trailing_zeros32(lo); - return 32 + libdivide__count_trailing_zeros32((uint32_t)(val >> 32)); + return 32 + libdivide__count_trailing_zeros32(static_cast(val >> 32)); #endif } @@ -444,9 +444,9 @@ static uint32_t libdivide_64_div_32_to_32(uint32_t u1, uint32_t u0, uint32_t v, } #else static uint32_t libdivide_64_div_32_to_32(uint32_t u1, uint32_t u0, uint32_t v, uint32_t *r) { - uint64_t n = (((uint64_t)u1) << 32) | u0; - uint32_t result = (uint32_t)(n / v); - *r = (uint32_t)(n - result * (uint64_t)v); + uint64_t n = (static_cast(u1) << 32) | u0; + uint32_t result = static_cast(n / v); + *r = static_cast(n - result * (uint64_t)v); return result; } #endif @@ -479,8 +479,8 @@ static uint64_t libdivide_128_div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v, if (u1 >= v) { // If overflow, set rem. if (r != NULL) // to an impossible value, - *r = (uint64_t)(-1); // and return the largest - return (uint64_t)(-1);} // possible quotient. + *r = static_cast(-1); // and return the largest + return static_cast(-1);} // possible quotient. /* count leading zeros */ s = libdivide__count_leading_zeros64(v); // 0 <= s <= 63. @@ -770,14 +770,14 @@ __m128i libdivide_u64_do_vector_alg2(__m128i numers, const struct libdivide_u64_ static inline int32_t libdivide__mullhi_s32(int32_t x, int32_t y) { int64_t xl = x, yl = y; int64_t rl = xl * yl; - return (int32_t)(rl >> 32); //needs to be arithmetic shift + return static_cast(rl >> 32); //needs to be arithmetic shift } struct libdivide_s32_t libdivide_s32_gen(int32_t d) { struct libdivide_s32_t result; /* If d is a power of 2, or negative a power of 2, we have to use a shift. This is especially important because the magic algorithm fails for -1. To check if d is a power of 2 or its inverse, it suffices to check whether its absolute value has exactly one bit set. This works even for INT_MIN, because abs(INT_MIN) == INT_MIN, and INT_MIN has one bit set and is a power of 2. */ - uint32_t absD = (uint32_t)(d < 0 ? -d : d); //gcc optimizes this to the fast abs trick + uint32_t absD = static_cast(d < 0 ? -d : d); //gcc optimizes this to the fast abs trick if ((absD & (absD - 1)) == 0) { //check if exactly one bit is set, don't care if absD is 0 since that's divide by zero result.magic = 0; result.more = libdivide__count_trailing_zeros32(absD) | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0) | LIBDIVIDE_S32_SHIFT_PATH; @@ -805,7 +805,7 @@ struct libdivide_s32_t libdivide_s32_gen(int32_t d) { more = floor_log_2_d | LIBDIVIDE_ADD_MARKER | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0); //use the general algorithm } proposed_m += 1; - result.magic = (d < 0 ? -(int32_t)proposed_m : (int32_t)proposed_m); + result.magic = (d < 0 ? -static_cast(proposed_m) : static_cast(proposed_m)); result.more = more; } @@ -818,14 +818,14 @@ int32_t libdivide_s32_do(int32_t numer, const struct libdivide_s32_t *denom) { uint8_t shifter = more & LIBDIVIDE_32_SHIFT_MASK; int32_t q = numer + ((numer >> 31) & ((1 << shifter) - 1)); q = q >> shifter; - int32_t shiftMask = (int8_t)more >> 7; //must be arithmetic shift and then sign-extend + int32_t shiftMask = static_cast(more) >> 7; //must be arithmetic shift and then sign-extend q = (q ^ shiftMask) - shiftMask; return q; } else { int32_t q = libdivide__mullhi_s32(denom->magic, numer); if (more & LIBDIVIDE_ADD_MARKER) { - int32_t sign = (int8_t)more >> 7; //must be arithmetic shift and then sign extend + int32_t sign = static_cast(more) >> 7; //must be arithmetic shift and then sign extend q += ((numer ^ sign) - sign); } q >>= more & LIBDIVIDE_32_SHIFT_MASK; @@ -946,7 +946,7 @@ struct libdivide_s64_t libdivide_s64_gen(int64_t d) { struct libdivide_s64_t result; /* If d is a power of 2, or negative a power of 2, we have to use a shift. This is especially important because the magic algorithm fails for -1. To check if d is a power of 2 or its inverse, it suffices to check whether its absolute value has exactly one bit set. This works even for INT_MIN, because abs(INT_MIN) == INT_MIN, and INT_MIN has one bit set and is a power of 2. */ - const uint64_t absD = (uint64_t)(d < 0 ? -d : d); //gcc optimizes this to the fast abs trick + const uint64_t absD = static_cast(d < 0 ? -d : d); //gcc optimizes this to the fast abs trick if ((absD & (absD - 1)) == 0) { //check if exactly one bit is set, don't care if absD is 0 since that's divide by zero result.more = libdivide__count_trailing_zeros64(absD) | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0); result.magic = 0; @@ -974,7 +974,7 @@ struct libdivide_s64_t libdivide_s64_gen(int64_t d) { } proposed_m += 1; result.more = more; - result.magic = (d < 0 ? -(int64_t)proposed_m : (int64_t)proposed_m); + result.magic = (d < 0 ? -static_cast(proposed_m) : static_cast(proposed_m)); } return result; } @@ -986,14 +986,14 @@ int64_t libdivide_s64_do(int64_t numer, const struct libdivide_s64_t *denom) { uint32_t shifter = more & LIBDIVIDE_64_SHIFT_MASK; int64_t q = numer + ((numer >> 63) & ((1LL << shifter) - 1)); q = q >> shifter; - int64_t shiftMask = (int8_t)more >> 7; //must be arithmetic shift and then sign-extend + int64_t shiftMask = static_cast(more) >> 7; //must be arithmetic shift and then sign-extend q = (q ^ shiftMask) - shiftMask; return q; } else { int64_t q = libdivide__mullhi_s64(magic, numer); if (more & LIBDIVIDE_ADD_MARKER) { - int64_t sign = (int8_t)more >> 7; //must be arithmetic shift and then sign extend + int64_t sign = static_cast(more) >> 7; //must be arithmetic shift and then sign extend q += ((numer ^ sign) - sign); } q >>= more & LIBDIVIDE_64_SHIFT_MASK; @@ -1141,8 +1141,8 @@ namespace libdivide_internal { #endif /* Some bogus unswitch functions for unsigned types so the same (presumably templated) code can work for both signed and unsigned. */ - uint32_t crash_u32(uint32_t, const libdivide_u32_t *) { abort(); return *(uint32_t *)NULL; } - uint64_t crash_u64(uint64_t, const libdivide_u64_t *) { abort(); return *(uint64_t *)NULL; } + uint32_t crash_u32(uint32_t, const libdivide_u32_t *) { abort(); return *static_cast(NULL); } + uint64_t crash_u64(uint64_t, const libdivide_u64_t *) { abort(); return *static_cast(NULL); } #if LIBDIVIDE_USE_SSE2 __m128i crash_u32_vector(__m128i, const libdivide_u32_t *) { abort(); return *(__m128i *)NULL; } __m128i crash_u64_vector(__m128i, const libdivide_u64_t *) { abort(); return *(__m128i *)NULL; } diff --git a/Minecraft.Client/PaintingRenderer.cpp b/Minecraft.Client/PaintingRenderer.cpp index f5e09dbd2..b51ab0f48 100644 --- a/Minecraft.Client/PaintingRenderer.cpp +++ b/Minecraft.Client/PaintingRenderer.cpp @@ -21,7 +21,7 @@ void PaintingRenderer::render(shared_ptr _painting, double x, double y, random->setSeed(187); glPushMatrix(); - glTranslatef((float)x, (float)y, (float)z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); glRotatef(rot, 0, 1, 0); glEnable(GL_RESCALE_NORMAL); bindTexture(painting); // 4J was L"/art/kz.png" diff --git a/Minecraft.Client/Particle.cpp b/Minecraft.Client/Particle.cpp index 1091a26aa..25ec2ec4c 100644 --- a/Minecraft.Client/Particle.cpp +++ b/Minecraft.Client/Particle.cpp @@ -35,7 +35,7 @@ void Particle::_init(Level *level, double x, double y, double z) size = (random->nextFloat() * 0.5f + 0.5f) * 2; - lifetime = (int) (4 / (random->nextFloat() * 0.9f + 0.1f)); + lifetime = static_cast(4 / (random->nextFloat() * 0.9f + 0.1f)); age = 0; texX = 0; @@ -51,10 +51,10 @@ Particle::Particle(Level *level, double x, double y, double z, double xa, double { _init(level,x,y,z); - xd = xa + (float) (Math::random() * 2 - 1) * 0.4f; - yd = ya + (float) (Math::random() * 2 - 1) * 0.4f; - zd = za + (float) (Math::random() * 2 - 1) * 0.4f; - float speed = (float) (Math::random() + Math::random() + 1) * 0.15f; + xd = xa + static_cast(Math::random() * 2 - 1) * 0.4f; + yd = ya + static_cast(Math::random() * 2 - 1) * 0.4f; + zd = za + static_cast(Math::random() * 2 - 1) * 0.4f; + float speed = static_cast(Math::random() + Math::random() + 1) * 0.15f; float dd = (float) (Mth::sqrt(xd * xd + yd * yd + zd * zd)); xd = xd / dd * speed * 0.4f; @@ -164,9 +164,9 @@ void Particle::render(Tesselator *t, float a, float xa, float ya, float za, floa v1 = tex->getV1(); } - float x = (float) (xo + (this->x - xo) * a - xOff); - float y = (float) (yo + (this->y - yo) * a - yOff); - float z = (float) (zo + (this->z - zo) * a - zOff); + float x = static_cast(xo + (this->x - xo) * a - xOff); + float y = static_cast(yo + (this->y - yo) * a - yOff); + float z = static_cast(zo + (this->z - zo) * a - zOff); float br = 1.0f; // 4J - change brought forward from 1.8.2 if( !SharedConstants::TEXTURE_LIGHTING ) diff --git a/Minecraft.Client/PauseScreen.cpp b/Minecraft.Client/PauseScreen.cpp index 18d066b5a..791d819b5 100644 --- a/Minecraft.Client/PauseScreen.cpp +++ b/Minecraft.Client/PauseScreen.cpp @@ -88,7 +88,7 @@ void PauseScreen::render(int xm, int ym, float a) { float col = ((visibleTime % 10) + a) / 10.0f; col = Mth::sin(col * PI * 2) * 0.2f + 0.8f; - int br = (int) (255 * col); + int br = static_cast(255 * col); drawString(font, L"Saving level..", 8, height - 16, br << 16 | br << 8 | br); } diff --git a/Minecraft.Client/PistonPieceRenderer.cpp b/Minecraft.Client/PistonPieceRenderer.cpp index c51d2e0f8..ca7294fc8 100644 --- a/Minecraft.Client/PistonPieceRenderer.cpp +++ b/Minecraft.Client/PistonPieceRenderer.cpp @@ -35,7 +35,7 @@ void PistonPieceRenderer::render(shared_ptr _entity, double x, doubl t->begin(); - t->offset((float) x - entity->x + entity->getXOff(a), (float) y - entity->y + entity->getYOff(a), (float) z - entity->z + entity->getZOff(a)); + t->offset(static_cast(x) - entity->x + entity->getXOff(a), static_cast(y) - entity->y + entity->getYOff(a), static_cast(z) - entity->z + entity->getZOff(a)); t->color(1, 1, 1); if (tile == Tile::pistonExtension && entity->getProgress(a) < 0.5f) { @@ -45,11 +45,11 @@ void PistonPieceRenderer::render(shared_ptr _entity, double x, doubl else if (entity->isSourcePiston() && !entity->isExtending()) { // special case for withdrawing the arm back into the base - Tile::pistonExtension->setOverrideTopTexture(((PistonBaseTile *) tile)->getPlatformTexture()); + Tile::pistonExtension->setOverrideTopTexture(static_cast(tile)->getPlatformTexture()); tileRenderer->tesselatePistonArmNoCulling(Tile::pistonExtension, entity->x, entity->y, entity->z, entity->getProgress(a) < 0.5f, entity->getData()); Tile::pistonExtension->clearOverrideTopTexture(); - t->offset((float) x - entity->x, (float) y - entity->y, (float) z - entity->z); + t->offset(static_cast(x) - entity->x, static_cast(y) - entity->y, static_cast(z) - entity->z); tileRenderer->tesselatePistonBaseForceExtended(tile, entity->x, entity->y, entity->z, entity->getData()); } else diff --git a/Minecraft.Client/PlayerChunkMap.cpp b/Minecraft.Client/PlayerChunkMap.cpp index ae81bd699..01d1b8fdb 100644 --- a/Minecraft.Client/PlayerChunkMap.cpp +++ b/Minecraft.Client/PlayerChunkMap.cpp @@ -187,7 +187,7 @@ void PlayerChunkMap::PlayerChunk::tileChanged(int x, int y, int z) if (changes < MAX_CHANGES_BEFORE_RESEND) { - short id = (short) ((x << 12) | (z << 8) | (y)); + short id = static_cast((x << 12) | (z << 8) | (y)); for (int i = 0; i < changes; i++) { @@ -365,7 +365,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) else { // 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet - broadcast( shared_ptr( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, (byte)changes, level) ) ); + broadcast( shared_ptr( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, static_cast(changes), level) ) ); for (int i = 0; i < changes; i++) { int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15); @@ -544,8 +544,8 @@ void PlayerChunkMap::tickAddRequests(shared_ptr player) if( addRequests.size() ) { // Find the nearest chunk request to the player - int px = (int)player->x; - int pz = (int)player->z; + int px = static_cast(player->x); + int pz = static_cast(player->z); int minDistSq = -1; auto itNearest = addRequests.end(); @@ -621,8 +621,8 @@ void PlayerChunkMap::add(shared_ptr player) { static int direction[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, {0, -1} }; - int xc = (int) player->x >> 4; - int zc = (int) player->z >> 4; + int xc = static_cast(player->x) >> 4; + int zc = static_cast(player->z) >> 4; player->lastMoveX = player->x; player->lastMoveZ = player->z; @@ -724,8 +724,8 @@ void PlayerChunkMap::add(shared_ptr player) void PlayerChunkMap::remove(shared_ptr player) { - int xc = ((int) player->lastMoveX) >> 4; - int zc = ((int) player->lastMoveZ) >> 4; + int xc = static_cast(player->lastMoveX) >> 4; + int zc = static_cast(player->lastMoveZ) >> 4; for (int x = xc - radius; x <= xc + radius; x++) for (int z = zc - radius; z <= zc + radius; z++) @@ -767,16 +767,16 @@ bool PlayerChunkMap::chunkInRange(int x, int z, int xc, int zc) // need to be created, so that we aren't creating potentially 20 chunks per player per tick void PlayerChunkMap::move(shared_ptr player) { - int xc = ((int) player->x) >> 4; - int zc = ((int) player->z) >> 4; + int xc = static_cast(player->x) >> 4; + int zc = static_cast(player->z) >> 4; double _xd = player->lastMoveX - player->x; double _zd = player->lastMoveZ - player->z; double dist = _xd * _xd + _zd * _zd; if (dist < 8 * 8) return; - int last_xc = ((int) player->lastMoveX) >> 4; - int last_zc = ((int) player->lastMoveZ) >> 4; + int last_xc = static_cast(player->lastMoveX) >> 4; + int last_zc = static_cast(player->lastMoveZ) >> 4; int xd = xc - last_xc; int zd = zc - last_zc; @@ -841,8 +841,8 @@ void PlayerChunkMap::setRadius(int newRadius) shared_ptr player = players->players[i]; if( player->level == level ) { - int xc = ((int) player->x) >> 4; - int zc = ((int) player->z) >> 4; + int xc = static_cast(player->x) >> 4; + int zc = static_cast(player->z) >> 4; for (int x = xc - newRadius; x <= xc + newRadius; x++) for (int z = zc - newRadius; z <= zc + newRadius; z++) diff --git a/Minecraft.Client/PlayerCloudParticle.cpp b/Minecraft.Client/PlayerCloudParticle.cpp index 6976fbab9..5132dfc6b 100644 --- a/Minecraft.Client/PlayerCloudParticle.cpp +++ b/Minecraft.Client/PlayerCloudParticle.cpp @@ -15,12 +15,12 @@ PlayerCloudParticle::PlayerCloudParticle(Level *level, double x, double y, doubl yd += ya; zd += za; - rCol = gCol = bCol = 1 - (float) (Math::random() * 0.3f); + rCol = gCol = bCol = 1 - static_cast(Math::random() * 0.3f); size *= 0.75f; size *= scale; oSize = size; - lifetime = (int) (8 / (Math::random() * 0.8 + 0.3)); + lifetime = static_cast(8 / (Math::random() * 0.8 + 0.3)); lifetime *= scale; noPhysics = false; } diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index 266cae361..234a7bfa6 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -195,7 +195,7 @@ void PlayerConnection::handleMovePlayer(shared_ptr packet) yLastOk = player->y; zLastOk = player->z; } - ((Level *)level)->tick(player); + static_cast(level)->tick(player); return; } @@ -204,7 +204,7 @@ void PlayerConnection::handleMovePlayer(shared_ptr packet) { player->doTick(false); player->absMoveTo(xLastOk, yLastOk, zLastOk, player->yRot, player->xRot); - ((Level *)level)->tick(player); + static_cast(level)->tick(player); return; } @@ -1185,8 +1185,8 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptrx / scale) * scale); - int centreZC = (int) (Math::round(player->z / scale) * scale); + int centreXC = static_cast(Math::round(player->x / scale) * scale); + int centreZC = static_cast(Math::round(player->z / scale) * scale); #else // 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map int centreXC = 0; @@ -1210,7 +1210,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptrx = centreXC; data->z = centreZC; - data->dimension = (byte) player->level->dimension->id; + data->dimension = static_cast(player->level->dimension->id); data->setDirty(); } @@ -1313,7 +1313,7 @@ void PlayerConnection::handleKeepAlive(shared_ptr packet) { if (packet->id == lastKeepAliveId) { - int time = (int) (System::nanoTime() / 1000000 - lastKeepAliveTime); + int time = static_cast(System::nanoTime() / 1000000 - lastKeepAliveTime); player->latency = (player->latency * 3 + time) / 4; } } @@ -1489,7 +1489,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr custo AbstractContainerMenu *menu = player->containerMenu; if (dynamic_cast(menu)) { - ((MerchantMenu *) menu)->setSelectionHint(selection); + static_cast(menu)->setSelectionHint(selection); } } else if (CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET.compare(customPayloadPacket->identifier) == 0) @@ -1531,7 +1531,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr custo int primary = input.readInt(); int secondary = input.readInt(); - BeaconMenu *beaconMenu = (BeaconMenu *) player->containerMenu; + BeaconMenu *beaconMenu = static_cast(player->containerMenu); Slot *slot = beaconMenu->getSlot(0); if (slot->hasItem()) { @@ -1600,7 +1600,7 @@ void PlayerConnection::handleCraftItem(shared_ptr packet) } else if (pTempItemInst->id == Item::fireworksCharge_Id || pTempItemInst->id == Item::fireworks_Id) { - CraftingMenu *menu = (CraftingMenu *)player->containerMenu; + CraftingMenu *menu = static_cast(player->containerMenu); player->openFireworks(menu->getX(), menu->getY(), menu->getZ() ); } else @@ -1697,7 +1697,7 @@ void PlayerConnection::handleTradeItem(shared_ptr packet) { if (player->containerMenu->containerId == packet->containerId) { - MerchantMenu *menu = (MerchantMenu *)player->containerMenu; + MerchantMenu *menu = static_cast(player->containerMenu); MerchantRecipeList *offers = menu->getMerchant()->getOffers(player); diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp index c1ccfe148..d1bde2079 100644 --- a/Minecraft.Client/PlayerList.cpp +++ b/Minecraft.Client/PlayerList.cpp @@ -85,7 +85,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr bool newPlayer = playerTag == NULL; player->setLevel(server->getLevel(player->dimension)); - player->gameMode->setLevel((ServerLevel *)player->level); + player->gameMode->setLevel(static_cast(player->level)); // Make sure these privileges are always turned off for the host player INetworkPlayer *networkPlayer = connection->getSocket()->getPlayer(); @@ -108,7 +108,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr #ifdef _WINDOWS64 if (networkPlayer != NULL && !networkPlayer->IsLocal()) { - NetworkPlayerXbox* nxp = (NetworkPlayerXbox*)networkPlayer; + NetworkPlayerXbox* nxp = static_cast(networkPlayer); IQNetPlayer* qnp = nxp->GetQNetPlayer(); wcsncpy_s(qnp->m_gamertag, 32, player->name.c_str(), _TRUNCATE); } @@ -151,8 +151,8 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr int mapScale = 3; #ifdef _LARGE_WORLDS int scale = MapItemSavedData::MAP_SIZE * 2 * (1 << mapScale); - int centreXC = (int) (Math::round(player->x / scale) * scale); - int centreZC = (int) (Math::round(player->z / scale) * scale); + int centreXC = static_cast(Math::round(player->x / scale) * scale); + int centreZC = static_cast(Math::round(player->z / scale) * scale); #else // 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map int centreXC = 0; @@ -226,8 +226,8 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr addPlayerToReceiving( player ); playerConnection->send( shared_ptr( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(), - (byte) level->dimension->id, (byte) level->getMaxBuildHeight(), (byte) getMaxPlayers(), - level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), + static_cast(level->dimension->id), static_cast(level->getMaxBuildHeight()), static_cast(getMaxPlayers()), + level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), static_cast(playerIndex), level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) ); playerConnection->send( shared_ptr( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) ); playerConnection->send( shared_ptr( new PlayerAbilitiesPacket(&player->abilities)) ); @@ -329,7 +329,7 @@ void PlayerList::changeDimension(shared_ptr player, ServerLevel *f if (from != NULL) from->getChunkMap()->remove(player); to->getChunkMap()->add(player); - to->cache->create(((int) player->x) >> 4, ((int) player->z) >> 4); + to->cache->create(static_cast(player->x) >> 4, static_cast(player->z) >> 4); } int PlayerList::getMaxRange() @@ -506,7 +506,7 @@ if (player->riding != NULL) shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid) { #ifdef _WINDOWS64 - if (players.size() >= (unsigned int)MINECRAFT_NET_MAX_PLAYERS) + if (players.size() >= static_cast(MINECRAFT_NET_MAX_PLAYERS)) #else if (players.size() >= (unsigned int)maxPlayers) #endif @@ -682,14 +682,14 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay } // Ensure the area the player is spawning in is loaded! - level->cache->create(((int) player->x) >> 4, ((int) player->z) >> 4); + level->cache->create(static_cast(player->x) >> 4, static_cast(player->z) >> 4); while (!level->getCubes(player, player->bb)->empty()) { player->setPos(player->x, player->y + 1, player->z); } - player->connection->send( std::make_shared( (char) player->dimension, player->level->getSeed(), player->level->getMaxBuildHeight(), + player->connection->send( std::make_shared( static_cast(player->dimension), player->level->getSeed(), player->level->getMaxBuildHeight(), player->gameMode->getGameModeForPlayer(), level->difficulty, level->getLevelData()->getGenerator(), player->level->useNewSeaLevel(), player->entityId, level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ); player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot); @@ -806,7 +806,7 @@ void PlayerList::toggleDimension(shared_ptr player, int targetDime // 4J Stu Added so that we remove entities from the correct level, after the respawn packet we will be in the wrong level player->flushEntitiesToRemove(); - player->connection->send( shared_ptr( new RespawnPacket((char) player->dimension, newLevel->getSeed(), newLevel->getMaxBuildHeight(), + player->connection->send( shared_ptr( new RespawnPacket(static_cast(player->dimension), newLevel->getSeed(), newLevel->getMaxBuildHeight(), player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(), newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale()) ) ); @@ -905,8 +905,8 @@ void PlayerList::repositionAcrossDimension(shared_ptr entity, int lastDi if (lastDimension != 1) { - xt = (double) Mth::clamp((int) xt, -Level::MAX_LEVEL_SIZE + 128, Level::MAX_LEVEL_SIZE - 128); - zt = (double) Mth::clamp((int) zt, -Level::MAX_LEVEL_SIZE + 128, Level::MAX_LEVEL_SIZE - 128); + xt = static_cast(Mth::clamp((int)xt, -Level::MAX_LEVEL_SIZE + 128, Level::MAX_LEVEL_SIZE - 128)); + zt = static_cast(Mth::clamp((int)zt, -Level::MAX_LEVEL_SIZE + 128, Level::MAX_LEVEL_SIZE - 128)); if (entity->isAlive()) { newLevel->addEntity(entity); @@ -1314,7 +1314,7 @@ void PlayerList::saveAll(ProgressListener *progressListener, bool bDeleteGuestMa //4J Stu - We don't want to save the map data for guests, so when we are sure that the player is gone delete the map if(bDeleteGuestMaps && players[i]->isGuest()) playerIo->deleteMapFilesForPlayer(players[i]); - if(progressListener != NULL) progressListener->progressStagePercentage((i * 100)/ ((int)players.size())); + if(progressListener != NULL) progressListener->progressStagePercentage((i * 100)/ static_cast(players.size())); } playerIo->clearOldPlayerFiles(); playerIo->saveMapIdLookup(); @@ -1363,7 +1363,7 @@ void PlayerList::sendAllPlayerInfo(shared_ptr player) int PlayerList::getPlayerCount() { - return (int)players.size(); + return static_cast(players.size()); } int PlayerList::getPlayerCount(ServerLevel *level) diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index 71c05067b..09d754183 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -32,7 +32,7 @@ ResourceLocation PlayerRenderer::DEFAULT_LOCATION = ResourceLocation(TN_MOB_CHAR PlayerRenderer::PlayerRenderer() : LivingEntityRenderer( new HumanoidModel(0), 0.5f ) { - humanoidModel = (HumanoidModel *) model; + humanoidModel = static_cast(model); armorParts1 = new HumanoidModel(1.0f); armorParts2 = new HumanoidModel(0.5f); @@ -87,9 +87,9 @@ int PlayerRenderer::prepareArmor(shared_ptr _player, int layer, fl if (armorItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH) { int color = armorItem->getColor(itemInstance); - float red = (float) ((color >> 16) & 0xFF) / 0xFF; - float green = (float) ((color >> 8) & 0xFF) / 0xFF; - float blue = (float) (color & 0xFF) / 0xFF; + float red = static_cast((color >> 16) & 0xFF) / 0xFF; + float green = static_cast((color >> 8) & 0xFF) / 0xFF; + float blue = static_cast(color & 0xFF) / 0xFF; glColor3f(brightness * red, brightness * green, brightness * blue); if (itemInstance->isEnchanted()) return 0x1f; @@ -120,7 +120,7 @@ void PlayerRenderer::prepareSecondPassArmor(shared_ptr _player, in if (dynamic_cast(item)) { ArmorItem *armorItem = dynamic_cast(item); - bindTexture(HumanoidMobRenderer::getArmorLocation((ArmorItem *)item, layer, true)); + bindTexture(HumanoidMobRenderer::getArmorLocation(static_cast(item), layer, true)); float brightness = SharedConstants::TEXTURE_LIGHTING ? 1 : player->getBrightness(a); glColor3f(brightness, brightness, brightness); @@ -316,11 +316,11 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) double xa = Mth::sin(yr * PI / 180); double za = -Mth::cos(yr * PI / 180); - float flap = (float) yd * 10; + float flap = static_cast(yd) * 10; if (flap < -6) flap = -6; if (flap > 32) flap = 32; - float lean = (float) (xd * xa + zd * za) * 100; - float lean2 = (float) (xd * za - zd * xa) * 100; + float lean = static_cast(xd * xa + zd * za) * 100; + float lean2 = static_cast(xd * za - zd * xa) * 100; if (lean < 0) lean = 0; float pow = mob->oBob + (mob->bob - mob->oBob) * a; @@ -550,5 +550,5 @@ void PlayerRenderer::bindTexture(shared_ptr entity) ResourceLocation *PlayerRenderer::getTextureLocation(shared_ptr entity) { shared_ptr player = dynamic_pointer_cast(entity); - return new ResourceLocation((_TEXTURE_NAME)player->getTexture()); + return new ResourceLocation(static_cast<_TEXTURE_NAME>(player->getTexture())); } \ No newline at end of file diff --git a/Minecraft.Client/Polygon.cpp b/Minecraft.Client/Polygon.cpp index 00176511f..05cf9b077 100644 --- a/Minecraft.Client/Polygon.cpp +++ b/Minecraft.Client/Polygon.cpp @@ -58,17 +58,17 @@ void _Polygon::render(Tesselator *t, float scale) t->begin(); if (_flipNormal) { - t->normal(-(float)n->x, -(float)n->y, -(float)n->z); + t->normal(-static_cast(n->x), -static_cast(n->y), -static_cast(n->z)); } else { - t->normal((float)n->x, (float)n->y, (float)n->z); + t->normal(static_cast(n->x), static_cast(n->y), static_cast(n->z)); } for (int i = 0; i < 4; i++) { Vertex *v = vertices[i]; - t->vertexUV((float)(v->pos->x * scale), (float)( v->pos->y * scale), (float)( v->pos->z * scale), (float)( v->u), (float)( v->v)); + t->vertexUV(static_cast(v->pos->x * scale), static_cast(v->pos->y * scale), static_cast(v->pos->z * scale), (float)( v->u), (float)( v->v)); } t->end(); } diff --git a/Minecraft.Client/PreStitchedTextureMap.cpp b/Minecraft.Client/PreStitchedTextureMap.cpp index eeccb6285..5a98b3462 100644 --- a/Minecraft.Client/PreStitchedTextureMap.cpp +++ b/Minecraft.Client/PreStitchedTextureMap.cpp @@ -30,7 +30,7 @@ PreStitchedTextureMap::PreStitchedTextureMap(int type, const wstring &name, cons stitchResult = NULL; m_mipMap = mipmap; - missingPosition = (StitchedTexture *)(new SimpleIcon(NAME_MISSING_TEXTURE,NAME_MISSING_TEXTURE,0,0,1,1)); + missingPosition = static_cast(new SimpleIcon(NAME_MISSING_TEXTURE, NAME_MISSING_TEXTURE, 0, 0, 1, 1)); } void PreStitchedTextureMap::stitch() diff --git a/Minecraft.Client/QuadrupedModel.cpp b/Minecraft.Client/QuadrupedModel.cpp index ea0419104..23d1758b4 100644 --- a/Minecraft.Client/QuadrupedModel.cpp +++ b/Minecraft.Client/QuadrupedModel.cpp @@ -10,27 +10,27 @@ QuadrupedModel::QuadrupedModel(int legSize, float g) : Model() head = new ModelPart(this, 0, 0); head->addBox(-4, -4, -8, 8, 8, 8, g); // Head - head->setPos(0, (float)(12 + 6 - legSize), -6); + head->setPos(0, static_cast(12 + 6 - legSize), -6); body = new ModelPart(this, 28, 8); body->addBox(-5, -10, -7, 10, 16, 8, g); // Body - body->setPos(0, (float)(11 + 6 - legSize), 2); + body->setPos(0, static_cast(11 + 6 - legSize), 2); leg0 = new ModelPart(this, 0, 16); leg0->addBox(-2, 0, -2, 4, legSize, 4, g); // Leg0 - leg0->setPos(-3, (float)(18 + 6 - legSize), 7); + leg0->setPos(-3, static_cast(18 + 6 - legSize), 7); leg1 = new ModelPart(this, 0, 16); leg1->addBox(-2, 0, -2, 4, legSize, 4, g); // Leg1 - leg1->setPos(3, (float)(18 + 6 - legSize), 7); + leg1->setPos(3, static_cast(18 + 6 - legSize), 7); leg2 = new ModelPart(this, 0, 16); leg2->addBox(-2, 0, -2, 4, legSize, 4, g); // Leg2 - leg2->setPos(-3, (float)(18 + 6 - legSize), -5); + leg2->setPos(-3, static_cast(18 + 6 - legSize), -5); leg3 = new ModelPart(this, 0, 16); leg3->addBox(-2, 0, -2, 4, legSize, 4, g); // Leg3 - leg3->setPos(3, (float)(18 + 6 - legSize), -5); + leg3->setPos(3, static_cast(18 + 6 - legSize), -5); // 4J added - compile now to avoid random performance hit first time cubes are rendered head->compile(1.0f/16.0f); diff --git a/Minecraft.Client/RedDustParticle.cpp b/Minecraft.Client/RedDustParticle.cpp index 6a6ad1e1b..69eb225a0 100644 --- a/Minecraft.Client/RedDustParticle.cpp +++ b/Minecraft.Client/RedDustParticle.cpp @@ -14,16 +14,16 @@ void RedDustParticle::init(Level *level, double x, double y, double z, float sca { rCol = 1; } - float brr = (float) Math::random() * 0.4f + 0.6f; - this->rCol = ((float) (Math::random() * 0.2f) + 0.8f) * rCol * brr; - this->gCol = ((float) (Math::random() * 0.2f) + 0.8f) * gCol * brr; - this->bCol = ((float) (Math::random() * 0.2f) + 0.8f) * bCol * brr; + float brr = static_cast(Math::random()) * 0.4f + 0.6f; + this->rCol = (static_cast(Math::random() * 0.2f) + 0.8f) * rCol * brr; + this->gCol = (static_cast(Math::random() * 0.2f) + 0.8f) * gCol * brr; + this->bCol = (static_cast(Math::random() * 0.2f) + 0.8f) * bCol * brr; size *= 0.75f; size *= scale; oSize = size; - lifetime = (int) (8 / (Math::random() * 0.8 + 0.2)); - lifetime = (int)(lifetime * scale); + lifetime = static_cast(8 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(lifetime * scale); noPhysics = false; } diff --git a/Minecraft.Client/RemotePlayer.cpp b/Minecraft.Client/RemotePlayer.cpp index bea128428..ea946db02 100644 --- a/Minecraft.Client/RemotePlayer.cpp +++ b/Minecraft.Client/RemotePlayer.cpp @@ -103,8 +103,8 @@ void RemotePlayer::aiStep() while (yrd >= 180) yrd -= 360; - yRot += (float)((yrd) / lSteps); - xRot += (float)((lxr - xRot) / lSteps); + yRot += static_cast((yrd) / lSteps); + xRot += static_cast((lxr - xRot) / lSteps); lSteps--; setPos(xt, yt, zt); @@ -113,7 +113,7 @@ void RemotePlayer::aiStep() oBob = bob; float tBob = (float) Mth::sqrt(xd * xd + zd * zd); - float tTilt = (float) atan(-yd * 0.2f) * 15.0f; + float tTilt = static_cast(atan(-yd * 0.2f)) * 15.0f; if (tBob > 0.1f) tBob = 0.1f; if (!onGround || getHealth() <= 0) tBob = 0; if (onGround || getHealth() <= 0) tTilt = 0; diff --git a/Minecraft.Client/ResourceLocation.h b/Minecraft.Client/ResourceLocation.h index f53c46c87..1274b25ab 100644 --- a/Minecraft.Client/ResourceLocation.h +++ b/Minecraft.Client/ResourceLocation.h @@ -34,7 +34,7 @@ class ResourceLocation m_texture = textureNameArray(textures.length); for(unsigned int i = 0; i < textures.length; ++i) { - m_texture[i] = (_TEXTURE_NAME)textures[i]; + m_texture[i] = static_cast<_TEXTURE_NAME>(textures[i]); } m_preloaded = true; } diff --git a/Minecraft.Client/Screen.cpp b/Minecraft.Client/Screen.cpp index 131cf0134..3e632f0b6 100644 --- a/Minecraft.Client/Screen.cpp +++ b/Minecraft.Client/Screen.cpp @@ -140,10 +140,10 @@ void Screen::updateEvents() else if (vk == VK_TAB) mappedKey = Keyboard::KEY_TAB; else if (vk >= 'A' && vk <= 'Z') { - ch = (wchar_t)(vk - 'A' + L'a'); - if (g_KBMInput.IsKeyDown(VK_LSHIFT) || g_KBMInput.IsKeyDown(VK_RSHIFT)) ch = (wchar_t)vk; + ch = static_cast(vk - 'A' + L'a'); + if (g_KBMInput.IsKeyDown(VK_LSHIFT) || g_KBMInput.IsKeyDown(VK_RSHIFT)) ch = static_cast(vk); } - else if (vk >= '0' && vk <= '9') ch = (wchar_t)vk; + else if (vk >= '0' && vk <= '9') ch = static_cast(vk); else if (vk == VK_SPACE) ch = L' '; if (mappedKey != -1) keyPressed(ch, mappedKey); diff --git a/Minecraft.Client/ScreenSizeCalculator.cpp b/Minecraft.Client/ScreenSizeCalculator.cpp index 32e942a79..38aa75a83 100644 --- a/Minecraft.Client/ScreenSizeCalculator.cpp +++ b/Minecraft.Client/ScreenSizeCalculator.cpp @@ -21,10 +21,10 @@ ScreenSizeCalculator::ScreenSizeCalculator(Options *options, int width, int heig { scale = forceScale; } - rawWidth = w / (double) scale; - rawHeight = h / (double) scale; - w = (int) ceil(rawWidth); - h = (int) ceil(rawHeight); + rawWidth = w / static_cast(scale); + rawHeight = h / static_cast(scale); + w = static_cast(ceil(rawWidth)); + h = static_cast(ceil(rawHeight)); } int ScreenSizeCalculator::getWidth() diff --git a/Minecraft.Client/ScrolledSelectionList.cpp b/Minecraft.Client/ScrolledSelectionList.cpp index 9b7367ce0..953695ab9 100644 --- a/Minecraft.Client/ScrolledSelectionList.cpp +++ b/Minecraft.Client/ScrolledSelectionList.cpp @@ -72,7 +72,7 @@ void ScrolledSelectionList::renderDecorations(int mouseX, int mouseY) int x0 = width / 2 - (92 + 16 + 2); int x1 = width / 2 + (92 + 16 + 2); - int clickSlotPos = (y - y0 - headerHeight + (int) yo - 4); + int clickSlotPos = (y - y0 - headerHeight + static_cast(yo) - 4); int slot = clickSlotPos / itemHeight; if (x >= x0 && x <= x1 && slot >= 0 && clickSlotPos >= 0 && slot < getNumberOfItems()) { @@ -92,7 +92,7 @@ void ScrolledSelectionList::capYPosition() int max = getMaxPosition() - (y1 - y0 - 4); if (max < 0) max /= 2; if (yo < 0) yo = 0; - if (yo > max) yo = (float)max; + if (yo > max) yo = static_cast(max); } void ScrolledSelectionList::buttonClicked(Button *button) diff --git a/Minecraft.Client/SelectWorldScreen.cpp b/Minecraft.Client/SelectWorldScreen.cpp index 0481f1e53..75ccc268c 100644 --- a/Minecraft.Client/SelectWorldScreen.cpp +++ b/Minecraft.Client/SelectWorldScreen.cpp @@ -235,7 +235,7 @@ SelectWorldScreen::WorldSelectionList::WorldSelectionList(SelectWorldScreen *sws int SelectWorldScreen::WorldSelectionList::getNumberOfItems() { - return (int)this->parent->levelList->size(); + return static_cast(this->parent->levelList->size()); } void SelectWorldScreen::WorldSelectionList::selectItem(int item, bool doubleClick) @@ -259,7 +259,7 @@ bool SelectWorldScreen::WorldSelectionList::isSelectedItem(int item) int SelectWorldScreen::WorldSelectionList::getMaxPosition() { - return (int)parent->levelList->size() * 36; + return static_cast(parent->levelList->size()) * 36; } void SelectWorldScreen::WorldSelectionList::renderBackground() diff --git a/Minecraft.Client/ServerChunkCache.cpp b/Minecraft.Client/ServerChunkCache.cpp index 3af98ca66..2f79c6caa 100644 --- a/Minecraft.Client/ServerChunkCache.cpp +++ b/Minecraft.Client/ServerChunkCache.cpp @@ -995,7 +995,7 @@ void ServerChunkCache::recreateLogicStructuresForChunk(int chunkX, int chunkZ) int ServerChunkCache::runSaveThreadProc(LPVOID lpParam) { - SaveThreadData *params = (SaveThreadData *)lpParam; + SaveThreadData *params = static_cast(lpParam); if(params->useSharedThreadStorage) { diff --git a/Minecraft.Client/ServerLevel.cpp b/Minecraft.Client/ServerLevel.cpp index 1e00b591f..265a1428c 100644 --- a/Minecraft.Client/ServerLevel.cpp +++ b/Minecraft.Client/ServerLevel.cpp @@ -315,7 +315,7 @@ Biome::MobSpawnerData *ServerLevel::getRandomMobSpawnAt(MobCategory *mobCategory vector *mobList = getChunkSource()->getMobsAt(mobCategory, x, y, z); if (mobList == NULL || mobList->empty()) return NULL; - return (Biome::MobSpawnerData *) WeighedRandom::getRandomItem(random, (vector *)mobList); + return static_cast(WeighedRandom::getRandomItem(random, (vector *)mobList)); } void ServerLevel::updateSleepingPlayerList() @@ -640,8 +640,8 @@ void ServerLevel::resetEmptyTime() bool ServerLevel::tickPendingTicks(bool force) { EnterCriticalSection(&m_tickNextTickCS); - int count = (int)tickNextTickList.size(); - int count2 = (int)tickNextTickSet.size(); + int count = static_cast(tickNextTickList.size()); + int count2 = static_cast(tickNextTickSet.size()); if (count != tickNextTickSet.size()) { // TODO 4J Stu - Add new exception types @@ -685,8 +685,8 @@ bool ServerLevel::tickPendingTicks(bool force) toBeTicked.clear(); - int count3 = (int)tickNextTickList.size(); - int count4 = (int)tickNextTickSet.size(); + int count3 = static_cast(tickNextTickList.size()); + int count4 = static_cast(tickNextTickSet.size()); bool retval = tickNextTickList.size() != 0; LeaveCriticalSection(&m_tickNextTickCS); @@ -1024,7 +1024,7 @@ void ServerLevel::saveToDisc(ProgressListener *progressListener, bool autosave) if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + DLCTexturePack *pDLCTexPack=static_cast(tPack); DLCPack * pDLCPack=pDLCTexPack->getDLCInfoParentPack(); @@ -1268,7 +1268,7 @@ void ServerLevel::sendParticles(const wstring &name, double x, double y, double void ServerLevel::sendParticles(const wstring &name, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed) { - shared_ptr packet = std::make_shared( name, (float) x, (float) y, (float) z, (float) xDist, (float) yDist, (float) zDist, (float) speed, count ); + shared_ptr packet = std::make_shared( name, static_cast(x), static_cast(y), static_cast(z), static_cast(xDist), static_cast(yDist), static_cast(zDist), static_cast(speed), count ); for(auto& it : players) { diff --git a/Minecraft.Client/ServerLevelListener.cpp b/Minecraft.Client/ServerLevelListener.cpp index c191b1a95..3884b4696 100644 --- a/Minecraft.Client/ServerLevelListener.cpp +++ b/Minecraft.Client/ServerLevelListener.cpp @@ -117,9 +117,9 @@ void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int p for(auto& p : server->getPlayers()->players) { if (p == nullptr || p->level != level || p->entityId == id) continue; - double xd = (double) x - p->x; - double yd = (double) y - p->y; - double zd = (double) z - p->z; + double xd = static_cast(x) - p->x; + double yd = static_cast(y) - p->y; + double zd = static_cast(z) - p->z; if (xd * xd + yd * yd + zd * zd < 32 * 32) { diff --git a/Minecraft.Client/ServerPlayer.cpp b/Minecraft.Client/ServerPlayer.cpp index 76332358c..898e4a66f 100644 --- a/Minecraft.Client/ServerPlayer.cpp +++ b/Minecraft.Client/ServerPlayer.cpp @@ -1087,7 +1087,7 @@ bool ServerPlayer::openTrading(shared_ptr traderTarget, const wstring containerMenu = new MerchantMenu(inventory, traderTarget, level); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); - shared_ptr container = ((MerchantMenu *) containerMenu)->getTradeContainer(); + shared_ptr container = static_cast(containerMenu)->getTradeContainer(); connection->send(shared_ptr(new ContainerOpenPacket(containerCounter, ContainerOpenPacket::TRADER_NPC, name.empty()?L"":name, container->getContainerSize(), !name.empty()))); @@ -1559,7 +1559,7 @@ void ServerPlayer::onUpdateAbilities() ServerLevel *ServerPlayer::getLevel() { - return (ServerLevel *) level; + return static_cast(level); } void ServerPlayer::setGameMode(GameType *mode) diff --git a/Minecraft.Client/ServerPlayerGameMode.cpp b/Minecraft.Client/ServerPlayerGameMode.cpp index 2e6bca35e..4495c4da8 100644 --- a/Minecraft.Client/ServerPlayerGameMode.cpp +++ b/Minecraft.Client/ServerPlayerGameMode.cpp @@ -86,7 +86,7 @@ void ServerPlayerGameMode::tick() { Tile *tile = Tile::tiles[t]; float destroyProgress = tile->getDestroyProgress(player, player->level, delayedDestroyX, delayedDestroyY, delayedDestroyZ) * (ticksSpentDestroying + 1); - int state = (int) (destroyProgress * 10); + int state = static_cast(destroyProgress * 10); if (state != lastSentState) { @@ -115,7 +115,7 @@ void ServerPlayerGameMode::tick() { int ticksSpentDestroying = gameTicks - destroyProgressStart; float destroyProgress = tile->getDestroyProgress(player, player->level, xDestroyBlock, yDestroyBlock, zDestroyBlock) * (ticksSpentDestroying + 1); - int state = (int) (destroyProgress * 10); + int state = static_cast(destroyProgress * 10); if (state != lastSentState) { @@ -166,7 +166,7 @@ void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) xDestroyBlock = x; yDestroyBlock = y; zDestroyBlock = z; - int state = (int) (progress * 10); + int state = static_cast(progress * 10); level->destroyTileProgress(player->entityId, x, y, z, state); lastSentState = state; } diff --git a/Minecraft.Client/Settings.cpp b/Minecraft.Client/Settings.cpp index 658d641db..ca0520f4e 100644 --- a/Minecraft.Client/Settings.cpp +++ b/Minecraft.Client/Settings.cpp @@ -40,9 +40,9 @@ Settings::Settings(File *file) line.erase(line.size() - 1); if (line.size() >= 3 && - (unsigned char)line[0] == 0xEF && - (unsigned char)line[1] == 0xBB && - (unsigned char)line[2] == 0xBF) + static_cast(line[0]) == 0xEF && + static_cast(line[1]) == 0xBB && + static_cast(line[2]) == 0xBF) { line.erase(0, 3); } diff --git a/Minecraft.Client/SheepRenderer.cpp b/Minecraft.Client/SheepRenderer.cpp index 5a3580bce..434505781 100644 --- a/Minecraft.Client/SheepRenderer.cpp +++ b/Minecraft.Client/SheepRenderer.cpp @@ -30,7 +30,7 @@ int SheepRenderer::prepareArmor(shared_ptr _sheep, int layer, floa int value = (sheep->tickCount / colorDuration) + sheep->entityId; int c1 = value % Sheep::COLOR_LENGTH; int c2 = (value + 1) % Sheep::COLOR_LENGTH; - float subStep = ((sheep->tickCount % colorDuration) + a) / (float) colorDuration; + float subStep = ((sheep->tickCount % colorDuration) + a) / static_cast(colorDuration); glColor3f(Sheep::COLOR[c1][0] * (1.0f - subStep) + Sheep::COLOR[c2][0] * subStep, Sheep::COLOR[c1][1] * (1.0f - subStep) + Sheep::COLOR[c2][1] * subStep, Sheep::COLOR[c1][2] * (1.0f - subStep) + Sheep::COLOR[c2][2] * subStep); diff --git a/Minecraft.Client/SignRenderer.cpp b/Minecraft.Client/SignRenderer.cpp index 5f764a92a..3f0b21757 100644 --- a/Minecraft.Client/SignRenderer.cpp +++ b/Minecraft.Client/SignRenderer.cpp @@ -25,7 +25,7 @@ void SignRenderer::render(shared_ptr _sign, double x, double y, doub float size = 16 / 24.0f; if (tile == Tile::sign) { - glTranslatef((float) x + 0.5f, (float) y + 0.75f * size, (float) z + 0.5f); + glTranslatef(static_cast(x) + 0.5f, static_cast(y) + 0.75f * size, static_cast(z) + 0.5f); float rot = sign->getData() * 360 / 16.0f; glRotatef(-rot, 0, 1, 0); signModel->cube2->visible = true; @@ -39,7 +39,7 @@ void SignRenderer::render(shared_ptr _sign, double x, double y, doub if (face == 4) rot = 90; if (face == 5) rot = -90; - glTranslatef((float) x + 0.5f, (float) y + 0.75f * size, (float) z + 0.5f); + glTranslatef(static_cast(x) + 0.5f, static_cast(y) + 0.75f * size, static_cast(z) + 0.5f); glRotatef(-rot, 0, 1, 0); glTranslatef(0, -5 / 16.0f, -7 / 16.0f); diff --git a/Minecraft.Client/SilverfishModel.cpp b/Minecraft.Client/SilverfishModel.cpp index ce8b8254a..7058d1870 100644 --- a/Minecraft.Client/SilverfishModel.cpp +++ b/Minecraft.Client/SilverfishModel.cpp @@ -48,7 +48,7 @@ SilverfishModel::SilverfishModel() { bodyParts[i] = new ModelPart(this, BODY_TEXS[i][0], BODY_TEXS[i][1]); bodyParts[i]->addBox(BODY_SIZES[i][0] * -0.5f, 0, BODY_SIZES[i][2] * -0.5f, BODY_SIZES[i][0], BODY_SIZES[i][1], BODY_SIZES[i][2]); - bodyParts[i]->setPos(0.0f, 24.0f - (float)BODY_SIZES[i][1], placement); + bodyParts[i]->setPos(0.0f, 24.0f - static_cast(BODY_SIZES[i][1]), placement); zPlacement[i] = placement; if (i < bodyParts.length - 1) { @@ -100,8 +100,8 @@ void SilverfishModel::setupAnim(float time, float r, float bob, float yRot, floa { for (unsigned int i = 0; i < bodyParts.length; i++) { - bodyParts[i]->yRot = Mth::cos(bob * .9f + i * .15f * PI) * PI * .05f * (1 + abs((int)i - 2)); - bodyParts[i]->x = Mth::sin(bob * .9f + i * .15f * PI) * PI * .2f * abs((int)i - 2); + bodyParts[i]->yRot = Mth::cos(bob * .9f + i * .15f * PI) * PI * .05f * (1 + abs(static_cast(i) - 2)); + bodyParts[i]->x = Mth::sin(bob * .9f + i * .15f * PI) * PI * .2f * abs(static_cast(i) - 2); } bodyLayers[0]->yRot = bodyParts[2]->yRot; diff --git a/Minecraft.Client/SkullTileRenderer.cpp b/Minecraft.Client/SkullTileRenderer.cpp index 32d216cd6..e7b610bf1 100644 --- a/Minecraft.Client/SkullTileRenderer.cpp +++ b/Minecraft.Client/SkullTileRenderer.cpp @@ -28,7 +28,7 @@ SkullTileRenderer::~SkullTileRenderer() void SkullTileRenderer::render(shared_ptr _skull, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) { shared_ptr skull = dynamic_pointer_cast(_skull); - renderSkull((float) x, (float) y, (float) z, skull->getData() & SkullTile::PLACEMENT_MASK, skull->getRotation() * 360 / 16.0f, skull->getSkullType(), skull->getExtraType()); + renderSkull(static_cast(x), static_cast(y), static_cast(z), skull->getData() & SkullTile::PLACEMENT_MASK, skull->getRotation() * 360 / 16.0f, skull->getSkullType(), skull->getExtraType()); } void SkullTileRenderer::init(TileEntityRenderDispatcher *tileEntityRenderDispatcher) diff --git a/Minecraft.Client/SlideButton.cpp b/Minecraft.Client/SlideButton.cpp index 0da24515a..0c7735af6 100644 --- a/Minecraft.Client/SlideButton.cpp +++ b/Minecraft.Client/SlideButton.cpp @@ -18,22 +18,22 @@ void SlideButton::renderBg(Minecraft *minecraft, int xm, int ym) if (!visible) return; if (sliding) { - value = (xm - (x + 4)) / (float) (w - 8); + value = (xm - (x + 4)) / static_cast(w - 8); if (value < 0) value = 0; if (value > 1) value = 1; minecraft->options->set(option, value); msg = minecraft->options->getMessage(option); } glColor4f(1, 1, 1, 1); - blit(x + (int) (value * (w - 8)), y, 0, 46 + 1 * 20, 4, 20); - blit(x + (int) (value * (w - 8)) + 4, y, 196, 46 + 1 * 20, 4, 20); + blit(x + static_cast(value * (w - 8)), y, 0, 46 + 1 * 20, 4, 20); + blit(x + static_cast(value * (w - 8)) + 4, y, 196, 46 + 1 * 20, 4, 20); } bool SlideButton::clicked(Minecraft *minecraft, int mx, int my) { if (Button::clicked(minecraft, mx, my)) { - value = (mx - (x + 4)) / (float) (w - 8); + value = (mx - (x + 4)) / static_cast(w - 8); if (value < 0) value = 0; if (value > 1) value = 1; minecraft->options->set(option, value); diff --git a/Minecraft.Client/SlimeRenderer.cpp b/Minecraft.Client/SlimeRenderer.cpp index f3f64aed4..ca5e51916 100644 --- a/Minecraft.Client/SlimeRenderer.cpp +++ b/Minecraft.Client/SlimeRenderer.cpp @@ -41,7 +41,7 @@ void SlimeRenderer::scale(shared_ptr _slime, float a) // 4J - dynamic cast required because we aren't using templates/generics in our version shared_ptr slime = dynamic_pointer_cast(_slime); - float size = (float) slime->getSize(); + float size = static_cast(slime->getSize()); float ss = (slime->oSquish + (slime->squish - slime->oSquish) * a) / (size * 0.5f + 1); float w = 1 / (ss + 1); glScalef(w * size, 1 / w * size, w * size); diff --git a/Minecraft.Client/SmokeParticle.cpp b/Minecraft.Client/SmokeParticle.cpp index a88558851..b48978f09 100644 --- a/Minecraft.Client/SmokeParticle.cpp +++ b/Minecraft.Client/SmokeParticle.cpp @@ -26,8 +26,8 @@ void SmokeParticle::init(Level *level, double x, double y, double z, double xa, size *= scale; oSize = size; - lifetime = (int) (8 / (Math::random() * 0.8 + 0.2)); - lifetime = (int) (lifetime * scale); + lifetime = static_cast(8 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(lifetime * scale); noPhysics = false; } diff --git a/Minecraft.Client/SnowManRenderer.cpp b/Minecraft.Client/SnowManRenderer.cpp index 1e258f3c6..11855fe37 100644 --- a/Minecraft.Client/SnowManRenderer.cpp +++ b/Minecraft.Client/SnowManRenderer.cpp @@ -11,7 +11,7 @@ ResourceLocation SnowManRenderer::SNOWMAN_LOCATION = ResourceLocation(TN_MOB_SNO SnowManRenderer::SnowManRenderer() : MobRenderer(new SnowManModel(), 0.5f) { - model = (SnowManModel *) MobRenderer::model; + model = static_cast(MobRenderer::model); this->setArmor(model); } diff --git a/Minecraft.Client/SnowShovelParticle.cpp b/Minecraft.Client/SnowShovelParticle.cpp index 4417cb5d8..cf63a7309 100644 --- a/Minecraft.Client/SnowShovelParticle.cpp +++ b/Minecraft.Client/SnowShovelParticle.cpp @@ -11,13 +11,13 @@ void SnowShovelParticle::init(Level *level, double x, double y, double z, double yd += ya; zd += za; - rCol = gCol = bCol = 1 - (float) (Math::random() * 0.3f); + rCol = gCol = bCol = 1 - static_cast(Math::random() * 0.3f); size *= 0.75f; size *= scale; oSize = size; - lifetime = (int) (8 / (Math::random() * 0.8 + 0.2)); - lifetime = (int) ( lifetime * scale ); + lifetime = static_cast(8 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(lifetime * scale); noPhysics = false; } diff --git a/Minecraft.Client/SpellParticle.cpp b/Minecraft.Client/SpellParticle.cpp index ce8b975f1..cd0797ace 100644 --- a/Minecraft.Client/SpellParticle.cpp +++ b/Minecraft.Client/SpellParticle.cpp @@ -13,7 +13,7 @@ SpellParticle::SpellParticle(Level *level, double x, double y, double z, double size *= 0.75f; - lifetime = (int) (8 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(8 / (Math::random() * 0.8 + 0.2)); noPhysics = false; baseTex = 8 * 16; diff --git a/Minecraft.Client/SpiderModel.cpp b/Minecraft.Client/SpiderModel.cpp index 739677e43..0cdc14cae 100644 --- a/Minecraft.Client/SpiderModel.cpp +++ b/Minecraft.Client/SpiderModel.cpp @@ -11,48 +11,48 @@ SpiderModel::SpiderModel() : Model() head = new ModelPart(this, 32, 4); head->addBox(-4, -4, -8, 8, 8, 8, g); // Head - head->setPos(0, (float)(0+yo), -3); + head->setPos(0, static_cast(0 + yo), -3); body0 = new ModelPart(this, 0, 0); body0->addBox(-3, -3, -3, 6, 6, 6, g); // Body - body0->setPos(0,(float)(yo), 0); + body0->setPos(0,static_cast(yo), 0); body1 = new ModelPart(this, 0, 12); body1->addBox(-5, -4, -6, 10, 8, 12, g); // Body - body1->setPos(0, (float)(0+yo), 3 + 6); + body1->setPos(0, static_cast(0 + yo), 3 + 6); leg0 = new ModelPart(this, 18, 0); leg0->addBox(-15, -1, -1, 16, 2, 2, g); // Leg0 - leg0->setPos(-4, (float)(0+yo), 2); + leg0->setPos(-4, static_cast(0 + yo), 2); leg1 = new ModelPart(this, 18, 0); leg1->addBox(-1, -1, -1, 16, 2, 2, g); // Leg1 - leg1->setPos(4, (float)(0+yo), 2); + leg1->setPos(4, static_cast(0 + yo), 2); leg2 = new ModelPart(this, 18, 0); leg2->addBox(-15, -1, -1, 16, 2, 2, g); // Leg2 - leg2->setPos(-4, (float)(0+yo), 1); + leg2->setPos(-4, static_cast(0 + yo), 1); leg3 = new ModelPart(this, 18, 0); leg3->addBox(-1, -1, -1, 16, 2, 2, g); // Leg3 - leg3->setPos(4, (float)(0+yo), 1); + leg3->setPos(4, static_cast(0 + yo), 1); leg4 = new ModelPart(this, 18, 0); leg4->addBox(-15, -1, -1, 16, 2, 2, g); // Leg0 - leg4->setPos(-4, (float)(0+yo), 0); + leg4->setPos(-4, static_cast(0 + yo), 0); leg5 = new ModelPart(this, 18, 0); leg5->addBox(-1, -1, -1, 16, 2, 2, g); // Leg1 - leg5->setPos(4, (float)(0+yo), 0); + leg5->setPos(4, static_cast(0 + yo), 0); leg6 = new ModelPart(this, 18, 0); leg6->addBox(-15, -1, -1, 16, 2, 2, g); // Leg2 - leg6->setPos(-4, (float)(0+yo), -1); + leg6->setPos(-4, static_cast(0 + yo), -1); leg7 = new ModelPart(this, 18, 0); leg7->addBox(-1, -1, -1, 16, 2, 2, g); // Leg3 - leg7->setPos(4, (float)(0+yo), -1); + leg7->setPos(4, static_cast(0 + yo), -1); // 4J added - compile now to avoid random performance hit first time cubes are rendered head->compile(1.0f/16.0f); diff --git a/Minecraft.Client/SquidModel.cpp b/Minecraft.Client/SquidModel.cpp index 0152418f2..0ee2501d6 100644 --- a/Minecraft.Client/SquidModel.cpp +++ b/Minecraft.Client/SquidModel.cpp @@ -14,17 +14,17 @@ SquidModel::SquidModel() : Model() { tentacles[i] = new ModelPart(this, 48, 0); - double angle = i * PI * 2.0 / (double) TENTACLES_LENGTH; // 4J - 8 was tentacles.length - float xo = Mth::cos((float)angle) * 5; - float yo = Mth::sin((float)angle) * 5; + double angle = i * PI * 2.0 / static_cast(TENTACLES_LENGTH); // 4J - 8 was tentacles.length + float xo = Mth::cos(static_cast(angle)) * 5; + float yo = Mth::sin(static_cast(angle)) * 5; tentacles[i]->addBox(-1, 0, -1, 2, 18, 2); tentacles[i]->x = xo; tentacles[i]->z = yo; - tentacles[i]->y = (float)(31 + yoffs); + tentacles[i]->y = static_cast(31 + yoffs); - angle = i * PI * -2.0 / (double) TENTACLES_LENGTH + PI * .5; // 4J - 8 was tentacles.length - tentacles[i]->yRot = (float) angle; + angle = i * PI * -2.0 / static_cast(TENTACLES_LENGTH) + PI * .5; // 4J - 8 was tentacles.length + tentacles[i]->yRot = static_cast(angle); // 4J added - compile now to avoid random performance hit first time cubes are rendered tentacles[i]->compile(1.0f/16.0f); diff --git a/Minecraft.Client/StatsCounter.cpp b/Minecraft.Client/StatsCounter.cpp index b75625e9d..8f930fcf9 100644 --- a/Minecraft.Client/StatsCounter.cpp +++ b/Minecraft.Client/StatsCounter.cpp @@ -142,7 +142,7 @@ void StatsCounter::parse(void* data) assert( stats.size() == 0 ); //Pointer to current position in stat array - PBYTE pbData=(PBYTE)data; + PBYTE pbData=static_cast(data); pbData+=sizeof(GAME_SETTINGS); unsigned short* statData = (unsigned short*)pbData;//data + (STAT_DATA_OFFSET/sizeof(unsigned short)); @@ -217,7 +217,7 @@ void StatsCounter::save(int player, bool force) #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ ) PBYTE pbData = (PBYTE)StorageManager.GetGameDefinedProfileData(player); #else - PBYTE pbData = (PBYTE)ProfileManager.GetGameDefinedProfileData(player); + PBYTE pbData = static_cast(ProfileManager.GetGameDefinedProfileData(player)); #endif pbData+=sizeof(GAME_SETTINGS); diff --git a/Minecraft.Client/StatsScreen.cpp b/Minecraft.Client/StatsScreen.cpp index 01d041f0e..6c42532db 100644 --- a/Minecraft.Client/StatsScreen.cpp +++ b/Minecraft.Client/StatsScreen.cpp @@ -107,7 +107,7 @@ StatsScreen::GeneralStatisticsList::GeneralStatisticsList(StatsScreen *ss) : Scr int StatsScreen::GeneralStatisticsList::getNumberOfItems() { - return (int)Stats::generalStats->size(); + return static_cast(Stats::generalStats->size()); } void StatsScreen::GeneralStatisticsList::selectItem(int item, bool doubleClick) @@ -293,7 +293,7 @@ void StatsScreen::StatisticsList::clickedHeader(int headerMouseX, int headerMous int StatsScreen::StatisticsList::getNumberOfItems() { - return (int)statItemList.size(); + return static_cast(statItemList.size()); } ItemStat *StatsScreen::StatisticsList::getSlotStat(int slot) diff --git a/Minecraft.Client/StitchedTexture.cpp b/Minecraft.Client/StitchedTexture.cpp index 64ab2f365..29e3e4bd7 100644 --- a/Minecraft.Client/StitchedTexture.cpp +++ b/Minecraft.Client/StitchedTexture.cpp @@ -94,10 +94,10 @@ void StitchedTexture::init(Texture *source, vector *frames, int x, in float marginX = 0.0f; //0.01f / source->getWidth(); float marginY = 0.0f; //0.01f / source->getHeight(); - this->u0 = x / (float) source->getWidth() + marginX; - this->u1 = (x + width) / (float) source->getWidth() - marginX; - this->v0 = y / (float) source->getHeight() + marginY; - this->v1 = (y + height) / (float) source->getHeight() - marginY; + this->u0 = x / static_cast(source->getWidth()) + marginX; + this->u1 = (x + width) / static_cast(source->getWidth()) - marginX; + this->v0 = y / static_cast(source->getHeight()) + marginY; + this->v1 = (y + height) / static_cast(source->getHeight()) - marginY; #ifndef _CONTENT_PACKAGE bool addBreakpoint = false; @@ -112,8 +112,8 @@ void StitchedTexture::init(Texture *source, vector *frames, int x, in } #endif - this->widthTranslation = width / (float) SharedConstants::WORLD_RESOLUTION; - this->heightTranslation = height / (float) SharedConstants::WORLD_RESOLUTION; + this->widthTranslation = width / static_cast(SharedConstants::WORLD_RESOLUTION); + this->heightTranslation = height / static_cast(SharedConstants::WORLD_RESOLUTION); } void StitchedTexture::replaceWith(StitchedTexture *texture) @@ -156,7 +156,7 @@ float StitchedTexture::getU1(bool adjust/*=false*/) const float StitchedTexture::getU(double offset, bool adjust/*=false*/) const { float diff = getU1(adjust) - getU0(adjust); - return getU0(adjust) + (diff * ((float) offset / SharedConstants::WORLD_RESOLUTION)); + return getU0(adjust) + (diff * (static_cast(offset) / SharedConstants::WORLD_RESOLUTION)); } float StitchedTexture::getV0(bool adjust/*=false*/) const @@ -172,7 +172,7 @@ float StitchedTexture::getV1(bool adjust/*=false*/) const float StitchedTexture::getV(double offset, bool adjust/*=false*/) const { float diff = getV1(adjust) - getV0(adjust); - return getV0(adjust) + (diff * ((float) offset / SharedConstants::WORLD_RESOLUTION)); + return getV0(adjust) + (diff * (static_cast(offset) / SharedConstants::WORLD_RESOLUTION)); } wstring StitchedTexture::getName() const diff --git a/Minecraft.Client/SuspendedParticle.cpp b/Minecraft.Client/SuspendedParticle.cpp index 70702de0f..b7305207a 100644 --- a/Minecraft.Client/SuspendedParticle.cpp +++ b/Minecraft.Client/SuspendedParticle.cpp @@ -25,7 +25,7 @@ SuspendedParticle::SuspendedParticle(Level *level, double x, double y, double z, yd = ya * 0.0f; zd = za * 0.0f; - lifetime = (int) (16 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(16 / (Math::random() * 0.8 + 0.2)); } void SuspendedParticle::tick() diff --git a/Minecraft.Client/SuspendedTownParticle.cpp b/Minecraft.Client/SuspendedTownParticle.cpp index a24bbc42a..4c31b0c0b 100644 --- a/Minecraft.Client/SuspendedTownParticle.cpp +++ b/Minecraft.Client/SuspendedTownParticle.cpp @@ -18,7 +18,7 @@ SuspendedTownParticle::SuspendedTownParticle(Level *level, double x, double y, d yd *= 0.02f; zd *= 0.02f; - lifetime = (int) (20 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(20 / (Math::random() * 0.8 + 0.2)); this->noPhysics = true; } diff --git a/Minecraft.Client/TakeAnimationParticle.cpp b/Minecraft.Client/TakeAnimationParticle.cpp index c9530b0a0..f629363e1 100644 --- a/Minecraft.Client/TakeAnimationParticle.cpp +++ b/Minecraft.Client/TakeAnimationParticle.cpp @@ -64,7 +64,7 @@ void TakeAnimationParticle::render(Tesselator *t, float a, float xa, float ya, f zz-=zOff; - EntityRenderDispatcher::instance->render(item, (float)xx, (float)yy, (float)zz, item->yRot, a); + EntityRenderDispatcher::instance->render(item, static_cast(xx), static_cast(yy), static_cast(zz), item->yRot, a); } diff --git a/Minecraft.Client/TerrainParticle.cpp b/Minecraft.Client/TerrainParticle.cpp index 811ba840b..cec8df8fb 100644 --- a/Minecraft.Client/TerrainParticle.cpp +++ b/Minecraft.Client/TerrainParticle.cpp @@ -55,9 +55,9 @@ void TerrainParticle::render(Tesselator *t, float a, float xa, float ya, float z v1 = tex->getV(((vo + 1) / 4.0f) * SharedConstants::WORLD_RESOLUTION); } - float x = (float) (xo + (this->x - xo) * a - xOff); - float y = (float) (yo + (this->y - yo) * a - yOff); - float z = (float) (zo + (this->z - zo) * a - zOff); + float x = static_cast(xo + (this->x - xo) * a - xOff); + float y = static_cast(yo + (this->y - yo) * a - yOff); + float z = static_cast(zo + (this->z - zo) * a - zOff); // 4J - don't render terrain particles that are less than a metre away, to try and avoid large particles that are causing us problems with // photosensitivity testing diff --git a/Minecraft.Client/Tesselator.cpp b/Minecraft.Client/Tesselator.cpp index 7bae7aca9..b70ec983e 100644 --- a/Minecraft.Client/Tesselator.cpp +++ b/Minecraft.Client/Tesselator.cpp @@ -28,7 +28,7 @@ DWORD Tesselator::tlsIdx = TlsAlloc(); Tesselator *Tesselator::getInstance() { - return (Tesselator *)TlsGetValue(tlsIdx); + return static_cast(TlsGetValue(tlsIdx)); } void Tesselator::CreateNewThreadStorage(int bytes) @@ -179,18 +179,18 @@ void Tesselator::end() } #else - RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_COMPRESSED, C4JRender::PIXEL_SHADER_TYPE_STANDARD); + RenderManager.DrawVertices(static_cast(mode),vertexCount,_array->data,C4JRender::VERTEX_TYPE_COMPRESSED, C4JRender::PIXEL_SHADER_TYPE_STANDARD); #endif } else { if( useProjectedTexturePixelShader ) { - RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, C4JRender::PIXEL_SHADER_TYPE_PROJECTION); + RenderManager.DrawVertices(static_cast(mode),vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, C4JRender::PIXEL_SHADER_TYPE_PROJECTION); } else { - RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, C4JRender::PIXEL_SHADER_TYPE_STANDARD); + RenderManager.DrawVertices(static_cast(mode),vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, C4JRender::PIXEL_SHADER_TYPE_STANDARD); } } #endif @@ -295,12 +295,12 @@ void Tesselator::tex2(int tex2) void Tesselator::color(float r, float g, float b) { - color((int) (r * 255), (int) (g * 255), (int) (b * 255)); + color(static_cast(r * 255), static_cast(g * 255), static_cast(b * 255)); } void Tesselator::color(float r, float g, float b, float a) { - color((int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255)); + color(static_cast(r * 255), static_cast(g * 255), static_cast(b * 255), static_cast(a * 255)); } void Tesselator::color(int r, int g, int b) @@ -749,7 +749,7 @@ void Tesselator::vertex(float x, float y, float z) // see comments in packCompactQuad() for exact format if( useCompactFormat360 ) { - unsigned int ucol = (unsigned int)col; + unsigned int ucol = static_cast(col); #ifdef _XBOX // Pack as 4:4:4 RGB_ @@ -774,7 +774,7 @@ void Tesselator::vertex(float x, float y, float z) unsigned short packedcol = ((col & 0xf8000000 ) >> 16 ) | ((col & 0x00fc0000 ) >> 13 ) | ((col & 0x0000f800 ) >> 11 ); - int ipackedcol = ((int)packedcol) & 0xffff; // 0 to 65535 range + int ipackedcol = static_cast(packedcol) & 0xffff; // 0 to 65535 range ipackedcol -= 32768; // -32768 to 32767 range ipackedcol &= 0xffff; @@ -824,12 +824,12 @@ void Tesselator::vertex(float x, float y, float z) p += 4; #else - pShortData[0] = (((int)((x + xo ) * 1024.0f))&0xffff); - pShortData[1] = (((int)((y + yo ) * 1024.0f))&0xffff); - pShortData[2] = (((int)((z + zo ) * 1024.0f))&0xffff); + pShortData[0] = (static_cast((x + xo) * 1024.0f)&0xffff); + pShortData[1] = (static_cast((y + yo) * 1024.0f)&0xffff); + pShortData[2] = (static_cast((z + zo) * 1024.0f)&0xffff); pShortData[3] = ipackedcol; - pShortData[4] = (((int)(uu * 8192.0f))&0xffff); - pShortData[5] = (((int)(v * 8192.0f))&0xffff); + pShortData[4] = (static_cast(uu * 8192.0f)&0xffff); + pShortData[5] = (static_cast(v * 8192.0f)&0xffff); int16_t u2 = ((int16_t*)&_tex2)[0]; int16_t v2 = ((int16_t*)&_tex2)[1]; #if defined _XBOX_ONE || defined __ORBIS__ @@ -1040,9 +1040,9 @@ void Tesselator::normal(float x, float y, float z) int8_t zz = (int8_t) (z * 127); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); #else - byte xx = (byte) (x * 127); - byte yy = (byte) (y * 127); - byte zz = (byte) (z * 127); + byte xx = static_cast(x * 127); + byte yy = static_cast(y * 127); + byte zz = static_cast(z * 127); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); #endif } diff --git a/Minecraft.Client/TextEditScreen.cpp b/Minecraft.Client/TextEditScreen.cpp index 9537b969c..6b14ce5d1 100644 --- a/Minecraft.Client/TextEditScreen.cpp +++ b/Minecraft.Client/TextEditScreen.cpp @@ -82,7 +82,7 @@ void TextEditScreen::render(int xm, int ym, float a) drawCenteredString(font, title, width / 2, 40, 0xffffff); glPushMatrix(); - glTranslatef((float)width / 2, (float)height / 2, 50); + glTranslatef(static_cast(width) / 2, static_cast(height) / 2, 50); float ss = 60 / (16 / 25.0f); glScalef(-ss, -ss, -ss); glRotatef(180, 0, 1, 0); diff --git a/Minecraft.Client/Texture.cpp b/Minecraft.Client/Texture.cpp index 809f606aa..dd1804d7a 100644 --- a/Minecraft.Client/Texture.cpp +++ b/Minecraft.Client/Texture.cpp @@ -225,10 +225,10 @@ void Texture::fill(const Rect2i *rect, int color) int line = y * width * 4; for (int x = myRect->getX(); x < (myRect->getX() + myRect->getWidth()); x++) { - data[0]->put(line + x * 4 + 0, (BYTE)((color >> 24) & 0x000000ff)); - data[0]->put(line + x * 4 + 1, (BYTE)((color >> 16) & 0x000000ff)); - data[0]->put(line + x * 4 + 2, (BYTE)((color >> 8) & 0x000000ff)); - data[0]->put(line + x * 4 + 3, (BYTE)((color >> 0) & 0x000000ff)); + data[0]->put(line + x * 4 + 0, static_cast((color >> 24) & 0x000000ff)); + data[0]->put(line + x * 4 + 1, static_cast((color >> 16) & 0x000000ff)); + data[0]->put(line + x * 4 + 2, static_cast((color >> 8) & 0x000000ff)); + data[0]->put(line + x * 4 + 3, static_cast((color >> 0) & 0x000000ff)); } } delete myRect; @@ -530,10 +530,10 @@ void Texture::transferFromBuffer(intArray buffer) { int texel = column + x * 4; data[0]->position(0); - data[0]->put(texel + byteRemap[0], (byte)((buffer[texel >> 2] >> 24) & 0xff)); - data[0]->put(texel + byteRemap[1], (byte)((buffer[texel >> 2] >> 16) & 0xff)); - data[0]->put(texel + byteRemap[2], (byte)((buffer[texel >> 2] >> 8) & 0xff)); - data[0]->put(texel + byteRemap[3], (byte)((buffer[texel >> 2] >> 0) & 0xff)); + data[0]->put(texel + byteRemap[0], static_cast((buffer[texel >> 2] >> 24) & 0xff)); + data[0]->put(texel + byteRemap[1], static_cast((buffer[texel >> 2] >> 16) & 0xff)); + data[0]->put(texel + byteRemap[2], static_cast((buffer[texel >> 2] >> 8) & 0xff)); + data[0]->put(texel + byteRemap[3], static_cast((buffer[texel >> 2] >> 0) & 0xff)); } } } @@ -589,10 +589,10 @@ void Texture::transferFromImage(BufferedImage *image) // Pull ARGB bytes into either RGBA or BGRA depending on format - tempBytes[byteIndex + byteRemap[0]] = (byte)((tempPixels[intIndex] >> 24) & 0xff); - tempBytes[byteIndex + byteRemap[1]] = (byte)((tempPixels[intIndex] >> 16) & 0xff); - tempBytes[byteIndex + byteRemap[2]] = (byte)((tempPixels[intIndex] >> 8) & 0xff); - tempBytes[byteIndex + byteRemap[3]] = (byte)((tempPixels[intIndex] >> 0) & 0xff); + tempBytes[byteIndex + byteRemap[0]] = static_cast((tempPixels[intIndex] >> 24) & 0xff); + tempBytes[byteIndex + byteRemap[1]] = static_cast((tempPixels[intIndex] >> 16) & 0xff); + tempBytes[byteIndex + byteRemap[2]] = static_cast((tempPixels[intIndex] >> 8) & 0xff); + tempBytes[byteIndex + byteRemap[3]] = static_cast((tempPixels[intIndex] >> 0) & 0xff); } } @@ -641,10 +641,10 @@ void Texture::transferFromImage(BufferedImage *image) // Pull ARGB bytes into either RGBA or BGRA depending on format - tempBytes[byteIndex + byteRemap[0]] = (byte)((tempData[intIndex] >> 24) & 0xff); - tempBytes[byteIndex + byteRemap[1]] = (byte)((tempData[intIndex] >> 16) & 0xff); - tempBytes[byteIndex + byteRemap[2]] = (byte)((tempData[intIndex] >> 8) & 0xff); - tempBytes[byteIndex + byteRemap[3]] = (byte)((tempData[intIndex] >> 0) & 0xff); + tempBytes[byteIndex + byteRemap[0]] = static_cast((tempData[intIndex] >> 24) & 0xff); + tempBytes[byteIndex + byteRemap[1]] = static_cast((tempData[intIndex] >> 16) & 0xff); + tempBytes[byteIndex + byteRemap[2]] = static_cast((tempData[intIndex] >> 8) & 0xff); + tempBytes[byteIndex + byteRemap[3]] = static_cast((tempData[intIndex] >> 0) & 0xff); } } } @@ -676,10 +676,10 @@ void Texture::transferFromImage(BufferedImage *image) // Pull ARGB bytes into either RGBA or BGRA depending on format - tempBytes[byteIndex + byteRemap[0]] = (byte)((col >> 24) & 0xff); - tempBytes[byteIndex + byteRemap[1]] = (byte)((col >> 16) & 0xff); - tempBytes[byteIndex + byteRemap[2]] = (byte)((col >> 8) & 0xff); - tempBytes[byteIndex + byteRemap[3]] = (byte)((col >> 0) & 0xff); + tempBytes[byteIndex + byteRemap[0]] = static_cast((col >> 24) & 0xff); + tempBytes[byteIndex + byteRemap[1]] = static_cast((col >> 16) & 0xff); + tempBytes[byteIndex + byteRemap[2]] = static_cast((col >> 8) & 0xff); + tempBytes[byteIndex + byteRemap[3]] = static_cast((col >> 0) & 0xff); } } @@ -713,8 +713,8 @@ void Texture::transferFromImage(BufferedImage *image) // 4J Kept from older versions for where we create mip-maps for levels that do not have pre-made graphics int Texture::crispBlend(int c0, int c1) { - int a0 = (int) (((c0 & 0xff000000) >> 24)) & 0xff; - int a1 = (int) (((c1 & 0xff000000) >> 24)) & 0xff; + int a0 = static_cast(((c0 & 0xff000000) >> 24)) & 0xff; + int a1 = static_cast(((c1 & 0xff000000) >> 24)) & 0xff; int a = 255; if (a0 + a1 < 255) diff --git a/Minecraft.Client/TextureHolder.cpp b/Minecraft.Client/TextureHolder.cpp index 0f10272cf..11c8fb96b 100644 --- a/Minecraft.Client/TextureHolder.cpp +++ b/Minecraft.Client/TextureHolder.cpp @@ -22,12 +22,12 @@ Texture *TextureHolder::getTexture() int TextureHolder::getWidth() const { - return rotated ? smallestFittingMinTexel((int) (height * scale)) : smallestFittingMinTexel((int) (width * scale)); + return rotated ? smallestFittingMinTexel(static_cast(height * scale)) : smallestFittingMinTexel(static_cast(width * scale)); } int TextureHolder::getHeight() const { - return rotated ? smallestFittingMinTexel((int) (width * scale)) : smallestFittingMinTexel((int) (height * scale)); + return rotated ? smallestFittingMinTexel(static_cast(width * scale)) : smallestFittingMinTexel(static_cast(height * scale)); } void TextureHolder::rotate() @@ -52,7 +52,7 @@ void TextureHolder::setForcedScale(int targetSize) return; } - scale = (float) targetSize / min(width, height); + scale = static_cast(targetSize) / min(width, height); } //@Override diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index cd6e0bae1..e864a2f49 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -288,7 +288,7 @@ void Textures::loadIndexedTextures() // 4J - added - preload a set of commonly used textures that can then be referenced directly be an enumerated type rather by string for( int i = 0; i < TN_COUNT - 2; i++ ) { - preLoadedIdx[i] = loadTexture((TEXTURE_NAME)i, wstring(preLoaded[i]) + L".png"); + preLoadedIdx[i] = loadTexture(static_cast(i), wstring(preLoaded[i]) + L".png"); } } @@ -451,7 +451,7 @@ void Textures::bindTextureLayers(ResourceLocation *resource) for( int i = 0; i < layers; i++ ) { TEXTURE_NAME textureName = resource->getTexture(i); - if( textureName == (_TEXTURE_NAME)-1 ) + if( textureName == static_cast<_TEXTURE_NAME>(-1) ) { continue; } @@ -500,10 +500,10 @@ void Textures::bindTextureLayers(ResourceLocation *resource) float srcFactor = srcAlpha / outAlpha; float dstFactor = (dstAlpha * (1.0f - srcAlpha)) / outAlpha; - int outA = (int)(outAlpha * 255.0f + 0.5f); - int outR = (int)((((src >> 16) & 0xff) * srcFactor) + (((dst >> 16) & 0xff) * dstFactor) + 0.5f); - int outG = (int)((((src >> 8) & 0xff) * srcFactor) + (((dst >> 8) & 0xff) * dstFactor) + 0.5f); - int outB = (int)(((src & 0xff) * srcFactor) + ((dst & 0xff) * dstFactor) + 0.5f); + int outA = static_cast(outAlpha * 255.0f + 0.5f); + int outR = static_cast((((src >> 16) & 0xff) * srcFactor) + (((dst >> 16) & 0xff) * dstFactor) + 0.5f); + int outG = static_cast((((src >> 8) & 0xff) * srcFactor) + (((dst >> 8) & 0xff) * dstFactor) + 0.5f); + int outB = static_cast(((src & 0xff) * srcFactor) + ((dst & 0xff) * dstFactor) + 0.5f); mergedPixels[p] = (outA << 24) | (outR << 16) | (outG << 8) | outB; } } @@ -730,10 +730,10 @@ void Textures::loadTexture(BufferedImage *img, int id, bool blur, bool clamp) newPixels[i * 4 + 2] = (byte) g; newPixels[i * 4 + 3] = (byte) b; #else - newPixels[i * 4 + 0] = (byte) r; - newPixels[i * 4 + 1] = (byte) g; - newPixels[i * 4 + 2] = (byte) b; - newPixels[i * 4 + 3] = (byte) a; + newPixels[i * 4 + 0] = static_cast(r); + newPixels[i * 4 + 1] = static_cast(g); + newPixels[i * 4 + 2] = static_cast(b); + newPixels[i * 4 + 3] = static_cast(a); #endif } // 4J - now creating a buffer of the size we require dynamically @@ -901,10 +901,10 @@ void Textures::replaceTexture(intArray rawPixels, int w, int h, int id) b = bb; } - newPixels[i * 4 + 0] = (byte) r; - newPixels[i * 4 + 1] = (byte) g; - newPixels[i * 4 + 2] = (byte) b; - newPixels[i * 4 + 3] = (byte) a; + newPixels[i * 4 + 0] = static_cast(r); + newPixels[i * 4 + 1] = static_cast(g); + newPixels[i * 4 + 2] = static_cast(b); + newPixels[i * 4 + 3] = static_cast(a); } ByteBuffer *pixels = MemoryTracker::createByteBuffer(w * h * 4); // 4J - now creating dynamically pixels->put(newPixels); diff --git a/Minecraft.Client/TheEndPortalRenderer.cpp b/Minecraft.Client/TheEndPortalRenderer.cpp index 98c7e7cc5..c709cfd18 100644 --- a/Minecraft.Client/TheEndPortalRenderer.cpp +++ b/Minecraft.Client/TheEndPortalRenderer.cpp @@ -16,9 +16,9 @@ void TheEndPortalRenderer::render(shared_ptr _table, double x, doubl { // 4J Convert as we aren't using a templated class shared_ptr table = dynamic_pointer_cast(_table); - float xx = (float) tileEntityRenderDispatcher->xPlayer; - float yy = (float) tileEntityRenderDispatcher->yPlayer; - float zz = (float) tileEntityRenderDispatcher->zPlayer; + float xx = static_cast(tileEntityRenderDispatcher->xPlayer); + float yy = static_cast(tileEntityRenderDispatcher->yPlayer); + float zz = static_cast(tileEntityRenderDispatcher->zPlayer); glDisable(GL_LIGHTING); @@ -50,12 +50,12 @@ void TheEndPortalRenderer::render(shared_ptr _table, double x, doubl sscale = 1 / 2.0f; } - float dd = (float) -(y + hoff); + float dd = static_cast(-(y + hoff)); { float ss1 = (float) (dd + Camera::yPlayerOffs); float ss2 = (float) (dd + dist + Camera::yPlayerOffs); float s = ss1 / ss2; - s = (float) (y + hoff) + s; + s = static_cast(y + hoff) + s; glTranslatef(xx, s, zz); } diff --git a/Minecraft.Client/TileRenderer.cpp b/Minecraft.Client/TileRenderer.cpp index 2acc6170a..acf6a57b6 100644 --- a/Minecraft.Client/TileRenderer.cpp +++ b/Minecraft.Client/TileRenderer.cpp @@ -131,7 +131,7 @@ int TileRenderer::getLightColor( Tile *tt, LevelSource *level, int x, int y, int // Tiles that were determined to be invisible (by being surrounded by solid stuff) will be set to 255 rather than their actual ID if( ucTileId != 255 ) { - tileId = (int)ucTileId; + tileId = static_cast(ucTileId); } } int ret = tt->getLightColor(level, x, y, z, tileId); @@ -347,7 +347,7 @@ bool TileRenderer::tesselateInWorld( Tile* tt, int x, int y, int z, int forceDat retVal = tesselateTorchInWorld( tt, x, y, z ); break; case Tile::SHAPE_FIRE: - retVal = tesselateFireInWorld( (FireTile *)tt, x, y, z ); + retVal = tesselateFireInWorld( static_cast(tt), x, y, z ); break; case Tile::SHAPE_RED_DUST: retVal = tesselateDustInWorld( tt, x, y, z ); @@ -359,19 +359,19 @@ bool TileRenderer::tesselateInWorld( Tile* tt, int x, int y, int z, int forceDat retVal = tesselateDoorInWorld( tt, x, y, z ); break; case Tile::SHAPE_RAIL: - retVal = tesselateRailInWorld( ( RailTile* )tt, x, y, z ); + retVal = tesselateRailInWorld( static_cast(tt), x, y, z ); break; case Tile::SHAPE_STAIRS: - retVal = tesselateStairsInWorld( (StairTile *)tt, x, y, z ); + retVal = tesselateStairsInWorld( static_cast(tt), x, y, z ); break; case Tile::SHAPE_EGG: - retVal = tesselateEggInWorld((EggTile*) tt, x, y, z); + retVal = tesselateEggInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_FENCE: - retVal = tesselateFenceInWorld( ( FenceTile* )tt, x, y, z ); + retVal = tesselateFenceInWorld( static_cast(tt), x, y, z ); break; case Tile::SHAPE_WALL: - retVal = tesselateWallInWorld( (WallTile *) tt, x, y, z); + retVal = tesselateWallInWorld( static_cast(tt), x, y, z); break; case Tile::SHAPE_LEVER: retVal = tesselateLeverInWorld( tt, x, y, z ); @@ -386,13 +386,13 @@ bool TileRenderer::tesselateInWorld( Tile* tt, int x, int y, int z, int forceDat retVal = tesselateBedInWorld( tt, x, y, z ); break; case Tile::SHAPE_REPEATER: - retVal = tesselateRepeaterInWorld((RepeaterTile *)tt, x, y, z); + retVal = tesselateRepeaterInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_DIODE: - retVal = tesselateDiodeInWorld( (DiodeTile *)tt, x, y, z ); + retVal = tesselateDiodeInWorld( static_cast(tt), x, y, z ); break; case Tile::SHAPE_COMPARATOR: - retVal = tesselateComparatorInWorld((ComparatorTile *)tt, x, y, z); + retVal = tesselateComparatorInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_PISTON_BASE: retVal = tesselatePistonBaseInWorld( tt, x, y, z, false, forceData ); @@ -401,7 +401,7 @@ bool TileRenderer::tesselateInWorld( Tile* tt, int x, int y, int z, int forceDat retVal = tesselatePistonExtensionInWorld( tt, x, y, z, true, forceData ); break; case Tile::SHAPE_IRON_FENCE: - retVal = tesselateThinFenceInWorld( ( ThinFenceTile* )tt, x, y, z ); + retVal = tesselateThinFenceInWorld( static_cast(tt), x, y, z ); break; case Tile::SHAPE_THIN_PANE: retVal = tesselateThinPaneInWorld(tt, x, y, z); @@ -410,25 +410,25 @@ bool TileRenderer::tesselateInWorld( Tile* tt, int x, int y, int z, int forceDat retVal = tesselateVineInWorld( tt, x, y, z ); break; case Tile::SHAPE_FENCE_GATE: - retVal = tesselateFenceGateInWorld( ( FenceGateTile* )tt, x, y, z ); + retVal = tesselateFenceGateInWorld( static_cast(tt), x, y, z ); break; case Tile::SHAPE_CAULDRON: - retVal = tesselateCauldronInWorld((CauldronTile* ) tt, x, y, z); + retVal = tesselateCauldronInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_FLOWER_POT: - retVal = tesselateFlowerPotInWorld((FlowerPotTile *) tt, x, y, z); + retVal = tesselateFlowerPotInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_ANVIL: - retVal = tesselateAnvilInWorld((AnvilTile *) tt, x, y, z); + retVal = tesselateAnvilInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_BREWING_STAND: - retVal = tesselateBrewingStandInWorld((BrewingStandTile* ) tt, x, y, z); + retVal = tesselateBrewingStandInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_PORTAL_FRAME: - retVal = tesselateAirPortalFrameInWorld((TheEndPortalFrameTile *)tt, x, y, z); + retVal = tesselateAirPortalFrameInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_COCOA: - retVal = tesselateCocoaInWorld((CocoaTile *)tt, x, y, z); + retVal = tesselateCocoaInWorld(static_cast(tt), x, y, z); break; case Tile::SHAPE_BEACON: retVal = tesselateBeaconInWorld(tt, x, y, z); @@ -1160,23 +1160,23 @@ bool TileRenderer::tesselateTorchInWorld( Tile* tt, int x, int y, int z ) float h = 0.20f; if ( dir == 1 ) { - tesselateTorch( tt, (float)x - r2, (float)y + h, (float)z, -r, 0.0f, 0 ); + tesselateTorch( tt, static_cast(x) - r2, static_cast(y) + h, static_cast(z), -r, 0.0f, 0 ); } else if ( dir == 2 ) { - tesselateTorch( tt, (float)x + r2, (float)y + h, (float)z, +r, 0.0f, 0 ); + tesselateTorch( tt, static_cast(x) + r2, static_cast(y) + h, static_cast(z), +r, 0.0f, 0 ); } else if ( dir == 3 ) { - tesselateTorch( tt, (float)x, (float)y + h, z - r2, 0.0f, -r, 0 ); + tesselateTorch( tt, static_cast(x), static_cast(y) + h, z - r2, 0.0f, -r, 0 ); } else if ( dir == 4 ) { - tesselateTorch( tt, (float)x, (float)y + h, (float)z + r2, 0.0f, +r, 0 ); + tesselateTorch( tt, static_cast(x), static_cast(y) + h, static_cast(z) + r2, 0.0f, +r, 0 ); } else { - tesselateTorch( tt, (float)x, (float)y, (float)z, 0.0f, 0.0f, 0 ); + tesselateTorch( tt, static_cast(x), static_cast(y), static_cast(z), 0.0f, 0.0f, 0 ); } return true; @@ -1257,7 +1257,7 @@ bool TileRenderer::tesselateRepeaterInWorld(RepeaterTile *tt, int x, int y, int south = 14.f; break; } - setShape(west / 16.0f + (float) transmitterX, 2.f / 16.0f, north / 16.0f + (float) transmitterZ, east / 16.0f + (float) transmitterX, 4.f / 16.0f, south / 16.0f + (float) transmitterZ); + setShape(west / 16.0f + static_cast(transmitterX), 2.f / 16.0f, north / 16.0f + static_cast(transmitterZ), east / 16.0f + static_cast(transmitterX), 4.f / 16.0f, south / 16.0f + static_cast(transmitterZ)); double u0 = lockTex->getU(west); double v0 = lockTex->getV(north); double u1 = lockTex->getU(east); @@ -1503,7 +1503,7 @@ bool TileRenderer::tesselatePistonBaseInWorld( Tile* tt, int x, int y, int z, bo } // weird way of telling the piston to use the // "inside" texture for the forward-facing edge - ((PistonBaseTile *) tt)->updateShape((float) tileShapeX0, (float) tileShapeY0, (float) tileShapeZ0, (float) tileShapeX1, (float) tileShapeY1, (float) tileShapeZ1); + static_cast(tt)->updateShape((float) tileShapeX0, (float) tileShapeY0, (float) tileShapeZ0, (float) tileShapeX1, (float) tileShapeY1, (float) tileShapeZ1); tesselateBlockInWorld( tt, x, y, z ); northFlip = FLIP_NONE; southFlip = FLIP_NONE; @@ -1511,7 +1511,7 @@ bool TileRenderer::tesselatePistonBaseInWorld( Tile* tt, int x, int y, int z, bo westFlip = FLIP_NONE; upFlip = FLIP_NONE; downFlip = FLIP_NONE; - ((PistonBaseTile *) tt)->updateShape((float) tileShapeX0, (float) tileShapeY0, (float) tileShapeZ0, (float) tileShapeX1, (float) tileShapeY1, (float) tileShapeZ1); + static_cast(tt)->updateShape((float) tileShapeX0, (float) tileShapeY0, (float) tileShapeZ0, (float) tileShapeX1, (float) tileShapeY1, (float) tileShapeZ1); } else { @@ -1961,10 +1961,10 @@ bool TileRenderer::tesselateLeverInWorld( Tile* tt, int x, int y, int z ) c2 = corners[7]; c3 = corners[4]; } - t->vertexUV( ( float )( c0->x ), ( float )( c0->y ), ( float )( c0->z ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( c1->x ), ( float )( c1->y ), ( float )( c1->z ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( c2->x ), ( float )( c2->y ), ( float )( c2->z ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( c3->x ), ( float )( c3->y ), ( float )( c3->z ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(c0->x), static_cast(c0->y), static_cast(c0->z), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(c1->x), static_cast(c1->y), static_cast(c1->z), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(c2->x), static_cast(c2->y), static_cast(c2->z), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(c3->x), static_cast(c3->y), static_cast(c3->z), ( float )( u0 ), ( float )( v0 ) ); } return true; @@ -2491,15 +2491,15 @@ bool TileRenderer::tesselateFireInWorld( FireTile* tt, int x, int y, int z ) float z0_ = z + 0.5f - 0.3f; float z1_ = z + 0.5f + 0.3f; - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + 1), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + 1), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + 0), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + 0), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + 0), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), static_cast(z + 0), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), static_cast(z + 1), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + 1), ( float )( u0 ), ( float )( v0 ) ); tex = secondTex; u0 = tex->getU0(true); @@ -2507,15 +2507,15 @@ bool TileRenderer::tesselateFireInWorld( FireTile* tt, int x, int y, int z ) u1 = tex->getU1(true); v1 = tex->getV1(true); - t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 1), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 0), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 0), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); x0 = x + 0.5f - 0.5f; x1 = x + 0.5f + 0.5f; @@ -2527,15 +2527,15 @@ bool TileRenderer::tesselateFireInWorld( FireTile* tt, int x, int y, int z ) z0_ = z + 0.5f - 0.4f; z1_ = z + 0.5f + 0.4f; - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + 0), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + 0), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), static_cast(z + 1), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0_ ), ( float )( y + h ), static_cast(z + 1), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + 1), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), static_cast(z + 1), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), static_cast(z + 0), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1_ ), ( float )( y + h ), static_cast(z + 0), ( float )( u1 ), ( float )( v0 ) ); tex = firstTex; u0 = tex->getU0(true); @@ -2543,15 +2543,15 @@ bool TileRenderer::tesselateFireInWorld( FireTile* tt, int x, int y, int z ) u1 = tex->getU1(true); v1 = tex->getV1(true); - t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 0), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 1), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 0), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); } else { @@ -2595,10 +2595,10 @@ bool TileRenderer::tesselateFireInWorld( FireTile* tt, int x, int y, int z ) { t->vertexUV( ( float )( x + 1 - r ), ( float )( y + h + yo ), ( float )( z + 0.0f ), ( float )( u0 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x + 1 - 0 ), ( float )( y + 0 + yo ), ( float )( z + - 0.0f ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x + 1 - 0 ), ( float )( y + 0 + yo ), ( float )( z + - 1.0f ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1 - 0), ( float )( y + 0 + yo ), ( float )( z + + 0.0f ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x + 1 - 0), ( float )( y + 0 + yo ), ( float )( z + + 1.0f ), ( float )( u1 ), ( float )( v1 ) ); t->vertexUV( ( float )( x + 1 - r ), ( float )( y + h + yo ), ( float )( z + 1.0f ), ( float )( u1 ), ( float )( v0 ) ); @@ -2674,14 +2674,14 @@ bool TileRenderer::tesselateFireInWorld( FireTile* tt, int x, int y, int z ) if ( ( ( x + y + z ) & 1 ) == 0 ) { - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + - 0 ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + - 0 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + - 1 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + - 1 ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x0_), ( float )( y + h ), static_cast(z + + 0), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x0), static_cast(y + 0), static_cast(z + + 0), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x0), static_cast(y + 0), static_cast(z + + 1), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x0_), ( float )( y + h ), static_cast(z + + 1), ( float )( u0 ), ( float )( v0 ) ); tex = secondTex; u0 = tex->getU0(true); @@ -2689,25 +2689,25 @@ bool TileRenderer::tesselateFireInWorld( FireTile* tt, int x, int y, int z ) u1 = tex->getU1(true); v1 = tex->getV1(true); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + - 1.0f ), ( float )( u1 ), ( float )( v0 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0.0f ), ( float )( z + - 1.0f ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0.0f ), ( float )( z + - 0 ), ( float )( u0 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + - 0 ), ( float )( u0 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x1_), ( float )( y + h ), ( float )( z + + 1.0f ), ( float )( u1 ), ( float )( v0 ) ); + t->vertexUV( static_cast(x1), ( float )( y + 0.0f ), ( float )( z + + 1.0f ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x1), ( float )( y + 0.0f ), static_cast(z + + 0), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( static_cast(x1_), ( float )( y + h ), static_cast(z + + 0), ( float )( u0 ), ( float )( v0 ) ); } else { t->vertexUV( ( float )( x + 0.0f ), ( float )( y + - h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) ); + h ), static_cast(z1_), ( float )( u1 ), ( float )( v0 ) ); t->vertexUV( ( float )( x + 0.0f ), ( float )( y + - 0.0f ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); + 0.0f ), static_cast(z1), ( float )( u1 ), ( float )( v1 ) ); t->vertexUV( ( float )( x + 1.0f ), ( float )( y + - 0.0f ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) ); + 0.0f ), static_cast(z1), ( float )( u0 ), ( float )( v1 ) ); t->vertexUV( ( float )( x + 1.0f ), ( float )( y + - h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) ); + h ), static_cast(z1_), ( float )( u0 ), ( float )( v0 ) ); tex = secondTex; u0 = tex->getU0(true); @@ -2716,13 +2716,13 @@ bool TileRenderer::tesselateFireInWorld( FireTile* tt, int x, int y, int z ) v1 = tex->getV1(true); t->vertexUV( ( float )( x + 1.0f ), ( float )( y + - h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) ); + h ), static_cast(z0_), ( float )( u1 ), ( float )( v0 ) ); t->vertexUV( ( float )( x + 1.0f ), ( float )( y + - 0.0f ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) ); + 0.0f ), static_cast(z0), ( float )( u1 ), ( float )( v1 ) ); t->vertexUV( ( float )( x + 0.0f ), ( float )( y + - 0.0f ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); + 0.0f ), static_cast(z0), ( float )( u0 ), ( float )( v1 ) ); t->vertexUV( ( float )( x + 0.0f ), ( float )( y + - h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) ); + h ), static_cast(z0_), ( float )( u0 ), ( float )( v0 ) ); } } } @@ -2838,13 +2838,13 @@ bool TileRenderer::tesselateDustInWorld( Tile* tt, int x, int y, int z ) int v1 = SharedConstants::WORLD_RESOLUTION; int cutDistance = 5; - if (!w) x0 += cutDistance / (float) SharedConstants::WORLD_RESOLUTION; + if (!w) x0 += cutDistance / static_cast(SharedConstants::WORLD_RESOLUTION); if (!w) u0 += cutDistance; - if (!e) x1 -= cutDistance / (float) SharedConstants::WORLD_RESOLUTION; + if (!e) x1 -= cutDistance / static_cast(SharedConstants::WORLD_RESOLUTION); if (!e) u1 -= cutDistance; - if (!n) z0 += cutDistance / (float) SharedConstants::WORLD_RESOLUTION; + if (!n) z0 += cutDistance / static_cast(SharedConstants::WORLD_RESOLUTION); if (!n) v0 += cutDistance; - if (!s) z1 -= cutDistance / (float) SharedConstants::WORLD_RESOLUTION; + if (!s) z1 -= cutDistance / static_cast(SharedConstants::WORLD_RESOLUTION); if (!s) v1 -= cutDistance; t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z1 ), crossTexture->getU(u1, true), crossTexture->getV(v1) ); t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z0 ), crossTexture->getU(u1, true), crossTexture->getV(v0) ); @@ -2891,58 +2891,58 @@ bool TileRenderer::tesselateDustInWorld( Tile* tt, int x, int y, int z ) if ( level->isSolidBlockingTile( x - 1, y, z ) && level->getTile( x - 1, y + 1, z ) == Tile::redStoneDust_Id ) { t->color( br * red, br * green, br * blue ); - t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 1 ), lineTexture->getU1(true), lineTexture->getV0(true) ); - t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 0 ), ( float )( z + 1 ), lineTexture->getU0(true), lineTexture->getV0(true) ); - t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 0 ), ( float )( z + 0 ), lineTexture->getU0(true), lineTexture->getV1(true) ); - t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 0 ), lineTexture->getU1(true), lineTexture->getV1(true) ); + t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 1 + yStretch ), static_cast(z + 1), lineTexture->getU1(true), lineTexture->getV0(true) ); + t->vertexUV( ( float )( x + dustOffset ), static_cast(y + 0), static_cast(z + 1), lineTexture->getU0(true), lineTexture->getV0(true) ); + t->vertexUV( ( float )( x + dustOffset ), static_cast(y + 0), static_cast(z + 0), lineTexture->getU0(true), lineTexture->getV1(true) ); + t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 1 + yStretch ), static_cast(z + 0), lineTexture->getU1(true), lineTexture->getV1(true) ); t->color( br, br, br ); - t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 1 ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV0(true) ); - t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 0 ), ( float )( z + 1 ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV0(true) ); - t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 0 ), ( float )( z + 0 ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV1(true) ); - t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 0 ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV1(true) ); + t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 1 + yStretch ), static_cast(z + 1), lineTextureOverlay->getU1(true), lineTextureOverlay->getV0(true) ); + t->vertexUV( ( float )( x + overlayOffset ), static_cast(y + 0), static_cast(z + 1), lineTextureOverlay->getU0(true), lineTextureOverlay->getV0(true) ); + t->vertexUV( ( float )( x + overlayOffset ), static_cast(y + 0), static_cast(z + 0), lineTextureOverlay->getU0(true), lineTextureOverlay->getV1(true) ); + t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 1 + yStretch ), static_cast(z + 0), lineTextureOverlay->getU1(true), lineTextureOverlay->getV1(true) ); } if ( level->isSolidBlockingTile( x + 1, y, z ) && level->getTile( x + 1, y + 1, z ) == Tile::redStoneDust_Id ) { t->color( br * red, br * green, br * blue ); - t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 0 ), ( float )( z + 1 ), lineTexture->getU0(true), lineTexture->getV1(true) ); - t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 1 ), lineTexture->getU1(true), lineTexture->getV1(true) ); - t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 0 ), lineTexture->getU1(true), lineTexture->getV0(true) ); - t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 0 ), ( float )( z + 0 ), lineTexture->getU0(true), lineTexture->getV0(true) ); + t->vertexUV( ( float )( x + 1 - dustOffset ), static_cast(y + 0), static_cast(z + 1), lineTexture->getU0(true), lineTexture->getV1(true) ); + t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 1 + yStretch ), static_cast(z + 1), lineTexture->getU1(true), lineTexture->getV1(true) ); + t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 1 + yStretch ), static_cast(z + 0), lineTexture->getU1(true), lineTexture->getV0(true) ); + t->vertexUV( ( float )( x + 1 - dustOffset ), static_cast(y + 0), static_cast(z + 0), lineTexture->getU0(true), lineTexture->getV0(true) ); t->color( br, br, br ); - t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 0 ), ( float )( z + 1 ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV1(true) ); - t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 1 ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV1(true) ); - t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 0 ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV0(true) ); - t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 0 ), ( float )( z + 0 ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV0(true) ); + t->vertexUV( ( float )( x + 1 - overlayOffset ), static_cast(y + 0), static_cast(z + 1), lineTextureOverlay->getU0(true), lineTextureOverlay->getV1(true) ); + t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 1 + yStretch ), static_cast(z + 1), lineTextureOverlay->getU1(true), lineTextureOverlay->getV1(true) ); + t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 1 + yStretch ), static_cast(z + 0), lineTextureOverlay->getU1(true), lineTextureOverlay->getV0(true) ); + t->vertexUV( ( float )( x + 1 - overlayOffset ), static_cast(y + 0), static_cast(z + 0), lineTextureOverlay->getU0(true), lineTextureOverlay->getV0(true) ); } if ( level->isSolidBlockingTile( x, y, z - 1 ) && level->getTile( x, y + 1, z - 1 ) == Tile::redStoneDust_Id ) { t->color( br * red, br * green, br * blue ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z + dustOffset ), lineTexture->getU0(true), lineTexture->getV1(true) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 1 + yStretch ), ( float )( z + dustOffset ), lineTexture->getU1(true), lineTexture->getV1(true) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 1 + yStretch ), ( float )( z + dustOffset ), lineTexture->getU1(true), lineTexture->getV0(true) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z + dustOffset ), lineTexture->getU0(true), lineTexture->getV0(true) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z + dustOffset ), lineTexture->getU0(true), lineTexture->getV1(true) ); + t->vertexUV( static_cast(x + 1), ( float )( y + 1 + yStretch ), ( float )( z + dustOffset ), lineTexture->getU1(true), lineTexture->getV1(true) ); + t->vertexUV( static_cast(x + 0), ( float )( y + 1 + yStretch ), ( float )( z + dustOffset ), lineTexture->getU1(true), lineTexture->getV0(true) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z + dustOffset ), lineTexture->getU0(true), lineTexture->getV0(true) ); t->color( br, br, br ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z + overlayOffset ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV1(true) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 1 + yStretch ), ( float )( z + overlayOffset ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV1(true) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 1 + yStretch ), ( float )( z + overlayOffset ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV0(true) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z + overlayOffset ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV0(true) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z + overlayOffset ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV1(true) ); + t->vertexUV( static_cast(x + 1), ( float )( y + 1 + yStretch ), ( float )( z + overlayOffset ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV1(true) ); + t->vertexUV( static_cast(x + 0), ( float )( y + 1 + yStretch ), ( float )( z + overlayOffset ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV0(true) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z + overlayOffset ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV0(true) ); } if ( level->isSolidBlockingTile( x, y, z + 1 ) && level->getTile( x, y + 1, z + 1 ) == Tile::redStoneDust_Id ) { t->color( br * red, br * green, br * blue ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 1 + yStretch ), ( float )( z + 1 - dustOffset ), lineTexture->getU1(true), lineTexture->getV0(true) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z + 1 - dustOffset ), lineTexture->getU0(true), lineTexture->getV0(true) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z + 1 - dustOffset ), lineTexture->getU0(true), lineTexture->getV1(true) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 1 + yStretch ), ( float )( z + 1 - dustOffset ), lineTexture->getU1(true), lineTexture->getV1(true) ); + t->vertexUV( static_cast(x + 1), ( float )( y + 1 + yStretch ), ( float )( z + 1 - dustOffset ), lineTexture->getU1(true), lineTexture->getV0(true) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z + 1 - dustOffset ), lineTexture->getU0(true), lineTexture->getV0(true) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z + 1 - dustOffset ), lineTexture->getU0(true), lineTexture->getV1(true) ); + t->vertexUV( static_cast(x + 0), ( float )( y + 1 + yStretch ), ( float )( z + 1 - dustOffset ), lineTexture->getU1(true), lineTexture->getV1(true) ); t->color( br, br, br ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 1 + yStretch ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV0(true) ); - t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV0(true) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV1(true) ); - t->vertexUV( ( float )( x + 0 ), ( float )( y + 1 + yStretch ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV1(true) ); + t->vertexUV( static_cast(x + 1), ( float )( y + 1 + yStretch ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV0(true) ); + t->vertexUV( static_cast(x + 1), static_cast(y + 0), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV0(true) ); + t->vertexUV( static_cast(x + 0), static_cast(y + 0), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU0(true), lineTextureOverlay->getV1(true) ); + t->vertexUV( static_cast(x + 0), ( float )( y + 1 + yStretch ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU1(true), lineTextureOverlay->getV1(true) ); } } @@ -2982,15 +2982,15 @@ bool TileRenderer::tesselateRailInWorld( RailTile* tt, int x, int y, int z ) float r = 1 / 16.0f; - float x0 = ( float )( x + 1 ); - float x1 = ( float )( x + 1 ); - float x2 = ( float )( x + 0 ); - float x3 = ( float )( x + 0 ); + float x0 = static_cast(x + 1); + float x1 = static_cast(x + 1); + float x2 = static_cast(x + 0); + float x3 = static_cast(x + 0); - float z0 = ( float )( z + 0 ); - float z1 = ( float )( z + 1 ); - float z2 = ( float )( z + 1 ); - float z3 = ( float )( z + 0 ); + float z0 = static_cast(z + 0); + float z1 = static_cast(z + 1); + float z2 = static_cast(z + 1); + float z3 = static_cast(z + 0); float y0 = ( float )( y + r ); float y1 = ( float )( y + r ); @@ -2999,24 +2999,24 @@ bool TileRenderer::tesselateRailInWorld( RailTile* tt, int x, int y, int z ) if ( data == 1 || data == 2 || data == 3 || data == 7 ) { - x0 = x3 = ( float )( x + 1 ); - x1 = x2 = ( float )( x + 0 ); - z0 = z1 = ( float )( z + 1 ); - z2 = z3 = ( float )( z + 0 ); + x0 = x3 = static_cast(x + 1); + x1 = x2 = static_cast(x + 0); + z0 = z1 = static_cast(z + 1); + z2 = z3 = static_cast(z + 0); } else if ( data == 8 ) { - x0 = x1 = ( float )( x + 0 ); - x2 = x3 = ( float )( x + 1 ); - z0 = z3 = ( float )( z + 1 ); - z1 = z2 = ( float )( z + 0 ); + x0 = x1 = static_cast(x + 0); + x2 = x3 = static_cast(x + 1); + z0 = z3 = static_cast(z + 1); + z1 = z2 = static_cast(z + 0); } else if ( data == 9 ) { - x0 = x3 = ( float )( x + 0 ); - x1 = x2 = ( float )( x + 1 ); - z0 = z1 = ( float )( z + 0 ); - z2 = z3 = ( float )( z + 1 ); + x0 = x3 = static_cast(x + 0); + x1 = x2 = static_cast(x + 1); + z0 = z1 = static_cast(z + 0); + z2 = z3 = static_cast(z + 1); } if ( data == 2 || data == 4 ) @@ -3251,7 +3251,7 @@ bool TileRenderer::tesselateThinPaneInWorld(Tile *tt, int x, int y, int z) { int data = level->getData(x, y, z); tex = getTexture(tt, 0, data); - edgeTex = (stained) ? ((StainedGlassPaneBlock *) tt)->getEdgeTexture(data) : ((ThinFenceTile *) tt)->getEdgeTexture(); + edgeTex = (stained) ? static_cast(tt)->getEdgeTexture(data) : static_cast(tt)->getEdgeTexture(); } double u0 = tex->getU0(); @@ -3277,10 +3277,10 @@ bool TileRenderer::tesselateThinPaneInWorld(Tile *tt, int x, int y, int z) double iz0 = z + .5 - 1.0 / 16.0; double iz1 = z + .5 + 1.0 / 16.0; - bool n = (stained) ? ((StainedGlassPaneBlock *)tt)->attachsTo(level->getTile(x, y, z - 1)) : ((ThinFenceTile *)tt)->attachsTo(level->getTile(x, y, z - 1)); - bool s = (stained) ? ((StainedGlassPaneBlock *)tt)->attachsTo(level->getTile(x, y, z + 1)) : ((ThinFenceTile *)tt)->attachsTo(level->getTile(x, y, z + 1)); - bool w = (stained) ? ((StainedGlassPaneBlock *)tt)->attachsTo(level->getTile(x - 1, y, z)) : ((ThinFenceTile *)tt)->attachsTo(level->getTile(x - 1, y, z)); - bool e = (stained) ? ((StainedGlassPaneBlock *)tt)->attachsTo(level->getTile(x + 1, y, z)) : ((ThinFenceTile *)tt)->attachsTo(level->getTile(x + 1, y, z)); + bool n = (stained) ? static_cast(tt)->attachsTo(level->getTile(x, y, z - 1)) : static_cast(tt)->attachsTo(level->getTile(x, y, z - 1)); + bool s = (stained) ? static_cast(tt)->attachsTo(level->getTile(x, y, z + 1)) : static_cast(tt)->attachsTo(level->getTile(x, y, z + 1)); + bool w = (stained) ? static_cast(tt)->attachsTo(level->getTile(x - 1, y, z)) : static_cast(tt)->attachsTo(level->getTile(x - 1, y, z)); + bool e = (stained) ? static_cast(tt)->attachsTo(level->getTile(x + 1, y, z)) : static_cast(tt)->attachsTo(level->getTile(x + 1, y, z)); double noZFightingOffset = 0.001; double yt = 1.0 - noZFightingOffset; @@ -3691,10 +3691,10 @@ bool TileRenderer::tesselateThinFenceInWorld( ThinFenceTile* tt, int x, int y, i float iv1 = edgeTex->getV(8, true); float iv2 = edgeTex->getV1(true); - float x0 = (float)x; + float x0 = static_cast(x); float x1 = x + 0.5f; float x2 = x + 1.0f; - float z0 = (float)z; + float z0 = static_cast(z); float z1 = z + 0.5f; float z2 = z + 1.0f; float ix0 = x + 0.5f - 1.0f / 16.0f; @@ -4161,9 +4161,9 @@ bool TileRenderer::tesselateCrossInWorld( Tile* tt, int x, int y, int z ) } t->color( br * r, br * g, br * b ); - float xt = (float)x; - float yt = (float)y; - float zt = (float)z; + float xt = static_cast(x); + float yt = static_cast(y); + float zt = static_cast(z); if (tt == Tile::tallgrass) { @@ -4181,7 +4181,7 @@ bool TileRenderer::tesselateCrossInWorld( Tile* tt, int x, int y, int z ) bool TileRenderer::tesselateStemInWorld( Tile* _tt, int x, int y, int z ) { - StemTile* tt = ( StemTile* )_tt; + StemTile* tt = static_cast(_tt); Tesselator* t = Tesselator::getInstance(); float br; @@ -4409,7 +4409,7 @@ bool TileRenderer::tesselateLilypadInWorld(Tile *tt, int x, int y, int z) __int64 seed = (x * 3129871) ^ (z * 116129781l) ^ (y); seed = seed * seed * 42317861 + seed * 11; - int dir = (int) ((seed >> 16) & 0x3); + int dir = static_cast((seed >> 16) & 0x3); @@ -4622,7 +4622,7 @@ bool TileRenderer::tesselateWaterInWorld( Tile* tt, int x, int y, int z ) { changed = true; Icon *tex = getTexture( tt, 1, data ); - float angle = ( float )LiquidTile::getSlopeAngle( level, x, y, z, m ); + float angle = static_cast(LiquidTile::getSlopeAngle(level, x, y, z, m)); if ( angle > -999 ) { tex = getTexture( tt, 2, data ); @@ -4717,8 +4717,8 @@ bool TileRenderer::tesselateWaterInWorld( Tile* tt, int x, int y, int z ) { hh0 = ( float )( h0 ); hh1 = ( float )( h3 ); - x0 = ( float )( x ); - x1 = ( float )( x + 1 ); + x0 = static_cast(x); + x1 = static_cast(x + 1); z0 = ( float )( z + offs); z1 = ( float )( z + offs); } @@ -4726,8 +4726,8 @@ bool TileRenderer::tesselateWaterInWorld( Tile* tt, int x, int y, int z ) { hh0 = ( float )( h2 ); hh1 = ( float )( h1 ); - x0 = ( float )( x + 1 ); - x1 = ( float )( x ); + x0 = static_cast(x + 1); + x1 = static_cast(x); z0 = ( float )( z + 1 - offs); z1 = ( float )( z + 1 - offs); } @@ -4737,8 +4737,8 @@ bool TileRenderer::tesselateWaterInWorld( Tile* tt, int x, int y, int z ) hh1 = ( float )( h0 ); x0 = ( float )( x + offs); x1 = ( float )( x + offs); - z0 = ( float )( z + 1 ); - z1 = ( float )( z ); + z0 = static_cast(z + 1); + z1 = static_cast(z); } else { @@ -4746,8 +4746,8 @@ bool TileRenderer::tesselateWaterInWorld( Tile* tt, int x, int y, int z ) hh1 = ( float )( h2 ); x0 = ( float )( x + 1 - offs); x1 = ( float )( x + 1 - offs); - z0 = ( float )( z ); - z1 = ( float )( z + 1 ); + z0 = static_cast(z); + z1 = static_cast(z + 1); } @@ -4777,8 +4777,8 @@ bool TileRenderer::tesselateWaterInWorld( Tile* tt, int x, int y, int z ) t->color( c11 * br * r, c11 * br * g, c11 * br * b ); t->vertexUV( ( float )( x0 ), ( float )( y + hh0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v01 ) ); t->vertexUV( ( float )( x1 ), ( float )( y + hh1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v02 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x1 ), static_cast(y + 0), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) ); + t->vertexUV( ( float )( x0 ), static_cast(y + 0), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) ); } @@ -5534,14 +5534,14 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tile* float _ll2 = (ll00z + ll0Yz + llX0z + llXYz) / 4.0f; float _ll3 = (ll0yz + ll00z + llXyz + llX0z) / 4.0f; float _ll4 = (llxyz + llx0z + ll0yz + ll00z) / 4.0f; - ll1 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll4 * (1.0 - tileShapeY1) - * (1.0 - tileShapeX0)); - ll2 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll2 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll4 * (1.0 - tileShapeY1) - * (1.0 - tileShapeX1)); - ll3 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll2 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll4 * (1.0 - tileShapeY0) - * (1.0 - tileShapeX1)); - ll4 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll4 * (1.0 - tileShapeY0) - * (1.0 - tileShapeX0)); + ll1 = static_cast(_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll4 * (1.0 - tileShapeY1) + * (1.0 - tileShapeX0)); + ll2 = static_cast(_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll2 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll4 * (1.0 - tileShapeY1) + * (1.0 - tileShapeX1)); + ll3 = static_cast(_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll2 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll4 * (1.0 - tileShapeY0) + * (1.0 - tileShapeX1)); + ll4 = static_cast(_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll4 * (1.0 - tileShapeY0) + * (1.0 - tileShapeX0)); int _tc1 = blend(ccx0z, ccxYz, cc0Yz, cc00z); int _tc2 = blend(cc0Yz, ccX0z, ccXYz, cc00z); @@ -5689,14 +5689,14 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tile* float _ll4 = (ll00Z + ll0YZ + llX0Z + llXYZ) / 4.0f; float _ll3 = (ll0yZ + ll00Z + llXyZ + llX0Z) / 4.0f; float _ll2 = (llxyZ + llx0Z + ll0yZ + ll00Z) / 4.0f; - ll1 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll4 * tileShapeY1 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll2 * (1.0 - tileShapeY1) - * (1.0 - tileShapeX0)); - ll2 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll4 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll2 * (1.0 - tileShapeY0) - * (1.0 - tileShapeX0)); - ll3 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll4 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll2 * (1.0 - tileShapeY0) - * (1.0 - tileShapeX1)); - ll4 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll4 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll2 * (1.0 - tileShapeY1) - * (1.0 - tileShapeX1)); + ll1 = static_cast(_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll4 * tileShapeY1 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll2 * (1.0 - tileShapeY1) + * (1.0 - tileShapeX0)); + ll2 = static_cast(_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll4 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll2 * (1.0 - tileShapeY0) + * (1.0 - tileShapeX0)); + ll3 = static_cast(_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll4 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll2 * (1.0 - tileShapeY0) + * (1.0 - tileShapeX1)); + ll4 = static_cast(_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll4 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll2 * (1.0 - tileShapeY1) + * (1.0 - tileShapeX1)); int _tc1 = blend(ccx0Z, ccxYZ, cc0YZ, cc00Z); int _tc4 = blend(cc0YZ, ccX0Z, ccXYZ, cc00Z); @@ -5840,14 +5840,14 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tile* float _ll1 = (llx00 + llx0Z + llxY0 + llxYZ) / 4.0f; float _ll2 = (llx0z + llx00 + llxYz + llxY0) / 4.0f; float _ll3 = (llxyz + llxy0 + llx0z + llx00) / 4.0f; - ll1 = (float) (_ll1 * tileShapeY1 * tileShapeZ1 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY1) - * tileShapeZ1); - ll2 = (float) (_ll1 * tileShapeY1 * tileShapeZ0 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY1) - * tileShapeZ0); - ll3 = (float) (_ll1 * tileShapeY0 * tileShapeZ0 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY0) - * tileShapeZ0); - ll4 = (float) (_ll1 * tileShapeY0 * tileShapeZ1 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY0) - * tileShapeZ1); + ll1 = static_cast(_ll1 * tileShapeY1 * tileShapeZ1 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY1) + * tileShapeZ1); + ll2 = static_cast(_ll1 * tileShapeY1 * tileShapeZ0 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY1) + * tileShapeZ0); + ll3 = static_cast(_ll1 * tileShapeY0 * tileShapeZ0 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY0) + * tileShapeZ0); + ll4 = static_cast(_ll1 * tileShapeY0 * tileShapeZ1 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY0) + * tileShapeZ1); int _tc4 = blend(ccxy0, ccxyZ, ccx0Z, ccx00); int _tc1 = blend(ccx0Z, ccxY0, ccxYZ, ccx00); @@ -5991,14 +5991,14 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tile* float _ll2 = (llXyz + llXy0 + llX0z + llX00) / 4.0f; float _ll3 = (llX0z + llX00 + llXYz + llXY0) / 4.0f; float _ll4 = (llX00 + llX0Z + llXY0 + llXYZ) / 4.0f; - ll1 = (float) (_ll1 * (1.0 - tileShapeY0) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY0 - * tileShapeZ1); - ll2 = (float) (_ll1 * (1.0 - tileShapeY0) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY0 - * tileShapeZ0); - ll3 = (float) (_ll1 * (1.0 - tileShapeY1) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY1 - * tileShapeZ0); - ll4 = (float) (_ll1 * (1.0 - tileShapeY1) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY1 - * tileShapeZ1); + ll1 = static_cast(_ll1 * (1.0 - tileShapeY0) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY0 + * tileShapeZ1); + ll2 = static_cast(_ll1 * (1.0 - tileShapeY0) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY0 + * tileShapeZ0); + ll3 = static_cast(_ll1 * (1.0 - tileShapeY1) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY1 + * tileShapeZ0); + ll4 = static_cast(_ll1 * (1.0 - tileShapeY1) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY1 + * tileShapeZ1); int _tc1 = blend(ccXy0, ccXyZ, ccX0Z, ccX00); int _tc4 = blend(ccX0Z, ccXY0, ccXYZ, ccX00); @@ -6085,8 +6085,8 @@ int TileRenderer::blend( int a, int b, int c, int def ) int TileRenderer::blend(int a, int b, int c, int d, double fa, double fb, double fc, double fd) { - int top = (int) ((double) ((a >> 16) & 0xff) * fa + (double) ((b >> 16) & 0xff) * fb + (double) ((c >> 16) & 0xff) * fc + (double) ((d >> 16) & 0xff) * fd) & 0xff; - int bottom = (int) ((double) (a & 0xff) * fa + (double) (b & 0xff) * fb + (double) (c & 0xff) * fc + (double) (d & 0xff) * fd) & 0xff; + int top = static_cast((double)((a >> 16) & 0xff) * fa + (double)((b >> 16) & 0xff) * fb + (double)((c >> 16) & 0xff) * fc + (double)((d >> 16) & 0xff) * fd) & 0xff; + int bottom = static_cast((double)(a & 0xff) * fa + (double)(b & 0xff) * fb + (double)(c & 0xff) * fc + (double)(d & 0xff) * fd) & 0xff; return (top << 16) | bottom; } @@ -7282,23 +7282,23 @@ void TileRenderer::renderFaceDown( Tile* tt, double x, double y, double z, Icon t->color( c1r, c1g, c1b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z1), static_cast(u10), static_cast(v10) ); t->color( c2r, c2g, c2b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z0), ( float )( u00 ), ( float )( v00 ) ); t->color( c3r, c3g, c3b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z0), static_cast(u01), static_cast(v01) ); t->color( c4r, c4g, c4b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z1), ( float )( u11 ), ( float )( v11 ) ); } else { - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z1), static_cast(u10), static_cast(v10) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z0), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z0), static_cast(u01), static_cast(v01) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z1), ( float )( u11 ), ( float )( v11 ) ); } } @@ -7394,23 +7394,23 @@ void TileRenderer::renderFaceUp( Tile* tt, double x, double y, double z, Icon *t t->color( c1r, c1g, c1b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z1), ( float )( u11 ), ( float )( v11 ) ); t->color( c2r, c2g, c2b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z0), ( float )( u01 ), ( float )( v01 ) ); t->color( c3r, c3g, c3b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z0), ( float )( u00 ), ( float )( v00 ) ); t->color( c4r, c4g, c4b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z1), ( float )( u10 ), ( float )( v10 ) ); } else { - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z1), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z0), ( float )( u01 ), ( float )( v01 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z0), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z1), ( float )( u10 ), ( float )( v10 ) ); } } @@ -7513,23 +7513,23 @@ void TileRenderer::renderNorth( Tile* tt, double x, double y, double z, Icon *te t->color( c1r, c1g, c1b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z0), static_cast(u01), static_cast(v01) ); t->color( c2r, c2g, c2b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z0), static_cast(u00), static_cast(v00) ); t->color( c3r, c3g, c3b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u10 ), ( float )( v10 ) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z0), static_cast(u10), static_cast(v10) ); t->color( c4r, c4g, c4b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z0), static_cast(u11), static_cast(v11) ); } else { - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u10 ), ( float )( v10 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z0), static_cast(u01), static_cast(v01) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z0), static_cast(u00), static_cast(v00) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z0), static_cast(u10), static_cast(v10) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z0), static_cast(u11), static_cast(v11) ); } } @@ -7632,23 +7632,23 @@ void TileRenderer::renderSouth( Tile* tt, double x, double y, double z, Icon *te t->color( c1r, c1g, c1b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z1), static_cast(u00), static_cast(v00) ); t->color( c2r, c2g, c2b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z1), static_cast(u10), static_cast(v10) ); t->color( c3r, c3g, c3b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z1), static_cast(u11), static_cast(v11) ); t->color( c4r, c4g, c4b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u01 ), ( float )( v01 ) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z1), static_cast(u01), static_cast(v01) ); } else { - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u00 ), ( float )( v00 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u01 ), ( float )( v01 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z1), static_cast(u00), static_cast(v00) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z1), static_cast(u10), static_cast(v10) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z1), static_cast(u11), static_cast(v11) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z1), static_cast(u01), static_cast(v01) ); } } @@ -7750,23 +7750,23 @@ void TileRenderer::renderWest( Tile* tt, double x, double y, double z, Icon *tex t->color( c1r, c1g, c1b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u01 ), ( float )( v01 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z1), static_cast(u01), static_cast(v01) ); t->color( c2r, c2g, c2b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z0), static_cast(u00), static_cast(v00) ); t->color( c3r, c3g, c3b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u10 ), ( float )( v10 ) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z0), static_cast(u10), static_cast(v10) ); t->color( c4r, c4g, c4b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z1), static_cast(u11), static_cast(v11) ); } else { - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u01 ), ( float )( v01 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u10 ), ( float )( v10 ) ); - t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z1), static_cast(u01), static_cast(v01) ); + t->vertexUV( static_cast(x0), static_cast(y1), static_cast(z0), static_cast(u00), static_cast(v00) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z0), static_cast(u10), static_cast(v10) ); + t->vertexUV( static_cast(x0), static_cast(y0), static_cast(z1), static_cast(u11), static_cast(v11) ); } } @@ -7868,23 +7868,23 @@ void TileRenderer::renderEast( Tile* tt, double x, double y, double z, Icon *tex t->color( c1r, c1g, c1b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z1), static_cast(u10), static_cast(v10) ); t->color( c2r, c2g, c2b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u11 ), ( float )( v11 ) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z0), static_cast(u11), static_cast(v11) ); t->color( c3r, c3g, c3b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z0), static_cast(u01), static_cast(v01) ); t->color( c4r, c4g, c4b ); if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z1), static_cast(u00), static_cast(v00) ); } else { - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u11 ), ( float )( v11 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) ); - t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u00 ), ( float )( v00 ) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z1), static_cast(u10), static_cast(v10) ); + t->vertexUV( static_cast(x1), static_cast(y0), static_cast(z0), static_cast(u11), static_cast(v11) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z0), static_cast(u01), static_cast(v01) ); + t->vertexUV( static_cast(x1), static_cast(y1), static_cast(z1), static_cast(u00), static_cast(v00) ); } } @@ -8399,7 +8399,7 @@ void TileRenderer::renderTile( Tile* tile, int data, float brightness, float fAl else if (shape == Tile::SHAPE_ANVIL) { glTranslatef(-0.5f, -0.5f, -0.5f); - tesselateAnvilInWorld((AnvilTile *) tile, 0, 0, 0, data << 2, true); + tesselateAnvilInWorld(static_cast(tile), 0, 0, 0, data << 2, true); glTranslatef(0.5f, 0.5f, 0.5f); } else if ( shape == Tile::SHAPE_PORTAL_FRAME ) diff --git a/Minecraft.Client/Timer.cpp b/Minecraft.Client/Timer.cpp index 15a2c2f13..100322ba7 100644 --- a/Minecraft.Client/Timer.cpp +++ b/Minecraft.Client/Timer.cpp @@ -40,10 +40,10 @@ void Timer::advanceTime() accumMs += passedMs; if (accumMs > 1000) { - __int64 msSysTime = (__int64)(now * 1000.0); + __int64 msSysTime = static_cast<__int64>(now * 1000.0); __int64 passedMsSysTime = msSysTime - lastMsSysTime; - double adjustTimeT = accumMs / (double) passedMsSysTime; + double adjustTimeT = accumMs / static_cast(passedMsSysTime); adjustTime += (adjustTimeT - adjustTime) * 0.2f; lastMsSysTime = msSysTime; @@ -51,7 +51,7 @@ void Timer::advanceTime() } if (accumMs < 0) { - lastMsSysTime = (__int64)(now * 1000.0); + lastMsSysTime = static_cast<__int64>(now * 1000.0); } } lastMs = nowMs; @@ -62,9 +62,9 @@ void Timer::advanceTime() if (passedSeconds < 0) passedSeconds = 0; if (passedSeconds > 1) passedSeconds = 1; - passedTime = (float)( passedTime + (passedSeconds * timeScale * ticksPerSecond)); + passedTime = static_cast(passedTime + (passedSeconds * timeScale * ticksPerSecond)); - ticks = (int) passedTime; + ticks = static_cast(passedTime); passedTime -= ticks; if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE; @@ -75,10 +75,10 @@ void Timer::advanceTime() void Timer::advanceTimeQuickly() { - double passedSeconds = (double) MAX_TICKS_PER_UPDATE / (double) ticksPerSecond; + double passedSeconds = static_cast(MAX_TICKS_PER_UPDATE) / static_cast(ticksPerSecond); - passedTime = (float)(passedTime + (passedSeconds * timeScale * ticksPerSecond)); - ticks = (int) passedTime; + passedTime = static_cast(passedTime + (passedSeconds * timeScale * ticksPerSecond)); + ticks = static_cast(passedTime); passedTime -= ticks; a = passedTime; @@ -110,7 +110,7 @@ void Timer::skipTime() { __int64 passedMsSysTime = msSysTime - lastMsSysTime; - double adjustTimeT = accumMs / (double) passedMsSysTime; + double adjustTimeT = accumMs / static_cast(passedMsSysTime); adjustTime += (adjustTimeT - adjustTime) * 0.2f; lastMsSysTime = msSysTime; @@ -130,9 +130,9 @@ void Timer::skipTime() if (passedSeconds < 0) passedSeconds = 0; if (passedSeconds > 1) passedSeconds = 1; - passedTime = (float)(passedTime + (passedSeconds * timeScale * ticksPerSecond)); + passedTime = static_cast(passedTime + (passedSeconds * timeScale * ticksPerSecond)); - ticks = (int) 0; + ticks = static_cast(0); if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE; passedTime -= ticks; diff --git a/Minecraft.Client/TntRenderer.cpp b/Minecraft.Client/TntRenderer.cpp index 52e2877dc..848a456c1 100644 --- a/Minecraft.Client/TntRenderer.cpp +++ b/Minecraft.Client/TntRenderer.cpp @@ -17,7 +17,7 @@ void TntRenderer::render(shared_ptr _tnt, double x, double y, double z, shared_ptr tnt = dynamic_pointer_cast(_tnt); glPushMatrix(); - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); if (tnt->life - a + 1 < 10) { float g = 1 - ((tnt->life - a + 1) / 10.0f); diff --git a/Minecraft.Client/TrackedEntity.cpp b/Minecraft.Client/TrackedEntity.cpp index 0a5a02bff..74cfbca32 100644 --- a/Minecraft.Client/TrackedEntity.cpp +++ b/Minecraft.Client/TrackedEntity.cpp @@ -152,7 +152,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ) { teleportDelay = 0; - packet = shared_ptr( new TeleportEntityPacket(e->entityId, xn, yn, zn, (byte) yRotn, (byte) xRotn) ); + packet = shared_ptr( new TeleportEntityPacket(e->entityId, xn, yn, zn, static_cast(yRotn), static_cast(xRotn)) ); // printf("%d: New teleport rot %d\n",e->entityId,yRotn); yRotp = yRotn; xRotp = xRotn; @@ -179,12 +179,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl yRotn = yRotp + yRota; } // 5 bits each for x & z, and 6 for y - packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, (char) xa, (char) ya, (char) za, (char) yRota, 0 ) ); + packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), 0 ) ); c0a++; } else { - packet = shared_ptr( new MoveEntityPacket::PosRot(e->entityId, (char) xa, (char) ya, (char) za, (char) yRota, (char) xRota) ); + packet = shared_ptr( new MoveEntityPacket::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), static_cast(xRota)) ); // printf("%d: New posrot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); c0b++; } @@ -197,7 +197,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ( ya >= -16 ) && ( ya <= 15 ) ) { // 4 bits each for x & z, and 5 for y - packet = shared_ptr( new MoveEntityPacketSmall::Pos(e->entityId, (char) xa, (char) ya, (char) za) ); + packet = shared_ptr( new MoveEntityPacketSmall::Pos(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)) ); c1a++; } @@ -206,12 +206,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ( ya >= -32 ) && ( ya <= 31 ) ) { // use the packet with small packet with rotation if we can - 5 bits each for x & z, and 6 for y - still a byte less than the alternative - packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, (char) xa, (char) ya, (char) za, 0, 0 )); + packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), 0, 0 )); c1b++; } else { - packet = shared_ptr( new MoveEntityPacket::Pos(e->entityId, (char) xa, (char) ya, (char) za) ); + packet = shared_ptr( new MoveEntityPacket::Pos(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)) ); c1c++; } } @@ -231,13 +231,13 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl yRota = 15; yRotn = yRotp + yRota; } - packet = shared_ptr( new MoveEntityPacketSmall::Rot(e->entityId, (char) yRota, 0) ); + packet = shared_ptr( new MoveEntityPacketSmall::Rot(e->entityId, static_cast(yRota), 0) ); c2a++; } else { // printf("%d: New rot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); - packet = shared_ptr( new MoveEntityPacket::Rot(e->entityId, (char) yRota, (char) xRota) ); + packet = shared_ptr( new MoveEntityPacket::Rot(e->entityId, static_cast(yRota), static_cast(xRota)) ); c2b++; } } @@ -291,7 +291,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (rot) { // 4J: Changed this to use deltas - broadcast( shared_ptr( new MoveEntityPacket::Rot(e->entityId, (byte) yRota, (byte) xRota)) ); + broadcast( shared_ptr( new MoveEntityPacket::Rot(e->entityId, static_cast(yRota), static_cast(xRota))) ); yRotp = yRotn; xRotp = xRotn; } @@ -308,7 +308,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360); if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL) { - broadcast(shared_ptr( new RotateHeadPacket(e->entityId, (byte) yHeadRot))); + broadcast(shared_ptr( new RotateHeadPacket(e->entityId, static_cast(yHeadRot)))); yHeadRotp = yHeadRot; } @@ -337,7 +337,7 @@ void TrackedEntity::sendDirtyEntityData() if ( e->instanceof(eTYPE_LIVINGENTITY) ) { shared_ptr living = dynamic_pointer_cast(e); - ServersideAttributeMap *attributeMap = (ServersideAttributeMap *) living->getAttributes(); + ServersideAttributeMap *attributeMap = static_cast(living->getAttributes()); unordered_set *attributes = attributeMap->getDirtyAttributes(); if (!attributes->empty()) @@ -545,7 +545,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptrinstanceof(eTYPE_LIVINGENTITY) ) { shared_ptr living = dynamic_pointer_cast(e); - ServersideAttributeMap *attributeMap = (ServersideAttributeMap *) living->getAttributes(); + ServersideAttributeMap *attributeMap = static_cast(living->getAttributes()); unordered_set *attributes = attributeMap->getSyncableAttributes(); if (!attributes->empty()) @@ -736,9 +736,9 @@ shared_ptr TrackedEntity::getAddEntityPacket() { aep = shared_ptr( new AddEntityPacket(e, type, 0, yRotp, xRotp, xp, yp, zp) ); } - aep->xa = (int) (fb->xPower * 8000); - aep->ya = (int) (fb->yPower * 8000); - aep->za = (int) (fb->zPower * 8000); + aep->xa = static_cast(fb->xPower * 8000); + aep->ya = static_cast(fb->yPower * 8000); + aep->za = static_cast(fb->zPower * 8000); return aep; } else if (e->instanceof(eTYPE_THROWNEGG)) @@ -784,9 +784,9 @@ shared_ptr TrackedEntity::getAddEntityPacket() { shared_ptr knot = dynamic_pointer_cast(e); shared_ptr packet = shared_ptr(new AddEntityPacket(e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp) ); - packet->x = Mth::floor((float)knot->xTile * 32); - packet->y = Mth::floor((float)knot->yTile * 32); - packet->z = Mth::floor((float)knot->zTile * 32); + packet->x = Mth::floor(static_cast(knot->xTile) * 32); + packet->y = Mth::floor(static_cast(knot->yTile) * 32); + packet->z = Mth::floor(static_cast(knot->zTile) * 32); return packet; } else if (e->instanceof(eTYPE_EXPERIENCEORB)) diff --git a/Minecraft.Client/VideoSettingsScreen.cpp b/Minecraft.Client/VideoSettingsScreen.cpp index 5c948cdd1..2fefe9298 100644 --- a/Minecraft.Client/VideoSettingsScreen.cpp +++ b/Minecraft.Client/VideoSettingsScreen.cpp @@ -48,7 +48,7 @@ void VideoSettingsScreen::buttonClicked(Button *button) if (!button->active) return; if (button->id < 100 && (dynamic_cast(button) != NULL)) { - options->toggle(((SmallButton *) button)->getOption(), 1); + options->toggle(static_cast(button)->getOption(), 1); button->msg = options->getMessage(Options::Option::getItem(button->id)); } if (button->id == 200) diff --git a/Minecraft.Client/VillagerGolemRenderer.cpp b/Minecraft.Client/VillagerGolemRenderer.cpp index 5d6809784..0b62435b2 100644 --- a/Minecraft.Client/VillagerGolemRenderer.cpp +++ b/Minecraft.Client/VillagerGolemRenderer.cpp @@ -10,7 +10,7 @@ ResourceLocation VillagerGolemRenderer::GOLEM_LOCATION = ResourceLocation(TN_MOB VillagerGolemRenderer::VillagerGolemRenderer() : MobRenderer(new VillagerGolemModel(), 0.5f) { - golemModel = (VillagerGolemModel *) model; + golemModel = static_cast(model); } void VillagerGolemRenderer::render(shared_ptr mob, double x, double y, double z, float rot, float a) diff --git a/Minecraft.Client/VillagerRenderer.cpp b/Minecraft.Client/VillagerRenderer.cpp index ac885747c..0b54a70b7 100644 --- a/Minecraft.Client/VillagerRenderer.cpp +++ b/Minecraft.Client/VillagerRenderer.cpp @@ -12,7 +12,7 @@ ResourceLocation VillagerRenderer::VILLAGER_BUTCHER_LOCATION = ResourceLocation( VillagerRenderer::VillagerRenderer() : MobRenderer(new VillagerModel(0), 0.5f) { - villagerModel = (VillagerModel *) model; + villagerModel = static_cast(model); } int VillagerRenderer::prepareArmor(shared_ptr villager, int layer, float a) diff --git a/Minecraft.Client/WaterDropParticle.cpp b/Minecraft.Client/WaterDropParticle.cpp index 90035243e..065738af9 100644 --- a/Minecraft.Client/WaterDropParticle.cpp +++ b/Minecraft.Client/WaterDropParticle.cpp @@ -8,7 +8,7 @@ WaterDropParticle::WaterDropParticle(Level *level, double x, double y, double z) : Particle(level, x, y, z, 0, 0, 0) { xd *= 0.3f; - yd = (float) Math::random() * 0.2f + 0.1f; + yd = static_cast(Math::random()) * 0.2f + 0.1f; zd *= 0.3f; rCol = 1.0f; @@ -19,7 +19,7 @@ WaterDropParticle::WaterDropParticle(Level *level, double x, double y, double z) gravity = 0.06f; noPhysics = true; // 4J - optimisation - do we really need collision on these? its really slow... - lifetime = (int) (8 / (Math::random() * 0.8 + 0.2)); + lifetime = static_cast(8 / (Math::random() * 0.8 + 0.2)); } void WaterDropParticle::tick() diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d1x_shared.inl b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d1x_shared.inl index df42488c6..6e14791c4 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d1x_shared.inl +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d1x_shared.inl @@ -270,7 +270,7 @@ static void *start_write_dyn(DynBuffer *buf, U32 size) // discard buffer whenever the current write position is 0; // done this way so that if a DISCARD Map() were to fail, we would // just keep retrying the next time around. - ptr = (U8 *) map_buffer(gdraw->d3d_context, buf->buffer, buf->write_pos == 0); + ptr = static_cast(map_buffer(gdraw->d3d_context, buf->buffer, buf->write_pos == 0)); if (ptr) { ptr += buf->write_pos; // we return pointer to write position in buffer buf->alloc_pos = buf->write_pos + size; // bump alloc position @@ -474,7 +474,7 @@ static rrbool RADLINK gdraw_MakeTextureMore(GDraw_MakeTexture_ProcessingInfo * / static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) { - GDrawHandle *t = (GDrawHandle *) p->p0; + GDrawHandle *t = static_cast(p->p0); D3D1X_(SUBRESOURCE_DATA) mipdata[24]; S32 i, w, h, nmips, bpp; HRESULT hr = S_OK; @@ -643,7 +643,7 @@ static rrbool RADLINK gdraw_MakeVertexBufferMore(GDraw_MakeVertexBuffer_Processi static GDrawVertexBuffer * RADLINK gdraw_MakeVertexBufferEnd(GDraw_MakeVertexBuffer_ProcessingInfo *p, GDrawStats * /*stats*/) { - GDrawHandle *vb = (GDrawHandle *) p->p0; + GDrawHandle *vb = static_cast(p->p0); HRESULT hr; D3D1X_(BUFFER_DESC) vbdesc = { static_cast(p->vertex_data_length), D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_VERTEX_BUFFER), 0U, 0U }; @@ -861,7 +861,7 @@ static void disable_scissor(int force) static void set_viewport_raw(S32 x, S32 y, S32 w, S32 h) { - D3D1X_(VIEWPORT) vp = { (ViewCoord) x, (ViewCoord) y, (ViewCoord) w, (ViewCoord) h, 0.0f, 1.0f }; + D3D1X_(VIEWPORT) vp = { static_cast(x), static_cast(y), static_cast(w), static_cast(h), 0.0f, 1.0f }; gdraw->d3d_context->RSSetViewports(1, &vp); gdraw->cview.x = x; gdraw->cview.y = y; @@ -891,8 +891,8 @@ static void set_projection_raw(S32 x0, S32 x1, S32 y0, S32 y1) { gdraw->projection[0] = 2.0f / (x1-x0); gdraw->projection[1] = 2.0f / (y1-y0); - gdraw->projection[2] = (x1+x0)/(F32)(x0-x1); - gdraw->projection[3] = (y1+y0)/(F32)(y0-y1); + gdraw->projection[2] = (x1+x0)/static_cast(x0 - x1); + gdraw->projection[3] = (y1+y0)/static_cast(y0 - y1); set_projection_base(); } @@ -1164,7 +1164,7 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex set_render_target(stats); assert(gdraw->frametex_width >= gdraw->tw && gdraw->frametex_height >= gdraw->th); // @GDRAW_ASSERT - S32 k = (S32) (t - gdraw->rendertargets.handle); + S32 k = static_cast(t - gdraw->rendertargets.handle); if (region) { gswf_recti r; @@ -1284,7 +1284,7 @@ static void RADLINK gdraw_ClearID(void) // assuming the depth buffer has been mappped to 0..1 static F32 depth_from_id(S32 id) { - return 1.0f - ((F32) id + 1.0f) / MAX_DEPTH_VALUE; + return 1.0f - (static_cast(id) + 1.0f) / MAX_DEPTH_VALUE; } static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap) @@ -1319,7 +1319,7 @@ static int set_renderstate_full(S32 vertex_format, GDrawRenderState *r, GDrawSta set_vertex_shader(d3d, gdraw->vert[vertex_format].vshader); // set vertex shader constants - if (VertexVars *vvars = (VertexVars *) map_buffer(gdraw->d3d_context, gdraw->cb_vertex, true)) { + if (VertexVars *vvars = static_cast(map_buffer(gdraw->d3d_context, gdraw->cb_vertex, true))) { F32 depth = depth_from_id(r->id); if (!r->use_world_space) gdraw_ObjectSpace(vvars->world[0], r->o2w, depth, 0.0f); @@ -1384,7 +1384,7 @@ static int set_renderstate_full(S32 vertex_format, GDrawRenderState *r, GDrawSta set_texture(0, r->tex[0], r->nearest0, r->wrap0); // pixel shader constants - if (PixelCommonVars *pvars = (PixelCommonVars *) map_buffer(gdraw->d3d_context, gdraw->cb_ps_common, true)) { + if (PixelCommonVars *pvars = static_cast(map_buffer(gdraw->d3d_context, gdraw->cb_ps_common, true))) { memcpy(pvars->color_mul, r->color, 4*sizeof(float)); if (r->cxf_add) { @@ -1481,10 +1481,10 @@ static int vertsize[GDRAW_vformat__basic_count] = { static void tag_resources(void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL) { U64 now = gdraw->frame_counter; - if (r1) ((GDrawHandle *) r1)->fence.value = now; - if (r2) ((GDrawHandle *) r2)->fence.value = now; - if (r3) ((GDrawHandle *) r3)->fence.value = now; - if (r4) ((GDrawHandle *) r4)->fence.value = now; + if (r1) static_cast(r1)->fence.value = now; + if (r2) static_cast(r2)->fence.value = now; + if (r3) static_cast(r3)->fence.value = now; + if (r4) static_cast(r4)->fence.value = now; } static void RADLINK gdraw_DrawIndexedTriangles(GDrawRenderState *r, GDrawPrimitive *p, GDrawVertexBuffer *buf, GDrawStats *stats) @@ -1501,10 +1501,10 @@ static void RADLINK gdraw_DrawIndexedTriangles(GDrawRenderState *r, GDrawPrimiti d3d->IASetInputLayout(gdraw->inlayout[vfmt]); if (vb) { - UINT offs = (UINT) (UINTa) p->vertices; + UINT offs = static_cast((UINTa)p->vertices); d3d->IASetVertexBuffers(0, 1, &vb->handle.vbuf.verts, &stride, &offs); - d3d->IASetIndexBuffer(vb->handle.vbuf.inds, DXGI_FORMAT_R16_UINT, (UINT) (UINTa) p->indices); + d3d->IASetIndexBuffer(vb->handle.vbuf.inds, DXGI_FORMAT_R16_UINT, static_cast((UINTa)p->indices)); d3d->DrawIndexed(p->num_indices, 0, 0); } else if (p->indices) { U32 vbytes = p->num_vertices * stride; @@ -1581,10 +1581,10 @@ static void set_pixel_constant(F32 *constant, F32 x, F32 y, F32 z, F32 w) static void do_screen_quad(gswf_recti *s, const F32 *tc, GDrawStats *stats) { ID3D1XContext *d3d = gdraw->d3d_context; - F32 px0 = (F32) s->x0, py0 = (F32) s->y0, px1 = (F32) s->x1, py1 = (F32) s->y1; + F32 px0 = static_cast(s->x0), py0 = static_cast(s->y0), px1 = static_cast(s->x1), py1 = static_cast(s->y1); // generate vertex data - gswf_vertex_xyst *vert = (gswf_vertex_xyst *) start_write_dyn(&gdraw->dyn_vb, 4 * sizeof(gswf_vertex_xyst)); + gswf_vertex_xyst *vert = static_cast(start_write_dyn(&gdraw->dyn_vb, 4 * sizeof(gswf_vertex_xyst))); if (!vert) return; @@ -1595,7 +1595,7 @@ static void do_screen_quad(gswf_recti *s, const F32 *tc, GDrawStats *stats) UINT offs = end_write_dyn(&gdraw->dyn_vb); UINT stride = sizeof(gswf_vertex_xyst); - if (VertexVars *vvars = (VertexVars *) map_buffer(gdraw->d3d_context, gdraw->cb_vertex, true)) { + if (VertexVars *vvars = static_cast(map_buffer(gdraw->d3d_context, gdraw->cb_vertex, true))) { gdraw_PixelSpace(vvars->world[0]); memcpy(vvars->x3d, gdraw->projmat, 12*sizeof(F32)); unmap_buffer(gdraw->d3d_context, gdraw->cb_vertex); @@ -1629,7 +1629,7 @@ static void manual_clear(gswf_recti *r, GDrawStats *stats) set_projection_raw(0, gdraw->frametex_width, gdraw->frametex_height, 0); set_pixel_shader(d3d, gdraw->clear_ps.pshader); - if (PixelCommonVars *pvars = (PixelCommonVars *) map_buffer(gdraw->d3d_context, gdraw->cb_ps_common, true)) { + if (PixelCommonVars *pvars = static_cast(map_buffer(gdraw->d3d_context, gdraw->cb_ps_common, true))) { memset(pvars, 0, sizeof(*pvars)); unmap_buffer(gdraw->d3d_context, gdraw->cb_ps_common); d3d->PSSetConstantBuffers(0, 1, &gdraw->cb_ps_common); @@ -1643,7 +1643,7 @@ static void gdraw_DriverBlurPass(GDrawRenderState *r, int taps, float *data, gs set_texture(0, r->tex[0], false, GDRAW_WRAP_clamp); set_pixel_shader(gdraw->d3d_context, gdraw->blur_prog[taps].pshader); - PixelParaBlur *para = (PixelParaBlur *) start_ps_constants(gdraw->cb_blur); + PixelParaBlur *para = static_cast(start_ps_constants(gdraw->cb_blur)); memcpy(para->clamp, clamp, 4 * sizeof(float)); memcpy(para->tap, data, taps * 4 * sizeof(float)); end_ps_constants(gdraw->cb_blur); @@ -1660,7 +1660,7 @@ static void gdraw_Colormatrix(GDrawRenderState *r, gswf_recti *s, float *tc, GDr set_texture(0, r->tex[0], false, GDRAW_WRAP_clamp); set_pixel_shader(gdraw->d3d_context, gdraw->colormatrix.pshader); - PixelParaColorMatrix *para = (PixelParaColorMatrix *) start_ps_constants(gdraw->cb_colormatrix); + PixelParaColorMatrix *para = static_cast(start_ps_constants(gdraw->cb_colormatrix)); memcpy(para->data, r->shader_data, 5 * 4 * sizeof(float)); end_ps_constants(gdraw->cb_colormatrix); @@ -1672,7 +1672,7 @@ static void gdraw_Colormatrix(GDrawRenderState *r, gswf_recti *s, float *tc, GDr static gswf_recti *get_valid_rect(GDrawTexture *tex) { GDrawHandle *h = (GDrawHandle *) tex; - S32 n = (S32) (h - gdraw->rendertargets.handle); + S32 n = static_cast(h - gdraw->rendertargets.handle); assert(n >= 0 && n <= MAX_RENDER_STACK_DEPTH+1); return &gdraw->rt_valid[n]; } @@ -1698,12 +1698,12 @@ static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbe set_texture(2, r->tex[2], false, GDRAW_WRAP_clamp); set_pixel_shader(gdraw->d3d_context, gdraw->filter_prog[isbevel][r->filter_mode].pshader); - PixelParaFilter *para = (PixelParaFilter *) start_ps_constants(gdraw->cb_filter); + PixelParaFilter *para = static_cast(start_ps_constants(gdraw->cb_filter)); set_clamp_constant(para->clamp0, r->tex[0]); set_clamp_constant(para->clamp1, r->tex[1]); set_pixel_constant(para->color, r->shader_data[0], r->shader_data[1], r->shader_data[2], r->shader_data[3]); set_pixel_constant(para->color2, r->shader_data[8], r->shader_data[9], r->shader_data[10], r->shader_data[11]); - set_pixel_constant(para->tc_off, -r->shader_data[4] / (F32)gdraw->frametex_width, -r->shader_data[5] / (F32)gdraw->frametex_height, r->shader_data[6], 0); + set_pixel_constant(para->tc_off, -r->shader_data[4] / static_cast(gdraw->frametex_width), -r->shader_data[5] / static_cast(gdraw->frametex_height), r->shader_data[6], 0); end_ps_constants(gdraw->cb_filter); do_screen_quad(s, tc, stats); @@ -1725,10 +1725,10 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 if (s.x1 < s.x0 || s.y1 < s.y0) return; - tc[0] = (s.x0 - gdraw->tx0p) / (F32) gdraw->frametex_width; - tc[1] = (s.y0 - gdraw->ty0p) / (F32) gdraw->frametex_height; - tc[2] = (s.x1 - gdraw->tx0p) / (F32) gdraw->frametex_width; - tc[3] = (s.y1 - gdraw->ty0p) / (F32) gdraw->frametex_height; + tc[0] = (s.x0 - gdraw->tx0p) / static_cast(gdraw->frametex_width); + tc[1] = (s.y0 - gdraw->ty0p) / static_cast(gdraw->frametex_height); + tc[2] = (s.x1 - gdraw->tx0p) / static_cast(gdraw->frametex_width); + tc[3] = (s.y1 - gdraw->ty0p) / static_cast(gdraw->frametex_height); // clear to known render state d3d->OMSetBlendState(gdraw->blend_state[GDRAW_BLEND_none], four_zeros, ~0u); @@ -1811,10 +1811,10 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 d3d->PSSetSamplers(1, 1, &gdraw->sampler_state[0][GDRAW_WRAP_clamp]); // calculate texture coordinate remapping - rescale1[0] = gdraw->frametex_width / (F32) texdesc.Width; - rescale1[1] = gdraw->frametex_height / (F32) texdesc.Height; - rescale1[2] = (gdraw->vx - gdraw->tx0 + gdraw->tx0p) / (F32) texdesc.Width; - rescale1[3] = (gdraw->vy - gdraw->ty0 + gdraw->ty0p) / (F32) texdesc.Height; + rescale1[0] = gdraw->frametex_width / static_cast(texdesc.Width); + rescale1[1] = gdraw->frametex_height / static_cast(texdesc.Height); + rescale1[2] = (gdraw->vx - gdraw->tx0 + gdraw->tx0p) / static_cast(texdesc.Width); + rescale1[3] = (gdraw->vy - gdraw->ty0 + gdraw->ty0p) / static_cast(texdesc.Height); } else { D3D1X_(BOX) box = { 0,0,0,0,0,1 }; S32 dx = 0, dy = 0; diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_shared.inl index a60fa520c..11a197e67 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_shared.inl @@ -368,7 +368,7 @@ static void gdraw_HandleTransitionInsertBefore(GDrawHandle *t, GDrawHandleState { check_lists(t->cache); assert(t->state != GDRAW_HANDLE_STATE_sentinel); // sentinels should never get here! - assert(t->state != (U32) new_state); // code should never call "transition" if it's not transitioning! + assert(t->state != static_cast(new_state)); // code should never call "transition" if it's not transitioning! // unlink from prev state t->prev->next = t->next; t->next->prev = t->prev; @@ -773,7 +773,7 @@ static GDrawTexture *gdraw_BlurPass(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRe if (!g->TextureDrawBufferBegin(draw_bounds, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats)) return r->tex[0]; - c->BlurPass(r, taps, data, draw_bounds, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, draw_bounds, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -825,7 +825,7 @@ static GDrawTexture *gdraw_BlurPassDownsample(GDrawFunctions *g, GDrawBlurInfo * assert(clamp[0] <= clamp[2]); assert(clamp[1] <= clamp[3]); - c->BlurPass(r, taps, data, &z, tc, (F32) c->h / c->frametex_height, clamp, gstats); + c->BlurPass(r, taps, data, &z, tc, static_cast(c->h) / c->frametex_height, clamp, gstats); return g->TextureDrawBufferEnd(gstats); } @@ -837,7 +837,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR GDrawTexture *t; F32 data[MAX_TAPS][4]; S32 off_axis = 1-axis; - S32 w = ((S32) ceil((blur_width-1)/2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 + S32 w = static_cast(ceil((blur_width - 1) / 2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5 F32 edge_weight = 1 - (w - blur_width)/2; // 3 => 0 => 1; 1.2 => 1.8 => 0.9 => 0.1 F32 inverse_weight = 1.0f / blur_width; @@ -944,7 +944,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR // max coverage is 25 samples, or a filter width of 13. with 7 taps, we sample // 13 samples in one pass, max coverage is 13*13 samples or (13*13-1)/2 width, // which is ((2T-1)*(2T-1)-1)/2 or (4T^2 - 4T + 1 -1)/2 or 2T^2 - 2T or 2T*(T-1) - S32 w_mip = (S32) ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS)); + S32 w_mip = static_cast(ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS))); S32 downsample = w_mip; F32 sample_spacing = texel; if (downsample < 2) downsample = 2; diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp index fe3c39194..d3e408065 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp @@ -257,8 +257,8 @@ bool KeyboardMouseInput::IsMouseButtonReleased(int button) const void KeyboardMouseInput::ConsumeMouseDelta(float &dx, float &dy) { - dx = (float)m_mouseDeltaAccumX; - dy = (float)m_mouseDeltaAccumY; + dx = static_cast(m_mouseDeltaAccumX); + dy = static_cast(m_mouseDeltaAccumY); m_mouseDeltaAccumX = 0; m_mouseDeltaAccumY = 0; } @@ -375,12 +375,12 @@ float KeyboardMouseInput::GetMoveY() const float KeyboardMouseInput::GetLookX(float sensitivity) const { - return (float)m_mouseDeltaX * sensitivity; + return static_cast(m_mouseDeltaX) * sensitivity; } float KeyboardMouseInput::GetLookY(float sensitivity) const { - return (float)(-m_mouseDeltaY) * sensitivity; + return static_cast(-m_mouseDeltaY) * sensitivity; } void KeyboardMouseInput::OnChar(wchar_t c) diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp index ca1d62af7..fde78e308 100644 --- a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp +++ b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp @@ -189,7 +189,7 @@ bool WinsockNetLayer::HostGame(int port, const char* bindIp) int opt = 1; setsockopt(s_listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&opt, sizeof(opt)); - iResult = ::bind(s_listenSocket, result->ai_addr, (int)result->ai_addrlen); + iResult = ::bind(s_listenSocket, result->ai_addr, static_cast(result->ai_addrlen)); freeaddrinfo(result); if (iResult == SOCKET_ERROR) { @@ -267,7 +267,7 @@ bool WinsockNetLayer::JoinGame(const char* ip, int port) int noDelay = 1; setsockopt(s_hostConnectionSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&noDelay, sizeof(noDelay)); - iResult = connect(s_hostConnectionSocket, result->ai_addr, (int)result->ai_addrlen); + iResult = connect(s_hostConnectionSocket, result->ai_addr, static_cast(result->ai_addrlen)); if (iResult == SOCKET_ERROR) { int err = WSAGetLastError(); @@ -318,10 +318,10 @@ bool WinsockNetLayer::SendOnSocket(SOCKET sock, const void* data, int dataSize) EnterCriticalSection(&s_sendLock); BYTE header[4]; - header[0] = (BYTE)((dataSize >> 24) & 0xFF); - header[1] = (BYTE)((dataSize >> 16) & 0xFF); - header[2] = (BYTE)((dataSize >> 8) & 0xFF); - header[3] = (BYTE)(dataSize & 0xFF); + header[0] = static_cast((dataSize >> 24) & 0xFF); + header[1] = static_cast((dataSize >> 16) & 0xFF); + header[2] = static_cast((dataSize >> 8) & 0xFF); + header[3] = static_cast(dataSize & 0xFF); int totalSent = 0; int toSend = 4; @@ -339,7 +339,7 @@ bool WinsockNetLayer::SendOnSocket(SOCKET sock, const void* data, int dataSize) totalSent = 0; while (totalSent < dataSize) { - int sent = send(sock, (const char*)data + totalSent, dataSize - totalSent, 0); + int sent = send(sock, static_cast(data) + totalSent, dataSize - totalSent, 0); if (sent == SOCKET_ERROR || sent == 0) { LeaveCriticalSection(&s_sendLock); @@ -477,7 +477,7 @@ DWORD WINAPI WinsockNetLayer::AcceptThreadProc(LPVOID param) EnterCriticalSection(&s_connectionsLock); s_connections.push_back(conn); - int connIdx = (int)s_connections.size() - 1; + int connIdx = static_cast(s_connections.size()) - 1; LeaveCriticalSection(&s_connectionsLock); app.DebugPrintf("Win64 LAN: Client connected, assigned smallId=%d\n", assignedSmallId); @@ -495,7 +495,7 @@ DWORD WINAPI WinsockNetLayer::AcceptThreadProc(LPVOID param) HANDLE hThread = CreateThread(NULL, 0, RecvThreadProc, threadParam, 0, NULL); EnterCriticalSection(&s_connectionsLock); - if (connIdx < (int)s_connections.size()) + if (connIdx < static_cast(s_connections.size())) s_connections[connIdx].recvThread = hThread; LeaveCriticalSection(&s_connectionsLock); } @@ -504,11 +504,11 @@ DWORD WINAPI WinsockNetLayer::AcceptThreadProc(LPVOID param) DWORD WINAPI WinsockNetLayer::RecvThreadProc(LPVOID param) { - DWORD connIdx = *(DWORD*)param; - delete (DWORD*)param; + DWORD connIdx = *static_cast(param); + delete static_cast(param); EnterCriticalSection(&s_connectionsLock); - if (connIdx >= (DWORD)s_connections.size()) + if (connIdx >= static_cast(s_connections.size())) { LeaveCriticalSection(&s_connectionsLock); return 0; @@ -530,10 +530,10 @@ DWORD WINAPI WinsockNetLayer::RecvThreadProc(LPVOID param) } int packetSize = - ((uint32_t)header[0] << 24) | - ((uint32_t)header[1] << 16) | - ((uint32_t)header[2] << 8) | - ((uint32_t)header[3]); + (static_cast(header[0]) << 24) | + (static_cast(header[1]) << 16) | + (static_cast(header[2]) << 8) | + static_cast(header[3]); if (packetSize <= 0 || packetSize > WIN64_NET_MAX_PACKET_SIZE) { @@ -544,7 +544,7 @@ DWORD WINAPI WinsockNetLayer::RecvThreadProc(LPVOID param) break; } - if ((int)recvBuf.size() < packetSize) + if (static_cast(recvBuf.size()) < packetSize) { recvBuf.resize(packetSize); app.DebugPrintf("Win64 LAN: Resized host recv buffer to %d bytes for client smallId=%d\n", packetSize, clientSmallId); @@ -643,7 +643,7 @@ DWORD WINAPI WinsockNetLayer::ClientRecvThreadProc(LPVOID param) break; } - if ((int)recvBuf.size() < packetSize) + if (static_cast(recvBuf.size()) < packetSize) { recvBuf.resize(packetSize); app.DebugPrintf("Win64 LAN: Resized client recv buffer to %d bytes\n", packetSize); @@ -671,7 +671,7 @@ bool WinsockNetLayer::StartAdvertising(int gamePort, const wchar_t* hostName, un memset(&s_advertiseData, 0, sizeof(s_advertiseData)); s_advertiseData.magic = WIN64_LAN_BROADCAST_MAGIC; s_advertiseData.netVersion = netVer; - s_advertiseData.gamePort = (WORD)gamePort; + s_advertiseData.gamePort = static_cast(gamePort); wcsncpy_s(s_advertiseData.hostName, 32, hostName, _TRUNCATE); s_advertiseData.playerCount = 1; s_advertiseData.maxPlayers = MINECRAFT_NET_MAX_PLAYERS; @@ -846,7 +846,7 @@ DWORD WINAPI WinsockNetLayer::DiscoveryThreadProc(LPVOID param) continue; } - if (recvLen < (int)sizeof(Win64LANBroadcast)) + if (recvLen < static_cast(sizeof(Win64LANBroadcast))) continue; Win64LANBroadcast* broadcast = (Win64LANBroadcast*)recvBuf; @@ -864,7 +864,7 @@ DWORD WINAPI WinsockNetLayer::DiscoveryThreadProc(LPVOID param) for (size_t i = 0; i < s_discoveredSessions.size(); i++) { if (strcmp(s_discoveredSessions[i].hostIP, senderIP) == 0 && - s_discoveredSessions[i].hostPort == (int)broadcast->gamePort) + s_discoveredSessions[i].hostPort == static_cast(broadcast->gamePort)) { s_discoveredSessions[i].netVersion = broadcast->netVersion; wcsncpy_s(s_discoveredSessions[i].hostName, 32, broadcast->hostName, _TRUNCATE); @@ -885,7 +885,7 @@ DWORD WINAPI WinsockNetLayer::DiscoveryThreadProc(LPVOID param) Win64LANSession session; memset(&session, 0, sizeof(session)); strncpy_s(session.hostIP, sizeof(session.hostIP), senderIP, _TRUNCATE); - session.hostPort = (int)broadcast->gamePort; + session.hostPort = static_cast(broadcast->gamePort); session.netVersion = broadcast->netVersion; wcsncpy_s(session.hostName, 32, broadcast->hostName, _TRUNCATE); session.playerCount = broadcast->playerCount; diff --git a/Minecraft.Client/Windows64/Windows64_App.cpp b/Minecraft.Client/Windows64/Windows64_App.cpp index ad9e1f24a..70e61f035 100644 --- a/Minecraft.Client/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Windows64/Windows64_App.cpp @@ -125,7 +125,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = static_cast(param); // Reset the autosave time app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/Windows64/Windows64_App.h b/Minecraft.Client/Windows64/Windows64_App.h index bff916ec7..af3192e2f 100644 --- a/Minecraft.Client/Windows64/Windows64_App.h +++ b/Minecraft.Client/Windows64/Windows64_App.h @@ -25,7 +25,7 @@ class CConsoleMinecraftApp : public CMinecraftApp virtual int GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT=eFileExtensionType_PNG); // BANNED LEVEL LIST - virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {} + virtual void ReadBannedList(int iPad, eTMSAction action=static_cast(0), bool bCallback=false) {} C4JStringTable *GetStringTable() { return NULL;} diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 2eef5f737..ed62daa13 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -121,14 +121,14 @@ static void CopyWideArgToAnsi(LPCWSTR source, char* dest, size_t destSize) if (source == NULL) return; - WideCharToMultiByte(CP_ACP, 0, source, -1, dest, (int)destSize, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, source, -1, dest, static_cast(destSize), NULL, NULL); dest[destSize - 1] = 0; } // ---------- Persistent options (options.txt next to exe) ---------- static void GetOptionsFilePath(char *out, size_t outSize) { - GetModuleFileNameA(NULL, out, (DWORD)outSize); + GetModuleFileNameA(NULL, out, static_cast(outSize)); char *p = strrchr(out, '\\'); if (p) *(p + 1) = '\0'; strncat_s(out, outSize, "options.txt", _TRUNCATE); @@ -251,9 +251,9 @@ static Win64LaunchOptions ParseLaunchOptions() if (endPtr != argv[i] && *endPtr == 0 && port > 0 && port <= 65535) { if (options.serverMode) - g_Win64DedicatedServerPort = (int)port; + g_Win64DedicatedServerPort = static_cast(port); else - g_Win64MultiplayerPort = (int)port; + g_Win64MultiplayerPort = static_cast(port); } } } @@ -568,13 +568,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CHAR: // Buffer typed characters so UIScene_Keyboard can dispatch them to the Iggy Flash player if (wParam >= 0x20 || wParam == 0x08 || wParam == 0x0D) // printable chars + backspace + enter - g_KBMInput.OnChar((wchar_t)wParam); + g_KBMInput.OnChar(static_cast(wParam)); break; case WM_KEYDOWN: case WM_SYSKEYDOWN: { - int vk = (int)wParam; + int vk = static_cast(wParam); if (lParam & 0x40000000) break; // ignore auto-repeat if (vk == VK_SHIFT) vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT; @@ -588,7 +588,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_KEYUP: case WM_SYSKEYUP: { - int vk = (int)wParam; + int vk = static_cast(wParam); if (vk == VK_SHIFT) vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT; else if (vk == VK_CONTROL) @@ -871,8 +871,8 @@ HRESULT InitDevice() // Setup the viewport D3D11_VIEWPORT vp; - vp.Width = (FLOAT)width; - vp.Height = (FLOAT)height; + vp.Width = static_cast(width); + vp.Height = static_cast(height); vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; vp.TopLeftX = 0; @@ -975,7 +975,7 @@ static Minecraft* InitialiseMinecraftRuntime() for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++) { - IQNet::m_player[i].m_smallId = (BYTE)i; + IQNet::m_player[i].m_smallId = static_cast(i); IQNet::m_player[i].m_isRemote = false; IQNet::m_player[i].m_isHostPlayer = (i == 0); swprintf_s(IQNet::m_player[i].m_gamertag, 32, L"Player%d", i); @@ -1200,7 +1200,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, char buf[128] = {}; if (fgets(buf, sizeof(buf), f)) { - int len = (int)strlen(buf); + int len = static_cast(strlen(buf)); while (len > 0 && (buf[len - 1] == '\n' || buf[len - 1] == '\r' || buf[len - 1] == ' ')) { buf[--len] = '\0'; diff --git a/Minecraft.Client/Windows64/Windows64_UIController.cpp b/Minecraft.Client/Windows64/Windows64_UIController.cpp index 10ae20aff..b76b724a2 100644 --- a/Minecraft.Client/Windows64/Windows64_UIController.cpp +++ b/Minecraft.Client/Windows64/Windows64_UIController.cpp @@ -163,7 +163,7 @@ GDrawTexture *ConsoleUIController::getSubstitutionTexture(int textureId) ID3D11ShaderResourceView *tex = RenderManager.TextureGetTexture(textureId); ID3D11Resource *resource; tex->GetResource(&resource); - ID3D11Texture2D *tex2d = (ID3D11Texture2D *)resource; + ID3D11Texture2D *tex2d = static_cast(resource); D3D11_TEXTURE2D_DESC desc; tex2d->GetDesc(&desc); GDrawTexture *gdrawTex = gdraw_D3D11_WrappedTextureCreate(tex); diff --git a/Minecraft.Client/WitherBossRenderer.cpp b/Minecraft.Client/WitherBossRenderer.cpp index 254a00bc7..e358c6dab 100644 --- a/Minecraft.Client/WitherBossRenderer.cpp +++ b/Minecraft.Client/WitherBossRenderer.cpp @@ -48,7 +48,7 @@ void WitherBossRenderer::scale(shared_ptr _mob, float a) int inTicks = mob->getInvulnerableTicks(); if (inTicks > 0) { - float scale = 2.0f - (((float) inTicks - a) / (SharedConstants::TICKS_PER_SECOND * 11)) * .5f; + float scale = 2.0f - ((static_cast(inTicks) - a) / (SharedConstants::TICKS_PER_SECOND * 11)) * .5f; glScalef(scale, scale, scale); } else diff --git a/Minecraft.Client/WitherSkullRenderer.cpp b/Minecraft.Client/WitherSkullRenderer.cpp index 878735740..5f08b5b67 100644 --- a/Minecraft.Client/WitherSkullRenderer.cpp +++ b/Minecraft.Client/WitherSkullRenderer.cpp @@ -19,7 +19,7 @@ void WitherSkullRenderer::render(shared_ptr entity, double x, double y, float headRot = rotlerp(entity->yRotO, entity->yRot, a); float headRotx = entity->xRotO + (entity->xRot - entity->xRotO) * a; - glTranslatef((float) x, (float) y, (float) z); + glTranslatef(static_cast(x), static_cast(y), static_cast(z)); float scale = 1 / 16.0f; glEnable(GL_RESCALE_NORMAL); diff --git a/Minecraft.Client/Xbox/Audio/SoundEngine.cpp b/Minecraft.Client/Xbox/Audio/SoundEngine.cpp index b088150c9..97eb0658e 100644 --- a/Minecraft.Client/Xbox/Audio/SoundEngine.cpp +++ b/Minecraft.Client/Xbox/Audio/SoundEngine.cpp @@ -420,7 +420,7 @@ void SoundEngine::XACTNotificationCallback( const XACT_NOTIFICATION* pNotificati { if(pNotification->type==XACTNOTIFICATIONTYPE_WAVEBANKPREPARED) { - SoundEngine *pSoundEngine=(SoundEngine *)pNotification->pvContext; + SoundEngine *pSoundEngine=static_cast(pNotification->pvContext); if(pNotification->waveBank.pWaveBank==pSoundEngine->m_pStreamedWaveBank) { pSoundEngine->m_bStreamingWaveBank1Ready=true; @@ -446,7 +446,7 @@ char *SoundEngine::ConvertSoundPathToName(const wstring& name, bool bConvertSpac { wchar_t c = name[i]; if(c=='.') c='_'; - buf[i] = (char)c; + buf[i] = static_cast(c); } buf[name.length()] = 0; return buf; @@ -541,7 +541,7 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume, floa soundInfo *info = new soundInfo(); info->idx = idx; - info->eSoundID = (eSOUND_TYPE)iSound; + info->eSoundID = static_cast(iSound); info->iSoundBank = bSoundbank1?0:1; info->x = x; info->y = y; @@ -578,7 +578,7 @@ void SoundEngine::playUI(int iSound, float, float) } wstring name = wchSoundNames[iSound]; - char *xboxName = (char *)ConvertSoundPathToName(name); + char *xboxName = static_cast(ConvertSoundPathToName(name)); XACTINDEX idx = m_pSoundBank->GetCueIndex(xboxName); @@ -618,7 +618,7 @@ void SoundEngine::playUI(int iSound, float, float) // Add sound info just so we can detect end of this sound soundInfo *info = new soundInfo(); - info->eSoundID = (eSOUND_TYPE)0; + info->eSoundID = static_cast(0); info->iSoundBank = bSoundBank1?0:1; info->idx =idx; info->x = 0.0f; @@ -701,7 +701,7 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z, else { // get the dlc texture pack - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexPack; + DLCTexturePack *pDLCTexPack=static_cast(pTexPack); pSoundBank=pDLCTexPack->m_pSoundBank; // check we can play the sound @@ -999,9 +999,9 @@ void SoundEngine::tick(shared_ptr *players, float a) { float yRot = players[i]->yRotO + (players[i]->yRot - players[i]->yRotO) * a; - m_listeners[listenerCount].Position.x = (float) (players[i]->xo + (players[i]->x - players[i]->xo) * a); - m_listeners[listenerCount].Position.y = (float) (players[i]->yo + (players[i]->y - players[i]->yo) * a); - m_listeners[listenerCount].Position.z = -(float) (players[i]->zo + (players[i]->z - players[i]->zo) * a); // Flipped sign of z as x3daudio is expecting left handed coord system + m_listeners[listenerCount].Position.x = static_cast(players[i]->xo + (players[i]->x - players[i]->xo) * a); + m_listeners[listenerCount].Position.y = static_cast(players[i]->yo + (players[i]->y - players[i]->yo) * a); + m_listeners[listenerCount].Position.z = -static_cast(players[i]->zo + (players[i]->z - players[i]->zo) * a); // Flipped sign of z as x3daudio is expecting left handed coord system float yCos = (float)cos(-yRot * Mth::RAD_TO_GRAD - PI); float ySin = (float)sin(-yRot * Mth::RAD_TO_GRAD - PI); diff --git a/Minecraft.Client/Xbox/Font/XUI_Font.cpp b/Minecraft.Client/Xbox/Font/XUI_Font.cpp index 8b1a624be..f4ae9d069 100644 --- a/Minecraft.Client/Xbox/Font/XUI_Font.cpp +++ b/Minecraft.Client/Xbox/Font/XUI_Font.cpp @@ -244,21 +244,21 @@ VOID XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, DWORD dwColor, { if(RenderManager.IsWidescreen()) { - int iScaleX=(int)m_fXScaleFactor; + int iScaleX=static_cast(m_fXScaleFactor); int iOriginX; if(iScaleX%2==0) { - iOriginX=(int)fOriginX; + iOriginX=static_cast(fOriginX); if(iOriginX%2==1) { fOriginX+=1.0f; } } - int iScaleY=(int)m_fYScaleFactor; + int iScaleY=static_cast(m_fYScaleFactor); int iOriginY; if(iScaleY%2==0) { - iOriginY=(int)fOriginY; + iOriginY=static_cast(fOriginY); if(iOriginY%2==1) { fOriginY+=1.0f; @@ -268,7 +268,7 @@ VOID XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, DWORD dwColor, else { // 480 SD mode - y needs to be on a pixel boundary when multiplied by 1.5, so if it's an odd number, subtract 1/3 from it - int iOriginY=(int)fOriginY; + int iOriginY=static_cast(fOriginY); if(iOriginY%2==1) { fOriginY-=1.0f/3.0f; @@ -415,8 +415,8 @@ VOID XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, DWORD dwColor, // Translate unprintable characters XUI_FontData::SChar sChar = m_fontData->getChar( letter ); - FLOAT fOffset = m_fXScaleFactor * ( FLOAT )sChar.getOffset(); - FLOAT fAdvance = m_fXScaleFactor * ( FLOAT )sChar.getWAdvance(); + FLOAT fOffset = m_fXScaleFactor * static_cast(sChar.getOffset()); + FLOAT fAdvance = m_fXScaleFactor * static_cast(sChar.getWAdvance()); // 4J Use the font max width otherwise scaling doesnt look right FLOAT fWidth = m_fXScaleFactor * (sChar.tu2() - sChar.tu1());//( FLOAT )pGlyph->wWidth; FLOAT fHeight = m_fYScaleFactor * m_fontData->getFontHeight(); @@ -450,10 +450,10 @@ VOID XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, DWORD dwColor, // Add the vertices to draw this glyph - FLOAT tu1 = sChar.tu1() / (float)m_fontData->getImageWidth(); - FLOAT tv1 = sChar.tv1() / (float)m_fontData->getImageHeight(); - FLOAT tu2 = sChar.tu2() / (float)m_fontData->getImageWidth(); - FLOAT tv2 = sChar.tv2() / (float)m_fontData->getImageHeight(); + FLOAT tu1 = sChar.tu1() / static_cast(m_fontData->getImageWidth()); + FLOAT tv1 = sChar.tv1() / static_cast(m_fontData->getImageHeight()); + FLOAT tu2 = sChar.tu2() / static_cast(m_fontData->getImageWidth()); + FLOAT tv2 = sChar.tv2() / static_cast(m_fontData->getImageHeight()); Tesselator *t = Tesselator::getInstance(); t->begin(); diff --git a/Minecraft.Client/Xbox/Font/XUI_FontData.cpp b/Minecraft.Client/Xbox/Font/XUI_FontData.cpp index 7a70cdfbb..d8d87547c 100644 --- a/Minecraft.Client/Xbox/Font/XUI_FontData.cpp +++ b/Minecraft.Client/Xbox/Font/XUI_FontData.cpp @@ -68,7 +68,7 @@ float XUI_FontData::SChar::getMinX() float XUI_FontData::SChar::getMaxX() { - return (float) m_parent->m_fontData->getFontData()->m_uiGlyphWidth; + return static_cast(m_parent->m_fontData->getFontData()->m_uiGlyphWidth); } float XUI_FontData::SChar::getMinY() @@ -83,7 +83,7 @@ float XUI_FontData::SChar::getMaxY() float XUI_FontData::SChar::getAdvance() { - return (float) m_parent->m_fontData->getWidth(m_glyphId); + return static_cast(m_parent->m_fontData->getWidth(m_glyphId)); } int XUI_FontData::SChar::getGlyphId() diff --git a/Minecraft.Client/Xbox/Font/XUI_FontRenderer.cpp b/Minecraft.Client/Xbox/Font/XUI_FontRenderer.cpp index d708af791..5fff04db6 100644 --- a/Minecraft.Client/Xbox/Font/XUI_FontRenderer.cpp +++ b/Minecraft.Client/Xbox/Font/XUI_FontRenderer.cpp @@ -50,7 +50,7 @@ HRESULT XUI_FontRenderer::CreateFont( const TypefaceDescriptor * pTypefaceDescri //float fXuiSize = fPointSize * ( 16.0f / 16.0f ); fXuiSize /= 4.0f; fXuiSize = floor( fXuiSize ); - int xuiSize = (int)(fXuiSize * 4.0f); + int xuiSize = static_cast(fXuiSize * 4.0f); if( xuiSize < 1 ) xuiSize = 8; // 4J Stu - We have fonts based on multiples of 8 or 12 @@ -101,13 +101,13 @@ HRESULT XUI_FontRenderer::CreateFont( const TypefaceDescriptor * pTypefaceDescri } font->IncRefCount(); - *phFont = (HFONTOBJ)font; + *phFont = static_cast(font); return S_OK; } VOID XUI_FontRenderer::ReleaseFont( HFONTOBJ hFont ) { - XUI_Font *xuiFont = (XUI_Font*) hFont; + XUI_Font *xuiFont = static_cast(hFont); if (xuiFont != NULL) { xuiFont->DecRefCount(); @@ -125,7 +125,7 @@ HRESULT XUI_FontRenderer::GetFontMetrics( HFONTOBJ hFont, XUIFontMetrics *pFontM { if( hFont == 0 || pFontMetrics == 0 ) return E_INVALIDARG; - XUI_Font *font = (XUI_Font *)hFont; + XUI_Font *font = static_cast(hFont); pFontMetrics->fLineHeight = (font->m_fontData->getFontYAdvance() + 1) * font->m_fYScaleFactor; pFontMetrics->fMaxAscent = font->m_fontData->getMaxAscent() * font->m_fYScaleFactor; @@ -142,7 +142,7 @@ HRESULT XUI_FontRenderer::GetCharMetrics( HFONTOBJ hFont, WCHAR wch, XUICharMetr { if (hFont == 0 || pCharMetrics == 0) return E_INVALIDARG; - XUI_Font *font = (XUI_Font *)hFont; + XUI_Font *font = static_cast(hFont); XUI_FontData::SChar sChar = font->m_fontData->getChar(wch); pCharMetrics->fMinX = sChar.getMinX() * font->m_fYScaleFactor; @@ -169,7 +169,7 @@ HRESULT XUI_FontRenderer::DrawCharsToDevice( HFONTOBJ hFont, CharData * pCharDat DWORD SamplerStateA[5]; XMVECTOR vconsts[20]; XMVECTOR pconsts[20]; - XUI_Font *font = (XUI_Font *)hFont; + XUI_Font *font = static_cast(hFont); // 4J-PB - if we're in 480 Widescreen mode, we need to ensure that the font characters are aligned on an even boundary if they are a 2x multiple if(!RenderManager.IsHiDef()) @@ -184,19 +184,19 @@ HRESULT XUI_FontRenderer::DrawCharsToDevice( HFONTOBJ hFont, CharData * pCharDat if(iScaleX%2==0) { int iWorldX=pWorldViewProj->_41; - pWorldViewProj->_41 = (float)(iWorldX & -2); + pWorldViewProj->_41 = static_cast(iWorldX & -2); } if(iScaleY%2==0) { int iWorldY=pWorldViewProj->_42; - pWorldViewProj->_42 = (float)(iWorldY & -2); + pWorldViewProj->_42 = static_cast(iWorldY & -2); } } else { // make x an even number for 480 4:3 int iWorldX=pWorldViewProj->_41; - pWorldViewProj->_41 = (float)(iWorldX & -2); + pWorldViewProj->_41 = static_cast(iWorldX & -2); // 480 SD mode - y needs to be on a pixel boundary when multiplied by 1.5, so if it's an odd number, subtract 1/3 from it int iWorldY=pWorldViewProj->_42; diff --git a/Minecraft.Client/Xbox/Leaderboards/XboxLeaderboardManager.cpp b/Minecraft.Client/Xbox/Leaderboards/XboxLeaderboardManager.cpp index efa8a3dae..76fca0e48 100644 --- a/Minecraft.Client/Xbox/Leaderboards/XboxLeaderboardManager.cpp +++ b/Minecraft.Client/Xbox/Leaderboards/XboxLeaderboardManager.cpp @@ -192,7 +192,7 @@ bool XboxLeaderboardManager::WriteStats(unsigned int viewCount, ViewIn views) INetworkPlayer *player = g_NetworkManager.GetPlayerByXuid(m_myXUID); if(player != NULL) { - ret = ((NetworkPlayerXbox *)player)->GetQNetPlayer()->WriteStats(viewCount,views); + ret = static_cast(player)->GetQNetPlayer()->WriteStats(viewCount,views); //printf("Wrote stats to QNet player\n"); } else @@ -376,10 +376,10 @@ bool XboxLeaderboardManager::readStats(int difficulty, EStatsType type) //Setup the spec structure for the read request m_spec = new XUSER_STATS_SPEC[1]; - m_spec[0].dwViewId = LEADERBOARD_DESCRIPTORS[(int)type][difficulty].m_viewId; - m_spec[0].dwNumColumnIds = LEADERBOARD_DESCRIPTORS[(int)type][difficulty].m_columnCount; + m_spec[0].dwViewId = LEADERBOARD_DESCRIPTORS[static_cast(type)][difficulty].m_viewId; + m_spec[0].dwNumColumnIds = LEADERBOARD_DESCRIPTORS[static_cast(type)][difficulty].m_columnCount; for (unsigned int i=0; i(type)][difficulty].m_columnIds[i]; return true; } @@ -431,7 +431,7 @@ bool XboxLeaderboardManager::IsStatsReadComplete() int XboxLeaderboardManager::FriendSortFunction(const void* a, const void* b) { - return ((int)((XUSER_STATS_ROW*)a)->dwRank) - ((int)((XUSER_STATS_ROW*)b)->dwRank); + return static_cast(((XUSER_STATS_ROW *)a)->dwRank) - static_cast(((XUSER_STATS_ROW *)b)->dwRank); } void XboxLeaderboardManager::SortFriendStats() diff --git a/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp b/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp index 386a0206a..ea9ef39ea 100644 --- a/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp +++ b/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp @@ -17,7 +17,7 @@ void NetworkPlayerXbox::SendData(INetworkPlayer *player, const void *pvData, int DWORD flags; flags = QNET_SENDDATA_RELIABLE | QNET_SENDDATA_SEQUENTIAL; if( lowPriority ) flags |= QNET_SENDDATA_LOW_PRIORITY | QNET_SENDDATA_SECONDARY; - m_qnetPlayer->SendData(((NetworkPlayerXbox *)player)->m_qnetPlayer, pvData, dataSize, flags); + m_qnetPlayer->SendData(static_cast(player)->m_qnetPlayer, pvData, dataSize, flags); } int NetworkPlayerXbox::GetOutstandingAckCount() @@ -27,21 +27,21 @@ int NetworkPlayerXbox::GetOutstandingAckCount() bool NetworkPlayerXbox::IsSameSystem(INetworkPlayer *player) { - return ( m_qnetPlayer->IsSameSystem(((NetworkPlayerXbox *)player)->m_qnetPlayer) == TRUE ); + return ( m_qnetPlayer->IsSameSystem(static_cast(player)->m_qnetPlayer) == TRUE ); } int NetworkPlayerXbox::GetSendQueueSizeBytes( INetworkPlayer *player, bool lowPriority ) { DWORD flags = QNET_GETSENDQUEUESIZE_BYTES; if( lowPriority ) flags |= QNET_GETSENDQUEUESIZE_SECONDARY_TYPE; - return m_qnetPlayer->GetSendQueueSize(player ? ((NetworkPlayerXbox *)player)->m_qnetPlayer : NULL , flags); + return m_qnetPlayer->GetSendQueueSize(player ? static_cast(player)->m_qnetPlayer : NULL , flags); } int NetworkPlayerXbox::GetSendQueueSizeMessages( INetworkPlayer *player, bool lowPriority ) { DWORD flags = QNET_GETSENDQUEUESIZE_MESSAGES; if( lowPriority ) flags |= QNET_GETSENDQUEUESIZE_SECONDARY_TYPE; - return m_qnetPlayer->GetSendQueueSize(player ? ((NetworkPlayerXbox *)player)->m_qnetPlayer : NULL , flags); + return m_qnetPlayer->GetSendQueueSize(player ? static_cast(player)->m_qnetPlayer : NULL , flags); } int NetworkPlayerXbox::GetCurrentRtt() @@ -138,5 +138,5 @@ int NetworkPlayerXbox::GetTimeSinceLastChunkPacket_ms() } __int64 currentTime = System::currentTimeMillis(); - return (int)( currentTime - m_lastChunkPacketTime ); + return static_cast(currentTime - m_lastChunkPacketTime); } \ No newline at end of file diff --git a/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.cpp b/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.cpp index 473171463..882137eb8 100644 --- a/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.cpp +++ b/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.cpp @@ -109,7 +109,7 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerJoined( bool createFakeSocket = false; bool localPlayer = false; - NetworkPlayerXbox *networkPlayer = (NetworkPlayerXbox *)addNetworkPlayer(pQNetPlayer); + NetworkPlayerXbox *networkPlayer = static_cast(addNetworkPlayer(pQNetPlayer)); if( pQNetPlayer->IsLocal() ) { @@ -380,7 +380,7 @@ VOID CPlatformNetworkManagerXbox::NotifyReadinessChanged( __in BOOL bReady ) { - app.DebugPrintf( "Player 0x%p readiness is now %i.\n", pQNetPlayer, (int) bReady ); + app.DebugPrintf( "Player 0x%p readiness is now %i.\n", pQNetPlayer, static_cast(bReady) ); } @@ -946,7 +946,7 @@ void CPlatformNetworkManagerXbox::UpdateAndSetGameSessionData(INetworkPlayer *pN // We can call this from NotifyPlayerLeaving but at that point the player is still considered in the session if( pNetworkPlayer != pNetworkPlayerLeaving ) { - m_hostGameSessionData.players[i] = ((NetworkPlayerXbox *)pNetworkPlayer)->GetUID(); + m_hostGameSessionData.players[i] = static_cast(pNetworkPlayer)->GetUID(); char *temp; temp = (char *)wstringtofilename( pNetworkPlayer->GetOnlineName() ); @@ -965,7 +965,7 @@ void CPlatformNetworkManagerXbox::UpdateAndSetGameSessionData(INetworkPlayer *pN } } - m_hostGameSessionData.hostPlayerUID = ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetXuid(); + m_hostGameSessionData.hostPlayerUID = static_cast(GetHostPlayer())->GetQNetPlayer()->GetXuid(); m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All); HRESULT hr = S_OK; @@ -978,7 +978,7 @@ void CPlatformNetworkManagerXbox::UpdateAndSetGameSessionData(INetworkPlayer *pN int CPlatformNetworkManagerXbox::RemovePlayerOnSocketClosedThreadProc( void* lpParam ) { - INetworkPlayer *pNetworkPlayer = (INetworkPlayer *)lpParam; + INetworkPlayer *pNetworkPlayer = static_cast(lpParam); Socket *socket = pNetworkPlayer->GetSocket(); @@ -1099,8 +1099,8 @@ bool CPlatformNetworkManagerXbox::SystemFlagGet(INetworkPlayer *pNetworkPlayer, wstring CPlatformNetworkManagerXbox::GatherStats() { - return L"Queue messages: " + std::to_wstring(((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_MESSAGES ) ) - + L" Queue bytes: " + std::to_wstring( ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES ) ); + return L"Queue messages: " + std::to_wstring(static_cast(GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_MESSAGES ) ) + + L" Queue bytes: " + std::to_wstring( static_cast(GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES ) ); } wstring CPlatformNetworkManagerXbox::GatherRTTStats() @@ -1111,7 +1111,7 @@ wstring CPlatformNetworkManagerXbox::GatherRTTStats() for(unsigned int i = 0; i < GetPlayerCount(); ++i) { - IQNetPlayer *pQNetPlayer = ((NetworkPlayerXbox *)GetPlayerByIndex( i ))->GetQNetPlayer(); + IQNetPlayer *pQNetPlayer = static_cast(GetPlayerByIndex(i))->GetQNetPlayer(); if(!pQNetPlayer->IsLocal()) { @@ -1386,7 +1386,7 @@ void CPlatformNetworkManagerXbox::SearchForGames() int CPlatformNetworkManagerXbox::SearchForGamesThreadProc( void* lpParameter ) { - SearchForGamesData *threadData = (SearchForGamesData *)lpParameter; + SearchForGamesData *threadData = static_cast(lpParameter); DWORD sessionIDCount = threadData->sessionIDCount; diff --git a/Minecraft.Client/Xbox/Sentient/DynamicConfigurations.cpp b/Minecraft.Client/Xbox/Sentient/DynamicConfigurations.cpp index 5d2b97631..327e094c9 100644 --- a/Minecraft.Client/Xbox/Sentient/DynamicConfigurations.cpp +++ b/Minecraft.Client/Xbox/Sentient/DynamicConfigurations.cpp @@ -43,7 +43,7 @@ void MinecraftDynamicConfigurations::UpdateNextConfiguration() { if(!s_bUpdatedConfigs[i]) { - update = (EDynamic_Configs)i; + update = static_cast(i); break; } } diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientResource.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientResource.h index e8405d5e1..b749a1640 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientResource.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientResource.h @@ -45,10 +45,10 @@ namespace Sentient enum SenResourceID : INT32 { /// This is used to indicate a failed search, an invalid resource structure, or sometimes to substitute for a default. - SenResourceID_Invalid = (INT32)SenResourceType_Invalid << 24, + SenResourceID_Invalid = static_cast(SenResourceType_Invalid) << 24, /// This is the first VIP reward costume and there is one for each title. - SenResourceID_Superstar_0 = (INT32)SenResourceType_Avatar << 24, + SenResourceID_Superstar_0 = static_cast(SenResourceType_Avatar) << 24, /// This is the second VIP reward costume and there is one for each title. SenResourceID_Superstar_1, /// This is the third VIP reward costume and there is one for each title. @@ -59,15 +59,15 @@ namespace Sentient SenResourceID_Superstar_4, /// This is used for the cross-sell screen and contains things such as an image, offerID, strings, etc. - SenResourceID_BoxArt_0 = (INT32)SenResourceType_BoxArt << 24, + SenResourceID_BoxArt_0 = static_cast(SenResourceType_BoxArt) << 24, /// This is used for game-private config files, and is only the base of the range. /// Titles may use the entire 24-bit space for various custom config files. - SenResourceID_Config_0 = (INT32)SenResourceType_Config << 24, + SenResourceID_Config_0 = static_cast(SenResourceType_Config) << 24, /// This is used for server-supplied help files/text. /// At the moment, this is not supported. - SenResourceID_Help_0 = (INT32)SenResourceType_Help << 24, + SenResourceID_Help_0 = static_cast(SenResourceType_Help) << 24, }; diff --git a/Minecraft.Client/Xbox/Sentient/SentientManager.cpp b/Minecraft.Client/Xbox/Sentient/SentientManager.cpp index aade06bca..bf48c400a 100644 --- a/Minecraft.Client/Xbox/Sentient/SentientManager.cpp +++ b/Minecraft.Client/Xbox/Sentient/SentientManager.cpp @@ -20,7 +20,7 @@ CTelemetryManager *TelemetryManager = new CSentientManager(); HRESULT CSentientManager::Init() { Sentient::SenSysTitleID sentitleID; - sentitleID = (Sentient::SenSysTitleID)TITLEID_MINECRAFT; + sentitleID = static_cast(TITLEID_MINECRAFT); HRESULT hr = SentientInitialize( sentitleID ); @@ -123,7 +123,7 @@ HRESULT CSentientManager::Flush() BOOL CSentientManager::RecordPlayerSessionStart(DWORD dwUserId) { - return SenStatPlayerSessionStart( dwUserId, GetSecondsSinceInitialize(), GetMode(dwUserId), GetSubMode(dwUserId), GetLevelId(dwUserId), GetSubLevelId(dwUserId), GetTitleBuildId(), 0, 0, 0, (INT)app.getDeploymentType() ); + return SenStatPlayerSessionStart( dwUserId, GetSecondsSinceInitialize(), GetMode(dwUserId), GetSubMode(dwUserId), GetLevelId(dwUserId), GetSubLevelId(dwUserId), GetTitleBuildId(), 0, 0, 0, static_cast(app.getDeploymentType()) ); } BOOL CSentientManager::RecordPlayerSessionExit(DWORD dwUserId, int _) @@ -149,13 +149,13 @@ BOOL CSentientManager::RecordLevelStart(DWORD dwUserId, ESen_FriendOrMatch frien BOOL CSentientManager::RecordLevelExit(DWORD dwUserId, ESen_LevelExitStatus levelExitStatus) { float levelDuration = app.getAppTime() - m_fLevelStartTime[dwUserId]; - return SenStatLevelExit( dwUserId, GetSecondsSinceInitialize(), GetMode(dwUserId), GetSubMode(dwUserId), GetLevelId(dwUserId), GetSubLevelId(dwUserId), GetLevelInstanceID(), GetMultiplayerInstanceID(), levelExitStatus, GetLevelExitProgressStat1(), GetLevelExitProgressStat2(), (INT)levelDuration ); + return SenStatLevelExit( dwUserId, GetSecondsSinceInitialize(), GetMode(dwUserId), GetSubMode(dwUserId), GetLevelId(dwUserId), GetSubLevelId(dwUserId), GetLevelInstanceID(), GetMultiplayerInstanceID(), levelExitStatus, GetLevelExitProgressStat1(), GetLevelExitProgressStat2(), static_cast(levelDuration) ); } BOOL CSentientManager::RecordLevelSaveOrCheckpoint(DWORD dwUserId, INT saveOrCheckPointID, INT saveSizeInBytes) { float levelDuration = app.getAppTime() - m_fLevelStartTime[dwUserId]; - return SenStatLevelSaveOrCheckpoint( dwUserId, GetSecondsSinceInitialize(), GetMode(dwUserId), GetSubMode(dwUserId), GetLevelId(dwUserId), GetSubLevelId(dwUserId), GetLevelInstanceID(), GetMultiplayerInstanceID(), GetLevelExitProgressStat1(), GetLevelExitProgressStat2(), (INT)levelDuration, saveOrCheckPointID, saveSizeInBytes ); + return SenStatLevelSaveOrCheckpoint( dwUserId, GetSecondsSinceInitialize(), GetMode(dwUserId), GetSubMode(dwUserId), GetLevelId(dwUserId), GetSubLevelId(dwUserId), GetLevelInstanceID(), GetMultiplayerInstanceID(), GetLevelExitProgressStat1(), GetLevelExitProgressStat2(), static_cast(levelDuration), saveOrCheckPointID, saveSizeInBytes ); } BOOL CSentientManager::RecordLevelResume(DWORD dwUserId, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, DWORD numberOfLocalPlayers, DWORD numberOfOnlinePlayers, INT saveOrCheckPointID) @@ -240,7 +240,7 @@ This should be tracked independently of saved games (restoring a save should not */ INT CSentientManager::GetSecondsSinceInitialize() { - return (INT)(app.getAppTime() - m_initialiseTime); + return static_cast(app.getAppTime() - m_initialiseTime); } /* @@ -263,15 +263,15 @@ INT CSentientManager::GetMode(DWORD dwUserId) if (gameType->isSurvival()) { - mode = (INT)eTelem_ModeId_Survival; + mode = static_cast(eTelem_ModeId_Survival); } else if (gameType->isCreative()) { - mode = (INT)eTelem_ModeId_Creative; + mode = static_cast(eTelem_ModeId_Creative); } else { - mode = (INT)eTelem_ModeId_Undefined; + mode = static_cast(eTelem_ModeId_Undefined); } } return mode; @@ -290,11 +290,11 @@ INT CSentientManager::GetSubMode(DWORD dwUserId) if(Minecraft::GetInstance()->isTutorial()) { - subMode = (INT)eTelem_SubModeId_Tutorial; + subMode = static_cast(eTelem_SubModeId_Tutorial); } else { - subMode = (INT)eTelem_SubModeId_Normal; + subMode = static_cast(eTelem_SubModeId_Normal); } return subMode; @@ -312,7 +312,7 @@ INT CSentientManager::GetLevelId(DWORD dwUserId) { INT levelId = (INT)eTelem_LevelId_Undefined; - levelId = (INT)eTelem_LevelId_PlayerGeneratedLevel; + levelId = static_cast(eTelem_LevelId_PlayerGeneratedLevel); return levelId; } @@ -334,13 +334,13 @@ INT CSentientManager::GetSubLevelId(DWORD dwUserId) switch(pMinecraft->localplayers[dwUserId]->dimension) { case 0: - subLevelId = (INT)eTelem_SubLevelId_Overworld; + subLevelId = static_cast(eTelem_SubLevelId_Overworld); break; case -1: - subLevelId = (INT)eTelem_SubLevelId_Nether; + subLevelId = static_cast(eTelem_SubLevelId_Nether); break; case 1: - subLevelId = (INT)eTelem_SubLevelId_End; + subLevelId = static_cast(eTelem_SubLevelId_End); break; }; } @@ -364,7 +364,7 @@ Helps differentiate level attempts when a play plays the same mode/level - espec */ INT CSentientManager::GetLevelInstanceID() { - return (INT)m_levelInstanceID; + return static_cast(m_levelInstanceID); } /* @@ -403,19 +403,19 @@ INT CSentientManager::GetSingleOrMultiplayer() if(app.GetLocalPlayerCount() == 1 && g_NetworkManager.GetOnlinePlayerCount() == 0) { - singleOrMultiplayer = (INT)eSen_SingleOrMultiplayer_Single_Player; + singleOrMultiplayer = static_cast(eSen_SingleOrMultiplayer_Single_Player); } else if(app.GetLocalPlayerCount() > 1 && g_NetworkManager.GetOnlinePlayerCount() == 0) { - singleOrMultiplayer = (INT)eSen_SingleOrMultiplayer_Multiplayer_Local; + singleOrMultiplayer = static_cast(eSen_SingleOrMultiplayer_Multiplayer_Local); } else if(app.GetLocalPlayerCount() == 1 && g_NetworkManager.GetOnlinePlayerCount() > 0) { - singleOrMultiplayer = (INT)eSen_SingleOrMultiplayer_Multiplayer_Live; + singleOrMultiplayer = static_cast(eSen_SingleOrMultiplayer_Multiplayer_Live); } else if(app.GetLocalPlayerCount() > 1 && g_NetworkManager.GetOnlinePlayerCount() > 0) { - singleOrMultiplayer = (INT)eSen_SingleOrMultiplayer_Multiplayer_Both_Local_and_Live; + singleOrMultiplayer = static_cast(eSen_SingleOrMultiplayer_Multiplayer_Both_Local_and_Live); } return singleOrMultiplayer; @@ -432,16 +432,16 @@ INT CSentientManager::GetDifficultyLevel(INT diff) switch(diff) { case 0: - difficultyLevel = (INT)eSen_DifficultyLevel_Easiest; + difficultyLevel = static_cast(eSen_DifficultyLevel_Easiest); break; case 1: - difficultyLevel = (INT)eSen_DifficultyLevel_Easier; + difficultyLevel = static_cast(eSen_DifficultyLevel_Easier); break; case 2: - difficultyLevel = (INT)eSen_DifficultyLevel_Normal; + difficultyLevel = static_cast(eSen_DifficultyLevel_Normal); break; case 3: - difficultyLevel = (INT)eSen_DifficultyLevel_Harder; + difficultyLevel = static_cast(eSen_DifficultyLevel_Harder); break; } @@ -461,11 +461,11 @@ INT CSentientManager::GetLicense() if(ProfileManager.IsFullVersion()) { - license = (INT)eSen_License_Full_Purchased_Title; + license = static_cast(eSen_License_Full_Purchased_Title); } else { - license = (INT)eSen_License_Trial_or_Demo; + license = static_cast(eSen_License_Trial_or_Demo); } return license; } @@ -500,15 +500,15 @@ INT CSentientManager::GetAudioSettings(DWORD dwUserId) if(volume == 0) { - audioSettings = (INT)eSen_AudioSettings_Off; + audioSettings = static_cast(eSen_AudioSettings_Off); } else if(volume == DEFAULT_VOLUME_LEVEL) { - audioSettings = (INT)eSen_AudioSettings_On_Default; + audioSettings = static_cast(eSen_AudioSettings_On_Default); } else { - audioSettings = (INT)eSen_AudioSettings_On_CustomSetting; + audioSettings = static_cast(eSen_AudioSettings_On_CustomSetting); } } return audioSettings; diff --git a/Minecraft.Client/Xbox/XML/ATGXmlParser.cpp b/Minecraft.Client/Xbox/XML/ATGXmlParser.cpp index 5366e721f..96b6bfc83 100644 --- a/Minecraft.Client/Xbox/XML/ATGXmlParser.cpp +++ b/Minecraft.Client/Xbox/XML/ATGXmlParser.cpp @@ -69,8 +69,8 @@ VOID XMLParser::FillBuffer() } m_dwCharsConsumed += NChars; - __int64 iProgress = m_dwCharsTotal ? (( (__int64)m_dwCharsConsumed * 1000 ) / (__int64)m_dwCharsTotal) : 0; - m_pISAXCallback->SetParseProgress( (DWORD)iProgress ); + __int64 iProgress = m_dwCharsTotal ? (( static_cast<__int64>(m_dwCharsConsumed) * 1000 ) / static_cast<__int64>(m_dwCharsTotal)) : 0; + m_pISAXCallback->SetParseProgress( static_cast(iProgress) ); m_pReadBuf[ NChars ] = '\0'; m_pReadBuf[ NChars + 1] = '\0'; @@ -198,7 +198,7 @@ HRESULT XMLParser::ConvertEscape() if( FAILED( hr = AdvanceName() ) ) return hr; - EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal ); + EntityRefLen = static_cast(m_pWritePtr - pEntityRefVal); m_pWritePtr = pEntityRefVal; if ( EntityRefLen == 0 ) @@ -497,8 +497,8 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - if( FAILED( m_pISAXCallback->ElementEnd( pEntityRefVal, - (UINT) ( m_pWritePtr - pEntityRefVal ) ) ) ) + if( FAILED( m_pISAXCallback->ElementEnd( pEntityRefVal, + static_cast(m_pWritePtr - pEntityRefVal)) ) ) return E_ABORT; if( FAILED( hr = ConsumeSpace() ) ) @@ -541,7 +541,7 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal ); + EntityRefLen = static_cast(m_pWritePtr - pEntityRefVal); if( FAILED( hr = ConsumeSpace() ) ) return hr; @@ -566,7 +566,7 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceName() ) ) return hr; - Attributes[ NumAttrs ].NameLen = (UINT)( m_pWritePtr - Attributes[ NumAttrs ].strName ); + Attributes[ NumAttrs ].NameLen = static_cast(m_pWritePtr - Attributes[NumAttrs].strName); if( FAILED( hr = ConsumeSpace() ) ) return hr; @@ -588,8 +588,8 @@ HRESULT XMLParser::AdvanceElement() if( FAILED( hr = AdvanceAttrVal() ) ) return hr; - Attributes[ NumAttrs ].ValueLen = (UINT)( m_pWritePtr - - Attributes[ NumAttrs ].strValue ); + Attributes[ NumAttrs ].ValueLen = static_cast(m_pWritePtr - + Attributes[NumAttrs].strValue); ++NumAttrs; @@ -663,13 +663,13 @@ HRESULT XMLParser::AdvanceCDATA() if( m_pWritePtr - m_pWriteBuf >= XML_WRITE_BUFFER_SIZE ) { - if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), TRUE ) ) ) + if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, static_cast(m_pWritePtr - m_pWriteBuf), TRUE ) ) ) return E_ABORT; m_pWritePtr = m_pWriteBuf; } } - if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, static_cast(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; m_pWritePtr = m_pWriteBuf; @@ -782,9 +782,9 @@ HRESULT XMLParser::MainParseLoop() { if( FAILED( AdvanceCharacter( TRUE ) ) ) { - if ( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) ) + if ( ( static_cast(m_pWritePtr - m_pWriteBuf) != 0 ) && ( !bWhiteSpaceOnly ) ) { - if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, static_cast(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; bWhiteSpaceOnly = TRUE; @@ -798,9 +798,9 @@ HRESULT XMLParser::MainParseLoop() if( m_Ch == '<' ) { - if( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) ) + if( ( static_cast(m_pWritePtr - m_pWriteBuf) != 0 ) && ( !bWhiteSpaceOnly ) ) { - if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) ) + if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, static_cast(m_pWritePtr - m_pWriteBuf), FALSE ) ) ) return E_ABORT; bWhiteSpaceOnly = TRUE; @@ -837,8 +837,8 @@ HRESULT XMLParser::MainParseLoop() { if( !bWhiteSpaceOnly ) { - if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, - ( UINT ) ( m_pWritePtr - m_pWriteBuf ), + if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, + static_cast(m_pWritePtr - m_pWriteBuf), TRUE ) ) ) { return E_ABORT; @@ -888,7 +888,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) { LARGE_INTEGER iFileSize; GetFileSizeEx( m_hFile, &iFileSize ); - m_dwCharsTotal = (DWORD)iFileSize.QuadPart; + m_dwCharsTotal = static_cast(iFileSize.QuadPart); m_dwCharsConsumed = 0; hr = MainParseLoop(); } diff --git a/Minecraft.Client/Xbox/Xbox_App.h b/Minecraft.Client/Xbox/Xbox_App.h index f64e71423..79ee28f97 100644 --- a/Minecraft.Client/Xbox/Xbox_App.h +++ b/Minecraft.Client/Xbox/Xbox_App.h @@ -121,7 +121,7 @@ class CConsoleMinecraftApp : public CMinecraftApp public: - void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false); + void ReadBannedList(int iPad, eTMSAction action=static_cast(0), bool bCallback=false); // void ReadXuidsFileFromTMS(int iPad,eTMSAction NextAction,bool bCallback); // void ReadDLCFileFromTMS(int iPad,eTMSAction NextAction, bool bCallback); diff --git a/Minecraft.Client/ZombieRenderer.cpp b/Minecraft.Client/ZombieRenderer.cpp index 7fd2d2015..9db758075 100644 --- a/Minecraft.Client/ZombieRenderer.cpp +++ b/Minecraft.Client/ZombieRenderer.cpp @@ -98,7 +98,7 @@ void ZombieRenderer::swapArmor(shared_ptr mob) armorParts2 = defaultArmorParts2; } - humanoidModel = (HumanoidModel *) model; + humanoidModel = static_cast(model); } void ZombieRenderer::setupRotations(shared_ptr _mob, float bob, float bodyRot, float a) @@ -106,7 +106,7 @@ void ZombieRenderer::setupRotations(shared_ptr _mob, float bob, fl shared_ptr mob = dynamic_pointer_cast(_mob); if (mob->isConverting()) { - bodyRot += (float) (cos(mob->tickCount * 3.25) * PI * .25f); + bodyRot += static_cast(cos(mob->tickCount * 3.25) * PI * .25f); } HumanoidMobRenderer::setupRotations(mob, bob, bodyRot, a); } \ No newline at end of file diff --git a/Minecraft.Client/glWrapper.cpp b/Minecraft.Client/glWrapper.cpp index a356e674c..9c3c8559d 100644 --- a/Minecraft.Client/glWrapper.cpp +++ b/Minecraft.Client/glWrapper.cpp @@ -62,7 +62,7 @@ void glOrtho(float left,float right,float bottom,float top,float zNear,float zFa void glScaled(double x,double y,double z) { - RenderManager.MatrixScale((float)x,(float)y,(float)z); + RenderManager.MatrixScale(static_cast(x),static_cast(y),static_cast(z)); } void glGetFloat(int type, FloatBuffer *buff) diff --git a/Minecraft.World/AABB.cpp b/Minecraft.World/AABB.cpp index f8e134971..6610bc27e 100644 --- a/Minecraft.World/AABB.cpp +++ b/Minecraft.World/AABB.cpp @@ -41,7 +41,7 @@ void AABB::UseDefaultThreadStorage() void AABB::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); if( tls == tlsDefault ) return; delete tls; @@ -62,7 +62,7 @@ void AABB::resetPool() AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, double z1) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); AABB *thisAABB = &tls->pool[tls->poolPointer]; thisAABB->set(x0, y0, z0, x1, y1, z1); tls->poolPointer = ( tls->poolPointer + 1 ) % ThreadStorage::POOL_SIZE; diff --git a/Minecraft.World/AbstractContainerMenu.cpp b/Minecraft.World/AbstractContainerMenu.cpp index 57b0b1775..2cbea246d 100644 --- a/Minecraft.World/AbstractContainerMenu.cpp +++ b/Minecraft.World/AbstractContainerMenu.cpp @@ -29,7 +29,7 @@ AbstractContainerMenu::~AbstractContainerMenu() Slot *AbstractContainerMenu::addSlot(Slot *slot) { - slot->index = (int)slots.size(); + slot->index = static_cast(slots.size()); slots.push_back(slot); lastSlots.push_back(nullptr); return slot; @@ -722,7 +722,7 @@ void AbstractContainerMenu::getQuickCraftSlotCount(unordered_set *quickC switch (quickCraftingType) { case QUICKCRAFT_TYPE_CHARITABLE: - item->count = Mth::floor(item->count / (float) quickCraftSlots->size()); + item->count = Mth::floor(item->count / static_cast(quickCraftSlots->size())); break; case QUICKCRAFT_TYPE_GREEDY: item->count = 1; @@ -749,7 +749,7 @@ int AbstractContainerMenu::getRedstoneSignalFromContainer(shared_ptr if (item != NULL) { - totalPct += item->count / (float) min(container->getMaxStackSize(), item->getMaxStackSize()); + totalPct += item->count / static_cast(min(container->getMaxStackSize(), item->getMaxStackSize())); count++; } } diff --git a/Minecraft.World/AbstractContainerMenu.h b/Minecraft.World/AbstractContainerMenu.h index 5ac115de3..3365593cf 100644 --- a/Minecraft.World/AbstractContainerMenu.h +++ b/Minecraft.World/AbstractContainerMenu.h @@ -95,7 +95,7 @@ class AbstractContainerMenu virtual bool stillValid(shared_ptr player) = 0; // 4J Stu Added for UI - unsigned int getSize() { return (unsigned int)slots.size(); } + unsigned int getSize() { return static_cast(slots.size()); } protected: diff --git a/Minecraft.World/AddEntityPacket.cpp b/Minecraft.World/AddEntityPacket.cpp index 6231537d6..f70082b89 100644 --- a/Minecraft.World/AddEntityPacket.cpp +++ b/Minecraft.World/AddEntityPacket.cpp @@ -32,9 +32,9 @@ void AddEntityPacket::_init(shared_ptr e, int type, int data, int xp, in if (xd > m) xd = m; if (yd > m) yd = m; if (zd > m) zd = m; - xa = (int) (xd * 8000.0); - ya = (int) (yd * 8000.0); - za = (int) (zd * 8000.0); + xa = static_cast(xd * 8000.0); + ya = static_cast(yd * 8000.0); + za = static_cast(zd * 8000.0); } } diff --git a/Minecraft.World/AddMobPacket.cpp b/Minecraft.World/AddMobPacket.cpp index 878e2ee72..d224b2931 100644 --- a/Minecraft.World/AddMobPacket.cpp +++ b/Minecraft.World/AddMobPacket.cpp @@ -29,7 +29,7 @@ AddMobPacket::AddMobPacket(shared_ptr mob, int yRotp, int xRotp, i { id = mob->entityId; - type = (byte) EntityIO::getId(mob); + type = static_cast(EntityIO::getId(mob)); // 4J Stu - We should add entities at their "last sent" position so that the relative update packets // put them in the correct place x = xp;//Mth::floor(mob->x * 32); @@ -54,9 +54,9 @@ AddMobPacket::AddMobPacket(shared_ptr mob, int yRotp, int xRotp, i if (xd > m) xd = m; if (yd > m) yd = m; if (zd > m) zd = m; - this->xd = (int) (xd * 8000.0); - this->yd = (int) (yd * 8000.0); - this->zd = (int) (zd * 8000.0); + this->xd = static_cast(xd * 8000.0); + this->yd = static_cast(yd * 8000.0); + this->zd = static_cast(zd * 8000.0); // printf("%d: New add mob rot %d\n",id,yRot); diff --git a/Minecraft.World/AddPlayerPacket.cpp b/Minecraft.World/AddPlayerPacket.cpp index 939843679..6b3e26365 100644 --- a/Minecraft.World/AddPlayerPacket.cpp +++ b/Minecraft.World/AddPlayerPacket.cpp @@ -55,7 +55,7 @@ AddPlayerPacket::AddPlayerPacket(shared_ptr player, PlayerUID xuid, Play this->xuid = xuid; this->OnlineXuid = OnlineXuid; - m_playerIndex = (BYTE)player->getPlayerIndex(); + m_playerIndex = static_cast(player->getPlayerIndex()); m_skinId = player->getCustomSkin(); m_capeId = player->getCustomCape(); m_uiGamePrivileges = player->getAllPlayerGamePrivileges(); diff --git a/Minecraft.World/Animal.cpp b/Minecraft.World/Animal.cpp index ecda8fc53..77048d06d 100644 --- a/Minecraft.World/Animal.cpp +++ b/Minecraft.World/Animal.cpp @@ -72,7 +72,7 @@ void Animal::checkHurtTarget(shared_ptr target, float d) { double xd = target->x - x; double zd = target->z - z; - yRot = (float) (atan2(zd, xd) * 180 / PI) - 90; + yRot = static_cast(atan2(zd, xd) * 180 / PI) - 90; holdGround = true; } diff --git a/Minecraft.World/ArmorDyeRecipe.cpp b/Minecraft.World/ArmorDyeRecipe.cpp index c2f681fa9..c55cbc592 100644 --- a/Minecraft.World/ArmorDyeRecipe.cpp +++ b/Minecraft.World/ArmorDyeRecipe.cpp @@ -66,9 +66,9 @@ shared_ptr ArmorDyeRecipe::assembleDyedArmor(shared_ptrhasCustomColor(item)) { int color = armor->getColor(target); - float red = (float) ((color >> 16) & 0xFF) / 0xFF; - float green = (float) ((color >> 8) & 0xFF) / 0xFF; - float blue = (float) (color & 0xFF) / 0xFF; + float red = static_cast((color >> 16) & 0xFF) / 0xFF; + float green = static_cast((color >> 8) & 0xFF) / 0xFF; + float blue = static_cast(color & 0xFF) / 0xFF; intensityTotal += max(red, max(green, blue)) * 0xFF; @@ -86,9 +86,9 @@ shared_ptr ArmorDyeRecipe::assembleDyedArmor(shared_ptrid == Item::dye_powder_Id) { int tileData = ColoredTile::getTileDataForItemAuxValue(item->getAuxValue()); - int red = (int) (Sheep::COLOR[tileData][0] * 0xFF); - int green = (int) (Sheep::COLOR[tileData][1] * 0xFF); - int blue = (int) (Sheep::COLOR[tileData][2] * 0xFF); + int red = static_cast(Sheep::COLOR[tileData][0] * 0xFF); + int green = static_cast(Sheep::COLOR[tileData][1] * 0xFF); + int blue = static_cast(Sheep::COLOR[tileData][2] * 0xFF); intensityTotal += max(red, max(green, blue)); @@ -110,13 +110,13 @@ shared_ptr ArmorDyeRecipe::assembleDyedArmor(shared_ptr(intensityTotal) / colourCounts; + float resultIntensity = static_cast(max(red, max(green, blue))); // System.out.println(averageIntensity + ", " + resultIntensity); - red = (int) ((float) red * averageIntensity / resultIntensity); - green = (int) ((float) green * averageIntensity / resultIntensity); - blue = (int) ((float) blue * averageIntensity / resultIntensity); + red = static_cast((float)red * averageIntensity / resultIntensity); + green = static_cast((float)green * averageIntensity / resultIntensity); + blue = static_cast((float)blue * averageIntensity / resultIntensity); int rgb = red; rgb = (rgb << 8) + green; diff --git a/Minecraft.World/Arrow.cpp b/Minecraft.World/Arrow.cpp index ab942aac6..e6ee4b9cc 100644 --- a/Minecraft.World/Arrow.cpp +++ b/Minecraft.World/Arrow.cpp @@ -72,15 +72,15 @@ Arrow::Arrow(Level *level, shared_ptr mob, shared_ptr(atan2(zd, xd) * 180 / PI) - 90; + float xRot = static_cast(-(atan2(yd, sd) * 180 / PI)); double xdn = xd / sd; double zdn = zd / sd; moveTo(mob->x + xdn, y, mob->z + zdn, yRot, xRot); heightOffset = 0; - float yo = (float) sd * 0.2f; + float yo = static_cast(sd) * 0.2f; shoot(xd, yd + yo, zd, power, uncertainty); } @@ -123,13 +123,13 @@ Arrow::Arrow(Level *level, shared_ptr mob, float power) : Entity( void Arrow::defineSynchedData() { - entityData->define(ID_FLAGS, (byte) 0); + entityData->define(ID_FLAGS, static_cast(0)); } void Arrow::shoot(double xd, double yd, double zd, float pow, float uncertainty) { - float dist = (float) sqrt(xd * xd + yd * yd + zd * zd); + float dist = static_cast(sqrt(xd * xd + yd * yd + zd * zd)); xd /= dist; yd /= dist; @@ -149,8 +149,8 @@ void Arrow::shoot(double xd, double yd, double zd, float pow, float uncertainty) double sd = sqrt(xd * xd + zd * zd); - yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI); - xRotO = xRot = (float) (atan2(yd, sd) * 180 / PI); + yRotO = yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRotO = xRot = static_cast(atan2(yd, sd) * 180 / PI); life = 0; } @@ -168,8 +168,8 @@ void Arrow::lerpMotion(double xd, double yd, double zd) if (xRotO == 0 && yRotO == 0) { double sd = sqrt(xd * xd + zd * zd); - yRotO = yRot = (float) (atan2( xd, zd) * 180 / PI); - xRotO = xRot = (float) (atan2( yd, sd) * 180 / PI); + yRotO = yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRotO = xRot = static_cast(atan2(yd, sd) * 180 / PI); xRotO = xRot; yRotO = yRot; app.DebugPrintf("%f %f : 0x%x\n",xRot,yRot,&yRot); @@ -186,8 +186,8 @@ void Arrow::tick() if (xRotO == 0 && yRotO == 0) { double sd = sqrt(xd * xd + zd * zd); - yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI); - xRotO = xRot = (float) (atan2(yd, sd) * 180 / PI); + yRotO = yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRotO = xRot = static_cast(atan2(yd, sd) * 180 / PI); } @@ -289,7 +289,7 @@ void Arrow::tick() if (res->entity != NULL) { float pow = Mth::sqrt(xd * xd + yd * yd + zd * zd); - int dmg = (int) Mth::ceil((float)(pow * baseDamage)); + int dmg = (int) Mth::ceil(static_cast(pow * baseDamage)); if(isCritArrow()) dmg += random->nextInt(dmg / 2 + 2); @@ -376,10 +376,10 @@ void Arrow::tick() zTile = res->z; lastTile = level->getTile(xTile, yTile, zTile); lastData = level->getData(xTile, yTile, zTile); - xd = (float) (res->pos->x - x); - yd = (float) (res->pos->y - y); - zd = (float) (res->pos->z - z); - float dd = (float) sqrt(xd * xd + yd * yd + zd * zd); + xd = static_cast(res->pos->x - x); + yd = static_cast(res->pos->y - y); + zd = static_cast(res->pos->z - z); + float dd = static_cast(sqrt(xd * xd + yd * yd + zd * zd)); // 4J added check - zero dd here was creating NaNs if( dd > 0.0001f ) { @@ -414,8 +414,8 @@ void Arrow::tick() z += zd; double sd = sqrt(xd * xd + zd * zd); - yRot = (float) (atan2(xd, zd) * 180 / PI); - xRot = (float) (atan2(yd, sd) * 180 / PI); + yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRot = static_cast(atan2(yd, sd) * 180 / PI); while (xRot - xRotO < -180) xRotO -= 360; @@ -456,14 +456,14 @@ void Arrow::tick() void Arrow::addAdditonalSaveData(CompoundTag *tag) { - tag->putShort(L"xTile", (short) xTile); - tag->putShort(L"yTile", (short) yTile); - tag->putShort(L"zTile", (short) zTile); - tag->putByte(L"inTile", (byte) lastTile); - tag->putByte(L"inData", (byte) lastData); - tag->putByte(L"shake", (byte) shakeTime); - tag->putByte(L"inGround", (byte) (inGround ? 1 : 0)); - tag->putByte(L"pickup", (byte) pickup); + tag->putShort(L"xTile", static_cast(xTile)); + tag->putShort(L"yTile", static_cast(yTile)); + tag->putShort(L"zTile", static_cast(zTile)); + tag->putByte(L"inTile", static_cast(lastTile)); + tag->putByte(L"inData", static_cast(lastData)); + tag->putByte(L"shake", static_cast(shakeTime)); + tag->putByte(L"inGround", static_cast(inGround ? 1 : 0)); + tag->putByte(L"pickup", static_cast(pickup)); tag->putDouble(L"damage", baseDamage); } @@ -548,11 +548,11 @@ void Arrow::setCritArrow(bool critArrow) byte flags = entityData->getByte(ID_FLAGS); if (critArrow) { - entityData->set(ID_FLAGS, (byte) (flags | FLAG_CRIT)); + entityData->set(ID_FLAGS, static_cast(flags | FLAG_CRIT)); } else { - entityData->set(ID_FLAGS, (byte) (flags & ~FLAG_CRIT)); + entityData->set(ID_FLAGS, static_cast(flags & ~FLAG_CRIT)); } } diff --git a/Minecraft.World/AttributeModifier.cpp b/Minecraft.World/AttributeModifier.cpp index c479853d8..6c45c4ac6 100644 --- a/Minecraft.World/AttributeModifier.cpp +++ b/Minecraft.World/AttributeModifier.cpp @@ -123,7 +123,7 @@ HtmlString AttributeModifier::getHoverText(eATTRIBUTE_ID attribute) } wchar_t formatted[256]; - swprintf(formatted, 256, L"%ls%d%ls %ls", (amount > 0 ? L"+" : L"-"), (int) displayAmount, (percentage ? L"%" : L""), app.GetString(Attribute::getName(attribute))); + swprintf(formatted, 256, L"%ls%d%ls %ls", (amount > 0 ? L"+" : L"-"), static_cast(displayAmount), (percentage ? L"%" : L""), app.GetString(Attribute::getName(attribute))); return HtmlString(formatted, color); } \ No newline at end of file diff --git a/Minecraft.World/BaseMobSpawner.cpp b/Minecraft.World/BaseMobSpawner.cpp index 0e37e4447..743427dae 100644 --- a/Minecraft.World/BaseMobSpawner.cpp +++ b/Minecraft.World/BaseMobSpawner.cpp @@ -78,7 +78,7 @@ void BaseMobSpawner::tick() if (spawnDelay > 0) spawnDelay--; oSpin = spin; - spin = (int)(spin + 1000 / (spawnDelay + 200.0f)) % 360; + spin = static_cast(spin + 1000 / (spawnDelay + 200.0f)) % 360; } else { @@ -202,7 +202,7 @@ void BaseMobSpawner::delay() if ( (spawnPotentials != NULL) && (spawnPotentials->size() > 0) ) { - setNextSpawnData( (SpawnData*) WeighedRandom::getRandomItem((Random*)getLevel()->random, (vector*)spawnPotentials) ); + setNextSpawnData( static_cast(WeighedRandom::getRandomItem((Random *)getLevel()->random, (vector *)spawnPotentials)) ); } broadcastEvent(EVENT_SPAWN); @@ -261,17 +261,17 @@ void BaseMobSpawner::load(CompoundTag *tag) void BaseMobSpawner::save(CompoundTag *tag) { tag->putString(L"EntityId", getEntityId()); - tag->putShort(L"Delay", (short) spawnDelay); - tag->putShort(L"MinSpawnDelay", (short) minSpawnDelay); - tag->putShort(L"MaxSpawnDelay", (short) maxSpawnDelay); - tag->putShort(L"SpawnCount", (short) spawnCount); - tag->putShort(L"MaxNearbyEntities", (short) maxNearbyEntities); - tag->putShort(L"RequiredPlayerRange", (short) requiredPlayerRange); - tag->putShort(L"SpawnRange", (short) spawnRange); + tag->putShort(L"Delay", static_cast(spawnDelay)); + tag->putShort(L"MinSpawnDelay", static_cast(minSpawnDelay)); + tag->putShort(L"MaxSpawnDelay", static_cast(maxSpawnDelay)); + tag->putShort(L"SpawnCount", static_cast(spawnCount)); + tag->putShort(L"MaxNearbyEntities", static_cast(maxNearbyEntities)); + tag->putShort(L"RequiredPlayerRange", static_cast(requiredPlayerRange)); + tag->putShort(L"SpawnRange", static_cast(spawnRange)); if (getNextSpawnData() != NULL) { - tag->putCompound(L"SpawnData", (CompoundTag *) getNextSpawnData()->tag->copy()); + tag->putCompound(L"SpawnData", static_cast(getNextSpawnData()->tag->copy())); } if (getNextSpawnData() != NULL || (spawnPotentials != NULL && spawnPotentials->size() > 0)) diff --git a/Minecraft.World/BaseRailTile.cpp b/Minecraft.World/BaseRailTile.cpp index db854bb33..c08c2860e 100644 --- a/Minecraft.World/BaseRailTile.cpp +++ b/Minecraft.World/BaseRailTile.cpp @@ -19,7 +19,7 @@ BaseRailTile::Rail::Rail(Level *level, int x, int y, int z) if(m_bValidRail) { int direction = level->getData(x, y, z); - if (((BaseRailTile *) Tile::tiles[id])->usesDataBit) + if (static_cast(Tile::tiles[id])->usesDataBit) { usesDataBit = true; direction = direction & ~RAIL_DATA_BIT; diff --git a/Minecraft.World/BasicTree.cpp b/Minecraft.World/BasicTree.cpp index 01f10cb3d..f98b4dcb0 100644 --- a/Minecraft.World/BasicTree.cpp +++ b/Minecraft.World/BasicTree.cpp @@ -44,9 +44,9 @@ void BasicTree::prepare() // Populate the list of foliage cluster locations. // Designed to be overridden in child classes to change basic // tree properties (trunk width, branch angle, foliage density, etc..). - trunkHeight = (int) (height * trunkHeightScale); + trunkHeight = static_cast(height * trunkHeightScale); if (trunkHeight >= height) trunkHeight = height - 1; - int clustersPerY = (int) (1.382 + pow(foliageDensity * height / 13.0, 2)); + int clustersPerY = static_cast(1.382 + pow(foliageDensity * height / 13.0, 2)); if (clustersPerY < 1) clustersPerY = 1; // The foliage coordinates are a list of [x,y,z,y of branch base] values for each cluster int **tempFoliageCoords = new int *[clustersPerY * height]; @@ -100,7 +100,7 @@ void BasicTree::prepare() } else { - checkBranchBase[1] = (int) (checkStart[1] - branchHeight); + checkBranchBase[1] = static_cast(checkStart[1] - branchHeight); } // Now check the branch path if (checkLine(checkBranchBase, checkStart) == -1) @@ -147,7 +147,7 @@ void BasicTree::crossection(int x, int y, int z, float radius, byte direction, i // radius is the radius of the section from the center // direction is the direction the cross section is pointed, 0 for x, 1 for y, 2 for z // material is the index number for the material to use - int rad = (int) (radius + 0.618); + int rad = static_cast(radius + 0.618); byte secidx1 = axisConversionArray[direction]; byte secidx2 = axisConversionArray[direction + 3]; int center[] = { x, y, z }; @@ -197,15 +197,15 @@ float BasicTree::treeShape(int y) // This method is intended for overriding in child classes, allowing // different shaped trees. // This method should return a consistent value for each y (don't randomize). - if (y < (((float) height) * 0.3)) return (float) -1.618; - float radius = ((float) height) / ((float) 2.0); - float adjacent = (((float) height) / ((float) 2.0)) - y; + if (y < (static_cast(height) * 0.3)) return (float) -1.618; + float radius = static_cast(height) / static_cast(2.0); + float adjacent = (static_cast(height) / static_cast(2.0)) - y; float distance; if (adjacent == 0) distance = radius; - else if (abs(adjacent) >= radius) distance = (float) 0.0; - else distance = (float) sqrt(pow(abs(radius), 2) - pow(abs(adjacent), 2)); + else if (abs(adjacent) >= radius) distance = static_cast(0.0); + else distance = static_cast(sqrt(pow(abs(radius), 2) - pow(abs(adjacent), 2))); // Alter this factor to change the overall width of the tree. - distance *= (float) 0.5; + distance *= static_cast(0.5); return distance; } @@ -216,9 +216,9 @@ float BasicTree::foliageShape(int y) // Return a negative number if no foliage should be created at this level // this method is intended for overriding in child classes, allowing // foliage of different sizes and shapes. - if ((y < 0) || (y >= foliageHeight)) return (float) -1; - else if ((y == 0) || (y == (foliageHeight - 1))) return (float) 2; - else return (float) 3; + if ((y < 0) || (y >= foliageHeight)) return static_cast(-1); + else if ((y == 0) || (y == (foliageHeight - 1))) return static_cast(2); + else return static_cast(3); } void BasicTree::foliageCluster(int x, int y, int z) @@ -270,8 +270,8 @@ void BasicTree::limb(int *start, int *end, int material) if (delta[primidx] > 0) primsign = 1; else primsign = -1; // Initilize the per-step movement for the non-primary axies. - double secfac1 = ((double) delta[secidx1]) / ((double) delta[primidx]); - double secfac2 = ((double) delta[secidx2]) / ((double) delta[primidx]); + double secfac1 = static_cast(delta[secidx1]) / static_cast(delta[primidx]); + double secfac2 = static_cast(delta[secidx2]) / static_cast(delta[primidx]); // Initialize the coordinates. int coordinate[] = { 0, 0, 0 }; // Loop through each crossection along the primary axis, from start to end @@ -411,8 +411,8 @@ int BasicTree::checkLine(int *start, int *end) if (delta[primidx] > 0) primsign = 1; else primsign = -1; // Initilize the per-step movement for the non-primary axies. - double secfac1 = ((double) delta[secidx1]) / ((double) delta[primidx]); - double secfac2 = ((double) delta[secidx2]) / ((double) delta[primidx]); + double secfac1 = static_cast(delta[secidx1]) / static_cast(delta[primidx]); + double secfac2 = static_cast(delta[secidx2]) / static_cast(delta[primidx]); // Initialize the coordinates. int coordinate[] = { 0, 0, 0 }; // Loop through each crossection along the primary axis, from start to end @@ -507,7 +507,7 @@ void BasicTree::init(double heightInit, double widthInit, double foliageDensityI // // Note, you can call "place" without calling "init". // This is the same as calling init(1.0,1.0,1.0) and then calling place. - heightVariance = (int) (heightInit * 12); + heightVariance = static_cast(heightInit * 12); if (heightInit > 0.5) foliageHeight = 5; widthScale = widthInit; foliageDensity = foliageDensityInit; diff --git a/Minecraft.World/Bat.cpp b/Minecraft.World/Bat.cpp index d3bd35214..dbb003026 100644 --- a/Minecraft.World/Bat.cpp +++ b/Minecraft.World/Bat.cpp @@ -90,11 +90,11 @@ void Bat::setResting(bool value) char current = entityData->getByte(DATA_ID_FLAGS); if (value) { - entityData->set(DATA_ID_FLAGS, (char) (current | FLAG_RESTING)); + entityData->set(DATA_ID_FLAGS, static_cast(current | FLAG_RESTING)); } else { - entityData->set(DATA_ID_FLAGS, (char) (current & ~FLAG_RESTING)); + entityData->set(DATA_ID_FLAGS, static_cast(current & ~FLAG_RESTING)); } } @@ -128,10 +128,10 @@ void Bat::newServerAiStep() if (isResting()) { - if (!level->isSolidBlockingTile(Mth::floor(x), (int) y + 1, Mth::floor(z))) + if (!level->isSolidBlockingTile(Mth::floor(x), static_cast(y) + 1, Mth::floor(z))) { setResting(false); - level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, static_cast(x), static_cast(y), static_cast(z), 0); } else { @@ -144,7 +144,7 @@ void Bat::newServerAiStep() if (level->getNearestPlayer(shared_from_this(), 4.0f) != NULL) { setResting(false); - level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, static_cast(x), static_cast(y), static_cast(z), 0); } } } @@ -156,10 +156,10 @@ void Bat::newServerAiStep() delete targetPosition; targetPosition = NULL; } - if (targetPosition == NULL || random->nextInt(30) == 0 || targetPosition->distSqr((int) x, (int) y, (int) z) < 4) + if (targetPosition == NULL || random->nextInt(30) == 0 || targetPosition->distSqr(static_cast(x), static_cast(y), static_cast(z)) < 4) { delete targetPosition; - targetPosition = new Pos((int) x + random->nextInt(7) - random->nextInt(7), (int) y + random->nextInt(6) - 2, (int) z + random->nextInt(7) - random->nextInt(7)); + targetPosition = new Pos(static_cast(x) + random->nextInt(7) - random->nextInt(7), static_cast(y) + random->nextInt(6) - 2, static_cast(z) + random->nextInt(7) - random->nextInt(7)); } double dx = (targetPosition->x + .5) - x; @@ -170,12 +170,12 @@ void Bat::newServerAiStep() yd = yd + (signum(dy) * .7f - yd) * .1f; zd = zd + (signum(dz) * .5f - zd) * .1f; - float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90; + float yRotD = static_cast(atan2(zd, xd) * 180 / PI) - 90; float rotDiff = Mth::wrapDegrees(yRotD - yRot); yya = .5f; yRot += rotDiff; - if (random->nextInt(100) == 0 && level->isSolidBlockingTile(Mth::floor(x), (int) y + 1, Mth::floor(z))) + if (random->nextInt(100) == 0 && level->isSolidBlockingTile(Mth::floor(x), static_cast(y) + 1, Mth::floor(z))) { setResting(true); } diff --git a/Minecraft.World/BeachBiome.cpp b/Minecraft.World/BeachBiome.cpp index 50e7cc1ca..475f8468f 100644 --- a/Minecraft.World/BeachBiome.cpp +++ b/Minecraft.World/BeachBiome.cpp @@ -8,8 +8,8 @@ BeachBiome::BeachBiome(int id) : Biome(id) // remove default mob spawn settings friendlies.clear(); friendlies_chicken.clear(); // 4J added - topMaterial = (byte) Tile::sand_Id; - material = (byte) Tile::sand_Id; + topMaterial = static_cast(Tile::sand_Id); + material = static_cast(Tile::sand_Id); decorator->treeCount = -999; decorator->deadBushCount = 0; diff --git a/Minecraft.World/BeaconTileEntity.cpp b/Minecraft.World/BeaconTileEntity.cpp index d80eb9068..17f64723f 100644 --- a/Minecraft.World/BeaconTileEntity.cpp +++ b/Minecraft.World/BeaconTileEntity.cpp @@ -163,18 +163,18 @@ float BeaconTileEntity::getAndUpdateClientSideScale() return 0; } - int renderDelta = (int) (level->getGameTime() - clientSideRenderTick); + int renderDelta = static_cast(level->getGameTime() - clientSideRenderTick); clientSideRenderTick = level->getGameTime(); if (renderDelta > 1) { - clientSideRenderScale -= ((float) renderDelta / (float) SCALE_TIME); + clientSideRenderScale -= (static_cast(renderDelta) / static_cast(SCALE_TIME)); if (clientSideRenderScale < 0) { clientSideRenderScale = 0; } } - clientSideRenderScale += (1.0f / (float) SCALE_TIME); + clientSideRenderScale += (1.0f / static_cast(SCALE_TIME)); if (clientSideRenderScale > 1) { clientSideRenderScale = 1; diff --git a/Minecraft.World/BedItem.cpp b/Minecraft.World/BedItem.cpp index a55f277ed..c8765b749 100644 --- a/Minecraft.World/BedItem.cpp +++ b/Minecraft.World/BedItem.cpp @@ -24,7 +24,7 @@ bool BedItem::useOn(shared_ptr itemInstance, shared_ptr pl // place on top of tile y = y + 1; - BedTile *tile = (BedTile *) Tile::bed; + BedTile *tile = static_cast(Tile::bed); int dir = ( Mth::floor(player->yRot * 4 / (360) + 0.5f) ) & 3; int xra = 0; diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index 169db77e6..f8ac2107d 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -86,8 +86,8 @@ Biome::Biome(int id) : id(id) color = 0; // snowCovered = false; // 4J - this isn't set by the java game any more so removing to save confusion - topMaterial = (byte) Tile::grass_Id; - material = (byte) Tile::dirt_Id; + topMaterial = static_cast(Tile::grass_Id); + material = static_cast(Tile::dirt_Id); leafColor = 0x4EE031; _hasRain = true; depth = 0.1f; @@ -261,12 +261,12 @@ float Biome::getCreatureProbability() int Biome::getDownfallInt() { - return (int) (downfall * 65536); + return static_cast(downfall * 65536); } int Biome::getTemperatureInt() { - return (int) (temperature * 65536); + return static_cast(temperature * 65536); } // 4J - brought forward from 1.2.3 diff --git a/Minecraft.World/BiomeCache.cpp b/Minecraft.World/BiomeCache.cpp index b93ce32e1..f5469c595 100644 --- a/Minecraft.World/BiomeCache.cpp +++ b/Minecraft.World/BiomeCache.cpp @@ -85,7 +85,7 @@ BiomeCache::Block *BiomeCache::getBlockAt(int x, int z) EnterCriticalSection(&m_CS); x >>= ZONE_SIZE_BITS; z >>= ZONE_SIZE_BITS; - __int64 slot = (((__int64) x) & 0xffffffffl) | ((((__int64) z) & 0xffffffffl) << 32l); + __int64 slot = (static_cast<__int64>(x) & 0xffffffffl) | ((static_cast<__int64>(z) & 0xffffffffl) << 32l); auto it = cached.find(slot); Block *block = NULL; if (it == cached.end()) @@ -137,7 +137,7 @@ void BiomeCache::update() if (time > DECAY_TIME || time < 0) { it = all.erase(it); - __int64 slot = (((__int64) block->x) & 0xffffffffl) | ((((__int64) block->z) & 0xffffffffl) << 32l); + __int64 slot = (static_cast<__int64>(block->x) & 0xffffffffl) | ((static_cast<__int64>(block->z) & 0xffffffffl) << 32l); cached.erase(slot); delete block; } diff --git a/Minecraft.World/BiomeSource.cpp b/Minecraft.World/BiomeSource.cpp index 8e2a56809..d2454f4a6 100644 --- a/Minecraft.World/BiomeSource.cpp +++ b/Minecraft.World/BiomeSource.cpp @@ -97,7 +97,7 @@ void BiomeSource::getDownfallBlock(floatArray &downfalls, int x, int z, int w, i intArray result = zoomedLayer->getArea(x, z, w, h); for (int i = 0; i < w * h; i++) { - float d = (float) Biome::biomes[result[i]]->getDownfallInt() / 65536.0f; + float d = static_cast(Biome::biomes[result[i]]->getDownfallInt()) / 65536.0f; if (d > 1) d = 1; downfalls[i] = d; } @@ -141,7 +141,7 @@ void BiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z, in intArray result = zoomedLayer->getArea(x, z, w, h); for (int i = 0; i < w * h; i++) { - float t = (float) Biome::biomes[result[i]]->getTemperatureInt() / 65536.0f; + float t = static_cast(Biome::biomes[result[i]]->getTemperatureInt()) / 65536.0f; if (t > 1) t = 1; temperatures[i] = t; } @@ -264,7 +264,7 @@ void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, int intArray result = zoomedLayer->getArea(x, z, w, h); for (int i = 0; i < w * h; i++) { - biomeIndices[i] = (byte)result[i]; + biomeIndices[i] = static_cast(result[i]); } } @@ -553,7 +553,7 @@ void BiomeSource::getFracs(intArray indices, float *fracs) for( int i = 0; i < Biome::BIOME_COUNT; i++ ) { - fracs[i] /= (float)(indices.length); + fracs[i] /= static_cast(indices.length); } } diff --git a/Minecraft.World/Blaze.cpp b/Minecraft.World/Blaze.cpp index d87a83b2d..652aa673b 100644 --- a/Minecraft.World/Blaze.cpp +++ b/Minecraft.World/Blaze.cpp @@ -42,7 +42,7 @@ void Blaze::defineSynchedData() { Monster::defineSynchedData(); - entityData->define(DATA_FLAGS_ID, (byte) 0); + entityData->define(DATA_FLAGS_ID, static_cast(0)); } int Blaze::getAmbientSound() @@ -84,7 +84,7 @@ void Blaze::aiStep() if (nextHeightOffsetChangeTick <= 0) { nextHeightOffsetChangeTick = SharedConstants::TICKS_PER_SECOND * 5; - allowedHeightOffset = .5f + (float) random->nextGaussian() * 3; + allowedHeightOffset = .5f + static_cast(random->nextGaussian()) * 3; } if (getAttackTarget() != NULL && (getAttackTarget()->y + getAttackTarget()->getHeadHeight()) > (y + getHeadHeight() + allowedHeightOffset)) @@ -149,7 +149,7 @@ void Blaze::checkHurtTarget(shared_ptr target, float d) { float sqd = sqrt(d) * .5f; - level->levelEvent(nullptr, LevelEvent::SOUND_BLAZE_FIREBALL, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_BLAZE_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); // level.playSound(this, "mob.ghast.fireball", getSoundVolume(), (random.nextFloat() - random.nextFloat()) * 0.2f + 1.0f); for (int i = 0; i < 1; i++) { shared_ptr ie = shared_ptr( new SmallFireball(level, dynamic_pointer_cast( shared_from_this() ), xd + random->nextGaussian() * sqd, yd, zd + random->nextGaussian() * sqd) ); @@ -162,7 +162,7 @@ void Blaze::checkHurtTarget(shared_ptr target, float d) } } - yRot = (float) (atan2(zd, xd) * 180 / PI) - 90; + yRot = static_cast(atan2(zd, xd) * 180 / PI) - 90; holdGround = true; } diff --git a/Minecraft.World/BlockReplacements.cpp b/Minecraft.World/BlockReplacements.cpp index 7b8aee511..ac31b3d2e 100644 --- a/Minecraft.World/BlockReplacements.cpp +++ b/Minecraft.World/BlockReplacements.cpp @@ -8,7 +8,7 @@ void BlockReplacements::staticCtor() { for (int i = 0; i < 256; i++) { - byte b = (byte) i; + byte b = static_cast(i); if (b != 0 && Tile::tiles[b & 0xff] == NULL) { b = 0; diff --git a/Minecraft.World/Boat.cpp b/Minecraft.World/Boat.cpp index 1811c2094..b1cfa5331 100644 --- a/Minecraft.World/Boat.cpp +++ b/Minecraft.World/Boat.cpp @@ -245,8 +245,8 @@ void Boat::tick() double yrd = Mth::wrapDegrees(lyr - yRot); - yRot += (float) ( (yrd) / lSteps ); - xRot += (float) ( (lxr - xRot) / lSteps ); + yRot += static_cast((yrd) / lSteps); + xRot += static_cast((lxr - xRot) / lSteps); lSteps--; setPos(xt, yt, zt); @@ -390,7 +390,7 @@ void Boat::tick() double zDiff = zo - z; if (xDiff * xDiff + zDiff * zDiff > 0.001) { - yRotT = (float) (atan2(zDiff, xDiff) * 180 / PI); + yRotT = static_cast(atan2(zDiff, xDiff) * 180 / PI); } double rotDiff = Mth::wrapDegrees(yRotT - yRot); @@ -398,7 +398,7 @@ void Boat::tick() if (rotDiff > 20) rotDiff = 20; if (rotDiff < -20) rotDiff = -20; - yRot += (float) rotDiff; + yRot += static_cast(rotDiff); setRot(yRot, xRot); if(level->isClientSide) return; diff --git a/Minecraft.World/BottleItem.cpp b/Minecraft.World/BottleItem.cpp index 0f8e3c357..7a666752d 100644 --- a/Minecraft.World/BottleItem.cpp +++ b/Minecraft.World/BottleItem.cpp @@ -40,11 +40,11 @@ shared_ptr BottleItem::use(shared_ptr itemInstance, itemInstance->count--; if (itemInstance->count <= 0) { - return shared_ptr( new ItemInstance( (Item *)Item::potion) ); + return shared_ptr( new ItemInstance( static_cast(Item::potion)) ); } else { - if (!player->inventory->add(shared_ptr( new ItemInstance( (Item *)Item::potion) ))) + if (!player->inventory->add(shared_ptr( new ItemInstance( static_cast(Item::potion)) ))) { player->drop( shared_ptr( new ItemInstance(Item::potion_Id, 1, 0) )); } diff --git a/Minecraft.World/BowItem.cpp b/Minecraft.World/BowItem.cpp index 949b71e73..ef55a8a5c 100644 --- a/Minecraft.World/BowItem.cpp +++ b/Minecraft.World/BowItem.cpp @@ -25,7 +25,7 @@ void BowItem::releaseUsing(shared_ptr itemInstance, Level *level, if (infiniteArrows || player->inventory->hasResource(Item::arrow_Id)) { int timeHeld = getUseDuration(itemInstance) - durationLeft; - float pow = timeHeld / (float) MAX_DRAW_DURATION; + float pow = timeHeld / static_cast(MAX_DRAW_DURATION); pow = ((pow * pow) + pow * 2) / 3; if (pow < 0.1) return; if (pow > 1) pow = 1; @@ -35,7 +35,7 @@ void BowItem::releaseUsing(shared_ptr itemInstance, Level *level, int damageBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowBonus->id, itemInstance); if (damageBonus > 0) { - arrow->setBaseDamage(arrow->getBaseDamage() + (double) damageBonus * .5 + .5); + arrow->setBaseDamage(arrow->getBaseDamage() + static_cast(damageBonus) * .5 + .5); } int knockbackBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowKnockback->id, itemInstance); if (knockbackBonus > 0) diff --git a/Minecraft.World/BreakDoorGoal.cpp b/Minecraft.World/BreakDoorGoal.cpp index f63b4eb00..ea00f500d 100644 --- a/Minecraft.World/BreakDoorGoal.cpp +++ b/Minecraft.World/BreakDoorGoal.cpp @@ -47,7 +47,7 @@ void BreakDoorGoal::tick() breakTime++; - int progress = (int) (breakTime / (float) DOOR_BREAK_TIME * 10); + int progress = static_cast(breakTime / (float)DOOR_BREAK_TIME * 10); if (progress != lastBreakProgress) { mob->level->destroyTileProgress(mob->entityId, doorX, doorY, doorZ, progress); diff --git a/Minecraft.World/BrewingStandTile.cpp b/Minecraft.World/BrewingStandTile.cpp index 1aeb52d8f..afb324ce0 100644 --- a/Minecraft.World/BrewingStandTile.cpp +++ b/Minecraft.World/BrewingStandTile.cpp @@ -106,12 +106,12 @@ void BrewingStandTile::onRemove(Level *level, int x, int y, int z, int id, int d shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue())))); float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; + itemEntity->xd = static_cast(random->nextGaussian()) * pow; + itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random->nextGaussian()) * pow; if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + itemEntity->getItem()->setTag(static_cast(item->getTag()->copy())); } level->addEntity(itemEntity); } diff --git a/Minecraft.World/BrewingStandTileEntity.cpp b/Minecraft.World/BrewingStandTileEntity.cpp index 5bc6fd27d..2c535a0e7 100644 --- a/Minecraft.World/BrewingStandTileEntity.cpp +++ b/Minecraft.World/BrewingStandTileEntity.cpp @@ -322,7 +322,7 @@ void BrewingStandTileEntity::save(CompoundTag *base) { TileEntity::save(base); - base->putShort(L"BrewTime", (short) (brewTime)); + base->putShort(L"BrewTime", static_cast(brewTime)); ListTag *listTag = new ListTag(); for (int i = 0; i < items.length; i++) @@ -330,7 +330,7 @@ void BrewingStandTileEntity::save(CompoundTag *base) if (items[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); items[i]->save(tag); listTag->add(tag); } diff --git a/Minecraft.World/BufferedOutputStream.cpp b/Minecraft.World/BufferedOutputStream.cpp index 19fc95aff..4f9edbf65 100644 --- a/Minecraft.World/BufferedOutputStream.cpp +++ b/Minecraft.World/BufferedOutputStream.cpp @@ -79,7 +79,7 @@ void BufferedOutputStream::write(byteArray b) //b - the byte to be written. void BufferedOutputStream::write(unsigned int b) { - buf[count++] = (byte) b; + buf[count++] = static_cast(b); if( count == buf.length ) { flush(); diff --git a/Minecraft.World/ButtonTile.cpp b/Minecraft.World/ButtonTile.cpp index 045d5597d..f3387e20b 100644 --- a/Minecraft.World/ButtonTile.cpp +++ b/Minecraft.World/ButtonTile.cpp @@ -302,7 +302,7 @@ void ButtonTile::checkPressed(Level *level, int x, int y, int z) bool shouldBePressed; updateShape(data); - Tile::ThreadStorage *tls = (Tile::ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + Tile::ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); vector > *entities = level->getEntitiesOfClass(typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1)); shouldBePressed = !entities->empty(); delete entities; diff --git a/Minecraft.World/ByteArrayOutputStream.cpp b/Minecraft.World/ByteArrayOutputStream.cpp index 9296fe5ea..afb8c719a 100644 --- a/Minecraft.World/ByteArrayOutputStream.cpp +++ b/Minecraft.World/ByteArrayOutputStream.cpp @@ -33,7 +33,7 @@ void ByteArrayOutputStream::write(unsigned int b) if( count + 1 >= buf.length ) buf.resize( buf.length * 2 ); - buf[count] = (byte) b; + buf[count] = static_cast(b); count++; } diff --git a/Minecraft.World/ByteArrayTag.h b/Minecraft.World/ByteArrayTag.h index 598515ac8..ce701fdbf 100644 --- a/Minecraft.World/ByteArrayTag.h +++ b/Minecraft.World/ByteArrayTag.h @@ -40,7 +40,7 @@ class ByteArrayTag : public Tag { if (Tag::equals(obj)) { - ByteArrayTag *o = (ByteArrayTag *) obj; + ByteArrayTag *o = static_cast(obj); return ((data.data == NULL && o->data.data == NULL) || (data.data != NULL && data.length == o->data.length && memcmp(data.data, o->data.data, data.length) == 0) ); } return false; diff --git a/Minecraft.World/ByteTag.h b/Minecraft.World/ByteTag.h index 6b319c0bb..ef2364720 100644 --- a/Minecraft.World/ByteTag.h +++ b/Minecraft.World/ByteTag.h @@ -23,7 +23,7 @@ class ByteTag : public Tag { if (Tag::equals(obj)) { - ByteTag *o = (ByteTag *) obj; + ByteTag *o = static_cast(obj); return data == o->data; } return false; diff --git a/Minecraft.World/C4JThread.cpp b/Minecraft.World/C4JThread.cpp index d0794f064..0582abb8f 100644 --- a/Minecraft.World/C4JThread.cpp +++ b/Minecraft.World/C4JThread.cpp @@ -240,7 +240,7 @@ SceInt32 C4JThread::entryPoint(SceSize argSize, void *pArgBlock) #else DWORD WINAPI C4JThread::entryPoint(LPVOID lpParam) { - C4JThread* pThread = (C4JThread*)lpParam; + C4JThread* pThread = static_cast(lpParam); SetThreadName(-1, pThread->m_threadName); pThread->m_exitCode = (*pThread->m_startFunc)(pThread->m_threadParam); pThread->m_isRunning = false; @@ -1029,7 +1029,7 @@ void C4JThread::EventQueue::waitForFinish() int C4JThread::EventQueue::threadFunc( void* lpParam ) { - EventQueue* p = (EventQueue*)lpParam; + EventQueue* p = static_cast(lpParam); p->threadPoll(); return 0; } diff --git a/Minecraft.World/CanyonFeature.cpp b/Minecraft.World/CanyonFeature.cpp index 6d1dda64c..6fddd5ccf 100644 --- a/Minecraft.World/CanyonFeature.cpp +++ b/Minecraft.World/CanyonFeature.cpp @@ -141,11 +141,11 @@ void CanyonFeature::addTunnel(__int64 seed, int xOffs, int zOffs, byteArray bloc { if (yy < 10) { - blocks[p] = (byte) Tile::lava_Id; + blocks[p] = static_cast(Tile::lava_Id); } else { - blocks[p] = (byte) 0; + blocks[p] = static_cast(0); if (hasGrass && blocks[p - 1] == Tile::dirt_Id) blocks[p - 1] = (byte) level->getBiome(xx + xOffs * 16, zz + zOffs * 16)->topMaterial; } } @@ -179,7 +179,7 @@ void CanyonFeature::addFeature(Level *level, int x, int z, int xOffs, int zOffs, addTunnel(random->nextLong(), xOffs, zOffs, blocks, xCave, yCave, zCave, thickness, yRot, xRot, 0, 0, 3.0); // 4J Add to feature list - app.AddTerrainFeaturePosition(eTerrainFeature_Ravine,(int)(xCave/16.0),(int)(yCave/16.0)); + app.AddTerrainFeaturePosition(eTerrainFeature_Ravine,static_cast(xCave / 16.0),static_cast(yCave / 16.0)); } } \ No newline at end of file diff --git a/Minecraft.World/CaveFeature.cpp b/Minecraft.World/CaveFeature.cpp index adb5d4462..c460d8634 100644 --- a/Minecraft.World/CaveFeature.cpp +++ b/Minecraft.World/CaveFeature.cpp @@ -46,9 +46,9 @@ bool CaveFeature::place(Level *level, Random *random, int x, int y, int z) } } - for (int x2 = (int) (xx - r / 2); x2 <= (int) (xx + r / 2); x2++) - for (int y2 = (int) (yy - hr / 2); y2 <= (int) (yy + hr / 2); y2++) - for (int z2 = (int) (zz - r / 2); z2 <= (int) (zz + r / 2); z2++) + for (int x2 = static_cast(xx - r / 2); x2 <= static_cast(xx + r / 2); x2++) + for (int y2 = static_cast(yy - hr / 2); y2 <= static_cast(yy + hr / 2); y2++) + for (int z2 = static_cast(zz - r / 2); z2 <= static_cast(zz + r / 2); z2++) { double xd = ((x2 + 0.5) - xx) / (r / 2); double yd = ((y2 + 0.5) - yy) / (hr / 2); diff --git a/Minecraft.World/ChatPacket.cpp b/Minecraft.World/ChatPacket.cpp index 2988962e7..44e1fedb7 100644 --- a/Minecraft.World/ChatPacket.cpp +++ b/Minecraft.World/ChatPacket.cpp @@ -43,7 +43,7 @@ ChatPacket::ChatPacket(const wstring& message, EChatPacketMessage type, int sour // Read chat packet (throws IOException) void ChatPacket::read(DataInputStream *dis) { - m_messageType = (EChatPacketMessage) dis->readShort(); + m_messageType = static_cast(dis->readShort()); short packedCounts = dis->readShort(); int stringCount = (packedCounts >> 4) & 0xF; diff --git a/Minecraft.World/ChestTile.cpp b/Minecraft.World/ChestTile.cpp index 11178b8a3..06e57d7d2 100644 --- a/Minecraft.World/ChestTile.cpp +++ b/Minecraft.World/ChestTile.cpp @@ -235,12 +235,12 @@ void ChestTile::onRemove(Level *level, int x, int y, int z, int id, int data) newItem->set4JData( item->get4JData() ); shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) ); float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; + itemEntity->xd = static_cast(random->nextGaussian()) * pow; + itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random->nextGaussian()) * pow; if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + itemEntity->getItem()->setTag(static_cast(item->getTag()->copy())); } level->addEntity(itemEntity); diff --git a/Minecraft.World/ChestTileEntity.cpp b/Minecraft.World/ChestTileEntity.cpp index b8f323f4f..bdffb05cc 100644 --- a/Minecraft.World/ChestTileEntity.cpp +++ b/Minecraft.World/ChestTileEntity.cpp @@ -157,7 +157,7 @@ void ChestTileEntity::save(CompoundTag *base) if (items->data[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); items->data[i]->save(tag); listTag->add(tag); } @@ -254,7 +254,7 @@ bool ChestTileEntity::isSameChest(int x, int y, int z) { Tile *tile = Tile::tiles[level->getTile(x, y, z)]; if (tile == NULL || !(dynamic_cast(tile) != NULL)) return false; - return ((ChestTile *) tile)->type == getType(); + return static_cast(tile)->type == getType(); } void ChestTileEntity::tick() @@ -391,7 +391,7 @@ int ChestTileEntity::getType() { if (level != NULL && dynamic_cast( getTile() ) != NULL) { - type = ((ChestTile *) getTile())->type; + type = static_cast(getTile())->type; } else { diff --git a/Minecraft.World/ChunkPos.cpp b/Minecraft.World/ChunkPos.cpp index ff1c34f0a..434062c18 100644 --- a/Minecraft.World/ChunkPos.cpp +++ b/Minecraft.World/ChunkPos.cpp @@ -16,8 +16,8 @@ __int64 ChunkPos::hashCode(int x, int z) int ChunkPos::hashCode() { __int64 hash = hashCode(x, z); - int h1 = (int) (hash); - int h2 = (int) (hash >> 32l); + int h1 = static_cast(hash); + int h2 = static_cast(hash >> 32l); return h1 ^ h2; } diff --git a/Minecraft.World/ChunkStorageProfileDecorator.cpp b/Minecraft.World/ChunkStorageProfileDecorator.cpp index 76ffddbc1..52b78260a 100644 --- a/Minecraft.World/ChunkStorageProfileDecorator.cpp +++ b/Minecraft.World/ChunkStorageProfileDecorator.cpp @@ -45,7 +45,7 @@ void ChunkStorageProfilerDecorator::tick() #ifdef __PSVITA__ sprintf(buf,"Average load time: %f (%lld)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount); #else - sprintf(buf,"Average load time: %f (%I64d)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount); + sprintf(buf,"Average load time: %f (%I64d)",0.000001 * static_cast(timeSpentLoading) / static_cast(loadCount), loadCount); #endif app.DebugPrintf(buf); #endif @@ -56,7 +56,7 @@ void ChunkStorageProfilerDecorator::tick() #ifdef __PSVITA__ sprintf(buf,"Average save time: %f (%lld)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount); #else - sprintf(buf,"Average save time: %f (%I64d)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount); + sprintf(buf,"Average save time: %f (%I64d)",0.000001 * static_cast(timeSpentSaving) / static_cast(loadCount), loadCount); #endif app.DebugPrintf(buf); #endif diff --git a/Minecraft.World/ChunkTilesUpdatePacket.cpp b/Minecraft.World/ChunkTilesUpdatePacket.cpp index d90e6b2f0..de5abea16 100644 --- a/Minecraft.World/ChunkTilesUpdatePacket.cpp +++ b/Minecraft.World/ChunkTilesUpdatePacket.cpp @@ -42,8 +42,8 @@ ChunkTilesUpdatePacket::ChunkTilesUpdatePacket(int xc, int zc, shortArray positi int y = (positions[i]) & 255; this->positions[i] = positions[i]; - blocks[i] = (byte) levelChunk->getTile(x, y, z); - data[i] = (byte) levelChunk->getData(x, y, z); + blocks[i] = static_cast(levelChunk->getTile(x, y, z)); + data[i] = static_cast(levelChunk->getData(x, y, z)); } levelIdx = ( ( level->dimension->id == 0 ) ? 0 : ( (level->dimension->id == -1) ? 1 : 2 ) ); } diff --git a/Minecraft.World/Color.cpp b/Minecraft.World/Color.cpp index 256e9017f..554ee3792 100644 --- a/Minecraft.World/Color.cpp +++ b/Minecraft.World/Color.cpp @@ -18,7 +18,7 @@ Color::Color( float r, float g, float b) assert( b >= 0.0f && b <= 1.0f ); //argb - colour = ( (0xFF<<24) | ( (int)(r*255)<<16 ) | ( (int)(g*255)<<8 ) | ( (int)(b*255) ) ); + colour = ( (0xFF<<24) | ( static_cast(r * 255)<<16 ) | ( static_cast(g * 255)<<8 ) | static_cast(b * 255) ); } Color::Color( int r, int g, int b) @@ -43,7 +43,7 @@ Color Color::getHSBColor(float hue, float saturation, float brightness) int r = 0, g = 0, b = 0; if (saturation == 0) { - r = g = b = (int) (brightness * 255.0f + 0.5f); + r = g = b = static_cast(brightness * 255.0f + 0.5f); } else { @@ -52,37 +52,37 @@ Color Color::getHSBColor(float hue, float saturation, float brightness) float p = brightness * (1.0f - saturation); float q = brightness * (1.0f - saturation * f); float t = brightness * (1.0f - (saturation * (1.0f - f))); - switch ((int) h) + switch (static_cast(h)) { case 0: - r = (int) (brightness * 255.0f + 0.5f); - g = (int) (t * 255.0f + 0.5f); - b = (int) (p * 255.0f + 0.5f); + r = static_cast(brightness * 255.0f + 0.5f); + g = static_cast(t * 255.0f + 0.5f); + b = static_cast(p * 255.0f + 0.5f); break; case 1: - r = (int) (q * 255.0f + 0.5f); - g = (int) (brightness * 255.0f + 0.5f); - b = (int) (p * 255.0f + 0.5f); + r = static_cast(q * 255.0f + 0.5f); + g = static_cast(brightness * 255.0f + 0.5f); + b = static_cast(p * 255.0f + 0.5f); break; case 2: - r = (int) (p * 255.0f + 0.5f); - g = (int) (brightness * 255.0f + 0.5f); - b = (int) (t * 255.0f + 0.5f); + r = static_cast(p * 255.0f + 0.5f); + g = static_cast(brightness * 255.0f + 0.5f); + b = static_cast(t * 255.0f + 0.5f); break; case 3: - r = (int) (p * 255.0f + 0.5f); - g = (int) (q * 255.0f + 0.5f); - b = (int) (brightness * 255.0f + 0.5f); + r = static_cast(p * 255.0f + 0.5f); + g = static_cast(q * 255.0f + 0.5f); + b = static_cast(brightness * 255.0f + 0.5f); break; case 4: - r = (int) (t * 255.0f + 0.5f); - g = (int) (p * 255.0f + 0.5f); - b = (int) (brightness * 255.0f + 0.5f); + r = static_cast(t * 255.0f + 0.5f); + g = static_cast(p * 255.0f + 0.5f); + b = static_cast(brightness * 255.0f + 0.5f); break; case 5: - r = (int) (brightness * 255.0f + 0.5f); - g = (int) (p * 255.0f + 0.5f); - b = (int) (q * 255.0f + 0.5f); + r = static_cast(brightness * 255.0f + 0.5f); + g = static_cast(p * 255.0f + 0.5f); + b = static_cast(q * 255.0f + 0.5f); break; } } diff --git a/Minecraft.World/CompoundTag.h b/Minecraft.World/CompoundTag.h index f3a711d2d..e08706449 100644 --- a/Minecraft.World/CompoundTag.h +++ b/Minecraft.World/CompoundTag.h @@ -123,7 +123,7 @@ class CompoundTag : public Tag void putBoolean(const wstring &name, bool val) { - putByte(name, val?(byte)1:0); + putByte(name, val?static_cast(1):0); } Tag *get(const wstring &name) @@ -141,67 +141,67 @@ class CompoundTag : public Tag byte getByte(const wstring &name) { if (tags.find(name) == tags.end()) return (byte)0; - return ((ByteTag *) tags[name])->data; + return static_cast(tags[name])->data; } short getShort(const wstring &name) { if (tags.find(name) == tags.end()) return (short)0; - return ((ShortTag *) tags[name])->data; + return static_cast(tags[name])->data; } int getInt(const wstring &name) { if (tags.find(name) == tags.end()) return (int)0; - return ((IntTag *) tags[name])->data; + return static_cast(tags[name])->data; } __int64 getLong(const wstring &name) { if (tags.find(name) == tags.end()) return (__int64)0; - return ((LongTag *) tags[name])->data; + return static_cast(tags[name])->data; } float getFloat(const wstring &name) { - if (tags.find(name) == tags.end()) return (float)0; - return ((FloatTag *) tags[name])->data; + if (tags.find(name) == tags.end()) return static_cast(0); + return static_cast(tags[name])->data; } double getDouble(const wstring &name) { if (tags.find(name) == tags.end()) return (double)0; - return ((DoubleTag *) tags[name])->data; + return static_cast(tags[name])->data; } wstring getString(const wstring &name) { if (tags.find(name) == tags.end()) return wstring( L"" ); - return ((StringTag *) tags[name])->data; + return static_cast(tags[name])->data; } byteArray getByteArray(const wstring &name) { if (tags.find(name) == tags.end()) return byteArray(); - return ((ByteArrayTag *) tags[name])->data; + return static_cast(tags[name])->data; } intArray getIntArray(const wstring &name) { if (tags.find(name) == tags.end()) return intArray(); - return ((IntArrayTag *) tags[name])->data; + return static_cast(tags[name])->data; } CompoundTag *getCompound(const wstring &name) { if (tags.find(name) == tags.end()) return new CompoundTag(name); - return (CompoundTag *) tags[name]; + return static_cast(tags[name]); } ListTag *getList(const wstring &name) { if (tags.find(name) == tags.end()) return new ListTag(name); - return (ListTag *) tags[name]; + return static_cast *>(tags[name]); } bool getBoolean(const wstring &string) @@ -271,7 +271,7 @@ class CompoundTag : public Tag { if (Tag::equals(obj)) { - CompoundTag *o = (CompoundTag *) obj; + CompoundTag *o = static_cast(obj); if(tags.size() == o->tags.size()) { diff --git a/Minecraft.World/CompressedTileStorage.cpp b/Minecraft.World/CompressedTileStorage.cpp index 12c1ba3b7..8a999a0a6 100644 --- a/Minecraft.World/CompressedTileStorage.cpp +++ b/Minecraft.World/CompressedTileStorage.cpp @@ -55,7 +55,7 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage *copyFrom) allocatedSize = copyFrom->allocatedSize; if(allocatedSize > 0) { - indicesAndData = (unsigned char *)XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc(allocatedSize); + indicesAndData = static_cast(XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc(allocatedSize); XMemCpy(indicesAndData, copyFrom->indicesAndData, allocatedSize); } else @@ -75,7 +75,7 @@ CompressedTileStorage::CompressedTileStorage(byteArray initFrom, unsigned int in allocatedSize = 0; // We need 32768 bytes for a fully uncompressed chunk, plus 1024 for the index. Rounding up to nearest 4096 bytes for allocation - indicesAndData = (unsigned char *)XPhysicalAlloc(32768+4096, MAXULONG_PTR, 4096, PAGE_READWRITE); + indicesAndData = static_cast(XPhysicalAlloc(32768 + 4096, MAXULONG_PTR, 4096, PAGE_READWRITE)); unsigned short *indices = (unsigned short *)indicesAndData; unsigned char *data = indicesAndData + 1024; @@ -125,7 +125,7 @@ CompressedTileStorage::CompressedTileStorage(bool isEmpty) // XPhysicalAlloc just maps to malloc on PS3, so allocate the smallest amount indicesAndData = (unsigned char *)XPhysicalAlloc(1024, MAXULONG_PTR, 4096, PAGE_READWRITE); #else - indicesAndData = (unsigned char *)XPhysicalAlloc(4096, MAXULONG_PTR, 4096, PAGE_READWRITE); + indicesAndData = static_cast(XPhysicalAlloc(4096, MAXULONG_PTR, 4096, PAGE_READWRITE)); #endif //__PS3__ unsigned short *indices = (unsigned short *)indicesAndData; //unsigned char *data = indicesAndData + 1024; @@ -386,7 +386,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset) // printf("%d: %d (0) %d (1) %d (2) %d (4) %d (8)\n", chunkTotal, type0 / chunkTotal, type1 / chunkTotal, type2 / chunkTotal, type4 / chunkTotal, type8 / chunkTotal); memToAlloc += 1024; // For the indices - unsigned char *newIndicesAndData = (unsigned char *)XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc( memToAlloc ); + unsigned char *newIndicesAndData = static_cast(XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc( memToAlloc ); unsigned char *pucData = newIndicesAndData + 1024; unsigned short usDataOffset = 0; unsigned short *newIndices = (unsigned short *) newIndicesAndData; @@ -401,7 +401,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset) { if( _blockIndices[i] & INDEX_TYPE_0_BIT_FLAG ) { - newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (((unsigned short)data[getIndex(i,0)]) << INDEX_TILE_SHIFT); + newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (static_cast(data[getIndex(i, 0)]) << INDEX_TILE_SHIFT); } else { @@ -738,7 +738,7 @@ int CompressedTileStorage::setDataRegion(byteArray dataIn, int x0, int y0, int } ptrdiff_t count = pucIn - &dataIn.data[offset]; - return (int)count; + return static_cast(count); } // Tests whether setting data would actually change anything @@ -777,7 +777,7 @@ int CompressedTileStorage::getDataRegion(byteArray dataInOut, int x0, int y0, i } ptrdiff_t count = pucOut - &dataInOut.data[offset]; - return (int)count; + return static_cast(count); } void CompressedTileStorage::staticCtor() @@ -1049,7 +1049,7 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) if( needsCompressed ) { memToAlloc += 1024; // For the indices - unsigned char *newIndicesAndData = (unsigned char *)XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc( memToAlloc ); + unsigned char *newIndicesAndData = static_cast(XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc( memToAlloc ); if( newIndicesAndData == NULL ) { DWORD lastError = GetLastError(); @@ -1165,7 +1165,7 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) { if( _blockIndices[i] & INDEX_TYPE_0_BIT_FLAG ) { - newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (((unsigned short)unpacked_data[0]) << INDEX_TILE_SHIFT); + newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (static_cast(unpacked_data[0]) << INDEX_TILE_SHIFT); } else { @@ -1339,7 +1339,7 @@ void CompressedTileStorage::read(DataInputStream *dis) { XPhysicalFree(indicesAndData); } - indicesAndData = (unsigned char *)XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + indicesAndData = static_cast(XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); byteArray wrapper(indicesAndData, allocatedSize); dis->readFully(wrapper); diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp index 09f72be09..807ef1d98 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -111,7 +111,7 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet sprintf(readThreadName,"%s read\n",szId); sprintf(writeThreadName,"%s write\n",szId); - readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE); + readThread = new C4JThread(runRead, static_cast(this), readThreadName, READ_STACK_SIZE); writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE); readThread->SetProcessor(CPU_CORE_CONNECTIONS); writeThread->SetProcessor(CPU_CORE_CONNECTIONS ); @@ -558,14 +558,14 @@ void Connection::sendAndQuit() int Connection::countDelayedPackets() { - return (int)outgoing_slow.size(); + return static_cast(outgoing_slow.size()); } int Connection::runRead(void* lpParam) { ShutdownManager::HasStarted(ShutdownManager::eConnectionReadThreads); - Connection *con = (Connection *)lpParam; + Connection *con = static_cast(lpParam); if (con == NULL) { @@ -615,7 +615,7 @@ int Connection::runRead(void* lpParam) int Connection::runWrite(void* lpParam) { ShutdownManager::HasStarted(ShutdownManager::eConnectionWriteThreads); - Connection *con = dynamic_cast((Connection *) lpParam); + Connection *con = dynamic_cast(static_cast(lpParam)); if (con == NULL) { @@ -660,7 +660,7 @@ int Connection::runWrite(void* lpParam) int Connection::runClose(void* lpParam) { - Connection *con = dynamic_cast((Connection *) lpParam); + Connection *con = dynamic_cast(static_cast(lpParam)); if (con == NULL) return 0; @@ -683,7 +683,7 @@ int Connection::runClose(void* lpParam) int Connection::runSendAndQuit(void* lpParam) { - Connection *con = dynamic_cast((Connection *) lpParam); + Connection *con = dynamic_cast(static_cast(lpParam)); // printf("Con:0x%x runSendAndQuit\n",con); if (con == NULL) return 0; diff --git a/Minecraft.World/ConsoleSaveFileOriginal.cpp b/Minecraft.World/ConsoleSaveFileOriginal.cpp index 3a2b5ef11..f2bd522fb 100644 --- a/Minecraft.World/ConsoleSaveFileOriginal.cpp +++ b/Minecraft.World/ConsoleSaveFileOriginal.cpp @@ -141,10 +141,10 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID #else void* pvSourceData = pvSaveMem; #endif - int compressed = *(int*)pvSourceData; + int compressed = *static_cast(pvSourceData); if( compressed == 0 ) { - unsigned int decompSize = *( (int*)pvSourceData+1 ); + unsigned int decompSize = *( static_cast(pvSourceData)+1 ); if(isLocalEndianDifferent(plat)) System::ReverseULONG(&decompSize); // An invalid save, so clear the memory and start from scratch @@ -162,13 +162,13 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID #ifndef _XBOX if(plat == SAVE_FILE_PLATFORM_PSVITA) { - Compression::VitaVirtualDecompress(buf, &decompSize, (unsigned char *)pvSourceData+8, fileSize-8 ); + Compression::VitaVirtualDecompress(buf, &decompSize, static_cast(pvSourceData)+8, fileSize-8 ); } else #endif { Compression::getCompression()->SetDecompressionType(plat); // if this save is from another platform, set the correct decompression type - Compression::getCompression()->Decompress(buf, &decompSize, (unsigned char *)pvSourceData+8, fileSize-8 ); + Compression::getCompression()->Decompress(buf, &decompSize, static_cast(pvSourceData)+8, fileSize-8 ); Compression::getCompression()->SetDecompressionType(SAVE_FILE_PLATFORM_LOCAL); // and then set the decompression back to the local machine's standard type } @@ -248,18 +248,18 @@ void ConsoleSaveFileOriginal::deleteFile( FileEntry *file ) DWORD bufferDataSize = 0; - char *readStartOffset = (char *)pvSaveMem + file->data.startOffset + file->getFileSize(); + char *readStartOffset = static_cast(pvSaveMem) + file->data.startOffset + file->getFileSize(); - char *writeStartOffset = (char *)pvSaveMem + file->data.startOffset; + char *writeStartOffset = static_cast(pvSaveMem) + file->data.startOffset; - char *endOfDataOffset = (char *)pvSaveMem + header.GetStartOfNextData(); + char *endOfDataOffset = static_cast(pvSaveMem) + header.GetStartOfNextData(); while(true) { // Fill buffer from file if( readStartOffset + bufferSize > endOfDataOffset ) { - amountToRead = (int)(endOfDataOffset - readStartOffset); + amountToRead = static_cast(endOfDataOffset - readStartOffset); } else { @@ -349,7 +349,7 @@ BOOL ConsoleSaveFileOriginal::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD PrepareForWrite( file, nNumberOfBytesToWrite ); - char *writeStartOffset = (char *)pvSaveMem + file->currentFilePointer; + char *writeStartOffset = static_cast(pvSaveMem) + file->currentFilePointer; //printf("Write: pvSaveMem = %0xd, currentFilePointer = %d, writeStartOffset = %0xd\n", pvSaveMem, file->currentFilePointer, writeStartOffset); #ifdef __PSVITA__ @@ -386,7 +386,7 @@ BOOL ConsoleSaveFileOriginal::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWr PrepareForWrite( file, nNumberOfBytesToWrite ); - char *writeStartOffset = (char *)pvSaveMem + file->currentFilePointer; + char *writeStartOffset = static_cast(pvSaveMem) + file->currentFilePointer; //printf("Write: pvSaveMem = %0xd, currentFilePointer = %d, writeStartOffset = %0xd\n", pvSaveMem, file->currentFilePointer, writeStartOffset); #ifdef __PSVITA__ @@ -422,7 +422,7 @@ BOOL ConsoleSaveFileOriginal::readFile( FileEntry *file, LPVOID lpBuffer, DWORD LockSaveAccess(); - char *readStartOffset = (char *)pvSaveMem + file->currentFilePointer; + char *readStartOffset = static_cast(pvSaveMem) + file->currentFilePointer; //printf("Read: pvSaveMem = %0xd, currentFilePointer = %d, readStartOffset = %0xd\n", pvSaveMem, file->currentFilePointer, readStartOffset); assert( nNumberOfBytesToRead <= file->getFileSize() ); @@ -498,13 +498,13 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt } // This is the start of where we want the space to be, and the start of the data that we need to move - char *spaceStartOffset = (char *)pvSaveMem + file->data.startOffset + file->getFileSize(); + char *spaceStartOffset = static_cast(pvSaveMem) + file->data.startOffset + file->getFileSize(); // This is the end of where we want the space to be char *spaceEndOffset = spaceStartOffset + nNumberOfBytesToWrite; // This is the current end of the data that we want to move - char *beginEndOfDataOffset = (char *)pvSaveMem + header.GetStartOfNextData(); + char *beginEndOfDataOffset = static_cast(pvSaveMem) + header.GetStartOfNextData(); // This is where the end of the data is going to be char *finishEndOfDataOffset = beginEndOfDataOffset + nNumberOfBytesToWrite; @@ -530,8 +530,8 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt uintptr_t uiFromEnd = (uintptr_t)beginEndOfDataOffset; // Round both of these values to get 4096 byte chunks that we will need to at least partially move - uintptr_t uiFromStartChunk = uiFromStart & ~((uintptr_t)4095); - uintptr_t uiFromEndChunk = (uiFromEnd - 1 ) & ~((uintptr_t)4095); + uintptr_t uiFromStartChunk = uiFromStart & ~static_cast(4095); + uintptr_t uiFromEndChunk = (uiFromEnd - 1 ) & ~static_cast(4095); // Loop through all the affected source 4096 chunks, going backwards so we don't overwrite anything we'll need in the future for( uintptr_t uiCurrentChunk = uiFromEndChunk; uiCurrentChunk >= uiFromStartChunk; uiCurrentChunk -= 4096 ) @@ -570,7 +570,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt // Fill buffer 1 from file if( (readStartOffset - bufferSize) < spaceStartOffset ) { - amountToRead = (DWORD)(readStartOffset - spaceStartOffset); + amountToRead = static_cast(readStartOffset - spaceStartOffset); } else { @@ -652,7 +652,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) LARGE_INTEGER qwTicksPerSec, qwTime, qwNewTime, qwDeltaTime; float fElapsedTime = 0.0f; QueryPerformanceFrequency( &qwTicksPerSec ); - float fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; + float fSecsPerTick = 1.0f / static_cast(qwTicksPerSec.QuadPart); unsigned int fileSize = header.GetFileSize(); @@ -671,7 +671,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) #else // Attempt to allocate the required memory // We do not own this, it belongs to the StorageManager - byte *compData = (byte *)StorageManager.AllocateSaveData( compLength ); + byte *compData = static_cast(StorageManager.AllocateSaveData(compLength)); #ifdef __PSVITA__ // AP - make sure we always allocate just what is needed so it will only SAVE what is needed. @@ -699,7 +699,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) QueryPerformanceCounter( &qwNewTime ); qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; - fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); + fElapsedTime = fSecsPerTick * static_cast(qwDeltaTime.QuadPart); app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime); PIXEndNamedEvent(); @@ -709,7 +709,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) compLength = compLength+8; // Attempt to allocate the required memory - compData = (byte *)StorageManager.AllocateSaveData( compLength ); + compData = static_cast(StorageManager.AllocateSaveData(compLength)); } #endif @@ -730,7 +730,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) QueryPerformanceCounter( &qwNewTime ); qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; - fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); + fElapsedTime = fSecsPerTick * static_cast(qwDeltaTime.QuadPart); app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime); PIXEndNamedEvent(); @@ -819,7 +819,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes) { - ConsoleSaveFile *pClass=(ConsoleSaveFile *)lpParam; + ConsoleSaveFile *pClass=static_cast(lpParam); return 0; } @@ -1066,5 +1066,5 @@ void ConsoleSaveFileOriginal::ConvertToLocalPlatform() void *ConsoleSaveFileOriginal::getWritePointer(FileEntry *file) { - return (char *)pvSaveMem + file->currentFilePointer;; + return static_cast(pvSaveMem) + file->currentFilePointer;; } diff --git a/Minecraft.World/ConsoleSaveFileOutputStream.cpp b/Minecraft.World/ConsoleSaveFileOutputStream.cpp index 3d8bb3f7c..27b46df08 100644 --- a/Minecraft.World/ConsoleSaveFileOutputStream.cpp +++ b/Minecraft.World/ConsoleSaveFileOutputStream.cpp @@ -38,7 +38,7 @@ void ConsoleSaveFileOutputStream::write(unsigned int b) { DWORD numberOfBytesWritten; - byte value = (byte) b; + byte value = static_cast(b); BOOL result = m_saveFile->writeFile( m_file, diff --git a/Minecraft.World/ContainerMenu.cpp b/Minecraft.World/ContainerMenu.cpp index b1fd4d6bd..83c2db2ec 100644 --- a/Minecraft.World/ContainerMenu.cpp +++ b/Minecraft.World/ContainerMenu.cpp @@ -53,7 +53,7 @@ shared_ptr ContainerMenu::quickMoveStack(shared_ptr player if (slotIndex < containerRows * 9) { - if(!moveItemStackTo(stack, containerRows * 9, (int)slots.size(), true)) + if(!moveItemStackTo(stack, containerRows * 9, static_cast(slots.size()), true)) { // 4J Stu - Brought forward from 1.2 return nullptr; diff --git a/Minecraft.World/ContainerSetContentPacket.cpp b/Minecraft.World/ContainerSetContentPacket.cpp index 13cfebd7c..079ed59e2 100644 --- a/Minecraft.World/ContainerSetContentPacket.cpp +++ b/Minecraft.World/ContainerSetContentPacket.cpp @@ -20,7 +20,7 @@ ContainerSetContentPacket::ContainerSetContentPacket() ContainerSetContentPacket::ContainerSetContentPacket(int containerId, vector > *newItems) { this->containerId = containerId; - items = ItemInstanceArray((int)newItems->size()); + items = ItemInstanceArray(static_cast(newItems->size())); for (unsigned int i = 0; i < items.length; i++) { shared_ptr item = newItems->at(i); diff --git a/Minecraft.World/ControlledByPlayerGoal.cpp b/Minecraft.World/ControlledByPlayerGoal.cpp index cea227cda..ecda01b35 100644 --- a/Minecraft.World/ControlledByPlayerGoal.cpp +++ b/Minecraft.World/ControlledByPlayerGoal.cpp @@ -42,7 +42,7 @@ bool ControlledByPlayerGoal::canUse() void ControlledByPlayerGoal::tick() { shared_ptr player = dynamic_pointer_cast(mob->rider.lock()); - PathfinderMob *pig = (PathfinderMob *)mob; + PathfinderMob *pig = static_cast(mob); float yrd = Mth::wrapDegrees(player->yRot - mob->yRot) * 0.5f; if (yrd > 5) yrd = 5; @@ -62,7 +62,7 @@ void ControlledByPlayerGoal::tick() { boosting = false; } - moveSpeed += moveSpeed * 1.15f * Mth::sin((float) boostTime / boostTimeTotal * PI); + moveSpeed += moveSpeed * 1.15f * Mth::sin(static_cast(boostTime) / boostTimeTotal * PI); } float friction = 0.91f; diff --git a/Minecraft.World/Creeper.cpp b/Minecraft.World/Creeper.cpp index 29be2c0ca..15d84f409 100644 --- a/Minecraft.World/Creeper.cpp +++ b/Minecraft.World/Creeper.cpp @@ -66,7 +66,7 @@ int Creeper::getMaxFallDistance() { if (getTarget() == NULL) return 3; // As long as they survive the fall they should try. - return 3 + (int) (getHealth() - 1); + return 3 + static_cast(getHealth() - 1); } void Creeper::causeFallDamage(float distance) @@ -81,22 +81,22 @@ void Creeper::defineSynchedData() { Monster::defineSynchedData(); - entityData->define(DATA_SWELL_DIR, (byte) -1); - entityData->define(DATA_IS_POWERED, (byte) 0); + entityData->define(DATA_SWELL_DIR, static_cast(-1)); + entityData->define(DATA_IS_POWERED, static_cast(0)); } void Creeper::addAdditonalSaveData(CompoundTag *entityTag) { Monster::addAdditonalSaveData(entityTag); if (entityData->getByte(DATA_IS_POWERED) == 1) entityTag->putBoolean(L"powered", true); - entityTag->putShort(L"Fuse", (short) maxSwell); - entityTag->putByte(L"ExplosionRadius", (byte) explosionRadius); + entityTag->putShort(L"Fuse", static_cast(maxSwell)); + entityTag->putByte(L"ExplosionRadius", static_cast(explosionRadius)); } void Creeper::readAdditionalSaveData(CompoundTag *tag) { Monster::readAdditionalSaveData(tag); - entityData->set(DATA_IS_POWERED, (byte) (tag->getBoolean(L"powered") ? 1 : 0)); + entityData->set(DATA_IS_POWERED, static_cast(tag->getBoolean(L"powered") ? 1 : 0)); if (tag->contains(L"Fuse")) maxSwell = tag->getShort(L"Fuse"); if (tag->contains(L"ExplosionRadius")) explosionRadius = tag->getByte(L"ExplosionRadius"); } @@ -177,16 +177,16 @@ int Creeper::getDeathLoot() int Creeper::getSwellDir() { - return (int) (char) entityData->getByte(DATA_SWELL_DIR); + return (int) static_cast(entityData->getByte(DATA_SWELL_DIR)); } void Creeper::setSwellDir(int dir) { - entityData->set(DATA_SWELL_DIR, (byte) dir); + entityData->set(DATA_SWELL_DIR, static_cast(dir)); } void Creeper::thunderHit(const LightningBolt *lightningBolt) { Monster::thunderHit(lightningBolt); - entityData->set(DATA_IS_POWERED, (byte) 1); + entityData->set(DATA_IS_POWERED, static_cast(1)); } diff --git a/Minecraft.World/CropTile.cpp b/Minecraft.World/CropTile.cpp index 0df719246..a339d3e3c 100644 --- a/Minecraft.World/CropTile.cpp +++ b/Minecraft.World/CropTile.cpp @@ -40,7 +40,7 @@ void CropTile::tick(Level *level, int x, int y, int z, Random *random) { float growthSpeed = getGrowthSpeed(level, x, y, z); - if (random->nextInt((int) (25 / growthSpeed) + 1) == 0) + if (random->nextInt(static_cast(25 / growthSpeed) + 1) == 0) { age++; level->setData(x, y, z, age, Tile::UPDATE_CLIENTS); diff --git a/Minecraft.World/CustomLevelSource.cpp b/Minecraft.World/CustomLevelSource.cpp index 613162992..df3877441 100644 --- a/Minecraft.World/CustomLevelSource.cpp +++ b/Minecraft.World/CustomLevelSource.cpp @@ -196,7 +196,7 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) if( emin < falloffStart ) { int falloff = falloffStart - emin; - comp = ((float)falloff / (float)falloffStart ) * falloffMax; + comp = (static_cast(falloff) / static_cast(falloffStart) ) * falloffMax; } // 4J - end of extra code /////////////////////////////////////////////////////////////////// @@ -204,11 +204,11 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) // 4J - this comparison used to just be with 0.0f but is now varied by block above if (yc * CHUNK_HEIGHT + y < mapHeight) { - tileId = (byte) Tile::stone_Id; + tileId = static_cast(Tile::stone_Id); } else if (yc * CHUNK_HEIGHT + y < waterHeight) { - tileId = (byte) Tile::calmWater_Id; + tileId = static_cast(Tile::calmWater_Id); } // 4J - more extra code to make sure that the column at the edge of the world is just water & rock, to match the infinite sea that @@ -262,7 +262,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi Biome *b = biomes[z + x * 16]; float temp = b->getTemperature(); - int runDepth = (int) (depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25); + int runDepth = static_cast(depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25); int run = -1; @@ -290,7 +290,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (y <= 1 + random->nextInt(2)) // 4J - changed to make the bedrock not have bits you can get stuck in // if (y <= 0 + random->nextInt(5)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); } else { @@ -307,7 +307,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (runDepth <= 0) { top = 0; - material = (byte) Tile::stone_Id; + material = static_cast(Tile::stone_Id); } else if (y >= waterHeight - 4 && y <= waterHeight + 1) { @@ -321,8 +321,8 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (y < waterHeight && top == 0) { - if (temp < 0.15f) top = (byte) Tile::ice_Id; - else top = (byte) Tile::calmWater_Id; + if (temp < 0.15f) top = static_cast(Tile::ice_Id); + else top = static_cast(Tile::calmWater_Id); } run = runDepth; @@ -339,7 +339,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (run == 0 && material == Tile::sand_Id) { run = random->nextInt(4); - material = (byte) Tile::sandStone_Id; + material = static_cast(Tile::sandStone_Id); } } } @@ -368,7 +368,7 @@ LevelChunk *CustomLevelSource::getChunk(int xOffs, int zOffs) // 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed int blocksSize = Level::maxBuildHeight * 16 * 16; - byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + byte *tileData = static_cast(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); XMemSet128(tileData,0,blocksSize); byteArray blocks = byteArray(tileData,blocksSize); // byteArray blocks = byteArray(16 * level->depth * 16); diff --git a/Minecraft.World/CustomPayloadPacket.cpp b/Minecraft.World/CustomPayloadPacket.cpp index 29e2828ee..81ec45766 100644 --- a/Minecraft.World/CustomPayloadPacket.cpp +++ b/Minecraft.World/CustomPayloadPacket.cpp @@ -57,7 +57,7 @@ void CustomPayloadPacket::read(DataInputStream *dis) void CustomPayloadPacket::write(DataOutputStream *dos) { writeUtf(identifier, dos); - dos->writeShort((short) length); + dos->writeShort(static_cast(length)); if (data.data != NULL) { dos->write(data); diff --git a/Minecraft.World/DataInputStream.cpp b/Minecraft.World/DataInputStream.cpp index 97721c944..f7d15841e 100644 --- a/Minecraft.World/DataInputStream.cpp +++ b/Minecraft.World/DataInputStream.cpp @@ -92,12 +92,12 @@ bool DataInputStream::readBoolean() //the 8-bit value read. byte DataInputStream::readByte() { - return (byte) stream->read(); + return static_cast(stream->read()); } unsigned char DataInputStream::readUnsignedByte() { - return (unsigned char) stream->read(); + return static_cast(stream->read()); } //Reads two input bytes and returns a char value. Let a be the first byte read and b be the second byte. The value returned is: @@ -110,7 +110,7 @@ wchar_t DataInputStream::readChar() { int a = stream->read(); int b = stream->read(); - return (wchar_t)((a << 8) | (b & 0xff)); + return static_cast((a << 8) | (b & 0xff)); } //Reads some bytes from an input stream and stores them into the buffer array b. The number of bytes read is equal to the length of b. @@ -254,14 +254,14 @@ short DataInputStream::readShort() { int a = stream->read(); int b = stream->read(); - return (short)((a << 8) | (b & 0xff)); + return static_cast((a << 8) | (b & 0xff)); } unsigned short DataInputStream::readUnsignedShort() { int a = stream->read(); int b = stream->read(); - return (unsigned short)((a << 8) | (b & 0xff)); + return static_cast((a << 8) | (b & 0xff)); } //Reads in a string that has been encoded using a modified UTF-8 format. The general contract of readUTF is that it reads a representation @@ -301,7 +301,7 @@ wstring DataInputStream::readUTF() wstring outputString; int a = stream->read(); int b = stream->read(); - unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff)); + unsigned short UTFLength = static_cast(((a & 0xff) << 8) | (b & 0xff)); //// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format //// used in the java libs, and just write in/out as wchar_t all the time @@ -343,7 +343,7 @@ wstring DataInputStream::readUTF() else if( (firstByte & 0x80) == 0x00 ) { // One byte UTF - wchar_t readChar = (wchar_t)firstByte; + wchar_t readChar = static_cast(firstByte); outputString.push_back( readChar ); continue; } @@ -374,7 +374,7 @@ wstring DataInputStream::readUTF() break; } - wchar_t readChar = (wchar_t)( ((firstByte& 0x1F) << 6) | (secondByte & 0x3F) ); + wchar_t readChar = static_cast(((firstByte & 0x1F) << 6) | (secondByte & 0x3F)); outputString.push_back( readChar ); continue; } @@ -422,7 +422,7 @@ wstring DataInputStream::readUTF() break; } - wchar_t readChar = (wchar_t)(((firstByte & 0x0F) << 12) | ((secondByte & 0x3F) << 6) | (thirdByte & 0x3F)); + wchar_t readChar = static_cast(((firstByte & 0x0F) << 12) | ((secondByte & 0x3F) << 6) | (thirdByte & 0x3F)); outputString.push_back( readChar ); continue; } diff --git a/Minecraft.World/DataLayer.cpp b/Minecraft.World/DataLayer.cpp index a5e7d0881..81e9ddc2e 100644 --- a/Minecraft.World/DataLayer.cpp +++ b/Minecraft.World/DataLayer.cpp @@ -40,10 +40,10 @@ void DataLayer::set(int x, int y, int z, int val) if (part == 0) { - data[slot] = (byte) ((data[slot] & 0xf0) | (val & 0xf)); + data[slot] = static_cast((data[slot] & 0xf0) | (val & 0xf)); } else { - data[slot] = (byte) ((data[slot] & 0x0f) | ((val & 0xf) << 4)); + data[slot] = static_cast((data[slot] & 0x0f) | ((val & 0xf) << 4)); } } @@ -54,7 +54,7 @@ bool DataLayer::isValid() void DataLayer::setAll(int br) { - byte val = (byte) (br & (br << 4)); + byte val = static_cast(br & (br << 4)); for (unsigned int i = 0; i < data.length; i++) { data[i] = val; diff --git a/Minecraft.World/DataOutputStream.cpp b/Minecraft.World/DataOutputStream.cpp index 8d350f0b5..89f1f5d7c 100644 --- a/Minecraft.World/DataOutputStream.cpp +++ b/Minecraft.World/DataOutputStream.cpp @@ -184,7 +184,7 @@ void DataOutputStream::writeChars(const wstring& str) //v - a boolean value to be written. void DataOutputStream::writeBoolean(bool b) { - stream->write( b ? (byte)1 : (byte)0 ); + stream->write( b ? static_cast(1) : static_cast(0) ); // TODO 4J Stu - Error handling? written += 1; } @@ -199,7 +199,7 @@ void DataOutputStream::writeBoolean(bool b) //str - a string to be written. void DataOutputStream::writeUTF(const wstring& str) { - int strlen = (int)str.length(); + int strlen = static_cast(str.length()); int utflen = 0; int c, count = 0; @@ -227,15 +227,15 @@ void DataOutputStream::writeUTF(const wstring& str) byteArray bytearr(utflen+2); - bytearr[count++] = (byte) ((utflen >> 8) & 0xFF); - bytearr[count++] = (byte) ((utflen >> 0) & 0xFF); + bytearr[count++] = static_cast((utflen >> 8) & 0xFF); + bytearr[count++] = static_cast((utflen >> 0) & 0xFF); int i=0; for (i=0; i= 0x0001) && (c <= 0x007F))) break; - bytearr[count++] = (byte) c; + bytearr[count++] = static_cast(c); } for (;i < strlen; i++) @@ -243,19 +243,19 @@ void DataOutputStream::writeUTF(const wstring& str) c = str.at(i); if ((c >= 0x0001) && (c <= 0x007F)) { - bytearr[count++] = (byte) c; + bytearr[count++] = static_cast(c); } else if (c > 0x07FF) { - bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F)); - bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F)); - bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); + bytearr[count++] = static_cast(0xE0 | ((c >> 12) & 0x0F)); + bytearr[count++] = static_cast(0x80 | ((c >> 6) & 0x3F)); + bytearr[count++] = static_cast(0x80 | ((c >> 0) & 0x3F)); } else { - bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F)); - bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); + bytearr[count++] = static_cast(0xC0 | ((c >> 6) & 0x1F)); + bytearr[count++] = static_cast(0x80 | ((c >> 0) & 0x3F)); } } write(bytearr, 0, utflen+2); diff --git a/Minecraft.World/DaylightDetectorTile.cpp b/Minecraft.World/DaylightDetectorTile.cpp index 1bc9943e4..396daec6d 100644 --- a/Minecraft.World/DaylightDetectorTile.cpp +++ b/Minecraft.World/DaylightDetectorTile.cpp @@ -62,7 +62,7 @@ void DaylightDetectorTile::updateSignalStrength(Level *level, int x, int y, int sunAngle = sunAngle + (PI * 2.0f - sunAngle) * .2f; } - target = Math::round((float) target * Mth::cos(sunAngle)); + target = Math::round(static_cast(target) * Mth::cos(sunAngle)); if (target < 0) { target = 0; diff --git a/Minecraft.World/DaylightDetectorTileEntity.cpp b/Minecraft.World/DaylightDetectorTileEntity.cpp index 5a3294131..8f57b0040 100644 --- a/Minecraft.World/DaylightDetectorTileEntity.cpp +++ b/Minecraft.World/DaylightDetectorTileEntity.cpp @@ -14,7 +14,7 @@ void DaylightDetectorTileEntity::tick() tile = getTile(); if (tile != NULL && dynamic_cast(tile) != NULL) { - ((DaylightDetectorTile *) tile)->updateSignalStrength(level, x, y, z); + static_cast(tile)->updateSignalStrength(level, x, y, z); } } } diff --git a/Minecraft.World/DebugOptionsPacket.cpp b/Minecraft.World/DebugOptionsPacket.cpp index f287efcd2..e62fb2eb9 100644 --- a/Minecraft.World/DebugOptionsPacket.cpp +++ b/Minecraft.World/DebugOptionsPacket.cpp @@ -28,12 +28,12 @@ void DebugOptionsPacket::handle(PacketListener *listener) void DebugOptionsPacket::read(DataInputStream *dis) //throws IOException { - m_uiVal = (unsigned int)dis->readInt(); + m_uiVal = static_cast(dis->readInt()); } void DebugOptionsPacket::write(DataOutputStream *dos) // throws IOException { - dos->writeInt((int)m_uiVal); + dos->writeInt(static_cast(m_uiVal)); } int DebugOptionsPacket::getEstimatedSize() diff --git a/Minecraft.World/DesertBiome.cpp b/Minecraft.World/DesertBiome.cpp index c36b09081..e67faef57 100644 --- a/Minecraft.World/DesertBiome.cpp +++ b/Minecraft.World/DesertBiome.cpp @@ -10,8 +10,8 @@ DesertBiome::DesertBiome(int id) : Biome(id) friendlies.clear(); friendlies_chicken.clear(); // 4J added friendlies_wolf.clear(); // 4J added - topMaterial = (BYTE) Tile::sand_Id; - material = (BYTE) Tile::sand_Id; + topMaterial = static_cast(Tile::sand_Id); + material = static_cast(Tile::sand_Id); decorator->treeCount = -999; decorator->deadBushCount = 2; diff --git a/Minecraft.World/Dimension.cpp b/Minecraft.World/Dimension.cpp index 697da010b..75e225b3c 100644 --- a/Minecraft.World/Dimension.cpp +++ b/Minecraft.World/Dimension.cpp @@ -30,7 +30,7 @@ void Dimension::updateLightRamp() float ambientLight = 0.00f; for (int i = 0; i <= Level::MAX_BRIGHTNESS; i++) { - float v = (1 - i / (float) (Level::MAX_BRIGHTNESS)); + float v = (1 - i / static_cast(Level::MAX_BRIGHTNESS)); brightnessRamp[i] = ((1 - v) / (v * 3 + 1)) * (1 - ambientLight) + ambientLight; } } @@ -115,7 +115,7 @@ bool Dimension::isValidSpawn(int x, int z) const float Dimension::getTimeOfDay(__int64 time, float a) const { - int dayStep = (int) (time % Level::TICKS_PER_DAY); + int dayStep = static_cast(time % Level::TICKS_PER_DAY); float td = (dayStep + a) / Level::TICKS_PER_DAY - 0.25f; if (td < 0) td += 1; if (td > 1) td -= 1; @@ -127,7 +127,7 @@ float Dimension::getTimeOfDay(__int64 time, float a) const int Dimension::getMoonPhase(__int64 time) const { - return ((int) (time / Level::TICKS_PER_DAY)) % 8; + return static_cast(time / Level::TICKS_PER_DAY) % 8; } bool Dimension::isNaturalDimension() @@ -197,7 +197,7 @@ Dimension *Dimension::getNew(int id) float Dimension::getCloudHeight() { - return (float)Level::genDepth; + return static_cast(Level::genDepth); } bool Dimension::hasGround() diff --git a/Minecraft.World/Direction.cpp b/Minecraft.World/Direction.cpp index f758798b4..c9ac93c76 100644 --- a/Minecraft.World/Direction.cpp +++ b/Minecraft.World/Direction.cpp @@ -65,7 +65,7 @@ int Direction::RELATIVE_DIRECTION_FACING[4][6] = int Direction::getDirection(double xd, double zd) { - if (Mth::abs((float) xd) > Mth::abs((float) zd)) + if (Mth::abs(static_cast(xd)) > Mth::abs(static_cast(zd))) { if (xd > 0) { diff --git a/Minecraft.World/DirectoryLevelStorage.cpp b/Minecraft.World/DirectoryLevelStorage.cpp index facd949af..73c841e0f 100644 --- a/Minecraft.World/DirectoryLevelStorage.cpp +++ b/Minecraft.World/DirectoryLevelStorage.cpp @@ -108,7 +108,7 @@ void _MapDataMappings_old::setMapping(int id, PlayerUID xuid, int dimension) #ifdef _LARGE_WORLDS void DirectoryLevelStorage::PlayerMappings::addMapping(int id, int centreX, int centreZ, int dimension, int scale) { - __int64 index = ( ((__int64)(centreZ & 0x1FFFFFFF)) << 34) | ( ((__int64)(centreX & 0x1FFFFFFF)) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); + __int64 index = ( static_cast<__int64>(centreZ & 0x1FFFFFFF) << 34) | ( static_cast<__int64>(centreX & 0x1FFFFFFF) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); m_mappings[index] = id; //app.DebugPrintf("Adding mapping: %d - (%d,%d)/%d/%d [%I64d - 0x%016llx]\n", id, centreX, centreZ, dimension, scale, index, index); } @@ -120,7 +120,7 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int &id, int centreX, int //__int64 zShifted = zMasked << 34; //__int64 xShifted = xMasked << 5; //app.DebugPrintf("xShifted = %d (0x%016x), zShifted = %I64d (0x%016llx)\n", xShifted, xShifted, zShifted, zShifted); - __int64 index = ( ((__int64)(centreZ & 0x1FFFFFFF)) << 34) | ( ((__int64)(centreX & 0x1FFFFFFF)) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); + __int64 index = ( static_cast<__int64>(centreZ & 0x1FFFFFFF) << 34) | ( static_cast<__int64>(centreX & 0x1FFFFFFF) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); auto it = m_mappings.find(index); if(it != m_mappings.end()) { diff --git a/Minecraft.World/DisconnectPacket.cpp b/Minecraft.World/DisconnectPacket.cpp index da20686a0..0b6f6bf80 100644 --- a/Minecraft.World/DisconnectPacket.cpp +++ b/Minecraft.World/DisconnectPacket.cpp @@ -19,7 +19,7 @@ DisconnectPacket::DisconnectPacket(eDisconnectReason reason) void DisconnectPacket::read(DataInputStream *dis) //throws IOException { - reason = (eDisconnectReason)dis->readInt(); + reason = static_cast(dis->readInt()); } void DisconnectPacket::write(DataOutputStream *dos) //throws IOException diff --git a/Minecraft.World/DispenserTile.cpp b/Minecraft.World/DispenserTile.cpp index 8758b3c52..2e141948b 100644 --- a/Minecraft.World/DispenserTile.cpp +++ b/Minecraft.World/DispenserTile.cpp @@ -207,12 +207,12 @@ void DispenserTile::onRemove(Level *level, int x, int y, int z, int id, int data newItem->set4JData( item->get4JData() ); shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) ); float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; + itemEntity->xd = static_cast(random->nextGaussian()) * pow; + itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random->nextGaussian()) * pow; if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + itemEntity->getItem()->setTag(static_cast(item->getTag()->copy())); } level->addEntity(itemEntity); } diff --git a/Minecraft.World/DispenserTileEntity.cpp b/Minecraft.World/DispenserTileEntity.cpp index 3e743e22e..2a00f4cd5 100644 --- a/Minecraft.World/DispenserTileEntity.cpp +++ b/Minecraft.World/DispenserTileEntity.cpp @@ -189,7 +189,7 @@ void DispenserTileEntity::save(CompoundTag *base) if (items[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); items[i]->save(tag); listTag->add(tag); } diff --git a/Minecraft.World/DoorInfo.cpp b/Minecraft.World/DoorInfo.cpp index 0c61b6356..177b88858 100644 --- a/Minecraft.World/DoorInfo.cpp +++ b/Minecraft.World/DoorInfo.cpp @@ -12,7 +12,7 @@ DoorInfo::DoorInfo(int x, int y, int z, int insideDx, int insideDy, int timeStam int DoorInfo::distanceTo(int x2, int y2, int z2) { - return (int) sqrt((float)distanceToSqr(x2, y2, z2)); + return static_cast(sqrt((float)distanceToSqr(x2, y2, z2))); } int DoorInfo::distanceToSqr(int x2, int y2, int z2) diff --git a/Minecraft.World/DoorInteractGoal.cpp b/Minecraft.World/DoorInteractGoal.cpp index 1e3bfe11b..fc4a9a68e 100644 --- a/Minecraft.World/DoorInteractGoal.cpp +++ b/Minecraft.World/DoorInteractGoal.cpp @@ -50,14 +50,14 @@ bool DoorInteractGoal::canContinueToUse() void DoorInteractGoal::start() { passed = false; - doorOpenDirX = (float) (doorX + 0.5f - mob->x); - doorOpenDirZ = (float) (doorZ + 0.5f - mob->z); + doorOpenDirX = static_cast(doorX + 0.5f - mob->x); + doorOpenDirZ = static_cast(doorZ + 0.5f - mob->z); } void DoorInteractGoal::tick() { - float newDoorDirX = (float) (doorX + 0.5f - mob->x); - float newDoorDirZ = (float) (doorZ + 0.5f - mob->z); + float newDoorDirX = static_cast(doorX + 0.5f - mob->x); + float newDoorDirZ = static_cast(doorZ + 0.5f - mob->z); float dot = doorOpenDirX * newDoorDirX + doorOpenDirZ * newDoorDirZ; if (dot < 0) { @@ -69,5 +69,5 @@ DoorTile *DoorInteractGoal::getDoorTile(int x, int y, int z) { int tileId = mob->level->getTile(x, y, z); if (tileId != Tile::door_wood_Id) return NULL; - return (DoorTile *) Tile::tiles[tileId]; + return static_cast(Tile::tiles[tileId]); } \ No newline at end of file diff --git a/Minecraft.World/DoubleTag.h b/Minecraft.World/DoubleTag.h index 1f768d5bf..60e5808a4 100644 --- a/Minecraft.World/DoubleTag.h +++ b/Minecraft.World/DoubleTag.h @@ -29,7 +29,7 @@ class DoubleTag : public Tag { if (Tag::equals(obj)) { - DoubleTag *o = (DoubleTag *) obj; + DoubleTag *o = static_cast(obj); return data == o->data; } return false; diff --git a/Minecraft.World/DragonFireball.cpp b/Minecraft.World/DragonFireball.cpp index 335b345f4..348bc53e4 100644 --- a/Minecraft.World/DragonFireball.cpp +++ b/Minecraft.World/DragonFireball.cpp @@ -54,7 +54,7 @@ void DragonFireball::onHit(HitResult *res) } delete entitiesOfClass; } - level->levelEvent(LevelEvent::ENDERDRAGON_FIREBALL_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), 0); + level->levelEvent(LevelEvent::ENDERDRAGON_FIREBALL_SPLASH, static_cast(Math::round(x)), static_cast(Math::round(y)), static_cast(Math::round(z)), 0); remove(); } diff --git a/Minecraft.World/DungeonFeature.cpp b/Minecraft.World/DungeonFeature.cpp index 6c7dc6733..8c9abbe5e 100644 --- a/Minecraft.World/DungeonFeature.cpp +++ b/Minecraft.World/DungeonFeature.cpp @@ -142,12 +142,12 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, byteArray blocks, double xC { if (yy < 10) { - blocks[p] = (byte) Tile::lava_Id; + blocks[p] = static_cast(Tile::lava_Id); } else { - blocks[p] = (byte) 0; - if (hasGrass && blocks[p - 1] == Tile::dirt_Id) blocks[p - 1] = (byte) Tile::grass_Id; + blocks[p] = static_cast(0); + if (hasGrass && blocks[p - 1] == Tile::dirt_Id) blocks[p - 1] = static_cast(Tile::grass_Id); } } } diff --git a/Minecraft.World/DurangoStats.cpp b/Minecraft.World/DurangoStats.cpp index 6e50fd20d..7ec808bc6 100644 --- a/Minecraft.World/DurangoStats.cpp +++ b/Minecraft.World/DurangoStats.cpp @@ -345,7 +345,7 @@ void DsMobInteract::handleParamBlob(shared_ptr player, byteArray pa byteArray DsMobInteract::createParamBlob(eInteract interactionId, int entityId) { byteArray output; - Param param = { interactionId, EntityIO::eTypeToIoid((eINSTANCEOF)entityId) }; + Param param = { interactionId, EntityIO::eTypeToIoid(static_cast(entityId)) }; output.data = (byte*) new Param(param); output.length = sizeof(Param); return output; @@ -423,7 +423,7 @@ void DsTravel::flush(shared_ptr player) { if (param_cache[iPad][i] > 0) { - write( player, (eMethod) i, param_cache[iPad][i] ); + write( player, static_cast(i), param_cache[iPad][i] ); param_cache[iPad][i] = 0; } } @@ -1093,25 +1093,25 @@ bool DurangoStats::enhancedAchievement(eAward achievementId) void DurangoStats::generatePlayerSession() { - DurangoStats *dsInstance = (DurangoStats *) GenericStats::getInstance(); + DurangoStats *dsInstance = static_cast(GenericStats::getInstance()); CoCreateGuid( &dsInstance->playerSessionId ); } LPCGUID DurangoStats::getPlayerSession() { - DurangoStats *dsInstance = (DurangoStats *) GenericStats::getInstance(); + DurangoStats *dsInstance = static_cast(GenericStats::getInstance()); LPCGUID lpcguid = &dsInstance->playerSessionId; return lpcguid; } void DurangoStats::setMultiplayerCorrelationId(Platform::String^ mcpId) { - ((DurangoStats*)GenericStats::getInstance())->multiplayerCorrelationId = mcpId; + static_cast(GenericStats::getInstance())->multiplayerCorrelationId = mcpId; } LPCWSTR DurangoStats::getMultiplayerCorrelationId() { - return ((DurangoStats*)GenericStats::getInstance())->multiplayerCorrelationId->Data(); + return static_cast(GenericStats::getInstance())->multiplayerCorrelationId->Data(); } LPCWSTR DurangoStats::getUserId(shared_ptr player) diff --git a/Minecraft.World/DurangoStats.h b/Minecraft.World/DurangoStats.h index 1b2f7723c..b2f24643c 100644 --- a/Minecraft.World/DurangoStats.h +++ b/Minecraft.World/DurangoStats.h @@ -165,7 +165,7 @@ class DsEnteredBiome : public Stat class DurangoStats : public GenericStats { public: - static DurangoStats *getInstance() { return (DurangoStats*) GenericStats::getInstance(); } + static DurangoStats *getInstance() { return static_cast(GenericStats::getInstance()); } protected: enum { diff --git a/Minecraft.World/DyePowderItem.cpp b/Minecraft.World/DyePowderItem.cpp index b4ab86fa3..81faf63fc 100644 --- a/Minecraft.World/DyePowderItem.cpp +++ b/Minecraft.World/DyePowderItem.cpp @@ -177,7 +177,7 @@ bool DyePowderItem::growCrop(shared_ptr itemInstance, Level *level { if (!level->isClientSide) { - if (level->random->nextFloat() < 0.45) ((Sapling *) Tile::sapling)->advanceTree(level, x, y, z, level->random); + if (level->random->nextFloat() < 0.45) static_cast(Tile::sapling)->advanceTree(level, x, y, z, level->random); itemInstance->count--; } } @@ -189,7 +189,7 @@ bool DyePowderItem::growCrop(shared_ptr itemInstance, Level *level { if (!level->isClientSide) { - if (level->random->nextFloat() < 0.4) ((Mushroom *) Tile::tiles[tile])->growTree(level, x, y, z, level->random); + if (level->random->nextFloat() < 0.4) static_cast(Tile::tiles[tile])->growTree(level, x, y, z, level->random); itemInstance->count--; } } @@ -202,7 +202,7 @@ bool DyePowderItem::growCrop(shared_ptr itemInstance, Level *level { if (!level->isClientSide) { - ((StemTile *) Tile::tiles[tile])->growCrops(level, x, y, z); + static_cast(Tile::tiles[tile])->growCrops(level, x, y, z); itemInstance->count--; } } @@ -215,7 +215,7 @@ bool DyePowderItem::growCrop(shared_ptr itemInstance, Level *level { if (!level->isClientSide) { - ((CropTile *) Tile::tiles[tile])->growCrops(level, x, y, z); + static_cast(Tile::tiles[tile])->growCrops(level, x, y, z); itemInstance->count--; } } @@ -228,7 +228,7 @@ bool DyePowderItem::growCrop(shared_ptr itemInstance, Level *level { if (!level->isClientSide) { - ((CropTile *) Tile::tiles[tile])->growCrops(level, x, y, z); + static_cast(Tile::tiles[tile])->growCrops(level, x, y, z); itemInstance->count--; } } diff --git a/Minecraft.World/EnchantedBookItem.cpp b/Minecraft.World/EnchantedBookItem.cpp index 88776c18d..590c8bda6 100644 --- a/Minecraft.World/EnchantedBookItem.cpp +++ b/Minecraft.World/EnchantedBookItem.cpp @@ -40,7 +40,7 @@ ListTag *EnchantedBookItem::getEnchantments(shared_ptr(); } - return (ListTag *) item->tag->get((wchar_t *)TAG_STORED_ENCHANTMENTS.c_str()); + return static_cast *>(item->tag->get((wchar_t *)TAG_STORED_ENCHANTMENTS.c_str())); } void EnchantedBookItem::appendHoverText(shared_ptr itemInstance, shared_ptr player, vector *lines, bool advanced) @@ -78,7 +78,7 @@ void EnchantedBookItem::addEnchantment(shared_ptr item, Enchantmen { if (tag->getShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL) < enchantment->level) { - tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, (short) enchantment->level); + tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, static_cast(enchantment->level)); } add = false; @@ -90,8 +90,8 @@ void EnchantedBookItem::addEnchantment(shared_ptr item, Enchantmen { CompoundTag *tag = new CompoundTag(); - tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, (short) enchantment->enchantment->id); - tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, (short) enchantment->level); + tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, static_cast(enchantment->enchantment->id)); + tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, static_cast(enchantment->level)); enchantments->add(tag); } diff --git a/Minecraft.World/EnchantmentCategory.cpp b/Minecraft.World/EnchantmentCategory.cpp index 7fb44481e..b7460f58e 100644 --- a/Minecraft.World/EnchantmentCategory.cpp +++ b/Minecraft.World/EnchantmentCategory.cpp @@ -19,7 +19,7 @@ bool EnchantmentCategory::canEnchant(Item *item) const if (dynamic_cast( item ) != NULL) { if (this == armor) return true; - ArmorItem *ai = (ArmorItem *) item; + ArmorItem *ai = static_cast(item); if (ai->slot == ArmorItem::SLOT_HEAD) return this == armor_head; if (ai->slot == ArmorItem::SLOT_LEGS) return this == armor_legs; if (ai->slot == ArmorItem::SLOT_TORSO) return this == armor_torso; diff --git a/Minecraft.World/EnchantmentHelper.cpp b/Minecraft.World/EnchantmentHelper.cpp index 7abc9856e..8f4f4ed19 100644 --- a/Minecraft.World/EnchantmentHelper.cpp +++ b/Minecraft.World/EnchantmentHelper.cpp @@ -62,8 +62,8 @@ void EnchantmentHelper::setEnchantments(unordered_map *enchantments, s int id = it.first; CompoundTag *tag = new CompoundTag(); - tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, (short) id); - tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, (short)(int)it.second); + tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, static_cast(id)); + tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, static_cast((int)it.second)); list->add(tag); @@ -348,7 +348,7 @@ vector *EnchantmentHelper::selectEnchantment(Random *rand // the final enchantment cost will have another random span of +- 15% float deviation = (random->nextFloat() + random->nextFloat() - 1.0f) * .15f; - int realValue = (int) ((float) enchantmentValue * (1.0f + deviation) + .5f); + int realValue = static_cast((float)enchantmentValue * (1.0f + deviation) + .5f); if (realValue < 1) { realValue = 1; @@ -364,7 +364,7 @@ vector *EnchantmentHelper::selectEnchantment(Random *rand { values.push_back(it.second); } - EnchantmentInstance *instance = (EnchantmentInstance *) WeighedRandom::getRandomItem(random, &values); + EnchantmentInstance *instance = static_cast(WeighedRandom::getRandomItem(random, &values)); values.clear(); if (instance) @@ -409,7 +409,7 @@ vector *EnchantmentHelper::selectEnchantment(Random *rand { values.push_back(it.second); } - EnchantmentInstance *nextInstance = (EnchantmentInstance *) WeighedRandom::getRandomItem(random, &values); + EnchantmentInstance *nextInstance = static_cast(WeighedRandom::getRandomItem(random, &values)); values.clear(); results->push_back( nextInstance->copy() ); // 4J Stu - Inserting a copy so we can clear memory from the availableEnchantments collection } diff --git a/Minecraft.World/EnchantmentInstance.cpp b/Minecraft.World/EnchantmentInstance.cpp index 973cd2200..89a8bdd2f 100644 --- a/Minecraft.World/EnchantmentInstance.cpp +++ b/Minecraft.World/EnchantmentInstance.cpp @@ -13,5 +13,5 @@ EnchantmentInstance::EnchantmentInstance(int id, int level) : WeighedRandomItem( // 4J Added EnchantmentInstance *EnchantmentInstance::copy() { - return new EnchantmentInstance((Enchantment *)enchantment, (int)level); + return new EnchantmentInstance((Enchantment *)enchantment, static_cast(level)); } \ No newline at end of file diff --git a/Minecraft.World/EnchantmentTableEntity.cpp b/Minecraft.World/EnchantmentTableEntity.cpp index 15131aa29..0b722680b 100644 --- a/Minecraft.World/EnchantmentTableEntity.cpp +++ b/Minecraft.World/EnchantmentTableEntity.cpp @@ -51,7 +51,7 @@ void EnchantmentTableEntity::tick() double xd = player->x - (x + 0.5f); double zd = player->z - (z + 0.5f); - tRot = (float) atan2(zd, xd); + tRot = static_cast(atan2(zd, xd)); open += 0.1f; diff --git a/Minecraft.World/EnderDragon.cpp b/Minecraft.World/EnderDragon.cpp index e1dea1725..608f0cd59 100644 --- a/Minecraft.World/EnderDragon.cpp +++ b/Minecraft.World/EnderDragon.cpp @@ -220,7 +220,7 @@ void EnderDragon::aiStep() checkCrystals(); float flapSpeed = 0.2f / (sqrt(xd * xd + zd * zd) * 10.0f + 1); - flapSpeed *= (float) pow(2.0, yd); + flapSpeed *= static_cast(pow(2.0, yd)); if ( getSynchedAction() == e_EnderdragonAction_Sitting_Flaming || getSynchedAction() == e_EnderdragonAction_Sitting_Scanning || getSynchedAction() == e_EnderdragonAction_Sitting_Attacking) @@ -468,7 +468,7 @@ void EnderDragon::aiStep() { Vec3 *aim = Vec3::newTemp((attackTarget->x - x), 0, (attackTarget->z - z))->normalize(); Vec3 *dir = Vec3::newTemp(sin(yRot * PI / 180), 0, -cos(yRot * PI / 180))->normalize(); - float dot = (float)dir->dot(aim); + float dot = static_cast(dir->dot(aim)); float angleDegs = acos(dot)*180/PI; angleDegs = angleDegs + 0.5f; @@ -561,7 +561,7 @@ void EnderDragon::aiStep() Vec3 *aim = Vec3::newTemp((xTarget - x), (yTarget - y), (zTarget - z))->normalize(); Vec3 *dir = Vec3::newTemp(sin(yRot * PI / 180), yd, -cos(yRot * PI / 180))->normalize(); - float dot = (float) (dir->dot(aim) + 0.5f) / 1.5f; + float dot = static_cast(dir->dot(aim) + 0.5f) / 1.5f; if (dot < 0) dot = 0; yRotA *= 0.80f; @@ -579,7 +579,7 @@ void EnderDragon::aiStep() } yRot += yRotA * 0.1f; - float span = (float) (2.0f / (distToTarget + 1)); + float span = static_cast(2.0f / (distToTarget + 1)); float speed = 0.06f; moveRelative(0, -1, speed * (dot * span + (1 - span))); if (inWall) @@ -593,7 +593,7 @@ void EnderDragon::aiStep() } Vec3 *actual = Vec3::newTemp(xd, yd, zd)->normalize(); - float slide = (float) (actual->dot(dir) + 1) / 2.0f; + float slide = static_cast(actual->dot(dir) + 1) / 2.0f; slide = 0.8f + 0.15f * slide; @@ -722,7 +722,7 @@ void EnderDragon::aiStep() m_fireballCharge++; Vec3 *aim = Vec3::newTemp((attackTarget->x - x), 0, (attackTarget->z - z))->normalize(); Vec3 *dir = Vec3::newTemp(sin(yRot * PI / 180), 0, -cos(yRot * PI / 180))->normalize(); - float dot = (float)dir->dot(aim); + float dot = static_cast(dir->dot(aim)); float angleDegs = acos(dot)*180/PI; angleDegs = angleDegs + 0.5f; @@ -738,7 +738,7 @@ void EnderDragon::aiStep() double ydd = (attackTarget->bb->y0 + attackTarget->bbHeight / 2) - (startingY + head->bbHeight / 2); double zdd = attackTarget->z - startingZ; - level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); shared_ptr ie = shared_ptr( new DragonFireball(level, dynamic_pointer_cast( shared_from_this() ), xdd, ydd, zdd) ); ie->x = startingX; ie->y = startingY; @@ -1063,7 +1063,7 @@ float EnderDragon::rotWrap(double d) d -= 360; while (d < -180) d += 360; - return (float) d; + return static_cast(d); } bool EnderDragon::checkWalls(AABB *bb) @@ -1219,7 +1219,7 @@ void EnderDragon::tickDeath() } if (dragonDeathTime == 1) { - level->globalLevelEvent(LevelEvent::SOUND_DRAGON_DEATH, (int) x, (int) y, (int) z, 0); + level->globalLevelEvent(LevelEvent::SOUND_DRAGON_DEATH, static_cast(x), static_cast(y), static_cast(z), 0); } } move(0, 0.1f, 0); @@ -1458,14 +1458,14 @@ bool EnderDragon::setSynchedAction(EEnderdragonAction action, bool force /*= fal EnderDragon::EEnderdragonAction EnderDragon::getSynchedAction() { - return (EEnderdragonAction)entityData->getInteger(DATA_ID_SYNCHED_ACTION); + return static_cast(entityData->getInteger(DATA_ID_SYNCHED_ACTION)); } void EnderDragon::handleCrystalDestroyed(DamageSource *source) { AABB *tempBB = AABB::newTemp(PODIUM_X_POS,84.0,PODIUM_Z_POS,PODIUM_X_POS+1.0,85.0,PODIUM_Z_POS+1.0); vector > *crystals = level->getEntitiesOfClass(typeid(EnderCrystal), tempBB->grow(48, 40, 48)); - m_remainingCrystalsCount = (int)crystals->size() - 1; + m_remainingCrystalsCount = static_cast(crystals->size()) - 1; if(m_remainingCrystalsCount < 0) m_remainingCrystalsCount = 0; delete crystals; @@ -1641,7 +1641,7 @@ int EnderDragon::findClosestNode(double tX, double tY, double tZ) { float closestDist = 100.0f; int closestIndex = 0; - Node *currentPos = new Node((int) floor(tX), (int) floor(tY), (int) floor(tZ)); + Node *currentPos = new Node(static_cast(floor(tX)), static_cast(floor(tY)), static_cast(floor(tZ))); int startIndex = 0; if(m_remainingCrystalsCount <= 0) { @@ -1805,7 +1805,7 @@ void EnderDragon::readAdditionalSaveData(CompoundTag *tag) m_remainingCrystalsCount = tag->getShort(L"RemainingCrystals"); if(!tag->contains(L"RemainingCrystals")) m_remainingCrystalsCount = CRYSTAL_COUNT; - if(tag->contains(L"DragonState")) setSynchedAction( (EEnderdragonAction)tag->getInt(L"DragonState"), true); + if(tag->contains(L"DragonState")) setSynchedAction( static_cast(tag->getInt(L"DragonState")), true); Mob::readAdditionalSaveData(tag); } diff --git a/Minecraft.World/EnderEyeItem.cpp b/Minecraft.World/EnderEyeItem.cpp index 063e1408f..a0c3dad37 100644 --- a/Minecraft.World/EnderEyeItem.cpp +++ b/Minecraft.World/EnderEyeItem.cpp @@ -212,7 +212,7 @@ shared_ptr EnderEyeItem::use(shared_ptr instance, Le level->addEntity(eyeOfEnderSignal); level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - level->levelEvent(nullptr, LevelEvent::SOUND_LAUNCH, (int) player->x, (int) player->y, (int) player->z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_LAUNCH, static_cast(player->x), static_cast(player->y), static_cast(player->z), 0); if (!player->abilities.instabuild) { instance->count--; diff --git a/Minecraft.World/EnderMan.cpp b/Minecraft.World/EnderMan.cpp index d099911c0..d21f62d76 100644 --- a/Minecraft.World/EnderMan.cpp +++ b/Minecraft.World/EnderMan.cpp @@ -67,16 +67,16 @@ void EnderMan::defineSynchedData() { Monster::defineSynchedData(); - entityData->define(DATA_CARRY_ITEM_ID, (byte) 0); - entityData->define(DATA_CARRY_ITEM_DATA, (byte) 0); - entityData->define(DATA_CREEPY, (byte) 0); + entityData->define(DATA_CARRY_ITEM_ID, static_cast(0)); + entityData->define(DATA_CARRY_ITEM_DATA, static_cast(0)); + entityData->define(DATA_CREEPY, static_cast(0)); } void EnderMan::addAdditonalSaveData(CompoundTag *tag) { Monster::addAdditonalSaveData(tag); - tag->putShort(L"carried", (short) getCarryingTile()); - tag->putShort(L"carriedData", (short) getCarryingData()); + tag->putShort(L"carried", static_cast(getCarryingTile())); + tag->putShort(L"carriedData", static_cast(getCarryingData())); } void EnderMan::readAdditionalSaveData(CompoundTag *tag) @@ -202,7 +202,7 @@ void EnderMan::aiStep() float br = getBrightness(1); if (br > 0.5f) { - if (level->canSeeSky(Mth::floor(x), (int)floor( y + 0.5 ), Mth::floor(z)) && random->nextFloat() * 30 < (br - 0.4f) * 2) + if (level->canSeeSky(Mth::floor(x), static_cast(floor(y + 0.5)), Mth::floor(z)) && random->nextFloat() * 30 < (br - 0.4f) * 2) { attackTarget = nullptr; setCreepy(false); @@ -385,7 +385,7 @@ void EnderMan::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) // 4J Brought forward from 1.2.3 to help fix Enderman behaviour void EnderMan::setCarryingTile(int carryingTile) { - entityData->set(DATA_CARRY_ITEM_ID, (byte) (carryingTile & 0xff)); + entityData->set(DATA_CARRY_ITEM_ID, static_cast(carryingTile & 0xff)); } int EnderMan::getCarryingTile() @@ -395,7 +395,7 @@ int EnderMan::getCarryingTile() void EnderMan::setCarryingData(int carryingData) { - entityData->set(DATA_CARRY_ITEM_DATA, (byte) (carryingData & 0xff)); + entityData->set(DATA_CARRY_ITEM_DATA, static_cast(carryingData & 0xff)); } int EnderMan::getCarryingData() @@ -435,5 +435,5 @@ bool EnderMan::isCreepy() void EnderMan::setCreepy(bool creepy) { - entityData->set(DATA_CREEPY, (byte)(creepy ? 1 : 0)); + entityData->set(DATA_CREEPY, static_cast(creepy ? 1 : 0)); } \ No newline at end of file diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index e82331402..6a8107302 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -362,7 +362,7 @@ Entity::Entity(Level *level, bool useSmallId) // 4J - added useSmallId parameter if( entityData ) { - entityData->define(DATA_SHARED_FLAGS_ID, (byte) 0); + entityData->define(DATA_SHARED_FLAGS_ID, static_cast(0)); entityData->define(DATA_AIR_SUPPLY_ID, TOTAL_AIR_SUPPLY); // 4J Stu - Brought forward from 1.2.3 to fix 38654 - Gameplay: Player will take damage when air bubbles are present if resuming game from load/autosave underwater. } @@ -907,7 +907,7 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J - if (moveDist > nextStep && t > 0) { - nextStep = (int) moveDist + 1; + nextStep = static_cast(moveDist) + 1; if (isInWater()) { float speed = Mth::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.35f; @@ -1023,7 +1023,7 @@ void Entity::checkFallDamage(double ya, bool onGround) } else { - if (ya < 0) fallDistance -= (float) ya; + if (ya < 0) fallDistance -= static_cast(ya); } } @@ -1072,7 +1072,7 @@ bool Entity::updateInWaterState() MemSect(31); playSound(eSoundType_RANDOM_SPLASH, speed, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f); MemSect(0); - float yt = (float) Mth::floor(bb->y0); + float yt = static_cast(Mth::floor(bb->y0)); for (int i = 0; i < 1 + bbWidth * 20; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth; @@ -1202,9 +1202,9 @@ void Entity::moveTo(double x, double y, double z, float yRot, float xRot) float Entity::distanceTo(shared_ptr e) { - float xd = (float) (x - e->x); - float yd = (float) (y - e->y); - float zd = (float) (z - e->z); + float xd = static_cast(x - e->x); + float yd = static_cast(y - e->y); + float zd = static_cast(z - e->z); return sqrt(xd * xd + yd * yd + zd * zd); } @@ -1365,8 +1365,8 @@ void Entity::saveWithoutId(CompoundTag *entityTag) entityTag->put(L"Rotation", newFloatList(2, yRot, xRot)); entityTag->putFloat(L"FallDistance", fallDistance); - entityTag->putShort(L"Fire", (short) onFire); - entityTag->putShort(L"Air", (short) getAirSupply()); + entityTag->putShort(L"Fire", static_cast(onFire)); + entityTag->putShort(L"Air", static_cast(getAirSupply())); entityTag->putBoolean(L"OnGround", onGround); entityTag->putInt(L"Dimension", dimension); entityTag->putBoolean(L"Invulnerable", invulnerable); @@ -1823,11 +1823,11 @@ void Entity::setSharedFlag(int flag, bool value) byte currentValue = entityData->getByte(DATA_SHARED_FLAGS_ID); if (value) { - entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue | (1 << flag))); + entityData->set(DATA_SHARED_FLAGS_ID, static_cast(currentValue | (1 << flag))); } else { - entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue & ~(1 << flag))); + entityData->set(DATA_SHARED_FLAGS_ID, static_cast(currentValue & ~(1 << flag))); } } } @@ -1841,7 +1841,7 @@ int Entity::getAirSupply() // 4J Stu - Brought forward from 1.2.3 to fix 38654 - Gameplay: Player will take damage when air bubbles are present if resuming game from load/autosave underwater. void Entity::setAirSupply(int supply) { - entityData->set(DATA_AIR_SUPPLY_ID, (short) supply); + entityData->set(DATA_AIR_SUPPLY_ID, static_cast(supply)); } void Entity::thunderHit(const LightningBolt *lightningBolt) diff --git a/Minecraft.World/EntityHorse.cpp b/Minecraft.World/EntityHorse.cpp index 90c2a6b99..9636c9892 100644 --- a/Minecraft.World/EntityHorse.cpp +++ b/Minecraft.World/EntityHorse.cpp @@ -100,7 +100,7 @@ void EntityHorse::defineSynchedData() { Animal::defineSynchedData(); entityData->define(DATA_ID_HORSE_FLAGS, 0); - entityData->define(DATA_ID_TYPE, (byte) 0); + entityData->define(DATA_ID_TYPE, static_cast(0)); entityData->define(DATA_ID_TYPE_VARIANT, 0); entityData->define(DATA_ID_OWNER_NAME, L""); entityData->define(DATA_ID_ARMOR, 0); @@ -108,7 +108,7 @@ void EntityHorse::defineSynchedData() void EntityHorse::setType(int i) { - entityData->set(DATA_ID_TYPE, (byte) i); + entityData->set(DATA_ID_TYPE, static_cast(i)); clearLayeredTextureInfo(); } @@ -202,7 +202,7 @@ float EntityHorse::getFoalScale() { return 1.0f; } - return .5f + (float) (BABY_START_AGE - age) / (float) BABY_START_AGE * .5f; + return .5f + static_cast(BABY_START_AGE - age) / static_cast(BABY_START_AGE) * .5f; } @@ -995,7 +995,7 @@ bool EntityHorse::mobInteract(shared_ptr player) } doPlayerRide(player); - app.DebugPrintf(" Horse speed: %f\n", (float) (getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue())); + app.DebugPrintf(" Horse speed: %f\n", static_cast(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue())); return true; } @@ -1098,7 +1098,7 @@ int EntityHorse::nameYOffset() } else { - return (int) (-5 - getFoalScale() * 80.0f); + return static_cast(-5 - getFoalScale() * 80.0f); } } @@ -1407,7 +1407,7 @@ void EntityHorse::travel(float xa, float ya) flyingSpeed = getSpeed() * .1f; if (!level->isClientSide) { - setSpeed((float) (getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue())); + setSpeed(static_cast(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue())); Animal::travel(xa, ya); } @@ -1459,7 +1459,7 @@ void EntityHorse::addAdditonalSaveData(CompoundTag *tag) { CompoundTag *compoundTag = new CompoundTag(); - compoundTag->putByte(L"Slot", (byte) i); + compoundTag->putByte(L"Slot", static_cast(i)); stack->save(compoundTag); listTag->add(compoundTag); @@ -1639,8 +1639,8 @@ MobGroupData *EntityHorse::finalizeMobSpawn(MobGroupData *groupData, int extraDa if ( dynamic_cast(groupData) != NULL ) { - type = ((HorseGroupData *) groupData)->horseType; - variant = ((HorseGroupData *) groupData)->horseVariant & 0xff | (random->nextInt(MARKINGS) << 8); + type = static_cast(groupData)->horseType; + variant = static_cast(groupData)->horseVariant & 0xff | (random->nextInt(MARKINGS) << 8); } else { @@ -1744,7 +1744,7 @@ void EntityHorse::onPlayerJump(int jumpAmount) } else { - playerJumpPendingScale = .4f + .4f * (float) jumpAmount / 90.0f; + playerJumpPendingScale = .4f + .4f * static_cast(jumpAmount) / 90.0f; } } } diff --git a/Minecraft.World/ExperienceOrb.cpp b/Minecraft.World/ExperienceOrb.cpp index 9fed6d71b..9aad00086 100644 --- a/Minecraft.World/ExperienceOrb.cpp +++ b/Minecraft.World/ExperienceOrb.cpp @@ -35,11 +35,11 @@ ExperienceOrb::ExperienceOrb(Level *level, double x, double y, double z, int cou heightOffset = bbHeight / 2.0f; setPos(x, y, z); - yRot = (float) (Math::random() * 360); + yRot = static_cast(Math::random() * 360); - xd = (float) (Math::random() * 0.2f - 0.1f) * 2; - yd = (float) (Math::random() * 0.2) * 2; - zd = (float) (Math::random() * 0.2f - 0.1f) * 2; + xd = static_cast(Math::random() * 0.2f - 0.1f) * 2; + yd = static_cast(Math::random() * 0.2) * 2; + zd = static_cast(Math::random() * 0.2f - 0.1f) * 2; value = count; } @@ -70,7 +70,7 @@ int ExperienceOrb::getLightColor(float a) int br1 = (br) & 0xff; int br2 = (br >> 16) & 0xff; - br1 += (int) (l * 15 * 16); + br1 += static_cast(l * 15 * 16); if (br1 > 15 * 16) br1 = 15 * 16; // br2 = 15*16; return br1 | br2 << 16; @@ -176,9 +176,9 @@ bool ExperienceOrb::hurt(DamageSource *source, float damage) void ExperienceOrb::addAdditonalSaveData(CompoundTag *entityTag) { - entityTag->putShort(L"Health", (byte) health); - entityTag->putShort(L"Age", (short) age); - entityTag->putShort(L"Value", (short) value); + entityTag->putShort(L"Health", static_cast(health)); + entityTag->putShort(L"Age", static_cast(age)); + entityTag->putShort(L"Value", static_cast(value)); } void ExperienceOrb::readAdditionalSaveData(CompoundTag *tag) diff --git a/Minecraft.World/ExplodePacket.cpp b/Minecraft.World/ExplodePacket.cpp index 30d09e464..07626161f 100644 --- a/Minecraft.World/ExplodePacket.cpp +++ b/Minecraft.World/ExplodePacket.cpp @@ -34,9 +34,9 @@ ExplodePacket::ExplodePacket(double x, double y, double z, float r, unordered_se if (knockback != nullptr) { - knockbackX = (float) knockback->x; - knockbackY = (float) knockback->y; - knockbackZ = (float) knockback->z; + knockbackX = static_cast(knockback->x); + knockbackY = static_cast(knockback->y); + knockbackZ = static_cast(knockback->z); } } @@ -52,14 +52,14 @@ void ExplodePacket::read(DataInputStream *dis) //throws IOException r = dis->readFloat(); int count = dis->readInt(); - int xp = (int)x; - int yp = (int)y; - int zp = (int)z; + int xp = static_cast(x); + int yp = static_cast(y); + int zp = static_cast(z); for (int i=0; ireadByte())+xp; - int yy = ((signed char)dis->readByte())+yp; - int zz = ((signed char)dis->readByte())+zp; + int xx = static_cast(dis->readByte())+xp; + int yy = static_cast(dis->readByte())+yp; + int zz = static_cast(dis->readByte())+zp; toBlow.push_back( TilePos(xx, yy, zz) ); } } @@ -79,11 +79,11 @@ void ExplodePacket::write(DataOutputStream *dos) //throws IOException dos->writeDouble(y); dos->writeDouble(z); dos->writeFloat(r); - dos->writeInt((int)toBlow.size()); + dos->writeInt(static_cast(toBlow.size())); - int xp = (int)x; - int yp = (int)y; - int zp = (int)z; + int xp = static_cast(x); + int yp = static_cast(y); + int zp = static_cast(z); for ( const TilePos& tp : toBlow ) { @@ -108,7 +108,7 @@ void ExplodePacket::handle(PacketListener *listener) int ExplodePacket::getEstimatedSize() { - return 8*3+4+4+(int)toBlow.size()*3+12; + return 8*3+4+4+static_cast(toBlow.size())*3+12; } float ExplodePacket::getKnockbackX() diff --git a/Minecraft.World/Explosion.cpp b/Minecraft.World/Explosion.cpp index ab305a026..3fc085bec 100644 --- a/Minecraft.World/Explosion.cpp +++ b/Minecraft.World/Explosion.cpp @@ -143,7 +143,7 @@ void Explosion::explode() double sp = level->getSeenPercent(center, e->bb); double pow = (1 - dist) * sp; - if(canDamage) e->hurt(DamageSource::explosion(this), (int) ((pow * pow + pow) / 2 * 8 * r + 1)); + if(canDamage) e->hurt(DamageSource::explosion(this), static_cast((pow * pow + pow) / 2 * 8 * r + 1)); double kbPower = ProtectionEnchantment::getExplosionKnockbackAfterDampener(e, pow); e->xd += xa *kbPower; @@ -185,7 +185,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector *toBlo app.DebugPrintf("Finalizing explosion size %d\n",toBlow.size()); static const int MAX_EXPLODE_PARTICLES = 50; // 4J - try and make at most MAX_EXPLODE_PARTICLES pairs of particles - int fraction = (int)toBlowArray->size() / MAX_EXPLODE_PARTICLES; + int fraction = static_cast(toBlowArray->size()) / MAX_EXPLODE_PARTICLES; if( fraction == 0 ) fraction = 1; size_t j = toBlowArray->size() - 1; //for (size_t j = toBlowArray->size() - 1; j >= 0; j--) diff --git a/Minecraft.World/EyeOfEnderSignal.cpp b/Minecraft.World/EyeOfEnderSignal.cpp index 95747a894..ad2d48fc8 100644 --- a/Minecraft.World/EyeOfEnderSignal.cpp +++ b/Minecraft.World/EyeOfEnderSignal.cpp @@ -80,9 +80,9 @@ void EyeOfEnderSignal::lerpMotion(double xd, double yd, double zd) this->zd = zd; if (xRotO == 0 && yRotO == 0) { - float sd = (float) sqrt(xd * xd + zd * zd); - yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI); - xRotO = xRot = (float) (atan2(yd, (double)sd) * 180 / PI); + float sd = static_cast(sqrt(xd * xd + zd * zd)); + yRotO = yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRotO = xRot = static_cast(atan2(yd, (double)sd) * 180 / PI); } } @@ -97,9 +97,9 @@ void EyeOfEnderSignal::tick() y += yd; z += zd; - float sd = (float) sqrt(xd * xd + zd * zd); - yRot = (float) (atan2(xd, zd) * 180 / PI); - xRot = (float) (atan2(yd, (double)sd) * 180 / PI); + float sd = static_cast(sqrt(xd * xd + zd * zd)); + yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRot = static_cast(atan2(yd, (double)sd) * 180 / PI); while (xRot - xRotO < -180) xRotO -= 360; @@ -117,8 +117,8 @@ void EyeOfEnderSignal::tick() if (!level->isClientSide) { double dx = tx - x, dz = tz - z; - float tdist = (float) sqrt(dx * dx + dz * dz); - float angle = (float) atan2(dz, dx); + float tdist = static_cast(sqrt(dx * dx + dz * dz)); + float angle = static_cast(atan2(dz, dx)); double tspeed = (sd + (tdist - sd) * .0025); if (tdist < 1) { @@ -167,7 +167,7 @@ void EyeOfEnderSignal::tick() } else { - level->levelEvent(LevelEvent::PARTICLES_EYE_OF_ENDER_DEATH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), 0); + level->levelEvent(LevelEvent::PARTICLES_EYE_OF_ENDER_DEATH, static_cast(Math::round(x)), static_cast(Math::round(y)), static_cast(Math::round(z)), 0); } } } diff --git a/Minecraft.World/FallingTile.cpp b/Minecraft.World/FallingTile.cpp index c0eb7d226..aec50d9be 100644 --- a/Minecraft.World/FallingTile.cpp +++ b/Minecraft.World/FallingTile.cpp @@ -212,10 +212,10 @@ void FallingTile::causeFallDamage(float distance) void FallingTile::addAdditonalSaveData(CompoundTag *tag) { - tag->putByte(L"Tile", (byte) tile); + tag->putByte(L"Tile", static_cast(tile)); tag->putInt(L"TileID", tile); - tag->putByte(L"Data", (byte) data); - tag->putByte(L"Time", (byte) time); + tag->putByte(L"Data", static_cast(data)); + tag->putByte(L"Time", static_cast(time)); tag->putBoolean(L"DropItem", dropItem); tag->putBoolean(L"HurtEntities", hurtEntities); tag->putFloat(L"FallHurtAmount", fallDamageAmount); diff --git a/Minecraft.World/FastNoise.cpp b/Minecraft.World/FastNoise.cpp index 91d039b3f..65f8d7ecc 100644 --- a/Minecraft.World/FastNoise.cpp +++ b/Minecraft.World/FastNoise.cpp @@ -50,23 +50,23 @@ doubleArray FastNoise::getRegion(doubleArray buffer, double x, double y, double for (int zp = 0; zp < zSize; zp++) { double zz = (z + zp) * zScale; - int Z = (int) zz; + int Z = static_cast(zz); if (zz < Z) Z -= 1; - int zl = (int) ((zz - Z) * 65536); + int zl = static_cast((zz - Z) * 65536); for (int yp = 0; yp < ySize; yp++) { double yy = (y + yp) * yScale; - int Y = (int) yy; + int Y = static_cast(yy); if (yy < Y) Y -= 1; - int yl = (int) ((yy - Y) * 65536); + int yl = static_cast((yy - Y) * 65536); for (int xp = 0; xp < xSize; xp++) { double xx = (x + xp) * xScale; - int X = (int) xx; + int X = static_cast(xx); if (xx < X) X -= 1; - int xl = (int) ((xx - X) * 65536); + int xl = static_cast((xx - X) * 65536); int X0 = (X + 0) * AA; int X1 = (X + 1) * AA; diff --git a/Minecraft.World/File.cpp b/Minecraft.World/File.cpp index 82e593dc2..ca13f228f 100644 --- a/Minecraft.World/File.cpp +++ b/Minecraft.World/File.cpp @@ -673,7 +673,7 @@ const std::wstring File::getPath() const std::wstring File::getName() const { - unsigned int sep = (unsigned int )(m_abstractPathName.find_last_of( this->pathSeparator )); + unsigned int sep = static_cast(m_abstractPathName.find_last_of(this->pathSeparator)); return m_abstractPathName.substr( sep + 1, m_abstractPathName.length() ); } diff --git a/Minecraft.World/FileHeader.cpp b/Minecraft.World/FileHeader.cpp index 0a47e043e..01687628f 100644 --- a/Minecraft.World/FileHeader.cpp +++ b/Minecraft.World/FileHeader.cpp @@ -72,13 +72,13 @@ void FileHeader::WriteHeader( LPVOID saveMem ) unsigned int headerOffset = GetStartOfNextData(); // 4J Changed for save version 2 to be the number of files rather than the size in bytes - unsigned int headerSize = (int)(fileTable.size()); + unsigned int headerSize = static_cast(fileTable.size()); //DWORD numberOfBytesWritten = 0; // Write the offset of the header //assert(numberOfBytesWritten == 4); - int *begin = (int *)saveMem; + int *begin = static_cast(saveMem); #ifdef __PSVITA__ VirtualCopyTo(begin, &headerOffset, sizeof(headerOffset)); #else @@ -115,7 +115,7 @@ void FileHeader::WriteHeader( LPVOID saveMem ) app.DebugPrintf("Write save file with original version: %d, and current version %d\n", m_originalSaveVersion, versionNumber); #endif - char *headerPosition = (char *)saveMem + headerOffset; + char *headerPosition = static_cast(saveMem) + headerOffset; #ifdef _DEBUG_FILE_HEADER app.DebugPrintf("\n\nWrite file Header: Offset = %d, Size = %d\n", headerOffset, headerSize); @@ -164,7 +164,7 @@ void FileHeader::ReadHeader( LPVOID saveMem, ESavePlatform plat /*= SAVE_FILE_PL // Read the offset of the header //assert(numberOfBytesRead == 4); - int *begin = (int *)saveMem; + int *begin = static_cast(saveMem); #ifdef __PSVITA__ VirtualCopyFrom(&headerOffset, begin, sizeof(headerOffset)); #else @@ -205,7 +205,7 @@ void FileHeader::ReadHeader( LPVOID saveMem, ESavePlatform plat /*= SAVE_FILE_PL app.DebugPrintf("\n\nRead file Header: Offset = %d, Size = %d\n", headerOffset, headerSize); #endif - char *headerPosition = (char *)saveMem + headerOffset; + char *headerPosition = static_cast(saveMem) + headerOffset; switch( m_saveVersion ) { @@ -321,7 +321,7 @@ unsigned int FileHeader::GetStartOfNextData() unsigned int FileHeader::GetFileSize() { - return GetStartOfNextData() + ( sizeof(FileEntrySaveData) * (unsigned int)fileTable.size() ); + return GetStartOfNextData() + ( sizeof(FileEntrySaveData) * static_cast(fileTable.size()) ); } void FileHeader::AdjustStartOffsets(FileEntry *file, DWORD nNumberOfBytesToWrite, bool subtract /*= false*/) diff --git a/Minecraft.World/FileOutputStream.cpp b/Minecraft.World/FileOutputStream.cpp index 557ba812d..e554ccf59 100644 --- a/Minecraft.World/FileOutputStream.cpp +++ b/Minecraft.World/FileOutputStream.cpp @@ -61,7 +61,7 @@ void FileOutputStream::write(unsigned int b) { DWORD numberOfBytesWritten; - byte value = (byte) b; + byte value = static_cast(b); BOOL result = WriteFile( m_fileHandle, // handle to file diff --git a/Minecraft.World/Fireball.cpp b/Minecraft.World/Fireball.cpp index 2a538b064..2bd740ad3 100644 --- a/Minecraft.World/Fireball.cpp +++ b/Minecraft.World/Fireball.cpp @@ -130,7 +130,7 @@ void Fireball::tick() //if (!level->isClientSide && (owner == NULL || owner->removed)) if (!level->isClientSide) { - if((owner != NULL && owner->removed) || !level->hasChunkAt((int) x, (int) y, (int) z)) + if((owner != NULL && owner->removed) || !level->hasChunkAt(static_cast(x), static_cast(y), static_cast(z))) { app.DebugPrintf("Fireball removed - owner is null or removed is true for owner\n"); remove(); @@ -237,8 +237,8 @@ void Fireball::tick() z += zd; double sd = sqrt(xd * xd + zd * zd); - yRot = (float) (atan2(zd, xd) * 180 / PI) + 90; - xRot = (float) (atan2(sd, yd) * 180 / PI) - 90; + yRot = static_cast(atan2(zd, xd) * 180 / PI) + 90; + xRot = static_cast(atan2(sd, yd) * 180 / PI) - 90; while (xRot - xRotO < -180) xRotO -= 360; @@ -297,11 +297,11 @@ float Fireball::getInertia() void Fireball::addAdditonalSaveData(CompoundTag *tag) { - tag->putShort(L"xTile", (short) xTile); - tag->putShort(L"yTile", (short) yTile); - tag->putShort(L"zTile", (short) zTile); - tag->putByte(L"inTile", (byte) lastTile); - tag->putByte(L"inGround", (byte) (inGround ? 1 : 0)); + tag->putShort(L"xTile", static_cast(xTile)); + tag->putShort(L"yTile", static_cast(yTile)); + tag->putShort(L"zTile", static_cast(zTile)); + tag->putByte(L"inTile", static_cast(lastTile)); + tag->putByte(L"inGround", static_cast(inGround ? 1 : 0)); tag->put(L"direction", newDoubleList(3, xd, yd, zd)); } diff --git a/Minecraft.World/FireworksChargeItem.cpp b/Minecraft.World/FireworksChargeItem.cpp index 2de2be045..d027c5542 100644 --- a/Minecraft.World/FireworksChargeItem.cpp +++ b/Minecraft.World/FireworksChargeItem.cpp @@ -23,7 +23,7 @@ int FireworksChargeItem::getColor(shared_ptr item, int spriteLayer Tag *colorTag = getExplosionTagField(item, FireworksItem::TAG_E_COLORS); if (colorTag != NULL) { - IntArrayTag *colors = (IntArrayTag *) colorTag; + IntArrayTag *colors = static_cast(colorTag); if (colors->data.length == 1) { return colors->data[0]; diff --git a/Minecraft.World/FireworksRecipe.cpp b/Minecraft.World/FireworksRecipe.cpp index a357c9cbc..7bf631049 100644 --- a/Minecraft.World/FireworksRecipe.cpp +++ b/Minecraft.World/FireworksRecipe.cpp @@ -28,7 +28,7 @@ void FireworksRecipe::UseDefaultThreadStorage() void FireworksRecipe::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); if( tls == tlsDefault ) return; delete tls; @@ -36,7 +36,7 @@ void FireworksRecipe::ReleaseThreadStorage() void FireworksRecipe::setResultItem(shared_ptr item) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); tls->resultItem = item; } @@ -138,12 +138,12 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l if (item->hasTag() && item->getTag()->contains(FireworksItem::TAG_EXPLOSION)) { - expTags->add((CompoundTag *)item->getTag()->getCompound(FireworksItem::TAG_EXPLOSION)->copy()); + expTags->add(static_cast(item->getTag()->getCompound(FireworksItem::TAG_EXPLOSION)->copy())); } } fireTag->put(FireworksItem::TAG_EXPLOSIONS, expTags); - fireTag->putByte(FireworksItem::TAG_FLIGHT, (byte) sulphurCount); + fireTag->putByte(FireworksItem::TAG_FLIGHT, static_cast(sulphurCount)); itemTag->put(FireworksItem::TAG_FIREWORKS, fireTag); resultItem->setTag(itemTag); @@ -268,7 +268,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l shared_ptr FireworksRecipe::assemble(shared_ptr craftSlots) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); return tls->resultItem->copy(); //return resultItem->copy(); } @@ -280,7 +280,7 @@ int FireworksRecipe::size() const ItemInstance *FireworksRecipe::getResultItem() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); return tls->resultItem.get(); //return resultItem.get(); } diff --git a/Minecraft.World/FireworksRocketEntity.cpp b/Minecraft.World/FireworksRocketEntity.cpp index e84844f12..bd7410b29 100644 --- a/Minecraft.World/FireworksRocketEntity.cpp +++ b/Minecraft.World/FireworksRocketEntity.cpp @@ -61,8 +61,8 @@ void FireworksRocketEntity::lerpMotion(double xd, double yd, double zd) if (xRotO == 0 && yRotO == 0) { double sd = Mth::sqrt(xd * xd + zd * zd); - yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI); - xRotO = xRot = (float) (atan2(yd, sd) * 180 / PI); + yRotO = yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRotO = xRot = static_cast(atan2(yd, sd) * 180 / PI); } } @@ -79,8 +79,8 @@ void FireworksRocketEntity::tick() move(xd, yd, zd); double sd = Mth::sqrt(xd * xd + zd * zd); - yRot = (float) (atan2(xd, zd) * 180 / PI); - xRot = (float) (atan2(yd, sd) * 180 / PI); + yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRot = static_cast(atan2(yd, sd) * 180 / PI); while (xRot - xRotO < -180) xRotO -= 360; diff --git a/Minecraft.World/FishingHook.cpp b/Minecraft.World/FishingHook.cpp index e38a64b6a..51f37c97d 100644 --- a/Minecraft.World/FishingHook.cpp +++ b/Minecraft.World/FishingHook.cpp @@ -102,7 +102,7 @@ bool FishingHook::shouldRenderAtSqrDistance(double distance) void FishingHook::shoot(double xd, double yd, double zd, float pow, float uncertainty) { - float dist = (float) sqrt(xd * xd + yd * yd + zd * zd); + float dist = static_cast(sqrt(xd * xd + yd * yd + zd * zd)); xd /= dist; yd /= dist; @@ -122,8 +122,8 @@ void FishingHook::shoot(double xd, double yd, double zd, float pow, float uncert double sd = sqrt(xd * xd + zd * zd); - yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI); - xRotO = xRot = (float) (atan2(yd, sd) * 180 / PI); + yRotO = yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRotO = xRot = static_cast(atan2(yd, sd) * 180 / PI); life = 0; } @@ -161,8 +161,8 @@ void FishingHook::tick() double yrd = Mth::wrapDegrees(lyr - yRot); - yRot += (float) ( (yrd) / lSteps ); - xRot += (float) ( (lxr - xRot) / lSteps ); + yRot += static_cast((yrd) / lSteps); + xRot += static_cast((lxr - xRot) / lSteps); lSteps--; setPos(xt, yt, zt); @@ -284,8 +284,8 @@ void FishingHook::tick() move(xd, yd, zd); double sd = sqrt(xd * xd + zd * zd); - yRot = (float) (atan2(xd, zd) * 180 / PI); - xRot = (float) (atan2(yd, sd) * 180 / PI); + yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRot = static_cast(atan2(yd, sd) * 180 / PI); while (xRot - xRotO < -180) xRotO -= 360; @@ -337,7 +337,7 @@ void FishingHook::tick() nibble = random->nextInt(30) + 10; yd -= 0.2f; playSound(eSoundType_RANDOM_SPLASH, 0.25f, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f); - float yt = (float) Mth::floor(bb->y0); + float yt = static_cast(Mth::floor(bb->y0)); for (int i = 0; i < 1 + bbWidth * 20; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth; @@ -377,12 +377,12 @@ void FishingHook::tick() void FishingHook::addAdditonalSaveData(CompoundTag *tag) { - tag->putShort(L"xTile", (short) xTile); - tag->putShort(L"yTile", (short) yTile); - tag->putShort(L"zTile", (short) zTile); - tag->putByte(L"inTile", (byte) lastTile); - tag->putByte(L"shake", (byte) shakeTime); - tag->putByte(L"inGround", (byte) (inGround ? 1 : 0)); + tag->putShort(L"xTile", static_cast(xTile)); + tag->putShort(L"yTile", static_cast(yTile)); + tag->putShort(L"zTile", static_cast(zTile)); + tag->putByte(L"inTile", static_cast(lastTile)); + tag->putByte(L"shake", static_cast(shakeTime)); + tag->putByte(L"inGround", static_cast(inGround ? 1 : 0)); } void FishingHook::readAdditionalSaveData(CompoundTag *tag) diff --git a/Minecraft.World/FlatLevelSource.cpp b/Minecraft.World/FlatLevelSource.cpp index 7a31374eb..4713f43ef 100644 --- a/Minecraft.World/FlatLevelSource.cpp +++ b/Minecraft.World/FlatLevelSource.cpp @@ -55,7 +55,7 @@ void FlatLevelSource::prepareHeights(byteArray blocks) { block = Tile::grass_Id; } - blocks[xc << 11 | zc << 7 | yc] = (byte) block; + blocks[xc << 11 | zc << 7 | yc] = static_cast(block); } } } @@ -70,7 +70,7 @@ LevelChunk *FlatLevelSource::getChunk(int xOffs, int zOffs) { // 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed int chunksSize = Level::genDepth * 16 * 16; - byte *tileData = (byte *)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + byte *tileData = static_cast(XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); XMemSet128(tileData,0,chunksSize); byteArray blocks = byteArray(tileData,chunksSize); // byteArray blocks = byteArray(16 * level->depth * 16); diff --git a/Minecraft.World/FleeSunGoal.cpp b/Minecraft.World/FleeSunGoal.cpp index d58ad7097..353d1625b 100644 --- a/Minecraft.World/FleeSunGoal.cpp +++ b/Minecraft.World/FleeSunGoal.cpp @@ -18,7 +18,7 @@ bool FleeSunGoal::canUse() { if (!level->isDay()) return false; if (!mob->isOnFire()) return false; - if (!level->canSeeSky(Mth::floor(mob->x), (int) mob->bb->y0, Mth::floor(mob->z))) return false; + if (!level->canSeeSky(Mth::floor(mob->x), static_cast(mob->bb->y0), Mth::floor(mob->z))) return false; Vec3 *pos = getHidePos(); if (pos == NULL) return false; diff --git a/Minecraft.World/FlippedIcon.cpp b/Minecraft.World/FlippedIcon.cpp index 559423d7c..37122bfc0 100644 --- a/Minecraft.World/FlippedIcon.cpp +++ b/Minecraft.World/FlippedIcon.cpp @@ -41,7 +41,7 @@ float FlippedIcon::getU1(bool adjust/*=false*/) const float FlippedIcon::getU(double offset, bool adjust/*=false*/) const { float diff = getU1(adjust) - getU0(adjust); - return getU0(adjust) + (diff * ((float) offset / SharedConstants::WORLD_RESOLUTION)); + return getU0(adjust) + (diff * (static_cast(offset) / SharedConstants::WORLD_RESOLUTION)); } float FlippedIcon::getV0(bool adjust/*=false*/) const @@ -59,7 +59,7 @@ float FlippedIcon::getV1(bool adjust/*=false*/) const float FlippedIcon::getV(double offset, bool adjust/*=false*/) const { float diff = getV1(adjust) - getV0(adjust); - return getV0(adjust) + (diff * ((float) offset / SharedConstants::WORLD_RESOLUTION)); + return getV0(adjust) + (diff * (static_cast(offset) / SharedConstants::WORLD_RESOLUTION)); } wstring FlippedIcon::getName() const diff --git a/Minecraft.World/FloatTag.h b/Minecraft.World/FloatTag.h index 803016499..cc687da8e 100644 --- a/Minecraft.World/FloatTag.h +++ b/Minecraft.World/FloatTag.h @@ -29,7 +29,7 @@ class FloatTag : public Tag { if (Tag::equals(obj)) { - FloatTag *o = (FloatTag *) obj; + FloatTag *o = static_cast(obj); return data == o->data; } return false; diff --git a/Minecraft.World/FlyingMob.cpp b/Minecraft.World/FlyingMob.cpp index 1757ae58e..28404108c 100644 --- a/Minecraft.World/FlyingMob.cpp +++ b/Minecraft.World/FlyingMob.cpp @@ -75,7 +75,7 @@ void FlyingMob::travel(float xa, float ya) walkAnimSpeedO = walkAnimSpeed; double xxd = x - xo; double zzd = z - zo; - float wst = (float) sqrt(xxd * xxd + zzd * zzd) * 4; + float wst = static_cast(sqrt(xxd * xxd + zzd * zzd)) * 4; if (wst > 1) wst = 1; walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f; walkAnimPos += walkAnimSpeed; diff --git a/Minecraft.World/FoodConstants.cpp b/Minecraft.World/FoodConstants.cpp index 6ced45d5d..a8e024a2b 100644 --- a/Minecraft.World/FoodConstants.cpp +++ b/Minecraft.World/FoodConstants.cpp @@ -3,8 +3,8 @@ #include "FoodConstants.h" const int FoodConstants::MAX_FOOD = 20; -const float FoodConstants::MAX_SATURATION = (float) FoodConstants::MAX_FOOD; -const float FoodConstants::START_SATURATION = (float) FoodConstants::MAX_SATURATION / 4.0f; +const float FoodConstants::MAX_SATURATION = static_cast(FoodConstants::MAX_FOOD); +const float FoodConstants::START_SATURATION = static_cast(FoodConstants::MAX_SATURATION) / 4.0f; const float FoodConstants::SATURATION_FLOOR = FoodConstants::MAX_SATURATION / 8.0f; // this value modifies how quickly food is dropped diff --git a/Minecraft.World/FoodItem.h b/Minecraft.World/FoodItem.h index 16e6ce3f6..3fa04ed46 100644 --- a/Minecraft.World/FoodItem.h +++ b/Minecraft.World/FoodItem.h @@ -8,7 +8,7 @@ class Level; class FoodItem : public Item { public: - static const int EAT_DURATION = (int) (20 * 1.6); + static const int EAT_DURATION = static_cast(20 * 1.6); private: const int nutrition; diff --git a/Minecraft.World/FurnaceResultSlot.cpp b/Minecraft.World/FurnaceResultSlot.cpp index d845dada6..8ea4b19f7 100644 --- a/Minecraft.World/FurnaceResultSlot.cpp +++ b/Minecraft.World/FurnaceResultSlot.cpp @@ -61,8 +61,8 @@ void FurnaceResultSlot::checkTakeAchievements(shared_ptr carried) } else if (value < 1) { - int baseValue = floor((float) amount * value); - if (baseValue < ceil((float) amount * value) && (float) Math::random() < (((float) amount * value) - baseValue)) + int baseValue = floor(static_cast(amount) * value); + if (baseValue < ceil(static_cast(amount) * value) && static_cast(Math::random()) < ((static_cast(amount) * value) - baseValue)) { baseValue++; } diff --git a/Minecraft.World/FurnaceTile.cpp b/Minecraft.World/FurnaceTile.cpp index d22d6ca78..1393a325b 100644 --- a/Minecraft.World/FurnaceTile.cpp +++ b/Minecraft.World/FurnaceTile.cpp @@ -196,12 +196,12 @@ void FurnaceTile::onRemove(Level *level, int x, int y, int z, int id, int data) newItem->set4JData( item->get4JData() ); shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, newItem) ); float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; + itemEntity->xd = static_cast(random->nextGaussian()) * pow; + itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random->nextGaussian()) * pow; if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + itemEntity->getItem()->setTag(static_cast(item->getTag()->copy())); } level->addEntity(itemEntity); } diff --git a/Minecraft.World/FurnaceTileEntity.cpp b/Minecraft.World/FurnaceTileEntity.cpp index 1aa2c3005..70190f4ee 100644 --- a/Minecraft.World/FurnaceTileEntity.cpp +++ b/Minecraft.World/FurnaceTileEntity.cpp @@ -140,8 +140,8 @@ void FurnaceTileEntity::load(CompoundTag *base) void FurnaceTileEntity::save(CompoundTag *base) { TileEntity::save(base); - base->putShort(L"BurnTime", (short) (litTime)); - base->putShort(L"CookTime", (short) (tickCount)); + base->putShort(L"BurnTime", static_cast(litTime)); + base->putShort(L"CookTime", static_cast(tickCount)); ListTag *listTag = new ListTag(); for (unsigned int i = 0; i < items.length; i++) @@ -149,7 +149,7 @@ void FurnaceTileEntity::save(CompoundTag *base) if (items[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); items[i]->save(tag); listTag->add(tag); } @@ -300,15 +300,15 @@ int FurnaceTileEntity::getBurnDuration(shared_ptr itemInstance) } } - if (dynamic_cast(item) && ((DiggerItem *) item)->getTier() == Item::Tier::WOOD) + if (dynamic_cast(item) && static_cast(item)->getTier() == Item::Tier::WOOD) { return BURN_INTERVAL; } - else if (dynamic_cast(item) && ((WeaponItem *) item)->getTier() == Item::Tier::WOOD) + else if (dynamic_cast(item) && static_cast(item)->getTier() == Item::Tier::WOOD) { return BURN_INTERVAL; } - else if (dynamic_cast(item) && ((HoeItem *) item)->getTier() == Item::Tier::WOOD) + else if (dynamic_cast(item) && static_cast(item)->getTier() == Item::Tier::WOOD) { return BURN_INTERVAL; } diff --git a/Minecraft.World/GameCommandPacket.cpp b/Minecraft.World/GameCommandPacket.cpp index 98cdd3121..2f74778fc 100644 --- a/Minecraft.World/GameCommandPacket.cpp +++ b/Minecraft.World/GameCommandPacket.cpp @@ -37,7 +37,7 @@ GameCommandPacket::~GameCommandPacket() void GameCommandPacket::read(DataInputStream *dis) { - command = (EGameCommand)dis->readInt(); + command = static_cast(dis->readInt()); length = dis->readShort(); if (length > 0 && length < Short::MAX_VALUE) @@ -54,7 +54,7 @@ void GameCommandPacket::read(DataInputStream *dis) void GameCommandPacket::write(DataOutputStream *dos) { dos->writeInt(command); - dos->writeShort((short) length); + dos->writeShort(static_cast(length)); if (data.data != NULL) { dos->write(data); diff --git a/Minecraft.World/Ghast.cpp b/Minecraft.World/Ghast.cpp index f0817791c..dc70e9025 100644 --- a/Minecraft.World/Ghast.cpp +++ b/Minecraft.World/Ghast.cpp @@ -72,7 +72,7 @@ void Ghast::defineSynchedData() { FlyingMob::defineSynchedData(); - entityData->define(DATA_IS_CHARGING, (byte) 0); + entityData->define(DATA_IS_CHARGING, static_cast(0)); } void Ghast::registerAttributes() @@ -137,20 +137,20 @@ void Ghast::serverAiStep() double xdd = target->x - x; double ydd = (target->bb->y0 + target->bbHeight / 2) - (y + bbHeight / 2); double zdd = target->z - z; - yBodyRot = yRot = -(float) atan2(xdd, zdd) * 180 / PI; + yBodyRot = yRot = -static_cast(atan2(xdd, zdd)) * 180 / PI; if (canSee(target)) { if (charge == 10) { // 4J - change brought forward from 1.2.3 - level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_WARNING, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_WARNING, static_cast(x), static_cast(y), static_cast(z), 0); } charge++; if (charge == 20) { // 4J - change brought forward from 1.2.3 - level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); shared_ptr ie = shared_ptr( new LargeFireball(level, dynamic_pointer_cast( shared_from_this() ), xdd, ydd, zdd) ); ie->explosionPower = explosionPower; double d = 4; @@ -169,14 +169,14 @@ void Ghast::serverAiStep() } else { - yBodyRot = yRot = -(float) atan2(this->xd, this->zd) * 180 / PI; + yBodyRot = yRot = -static_cast(atan2(this->xd, this->zd)) * 180 / PI; if (charge > 0) charge--; } if (!level->isClientSide) { byte old = entityData->getByte(DATA_IS_CHARGING); - byte current = (byte) (charge > 10 ? 1 : 0); + byte current = static_cast(charge > 10 ? 1 : 0); if (old != current) { entityData->set(DATA_IS_CHARGING, current); diff --git a/Minecraft.World/HangingEntity.cpp b/Minecraft.World/HangingEntity.cpp index 26261710f..3d44b4260 100644 --- a/Minecraft.World/HangingEntity.cpp +++ b/Minecraft.World/HangingEntity.cpp @@ -35,16 +35,16 @@ HangingEntity::HangingEntity(Level *level, int xTile, int yTile, int zTile, int void HangingEntity::setDir(int dir) { this->dir = dir; - yRotO = yRot = (float)(dir * 90); + yRotO = yRot = static_cast(dir * 90); - float w = (float)getWidth(); - float h = (float)getHeight(); - float d = (float)getWidth(); + float w = static_cast(getWidth()); + float h = static_cast(getHeight()); + float d = static_cast(getWidth()); if (dir == Direction::NORTH || dir == Direction::SOUTH) { d = 0.5f; - yRot = yRotO = (float)(Direction::DIRECTION_OPPOSITE[dir] * 90); + yRot = yRotO = static_cast(Direction::DIRECTION_OPPOSITE[dir] * 90); } else { @@ -235,7 +235,7 @@ void HangingEntity::push(double xa, double ya, double za) void HangingEntity::addAdditonalSaveData(CompoundTag *tag) { - tag->putByte(L"Direction", (byte) dir); + tag->putByte(L"Direction", static_cast(dir)); tag->putInt(L"TileX", xTile); tag->putInt(L"TileY", yTile); tag->putInt(L"TileZ", zTile); diff --git a/Minecraft.World/HellDimension.cpp b/Minecraft.World/HellDimension.cpp index 85e2a25ae..94a4e5865 100644 --- a/Minecraft.World/HellDimension.cpp +++ b/Minecraft.World/HellDimension.cpp @@ -23,9 +23,9 @@ Vec3 *HellDimension::getFogColor(float td, float a) const byte greenComponent = ((colour>>8)&0xFF); byte blueComponent = ((colour)&0xFF); - float rr = (float)redComponent/256;//0.2f; - float gg = (float)greenComponent/256;//0.03f; - float bb = (float)blueComponent/256;//0.03f; + float rr = static_cast(redComponent)/256;//0.2f; + float gg = static_cast(greenComponent)/256;//0.03f; + float bb = static_cast(blueComponent)/256;//0.03f; return Vec3::newTemp(rr, gg, bb); } @@ -34,7 +34,7 @@ void HellDimension::updateLightRamp() float ambientLight = 0.10f; for (int i = 0; i <= Level::MAX_BRIGHTNESS; i++) { - float v = (1 - i / (float) (Level::MAX_BRIGHTNESS)); + float v = (1 - i / static_cast(Level::MAX_BRIGHTNESS)); brightnessRamp[i] = ((1 - v) / (v * 3 + 1)) * (1 - ambientLight) + ambientLight; } } @@ -85,5 +85,5 @@ bool HellDimension::isFoggyAt(int x, int z) int HellDimension::getXZSize() { - return ceil((float)level->getLevelData()->getXZSize() / level->getLevelData()->getHellScale()); + return ceil(static_cast(level->getLevelData()->getXZSize()) / level->getLevelData()->getHellScale()); } diff --git a/Minecraft.World/HellFlatLevelSource.cpp b/Minecraft.World/HellFlatLevelSource.cpp index 4957f6176..4c9a77077 100644 --- a/Minecraft.World/HellFlatLevelSource.cpp +++ b/Minecraft.World/HellFlatLevelSource.cpp @@ -8,7 +8,7 @@ HellFlatLevelSource::HellFlatLevelSource(Level *level, __int64 seed) { int xzSize = level->getLevelData()->getXZSize(); int hellScale = level->getLevelData()->getHellScale(); - m_XZSize = ceil((float)xzSize / hellScale); + m_XZSize = ceil(static_cast(xzSize) / hellScale); this->level = level; @@ -38,7 +38,7 @@ void HellFlatLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) block = Tile::netherRack_Id; } - blocks[xc << 11 | zc << 7 | yc] = (byte) block; + blocks[xc << 11 | zc << 7 | yc] = static_cast(block); } } } @@ -60,7 +60,7 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks) { if( z - random->nextInt( 4 ) <= 0 || xOffs < -(m_XZSize/2) ) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); blockSet = true; } } @@ -68,7 +68,7 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks) { if( x - random->nextInt( 4 ) <= 0 || zOffs < -(m_XZSize/2)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); blockSet = true; } } @@ -76,7 +76,7 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks) { if( z + random->nextInt(4) >= 15 || xOffs > (m_XZSize/2)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); blockSet = true; } } @@ -84,7 +84,7 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks) { if( x + random->nextInt(4) >= 15 || zOffs > (m_XZSize/2) ) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); blockSet = true; } } @@ -93,11 +93,11 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks) if (y >= Level::genDepthMinusOne - random->nextInt(5)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); } else if (y <= 0 + random->nextInt(5)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); } } } @@ -115,7 +115,7 @@ LevelChunk *HellFlatLevelSource::getChunk(int xOffs, int zOffs) // 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed int chunksSize = Level::genDepth * 16 * 16; - byte *tileData = (byte *)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + byte *tileData = static_cast(XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); XMemSet128(tileData,0,chunksSize); byteArray blocks = byteArray(tileData,chunksSize); // byteArray blocks = byteArray(16 * level->depth * 16); diff --git a/Minecraft.World/HellRandomLevelSource.cpp b/Minecraft.World/HellRandomLevelSource.cpp index 31bb3d696..e92ad2776 100644 --- a/Minecraft.World/HellRandomLevelSource.cpp +++ b/Minecraft.World/HellRandomLevelSource.cpp @@ -11,7 +11,7 @@ HellRandomLevelSource::HellRandomLevelSource(Level *level, __int64 seed) { int xzSize = level->getLevelData()->getXZSize(); int hellScale = level->getLevelData()->getHellScale(); - m_XZSize = ceil((float)xzSize / hellScale); + m_XZSize = ceil(static_cast(xzSize) / hellScale); netherBridgeFeature = new NetherBridgeFeature(); caveFeature = new LargeHellCaveFeature(); @@ -64,7 +64,7 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray block { for (int yc = 0; yc < Level::genDepth / CHUNK_HEIGHT; yc++) { - double yStep = 1 / (double) CHUNK_HEIGHT; + double yStep = 1 / static_cast(CHUNK_HEIGHT); double s0 = buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 0)]; double s1 = buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 0)]; double s2 = buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 0)]; @@ -77,7 +77,7 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray block for (int y = 0; y < CHUNK_HEIGHT; y++) { - double xStep = 1 / (double) CHUNK_WIDTH; + double xStep = 1 / static_cast(CHUNK_WIDTH); double _s0 = s0; double _s1 = s1; @@ -88,7 +88,7 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray block { int offs = (x + xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | (0 + zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y); int step = 1 << Level::genDepthBits; - double zStep = 1 / (double) CHUNK_WIDTH; + double zStep = 1 / static_cast(CHUNK_WIDTH); double val = _s0; double vala = (_s1 - _s0) * zStep; @@ -104,7 +104,7 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray block tileId = Tile::netherRack_Id; } - blocks[offs] = (byte) tileId; + blocks[offs] = static_cast(tileId); offs += step; val += vala; } @@ -143,7 +143,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks { bool sand = (sandBuffer[x + z * 16] + random->nextDouble() * 0.2) > 0; bool gravel = (gravelBuffer[x + z * 16] + random->nextDouble() * 0.2) > 0; - int runDepth = (int) (depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25); + int runDepth = static_cast(depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25); int run = -1; @@ -160,7 +160,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks { if( z - random->nextInt( 4 ) <= 0 || xOffs < -(m_XZSize/2) ) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); blockSet = true; } } @@ -168,7 +168,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks { if( x - random->nextInt( 4 ) <= 0 || zOffs < -(m_XZSize/2)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); blockSet = true; } } @@ -176,7 +176,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks { if( z + random->nextInt(4) >= 15 || xOffs > (m_XZSize/2)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); blockSet = true; } } @@ -184,7 +184,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks { if( x + random->nextInt(4) >= 15 || zOffs > (m_XZSize/2) ) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); blockSet = true; } } @@ -193,7 +193,7 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks if (y >= Level::genDepthMinusOne - random->nextInt(5) || y <= 0 + random->nextInt(5)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); } else { @@ -210,20 +210,20 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks if (runDepth <= 0) { top = 0; - material = (byte) Tile::netherRack_Id; + material = static_cast(Tile::netherRack_Id); } else if (y >= waterHeight - 4 && y <= waterHeight + 1) { - top = (byte) Tile::netherRack_Id; - material = (byte) Tile::netherRack_Id; - if (gravel) top = (byte) Tile::gravel_Id; - if (gravel) material = (byte) Tile::netherRack_Id; + top = static_cast(Tile::netherRack_Id); + material = static_cast(Tile::netherRack_Id); + if (gravel) top = static_cast(Tile::gravel_Id); + if (gravel) material = static_cast(Tile::netherRack_Id); if (sand) { // 4J Stu - Make some nether wart spawn outside of the nether fortresses if(random->nextInt(16) == 0) { - top = (byte) Tile::netherStalk_Id; + top = static_cast(Tile::netherStalk_Id); // Place the nether wart on top of the soul sand y += 1; @@ -234,13 +234,13 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks } else { - top = (byte) Tile::soulsand_Id; + top = static_cast(Tile::soulsand_Id); } } - if (sand) material = (byte) Tile::soulsand_Id; + if (sand) material = static_cast(Tile::soulsand_Id); } - if (y < waterHeight && top == 0) top = (byte) Tile::calmLava_Id; + if (y < waterHeight && top == 0) top = static_cast(Tile::calmLava_Id); run = runDepth; // 4J Stu - If sand, then allow adding nether wart at heights below the water level @@ -273,7 +273,7 @@ LevelChunk *HellRandomLevelSource::getChunk(int xOffs, int zOffs) // 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed int blocksSize = Level::genDepth * 16 * 16; - byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + byte *tileData = static_cast(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); XMemSet128(tileData,0,blocksSize); byteArray blocks = byteArray(tileData,blocksSize); // byteArray blocks = byteArray(16 * level->depth * 16); @@ -325,7 +325,7 @@ doubleArray HellRandomLevelSource::getHeights(doubleArray buffer, int x, int y, doubleArray yoffs = doubleArray(ySize); for (int yy = 0; yy < ySize; yy++) { - yoffs[yy] = cos(yy * PI * 6 / (double) ySize) * 2; + yoffs[yy] = cos(yy * PI * 6 / static_cast(ySize)) * 2; double dd = yy; if (yy > ySize / 2) diff --git a/Minecraft.World/HopperTile.cpp b/Minecraft.World/HopperTile.cpp index c111105ec..6e41aefc3 100644 --- a/Minecraft.World/HopperTile.cpp +++ b/Minecraft.World/HopperTile.cpp @@ -120,13 +120,13 @@ void HopperTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + itemEntity->getItem()->setTag(static_cast(item->getTag()->copy())); } float pow = 0.05f; - itemEntity->xd = (float) random.nextGaussian() * pow; - itemEntity->yd = (float) random.nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random.nextGaussian() * pow; + itemEntity->xd = static_cast(random.nextGaussian()) * pow; + itemEntity->yd = static_cast(random.nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random.nextGaussian()) * pow; level->addEntity(itemEntity); } } diff --git a/Minecraft.World/HopperTileEntity.cpp b/Minecraft.World/HopperTileEntity.cpp index 38a0e817d..efb11bac8 100644 --- a/Minecraft.World/HopperTileEntity.cpp +++ b/Minecraft.World/HopperTileEntity.cpp @@ -49,7 +49,7 @@ void HopperTileEntity::save(CompoundTag *base) if (items[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); items[i]->save(tag); listTag->add(tag); } @@ -307,7 +307,7 @@ shared_ptr HopperTileEntity::addItem(Container *container, shared_ { if (dynamic_cast( container ) != NULL && face > -1) { - WorldlyContainer *worldly = (WorldlyContainer *) container; + WorldlyContainer *worldly = static_cast(container); intArray slots = worldly->getSlotsForFace(face); for (int i = 0; i < slots.length && item != NULL && item->count > 0; i++) @@ -429,7 +429,7 @@ shared_ptr HopperTileEntity::getContainerAt(Level *level, double x, d if ( dynamic_cast( tile ) != NULL ) { - result = ((ChestTile *) tile)->getContainer(level, xt, yt, zt); + result = static_cast(tile)->getContainer(level, xt, yt, zt); } } } diff --git a/Minecraft.World/ImprovedNoise.cpp b/Minecraft.World/ImprovedNoise.cpp index 8be9e3851..47f390858 100644 --- a/Minecraft.World/ImprovedNoise.cpp +++ b/Minecraft.World/ImprovedNoise.cpp @@ -46,9 +46,9 @@ double ImprovedNoise::noise(double _x, double _y, double _z) double y = _y + yo; double z = _z + zo; - int xf = (int) x; - int yf = (int) y; - int zf = (int) z; + int xf = static_cast(x); + int yf = static_cast(y); + int zf = static_cast(z); if (x < xf) xf--; if (y < yf) yf--; @@ -125,7 +125,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int for (int xx = 0; xx < xSize; xx++) { double x = _x + (xx) * xs + xo; - int xf = (int) x; + int xf = static_cast(x); if (x < xf) xf--; int X = xf & 255; x -= xf; @@ -134,7 +134,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int for (int zz = 0; zz < zSize; zz++) { double z = _z + (zz) * zs + zo; - int zf = (int) z; + int zf = static_cast(z); if (z < zf) zf--; int Z = zf & 255; z -= zf; @@ -163,7 +163,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int for (int xx = 0; xx < xSize; xx++) { double x = _x + (xx) * xs + xo; - int xf = (int) x; + int xf = static_cast(x); if (x < xf) xf--; int X = xf & 255; x -= xf; @@ -173,7 +173,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int for (int zz = 0; zz < zSize; zz++) { double z = _z + (zz) * zs + zo; - int zf = (int) z; + int zf = static_cast(z); if (z < zf) zf--; int Z = zf & 255; z -= zf; @@ -183,7 +183,7 @@ void ImprovedNoise::add(doubleArray buffer, double _x, double _y, double _z, int for (int yy = 0; yy < ySize; yy++) { double y = _y + (yy) * ys + yo; - int yf = (int) y; + int yf = static_cast(y); if (y < yf) yf--; int Y = yf & 255; y -= yf; diff --git a/Minecraft.World/InputStreamReader.cpp b/Minecraft.World/InputStreamReader.cpp index 4a565cf4e..972c53167 100644 --- a/Minecraft.World/InputStreamReader.cpp +++ b/Minecraft.World/InputStreamReader.cpp @@ -39,7 +39,7 @@ int InputStreamReader::read(wchar_t cbuf[], unsigned int offset, unsigned int le unsigned int charsRead = 0; for( unsigned int i = offset; i < offset + length; i++ ) { - wchar_t value = (wchar_t)stream->readUTFChar(); + wchar_t value = static_cast(stream->readUTFChar()); if( value != -1 ) { cbuf[i] = value; diff --git a/Minecraft.World/IntArrayTag.h b/Minecraft.World/IntArrayTag.h index 48f4ce745..482a5e1a5 100644 --- a/Minecraft.World/IntArrayTag.h +++ b/Minecraft.World/IntArrayTag.h @@ -57,7 +57,7 @@ class IntArrayTag : public Tag { if (Tag::equals(obj)) { - IntArrayTag *o = (IntArrayTag *) obj; + IntArrayTag *o = static_cast(obj); return ((data.data == NULL && o->data.data == NULL) || (data.data != NULL && data.length == o->data.length && memcmp(data.data, o->data.data, data.length * sizeof(int)) == 0) ); } return false; diff --git a/Minecraft.World/IntCache.cpp b/Minecraft.World/IntCache.cpp index 174d01d3f..d193285a5 100644 --- a/Minecraft.World/IntCache.cpp +++ b/Minecraft.World/IntCache.cpp @@ -36,7 +36,7 @@ IntCache::ThreadStorage::~ThreadStorage() void IntCache::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); delete tls; @@ -44,7 +44,7 @@ void IntCache::ReleaseThreadStorage() intArray IntCache::allocate(int size) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); if (size <= TINY_CUTOFF) { @@ -100,7 +100,7 @@ intArray IntCache::allocate(int size) void IntCache::releaseAll() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); // 4J - added - we can now remove the vectors that were deemed as too small (see comment in IntCache::allocate) for( int i = 0; i < tls->toosmall.size(); i++ ) @@ -130,7 +130,7 @@ void IntCache::releaseAll() // 4J added so that we can fully reset between levels void IntCache::Reset() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); tls->maxSize = TINY_CUTOFF; for( int i = 0; i < tls->allocated.size(); i++ ) { diff --git a/Minecraft.World/IntTag.h b/Minecraft.World/IntTag.h index cce87da31..1f55c5f2a 100644 --- a/Minecraft.World/IntTag.h +++ b/Minecraft.World/IntTag.h @@ -28,7 +28,7 @@ class IntTag : public Tag { if (Tag::equals(obj)) { - IntTag *o = (IntTag *) obj; + IntTag *o = static_cast(obj); return data == o->data; } return false; diff --git a/Minecraft.World/Inventory.cpp b/Minecraft.World/Inventory.cpp index 1b9ff630b..1cb5218d2 100644 --- a/Minecraft.World/Inventory.cpp +++ b/Minecraft.World/Inventory.cpp @@ -243,7 +243,7 @@ int Inventory::addResource(shared_ptr itemInstance) // 4J Stu - Brought forward from 1.2 if (itemInstance->hasTag()) { - items[slot]->setTag((CompoundTag *) itemInstance->getTag()->copy()); + items[slot]->setTag(static_cast(itemInstance->getTag()->copy())); player->handleCollectItem(itemInstance); } } @@ -503,7 +503,7 @@ ListTag *Inventory::save(ListTag *listTag) if (items[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); items[i]->save(tag); listTag->add(tag); } @@ -513,7 +513,7 @@ ListTag *Inventory::save(ListTag *listTag) if (armor[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) (i + 100)); + tag->putByte(L"Slot", static_cast(i + 100)); armor[i]->save(tag); listTag->add(tag); } @@ -637,7 +637,7 @@ void Inventory::hurtArmor(float dmg) { if (armor[i] != NULL && dynamic_cast( armor[i]->getItem() ) != NULL ) { - armor[i]->hurtAndBreak( (int) dmg, dynamic_pointer_cast( player->shared_from_this() ) ); + armor[i]->hurtAndBreak( static_cast(dmg), dynamic_pointer_cast( player->shared_from_this() ) ); if (armor[i]->count == 0) { armor[i] = nullptr; diff --git a/Minecraft.World/Item.cpp b/Minecraft.World/Item.cpp index 2f23ab8cb..5b3838dbc 100644 --- a/Minecraft.World/Item.cpp +++ b/Minecraft.World/Item.cpp @@ -287,30 +287,30 @@ void Item::staticCtor() Item::door_wood = ( new DoorItem(68, Material::wood) ) ->setBaseItemTypeAndMaterial(eBaseItemType_door, eMaterial_wood)->setIconName(L"doorWood")->setDescriptionId(IDS_ITEM_DOOR_WOOD)->setUseDescriptionId(IDS_DESC_DOOR_WOOD); Item::door_iron = ( new DoorItem(74, Material::metal) ) ->setBaseItemTypeAndMaterial(eBaseItemType_door, eMaterial_iron)->setIconName(L"doorIron")->setDescriptionId(IDS_ITEM_DOOR_IRON)->setUseDescriptionId(IDS_DESC_DOOR_IRON); - Item::helmet_leather = (ArmorItem *) ( ( new ArmorItem(42, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_cloth) ->setIconName(L"helmetCloth")->setDescriptionId(IDS_ITEM_HELMET_CLOTH)->setUseDescriptionId(IDS_DESC_HELMET_LEATHER) ); - Item::helmet_iron = (ArmorItem *) ( ( new ArmorItem(50, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_iron) ->setIconName(L"helmetIron")->setDescriptionId(IDS_ITEM_HELMET_IRON)->setUseDescriptionId(IDS_DESC_HELMET_IRON) ); - Item::helmet_diamond = (ArmorItem *) ( ( new ArmorItem(54, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_diamond) ->setIconName(L"helmetDiamond")->setDescriptionId(IDS_ITEM_HELMET_DIAMOND)->setUseDescriptionId(IDS_DESC_HELMET_DIAMOND) ); - Item::helmet_gold = (ArmorItem *) ( ( new ArmorItem(58, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_gold) ->setIconName(L"helmetGold")->setDescriptionId(IDS_ITEM_HELMET_GOLD)->setUseDescriptionId(IDS_DESC_HELMET_GOLD) ); - - Item::chestplate_leather = (ArmorItem *) ( ( new ArmorItem(43, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_cloth) ->setIconName(L"chestplateCloth")->setDescriptionId(IDS_ITEM_CHESTPLATE_CLOTH)->setUseDescriptionId(IDS_DESC_CHESTPLATE_LEATHER) ); - Item::chestplate_iron = (ArmorItem *) ( ( new ArmorItem(51, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_iron) ->setIconName(L"chestplateIron")->setDescriptionId(IDS_ITEM_CHESTPLATE_IRON)->setUseDescriptionId(IDS_DESC_CHESTPLATE_IRON) ); - Item::chestplate_diamond = (ArmorItem *) ( ( new ArmorItem(55, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_diamond) ->setIconName(L"chestplateDiamond")->setDescriptionId(IDS_ITEM_CHESTPLATE_DIAMOND)->setUseDescriptionId(IDS_DESC_CHESTPLATE_DIAMOND) ); - Item::chestplate_gold = (ArmorItem *) ( ( new ArmorItem(59, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_gold) ->setIconName(L"chestplateGold")->setDescriptionId(IDS_ITEM_CHESTPLATE_GOLD)->setUseDescriptionId(IDS_DESC_CHESTPLATE_GOLD) ); - - Item::leggings_leather = (ArmorItem *) ( ( new ArmorItem(44, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_cloth) ->setIconName(L"leggingsCloth")->setDescriptionId(IDS_ITEM_LEGGINGS_CLOTH)->setUseDescriptionId(IDS_DESC_LEGGINGS_LEATHER) ); - Item::leggings_iron = (ArmorItem *) ( ( new ArmorItem(52, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_iron) ->setIconName(L"leggingsIron")->setDescriptionId(IDS_ITEM_LEGGINGS_IRON)->setUseDescriptionId(IDS_DESC_LEGGINGS_IRON) ); - Item::leggings_diamond = (ArmorItem *) ( ( new ArmorItem(56, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_diamond) ->setIconName(L"leggingsDiamond")->setDescriptionId(IDS_ITEM_LEGGINGS_DIAMOND)->setUseDescriptionId(IDS_DESC_LEGGINGS_DIAMOND) ); - Item::leggings_gold = (ArmorItem *) ( ( new ArmorItem(60, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_gold) ->setIconName(L"leggingsGold")->setDescriptionId(IDS_ITEM_LEGGINGS_GOLD)->setUseDescriptionId(IDS_DESC_LEGGINGS_GOLD) ); - - Item::helmet_chain = (ArmorItem *) ( ( new ArmorItem(46, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_chain) ->setIconName(L"helmetChain")->setDescriptionId(IDS_ITEM_HELMET_CHAIN)->setUseDescriptionId(IDS_DESC_HELMET_CHAIN) ); - Item::chestplate_chain = (ArmorItem *) ( ( new ArmorItem(47, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_chain) ->setIconName(L"chestplateChain")->setDescriptionId(IDS_ITEM_CHESTPLATE_CHAIN)->setUseDescriptionId(IDS_DESC_CHESTPLATE_CHAIN) ); - Item::leggings_chain = (ArmorItem *) ( ( new ArmorItem(48, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_chain) ->setIconName(L"leggingsChain")->setDescriptionId(IDS_ITEM_LEGGINGS_CHAIN)->setUseDescriptionId(IDS_DESC_LEGGINGS_CHAIN) ); - Item::boots_chain = (ArmorItem *) ( ( new ArmorItem(49, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_chain) ->setIconName(L"bootsChain")->setDescriptionId(IDS_ITEM_BOOTS_CHAIN)->setUseDescriptionId(IDS_DESC_BOOTS_CHAIN) ); - - Item::boots_leather = (ArmorItem *) ( ( new ArmorItem(45, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_cloth) ->setIconName(L"bootsCloth")->setDescriptionId(IDS_ITEM_BOOTS_CLOTH)->setUseDescriptionId(IDS_DESC_BOOTS_LEATHER) ); - Item::boots_iron = (ArmorItem *) ( ( new ArmorItem(53, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_iron) ->setIconName(L"bootsIron")->setDescriptionId(IDS_ITEM_BOOTS_IRON)->setUseDescriptionId(IDS_DESC_BOOTS_IRON) ); - Item::boots_diamond = (ArmorItem *) ( ( new ArmorItem(57, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_diamond) ->setIconName(L"bootsDiamond")->setDescriptionId(IDS_ITEM_BOOTS_DIAMOND)->setUseDescriptionId(IDS_DESC_BOOTS_DIAMOND) ); - Item::boots_gold = (ArmorItem *) ( ( new ArmorItem(61, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_FEET) ) ->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_gold) ->setIconName(L"bootsGold")->setDescriptionId(IDS_ITEM_BOOTS_GOLD)->setUseDescriptionId(IDS_DESC_BOOTS_GOLD) ); + Item::helmet_leather = static_cast((new ArmorItem(42, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_cloth)->setIconName(L"helmetCloth")->setDescriptionId(IDS_ITEM_HELMET_CLOTH)->setUseDescriptionId(IDS_DESC_HELMET_LEATHER)); + Item::helmet_iron = static_cast((new ArmorItem(50, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_iron)->setIconName(L"helmetIron")->setDescriptionId(IDS_ITEM_HELMET_IRON)->setUseDescriptionId(IDS_DESC_HELMET_IRON)); + Item::helmet_diamond = static_cast((new ArmorItem(54, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_diamond)->setIconName(L"helmetDiamond")->setDescriptionId(IDS_ITEM_HELMET_DIAMOND)->setUseDescriptionId(IDS_DESC_HELMET_DIAMOND)); + Item::helmet_gold = static_cast((new ArmorItem(58, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_gold)->setIconName(L"helmetGold")->setDescriptionId(IDS_ITEM_HELMET_GOLD)->setUseDescriptionId(IDS_DESC_HELMET_GOLD)); + + Item::chestplate_leather = static_cast((new ArmorItem(43, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_cloth)->setIconName(L"chestplateCloth")->setDescriptionId(IDS_ITEM_CHESTPLATE_CLOTH)->setUseDescriptionId(IDS_DESC_CHESTPLATE_LEATHER)); + Item::chestplate_iron = static_cast((new ArmorItem(51, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_iron)->setIconName(L"chestplateIron")->setDescriptionId(IDS_ITEM_CHESTPLATE_IRON)->setUseDescriptionId(IDS_DESC_CHESTPLATE_IRON)); + Item::chestplate_diamond = static_cast((new ArmorItem(55, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_diamond)->setIconName(L"chestplateDiamond")->setDescriptionId(IDS_ITEM_CHESTPLATE_DIAMOND)->setUseDescriptionId(IDS_DESC_CHESTPLATE_DIAMOND)); + Item::chestplate_gold = static_cast((new ArmorItem(59, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_gold)->setIconName(L"chestplateGold")->setDescriptionId(IDS_ITEM_CHESTPLATE_GOLD)->setUseDescriptionId(IDS_DESC_CHESTPLATE_GOLD)); + + Item::leggings_leather = static_cast((new ArmorItem(44, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_cloth)->setIconName(L"leggingsCloth")->setDescriptionId(IDS_ITEM_LEGGINGS_CLOTH)->setUseDescriptionId(IDS_DESC_LEGGINGS_LEATHER)); + Item::leggings_iron = static_cast((new ArmorItem(52, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_iron)->setIconName(L"leggingsIron")->setDescriptionId(IDS_ITEM_LEGGINGS_IRON)->setUseDescriptionId(IDS_DESC_LEGGINGS_IRON)); + Item::leggings_diamond = static_cast((new ArmorItem(56, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_diamond)->setIconName(L"leggingsDiamond")->setDescriptionId(IDS_ITEM_LEGGINGS_DIAMOND)->setUseDescriptionId(IDS_DESC_LEGGINGS_DIAMOND)); + Item::leggings_gold = static_cast((new ArmorItem(60, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_gold)->setIconName(L"leggingsGold")->setDescriptionId(IDS_ITEM_LEGGINGS_GOLD)->setUseDescriptionId(IDS_DESC_LEGGINGS_GOLD)); + + Item::helmet_chain = static_cast((new ArmorItem(46, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_HEAD))->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_chain)->setIconName(L"helmetChain")->setDescriptionId(IDS_ITEM_HELMET_CHAIN)->setUseDescriptionId(IDS_DESC_HELMET_CHAIN)); + Item::chestplate_chain = static_cast((new ArmorItem(47, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_TORSO))->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_chain)->setIconName(L"chestplateChain")->setDescriptionId(IDS_ITEM_CHESTPLATE_CHAIN)->setUseDescriptionId(IDS_DESC_CHESTPLATE_CHAIN)); + Item::leggings_chain = static_cast((new ArmorItem(48, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_LEGS))->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_chain)->setIconName(L"leggingsChain")->setDescriptionId(IDS_ITEM_LEGGINGS_CHAIN)->setUseDescriptionId(IDS_DESC_LEGGINGS_CHAIN)); + Item::boots_chain = static_cast((new ArmorItem(49, ArmorItem::ArmorMaterial::CHAIN, 1, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_chain)->setIconName(L"bootsChain")->setDescriptionId(IDS_ITEM_BOOTS_CHAIN)->setUseDescriptionId(IDS_DESC_BOOTS_CHAIN)); + + Item::boots_leather = static_cast((new ArmorItem(45, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_cloth)->setIconName(L"bootsCloth")->setDescriptionId(IDS_ITEM_BOOTS_CLOTH)->setUseDescriptionId(IDS_DESC_BOOTS_LEATHER)); + Item::boots_iron = static_cast((new ArmorItem(53, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_iron)->setIconName(L"bootsIron")->setDescriptionId(IDS_ITEM_BOOTS_IRON)->setUseDescriptionId(IDS_DESC_BOOTS_IRON)); + Item::boots_diamond = static_cast((new ArmorItem(57, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_diamond)->setIconName(L"bootsDiamond")->setDescriptionId(IDS_ITEM_BOOTS_DIAMOND)->setUseDescriptionId(IDS_DESC_BOOTS_DIAMOND)); + Item::boots_gold = static_cast((new ArmorItem(61, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_FEET))->setBaseItemTypeAndMaterial(eBaseItemType_boots, eMaterial_gold)->setIconName(L"bootsGold")->setDescriptionId(IDS_ITEM_BOOTS_GOLD)->setUseDescriptionId(IDS_DESC_BOOTS_GOLD)); Item::ironIngot = ( new Item(9) )->setIconName(L"ingotIron") ->setBaseItemTypeAndMaterial(eBaseItemType_treasure, eMaterial_iron)->setDescriptionId(IDS_ITEM_INGOT_IRON)->setUseDescriptionId(IDS_DESC_INGOT); Item::goldIngot = ( new Item(10) )->setIconName(L"ingotGold") ->setBaseItemTypeAndMaterial(eBaseItemType_treasure, eMaterial_gold)->setDescriptionId(IDS_ITEM_INGOT_GOLD)->setUseDescriptionId(IDS_DESC_INGOT); @@ -324,12 +324,12 @@ void Item::staticCtor() Item::bucket_lava = ( new BucketItem(71, Tile::lava_Id) ) ->setIconName(L"bucketLava")->setDescriptionId(IDS_ITEM_BUCKET_LAVA)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_LAVA); Item::bucket_milk = ( new MilkBucketItem(79) )->setIconName(L"milk")->setDescriptionId(IDS_ITEM_BUCKET_MILK)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_MILK); - Item::bow = (BowItem *)( new BowItem(5) ) ->setIconName(L"bow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_bow) ->setDescriptionId(IDS_ITEM_BOW)->setUseDescriptionId(IDS_DESC_BOW); + Item::bow = static_cast((new BowItem(5))->setIconName(L"bow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_bow)->setDescriptionId(IDS_ITEM_BOW)->setUseDescriptionId(IDS_DESC_BOW)); Item::arrow = ( new Item(6) ) ->setIconName(L"arrow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_arrow) ->setDescriptionId(IDS_ITEM_ARROW)->setUseDescriptionId(IDS_DESC_ARROW); Item::compass = ( new CompassItem(89) ) ->setIconName(L"compass")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_compass) ->setDescriptionId(IDS_ITEM_COMPASS)->setUseDescriptionId(IDS_DESC_COMPASS); Item::clock = ( new ClockItem(91) ) ->setIconName(L"clock")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_clock) ->setDescriptionId(IDS_ITEM_CLOCK)->setUseDescriptionId(IDS_DESC_CLOCK); - Item::map = (MapItem *) ( new MapItem(102) ) ->setIconName(L"map")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_map) ->setDescriptionId(IDS_ITEM_MAP)->setUseDescriptionId(IDS_DESC_MAP); + Item::map = static_cast((new MapItem(102))->setIconName(L"map")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_map)->setDescriptionId(IDS_ITEM_MAP)->setUseDescriptionId(IDS_DESC_MAP)); Item::flintAndSteel = ( new FlintAndSteelItem(3) ) ->setIconName(L"flintAndSteel")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_flintandsteel)->setDescriptionId(IDS_ITEM_FLINT_AND_STEEL)->setUseDescriptionId(IDS_DESC_FLINTANDSTEEL); Item::apple = ( new FoodItem(4, 4, FoodConstants::FOOD_SATURATION_LOW, false) ) ->setIconName(L"apple")->setDescriptionId(IDS_ITEM_APPLE)->setUseDescriptionId(IDS_DESC_APPLE); @@ -377,7 +377,7 @@ void Item::staticCtor() Item::minecart_chest = ( new MinecartItem(86, Minecart::TYPE_CHEST) ) ->setIconName(L"minecart_chest")->setDescriptionId(IDS_ITEM_MINECART_CHEST)->setUseDescriptionId(IDS_DESC_MINECARTWITHCHEST); Item::minecart_furnace = ( new MinecartItem(87, Minecart::TYPE_FURNACE) )->setIconName(L"minecart_furnace")->setDescriptionId(IDS_ITEM_MINECART_FURNACE)->setUseDescriptionId(IDS_DESC_MINECARTWITHFURNACE); Item::egg = ( new EggItem(88) ) ->setIconName(L"egg")->setDescriptionId(IDS_ITEM_EGG)->setUseDescriptionId(IDS_DESC_EGG); - Item::fishingRod = (FishingRodItem *)( new FishingRodItem(90) ) ->setBaseItemTypeAndMaterial(eBaseItemType_rod, eMaterial_wood)->setIconName(L"fishingRod")->setDescriptionId(IDS_ITEM_FISHING_ROD)->setUseDescriptionId(IDS_DESC_FISHINGROD); + Item::fishingRod = static_cast((new FishingRodItem(90))->setBaseItemTypeAndMaterial(eBaseItemType_rod, eMaterial_wood)->setIconName(L"fishingRod")->setDescriptionId(IDS_ITEM_FISHING_ROD)->setUseDescriptionId(IDS_DESC_FISHINGROD)); Item::yellowDust = ( new Item(92) ) ->setIconName(L"yellowDust")->setDescriptionId(IDS_ITEM_YELLOW_DUST)->setUseDescriptionId(IDS_DESC_YELLOW_DUST)->setPotionBrewingFormula(PotionBrewing::MOD_GLOWSTONE); Item::fish_raw = ( new FoodItem(93, 2, FoodConstants::FOOD_SATURATION_LOW, false) ) ->setIconName(L"fishRaw")->setDescriptionId(IDS_ITEM_FISH_RAW)->setUseDescriptionId(IDS_DESC_FISH_RAW); Item::fish_cooked = ( new FoodItem(94, 5, FoodConstants::FOOD_SATURATION_NORMAL, false) ) ->setIconName(L"fishCooked")->setDescriptionId(IDS_ITEM_FISH_COOKED)->setUseDescriptionId(IDS_DESC_FISH_COOKED); @@ -392,11 +392,11 @@ void Item::staticCtor() Item::bed = ( new BedItem(99) ) ->setMaxStackSize(1)->setIconName(L"bed")->setDescriptionId(IDS_ITEM_BED)->setUseDescriptionId(IDS_DESC_BED); - Item::repeater = ( new TilePlanterItem(100, (Tile *)Tile::diode_off) ) ->setIconName(L"diode")->setDescriptionId(IDS_ITEM_DIODE)->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER); + Item::repeater = ( new TilePlanterItem(100, static_cast(Tile::diode_off)) ) ->setIconName(L"diode")->setDescriptionId(IDS_ITEM_DIODE)->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER); Item::cookie = ( new FoodItem(101, 2, FoodConstants::FOOD_SATURATION_POOR, false) ) ->setIconName(L"cookie")->setDescriptionId(IDS_ITEM_COOKIE)->setUseDescriptionId(IDS_DESC_COOKIE); - Item::shears = (ShearsItem *)( new ShearsItem(103) ) ->setIconName(L"shears")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_shears)->setDescriptionId(IDS_ITEM_SHEARS)->setUseDescriptionId(IDS_DESC_SHEARS); + Item::shears = static_cast((new ShearsItem(103))->setIconName(L"shears")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_shears)->setDescriptionId(IDS_ITEM_SHEARS)->setUseDescriptionId(IDS_DESC_SHEARS)); Item::melon = (new FoodItem(104, 2, FoodConstants::FOOD_SATURATION_LOW, false)) ->setIconName(L"melon")->setDescriptionId(IDS_ITEM_MELON_SLICE)->setUseDescriptionId(IDS_DESC_MELON_SLICE); @@ -417,7 +417,7 @@ void Item::staticCtor() Item::netherwart_seeds = (new SeedItem(116, Tile::netherStalk_Id, Tile::soulsand_Id) ) ->setIconName(L"netherStalkSeeds")->setDescriptionId(IDS_ITEM_NETHER_STALK_SEEDS)->setUseDescriptionId(IDS_DESC_NETHER_STALK_SEEDS)->setPotionBrewingFormula(PotionBrewing::MOD_NETHERWART); - Item::potion = (PotionItem *) ( ( new PotionItem(117) ) ->setIconName(L"potion")->setDescriptionId(IDS_ITEM_POTION)->setUseDescriptionId(IDS_DESC_POTION) ); + Item::potion = static_cast((new PotionItem(117))->setIconName(L"potion")->setDescriptionId(IDS_ITEM_POTION)->setUseDescriptionId(IDS_DESC_POTION)); Item::glassBottle = (new BottleItem(118) ) ->setBaseItemTypeAndMaterial(eBaseItemType_utensil, eMaterial_glass)->setIconName(L"glassBottle")->setDescriptionId(IDS_ITEM_GLASS_BOTTLE)->setUseDescriptionId(IDS_DESC_GLASS_BOTTLE); Item::spiderEye = (new FoodItem(119, 2, FoodConstants::FOOD_SATURATION_GOOD, false) ) ->setEatEffect(MobEffect::poison->id, 5, 0, 1.0f)->setIconName(L"spiderEye")->setDescriptionId(IDS_ITEM_SPIDER_EYE)->setUseDescriptionId(IDS_DESC_SPIDER_EYE)->setPotionBrewingFormula(PotionBrewing::MOD_SPIDEREYE); @@ -473,7 +473,7 @@ void Item::staticCtor() Item::potatoBaked = (new FoodItem(137, 6, FoodConstants::FOOD_SATURATION_NORMAL, false)) ->setIconName(L"potatoBaked")->setDescriptionId(IDS_ITEM_POTATO_BAKED)->setUseDescriptionId(IDS_DESC_POTATO_BAKED); Item::potatoPoisonous = (new FoodItem(138, 2, FoodConstants::FOOD_SATURATION_LOW, false)) ->setEatEffect(MobEffect::poison->id, 5, 0, .6f)->setIconName(L"potatoPoisonous")->setDescriptionId(IDS_ITEM_POTATO_POISONOUS)->setUseDescriptionId(IDS_DESC_POTATO_POISONOUS); - Item::emptyMap = (EmptyMapItem *) (new EmptyMapItem(139))->setIconName(L"map_empty")->setDescriptionId(IDS_ITEM_MAP_EMPTY)->setUseDescriptionId(IDS_DESC_MAP_EMPTY); + Item::emptyMap = static_cast((new EmptyMapItem(139))->setIconName(L"map_empty")->setDescriptionId(IDS_ITEM_MAP_EMPTY)->setUseDescriptionId(IDS_DESC_MAP_EMPTY)); Item::carrotGolden = (new FoodItem(140, 6, FoodConstants::FOOD_SATURATION_SUPERNATURAL, false)) ->setBaseItemTypeAndMaterial(eBaseItemType_giltFruit, eMaterial_carrot)->setIconName(L"carrotGolden")->setPotionBrewingFormula(PotionBrewing::MOD_GOLDENCARROT)->setDescriptionId(IDS_ITEM_CARROT_GOLDEN)->setUseDescriptionId(IDS_DESC_CARROT_GOLDEN); @@ -482,7 +482,7 @@ void Item::staticCtor() Item::pumpkinPie = (new FoodItem(144, 8, FoodConstants::FOOD_SATURATION_LOW, false)) ->setIconName(L"pumpkinPie")->setDescriptionId(IDS_ITEM_PUMPKIN_PIE)->setUseDescriptionId(IDS_DESC_PUMPKIN_PIE); Item::fireworks = (new FireworksItem(145)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_fireworks, Item::eMaterial_undefined)->setIconName(L"fireworks")->setDescriptionId(IDS_FIREWORKS)->setUseDescriptionId(IDS_DESC_FIREWORKS); Item::fireworksCharge = (new FireworksChargeItem(146)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_fireworks, Item::eMaterial_undefined)->setIconName(L"fireworks_charge")->setDescriptionId(IDS_FIREWORKS_CHARGE)->setUseDescriptionId(IDS_DESC_FIREWORKS_CHARGE); - EnchantedBookItem::enchantedBook = (EnchantedBookItem *)(new EnchantedBookItem(147)) ->setMaxStackSize(1)->setIconName(L"enchantedBook")->setDescriptionId(IDS_ITEM_ENCHANTED_BOOK)->setUseDescriptionId(IDS_DESC_ENCHANTED_BOOK); + EnchantedBookItem::enchantedBook = static_cast((new EnchantedBookItem(147))->setMaxStackSize(1)->setIconName(L"enchantedBook")->setDescriptionId(IDS_ITEM_ENCHANTED_BOOK)->setUseDescriptionId(IDS_DESC_ENCHANTED_BOOK)); Item::comparator = (new TilePlanterItem(148, Tile::comparator_off)) ->setIconName(L"comparator")->setDescriptionId(IDS_ITEM_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR); Item::netherbrick = (new Item(149)) ->setIconName(L"netherbrick")->setDescriptionId(IDS_ITEM_NETHERBRICK)->setUseDescriptionId(IDS_DESC_ITEM_NETHERBRICK); Item::netherQuartz = (new Item(150)) ->setIconName(L"netherquartz")->setDescriptionId(IDS_ITEM_NETHER_QUARTZ)->setUseDescriptionId(IDS_DESC_NETHER_QUARTZ); diff --git a/Minecraft.World/ItemDispenseBehaviors.cpp b/Minecraft.World/ItemDispenseBehaviors.cpp index 08c73a0c1..8d051c735 100644 --- a/Minecraft.World/ItemDispenseBehaviors.cpp +++ b/Minecraft.World/ItemDispenseBehaviors.cpp @@ -273,7 +273,7 @@ void BoatDispenseBehavior::playSound(BlockSource *source, eOUTCOME outcome) shared_ptr FilledBucketDispenseBehavior::execute(BlockSource *source, shared_ptr dispensed, eOUTCOME &outcome) { - BucketItem *bucket = (BucketItem *)dispensed->getItem(); + BucketItem *bucket = static_cast(dispensed->getItem()); int sourceX = source->getBlockX(); int sourceY = source->getBlockY(); int sourceZ = source->getBlockZ(); diff --git a/Minecraft.World/ItemEntity.cpp b/Minecraft.World/ItemEntity.cpp index 66d271f72..c012a9123 100644 --- a/Minecraft.World/ItemEntity.cpp +++ b/Minecraft.World/ItemEntity.cpp @@ -20,7 +20,7 @@ void ItemEntity::_init() age = 0; throwTime = 0; health = 5; - bobOffs = (float) (Math::random() * PI * 2); + bobOffs = static_cast(Math::random() * PI * 2); // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that // the derived version of the function is called @@ -36,11 +36,11 @@ void ItemEntity::_init(Level *level, double x, double y, double z) setPos(x, y, z); - yRot = (float) (Math::random() * 360); + yRot = static_cast(Math::random() * 360); - xd = (float) (Math::random() * 0.2f - 0.1f); + xd = static_cast(Math::random() * 0.2f - 0.1f); yd = +0.2f; - zd = (float) (Math::random() * 0.2f - 0.1f); + zd = static_cast(Math::random() * 0.2f - 0.1f); } ItemEntity::ItemEntity(Level *level, double x, double y, double z) : Entity(level) @@ -84,7 +84,7 @@ void ItemEntity::tick() // 4J - added parameter here so that these don't care about colliding with other entities move(xd, yd, zd, true); - bool moved = (int) xo != (int) x || (int) yo != (int) y || (int) zo != (int) z; + bool moved = static_cast(xo) != static_cast(x) || static_cast(yo) != static_cast(y) || static_cast(zo) != static_cast(z); if (moved || tickCount % 25 == 0) { @@ -204,8 +204,8 @@ bool ItemEntity::hurt(DamageSource *source, float damage) void ItemEntity::addAdditonalSaveData(CompoundTag *entityTag) { - entityTag->putShort(L"Health", (byte) health); - entityTag->putShort(L"Age", (short) age); + entityTag->putShort(L"Health", static_cast(health)); + entityTag->putShort(L"Age", static_cast(age)); if (getItem() != NULL) entityTag->putCompound(L"Item", getItem()->save(new CompoundTag())); } diff --git a/Minecraft.World/ItemFrame.cpp b/Minecraft.World/ItemFrame.cpp index 0d52b421b..f8f4731b0 100644 --- a/Minecraft.World/ItemFrame.cpp +++ b/Minecraft.World/ItemFrame.cpp @@ -38,7 +38,7 @@ ItemFrame::ItemFrame(Level *level, int xTile, int yTile, int zTile, int dir) : H void ItemFrame::defineSynchedData() { getEntityData()->defineNULL(DATA_ITEM, NULL); - getEntityData()->define(DATA_ROTATION, (byte) 0); + getEntityData()->define(DATA_ROTATION, static_cast(0)); } bool ItemFrame::shouldRenderAtSqrDistance(double distance) @@ -107,7 +107,7 @@ int ItemFrame::getRotation() void ItemFrame::setRotation(int rotation) { - getEntityData()->set(DATA_ROTATION, (byte) (rotation % 4)); + getEntityData()->set(DATA_ROTATION, static_cast(rotation % 4)); } void ItemFrame::addAdditonalSaveData(CompoundTag *tag) @@ -115,7 +115,7 @@ void ItemFrame::addAdditonalSaveData(CompoundTag *tag) if (getItem() != NULL) { tag->putCompound(L"Item", getItem()->save(new CompoundTag())); - tag->putByte(L"ItemRotation", (byte) getRotation()); + tag->putByte(L"ItemRotation", static_cast(getRotation())); tag->putFloat(L"ItemDropChance", dropChance); } HangingEntity::addAdditonalSaveData(tag); diff --git a/Minecraft.World/ItemInstance.cpp b/Minecraft.World/ItemInstance.cpp index 4dcde7aa5..e344e4cd6 100644 --- a/Minecraft.World/ItemInstance.cpp +++ b/Minecraft.World/ItemInstance.cpp @@ -92,7 +92,7 @@ ItemInstance::~ItemInstance() shared_ptr ItemInstance::remove(int count) { shared_ptr ii = shared_ptr( new ItemInstance(id, count, auxValue) ); - if (tag != NULL) ii->tag = (CompoundTag *) tag->copy(); + if (tag != NULL) ii->tag = static_cast(tag->copy()); this->count -= count; // 4J Stu Fix for duplication glitch, make sure that item count is in range @@ -145,9 +145,9 @@ shared_ptr ItemInstance::useTimeDepleted(Level *level, shared_ptr< CompoundTag *ItemInstance::save(CompoundTag *compoundTag) { - compoundTag->putShort(L"id", (short) id); - compoundTag->putByte(L"Count", (byte) count); - compoundTag->putShort(L"Damage", (short) auxValue); + compoundTag->putShort(L"id", static_cast(id)); + compoundTag->putByte(L"Count", static_cast(count)); + compoundTag->putShort(L"Damage", static_cast(auxValue)); if (tag != NULL) compoundTag->put(L"tag", tag->copy()); return compoundTag; } @@ -165,7 +165,7 @@ void ItemInstance::load(CompoundTag *compoundTag) if (compoundTag->contains(L"tag")) { delete tag; - tag = (CompoundTag *)compoundTag->getCompound(L"tag")->copy(); + tag = static_cast(compoundTag->getCompound(L"tag")->copy()); } } @@ -305,7 +305,7 @@ shared_ptr ItemInstance::copy() const shared_ptr copy = shared_ptr( new ItemInstance(id, count, auxValue) ); if (tag != NULL) { - copy->tag = (CompoundTag *) tag->copy(); + copy->tag = static_cast(tag->copy()); } return copy; } @@ -316,7 +316,7 @@ ItemInstance *ItemInstance::copy_not_shared() const ItemInstance *copy = new ItemInstance(id, count, auxValue); if (tag != NULL) { - copy->tag = (CompoundTag *) tag->copy(); + copy->tag = static_cast(tag->copy()); if (!copy->tag->equals(tag)) { return copy; @@ -493,7 +493,7 @@ ListTag *ItemInstance::getEnchantmentTags() { return NULL; } - return (ListTag *) tag->get(L"ench"); + return static_cast *>(tag->get(L"ench")); } void ItemInstance::setTag(CompoundTag *tag) @@ -733,10 +733,10 @@ void ItemInstance::enchant(const Enchantment *enchantment, int level) if (tag == NULL) this->setTag(new CompoundTag()); if (!tag->contains(L"ench")) tag->put(L"ench", new ListTag(L"ench")); - ListTag *list = (ListTag *) tag->get(L"ench"); + ListTag *list = static_cast *>(tag->get(L"ench")); CompoundTag *ench = new CompoundTag(); - ench->putShort((wchar_t *)TAG_ENCH_ID, (short) enchantment->id); - ench->putShort((wchar_t *)TAG_ENCH_LEVEL, (byte) level); + ench->putShort((wchar_t *)TAG_ENCH_ID, static_cast(enchantment->id)); + ench->putShort((wchar_t *)TAG_ENCH_LEVEL, static_cast(level)); list->add(ench); } @@ -829,7 +829,7 @@ void ItemInstance::set4JData(int data) if (tag->contains(L"4jdata")) { - IntTag *dataTag = (IntTag *)tag->get(L"4jdata"); + IntTag *dataTag = static_cast(tag->get(L"4jdata")); dataTag->data = data; } else if(data != 0) @@ -843,7 +843,7 @@ int ItemInstance::get4JData() if(tag == NULL || !tag->contains(L"4jdata")) return 0; else { - IntTag *dataTag = (IntTag *)tag->get(L"4jdata"); + IntTag *dataTag = static_cast(tag->get(L"4jdata")); return dataTag->data; } } diff --git a/Minecraft.World/JavaIntHash.h b/Minecraft.World/JavaIntHash.h index fe6084699..8293cb468 100644 --- a/Minecraft.World/JavaIntHash.h +++ b/Minecraft.World/JavaIntHash.h @@ -13,9 +13,9 @@ struct IntKeyHash { int h = k; h += ~(h << 9); - h ^= (((unsigned int)h) >> 14); + h ^= (static_cast(h) >> 14); h += (h << 4); - h ^= (((unsigned int)h) >> 10); + h ^= (static_cast(h) >> 10); return h; } }; diff --git a/Minecraft.World/JavaMath.cpp b/Minecraft.World/JavaMath.cpp index 928436952..eacda91a0 100644 --- a/Minecraft.World/JavaMath.cpp +++ b/Minecraft.World/JavaMath.cpp @@ -36,7 +36,7 @@ double Math::random() //the value of the argument rounded to the nearest long value. __int64 Math::round( double d ) { - return (__int64)floor( d + 0.5 ); + return static_cast<__int64>(floor(d + 0.5)); } int Math::_max(int a, int b) diff --git a/Minecraft.World/LargeCaveFeature.cpp b/Minecraft.World/LargeCaveFeature.cpp index c05447cf8..cdef08753 100644 --- a/Minecraft.World/LargeCaveFeature.cpp +++ b/Minecraft.World/LargeCaveFeature.cpp @@ -144,11 +144,11 @@ void LargeCaveFeature::addTunnel(__int64 seed, int xOffs, int zOffs, byteArray b { if (yy < 10) { - blocks[p] = (byte) Tile::lava_Id; + blocks[p] = static_cast(Tile::lava_Id); } else { - blocks[p] = (byte) 0; + blocks[p] = static_cast(0); if (hasGrass && blocks[p - 1] == Tile::dirt_Id) blocks[p - 1] = (byte) level->getBiome(xx + xOffs * 16, zz + zOffs * 16)->topMaterial; } } diff --git a/Minecraft.World/LargeHellCaveFeature.cpp b/Minecraft.World/LargeHellCaveFeature.cpp index b1e636eb4..e09153fbd 100644 --- a/Minecraft.World/LargeHellCaveFeature.cpp +++ b/Minecraft.World/LargeHellCaveFeature.cpp @@ -138,7 +138,7 @@ void LargeHellCaveFeature::addTunnel(__int64 seed, int xOffs, int zOffs, byteArr int block = blocks[p]; if (block == Tile::netherRack_Id || block == Tile::dirt_Id || block == Tile::grass_Id) { - blocks[p] = (byte) 0; + blocks[p] = static_cast(0); } } p--; diff --git a/Minecraft.World/Layer.cpp b/Minecraft.World/Layer.cpp index 956a8917b..5187af7e0 100644 --- a/Minecraft.World/Layer.cpp +++ b/Minecraft.World/Layer.cpp @@ -189,7 +189,7 @@ int Layer::nextRandom(int max) } #else - int result = (int) ((rval >> 24) % max); + int result = static_cast((rval >> 24) % max); #endif if (result < 0) result += max; diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp index b977ad7d2..6b83d0aa8 100644 --- a/Minecraft.World/Level.cpp +++ b/Minecraft.World/Level.cpp @@ -91,13 +91,13 @@ DWORD Level::tlsIdxLightCache = TlsAlloc(); void Level::enableLightingCache() { // Allocate 16K (needs 32K for large worlds) for a 16x16x16x4 byte cache of results, plus 128K required for toCheck array. Rounding up to 256 to keep as multiple of alignement - aligning to 128K boundary for possible cache locking. - void *cache = (unsigned char *)XPhysicalAlloc(256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES); + void *cache = static_cast(XPhysicalAlloc(256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES)); TlsSetValue(tlsIdxLightCache,cache); } void Level::destroyLightingCache() { - lightCache_t *cache = (lightCache_t *)TlsGetValue(tlsIdxLightCache); + lightCache_t *cache = static_cast(TlsGetValue(tlsIdxLightCache)); XPhysicalFree(cache); } @@ -195,8 +195,8 @@ void inline Level::setBrightnessCached(lightCache_t *cache, __uint64 *cacheUse, ( ( z & 0x3f0 ) >> 4 ); #ifdef _LARGE_WORLDS // Add in the higher bits for x and z - posbits |= ( ( ((__uint64)x) & 0x3FFFC00L) << 38) | - ( ( ((__uint64)z) & 0x3FFFC00L) << 22); + posbits |= ( ( static_cast<__uint64>(x) & 0x3FFFC00L) << 38) | + ( ( static_cast<__uint64>(z) & 0x3FFFC00L) << 22); #endif lightCache_t cacheValue = cache[idx]; @@ -254,8 +254,8 @@ inline int Level::getBrightnessCached(lightCache_t *cache, LightLayer::variety l ( ( z & 0x3f0 ) >> 4 ); #ifdef _LARGE_WORLDS // Add in the higher bits for x and z - posbits |= ( ( ((__uint64)x) & 0x3FFFC00L) << 38) | - ( ( ((__uint64)z) & 0x3FFFC00L) << 22); + posbits |= ( ( static_cast<__uint64>(x) & 0x3FFFC00L) << 38) | + ( ( static_cast<__uint64>(z) & 0x3FFFC00L) << 22); #endif lightCache_t cacheValue = cache[idx]; @@ -321,8 +321,8 @@ inline int Level::getEmissionCached(lightCache_t *cache, int ct, int x, int y, i ( ( z & 0x3f0 ) >> 4 ); #ifdef _LARGE_WORLDS // Add in the higher bits for x and z - posbits |= ( ( ((__uint64)x) & 0x3FFFC00) << 38) | - ( ( ((__uint64)z) & 0x3FFFC00) << 22); + posbits |= ( ( static_cast<__uint64>(x) & 0x3FFFC00) << 38) | + ( ( static_cast<__uint64>(z) & 0x3FFFC00) << 22); #endif lightCache_t cacheValue = cache[idx]; @@ -397,8 +397,8 @@ inline int Level::getBlockingCached(lightCache_t *cache, LightLayer::variety lay ( ( z & 0x3f0 ) >> 4 ); #ifdef _LARGE_WORLDS // Add in the higher bits for x and z - posbits |= ( ( ((__uint64)x) & 0x3FFFC00L) << 38) | - ( ( ((__uint64)z) & 0x3FFFC00L) << 22); + posbits |= ( ( static_cast<__uint64>(x) & 0x3FFFC00L) << 38) | + ( ( static_cast<__uint64>(z) & 0x3FFFC00L) << 22); #endif lightCache_t cacheValue = cache[idx]; @@ -1377,7 +1377,7 @@ void Level::getNeighbourBrightnesses(int *brightnesses, LightLayer::variety laye { for( int i = 0; i < 6; i++ ) { - brightnesses[i] = (int)layer; + brightnesses[i] = static_cast(layer); } return; } @@ -1392,7 +1392,7 @@ void Level::getNeighbourBrightnesses(int *brightnesses, LightLayer::variety laye { for( int i = 0; i < 6; i++ ) { - brightnesses[i] = (int)layer; + brightnesses[i] = static_cast(layer); } return; } @@ -1592,19 +1592,19 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly) } Vec3 *tPos = Vec3::newTemp(a->x, a->y, a->z); - xTile0 = (int) (tPos->x = floor(a->x)); + xTile0 = static_cast(tPos->x = floor(a->x)); if (face == 5) { xTile0--; tPos->x++; } - yTile0 = (int) (tPos->y = floor(a->y)); + yTile0 = static_cast(tPos->y = floor(a->y)); if (face == 1) { yTile0--; tPos->y++; } - zTile0 = (int) (tPos->z = floor(a->z)); + zTile0 = static_cast(tPos->z = floor(a->z)); if (face == 3) { zTile0--; @@ -2001,7 +2001,7 @@ int Level::getOldSkyDarken(float a) br *= 1 - (getRainLevel(a) * 5 / 16.0f); br *= 1 - (getThunderLevel(a) * 5 / 16.0f); br = 1 - br; - return ((int) (br * 11)); + return static_cast(br * 11); } //4J - change brought forward from 1.8.2 @@ -2839,7 +2839,7 @@ float Level::getSeenPercent(Vec3 *center, AABB *bb) count++; } - return hits / (float) count; + return hits / static_cast(count); } @@ -3258,7 +3258,7 @@ void Level::buildAndPrepareChunksToPoll() // 4J - rewritten to add chunks interleaved by player, and to add them from the centre outwards. We're going to be // potentially adding less creatures than the original so that our count stays consistent with number of players added, so // we want to make sure as best we can that the ones we do add are near the active players - int playerCount = (int)players.size(); + int playerCount = static_cast(players.size()); int *xx = new int[playerCount]; int *zz = new int[playerCount]; for (size_t i = 0; i < playerCount; i++) @@ -3437,7 +3437,7 @@ int Level::getExpectedLight(lightCache_t *cache, int x, int y, int z, LightLayer // 4J - Made changes here so that lighting goes through a cache, if enabled for this thread void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool force, bool rootOnlyEmissive) { - lightCache_t *cache = (lightCache_t *)TlsGetValue(tlsIdxLightCache); + lightCache_t *cache = static_cast(TlsGetValue(tlsIdxLightCache)); __uint64 cacheUse = 0; if( force ) @@ -3964,7 +3964,7 @@ Path *Level::findPath(shared_ptr from, shared_ptr to, float maxD int y = Mth::floor(from->y + 1); int z = Mth::floor(from->z); - int r = (int) (maxDist + 16); + int r = static_cast(maxDist + 16); int x1 = x - r; int y1 = y - r; int z1 = z - r; @@ -3983,7 +3983,7 @@ Path *Level::findPath(shared_ptr from, int xBest, int yBest, int zBest, int y = Mth::floor(from->y); int z = Mth::floor(from->z); - int r = (int) (maxDist + 8); + int r = static_cast(maxDist + 8); int x1 = x - r; int y1 = y - r; int z1 = z - r; diff --git a/Minecraft.World/LevelChunk.cpp b/Minecraft.World/LevelChunk.cpp index d4be5ac23..9d7e51317 100644 --- a/Minecraft.World/LevelChunk.cpp +++ b/Minecraft.World/LevelChunk.cpp @@ -531,7 +531,7 @@ void LevelChunk::recalcHeightmapOnly() blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks; } #endif - heightmap[z << 4 | x] = (byte) y; + heightmap[z << 4 | x] = static_cast(y); if (y < min) min = y; } @@ -588,7 +588,7 @@ void LevelChunk::recalcHeightmap() blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks; } #endif - heightmap[z << 4 | x] = (byte) y; + heightmap[z << 4 | x] = static_cast(y); if (y < min) min = y; if (y < lowestHeightmap) lowestHeightmap = y; @@ -811,7 +811,7 @@ void LevelChunk::recalcHeight(int x, int yStart, int z) if (y == yOld) return; // level->lightColumnChanged(x, z, y, yOld); // 4J - this call moved below & corrected - see comment further down - heightmap[z << 4 | x] = (byte) y; + heightmap[z << 4 | x] = static_cast(y); if (y < minHeight) { @@ -919,12 +919,12 @@ int LevelChunk::getTile(int x, int y, int z) bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) { - byte tile = (byte) _tile; + byte tile = static_cast(_tile); // Optimisation brought forward from 1.8.2, change from int to unsigned char & this special value changed from -999 to 255 int slot = z << 4 | x; - if (y >= ((int)rainHeights[slot]) - 1) + if (y >= static_cast(rainHeights[slot]) - 1) { rainHeights[slot] = 255; } @@ -1719,7 +1719,7 @@ int LevelChunk::countEntities() #endif for (int yc = 0; yc < ENTITY_BLOCKS_LENGTH; yc++) { - entityCount += (int)entityBlocks[yc]->size(); + entityCount += static_cast(entityBlocks[yc]->size()); } #ifdef _ENTITIES_RW_SECTION LeaveCriticalRWSection(&m_csEntities, false); @@ -1813,7 +1813,7 @@ bool LevelChunk::testSetBlocksAndData(byteArray data, int x0, int y0, int z0, in void LevelChunk::tileUpdatedCallback(int x, int y, int z, void *param, int yparam) { - LevelChunk *lc = (LevelChunk *)param; + LevelChunk *lc = static_cast(param); int xx = lc->x * 16 + x; int yy = y + yparam; int zz = lc->z * 16 + z; @@ -2000,7 +2000,7 @@ void LevelChunk::checkChests(ChunkSource *source, int x, int z ) { int xOffs = x * 16 + xx; int zOffs = z * 16 + zz; - ChestTile *tile = (ChestTile *)Tile::tiles[Tile::chest_Id]; + ChestTile *tile = static_cast(Tile::tiles[Tile::chest_Id]); tile->recalcLockDir( level, xOffs, yy, zOffs ); level->checkLight(xOffs, yy, zOffs, true); } @@ -2047,7 +2047,7 @@ void LevelChunk::reloadBiomes() for(unsigned int z = 0; z < 16; ++z) { Biome *biome = biomeSource->getBiome((this->x << 4) + x, (this->z << 4) + z); - biomes[(z << 4) | x] = (byte) ( (biome->id) & 0xff); + biomes[(z << 4) | x] = static_cast((biome->id) & 0xff); } } } @@ -2059,7 +2059,7 @@ Biome *LevelChunk::getBiome(int x, int z, BiomeSource *biomeSource) { Biome *biome = biomeSource->getBiome((this->x << 4) + x, (this->z << 4) + z); value = biome->id; - biomes[(z << 4) | x] = (byte) (value & 0xff); + biomes[(z << 4) | x] = static_cast(value & 0xff); } if (Biome::biomes[value] == NULL) { diff --git a/Minecraft.World/LevelData.cpp b/Minecraft.World/LevelData.cpp index 91b72fe8c..a40602573 100644 --- a/Minecraft.World/LevelData.cpp +++ b/Minecraft.World/LevelData.cpp @@ -712,7 +712,7 @@ void LevelData::getMoatFlags(bool* bClassicEdgeMoat, bool* bSmallEdgeMoat, bool* int LevelData::getXZHellSizeOld() { - int hellXZSizeOld = ceil((float)m_xzSizeOld / m_hellScaleOld); + int hellXZSizeOld = ceil(static_cast(m_xzSizeOld) / m_hellScaleOld); while(hellXZSizeOld > HELL_LEVEL_MAX_WIDTH && m_hellScaleOld < HELL_LEVEL_MAX_SCALE) { diff --git a/Minecraft.World/LevelSoundPacket.cpp b/Minecraft.World/LevelSoundPacket.cpp index cbe31a2d5..cc2e29c45 100644 --- a/Minecraft.World/LevelSoundPacket.cpp +++ b/Minecraft.World/LevelSoundPacket.cpp @@ -20,9 +20,9 @@ LevelSoundPacket::LevelSoundPacket() LevelSoundPacket::LevelSoundPacket(int sound, double x, double y, double z, float volume, float pitch) { this->sound = sound; - this->x = (int) (x * LOCATION_ACCURACY); - this->y = (int) (y * LOCATION_ACCURACY); - this->z = (int) (z * LOCATION_ACCURACY); + this->x = static_cast(x * LOCATION_ACCURACY); + this->y = static_cast(y * LOCATION_ACCURACY); + this->z = static_cast(z * LOCATION_ACCURACY); this->volume = volume; // 4J-PB - Let's make the pitch a float so it doesn't get mangled and make the noteblock people unhappy //this->pitch = (int) (pitch * PITCH_ACCURACY); diff --git a/Minecraft.World/LightningBolt.cpp b/Minecraft.World/LightningBolt.cpp index a109d96b6..68ac77efb 100644 --- a/Minecraft.World/LightningBolt.cpp +++ b/Minecraft.World/LightningBolt.cpp @@ -78,11 +78,11 @@ void LightningBolt::tick() life = 1; seed = random->nextLong(); - if (!level->isClientSide && level->getGameRules()->getBoolean(GameRules::RULE_DOFIRETICK) && level->hasChunksAt( (int) floor(x), (int) floor(y), (int) floor(z), 10)) + if (!level->isClientSide && level->getGameRules()->getBoolean(GameRules::RULE_DOFIRETICK) && level->hasChunksAt( static_cast(floor(x)), static_cast(floor(y)), static_cast(floor(z)), 10)) { - int xt = (int) floor(x); - int yt = (int) floor(y); - int zt = (int) floor(z); + int xt = static_cast(floor(x)); + int yt = static_cast(floor(y)); + int zt = static_cast(floor(z)); // 4J added - don't go setting tiles if we aren't tracking them for network synchronisation if( MinecraftServer::getInstance()->getPlayers()->isTrackingTile(xt, yt, zt, level->dimension->id) ) diff --git a/Minecraft.World/LiquidTile.cpp b/Minecraft.World/LiquidTile.cpp index c31b64666..2e098928d 100644 --- a/Minecraft.World/LiquidTile.cpp +++ b/Minecraft.World/LiquidTile.cpp @@ -317,7 +317,7 @@ void LiquidTile::animateTick(Level *level, int x, int y, int z, Random *random) { if (random->nextInt(100) == 0) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); double xx = x + random->nextFloat(); double yy = y + tls->yy1; double zz = z + random->nextFloat(); diff --git a/Minecraft.World/ListTag.h b/Minecraft.World/ListTag.h index 69e51aee1..2a0fdebc3 100644 --- a/Minecraft.World/ListTag.h +++ b/Minecraft.World/ListTag.h @@ -18,7 +18,7 @@ template class ListTag : public Tag else type = 1; dos->writeByte(type); - dos->writeInt((int)list.size()); + dos->writeInt(static_cast(list.size())); for ( auto& it : list ) it->write(dos); @@ -83,12 +83,12 @@ template class ListTag : public Tag T *get(int index) { - return (T *) list[index]; + return static_cast(list[index]); } int size() { - return (int)list.size(); + return static_cast(list.size()); } virtual ~ListTag() @@ -105,7 +105,7 @@ template class ListTag : public Tag res->type = type; for ( auto& it : list ) { - T *copy = (T *) it->copy(); + T *copy = static_cast(it->copy()); res->list.push_back(copy); } return res; @@ -115,7 +115,7 @@ template class ListTag : public Tag { if (Tag::equals(obj)) { - ListTag *o = (ListTag *) obj; + ListTag *o = static_cast(obj); if (type == o->type) { bool equal = false; diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index ce702676c..c12f0a989 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -107,10 +107,10 @@ LivingEntity::LivingEntity( Level* level) : Entity(level) blocksBuilding = true; - rotA = (float) (Math::random() + 1) * 0.01f; + rotA = static_cast(Math::random() + 1) * 0.01f; setPos(x, y, z); - timeOffs = (float) Math::random() * 12398; - yRot = (float) (Math::random() * PI * 2); + timeOffs = static_cast(Math::random()) * 12398; + yRot = static_cast(Math::random() * PI * 2); yHeadRot = yRot; footSize = 0.5f; @@ -132,8 +132,8 @@ LivingEntity::~LivingEntity() void LivingEntity::defineSynchedData() { entityData->define(DATA_EFFECT_COLOR_ID, 0); - entityData->define(DATA_EFFECT_AMBIENCE_ID, (byte) 0); - entityData->define(DATA_ARROW_COUNT_ID, (byte) 0); + entityData->define(DATA_EFFECT_AMBIENCE_ID, static_cast(0)); + entityData->define(DATA_ARROW_COUNT_ID, static_cast(0)); entityData->define(DATA_HEALTH_ID, 1.0f); } @@ -391,10 +391,10 @@ int LivingEntity::getNoActionTime() void LivingEntity::addAdditonalSaveData(CompoundTag *entityTag) { entityTag->putFloat(L"HealF", getHealth()); - entityTag->putShort(L"Health", (short) ceil(getHealth())); - entityTag->putShort(L"HurtTime", (short) hurtTime); - entityTag->putShort(L"DeathTime", (short) deathTime); - entityTag->putShort(L"AttackTime", (short) attackTime); + entityTag->putShort(L"Health", static_cast(ceil(getHealth()))); + entityTag->putShort(L"HurtTime", static_cast(hurtTime)); + entityTag->putShort(L"DeathTime", static_cast(deathTime)); + entityTag->putShort(L"AttackTime", static_cast(attackTime)); entityTag->putFloat(L"AbsorptionAmount", getAbsorptionAmount()); ItemInstanceArray items = getEquipmentSlots(); @@ -464,12 +464,12 @@ void LivingEntity::readAdditionalSaveData(CompoundTag *tag) } else if (healthTag->getId() == Tag::TAG_Float) { - setHealth(((FloatTag *) healthTag)->data); + setHealth(static_cast(healthTag)->data); } else if (healthTag->getId() == Tag::TAG_Short) { // pre-1.6 health - setHealth((float) ((ShortTag *) healthTag)->data); + setHealth((float) static_cast(healthTag)->data); } } @@ -512,7 +512,7 @@ void LivingEntity::tickEffects() { if (activeEffects.empty()) { - entityData->set(DATA_EFFECT_AMBIENCE_ID, (byte) 0); + entityData->set(DATA_EFFECT_AMBIENCE_ID, static_cast(0)); entityData->set(DATA_EFFECT_COLOR_ID, 0); setInvisible(false); setWeakened(false); @@ -525,7 +525,7 @@ void LivingEntity::tickEffects() values.push_back(it.second); } int colorValue = PotionBrewing::getColorValue(&values); - entityData->set(DATA_EFFECT_AMBIENCE_ID, PotionBrewing::areAllEffectsAmbient(&values) ? (byte) 1 : (byte) 0); + entityData->set(DATA_EFFECT_AMBIENCE_ID, PotionBrewing::areAllEffectsAmbient(&values) ? static_cast(1) : static_cast(0)); values.clear(); entityData->set(DATA_EFFECT_COLOR_ID, colorValue); setInvisible(hasEffect(MobEffect::invisibility->id)); @@ -558,9 +558,9 @@ void LivingEntity::tickEffects() // int colorValue = entityData.getInteger(DATA_EFFECT_COLOR_ID); if (colorValue > 0) { - double red = (double) ((colorValue >> 16) & 0xff) / 255.0; - double green = (double) ((colorValue >> 8) & 0xff) / 255.0; - double blue = (double) ((colorValue >> 0) & 0xff) / 255.0; + double red = static_cast((colorValue >> 16) & 0xff) / 255.0; + double green = static_cast((colorValue >> 8) & 0xff) / 255.0; + double blue = static_cast((colorValue >> 0) & 0xff) / 255.0; level->addParticle(ambient? eParticleType_mobSpellAmbient : eParticleType_mobSpell, x + (random->nextDouble() - 0.5) * bbWidth, y + random->nextDouble() * bbHeight - heightOffset, z + (random->nextDouble() - 0.5) * bbWidth, red, green, blue); } @@ -775,7 +775,7 @@ bool LivingEntity::hurt(DamageSource *source, float dmg) if ((source == DamageSource::anvil || source == DamageSource::fallingBlock) && getCarried(SLOT_HELM) != NULL) { - getCarried(SLOT_HELM)->hurtAndBreak((int) (dmg * 4 + random->nextFloat() * dmg * 2.0f), dynamic_pointer_cast( shared_from_this() )); + getCarried(SLOT_HELM)->hurtAndBreak(static_cast(dmg * 4 + random->nextFloat() * dmg * 2.0f), dynamic_pointer_cast( shared_from_this() )); dmg *= 0.75f; } @@ -842,12 +842,12 @@ bool LivingEntity::hurt(DamageSource *source, float dmg) xd = (Math::random() - Math::random()) * 0.01; zd = (Math::random() - Math::random()) * 0.01; } - hurtDir = (float) (atan2(zd, xd) * 180 / PI) - yRot; + hurtDir = static_cast(atan2(zd, xd) * 180 / PI) - yRot; knockback(sourceEntity, dmg, xd, zd); } else { - hurtDir = (float) (int) ((Math::random() * 2) * 180); // 4J This cast is the same as Java + hurtDir = static_cast((int)((Math::random() * 2) * 180)); // 4J This cast is the same as Java } } @@ -1007,7 +1007,7 @@ void LivingEntity::causeFallDamage(float distance) MobEffectInstance *jumpBoost = getEffect(MobEffect::jump); float padding = jumpBoost != NULL ? jumpBoost->getAmplifier() + 1 : 0; - int dmg = (int) ceil(distance - 3 - padding); + int dmg = static_cast(ceil(distance - 3 - padding)); if (dmg > 0) { // 4J - new sounds here brought forward from 1.2.3 @@ -1052,7 +1052,7 @@ int LivingEntity::getArmorValue() shared_ptr item = items[i]; if (item != NULL && dynamic_cast(item->getItem()) != NULL) { - int baseProtection = ((ArmorItem *) item->getItem())->defense; + int baseProtection = static_cast(item->getItem())->defense; val += baseProtection; } } @@ -1139,7 +1139,7 @@ shared_ptr LivingEntity::getKillCredit() float LivingEntity::getMaxHealth() { - return (float) getAttribute(SharedMonsterAttributes::MAX_HEALTH)->getValue(); + return static_cast(getAttribute(SharedMonsterAttributes::MAX_HEALTH)->getValue()); } int LivingEntity::getArrowCount() @@ -1149,7 +1149,7 @@ int LivingEntity::getArrowCount() void LivingEntity::setArrowCount(int count) { - entityData->set(DATA_ARROW_COUNT_ID, (byte) count); + entityData->set(DATA_ARROW_COUNT_ID, static_cast(count)); } int LivingEntity::getCurrentSwingDuration() @@ -1174,7 +1174,7 @@ void LivingEntity::swing() if (dynamic_cast(level) != NULL) { - ((ServerLevel *) level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::SWING))); + static_cast(level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::SWING))); } } } @@ -1240,7 +1240,7 @@ void LivingEntity::updateSwingTime() swingTime = 0; } - attackAnim = swingTime / (float) currentSwingDuration; + attackAnim = swingTime / static_cast(currentSwingDuration); } AttributeInstance *LivingEntity::getAttribute(Attribute *attribute) @@ -1474,7 +1474,7 @@ void LivingEntity::travel(float xa, float ya) yd = 0.2; } - if (!level->isClientSide || (level->hasChunkAt((int) x, 0, (int) z) && level->getChunkAt((int) x, (int) z)->loaded)) + if (!level->isClientSide || (level->hasChunkAt(static_cast(x), 0, static_cast(z)) && level->getChunkAt(static_cast(x), static_cast(z))->loaded)) { yd -= 0.08; } @@ -1517,12 +1517,12 @@ int LivingEntity::getLightColor(float a) for( int yt = ymin; yt <= ymax; yt++ ) for( int zt = zmin; zt <= zmax; zt++ ) { - float tilexmin = (float)xt; - float tilexmax = (float)(xt+1); - float tileymin = (float)yt; - float tileymax = (float)(yt+1); - float tilezmin = (float)zt; - float tilezmax = (float)(zt+1); + float tilexmin = static_cast(xt); + float tilexmax = static_cast(xt + 1); + float tileymin = static_cast(yt); + float tileymax = static_cast(yt + 1); + float tilezmin = static_cast(zt); + float tilezmax = static_cast(zt + 1); if( tilexmin < bb->x0 ) tilexmin = bb->x0; if( tilexmax > bb->x1 ) tilexmax = bb->x1; if( tileymin < bb->y0 ) tileymin = bb->y0; @@ -1532,14 +1532,14 @@ int LivingEntity::getLightColor(float a) float tileVol = ( tilexmax - tilexmin ) * ( tileymax - tileymin ) * ( tilezmax - tilezmin ); float frac = tileVol / totVol; int lc = level->getLightColor(xt, yt, zt, 0); - accum[0] += frac * (float)( lc & 0xffff ); - accum[1] += frac * (float)( lc >> 16 ); + accum[0] += frac * static_cast(lc & 0xffff); + accum[1] += frac * static_cast(lc >> 16); } if( accum[0] > 240.0f ) accum[0] = 240.0f; if( accum[1] > 240.0f ) accum[1] = 240.0f; - return ( ( (int)accum[1])<<16) | ((int)accum[0]); + return ( static_cast(accum[1])<<16) | static_cast(accum[0]); } bool LivingEntity::useNewAi() @@ -1602,7 +1602,7 @@ void LivingEntity::tick() if (!ItemInstance::matches(current, previous)) { - ((ServerLevel *) level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new SetEquippedItemPacket(entityId, i, current))); + static_cast(level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new SetEquippedItemPacket(entityId, i, current))); if (previous != NULL) attributes->removeItemModifiers(previous); if (current != NULL) attributes->addItemModifiers(current); lastEquipment[i] = current == NULL ? nullptr : current->copy(); @@ -1626,7 +1626,7 @@ void LivingEntity::tick() { tRun = 1; walkSpeed = sqrt(sideDist) * 3; - yBodyRotT = ((float) atan2(zd, xd) * 180 / (float) PI - 90); + yBodyRotT = (static_cast(atan2(zd, xd)) * 180 / (float) PI - 90); } if (attackAnim > 0) { @@ -1698,8 +1698,8 @@ void LivingEntity::aiStep() double yrd = Mth::wrapDegrees(lyr - yRot); double xrd = Mth::wrapDegrees(lxr - xRot); - yRot += (float) ( (yrd) / lSteps ); - xRot += (float) ( (xrd) / lSteps ); + yRot += static_cast((yrd) / lSteps); + xRot += static_cast((xrd) / lSteps); lSteps--; setPos(xt, yt, zt); @@ -1857,7 +1857,7 @@ void LivingEntity::take(shared_ptr e, int orgCount) { if (!e->removed && !level->isClientSide) { - EntityTracker *entityTracker = ((ServerLevel *) level)->getTracker(); + EntityTracker *entityTracker = static_cast(level)->getTracker(); if ( e->instanceof(eTYPE_ITEMENTITY) ) { entityTracker->broadcast(e, shared_ptr( new TakeItemEntityPacket(e->entityId, entityId))); diff --git a/Minecraft.World/LoginPacket.cpp b/Minecraft.World/LoginPacket.cpp index bfe692264..97f25a677 100644 --- a/Minecraft.World/LoginPacket.cpp +++ b/Minecraft.World/LoginPacket.cpp @@ -176,8 +176,8 @@ int LoginPacket::getEstimatedSize() int length=0; if (m_pLevelType != NULL) { - length = (int)m_pLevelType->getGeneratorName().length(); + length = static_cast(m_pLevelType->getGeneratorName().length()); } - return (int)(sizeof(int) + userName.length() + 4 + 6 + sizeof(__int64) + sizeof(char) + sizeof(int) + (2*sizeof(PlayerUID)) +1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int)); + return static_cast(sizeof(int) + userName.length() + 4 + 6 + sizeof(__int64) + sizeof(char) + sizeof(int) + (2 * sizeof(PlayerUID)) + 1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int)); } diff --git a/Minecraft.World/LongTag.h b/Minecraft.World/LongTag.h index 8cfae41d2..8828521ec 100644 --- a/Minecraft.World/LongTag.h +++ b/Minecraft.World/LongTag.h @@ -28,7 +28,7 @@ class LongTag : public Tag { if (Tag::equals(obj)) { - LongTag *o = (LongTag *) obj; + LongTag *o = static_cast(obj); return data == o->data; } return false; diff --git a/Minecraft.World/LookAtTradingPlayerGoal.cpp b/Minecraft.World/LookAtTradingPlayerGoal.cpp index db1e25a2e..9b50f0e70 100644 --- a/Minecraft.World/LookAtTradingPlayerGoal.cpp +++ b/Minecraft.World/LookAtTradingPlayerGoal.cpp @@ -3,7 +3,7 @@ #include "net.minecraft.world.entity.npc.h" #include "LookAtTradingPlayerGoal.h" -LookAtTradingPlayerGoal::LookAtTradingPlayerGoal(Villager *villager) : LookAtPlayerGoal((Mob *)villager, typeid(Player), 8) +LookAtTradingPlayerGoal::LookAtTradingPlayerGoal(Villager *villager) : LookAtPlayerGoal(static_cast(villager), typeid(Player), 8) { this->villager = villager; } diff --git a/Minecraft.World/LookControl.cpp b/Minecraft.World/LookControl.cpp index 1e0d52584..8eff9bcac 100644 --- a/Minecraft.World/LookControl.cpp +++ b/Minecraft.World/LookControl.cpp @@ -47,8 +47,8 @@ void LookControl::tick() double zd = wantedZ - mob->z; double sd = sqrt(xd * xd + zd * zd); - float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90; - float xRotD = (float) -(atan2(yd, sd) * 180 / PI); + float yRotD = static_cast(atan2(zd, xd) * 180 / PI) - 90; + float xRotD = static_cast(-(atan2(yd, sd) * 180 / PI)); mob->xRot = rotlerp(mob->xRot, xRotD, xMax); mob->yHeadRot = rotlerp(mob->yHeadRot, yRotD, yMax); } diff --git a/Minecraft.World/MakeLoveGoal.cpp b/Minecraft.World/MakeLoveGoal.cpp index c399d632b..d64ee9b13 100644 --- a/Minecraft.World/MakeLoveGoal.cpp +++ b/Minecraft.World/MakeLoveGoal.cpp @@ -83,7 +83,7 @@ bool MakeLoveGoal::villageNeedsMoreVillagers() return false; } - int idealSize = (int) ((float) _village->getDoorCount() * 0.35); + int idealSize = static_cast((float)_village->getDoorCount() * 0.35); // System.out.println("idealSize: " + idealSize + " pop: " + // village.getPopulationSize()); return _village->getPopulationSize() < idealSize; diff --git a/Minecraft.World/MapItem.cpp b/Minecraft.World/MapItem.cpp index 03529c1ad..c02a8716e 100644 --- a/Minecraft.World/MapItem.cpp +++ b/Minecraft.World/MapItem.cpp @@ -71,10 +71,10 @@ shared_ptr MapItem::getSavedData(shared_ptr item { #ifdef _LARGE_WORLDS int scale = MapItemSavedData::MAP_SIZE * 2 * (1 << mapItemSavedData->scale); - mapItemSavedData->x = Math::round((float) level->getLevelData()->getXSpawn() / scale) * scale; + mapItemSavedData->x = Math::round(static_cast(level->getLevelData()->getXSpawn()) / scale) * scale; mapItemSavedData->z = Math::round(level->getLevelData()->getZSpawn() / scale) * scale; #endif - mapItemSavedData->dimension = (byte) level->dimension->id; + mapItemSavedData->dimension = static_cast(level->dimension->id); mapItemSavedData->setDirty(); @@ -190,7 +190,7 @@ void MapItem::update(Level *level, shared_ptr player, shared_ptr 0 && below != 0 && Tile::tiles[below]->material->isLiquid()); } } - hh += yy / (double) (scale * scale); + hh += yy / static_cast(scale * scale); count[t]++; } @@ -237,7 +237,7 @@ void MapItem::update(Level *level, shared_ptr player, shared_ptrcolors[x + z * w]; - byte newColor = (byte) (col * 4 + br); + byte newColor = static_cast(col * 4 + br); if (oldColor != newColor) { if (yd0 > z) yd0 = z; @@ -297,7 +297,7 @@ shared_ptr MapItem::getUpdatePacket(shared_ptr itemInstanc if (data.data == NULL || data.length == 0) return nullptr; - shared_ptr retval = shared_ptr(new ComplexItemDataPacket((short) Item::map->id, (short) itemInstance->getAuxValue(), data)); + shared_ptr retval = shared_ptr(new ComplexItemDataPacket(static_cast(Item::map->id), static_cast(itemInstance->getAuxValue()), data)); delete data.data; return retval; } @@ -309,8 +309,8 @@ void MapItem::onCraftedBy(shared_ptr itemInstance, Level *level, s int mapScale = 3; #ifdef _LARGE_WORLDS int scale = MapItemSavedData::MAP_SIZE * 2 * (1 << mapScale); - int centreXC = (int) (Math::round(player->x / scale) * scale); - int centreZC = (int) (Math::round(player->z / scale) * scale); + int centreXC = static_cast(Math::round(player->x / scale) * scale); + int centreZC = static_cast(Math::round(player->z / scale) * scale); #else // 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map int centreXC = 0; @@ -335,7 +335,7 @@ void MapItem::onCraftedBy(shared_ptr itemInstance, Level *level, s // 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map data->x = centreXC; data->z = centreZC; - data->dimension = (byte) level->dimension->id; + data->dimension = static_cast(level->dimension->id); data->setDirty(); } diff --git a/Minecraft.World/MapItemSavedData.cpp b/Minecraft.World/MapItemSavedData.cpp index c06c3facd..7bbc9f0b6 100644 --- a/Minecraft.World/MapItemSavedData.cpp +++ b/Minecraft.World/MapItemSavedData.cpp @@ -65,8 +65,8 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptrdecorations.size(); - unsigned int nonPlayerDecorationsSize = (int)parent->nonPlayerDecorations.size(); + unsigned int playerDecorationsSize = static_cast(parent->decorations.size()); + unsigned int nonPlayerDecorationsSize = static_cast(parent->nonPlayerDecorations.size()); charArray data = charArray( (playerDecorationsSize + nonPlayerDecorationsSize ) * DEC_PACKET_BYTES + 1); data[0] = 1; for (unsigned int i = 0; i < parent->decorations.size(); i++) @@ -74,7 +74,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptrdecorations.at(i); #ifdef _LARGE_WORLDS data[i * DEC_PACKET_BYTES + 1] = (char) (md->img); - data[i * DEC_PACKET_BYTES + 8] = (char) (md->rot & 0xF); + data[i * DEC_PACKET_BYTES + 8] = static_cast(md->rot & 0xF); #else data[i * DEC_PACKET_BYTES + 1] = (char) ((md->img << 4) | (md->rot & 0xF)); #endif @@ -92,7 +92,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptrimg); - data[dataIndex * DEC_PACKET_BYTES + 8] = (char) (md->rot & 0xF); + data[dataIndex * DEC_PACKET_BYTES + 8] = static_cast(md->rot & 0xF); #else data[dataIndex * DEC_PACKET_BYTES + 1] = (char) ((md->img << 4) | (md->rot & 0xF)); #endif @@ -148,8 +148,8 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr(column); + data[2] = static_cast(min); for (unsigned int y = 0; y < data.length - 3; y++) { data[y + 3] = parent->colors[(y + min) * MapItem::IMAGE_WIDTH + column]; @@ -303,17 +303,17 @@ void MapItemSavedData::tickCarriedBy(shared_ptr player, shared_ptr(xd * 2 + 0.5); + char y = static_cast(yd * 2 + 0.5); int size = MAP_SIZE - 1; #ifdef _LARGE_WORLDS if (xd < -size || yd < -size || xd > size || yd > size) { - if (xd <= -size) x = (byte) (size * 2 + 2.5); - if (yd <= -size) y = (byte) (size * 2 + 2.5); - if (xd >= size) x = (byte) (size * 2 + 1); - if (yd >= size) y = (byte) (size * 2 + 1); + if (xd <= -size) x = static_cast(size * 2 + 2.5); + if (yd <= -size) y = static_cast(size * 2 + 2.5); + if (xd >= size) x = static_cast(size * 2 + 1); + if (yd >= size) y = static_cast(size * 2 + 1); } #endif //decorations.push_back(new MapDecoration(4, x, y, 0)); @@ -332,25 +332,25 @@ void MapItemSavedData::tickCarriedBy(shared_ptr player, shared_ptrgetFrame()->entityId ) == nonPlayerDecorations.end() ) { - float xd = (float) ( item->getFrame()->xTile - x ) / (1 << scale); - float yd = (float) ( item->getFrame()->zTile - z ) / (1 << scale); - char x = (char) (xd * 2 + 0.5); - char y = (char) (yd * 2 + 0.5); + float xd = static_cast(item->getFrame()->xTile - x) / (1 << scale); + float yd = static_cast(item->getFrame()->zTile - z) / (1 << scale); + char x = static_cast(xd * 2 + 0.5); + char y = static_cast(yd * 2 + 0.5); int size = MAP_SIZE - 1; - char rot = (char) ( (item->getFrame()->dir * 90) * 16 / 360); + char rot = static_cast((item->getFrame()->dir * 90) * 16 / 360); if (dimension < 0) { - int s = (int) (playerLevel->getLevelData()->getDayTime() / 10); - rot = (char) ((s * s * 34187121 + s * 121) >> 15 & 15); + int s = static_cast(playerLevel->getLevelData()->getDayTime() / 10); + rot = static_cast((s * s * 34187121 + s * 121) >> 15 & 15); } #ifdef _LARGE_WORLDS if (xd < -size || yd < -size || xd > size || yd > size) { - if (xd <= -size) x = (byte) (size * 2 + 2.5); - if (yd <= -size) y = (byte) (size * 2 + 2.5); - if (xd >= size) x = (byte) (size * 2 + 1); - if (yd >= size) y = (byte) (size * 2 + 1); + if (xd <= -size) x = static_cast(size * 2 + 2.5); + if (yd <= -size) y = static_cast(size * 2 + 2.5); + if (xd >= size) x = static_cast(size * 2 + 1); + if (yd >= size) y = static_cast(size * 2 + 1); } #endif //decorations.push_back(new MapDecoration(7, x, y, 0)); @@ -401,10 +401,10 @@ void MapItemSavedData::tickCarriedBy(shared_ptr player, shared_ptrdimension == this->dimension) { - float xd = (float) (decorationPlayer->x - x) / (1 << scale); - float yd = (float) (decorationPlayer->z - z) / (1 << scale); - char x = (char) (xd * 2); - char y = (char) (yd * 2); + float xd = static_cast(decorationPlayer->x - x) / (1 << scale); + float yd = static_cast(decorationPlayer->z - z) / (1 << scale); + char x = static_cast(xd * 2); + char y = static_cast(yd * 2); int size = MAP_SIZE; // - 1; char rot; char imgIndex; @@ -414,16 +414,16 @@ void MapItemSavedData::tickCarriedBy(shared_ptr player, shared_ptryRot * 16 / 360 + 0.5); + rot = static_cast(decorationPlayer->yRot * 16 / 360 + 0.5); if (dimension < 0) { - int s = (int) (playerLevel->getLevelData()->getDayTime() / 10); - rot = (char) ((s * s * 34187121 + s * 121) >> 15 & 15); + int s = static_cast(playerLevel->getLevelData()->getDayTime() / 10); + rot = static_cast((s * s * 34187121 + s * 121) >> 15 & 15); } // 4J Stu - As we have added new icons for players on a new row below // other icons used in Java we need to move our index to the next row - imgIndex = (int)decorationPlayer->getPlayerIndex(); + imgIndex = static_cast(decorationPlayer->getPlayerIndex()); if(imgIndex>3) imgIndex += 4; } #ifdef _LARGE_WORLDS @@ -431,16 +431,16 @@ void MapItemSavedData::tickCarriedBy(shared_ptr player, shared_ptrgetPlayerIndex(); + imgIndex = static_cast(decorationPlayer->getPlayerIndex()); if(imgIndex>3) imgIndex += 4; imgIndex += 16; // Add 16 to indicate that it's on the next texture rot = 0; size--; // Added to match the old adjusted size - if (xd <= -size) x = (byte) (size * 2 + 2.5); - if (yd <= -size) y = (byte) (size * 2 + 2.5); - if (xd >= size) x = (byte) (size * 2 + 1); - if (yd >= size) y = (byte) (size * 2 + 1); + if (xd <= -size) x = static_cast(size * 2 + 2.5); + if (yd <= -size) y = static_cast(size * 2 + 2.5); + if (xd >= size) x = static_cast(size * 2 + 1); + if (yd >= size) y = static_cast(size * 2 + 1); } #endif @@ -527,7 +527,7 @@ void MapItemSavedData::handleComplexItemData(charArray &data) #endif char x = data[i * DEC_PACKET_BYTES + 2]; char y = data[i * DEC_PACKET_BYTES + 3]; - int entityId = (((int)data[i * DEC_PACKET_BYTES + 4])&0xFF) | ( (((int)data[i * DEC_PACKET_BYTES + 5])&0xFF)<<8) | ((((int)data[i * DEC_PACKET_BYTES + 6])&0xFF)<<16) | ((((int)data[i * DEC_PACKET_BYTES + 7])&0x7F)<<24); + int entityId = (static_cast(data[i * DEC_PACKET_BYTES + 4])&0xFF) | ( (static_cast(data[i * DEC_PACKET_BYTES + 5])&0xFF)<<8) | ((static_cast(data[i * DEC_PACKET_BYTES + 6])&0xFF)<<16) | ((static_cast(data[i * DEC_PACKET_BYTES + 7])&0x7F)<<24); bool visible = (data[i * DEC_PACKET_BYTES + 7] & 0x80) != 0; decorations.push_back(new MapDecoration(img, x, y, rot, entityId, visible)); } diff --git a/Minecraft.World/McRegionLevelStorageSource.cpp b/Minecraft.World/McRegionLevelStorageSource.cpp index 60904fdeb..d0aef97a4 100644 --- a/Minecraft.World/McRegionLevelStorageSource.cpp +++ b/Minecraft.World/McRegionLevelStorageSource.cpp @@ -275,7 +275,7 @@ void McRegionLevelStorageSource::eraseFolders(vector *folders, int curre folder->_delete(); currentCount++; - int percent = (int) Math::round(100.0 * (double) currentCount / (double) totalCount); + int percent = static_cast(Math::round(100.0 * (double)currentCount / (double)totalCount)); progress->progressStagePercentage(percent); } } diff --git a/Minecraft.World/MegaTreeFeature.cpp b/Minecraft.World/MegaTreeFeature.cpp index 09195fb4b..0d01130f6 100644 --- a/Minecraft.World/MegaTreeFeature.cpp +++ b/Minecraft.World/MegaTreeFeature.cpp @@ -69,14 +69,14 @@ bool MegaTreeFeature::place(Level *level, Random *random, int x, int y, int z) while (branchHeight > y + treeHeight / 2) { float angle = random->nextFloat() * PI * 2.0f; - int bx = x + (int) (0.5f + Mth::cos(angle) * 4.0f); - int bz = z + (int) (0.5f + Mth::sin(angle) * 4.0f); + int bx = x + static_cast(0.5f + Mth::cos(angle) * 4.0f); + int bz = z + static_cast(0.5f + Mth::sin(angle) * 4.0f); placeLeaves(level, bx, bz, branchHeight, 0, random); for (int b = 0; b < 5; b++) { - bx = x + (int) (1.5f + Mth::cos(angle) * b); - bz = z + (int) (1.5f + Mth::sin(angle) * b); + bx = x + static_cast(1.5f + Mth::cos(angle) * b); + bz = z + static_cast(1.5f + Mth::sin(angle) * b); placeBlock(level, bx, branchHeight - 3 + b / 2, bz, Tile::treeTrunk_Id, trunkType); } diff --git a/Minecraft.World/MenuBackup.cpp b/Minecraft.World/MenuBackup.cpp index b6d3ba09a..c811e068a 100644 --- a/Minecraft.World/MenuBackup.cpp +++ b/Minecraft.World/MenuBackup.cpp @@ -15,7 +15,7 @@ MenuBackup::MenuBackup(shared_ptr inventory, AbstractContainerMenu *m void MenuBackup::save(short changeUid) { - ItemInstanceArray *backup = new ItemInstanceArray( (int)menu->slots.size() + 1 ); + ItemInstanceArray *backup = new ItemInstanceArray( static_cast(menu->slots.size()) + 1 ); (*backup)[0] = ItemInstance::clone(inventory->getCarried()); for (unsigned int i = 0; i < menu->slots.size(); i++) { diff --git a/Minecraft.World/MerchantRecipeList.cpp b/Minecraft.World/MerchantRecipeList.cpp index c994081f2..d8f37c7f2 100644 --- a/Minecraft.World/MerchantRecipeList.cpp +++ b/Minecraft.World/MerchantRecipeList.cpp @@ -85,7 +85,7 @@ MerchantRecipe *MerchantRecipeList::getMatchingRecipeFor(shared_ptrwriteByte((byte) (m_recipes.size() & 0xff)); + stream->writeByte(static_cast(m_recipes.size() & 0xff)); for (int i = 0; i < m_recipes.size(); i++) { MerchantRecipe *r = m_recipes.at(i); diff --git a/Minecraft.World/MilkBucketItem.h b/Minecraft.World/MilkBucketItem.h index 672e31439..f2cff3eaa 100644 --- a/Minecraft.World/MilkBucketItem.h +++ b/Minecraft.World/MilkBucketItem.h @@ -5,7 +5,7 @@ class MilkBucketItem : public Item { private: - static const int DRINK_DURATION = (int) (20 * 1.6); + static const int DRINK_DURATION = static_cast(20 * 1.6); public: MilkBucketItem(int id); diff --git a/Minecraft.World/Minecart.cpp b/Minecraft.World/Minecart.cpp index 4e1419cc4..43caf0a23 100644 --- a/Minecraft.World/Minecart.cpp +++ b/Minecraft.World/Minecart.cpp @@ -95,7 +95,7 @@ void Minecart::defineSynchedData() entityData->define(DATA_ID_DAMAGE, 0.0f); entityData->define(DATA_ID_DISPLAY_TILE, 0); entityData->define(DATA_ID_DISPLAY_OFFSET, 6); - entityData->define(DATA_ID_CUSTOM_DISPLAY, (byte) 0); + entityData->define(DATA_ID_CUSTOM_DISPLAY, static_cast(0)); } @@ -225,7 +225,7 @@ void Minecart::tick() if (!level->isClientSide && dynamic_cast(level) != NULL) { - MinecraftServer *server = ((ServerLevel *) level)->getServer(); + MinecraftServer *server = static_cast(level)->getServer(); int waitTime = getPortalWaitTime(); if (isInsidePortal) @@ -275,8 +275,8 @@ void Minecart::tick() double yrd = Mth::wrapDegrees(lyr - yRot); - yRot += (float) ( (yrd) / lSteps ); - xRot += (float) ( (lxr - xRot) / lSteps ); + yRot += static_cast((yrd) / lSteps); + xRot += static_cast((lxr - xRot) / lSteps); lSteps--; setPos(xt, yt, zt); @@ -330,7 +330,7 @@ void Minecart::tick() double zDiff = zo - z; if (xDiff * xDiff + zDiff * zDiff > 0.001) { - yRot = (float) (atan2(zDiff, xDiff) * 180 / PI); + yRot = static_cast(atan2(zDiff, xDiff) * 180 / PI); if (flipped) yRot += 180; } @@ -415,7 +415,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl powerTrack = (data & BaseRailTile::RAIL_DATA_BIT) != 0; haltTrack = !powerTrack; } - if (((BaseRailTile *) Tile::tiles[tile])->isUsesDataBit()) + if (static_cast(Tile::tiles[tile])->isUsesDataBit()) { data &= BaseRailTile::RAIL_DIRECTION_MASK; } @@ -648,7 +648,7 @@ Vec3 *Minecart::getPosOffs(double x, double y, double z, double offs) { int data = level->getData(xt, yt, zt); - if (((BaseRailTile *) Tile::tiles[tile])->isUsesDataBit()) + if (static_cast(Tile::tiles[tile])->isUsesDataBit()) { data &= BaseRailTile::RAIL_DIRECTION_MASK; } @@ -703,7 +703,7 @@ Vec3 *Minecart::getPos(double x, double y, double z) int data = level->getData(xt, yt, zt); y = yt; - if (((BaseRailTile *) Tile::tiles[tile])->isUsesDataBit()) + if (static_cast(Tile::tiles[tile])->isUsesDataBit()) { data &= BaseRailTile::RAIL_DIRECTION_MASK; } @@ -1015,7 +1015,7 @@ bool Minecart::hasCustomDisplay() void Minecart::setCustomDisplay(bool value) { - getEntityData()->set(DATA_ID_CUSTOM_DISPLAY, (byte) (value ? 1 : 0)); + getEntityData()->set(DATA_ID_CUSTOM_DISPLAY, static_cast(value ? 1 : 0)); } void Minecart::setCustomName(const wstring &name) diff --git a/Minecraft.World/MinecartContainer.cpp b/Minecraft.World/MinecartContainer.cpp index 20bfc4ea8..54883281c 100644 --- a/Minecraft.World/MinecartContainer.cpp +++ b/Minecraft.World/MinecartContainer.cpp @@ -47,9 +47,9 @@ void MinecartContainer::destroy(DamageSource *source) shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()))) ); float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; + itemEntity->xd = static_cast(random->nextGaussian()) * pow; + itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random->nextGaussian()) * pow; level->addEntity(itemEntity); } } @@ -161,13 +161,13 @@ void MinecartContainer::remove() if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + itemEntity->getItem()->setTag(static_cast(item->getTag()->copy())); } float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; + itemEntity->xd = static_cast(random->nextGaussian()) * pow; + itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random->nextGaussian()) * pow; level->addEntity(itemEntity); } } @@ -188,7 +188,7 @@ void MinecartContainer::addAdditonalSaveData(CompoundTag *base) if (items[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); items[i]->save(tag); listTag->add(tag); } diff --git a/Minecraft.World/MinecartFurnace.cpp b/Minecraft.World/MinecartFurnace.cpp index 24950d5c1..838d8a272 100644 --- a/Minecraft.World/MinecartFurnace.cpp +++ b/Minecraft.World/MinecartFurnace.cpp @@ -37,7 +37,7 @@ int MinecartFurnace::getType() void MinecartFurnace::defineSynchedData() { Minecart::defineSynchedData(); - entityData->define(DATA_ID_FUEL, (byte) 0); + entityData->define(DATA_ID_FUEL, static_cast(0)); } void MinecartFurnace::tick() @@ -140,7 +140,7 @@ void MinecartFurnace::addAdditonalSaveData(CompoundTag *base) Minecart::addAdditonalSaveData(base); base->putDouble(L"PushX", xPush); base->putDouble(L"PushZ", zPush); - base->putShort(L"Fuel", (short) fuel); + base->putShort(L"Fuel", static_cast(fuel)); } void MinecartFurnace::readAdditionalSaveData(CompoundTag *base) @@ -160,11 +160,11 @@ void MinecartFurnace::setHasFuel(bool fuel) { if (fuel) { - entityData->set(DATA_ID_FUEL, (byte) (entityData->getByte(DATA_ID_FUEL) | 1)); + entityData->set(DATA_ID_FUEL, static_cast(entityData->getByte(DATA_ID_FUEL) | 1)); } else { - entityData->set(DATA_ID_FUEL, (byte) (entityData->getByte(DATA_ID_FUEL) & ~1)); + entityData->set(DATA_ID_FUEL, static_cast(entityData->getByte(DATA_ID_FUEL) & ~1)); } } diff --git a/Minecraft.World/MinecartItem.cpp b/Minecraft.World/MinecartItem.cpp index 6100be65a..3ffe561ab 100644 --- a/Minecraft.World/MinecartItem.cpp +++ b/Minecraft.World/MinecartItem.cpp @@ -47,7 +47,7 @@ shared_ptr MinecartItem::MinecartDispenseBehavior::execute(BlockSo outcome = ACTIVATED_ITEM; - shared_ptr minecart = Minecart::createMinecart(world, spawnX, spawnY + yOffset, spawnZ, ((MinecartItem *) dispensed->getItem())->type); + shared_ptr minecart = Minecart::createMinecart(world, spawnX, spawnY + yOffset, spawnZ, static_cast(dispensed->getItem())->type); if (dispensed->hasCustomHoverName()) { minecart->setCustomName(dispensed->getHoverName()); diff --git a/Minecraft.World/MinecartSpawner.cpp b/Minecraft.World/MinecartSpawner.cpp index 3fcd4ef08..8dd54d015 100644 --- a/Minecraft.World/MinecartSpawner.cpp +++ b/Minecraft.World/MinecartSpawner.cpp @@ -10,7 +10,7 @@ MinecartSpawner::MinecartMobSpawner::MinecartMobSpawner(MinecartSpawner *parent) void MinecartSpawner::MinecartMobSpawner::broadcastEvent(int id) { - m_parent->level->broadcastEntityEvent(m_parent->shared_from_this(), (byte) id); + m_parent->level->broadcastEntityEvent(m_parent->shared_from_this(), static_cast(id)); } Level *MinecartSpawner::MinecartMobSpawner::getLevel() diff --git a/Minecraft.World/MinecartTNT.cpp b/Minecraft.World/MinecartTNT.cpp index 26cac5cf5..11a664843 100644 --- a/Minecraft.World/MinecartTNT.cpp +++ b/Minecraft.World/MinecartTNT.cpp @@ -81,7 +81,7 @@ void MinecartTNT::explode(double speedSqr) { double speed = sqrt(speedSqr); if (speed > 5) speed = 5; - level->explode(shared_from_this(), x, y, z, (float) (4 + random->nextDouble() * 1.5f * speed), true); + level->explode(shared_from_this(), x, y, z, static_cast(4 + random->nextDouble() * 1.5f * speed), true); remove(); } } diff --git a/Minecraft.World/Mob.cpp b/Minecraft.World/Mob.cpp index 342400b49..2d363c0b0 100644 --- a/Minecraft.World/Mob.cpp +++ b/Minecraft.World/Mob.cpp @@ -155,7 +155,7 @@ void Mob::ate() void Mob::defineSynchedData() { LivingEntity::defineSynchedData(); - entityData->define(DATA_CUSTOM_NAME_VISIBLE, (byte) 0); + entityData->define(DATA_CUSTOM_NAME_VISIBLE, static_cast(0)); entityData->define(DATA_CUSTOM_NAME, L""); } @@ -347,7 +347,7 @@ void Mob::readAdditionalSaveData(CompoundTag *tag) _isLeashed = tag->getBoolean(L"Leashed"); if (_isLeashed && tag->contains(L"Leash")) { - leashInfoTag = (CompoundTag *)tag->getCompound(L"Leash")->copy(); + leashInfoTag = static_cast(tag->getCompound(L"Leash")->copy()); } } @@ -560,7 +560,7 @@ void Mob::serverAiStep() if (lookingAt != NULL) { - lookAt(lookingAt, 10.0f, (float) getMaxHeadXRot()); + lookAt(lookingAt, 10.0f, static_cast(getMaxHeadXRot())); if (lookTime-- <= 0 || lookingAt->removed || lookingAt->distanceToSqr(shared_from_this()) > lookDistance * lookDistance) { lookingAt = nullptr; @@ -605,8 +605,8 @@ void Mob::lookAt(shared_ptr e, float yMax, float xMax) double sd = Mth::sqrt(xd * xd + zd * zd); - float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90; - float xRotD = (float) -(atan2(yd, sd) * 180 / PI); + float yRotD = static_cast(atan2(zd, xd) * 180 / PI) - 90; + float xRotD = static_cast(-(atan2(yd, sd) * 180 / PI)); xRot = rotlerp(xRot, xRotD, xMax); yRot = rotlerp(yRot, yRotD, yMax); } @@ -659,7 +659,7 @@ int Mob::getMaxSpawnClusterSize() int Mob::getMaxFallDistance() { if (getTarget() == NULL) return 3; - int sacrifice = (int) (getHealth() - (getMaxHealth() * 0.33f)); + int sacrifice = static_cast(getHealth() - (getMaxHealth() * 0.33f)); sacrifice -= (3 - level->difficulty) * 4; if (sacrifice < 0) sacrifice = 0; return sacrifice + 3; @@ -799,7 +799,7 @@ void Mob::populateDefaultEquipmentEnchantments() float difficulty = level->getDifficulty(x, y, z); if (getCarriedItem() != NULL && random->nextFloat() < MAX_ENCHANTED_WEAPON_CHANCE * difficulty) { - EnchantmentHelper::enchantItem(random, getCarriedItem(), (int) (5 + difficulty * random->nextInt(18))); + EnchantmentHelper::enchantItem(random, getCarriedItem(), static_cast(5 + difficulty * random->nextInt(18))); } for (int i = 0; i < 4; i++) @@ -807,7 +807,7 @@ void Mob::populateDefaultEquipmentEnchantments() shared_ptr item = getArmor(i); if (item != NULL && random->nextFloat() < MAX_ENCHANTED_ARMOR_CHANCE * difficulty) { - EnchantmentHelper::enchantItem(random, item, (int) (5 + difficulty * random->nextInt(18))); + EnchantmentHelper::enchantItem(random, item, static_cast(5 + difficulty * random->nextInt(18))); } } } @@ -865,7 +865,7 @@ bool Mob::hasCustomName() void Mob::setCustomNameVisible(bool visible) { - entityData->set(DATA_CUSTOM_NAME_VISIBLE, visible ? (byte) 1 : (byte) 0); + entityData->set(DATA_CUSTOM_NAME_VISIBLE, visible ? static_cast(1) : static_cast(0)); } bool Mob::isCustomNameVisible() diff --git a/Minecraft.World/MobEffect.cpp b/Minecraft.World/MobEffect.cpp index 92f8c9d0a..f9978ca7d 100644 --- a/Minecraft.World/MobEffect.cpp +++ b/Minecraft.World/MobEffect.cpp @@ -173,12 +173,12 @@ void MobEffect::applyInstantenousEffect(shared_ptr source, shared_ { if ((id == heal->id && !mob->isInvertedHealAndHarm()) || (id == harm->id && mob->isInvertedHealAndHarm())) { - int amount = (int) (scale * (double) (4 << amplification) + .5); + int amount = static_cast(scale * (double)(4 << amplification) + .5); mob->heal(amount); } else if ((id == harm->id && !mob->isInvertedHealAndHarm()) || (id == heal->id && mob->isInvertedHealAndHarm())) { - int amount = (int) (scale * (double) (6 << amplification) + .5); + int amount = static_cast(scale * (double)(6 << amplification) + .5); if (source == NULL) { mob->hurt(DamageSource::magic, amount); diff --git a/Minecraft.World/MobEffectInstance.cpp b/Minecraft.World/MobEffectInstance.cpp index 2ca696f61..117311c37 100644 --- a/Minecraft.World/MobEffectInstance.cpp +++ b/Minecraft.World/MobEffectInstance.cpp @@ -172,8 +172,8 @@ bool MobEffectInstance::equals(MobEffectInstance *instance) CompoundTag *MobEffectInstance::save(CompoundTag *tag) { - tag->putByte(L"Id", (byte) getId()); - tag->putByte(L"Amplifier", (byte) getAmplifier()); + tag->putByte(L"Id", static_cast(getId())); + tag->putByte(L"Amplifier", static_cast(getAmplifier())); tag->putInt(L"Duration", getDuration()); tag->putBoolean(L"Ambient", isAmbient()); return tag; diff --git a/Minecraft.World/MobSpawner.cpp b/Minecraft.World/MobSpawner.cpp index e593a59f6..233cc28ff 100644 --- a/Minecraft.World/MobSpawner.cpp +++ b/Minecraft.World/MobSpawner.cpp @@ -118,7 +118,7 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie // 4J - rewritten to add chunks interleaved by player, and to add them from the centre outwards. We're going to be // potentially adding less creatures than the original so that our count stays consistent with number of players added, so // we want to make sure as best we can that the ones we do add are near the active players - int playerCount = (int)level->players.size(); + int playerCount = static_cast(level->players.size()); int *xx = new int[playerCount]; int *zz = new int[playerCount]; for (int i = 0; i < playerCount; i++) @@ -267,7 +267,7 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie if (isSpawnPositionOk(mobCategory, level, x, y, z)) { float xx = x + 0.5f; - float yy = (float) y; + float yy = static_cast(y); float zz = z + 0.5f; if (level->getNearestPlayer(xx, yy, zz, MIN_SPAWN_DISTANCE) != NULL) { diff --git a/Minecraft.World/Monster.cpp b/Minecraft.World/Monster.cpp index 174a706cb..254a5a6c6 100644 --- a/Minecraft.World/Monster.cpp +++ b/Minecraft.World/Monster.cpp @@ -75,7 +75,7 @@ bool Monster::hurt(DamageSource *source, float dmg) */ bool Monster::doHurtTarget(shared_ptr target) { - float dmg = (float) getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue(); + float dmg = static_cast(getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue()); int knockback = 0; diff --git a/Minecraft.World/MoveControl.cpp b/Minecraft.World/MoveControl.cpp index 02b5a9e0e..d2a529a18 100644 --- a/Minecraft.World/MoveControl.cpp +++ b/Minecraft.World/MoveControl.cpp @@ -54,10 +54,10 @@ void MoveControl::tick() double dd = xd * xd + yd * yd + zd * zd; if (dd < MIN_SPEED_SQR) return; - float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90; + float yRotD = static_cast(atan2(zd, xd) * 180 / PI) - 90; mob->yRot = rotlerp(mob->yRot, yRotD, MAX_TURN); - mob->setSpeed((float) (speedModifier * mob->getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue())); + mob->setSpeed(static_cast(speedModifier * mob->getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue())); if (yd > 0 && xd * xd + zd * zd < 1) mob->getJumpControl()->jump(); } diff --git a/Minecraft.World/MoveEntityPacket.cpp b/Minecraft.World/MoveEntityPacket.cpp index b52482f5e..e897c6f48 100644 --- a/Minecraft.World/MoveEntityPacket.cpp +++ b/Minecraft.World/MoveEntityPacket.cpp @@ -40,7 +40,7 @@ void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException // We shouln't be tracking an entity that doesn't have a short type of id __debugbreak(); } - dos->writeShort((short)id); + dos->writeShort(static_cast(id)); } void MoveEntityPacket::handle(PacketListener *listener) diff --git a/Minecraft.World/MoveEntityPacketSmall.cpp b/Minecraft.World/MoveEntityPacketSmall.cpp index 8216478fa..89f5e13ec 100644 --- a/Minecraft.World/MoveEntityPacketSmall.cpp +++ b/Minecraft.World/MoveEntityPacketSmall.cpp @@ -47,7 +47,7 @@ void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException // We shouln't be tracking an entity that doesn't have a short type of id __debugbreak(); } - dos->writeShort((short)id); + dos->writeShort(static_cast(id)); } void MoveEntityPacketSmall::handle(PacketListener *listener) @@ -131,7 +131,7 @@ void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException int idAndY = dis->readShort(); this->id = idAndY & 0x07ff; this->ya = idAndY >> 11; - int XandZ = (int)((signed char)(dis->readByte())); + int XandZ = (int)static_cast(dis->readByte()); xa = XandZ >> 4; za = ( XandZ << 28 ) >> 28; } diff --git a/Minecraft.World/Mth.cpp b/Minecraft.World/Mth.cpp index ab990e6cf..95e8ccbbb 100644 --- a/Minecraft.World/Mth.cpp +++ b/Minecraft.World/Mth.cpp @@ -26,13 +26,13 @@ void Mth::init() float Mth::sin(float i) { if(_sin == NULL) init(); // 4J - added - return _sin[(int) (i * sinScale) & 65535]; + return _sin[static_cast(i * sinScale) & 65535]; } float Mth::cos(float i) { if(_sin == NULL) init(); // 4J - added - return _sin[(int) (i * sinScale + 65536 / 4) & 65535]; + return _sin[static_cast(i * sinScale + 65536 / 4) & 65535]; } float Mth::sqrt(float x) @@ -42,35 +42,35 @@ float Mth::sqrt(float x) float Mth::sqrt(double x) { - return (float) ::sqrt(x); + return static_cast(::sqrt(x)); } int Mth::floor(float v) { - int i = (int) v; + int i = static_cast(v); return v < i ? i - 1 : i; } __int64 Mth::lfloor(double v) { - __int64 i = (__int64) v; + __int64 i = static_cast<__int64>(v); return v < i ? i - 1 : i; } int Mth::fastFloor(double x) { - return (int) (x + BIG_ENOUGH_FLOAT) - BIG_ENOUGH_INT; + return static_cast(x + BIG_ENOUGH_FLOAT) - BIG_ENOUGH_INT; } int Mth::floor(double v) { - int i = (int) v; + int i = static_cast(v); return v < i ? i - 1 : i; } int Mth::absFloor(double v) { - return (int) (v >= 0 ? v : -v + 1); + return static_cast(v >= 0 ? v : -v + 1); } float Mth::abs(float v) @@ -85,7 +85,7 @@ int Mth::abs(int v) int Mth::ceil(float v) { - int i = (int) v; + int i = static_cast(v); return v > i ? i + 1 : i; } diff --git a/Minecraft.World/MushroomIslandBiome.cpp b/Minecraft.World/MushroomIslandBiome.cpp index fa7eafdbe..91bd8097e 100644 --- a/Minecraft.World/MushroomIslandBiome.cpp +++ b/Minecraft.World/MushroomIslandBiome.cpp @@ -13,7 +13,7 @@ MushroomIslandBiome::MushroomIslandBiome(int id) : Biome(id) decorator->mushroomCount = 1; decorator->hugeMushrooms = 1; - topMaterial = (byte) Tile::mycel_Id; + topMaterial = static_cast(Tile::mycel_Id); enemies.clear(); friendlies.clear(); diff --git a/Minecraft.World/MusicTileEntity.cpp b/Minecraft.World/MusicTileEntity.cpp index d947cc69e..ac39758ae 100644 --- a/Minecraft.World/MusicTileEntity.cpp +++ b/Minecraft.World/MusicTileEntity.cpp @@ -33,7 +33,7 @@ void MusicTileEntity::load(CompoundTag *tag) void MusicTileEntity::tune() { - note = (byte) ((note + 1) % 25); + note = static_cast((note + 1) % 25); setChanged(); } diff --git a/Minecraft.World/NbtIo.cpp b/Minecraft.World/NbtIo.cpp index b6c632777..12b710163 100644 --- a/Minecraft.World/NbtIo.cpp +++ b/Minecraft.World/NbtIo.cpp @@ -52,7 +52,7 @@ CompoundTag *NbtIo::read(DataInput *dis) { Tag *tag = Tag::readNamedTag(dis); - if( tag->getId() == Tag::TAG_Compound ) return (CompoundTag *)tag; + if( tag->getId() == Tag::TAG_Compound ) return static_cast(tag); if(tag!=NULL) delete tag; // Root tag must be a named compound tag diff --git a/Minecraft.World/NetherBridgeFeature.cpp b/Minecraft.World/NetherBridgeFeature.cpp index d661d3b72..42cdfac94 100644 --- a/Minecraft.World/NetherBridgeFeature.cpp +++ b/Minecraft.World/NetherBridgeFeature.cpp @@ -118,7 +118,7 @@ NetherBridgeFeature::NetherBridgeStart::NetherBridgeStart(Level *level, Random * vector *pendingChildren = &start->pendingChildren; while (!pendingChildren->empty()) { - int pos = random->nextInt((int)pendingChildren->size()); + int pos = random->nextInt(static_cast(pendingChildren->size())); auto it = pendingChildren->begin() + pos; StructurePiece *structurePiece = *it; pendingChildren->erase(it); diff --git a/Minecraft.World/NetherBridgePieces.cpp b/Minecraft.World/NetherBridgePieces.cpp index 35baa71a3..de102da54 100644 --- a/Minecraft.World/NetherBridgePieces.cpp +++ b/Minecraft.World/NetherBridgePieces.cpp @@ -368,7 +368,7 @@ NetherBridgePieces::BridgeStraight::BridgeStraight(int genDepth, Random *random, void NetherBridgePieces::BridgeStraight::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildForward((StartPiece *) startPiece, pieces, random, 1, 3, false); + generateChildForward(static_cast(startPiece), pieces, random, 1, 3, false); } NetherBridgePieces::BridgeStraight *NetherBridgePieces::BridgeStraight::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -376,7 +376,7 @@ NetherBridgePieces::BridgeStraight *NetherBridgePieces::BridgeStraight::createPi BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -442,7 +442,7 @@ NetherBridgePieces::BridgeEndFiller *NetherBridgePieces::BridgeEndFiller::create BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -540,9 +540,9 @@ NetherBridgePieces::BridgeCrossing::BridgeCrossing(Random *random, int west, int void NetherBridgePieces::BridgeCrossing::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildForward((StartPiece *) startPiece, pieces, random, 8, 3, false); - generateChildLeft((StartPiece *) startPiece, pieces, random, 3, 8, false); - generateChildRight((StartPiece *) startPiece, pieces, random, 3, 8, false); + generateChildForward(static_cast(startPiece), pieces, random, 8, 3, false); + generateChildLeft(static_cast(startPiece), pieces, random, 3, 8, false); + generateChildRight(static_cast(startPiece), pieces, random, 3, 8, false); } NetherBridgePieces::BridgeCrossing *NetherBridgePieces::BridgeCrossing::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -550,7 +550,7 @@ NetherBridgePieces::BridgeCrossing *NetherBridgePieces::BridgeCrossing::createPi BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -8, -3, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -659,9 +659,9 @@ NetherBridgePieces::RoomCrossing::RoomCrossing(int genDepth, Random *random, Bou void NetherBridgePieces::RoomCrossing::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildForward((StartPiece *) startPiece, pieces, random, 2, 0, false); - generateChildLeft((StartPiece *) startPiece, pieces, random, 0, 2, false); - generateChildRight((StartPiece *) startPiece, pieces, random, 0, 2, false); + generateChildForward(static_cast(startPiece), pieces, random, 2, 0, false); + generateChildLeft(static_cast(startPiece), pieces, random, 0, 2, false); + generateChildRight(static_cast(startPiece), pieces, random, 0, 2, false); } NetherBridgePieces::RoomCrossing *NetherBridgePieces::RoomCrossing::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -669,7 +669,7 @@ NetherBridgePieces::RoomCrossing *NetherBridgePieces::RoomCrossing::createPiece( BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -731,7 +731,7 @@ NetherBridgePieces::StairsRoom::StairsRoom(int genDepth, Random *random, Boundin void NetherBridgePieces::StairsRoom::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildRight((StartPiece *) startPiece, pieces, random, 6, 2, false); + generateChildRight(static_cast(startPiece), pieces, random, 6, 2, false); } NetherBridgePieces::StairsRoom *NetherBridgePieces::StairsRoom::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -739,7 +739,7 @@ NetherBridgePieces::StairsRoom *NetherBridgePieces::StairsRoom::createPiece(list BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -813,7 +813,7 @@ NetherBridgePieces::MonsterThrone *NetherBridgePieces::MonsterThrone::createPiec BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -901,7 +901,7 @@ NetherBridgePieces::CastleEntrance::CastleEntrance(int genDepth, Random *random, void NetherBridgePieces::CastleEntrance::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildForward((StartPiece *) startPiece, pieces, random, 5, 3, true); + generateChildForward(static_cast(startPiece), pieces, random, 5, 3, true); } NetherBridgePieces::CastleEntrance *NetherBridgePieces::CastleEntrance::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -909,7 +909,7 @@ NetherBridgePieces::CastleEntrance *NetherBridgePieces::CastleEntrance::createPi BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1030,8 +1030,8 @@ NetherBridgePieces::CastleStalkRoom::CastleStalkRoom(int genDepth, Random *rando void NetherBridgePieces::CastleStalkRoom::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildForward((StartPiece *) startPiece, pieces, random, 5, 3, true); - generateChildForward((StartPiece *) startPiece, pieces, random, 5, 11, true); + generateChildForward(static_cast(startPiece), pieces, random, 5, 3, true); + generateChildForward(static_cast(startPiece), pieces, random, 5, 11, true); } NetherBridgePieces::CastleStalkRoom *NetherBridgePieces::CastleStalkRoom::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1039,7 +1039,7 @@ NetherBridgePieces::CastleStalkRoom *NetherBridgePieces::CastleStalkRoom::create BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1196,7 +1196,7 @@ NetherBridgePieces::CastleSmallCorridorPiece::CastleSmallCorridorPiece(int genDe void NetherBridgePieces::CastleSmallCorridorPiece::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildForward((StartPiece *) startPiece, pieces, random, 1, 0, true); + generateChildForward(static_cast(startPiece), pieces, random, 1, 0, true); } NetherBridgePieces::CastleSmallCorridorPiece *NetherBridgePieces::CastleSmallCorridorPiece::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1205,7 +1205,7 @@ NetherBridgePieces::CastleSmallCorridorPiece *NetherBridgePieces::CastleSmallCor BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1259,9 +1259,9 @@ NetherBridgePieces::CastleSmallCorridorCrossingPiece::CastleSmallCorridorCrossin void NetherBridgePieces::CastleSmallCorridorCrossingPiece::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildForward((StartPiece *) startPiece, pieces, random, 1, 0, true); - generateChildLeft((StartPiece *) startPiece, pieces, random, 0, 1, true); - generateChildRight((StartPiece *) startPiece, pieces, random, 0, 1, true); + generateChildForward(static_cast(startPiece), pieces, random, 1, 0, true); + generateChildLeft(static_cast(startPiece), pieces, random, 0, 1, true); + generateChildRight(static_cast(startPiece), pieces, random, 0, 1, true); } NetherBridgePieces::CastleSmallCorridorCrossingPiece *NetherBridgePieces::CastleSmallCorridorCrossingPiece::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1269,7 +1269,7 @@ NetherBridgePieces::CastleSmallCorridorCrossingPiece *NetherBridgePieces::Castle BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1337,7 +1337,7 @@ void NetherBridgePieces::CastleSmallCorridorRightTurnPiece::addAdditonalSaveData void NetherBridgePieces::CastleSmallCorridorRightTurnPiece::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildRight((StartPiece *) startPiece, pieces, random, 0, 1, true); + generateChildRight(static_cast(startPiece), pieces, random, 0, 1, true); } NetherBridgePieces::CastleSmallCorridorRightTurnPiece *NetherBridgePieces::CastleSmallCorridorRightTurnPiece::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1345,7 +1345,7 @@ NetherBridgePieces::CastleSmallCorridorRightTurnPiece *NetherBridgePieces::Castl BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1429,7 +1429,7 @@ void NetherBridgePieces::CastleSmallCorridorLeftTurnPiece::addAdditonalSaveData( void NetherBridgePieces::CastleSmallCorridorLeftTurnPiece::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildLeft((StartPiece *) startPiece, pieces, random, 0, 1, true); + generateChildLeft(static_cast(startPiece), pieces, random, 0, 1, true); } NetherBridgePieces::CastleSmallCorridorLeftTurnPiece *NetherBridgePieces::CastleSmallCorridorLeftTurnPiece::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1437,7 +1437,7 @@ NetherBridgePieces::CastleSmallCorridorLeftTurnPiece *NetherBridgePieces::Castle BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1505,7 +1505,7 @@ NetherBridgePieces::CastleCorridorStairsPiece::CastleCorridorStairsPiece(int gen void NetherBridgePieces::CastleCorridorStairsPiece::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateChildForward((StartPiece *) startPiece, pieces, random, 1, 0, true); + generateChildForward(static_cast(startPiece), pieces, random, 1, 0, true); } NetherBridgePieces::CastleCorridorStairsPiece *NetherBridgePieces::CastleCorridorStairsPiece::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1513,7 +1513,7 @@ NetherBridgePieces::CastleCorridorStairsPiece *NetherBridgePieces::CastleCorrido BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -7, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1586,8 +1586,8 @@ void NetherBridgePieces::CastleCorridorTBalconyPiece::addChildren(StructurePiece zOff = 5; } - generateChildLeft((StartPiece *) startPiece, pieces, random, 0, zOff, random->nextInt(8) > 0); - generateChildRight((StartPiece *) startPiece, pieces, random, 0, zOff, random->nextInt(8) > 0); + generateChildLeft(static_cast(startPiece), pieces, random, 0, zOff, random->nextInt(8) > 0); + generateChildRight(static_cast(startPiece), pieces, random, 0, zOff, random->nextInt(8) > 0); } NetherBridgePieces::CastleCorridorTBalconyPiece *NetherBridgePieces::CastleCorridorTBalconyPiece::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1595,7 +1595,7 @@ NetherBridgePieces::CastleCorridorTBalconyPiece *NetherBridgePieces::CastleCorri BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -3, 0, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { diff --git a/Minecraft.World/Node.cpp b/Minecraft.World/Node.cpp index 7059c0450..a8988091c 100644 --- a/Minecraft.World/Node.cpp +++ b/Minecraft.World/Node.cpp @@ -35,9 +35,9 @@ int Node::createHash(const int x, const int y, const int z) float Node::distanceTo(Node *to) { - float xd = (float) ( to->x - x ); - float yd = (float) ( to->y - y ); - float zd = (float) ( to->z - z ); + float xd = static_cast(to->x - x); + float yd = static_cast(to->y - y); + float zd = static_cast(to->z - z); return Mth::sqrt(xd * xd + yd * yd + zd * zd); } diff --git a/Minecraft.World/NoteBlockTile.cpp b/Minecraft.World/NoteBlockTile.cpp index 25ea587aa..504ed511e 100644 --- a/Minecraft.World/NoteBlockTile.cpp +++ b/Minecraft.World/NoteBlockTile.cpp @@ -57,7 +57,7 @@ shared_ptr NoteBlockTile::newTileEntity(Level *level) bool NoteBlockTile::triggerEvent(Level *level, int x, int y, int z, int i, int note) { - float pitch = (float) pow(2, (note - 12) / 12.0); + float pitch = static_cast(pow(2, (note - 12) / 12.0)); int iSound; switch(i) diff --git a/Minecraft.World/Ocelot.cpp b/Minecraft.World/Ocelot.cpp index 50285682a..53ee27299 100644 --- a/Minecraft.World/Ocelot.cpp +++ b/Minecraft.World/Ocelot.cpp @@ -57,7 +57,7 @@ void Ocelot::defineSynchedData() { TamableAnimal::defineSynchedData(); - entityData->define(DATA_TYPE_ID, (byte) 0); + entityData->define(DATA_TYPE_ID, static_cast(0)); } void Ocelot::serverAiMobStep() @@ -279,7 +279,7 @@ int Ocelot::getCatType() void Ocelot::setCatType(int type) { - entityData->set(DATA_TYPE_ID, (byte) type); + entityData->set(DATA_TYPE_ID, static_cast(type)); } bool Ocelot::canSpawn() @@ -351,7 +351,7 @@ MobGroupData *Ocelot::finalizeMobSpawn(MobGroupData *groupData, int extraData /* void Ocelot::setSittingOnTile(bool val) { byte current = entityData->getByte(DATA_FLAGS_ID); - entityData->set(DATA_FLAGS_ID, val ? (byte) (current | 0x02) : (byte) (current & ~0x02) ); + entityData->set(DATA_FLAGS_ID, val ? static_cast(current | 0x02) : static_cast(current & ~0x02) ); } bool Ocelot::isSittingOnTile() diff --git a/Minecraft.World/OcelotSitOnTileGoal.cpp b/Minecraft.World/OcelotSitOnTileGoal.cpp index a35537fb6..09b986503 100644 --- a/Minecraft.World/OcelotSitOnTileGoal.cpp +++ b/Minecraft.World/OcelotSitOnTileGoal.cpp @@ -41,7 +41,7 @@ bool OcelotSitOnTileGoal::canContinueToUse() void OcelotSitOnTileGoal::start() { - ocelot->getNavigation()->moveTo((float) tileX + 0.5, tileY + 1, (float) tileZ + 0.5, speedModifier); + ocelot->getNavigation()->moveTo(static_cast(tileX) + 0.5, tileY + 1, static_cast(tileZ) + 0.5, speedModifier); _tick = 0; tryTicks = 0; maxTicks = ocelot->getRandom()->nextInt(ocelot->getRandom()->nextInt(SIT_TICKS) + SIT_TICKS) + SIT_TICKS; @@ -64,7 +64,7 @@ void OcelotSitOnTileGoal::tick() if (ocelot->distanceToSqr(tileX, tileY + 1, tileZ) > 1) { ocelot->setSitting(false); - ocelot->getNavigation()->moveTo((float) tileX + 0.5, tileY + 1, (float) tileZ + 0.5, speedModifier); + ocelot->getNavigation()->moveTo(static_cast(tileX) + 0.5, tileY + 1, static_cast(tileZ) + 0.5, speedModifier); tryTicks++; } else if (!ocelot->isSitting()) @@ -79,12 +79,12 @@ void OcelotSitOnTileGoal::tick() bool OcelotSitOnTileGoal::findNearestTile() { - int y = (int) ocelot->y; + int y = static_cast(ocelot->y); double distSqr = Integer::MAX_VALUE; - for (int x = (int) ocelot->x - SEARCH_RANGE; x < ocelot->x + SEARCH_RANGE; x++) + for (int x = static_cast(ocelot->x) - SEARCH_RANGE; x < ocelot->x + SEARCH_RANGE; x++) { - for (int z = (int) ocelot->z - SEARCH_RANGE; z < ocelot->z + SEARCH_RANGE; z++) + for (int z = static_cast(ocelot->z) - SEARCH_RANGE; z < ocelot->z + SEARCH_RANGE; z++) { if (isValidTarget(ocelot->level, x, y, z) && ocelot->level->isEmptyTile(x, y + 1, z)) { diff --git a/Minecraft.World/OldChunkStorage.cpp b/Minecraft.World/OldChunkStorage.cpp index 24263d0d5..c3e6f4aea 100644 --- a/Minecraft.World/OldChunkStorage.cpp +++ b/Minecraft.World/OldChunkStorage.cpp @@ -45,7 +45,7 @@ void OldChunkStorage::UseDefaultThreadStorage() void OldChunkStorage::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); if( tls == tlsDefault ) return; delete tls; @@ -290,7 +290,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos) teTag->putInt(L"x", td.x); teTag->putInt(L"y", td.y); teTag->putInt(L"z", td.z); - teTag->putInt(L"t", (int) (td.m_delay - levelTime)); + teTag->putInt(L"t", static_cast(td.m_delay - levelTime)); tickTags->add(teTag); } @@ -318,7 +318,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) // Will be fine so long as we only actually create tags for once chunk at a time. // 4J Stu - As we now save on multiple threads, the static data has been moved to TLS - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); PIXBeginNamedEvent(0,"Getting block data"); //static byteArray blockData = byteArray(32768); @@ -378,7 +378,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) teTag->putInt(L"x", td.x); teTag->putInt(L"y", td.y); teTag->putInt(L"z", td.z); - teTag->putInt(L"t", (int) (td.m_delay - levelTime)); + teTag->putInt(L"t", static_cast(td.m_delay - levelTime)); teTag->putInt(L"p", td.priorityTilt); tickTags->add(teTag); diff --git a/Minecraft.World/Packet.cpp b/Minecraft.World/Packet.cpp index a37cb2ad6..44081a586 100644 --- a/Minecraft.World/Packet.cpp +++ b/Minecraft.World/Packet.cpp @@ -386,7 +386,7 @@ void Packet::writeUtf(const wstring& value, DataOutputStream *dos) // throws IOE } #endif - dos->writeShort((short)value.length()); + dos->writeShort(static_cast(value.length())); dos->writeChars(value); } @@ -443,7 +443,7 @@ double Packet::PacketStatistics::getAverageSize() { return 0; } - return (double) totalSize / count; + return static_cast(totalSize) / count; } int Packet::PacketStatistics::getTotalSize() @@ -562,7 +562,7 @@ void Packet::writeNbt(CompoundTag *tag, DataOutputStream *dos) else { byteArray buff = NbtIo::compress(tag); - dos->writeShort((short) buff.length); + dos->writeShort(static_cast(buff.length)); dos->write(buff); delete [] buff.data; } diff --git a/Minecraft.World/Painting.cpp b/Minecraft.World/Painting.cpp index 208beb773..4d79f6f44 100644 --- a/Minecraft.World/Painting.cpp +++ b/Minecraft.World/Painting.cpp @@ -98,7 +98,7 @@ void Painting::PaintingPostConstructor(int dir, int motive) } if (!survivableMotives->empty()) { - this->motive = survivableMotives->at(random->nextInt((int)survivableMotives->size())); + this->motive = survivableMotives->at(random->nextInt(static_cast(survivableMotives->size()))); } setDir(dir); } diff --git a/Minecraft.World/Path.cpp b/Minecraft.World/Path.cpp index 538917f6f..0006ce095 100644 --- a/Minecraft.World/Path.cpp +++ b/Minecraft.World/Path.cpp @@ -76,9 +76,9 @@ void Path::setIndex(int index) Vec3 *Path::getPos(shared_ptr e, int index) { - double x = nodes[index]->x + (int) (e->bbWidth + 1) * 0.5; + double x = nodes[index]->x + static_cast(e->bbWidth + 1) * 0.5; double y = nodes[index]->y; - double z = nodes[index]->z + (int) (e->bbWidth + 1) * 0.5; + double z = nodes[index]->z + static_cast(e->bbWidth + 1) * 0.5; return Vec3::newTemp(x, y, z); } @@ -105,12 +105,12 @@ bool Path::endsIn(Vec3 *pos) { Node *lastNode = last(); if (lastNode == NULL) return false; - return lastNode->x == (int) pos->x && lastNode->y == (int) pos->y && lastNode->z == (int) pos->z; + return lastNode->x == static_cast(pos->x) && lastNode->y == static_cast(pos->y) && lastNode->z == static_cast(pos->z); } bool Path::endsInXZ(Vec3 *pos) { Node *lastNode = last(); if (lastNode == NULL) return false; - return lastNode->x == (int) pos->x && lastNode->z == (int) pos->z; + return lastNode->x == static_cast(pos->x) && lastNode->z == static_cast(pos->z); } \ No newline at end of file diff --git a/Minecraft.World/PathFinder.cpp b/Minecraft.World/PathFinder.cpp index 2e11648f3..dc8a9882c 100644 --- a/Minecraft.World/PathFinder.cpp +++ b/Minecraft.World/PathFinder.cpp @@ -51,7 +51,7 @@ Path *PathFinder::findPath(Entity *e, double xt, double yt, double zt, float max int startY = Mth::floor(e->bb->y0 + 0.5f); if (canFloat && e->isInWater()) { - startY = (int) (e->bb->y0); + startY = static_cast(e->bb->y0); int tileId = level->getTile((int) Mth::floor(e->x), startY, (int) Mth::floor(e->z)); while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id) { @@ -62,10 +62,10 @@ Path *PathFinder::findPath(Entity *e, double xt, double yt, double zt, float max avoidWater = false; } else startY = Mth::floor(e->bb->y0 + 0.5f); - Node *from = getNode((int) floor(e->bb->x0), startY, (int) floor(e->bb->z0)); - Node *to = getNode((int) floor(xt - e->bbWidth / 2), (int) floor(yt), (int) floor(zt - e->bbWidth / 2)); + Node *from = getNode(static_cast(floor(e->bb->x0)), startY, static_cast(floor(e->bb->z0))); + Node *to = getNode(static_cast(floor(xt - e->bbWidth / 2)), static_cast(floor(yt)), static_cast(floor(zt - e->bbWidth / 2))); - Node *size = new Node((int) floor(e->bbWidth + 1), (int) floor(e->bbHeight + 1), (int) floor(e->bbWidth + 1)); + Node *size = new Node(static_cast(floor(e->bbWidth + 1)), static_cast(floor(e->bbHeight + 1)), static_cast(floor(e->bbWidth + 1))); Path *path = findPath(e, from, to, size, maxDist); delete size; diff --git a/Minecraft.World/PathNavigation.cpp b/Minecraft.World/PathNavigation.cpp index 7cac052ee..4a9f6d0c0 100644 --- a/Minecraft.World/PathNavigation.cpp +++ b/Minecraft.World/PathNavigation.cpp @@ -81,19 +81,19 @@ void PathNavigation::setCanFloat(bool canFloat) float PathNavigation::getMaxDist() { - return (float) dist->getValue(); + return static_cast(dist->getValue()); } Path *PathNavigation::createPath(double x, double y, double z) { if (!canUpdatePath()) return NULL; - return level->findPath(mob->shared_from_this(), Mth::floor(x), (int) y, Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat); + return level->findPath(mob->shared_from_this(), Mth::floor(x), static_cast(y), Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat); } bool PathNavigation::moveTo(double x, double y, double z, double speedModifier) { MemSect(52); - Path *newPath = createPath(Mth::floor(x), (int) y, Mth::floor(z)); + Path *newPath = createPath(Mth::floor(x), static_cast(y), Mth::floor(z)); MemSect(0); // No need to delete newPath here as this will be copied into the member variable path and the class can assume responsibility for it return moveTo(newPath, speedModifier); @@ -171,7 +171,7 @@ void PathNavigation::updatePath() int firstElevation = path->getSize(); for (int i = path->getIndex(); path != NULL && i < path->getSize(); ++i) { - if ((int) path->get(i)->y != (int) mobPos->y) + if (static_cast(path->get(i)->y) != static_cast(mobPos->y)) { firstElevation = i; break; @@ -191,8 +191,8 @@ void PathNavigation::updatePath() } // smooth remaining on same elevation - int sx = (int) ceil(mob->bbWidth); - int sy = (int) mob->bbHeight + 1; + int sx = static_cast(ceil(mob->bbWidth)); + int sy = static_cast(mob->bbHeight) + 1; int sz = sx; for (int i = firstElevation - 1; i >= path->getIndex(); --i) { @@ -232,16 +232,16 @@ Vec3 *PathNavigation::getTempMobPos() int PathNavigation::getSurfaceY() { - if (!mob->isInWater() || !canFloat) return (int) (mob->bb->y0 + 0.5); + if (!mob->isInWater() || !canFloat) return static_cast(mob->bb->y0 + 0.5); - int surface = (int) (mob->bb->y0); + int surface = static_cast(mob->bb->y0); int tileId = level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z)); int steps = 0; while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id) { ++surface; tileId = level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z)); - if (++steps > 16) return (int) (mob->bb->y0); + if (++steps > 16) return static_cast(mob->bb->y0); } return surface; } @@ -258,7 +258,7 @@ bool PathNavigation::isInLiquid() void PathNavigation::trimPathFromSun() { - if (level->canSeeSky(Mth::floor(mob->x), (int) (mob->bb->y0 + 0.5), Mth::floor(mob->z))) return; + if (level->canSeeSky(Mth::floor(mob->x), static_cast(mob->bb->y0 + 0.5), Mth::floor(mob->z))) return; for (int i = 0; i < path->getSize(); ++i) { @@ -288,7 +288,7 @@ bool PathNavigation::canMoveDirectly(Vec3 *startPos, Vec3 *stopPos, int sx, int sx += 2; sz += 2; - if (!canWalkOn(gridPosX, (int) startPos->y, gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false; + if (!canWalkOn(gridPosX, static_cast(startPos->y), gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false; sx -= 2; sz -= 2; @@ -323,7 +323,7 @@ bool PathNavigation::canMoveDirectly(Vec3 *startPos, Vec3 *stopPos, int sx, int currentDirZ = gridGoalZ - gridPosZ; } - if (!canWalkOn(gridPosX, (int) startPos->y, gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false; + if (!canWalkOn(gridPosX, static_cast(startPos->y), gridPosZ, sx, sy, sz, startPos, dirX, dirZ)) return false; } return true; } diff --git a/Minecraft.World/PathfinderMob.cpp b/Minecraft.World/PathfinderMob.cpp index c01790e78..9942445c9 100644 --- a/Minecraft.World/PathfinderMob.cpp +++ b/Minecraft.World/PathfinderMob.cpp @@ -141,9 +141,9 @@ void PathfinderMob::serverAiStep() double xd = target->x - x; double zd = target->z - z; double yd = target->y - yFloor; - float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90; + float yRotD = static_cast(atan2(zd, xd) * 180 / PI) - 90; float rotDiff = Mth::wrapDegrees(yRotD - yRot); - yya = (float) getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue(); + yya = static_cast(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()); if (rotDiff > MAX_TURN) { rotDiff = MAX_TURN; @@ -162,7 +162,7 @@ void PathfinderMob::serverAiStep() double zd2 = attackTarget->z - z; float oldyRot = yRot; - yRot = (float) (atan2(zd2, xd2) * 180 / PI) - 90; + yRot = static_cast(atan2(zd2, xd2) * 180 / PI) - 90; rotDiff = ((oldyRot - yRot) + 90) * PI / 180; xxa = -Mth::sin(rotDiff) * yya * 1.0f; @@ -315,7 +315,7 @@ void PathfinderMob::tickLeash() { // soft restriction shared_ptr leashHolder = getLeashHolder(); - restrictTo((int) leashHolder->x, (int) leashHolder->y, (int) leashHolder->z, 5); + restrictTo(static_cast(leashHolder->x), static_cast(leashHolder->y), static_cast(leashHolder->z), 5); float _distanceTo = distanceTo(leashHolder); diff --git a/Minecraft.World/PerformanceTimer.cpp b/Minecraft.World/PerformanceTimer.cpp index 5ed7ee0c8..1e01a4042 100644 --- a/Minecraft.World/PerformanceTimer.cpp +++ b/Minecraft.World/PerformanceTimer.cpp @@ -7,7 +7,7 @@ PerformanceTimer::PerformanceTimer() // Get the frequency of the timer LARGE_INTEGER qwTicksPerSec; QueryPerformanceFrequency( &qwTicksPerSec ); - m_fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; + m_fSecsPerTick = 1.0f / static_cast(qwTicksPerSec.QuadPart); Reset(); #endif @@ -28,7 +28,7 @@ void PerformanceTimer::PrintElapsedTime(const wstring &description) QueryPerformanceCounter( &qwNewTime ); qwDeltaTime.QuadPart = qwNewTime.QuadPart - m_qwStartTime.QuadPart; - float fElapsedTime = m_fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); + float fElapsedTime = m_fSecsPerTick * static_cast(qwDeltaTime.QuadPart); app.DebugPrintf("TIMER: %ls: Elapsed time %f\n", description.c_str(), fElapsedTime); #endif diff --git a/Minecraft.World/PerlinSimplexNoise.cpp b/Minecraft.World/PerlinSimplexNoise.cpp index dbc570a4c..a8f6101c7 100644 --- a/Minecraft.World/PerlinSimplexNoise.cpp +++ b/Minecraft.World/PerlinSimplexNoise.cpp @@ -72,7 +72,7 @@ doubleArray PerlinSimplexNoise::getRegion(doubleArray buffer, double x, double y xScale/=1.5; yScale/=1.5; - if (buffer.data == NULL || (int) buffer.length < xSize * ySize) + if (buffer.data == NULL || static_cast(buffer.length) < xSize * ySize) { if( buffer.data ) delete [] buffer.data; buffer = doubleArray(xSize * ySize); diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp index cc042f586..54d82ad85 100644 --- a/Minecraft.World/Pig.cpp +++ b/Minecraft.World/Pig.cpp @@ -70,7 +70,7 @@ bool Pig::canBeControlledByRider() void Pig::defineSynchedData() { Animal::defineSynchedData(); - entityData->define(DATA_SADDLE_ID, (byte) 0); + entityData->define(DATA_SADDLE_ID, static_cast(0)); } void Pig::addAdditonalSaveData(CompoundTag *tag) @@ -153,11 +153,11 @@ void Pig::setSaddle(bool value) { if (value) { - entityData->set(DATA_SADDLE_ID, (byte) 1); + entityData->set(DATA_SADDLE_ID, static_cast(1)); } else { - entityData->set(DATA_SADDLE_ID, (byte) 0); + entityData->set(DATA_SADDLE_ID, static_cast(0)); } } diff --git a/Minecraft.World/PigZombie.cpp b/Minecraft.World/PigZombie.cpp index c284c323f..6c5457c8a 100644 --- a/Minecraft.World/PigZombie.cpp +++ b/Minecraft.World/PigZombie.cpp @@ -78,7 +78,7 @@ bool PigZombie::canSpawn() void PigZombie::addAdditonalSaveData(CompoundTag *tag) { Zombie::addAdditonalSaveData(tag); - tag->putShort(L"Anger", (short) angerTime); + tag->putShort(L"Anger", static_cast(angerTime)); } void PigZombie::readAdditionalSaveData(CompoundTag *tag) diff --git a/Minecraft.World/PistonBaseTile.cpp b/Minecraft.World/PistonBaseTile.cpp index c71bbf95d..7cd4d1200 100644 --- a/Minecraft.World/PistonBaseTile.cpp +++ b/Minecraft.World/PistonBaseTile.cpp @@ -75,7 +75,7 @@ Icon *PistonBaseTile::getTexture(int face, int data) // when the piston is extended, either normally // or because a piston arm animation, the top // texture is the furnace bottom - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); if (isExtended(data) || tls->xx0 > 0 || tls->yy0 > 0 || tls->zz0 > 0 || tls->xx1 < 1 || tls->yy1 < 1 || tls->zz1 < 1) { return iconInside; @@ -412,7 +412,7 @@ bool PistonBaseTile::isExtended(int data) int PistonBaseTile::getNewFacing(Level *level, int x, int y, int z, shared_ptr player) { - if (Mth::abs((float) player->x - x) < 2 && Mth::abs((float) player->z - z) < 2) + if (Mth::abs(static_cast(player->x) - x) < 2 && Mth::abs(static_cast(player->z) - z) < 2) { // If the player is above the block, the slot is on the top double py = player->y + 1.82 - player->heightOffset; diff --git a/Minecraft.World/PistonMovingPiece.cpp b/Minecraft.World/PistonMovingPiece.cpp index 5fa9a475d..ed0bfeba3 100644 --- a/Minecraft.World/PistonMovingPiece.cpp +++ b/Minecraft.World/PistonMovingPiece.cpp @@ -138,7 +138,7 @@ void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int progress = 1.0f - progress; } int facing = entity->getFacing(); - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); tls->xx0 = tile->getShapeX0() - Facing::STEP_X[facing] * progress; tls->yy0 = tile->getShapeY0() - Facing::STEP_Y[facing] * progress; tls->zz0 = tile->getShapeZ0() - Facing::STEP_Z[facing] * progress; diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index bd6b68a8e..b7c659bb3 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -175,8 +175,8 @@ void Player::defineSynchedData() { LivingEntity::defineSynchedData(); - entityData->define(DATA_PLAYER_FLAGS_ID, (byte) 0); - entityData->define(DATA_PLAYER_ABSORPTION_ID, (float) 0); + entityData->define(DATA_PLAYER_FLAGS_ID, static_cast(0)); + entityData->define(DATA_PLAYER_ABSORPTION_ID, static_cast(0)); entityData->define(DATA_SCORE_ID, (int) 0); } @@ -657,13 +657,13 @@ void Player::setCustomSkin(DWORD skinId) DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId); if( ugcSkinIndex == 0 && defaultSkinIndex > 0 ) { - playerSkin = (EDefaultSkins) defaultSkinIndex; + playerSkin = static_cast(defaultSkinIndex); } } if( playerSkin == eDefaultSkins_ServerSelected) { - playerSkin = (EDefaultSkins)(m_playerIndex + 1); + playerSkin = static_cast(m_playerIndex + 1); } // We always set a default skin, since we may be waiting for the player's custom skin to be transmitted @@ -1018,9 +1018,9 @@ void Player::aiStep() flyingSpeed += defaultFlySpeed * 0.3f; } - setSpeed((float) speed->getValue()); + setSpeed(static_cast(speed->getValue())); - float tBob = (float) sqrt(xd * xd + zd * zd); + float tBob = static_cast(sqrt(xd * xd + zd * zd)); // 4J added - we were getting a NaN with zero xd & zd if(( xd * xd + zd * zd ) < 0.00001f ) @@ -1028,7 +1028,7 @@ void Player::aiStep() tBob = 0.0f; } - float tTilt = (float) atan(-yd * 0.2f) * 15.0f; + float tTilt = static_cast(atan(-yd * 0.2f)) * 15.0f; if (tBob > 0.1f) tBob = 0.1f; if (!onGround || getHealth() <= 0) tBob = 0; if (onGround || getHealth() <= 0) tTilt = 0; @@ -1305,7 +1305,7 @@ void Player::addAdditonalSaveData(CompoundTag *entityTag) entityTag->put(L"Inventory", inventory->save(new ListTag())); entityTag->putInt(L"SelectedItemSlot", inventory->selected); entityTag->putBoolean(L"Sleeping", m_isSleeping); - entityTag->putShort(L"SleepTimer", (short) sleepCounter); + entityTag->putShort(L"SleepTimer", static_cast(sleepCounter)); entityTag->putFloat(L"XpP", experienceProgress); entityTag->putInt(L"XpLevel", experienceLevel); @@ -1459,7 +1459,7 @@ float Player::getArmorCoverPercentage() count++; } } - return (float) count / (float) inventory->armor.length; + return static_cast(count) / static_cast(inventory->armor.length); } void Player::actuallyHurt(DamageSource *source, float dmg) @@ -1594,7 +1594,7 @@ void Player::attack(shared_ptr entity) return; } - float dmg = (float) getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue(); + float dmg = static_cast(getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue()); int knockback = 0; float magicBoost = 0; @@ -2028,11 +2028,11 @@ void Player::setPlayerFlag(int flag, bool value) byte currentValue = entityData->getByte(DATA_PLAYER_FLAGS_ID); if (value) { - entityData->set(DATA_PLAYER_FLAGS_ID, (byte) (currentValue | (1 << flag))); + entityData->set(DATA_PLAYER_FLAGS_ID, static_cast(currentValue | (1 << flag))); } else { - entityData->set(DATA_PLAYER_FLAGS_ID, (byte) (currentValue & ~(1 << flag))); + entityData->set(DATA_PLAYER_FLAGS_ID, static_cast(currentValue & ~(1 << flag))); } } @@ -2121,7 +2121,7 @@ void Player::travel(float xa, float ya) float Player::getSpeed() { - return (float) getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue(); + return static_cast(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue()); } void Player::checkMovementStatistiscs(double dx, double dy, double dz) @@ -2133,7 +2133,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz) } if (isUnderLiquid(Material::water)) { - int distance = (int) Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f); + int distance = static_cast(Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f)); if (distance > 0) { //awardStat(Stats::diveOneCm, distance); @@ -2142,7 +2142,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz) } else if (isInWater()) { - int horizontalDistance = (int) Math::round(sqrt(dx * dx + dz * dz) * 100.0f); + int horizontalDistance = static_cast(Math::round(sqrt(dx * dx + dz * dz) * 100.0f)); if (horizontalDistance > 0) { distanceSwim += horizontalDistance; @@ -2159,7 +2159,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz) { if (dy > 0) { - distanceClimb += (int) Math::round(dy * 100.0f); + distanceClimb += static_cast(Math::round(dy * 100.0f)); if( distanceClimb >= 100 ) { int newDistance = distanceClimb - (distanceClimb % 100); @@ -2170,7 +2170,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz) } else if (onGround) { - int horizontalDistance = (int) Math::round(sqrt(dx * dx + dz * dz) * 100.0f); + int horizontalDistance = static_cast(Math::round(sqrt(dx * dx + dz * dz) * 100.0f)); if (horizontalDistance > 0) { distanceWalk += horizontalDistance; @@ -2197,7 +2197,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) { if (riding != NULL) { - int distance = (int) Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f); + int distance = static_cast(Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f)); if (distance > 0) { if ( riding->instanceof(eTYPE_MINECART) ) @@ -2278,7 +2278,7 @@ void Player::causeFallDamage(float distance) if (distance >= 2) { - distanceFall += (int) Math::round(distance * 100.0); + distanceFall += static_cast(Math::round(distance * 100.0)); if( distanceFall >= 100 ) { int newDistance = distanceFall - (distanceFall % 100); @@ -2388,7 +2388,7 @@ void Player::increaseXp(int i) { i = max; } - experienceProgress += (float) i / getXpNeededForNextLevel(); + experienceProgress += static_cast(i) / getXpNeededForNextLevel(); totalExperience += i; while (experienceProgress >= 1) { @@ -2714,7 +2714,7 @@ int Player::hash_fnct(const shared_ptr k) #ifdef __PS3__ return (int)boost::hash_value( k->name ); // 4J Stu - Names are completely unique? #else - return (int)std::hash{}(k->name); // 4J Stu - Names are completely unique? + return static_cast(std::hash{}(k->name)); // 4J Stu - Names are completely unique? #endif //__PS3__ } diff --git a/Minecraft.World/PlayerEnderChestContainer.cpp b/Minecraft.World/PlayerEnderChestContainer.cpp index f0a1aaa3f..e84e59207 100644 --- a/Minecraft.World/PlayerEnderChestContainer.cpp +++ b/Minecraft.World/PlayerEnderChestContainer.cpp @@ -41,7 +41,7 @@ ListTag *PlayerEnderChestContainer::createTag() if (item != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); item->save(tag); items->add(tag); } diff --git a/Minecraft.World/Pos.cpp b/Minecraft.World/Pos.cpp index e673ecc3e..b7695a35a 100644 --- a/Minecraft.World/Pos.cpp +++ b/Minecraft.World/Pos.cpp @@ -29,12 +29,12 @@ bool Pos::equals(void *other) { // TODO 4J Stu I cannot do a dynamic_cast from a void pointer // If I cast it to a Pos then do a dynamic_cast will it still return NULL if it wasn't originally a Pos? - if (!( dynamic_cast( (Pos *)other ) != NULL )) + if (!( dynamic_cast( static_cast(other) ) != NULL )) { return false; } - Pos *p = (Pos *) other; + Pos *p = static_cast(other); return x == p->x && y == p->y && z == p->z; } diff --git a/Minecraft.World/PotionBrewing.cpp b/Minecraft.World/PotionBrewing.cpp index 8e27a6017..3ec38ef94 100644 --- a/Minecraft.World/PotionBrewing.cpp +++ b/Minecraft.World/PotionBrewing.cpp @@ -203,9 +203,9 @@ int PotionBrewing::getColorValue(vector *effects) for (int potency = 0; potency <= effect->getAmplifier(); potency++) { - red += (float) ((potionColor >> 16) & 0xff) / 255.0f; - green += (float) ((potionColor >> 8) & 0xff) / 255.0f; - blue += (float) ((potionColor >> 0) & 0xff) / 255.0f; + red += static_cast((potionColor >> 16) & 0xff) / 255.0f; + green += static_cast((potionColor >> 8) & 0xff) / 255.0f; + blue += static_cast((potionColor >> 0) & 0xff) / 255.0f; count++; } } @@ -214,7 +214,7 @@ int PotionBrewing::getColorValue(vector *effects) green = (green / count) * 255.0f; blue = (blue / count) * 255.0f; - return ((int) red) << 16 | ((int) green) << 8 | ((int) blue); + return static_cast(red) << 16 | static_cast(green) << 8 | static_cast(blue); } bool PotionBrewing::areAllEffectsAmbient(vector *effects) @@ -325,7 +325,7 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, } // split by and - int andIndex = (int)definition.find_first_of(L'&', start); + int andIndex = static_cast(definition.find_first_of(L'&', start)); if (andIndex >= 0 && andIndex < end) { int leftSide = parseEffectFormulaValue(definition, start, andIndex - 1, brew); @@ -570,7 +570,7 @@ vector *PotionBrewing::getEffects(int brew, bool includeDis } wstring durationString = effIt->second; - int duration = parseEffectFormulaValue(durationString, 0, (int)durationString.length(), brew); + int duration = parseEffectFormulaValue(durationString, 0, static_cast(durationString.length()), brew); if (duration > 0) { int amplifier = 0; @@ -578,7 +578,7 @@ vector *PotionBrewing::getEffects(int brew, bool includeDis if (ampIt != potionEffectAmplifier.end()) { wstring amplifierString = ampIt->second; - amplifier = parseEffectFormulaValue(amplifierString, 0, (int)amplifierString.length(), brew); + amplifier = parseEffectFormulaValue(amplifierString, 0, static_cast(amplifierString.length()), brew); if (amplifier < 0) { amplifier = 0; @@ -594,11 +594,11 @@ vector *PotionBrewing::getEffects(int brew, bool includeDis // 3, 8, 13, 18.. minutes duration = (SharedConstants::TICKS_PER_SECOND * 60) * (duration * 3 + (duration - 1) * 2); duration >>= amplifier; - duration = (int) Math::round((double) duration * effect->getDurationModifier()); + duration = static_cast(Math::round((double)duration * effect->getDurationModifier())); if ((brew & THROWABLE_MASK) != 0) { - duration = (int) Math::round((double) duration * .75 + .5); + duration = static_cast(Math::round((double)duration * .75 + .5)); } } @@ -756,7 +756,7 @@ int PotionBrewing::applyBrew(int currentBrew, const wstring &formula) { int start = 0; - int end = (int)formula.length(); + int end = static_cast(formula.length()); bool hasValue = false; bool isNot = false; diff --git a/Minecraft.World/PotionItem.h b/Minecraft.World/PotionItem.h index 9fa158c2a..4a43505f2 100644 --- a/Minecraft.World/PotionItem.h +++ b/Minecraft.World/PotionItem.h @@ -7,7 +7,7 @@ class MobEffectInstance; class PotionItem : public Item { private: - static const int DRINK_DURATION = (int) (20 * 1.6); + static const int DRINK_DURATION = static_cast(20 * 1.6); public: static const wstring DEFAULT_ICON; diff --git a/Minecraft.World/PreLoginPacket.cpp b/Minecraft.World/PreLoginPacket.cpp index 4b4742141..5be50ea79 100644 --- a/Minecraft.World/PreLoginPacket.cpp +++ b/Minecraft.World/PreLoginPacket.cpp @@ -92,7 +92,7 @@ void PreLoginPacket::write(DataOutputStream *dos) //throws IOException dos->writeByte(m_friendsOnlyBits); dos->writeInt(m_ugcPlayersVersion); - dos->writeByte((byte)m_dwPlayerCount); + dos->writeByte(static_cast(m_dwPlayerCount)); for(DWORD i = 0; i < m_dwPlayerCount; ++i) { dos->writePlayerUID( m_playerXuids[i] ); @@ -115,5 +115,5 @@ void PreLoginPacket::handle(PacketListener *listener) int PreLoginPacket::getEstimatedSize() { - return 4 + 4 + (int)loginKey.length() + 4 +14 + 4 + 1 + 4; + return 4 + 4 + static_cast(loginKey.length()) + 4 +14 + 4 + 1 + 4; } diff --git a/Minecraft.World/PrimedTnt.cpp b/Minecraft.World/PrimedTnt.cpp index 79fd760fb..39b3ea736 100644 --- a/Minecraft.World/PrimedTnt.cpp +++ b/Minecraft.World/PrimedTnt.cpp @@ -33,7 +33,7 @@ PrimedTnt::PrimedTnt(Level *level, double x, double y, double z, shared_ptr(Math::random() * PI * 2); xd = -sin(rot) * 0.02f; yd = +0.2f; zd = -cos(rot) * 0.02f; @@ -105,7 +105,7 @@ void PrimedTnt::explode() void PrimedTnt::addAdditonalSaveData(CompoundTag *entityTag) { - entityTag->putByte(L"Fuse", (byte) life); + entityTag->putByte(L"Fuse", static_cast(life)); } void PrimedTnt::readAdditionalSaveData(CompoundTag *tag) diff --git a/Minecraft.World/Random.cpp b/Minecraft.World/Random.cpp index 9176bf384..ad8f61654 100644 --- a/Minecraft.World/Random.cpp +++ b/Minecraft.World/Random.cpp @@ -27,22 +27,22 @@ void Random::setSeed(__int64 s) int Random::next(int bits) { seed = (seed * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1); - return (int)(seed >> (48 - bits)); + return static_cast(seed >> (48 - bits)); } void Random::nextBytes(byte *bytes, unsigned int count) { for(unsigned int i = 0; i < count; i++ ) { - bytes[i] = (byte)next(8); + bytes[i] = static_cast(next(8)); } } double Random::nextDouble() { - return (((__int64)next(26) << 27) + next(27)) - / (double)(1LL << 53); + return ((static_cast<__int64>(next(26)) << 27) + next(27)) + / static_cast(1LL << 53); } double Random::nextGaussian() @@ -79,7 +79,7 @@ int Random::nextInt(int n) if ((n & -n) == n) // i.e., n is a power of 2 - return (int)(((__int64)next(31) * n) >> 31); // 4J Stu - Made __int64 instead of long + return static_cast(((__int64)next(31) * n) >> 31); // 4J Stu - Made __int64 instead of long int bits, val; do @@ -92,12 +92,12 @@ int Random::nextInt(int n) float Random::nextFloat() { - return next(24) / ((float)(1 << 24)); + return next(24) / static_cast(1 << 24); } __int64 Random::nextLong() { - return ((__int64)next(32) << 32) + next(32); + return (static_cast<__int64>(next(32)) << 32) + next(32); } bool Random::nextBoolean() diff --git a/Minecraft.World/RandomLevelSource.cpp b/Minecraft.World/RandomLevelSource.cpp index 2b93578a6..3e6994f77 100644 --- a/Minecraft.World/RandomLevelSource.cpp +++ b/Minecraft.World/RandomLevelSource.cpp @@ -187,7 +187,7 @@ float RandomLevelSource::getHeightFalloff(int xxx, int zzz, int* pEMin) if( emin < falloffStart ) { int falloff = falloffStart - emin; - comp = ((float)falloff / (float)falloffStart ) * falloffMax; + comp = (static_cast(falloff) / static_cast(falloffStart) ) * falloffMax; } *pEMin = emin; return comp; @@ -267,7 +267,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) { for (int yc = 0; yc < yChunks; yc++) { - double yStep = 1 / (double) CHUNK_HEIGHT; + double yStep = 1 / static_cast(CHUNK_HEIGHT); double s0 = buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 0)]; double s1 = buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 0)]; double s2 = buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 0)]; @@ -280,7 +280,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) for (int y = 0; y < CHUNK_HEIGHT; y++) { - double xStep = 1 / (double) CHUNK_WIDTH; + double xStep = 1 / static_cast(CHUNK_WIDTH); double _s0 = s0; double _s1 = s1; @@ -292,7 +292,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) int offs = (x + xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | (0 + zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y); int step = 1 << Level::genDepthBits; offs -= step; - double zStep = 1 / (double) CHUNK_WIDTH; + double zStep = 1 / static_cast(CHUNK_WIDTH); double val = _s0; double vala = (_s1 - _s0) * zStep; @@ -315,11 +315,11 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) // 4J - this comparison used to just be with 0.0f but is now varied by block above if ((val += vala) > comp) { - tileId = (byte) Tile::stone_Id; + tileId = static_cast(Tile::stone_Id); } else if (yc * CHUNK_HEIGHT + y < waterHeight) { - tileId = (byte) Tile::calmWater_Id; + tileId = static_cast(Tile::calmWater_Id); } // 4J - more extra code to make sure that the column at the edge of the world is just water & rock, to match the infinite sea that @@ -377,7 +377,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi { Biome *b = biomes[z + x * 16]; float temp = b->getTemperature(); - int runDepth = (int) (depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25); + int runDepth = static_cast(depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25); int run = -1; @@ -397,7 +397,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (y <= 1 + random->nextInt(2)) // 4J - changed to make the bedrock not have bits you can get stuck in // if (y <= 0 + random->nextInt(5)) { - blocks[offs] = (byte) Tile::unbreakable_Id; + blocks[offs] = static_cast(Tile::unbreakable_Id); } else { @@ -414,7 +414,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (runDepth <= 0) { top = 0; - material = (byte) Tile::stone_Id; + material = static_cast(Tile::stone_Id); } else if (y >= waterHeight - 4 && y <= waterHeight + 1) { @@ -428,8 +428,8 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (y < waterHeight && top == 0) { - if (temp < 0.15f) top = (byte) Tile::ice_Id; - else top = (byte) Tile::calmWater_Id; + if (temp < 0.15f) top = static_cast(Tile::ice_Id); + else top = static_cast(Tile::calmWater_Id); } run = runDepth; @@ -445,7 +445,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (run == 0 && material == Tile::sand_Id) { run = random->nextInt(4); - material = (byte) Tile::sandStone_Id; + material = static_cast(Tile::sandStone_Id); } } } @@ -469,7 +469,7 @@ LevelChunk *RandomLevelSource::getChunk(int xOffs, int zOffs) // 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed int blocksSize = Level::genDepth * 16 * 16; - byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + byte *tileData = static_cast(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); XMemSet128(tileData,0,blocksSize); byteArray blocks = byteArray(tileData,blocksSize); // byteArray blocks = byteArray(16 * level->depth * 16); diff --git a/Minecraft.World/Recipes.cpp b/Minecraft.World/Recipes.cpp index 8dcbafdf6..cd41116ac 100644 --- a/Minecraft.World/Recipes.cpp +++ b/Minecraft.World/Recipes.cpp @@ -950,7 +950,7 @@ Recipes::Recipes() L'D'); // 4J - TODO - put these new 1.7.3 items in required place within recipes - addShapedRecipy(new ItemInstance((Tile *)Tile::pistonBase, 1), // + addShapedRecipy(new ItemInstance(static_cast(Tile::pistonBase), 1), // L"sssctcicictg", L"TTT", // L"#X#", // @@ -959,7 +959,7 @@ Recipes::Recipes() L'#', Tile::cobblestone, L'X', Item::ironIngot, L'R', Item::redStone, L'T', Tile::wood, L'M'); - addShapedRecipy(new ItemInstance((Tile *)Tile::pistonStickyBase, 1), // + addShapedRecipy(new ItemInstance(static_cast(Tile::pistonStickyBase), 1), // L"sscictg", L"S", // L"P", // @@ -1072,14 +1072,14 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...) pwchString=va_arg(vl,wchar_t *); wString=pwchString; height++; - width = (int)wString.length(); + width = static_cast(wString.length()); map += wString; break; case L's': pwchString=va_arg(vl,wchar_t *); wString=pwchString; height++; - width = (int)wString.length(); + width = static_cast(wString.length()); map += wString; break; case L'w': @@ -1091,7 +1091,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...) if(!wString.empty()) { height++; - width = (int)wString.length(); + width = static_cast(wString.length()); map += wString; } } @@ -1305,7 +1305,7 @@ void Recipes::buildRecipeIngredientsArray(void) { //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); - int iRecipeC=(int)recipies->size(); + int iRecipeC=static_cast(recipies->size()); m_pRecipeIngredientsRequired= new Recipy::INGREDIENTS_REQUIRED [iRecipeC]; diff --git a/Minecraft.World/RecordingItem.cpp b/Minecraft.World/RecordingItem.cpp index 455323c2b..8e0de1156 100644 --- a/Minecraft.World/RecordingItem.cpp +++ b/Minecraft.World/RecordingItem.cpp @@ -30,7 +30,7 @@ bool RecordingItem::useOn(shared_ptr itemInstance, shared_ptrisClientSide) return true; - ((JukeboxTile *) Tile::jukebox)->setRecord(level, x, y, z, itemInstance); + static_cast(Tile::jukebox)->setRecord(level, x, y, z, itemInstance); level->levelEvent(nullptr, LevelEvent::SOUND_PLAY_RECORDING, x, y, z, id); itemInstance->count--; diff --git a/Minecraft.World/Region.cpp b/Minecraft.World/Region.cpp index e3e91bf0e..e4edce166 100644 --- a/Minecraft.World/Region.cpp +++ b/Minecraft.World/Region.cpp @@ -105,7 +105,7 @@ int Region::getTile(int x, int y, int z) xc -= xc1; zc -= zc1; - if (xc < 0 || xc >= (int)chunks->length || zc < 0 || zc >= (int)(*chunks)[xc]->length) + if (xc < 0 || xc >= static_cast(chunks->length) || zc < 0 || zc >= static_cast((*chunks)[xc]->length)) { return 0; } @@ -124,7 +124,7 @@ void Region::setCachedTiles(unsigned char *tiles, int xc, int zc) int size = 16 * 16 * Level::maxBuildHeight; if( CachedTiles == NULL ) { - CachedTiles = (unsigned char *) malloc(size); + CachedTiles = static_cast(malloc(size)); } memcpy(CachedTiles, tiles, size); } @@ -137,7 +137,7 @@ LevelChunk* Region::getLevelChunk(int x, int y, int z) int xc = (x >> 4) - xc1; int zc = (z >> 4) - zc1; - if (xc < 0 || xc >= (int)chunks->length || zc < 0 || zc >= (int)(*chunks)[xc]->length) + if (xc < 0 || xc >= static_cast(chunks->length) || zc < 0 || zc >= static_cast((*chunks)[xc]->length)) { return NULL; } diff --git a/Minecraft.World/RegionFile.cpp b/Minecraft.World/RegionFile.cpp index 2cfd9078f..10efc2fa2 100644 --- a/Minecraft.World/RegionFile.cpp +++ b/Minecraft.World/RegionFile.cpp @@ -78,7 +78,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) } else { - nSectors = (int) fileEntry->getFileSize() / SECTOR_BYTES; + nSectors = static_cast(fileEntry->getFileSize()) / SECTOR_BYTES; } sectorFree = new vector; sectorFree->reserve(nSectors); @@ -326,7 +326,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync PIXBeginNamedEvent(0,"Scanning for free space\n"); /* scan for a free space large enough to store this chunk */ - int runStart = (int)(find(sectorFree->begin(),sectorFree->end(),true) - sectorFree->begin()); // 4J - was sectorFree.indexOf(true) + int runStart = static_cast(find(sectorFree->begin(), sectorFree->end(), true) - sectorFree->begin()); // 4J - was sectorFree.indexOf(true) int runLength = 0; if (runStart != -1) { @@ -375,7 +375,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync //SetFilePointer(file,0,0,FILE_END); m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END ); - sectorNumber = (int)sectorFree->size(); + sectorNumber = static_cast(sectorFree->size()); #ifndef _CONTENT_PACAKGE //wprintf(L"Writing chunk (%d,%d) in %ls from new sector %d to %d\n", x,z, fileEntry->data.filename, sectorNumber, sectorNumber + sectorsNeeded - 1); #endif @@ -393,7 +393,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync PIXEndNamedEvent(); } } - setTimestamp(x, z, (int) (System::currentTimeMillis() / 1000L)); + setTimestamp(x, z, static_cast(System::currentTimeMillis() / 1000L)); } m_saveFile->ReleaseSaveAccess(); diff --git a/Minecraft.World/RemoveMobEffectPacket.cpp b/Minecraft.World/RemoveMobEffectPacket.cpp index fcda69110..7e2d7c84f 100644 --- a/Minecraft.World/RemoveMobEffectPacket.cpp +++ b/Minecraft.World/RemoveMobEffectPacket.cpp @@ -13,7 +13,7 @@ RemoveMobEffectPacket::RemoveMobEffectPacket() RemoveMobEffectPacket::RemoveMobEffectPacket(int entityId, MobEffectInstance *effect) { this->entityId = entityId; - this->effectId = (byte) (effect->getId() & 0xff); + this->effectId = static_cast(effect->getId() & 0xff); } void RemoveMobEffectPacket::read(DataInputStream *dis) diff --git a/Minecraft.World/RespawnPacket.cpp b/Minecraft.World/RespawnPacket.cpp index 5c04bbebb..d9e37dca5 100644 --- a/Minecraft.World/RespawnPacket.cpp +++ b/Minecraft.World/RespawnPacket.cpp @@ -91,7 +91,7 @@ int RespawnPacket::getEstimatedSize() int length=0; if (m_pLevelType != NULL) { - length = (int)m_pLevelType->getGeneratorName().length(); + length = static_cast(m_pLevelType->getGeneratorName().length()); } return 13+length; } diff --git a/Minecraft.World/SetEntityMotionPacket.cpp b/Minecraft.World/SetEntityMotionPacket.cpp index a0749b749..20d841f17 100644 --- a/Minecraft.World/SetEntityMotionPacket.cpp +++ b/Minecraft.World/SetEntityMotionPacket.cpp @@ -17,9 +17,9 @@ void SetEntityMotionPacket::_init(int id, double xd, double yd, double zd) if (xd > m) xd = m; if (yd > m) yd = m; if (zd > m) zd = m; - xa = (int) (xd * 8000.0); - ya = (int) (yd * 8000.0); - za = (int) (zd * 8000.0); + xa = static_cast(xd * 8000.0); + ya = static_cast(yd * 8000.0); + za = static_cast(zd * 8000.0); // 4J - if we could transmit this as bytes (in 1/16 accuracy) then flag to do so if( ( xa >= (-128 * 16 ) ) && ( ya >= (-128 * 16 ) ) && ( za >= (-128 * 16 ) ) && ( xa < (128 * 16 ) ) && ( ya < (128 * 16 ) ) && ( za < (128 * 16 ) ) ) @@ -53,9 +53,9 @@ void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException id = idAndFlag & 0x07ff; if( idAndFlag & 0x0800 ) { - xa = (int)dis->readByte(); - ya = (int)dis->readByte(); - za = (int)dis->readByte(); + xa = static_cast(dis->readByte()); + ya = static_cast(dis->readByte()); + za = static_cast(dis->readByte()); xa = ( xa << 24 ) >> 24; ya = ( ya << 24 ) >> 24; za = ( za << 24 ) >> 24; diff --git a/Minecraft.World/SetHealthPacket.cpp b/Minecraft.World/SetHealthPacket.cpp index 639cacd8b..4557f7bb4 100644 --- a/Minecraft.World/SetHealthPacket.cpp +++ b/Minecraft.World/SetHealthPacket.cpp @@ -32,7 +32,7 @@ void SetHealthPacket::read(DataInputStream *dis) //throws IOException saturation = dis->readFloat(); // exhaustion = dis.readFloat(); - damageSource = (ETelemetryChallenges)dis->readByte(); + damageSource = static_cast(dis->readByte()); } void SetHealthPacket::write(DataOutputStream *dos) //throws IOException diff --git a/Minecraft.World/ShapedRecipy.cpp b/Minecraft.World/ShapedRecipy.cpp index 15ccca2de..be1adb0b7 100644 --- a/Minecraft.World/ShapedRecipy.cpp +++ b/Minecraft.World/ShapedRecipy.cpp @@ -92,7 +92,7 @@ shared_ptr ShapedRecipy::assemble(shared_ptr cr if (item != NULL && item->hasTag()) { - result->setTag((CompoundTag *) item->tag->copy()); + result->setTag(static_cast(item->tag->copy())); } } } diff --git a/Minecraft.World/ShapelessRecipy.cpp b/Minecraft.World/ShapelessRecipy.cpp index 44bf6a54f..21d964b7d 100644 --- a/Minecraft.World/ShapelessRecipy.cpp +++ b/Minecraft.World/ShapelessRecipy.cpp @@ -73,7 +73,7 @@ shared_ptr ShapelessRecipy::assemble(shared_ptr int ShapelessRecipy::size() { - return (int)ingredients->size(); + return static_cast(ingredients->size()); } // 4J-PB diff --git a/Minecraft.World/SharedMonsterAttributes.cpp b/Minecraft.World/SharedMonsterAttributes.cpp index 3ff841973..12d467f2f 100644 --- a/Minecraft.World/SharedMonsterAttributes.cpp +++ b/Minecraft.World/SharedMonsterAttributes.cpp @@ -101,6 +101,6 @@ void SharedMonsterAttributes::loadAttribute(AttributeInstance *instance, Compoun AttributeModifier *SharedMonsterAttributes::loadAttributeModifier(CompoundTag *tag) { - eMODIFIER_ID id = (eMODIFIER_ID)tag->getInt(L"UUID"); + eMODIFIER_ID id = static_cast(tag->getInt(L"UUID")); return new AttributeModifier(id, tag->getDouble(L"Amount"), tag->getInt(L"Operation")); } \ No newline at end of file diff --git a/Minecraft.World/Sheep.cpp b/Minecraft.World/Sheep.cpp index 32379c2a1..e865d899a 100644 --- a/Minecraft.World/Sheep.cpp +++ b/Minecraft.World/Sheep.cpp @@ -100,7 +100,7 @@ void Sheep::defineSynchedData() Animal::defineSynchedData(); // sheared and color share a byte - entityData->define(DATA_WOOL_ID, ((byte) 0)); //was new Byte((byte), 0) + entityData->define(DATA_WOOL_ID, static_cast(0)); //was new Byte((byte), 0) } void Sheep::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) @@ -141,16 +141,16 @@ float Sheep::getHeadEatPositionScale(float a) } if (eatAnimationTick < 4) { - return ((float) eatAnimationTick - a) / 4.0f; + return (static_cast(eatAnimationTick) - a) / 4.0f; } - return -((float) (eatAnimationTick - EAT_ANIMATION_TICKS) - a) / 4.0f; + return -(static_cast(eatAnimationTick - EAT_ANIMATION_TICKS) - a) / 4.0f; } float Sheep::getHeadEatAngleScale(float a) { if (eatAnimationTick > 4 && eatAnimationTick <= (EAT_ANIMATION_TICKS - 4)) { - float scale = ((float) (eatAnimationTick - 4) - a) / (float) (EAT_ANIMATION_TICKS - 8); + float scale = (static_cast(eatAnimationTick - 4) - a) / static_cast(EAT_ANIMATION_TICKS - 8); return PI * .20f + PI * .07f * Mth::sin(scale * 28.7f); } if (eatAnimationTick > 0) @@ -196,7 +196,7 @@ void Sheep::addAdditonalSaveData(CompoundTag *tag) { Animal::addAdditonalSaveData(tag); tag->putBoolean(L"Sheared", isSheared()); - tag->putByte(L"Color", (byte) getColor()); + tag->putByte(L"Color", static_cast(getColor())); } void Sheep::readAdditionalSaveData(CompoundTag *tag) @@ -234,7 +234,7 @@ int Sheep::getColor() void Sheep::setColor(int color) { byte current = entityData->getByte(DATA_WOOL_ID); - entityData->set(DATA_WOOL_ID, (byte) ((current & 0xf0) | (color & 0x0f))); + entityData->set(DATA_WOOL_ID, static_cast((current & 0xf0) | (color & 0x0f))); } bool Sheep::isSheared() @@ -247,11 +247,11 @@ void Sheep::setSheared(bool value) byte current = entityData->getByte(DATA_WOOL_ID); if (value) { - entityData->set(DATA_WOOL_ID, (byte) (current | 0x10)); + entityData->set(DATA_WOOL_ID, static_cast(current | 0x10)); } else { - entityData->set(DATA_WOOL_ID, (byte) (current & ~0x10)); + entityData->set(DATA_WOOL_ID, static_cast(current & ~0x10)); } } diff --git a/Minecraft.World/ShortTag.h b/Minecraft.World/ShortTag.h index 989e1fb14..cbe0b55fb 100644 --- a/Minecraft.World/ShortTag.h +++ b/Minecraft.World/ShortTag.h @@ -28,7 +28,7 @@ class ShortTag : public Tag { if (Tag::equals(obj)) { - ShortTag *o = (ShortTag *) obj; + ShortTag *o = static_cast(obj); return data == o->data; } return false; diff --git a/Minecraft.World/SignTileEntity.cpp b/Minecraft.World/SignTileEntity.cpp index dc189102b..a90ca5017 100644 --- a/Minecraft.World/SignTileEntity.cpp +++ b/Minecraft.World/SignTileEntity.cpp @@ -181,7 +181,7 @@ void SignTileEntity::SetMessage(int iIndex,wstring &wsText) int SignTileEntity::StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE *pResults) { // results will be in m_pStringVerifyResponse - SignTileEntity *pClass=(SignTileEntity *)lpParam; + SignTileEntity *pClass=static_cast(lpParam); pClass->m_bVerified=true; pClass->m_bCensored=false; @@ -195,7 +195,7 @@ int SignTileEntity::StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE * if(!pClass->level->isClientSide) { - ServerLevel *serverLevel = (ServerLevel *)pClass->level; + ServerLevel *serverLevel = static_cast(pClass->level); // 4J Stu - This callback gets called on the main thread, but tried to access things on the server thread. Change to go through the protected method. //pClass->level->sendTileUpdated(pClass->x, pClass->y, pClass->z); serverLevel->queueSendTileUpdate(pClass->x, pClass->y, pClass->z); diff --git a/Minecraft.World/SignUpdatePacket.cpp b/Minecraft.World/SignUpdatePacket.cpp index 7b3a32179..10cc223ee 100644 --- a/Minecraft.World/SignUpdatePacket.cpp +++ b/Minecraft.World/SignUpdatePacket.cpp @@ -66,6 +66,6 @@ int SignUpdatePacket::getEstimatedSize() l+=sizeof(byte); for (int i = 0; i < MAX_SIGN_LINES; i++) - l += (int)lines[i].length(); + l += static_cast(lines[i].length()); return l; } diff --git a/Minecraft.World/SimplexNoise.cpp b/Minecraft.World/SimplexNoise.cpp index 469e0b416..35b86add9 100644 --- a/Minecraft.World/SimplexNoise.cpp +++ b/Minecraft.World/SimplexNoise.cpp @@ -49,7 +49,7 @@ SimplexNoise::~SimplexNoise() int SimplexNoise::fastfloor(double x) { - return x > 0 ? (int) x : (int) x - 1; + return x > 0 ? static_cast(x) : static_cast(x) - 1; } double SimplexNoise::dot(int *g, double x, double y) diff --git a/Minecraft.World/Skeleton.cpp b/Minecraft.World/Skeleton.cpp index 9afb95c6b..e7db69430 100644 --- a/Minecraft.World/Skeleton.cpp +++ b/Minecraft.World/Skeleton.cpp @@ -63,7 +63,7 @@ void Skeleton::defineSynchedData() { Monster::defineSynchedData(); - entityData->define(DATA_TYPE_ID, (byte) TYPE_DEFAULT); + entityData->define(DATA_TYPE_ID, static_cast(TYPE_DEFAULT)); } bool Skeleton::useNewAi() @@ -114,7 +114,7 @@ void Skeleton::aiStep() if (level->isDay() && !level->isClientSide) { float br = getBrightness(1); - if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && level->canSeeSky(Mth::floor(x), (int)floor( y + 0.5 ), Mth::floor(z))) + if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && level->canSeeSky(Mth::floor(x), static_cast(floor(y + 0.5)), Mth::floor(z))) { bool burn = true; @@ -289,7 +289,7 @@ void Skeleton::performRangedAttack(shared_ptr target, float power) if (damageBonus > 0) { - arrow->setBaseDamage(arrow->getBaseDamage() + (double) damageBonus * .5 + .5); + arrow->setBaseDamage(arrow->getBaseDamage() + static_cast(damageBonus) * .5 + .5); } if (knockbackBonus > 0) { @@ -311,7 +311,7 @@ int Skeleton::getSkeletonType() void Skeleton::setSkeletonType(int type) { - entityData->set(DATA_TYPE_ID, (byte) type); + entityData->set(DATA_TYPE_ID, static_cast(type)); fireImmune = type == TYPE_WITHER; if (type == TYPE_WITHER) @@ -340,7 +340,7 @@ void Skeleton::readAdditionalSaveData(CompoundTag *tag) void Skeleton::addAdditonalSaveData(CompoundTag *entityTag) { Monster::addAdditonalSaveData(entityTag); - entityTag->putByte(L"SkeletonType", (byte) getSkeletonType()); + entityTag->putByte(L"SkeletonType", static_cast(getSkeletonType())); } void Skeleton::setEquippedSlot(int slot, shared_ptr item) diff --git a/Minecraft.World/SkullItem.cpp b/Minecraft.World/SkullItem.cpp index 8fabc3cd6..f0356a965 100644 --- a/Minecraft.World/SkullItem.cpp +++ b/Minecraft.World/SkullItem.cpp @@ -57,7 +57,7 @@ bool SkullItem::useOn(shared_ptr instance, shared_ptr play } skull->setSkullType(instance->getAuxValue(), extra); skull->setRotation(rot); - ((SkullTile *) Tile::skull)->checkMobSpawn(level, x, y, z, skull); + static_cast(Tile::skull)->checkMobSpawn(level, x, y, z, skull); } instance->count--; diff --git a/Minecraft.World/SkullTileEntity.cpp b/Minecraft.World/SkullTileEntity.cpp index ea19b4469..404332d46 100644 --- a/Minecraft.World/SkullTileEntity.cpp +++ b/Minecraft.World/SkullTileEntity.cpp @@ -13,8 +13,8 @@ SkullTileEntity::SkullTileEntity() void SkullTileEntity::save(CompoundTag *tag) { TileEntity::save(tag); - tag->putByte(L"SkullType", (BYTE) (skullType & 0xff)); - tag->putByte(L"Rot", (BYTE) (rotation & 0xff)); + tag->putByte(L"SkullType", static_cast(skullType & 0xff)); + tag->putByte(L"Rot", static_cast(rotation & 0xff)); tag->putString(L"ExtraType", extraType); } diff --git a/Minecraft.World/Slime.cpp b/Minecraft.World/Slime.cpp index eb80d09c8..5f93dbfb2 100644 --- a/Minecraft.World/Slime.cpp +++ b/Minecraft.World/Slime.cpp @@ -47,12 +47,12 @@ void Slime::defineSynchedData() { Mob::defineSynchedData(); - entityData->define(ID_SIZE, (byte) 1); + entityData->define(ID_SIZE, static_cast(1)); } void Slime::setSize(int size) { - entityData->set(ID_SIZE, (byte) size); + entityData->set(ID_SIZE, static_cast(size)); setSize(0.6f * size, 0.6f * size); setPos(x, y, z); getAttribute(SharedMonsterAttributes::MAX_HEALTH)->setBaseValue(size * size); @@ -155,7 +155,7 @@ void Slime::serverAiStep() // 4J Removed TU7 to bring forward change to fix lava slime render in MP //targetSquish = 1; xxa = 1 - random->nextFloat() * 2; - yya = (float) 1 * getSize(); + yya = static_cast(1) * getSize(); } else { diff --git a/Minecraft.World/Socket.cpp b/Minecraft.World/Socket.cpp index bd0c2032f..1a7d27caa 100644 --- a/Minecraft.World/Socket.cpp +++ b/Minecraft.World/Socket.cpp @@ -330,7 +330,7 @@ void Socket::SocketOutputStreamLocal::write(unsigned int b) return; } EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); - s_hostQueue[m_queueIdx].push((byte)b); + s_hostQueue[m_queueIdx].push(static_cast(b)); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); } @@ -442,7 +442,7 @@ void Socket::SocketOutputStreamNetwork::write(unsigned int b) if( m_streamOpen != true ) return; byteArray barray; byte bb; - bb = (byte)b; + bb = static_cast(b); barray.data = &bb; barray.length = 1; write(barray, 0, 1); diff --git a/Minecraft.World/SparseDataStorage.cpp b/Minecraft.World/SparseDataStorage.cpp index 6db131e78..15cd33acd 100644 --- a/Minecraft.World/SparseDataStorage.cpp +++ b/Minecraft.World/SparseDataStorage.cpp @@ -28,7 +28,7 @@ SparseDataStorage::SparseDataStorage() #ifdef _XBOX unsigned char *planeIndices = (unsigned char *)XPhysicalAlloc(128 * 128, MAXULONG_PTR, 4096, PAGE_READWRITE); #else - unsigned char *planeIndices = (unsigned char *)malloc(128 * 128); + unsigned char *planeIndices = static_cast(malloc(128 * 128)); #endif unsigned char *data = planeIndices + 128; planeIndices[0] = ALL_0_INDEX; @@ -51,7 +51,7 @@ SparseDataStorage::SparseDataStorage(bool isUpper) { // Allocate using physical alloc. As this will (by default) return memory from the pool of 4KB pages, the address will in the range of MM_PHYSICAL_4KB_BASE upwards. We can use // this fact to identify the allocation later, and so free it with the corresponding call to XPhysicalFree. - unsigned char *planeIndices = (unsigned char *)malloc(128); + unsigned char *planeIndices = static_cast(malloc(128)); for( int i = 0; i < 128; i++ ) { planeIndices[i] = ALL_0_INDEX; @@ -92,7 +92,7 @@ SparseDataStorage::SparseDataStorage(SparseDataStorage *copyFrom) int sourceCount = (sourceDataAndCount >> 48 ) & 0xffff; // Allocate & copy indices ( 128 bytes ) and any allocated planes (128 * count) - unsigned char *destIndicesAndData = (unsigned char *)malloc( sourceCount * 128 + 128 ); + unsigned char *destIndicesAndData = static_cast(malloc(sourceCount * 128 + 128)); // AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called. // This should never happen and this isn't a proper solution but fixes it for now. @@ -146,7 +146,7 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset) } // Allocate required storage - unsigned char *planeIndices = (unsigned char *)malloc(128 * allocatedPlaneCount + 128); + unsigned char *planeIndices = static_cast(malloc(128 * allocatedPlaneCount + 128)); unsigned char *data = planeIndices + 128; XMemCpy(planeIndices, _planeIndices, 128); @@ -178,7 +178,7 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset) #pragma warning ( disable : 4826 ) __int64 newDataAndCount = ((__int64) planeIndices) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) - newDataAndCount |= ((__int64)allocatedPlaneCount) << 48; + newDataAndCount |= static_cast<__int64>(allocatedPlaneCount) << 48; updateDataAndCount( newDataAndCount ); } @@ -341,7 +341,7 @@ int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, i } ptrdiff_t count = pucIn - &dataIn.data[offset]; - return (int)count; + return static_cast(count); } // Updates the data at offset position dataInOut with a region of data information - external ordering compatible with java DataLayer @@ -371,7 +371,7 @@ int SparseDataStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z0 } ptrdiff_t count = pucOut - &dataInOut.data[offset]; - return (int)count; + return static_cast(count); } void SparseDataStorage::addNewPlane(int y) @@ -383,7 +383,7 @@ void SparseDataStorage::addNewPlane(int y) __int64 lastDataAndCount = dataAndCount; // Unpack count & data pointer - int lastLinesUsed = (int)(( lastDataAndCount >> 48 ) & 0xffff); + int lastLinesUsed = static_cast((lastDataAndCount >> 48) & 0xffff); unsigned char *lastDataPointer = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff); // Find out what to prefill the newly allocated line with @@ -394,7 +394,7 @@ void SparseDataStorage::addNewPlane(int y) int linesUsed = lastLinesUsed + 1; // Allocate new memory storage, copy over anything from old storage, and initialise remainder - unsigned char *dataPointer = (unsigned char *)malloc(linesUsed * 128 + 128); + unsigned char *dataPointer = static_cast(malloc(linesUsed * 128 + 128)); XMemCpy( dataPointer, lastDataPointer, 128 * lastLinesUsed + 128); XMemSet( dataPointer + ( 128 * lastLinesUsed ) + 128, 0, 128 ); dataPointer[y] = lastLinesUsed; @@ -403,7 +403,7 @@ void SparseDataStorage::addNewPlane(int y) #pragma warning ( disable : 4826 ) __int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) - newDataAndCount |= ((__int64)linesUsed) << 48; + newDataAndCount |= static_cast<__int64>(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 @@ -543,7 +543,7 @@ int SparseDataStorage::compress() if( needsCompressed ) { - unsigned char *newIndicesAndData = (unsigned char *)malloc( 128 + 128 * planesToAlloc ); + unsigned char *newIndicesAndData = static_cast(malloc(128 + 128 * planesToAlloc)); unsigned char *pucData = newIndicesAndData + 128; XMemCpy( newIndicesAndData, _planeIndices, 128 ); @@ -560,7 +560,7 @@ int SparseDataStorage::compress() #pragma warning ( disable : 4826 ) __int64 newDataAndCount = ((__int64) newIndicesAndData) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) - newDataAndCount |= ((__int64)planesToAlloc) << 48; + newDataAndCount |= static_cast<__int64>(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 @@ -586,7 +586,7 @@ int SparseDataStorage::compress() } else { - return (int)((lastDataAndCount >> 48 ) & 0xffff); + return static_cast((lastDataAndCount >> 48) & 0xffff); } } @@ -612,14 +612,14 @@ void SparseDataStorage::write(DataOutputStream *dos) void SparseDataStorage::read(DataInputStream *dis) { int count = dis->readInt(); - unsigned char *dataPointer = (unsigned char *)malloc(count * 128 + 128); + unsigned char *dataPointer = static_cast(malloc(count * 128 + 128)); byteArray wrapper(dataPointer, count * 128 + 128); dis->readFully(wrapper); #pragma warning ( disable : 4826 ) __int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) - newDataAndCount |= ((__int64)count) << 48; + newDataAndCount |= static_cast<__int64>(count) << 48; updateDataAndCount(newDataAndCount); } diff --git a/Minecraft.World/SparseLightStorage.cpp b/Minecraft.World/SparseLightStorage.cpp index f9a2f0cbd..f0dc9f7ce 100644 --- a/Minecraft.World/SparseLightStorage.cpp +++ b/Minecraft.World/SparseLightStorage.cpp @@ -28,7 +28,7 @@ SparseLightStorage::SparseLightStorage(bool sky) #ifdef _XBOX unsigned char *planeIndices = (unsigned char *)XPhysicalAlloc(128 * 128, MAXULONG_PTR, 4096, PAGE_READWRITE); #else - unsigned char *planeIndices = (unsigned char *)malloc(128 * 128); + unsigned char *planeIndices = static_cast(malloc(128 * 128)); #endif unsigned char *data = planeIndices + 128; planeIndices[127] = sky ? ALL_15_INDEX : ALL_0_INDEX; @@ -51,7 +51,7 @@ SparseLightStorage::SparseLightStorage(bool sky, bool isUpper) { // Allocate using physical alloc. As this will (by default) return memory from the pool of 4KB pages, the address will in the range of MM_PHYSICAL_4KB_BASE upwards. We can use // this fact to identify the allocation later, and so free it with the corresponding call to XPhysicalFree. - unsigned char *planeIndices = (unsigned char *)malloc(128); + unsigned char *planeIndices = static_cast(malloc(128)); for( int i = 0; i < 128; i++ ) { planeIndices[i] = sky ? ALL_15_INDEX : ALL_0_INDEX; @@ -92,7 +92,7 @@ SparseLightStorage::SparseLightStorage(SparseLightStorage *copyFrom) int sourceCount = (sourceDataAndCount >> 48 ) & 0xffff; // Allocate & copy indices ( 128 bytes ) and any allocated planes (128 * count) - unsigned char *destIndicesAndData = (unsigned char *)malloc( sourceCount * 128 + 128 ); + unsigned char *destIndicesAndData = static_cast(malloc(sourceCount * 128 + 128)); // AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called. // This should never happen and this isn't a proper solution but fixes it for now. @@ -150,7 +150,7 @@ void SparseLightStorage::setData(byteArray dataIn, unsigned int inOffset) } // Allocate required storage - unsigned char *planeIndices = (unsigned char *)malloc(128 * allocatedPlaneCount + 128); + unsigned char *planeIndices = static_cast(malloc(128 * allocatedPlaneCount + 128)); unsigned char *data = planeIndices + 128; XMemCpy(planeIndices, _planeIndices, 128); @@ -182,7 +182,7 @@ void SparseLightStorage::setData(byteArray dataIn, unsigned int inOffset) #pragma warning ( disable : 4826 ) __int64 newDataAndCount = ((__int64) planeIndices) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) - newDataAndCount |= ((__int64)allocatedPlaneCount) << 48; + newDataAndCount |= static_cast<__int64>(allocatedPlaneCount) << 48; updateDataAndCount( newDataAndCount ); } @@ -305,7 +305,7 @@ void SparseLightStorage::set(int x, int y, int z, int val) void SparseLightStorage::setAllBright() { - unsigned char *planeIndices = (unsigned char *)malloc(128); + unsigned char *planeIndices = static_cast(malloc(128)); for( int i = 0; i < 128; i++ ) { planeIndices[i] = ALL_15_INDEX; @@ -346,7 +346,7 @@ int SparseLightStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, } ptrdiff_t count = pucIn - &dataIn.data[offset]; - return (int)count; + return static_cast(count); } // Updates the data at offset position dataInOut with a region of lighting information - external ordering compatible with java DataLayer @@ -376,7 +376,7 @@ int SparseLightStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z } ptrdiff_t count = pucOut - &dataInOut.data[offset]; - return (int)count; + return static_cast(count); } void SparseLightStorage::addNewPlane(int y) @@ -388,7 +388,7 @@ void SparseLightStorage::addNewPlane(int y) __int64 lastDataAndCount = dataAndCount; // Unpack count & data pointer - int lastLinesUsed = (int)(( lastDataAndCount >> 48 ) & 0xffff); + int lastLinesUsed = static_cast((lastDataAndCount >> 48) & 0xffff); unsigned char *lastDataPointer = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff); // Find out what to prefill the newly allocated line with @@ -400,7 +400,7 @@ void SparseLightStorage::addNewPlane(int y) int linesUsed = lastLinesUsed + 1; // Allocate new memory storage, copy over anything from old storage, and initialise remainder - unsigned char *dataPointer = (unsigned char *)malloc(linesUsed * 128 + 128); + unsigned char *dataPointer = static_cast(malloc(linesUsed * 128 + 128)); XMemCpy( dataPointer, lastDataPointer, 128 * lastLinesUsed + 128); XMemSet( dataPointer + ( 128 * lastLinesUsed ) + 128, prefill, 128 ); dataPointer[y] = lastLinesUsed; @@ -409,7 +409,7 @@ void SparseLightStorage::addNewPlane(int y) #pragma warning ( disable : 4826 ) __int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) - newDataAndCount |= ((__int64)linesUsed) << 48; + newDataAndCount |= static_cast<__int64>(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 @@ -560,7 +560,7 @@ int SparseLightStorage::compress() if( needsCompressed ) { - unsigned char *newIndicesAndData = (unsigned char *)malloc( 128 + 128 * planesToAlloc ); + unsigned char *newIndicesAndData = static_cast(malloc(128 + 128 * planesToAlloc)); unsigned char *pucData = newIndicesAndData + 128; XMemCpy( newIndicesAndData, _planeIndices, 128 ); @@ -577,7 +577,7 @@ int SparseLightStorage::compress() #pragma warning ( disable : 4826 ) __int64 newDataAndCount = ((__int64) newIndicesAndData) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) - newDataAndCount |= ((__int64)planesToAlloc) << 48; + newDataAndCount |= static_cast<__int64>(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 @@ -603,7 +603,7 @@ int SparseLightStorage::compress() } else { - return (int)((lastDataAndCount >> 48 ) & 0xffff); + return static_cast((lastDataAndCount >> 48) & 0xffff); } } @@ -629,14 +629,14 @@ void SparseLightStorage::write(DataOutputStream *dos) void SparseLightStorage::read(DataInputStream *dis) { int count = dis->readInt(); - unsigned char *dataPointer = (unsigned char *)malloc(count * 128 + 128); + unsigned char *dataPointer = static_cast(malloc(count * 128 + 128)); byteArray wrapper(dataPointer, count * 128 + 128); dis->readFully(wrapper); #pragma warning ( disable : 4826 ) __int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) - newDataAndCount |= ((__int64)count) << 48; + newDataAndCount |= static_cast<__int64>(count) << 48; updateDataAndCount( newDataAndCount ); } diff --git a/Minecraft.World/Spider.cpp b/Minecraft.World/Spider.cpp index 49997db39..ffce490d8 100644 --- a/Minecraft.World/Spider.cpp +++ b/Minecraft.World/Spider.cpp @@ -31,7 +31,7 @@ void Spider::defineSynchedData() { Monster::defineSynchedData(); - entityData->define(DATA_FLAGS_ID, (byte) 0); + entityData->define(DATA_FLAGS_ID, static_cast(0)); } void Spider::tick() @@ -109,7 +109,7 @@ void Spider::checkHurtTarget(shared_ptr target, float d) { double xdd = target->x - x; double zdd = target->z - z; - float dd = (float) sqrt(xdd * xdd + zdd * zdd); + float dd = static_cast(sqrt(xdd * xdd + zdd * zdd)); xd = (xdd / dd * 0.5f) * 0.8f + xd * 0.2f; zd = (zdd / dd * 0.5f) * 0.8f + zd * 0.2f; yd = 0.4f; @@ -208,12 +208,12 @@ MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /* if (level->difficulty > Difficulty::NORMAL && level->random->nextFloat() < SPIDER_SPECIAL_EFFECT_CHANCE * level->getDifficulty(x, y, z)) { - ((SpiderEffectsGroupData *) groupData)->setRandomEffect(level->random); + static_cast(groupData)->setRandomEffect(level->random); } } if ( dynamic_cast( groupData ) != NULL) { - int effect = ((SpiderEffectsGroupData *) groupData)->effectId; + int effect = static_cast(groupData)->effectId; if (effect > 0 && MobEffect::effects[effect] != NULL) { addEffect(new MobEffectInstance(effect, Integer::MAX_VALUE)); diff --git a/Minecraft.World/Squid.cpp b/Minecraft.World/Squid.cpp index 7aae36154..4539d5ee9 100644 --- a/Minecraft.World/Squid.cpp +++ b/Minecraft.World/Squid.cpp @@ -140,10 +140,10 @@ void Squid::aiStep() double horizontalMovement = sqrt(xd * xd + zd * zd); - yBodyRot += ((-(float) atan2(xd, zd) * 180 / PI) - yBodyRot) * 0.1f; + yBodyRot += ((-static_cast(atan2(xd, zd)) * 180 / PI) - yBodyRot) * 0.1f; yRot = yBodyRot; zBodyRot = zBodyRot + (float) PI * rotateSpeed * 1.5f; - xBodyRot += ((-(float) atan2(horizontalMovement, yd) * 180 / PI) - xBodyRot) * 0.1f; + xBodyRot += ((-static_cast(atan2(horizontalMovement, yd)) * 180 / PI) - xBodyRot) * 0.1f; } else { diff --git a/Minecraft.World/Stats.cpp b/Minecraft.World/Stats.cpp index c8a615ff5..3d4020b17 100644 --- a/Minecraft.World/Stats.cpp +++ b/Minecraft.World/Stats.cpp @@ -67,13 +67,13 @@ Stat *Stats::completeTheEnd = NULL; // The number of times this player has been void Stats::staticCtor() { - Stats::walkOneM = (new GeneralStat(2000, L"stat.walkOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::swimOneM = (new GeneralStat(2001, L"stat.swimOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::fallOneM = (new GeneralStat(2002, L"stat.fallOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::climbOneM = (new GeneralStat(2003, L"stat.climbOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::minecartOneM = (new GeneralStat(2004, L"stat.minecartOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::boatOneM = (new GeneralStat(2005, L"stat.boatOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::pigOneM = (new GeneralStat(2006, L"stat.pigOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); + Stats::walkOneM = (new GeneralStat(2000, L"stat.walkOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::swimOneM = (new GeneralStat(2001, L"stat.swimOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::fallOneM = (new GeneralStat(2002, L"stat.fallOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::climbOneM = (new GeneralStat(2003, L"stat.climbOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::minecartOneM = (new GeneralStat(2004, L"stat.minecartOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::boatOneM = (new GeneralStat(2005, L"stat.boatOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::pigOneM = (new GeneralStat(2006, L"stat.pigOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); Stats::portalsCreated = (new GeneralStat(2007, L"stat.portalsUsed"))->postConstruct(); Stats::cowsMilked = (new GeneralStat(2008, L"stat.cowsMilked"))->postConstruct(); Stats::netherLavaCollected = (new GeneralStat(2009, L"stat.netherLavaCollected"))->postConstruct(); diff --git a/Minecraft.World/StemTile.cpp b/Minecraft.World/StemTile.cpp index bf9b058d1..69ced0d27 100644 --- a/Minecraft.World/StemTile.cpp +++ b/Minecraft.World/StemTile.cpp @@ -34,7 +34,7 @@ void StemTile::tick(Level *level, int x, int y, int z, Random *random) float growthSpeed = getGrowthSpeed(level, x, y, z); // 4J Stu - Brought forward change from 1.2.3 to make fruit more likely to grow - if (random->nextInt((int) (25 / growthSpeed) + 1) == 0) + if (random->nextInt(static_cast(25 / growthSpeed) + 1) == 0) { int age = level->getData(x, y, z); if (age < 7) @@ -149,10 +149,10 @@ void StemTile::updateDefaultShape() void StemTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr forceEntity) // 4J added forceData, forceEntity param { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); tls->yy1 = (level->getData(x, y, z) * 2 + 2) / 16.0f; float ss = 0.125f; - setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float) tls->yy1, 0.5f + ss); + setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, static_cast(tls->yy1), 0.5f + ss); } int StemTile::getRenderShape() diff --git a/Minecraft.World/StringHelpers.cpp b/Minecraft.World/StringHelpers.cpp index 6985c88f8..43b4f58b4 100644 --- a/Minecraft.World/StringHelpers.cpp +++ b/Minecraft.World/StringHelpers.cpp @@ -10,10 +10,10 @@ wstring toLower(const wstring& a) wstring trimString(const wstring& a) { wstring b; - int start = (int)a.find_first_not_of(L" \t\n\r"); - int end = (int)a.find_last_not_of(L" \t\n\r"); + int start = static_cast(a.find_first_not_of(L" \t\n\r")); + int end = static_cast(a.find_last_not_of(L" \t\n\r")); if( start == wstring::npos ) start = 0; - if( end == wstring::npos ) end = (int)a.size()-1; + if( end == wstring::npos ) end = static_cast(a.size())-1; b = a.substr(start,(end-start)+1); return b; } @@ -62,7 +62,7 @@ const char *wstringtofilename(const wstring& name) if(c=='/') c='\\'; #endif assert(c<128); // Will we have to do any conversion of non-ASCII characters in filenames? - buf[i] = (char)c; + buf[i] = static_cast(c); } buf[name.length()] = 0; return buf; @@ -76,7 +76,7 @@ const char *wstringtochararray(const wstring& name) { wchar_t c = name[i]; assert(c<128); // Will we have to do any conversion of non-ASCII characters in filenames? - buf[i] = (char)c; + buf[i] = static_cast(c); } buf[name.length()] = 0; return buf; diff --git a/Minecraft.World/StringTag.h b/Minecraft.World/StringTag.h index 8eb0eb7fd..36b603689 100644 --- a/Minecraft.World/StringTag.h +++ b/Minecraft.World/StringTag.h @@ -34,7 +34,7 @@ class StringTag : public Tag { if (Tag::equals(obj)) { - StringTag *o = (StringTag *) obj; + StringTag *o = static_cast(obj); return ((data.empty() && o->data.empty()) || (!data.empty() && data.compare(o->data) == 0)); } return false; diff --git a/Minecraft.World/StrongholdFeature.cpp b/Minecraft.World/StrongholdFeature.cpp index fa85dc429..2ce875950 100644 --- a/Minecraft.World/StrongholdFeature.cpp +++ b/Minecraft.World/StrongholdFeature.cpp @@ -136,8 +136,8 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat) } #endif - int selectedX = (int) (Math::round(cos(angle) * dist)); - int selectedZ = (int) (Math::round(sin(angle) * dist)); + int selectedX = static_cast(Math::round(cos(angle) * dist)); + int selectedZ = static_cast(Math::round(sin(angle) * dist)); TilePos *position = level->getBiomeSource()->findBiome((selectedX << 4) + 8, (selectedZ << 4) + 8, 7 << 4, allowedBiomes, &random); if (position != NULL) @@ -164,7 +164,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat) delete strongholdPos[i]; strongholdPos[i] = new ChunkPos(selectedX, selectedZ); - angle += PI * 2.0 / (double) strongholdPos_length; + angle += PI * 2.0 / static_cast(strongholdPos_length); } // 4J Stu - We want to make sure that we have at least one stronghold in this world @@ -172,7 +172,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat) // 4J Stu - Randomise the angles for retries as well #ifdef _LARGE_WORLDS - angle = random.nextDouble() * PI * 2.0 * circle / (double) spread; + angle = random.nextDouble() * PI * 2.0 * circle / static_cast(spread); #endif } while(!hasFoundValidPos && findAttempts < MAX_STRONGHOLD_ATTEMPTS); @@ -225,7 +225,7 @@ StructureStart *StrongholdFeature::createStructureStart(int x, int z) StrongholdStart *start = new StrongholdStart(level, random, x, z); // 4J - front() was get(0) - while (start->getPieces()->empty() || ((StrongholdPieces::StartPiece *) start->getPieces()->front())->portalRoomPiece == NULL) + while (start->getPieces()->empty() || static_cast(start->getPieces()->front())->portalRoomPiece == NULL) { delete start; // regenerate stronghold without changing seed @@ -254,7 +254,7 @@ StrongholdFeature::StrongholdStart::StrongholdStart(Level *level, Random *random vector *pendingChildren = &startRoom->pendingChildren; while (!pendingChildren->empty()) { - int pos = random->nextInt((int)pendingChildren->size()); + int pos = random->nextInt(static_cast(pendingChildren->size())); auto it = pendingChildren->begin() + pos; StructurePiece *structurePiece = *it; pendingChildren->erase(it); diff --git a/Minecraft.World/StrongholdPieces.cpp b/Minecraft.World/StrongholdPieces.cpp index 383be42c4..e1f912bc0 100644 --- a/Minecraft.World/StrongholdPieces.cpp +++ b/Minecraft.World/StrongholdPieces.cpp @@ -268,7 +268,7 @@ void StrongholdPieces::StrongholdPiece::addAdditonalSaveData(CompoundTag *tag) void StrongholdPieces::StrongholdPiece::readAdditonalSaveData(CompoundTag *tag) { - entryDoor = (SmallDoorType)_fromString(tag->getString(L"EntryDoor")); + entryDoor = static_cast(_fromString(tag->getString(L"EntryDoor"))); } void StrongholdPieces::StrongholdPiece::generateSmallDoor(Level *level, Random *random, BoundingBox *chunkBB, StrongholdPieces::StrongholdPiece::SmallDoorType doorType, int footX, int footY, int footZ) @@ -554,7 +554,7 @@ void StrongholdPieces::StairsDown::addChildren(StructurePiece *startPiece, list< { imposedPiece = EPieceClass_FiveCrossing; } - generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1); + generateSmallDoorChildForward(static_cast(startPiece), pieces, random, 1, 1); } StrongholdPieces::StairsDown *StrongholdPieces::StairsDown::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -562,7 +562,7 @@ StrongholdPieces::StairsDown *StrongholdPieces::StairsDown::createPiece(listfront()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -663,9 +663,9 @@ void StrongholdPieces::Straight::readAdditonalSaveData(CompoundTag *tag) void StrongholdPieces::Straight::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1); - if (leftChild) generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, 1, 2); - if (rightChild) generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, 1, 2); + generateSmallDoorChildForward(static_cast(startPiece), pieces, random, 1, 1); + if (leftChild) generateSmallDoorChildLeft(static_cast(startPiece), pieces, random, 1, 2); + if (rightChild) generateSmallDoorChildRight(static_cast(startPiece), pieces, random, 1, 2); } StrongholdPieces::Straight *StrongholdPieces::Straight::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -673,7 +673,7 @@ StrongholdPieces::Straight *StrongholdPieces::Straight::createPiece(listfront()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -765,7 +765,7 @@ void StrongholdPieces::ChestCorridor::readAdditonalSaveData(CompoundTag *tag) void StrongholdPieces::ChestCorridor::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1); + generateSmallDoorChildForward(static_cast(startPiece), pieces, random, 1, 1); } StrongholdPieces::ChestCorridor *StrongholdPieces::ChestCorridor::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -773,7 +773,7 @@ StrongholdPieces::ChestCorridor *StrongholdPieces::ChestCorridor::createPiece(li BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -837,7 +837,7 @@ StrongholdPieces::StraightStairsDown::StraightStairsDown(int genDepth, Random *r void StrongholdPieces::StraightStairsDown::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1); + generateSmallDoorChildForward(static_cast(startPiece), pieces, random, 1, 1); } StrongholdPieces::StraightStairsDown *StrongholdPieces::StraightStairsDown::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -845,7 +845,7 @@ StrongholdPieces::StraightStairsDown *StrongholdPieces::StraightStairsDown::crea BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 4 - height, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -904,11 +904,11 @@ void StrongholdPieces::LeftTurn::addChildren(StructurePiece *startPiece, list(startPiece), pieces, random, 1, 1); } else { - generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, 1, 1); + generateSmallDoorChildRight(static_cast(startPiece), pieces, random, 1, 1); } } @@ -917,7 +917,7 @@ StrongholdPieces::LeftTurn *StrongholdPieces::LeftTurn::createPiece(listfront()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -965,11 +965,11 @@ void StrongholdPieces::RightTurn::addChildren(StructurePiece *startPiece, list(startPiece), pieces, random, 1, 1); } else { - generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, 1, 1); + generateSmallDoorChildLeft(static_cast(startPiece), pieces, random, 1, 1); } } @@ -1023,9 +1023,9 @@ void StrongholdPieces::RoomCrossing::readAdditonalSaveData(CompoundTag *tag) void StrongholdPieces::RoomCrossing::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateSmallDoorChildForward((StartPiece*) startPiece, pieces, random, 4, 1); - generateSmallDoorChildLeft((StartPiece*) startPiece, pieces, random, 1, 4); - generateSmallDoorChildRight((StartPiece*) startPiece, pieces, random, 1, 4); + generateSmallDoorChildForward(static_cast(startPiece), pieces, random, 4, 1); + generateSmallDoorChildLeft(static_cast(startPiece), pieces, random, 1, 4); + generateSmallDoorChildRight(static_cast(startPiece), pieces, random, 1, 4); } StrongholdPieces::RoomCrossing *StrongholdPieces::RoomCrossing::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1033,7 +1033,7 @@ StrongholdPieces::RoomCrossing *StrongholdPieces::RoomCrossing::createPiece(list BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -4, -1, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1177,7 +1177,7 @@ StrongholdPieces::PrisonHall::PrisonHall(int genDepth, Random *random, BoundingB void StrongholdPieces::PrisonHall::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 1, 1); + generateSmallDoorChildForward(static_cast(startPiece), pieces, random, 1, 1); } StrongholdPieces::PrisonHall *StrongholdPieces::PrisonHall::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1185,7 +1185,7 @@ StrongholdPieces::PrisonHall *StrongholdPieces::PrisonHall::createPiece(listfront()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1264,7 +1264,7 @@ StrongholdPieces::Library *StrongholdPieces::Library::createPiece(listfront()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1465,11 +1465,11 @@ void StrongholdPieces::FiveCrossing::addChildren(StructurePiece *startPiece, lis zOffB = depth - 3 - zOffB; } - generateSmallDoorChildForward((StartPiece *) startPiece, pieces, random, 5, 1); - if (leftLow) generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, zOffA, 1); - if (leftHigh) generateSmallDoorChildLeft((StartPiece *) startPiece, pieces, random, zOffB, 7); - if (rightLow) generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, zOffA, 1); - if (rightHigh) generateSmallDoorChildRight((StartPiece *) startPiece, pieces, random, zOffB, 7); + generateSmallDoorChildForward(static_cast(startPiece), pieces, random, 5, 1); + if (leftLow) generateSmallDoorChildLeft(static_cast(startPiece), pieces, random, zOffA, 1); + if (leftHigh) generateSmallDoorChildLeft(static_cast(startPiece), pieces, random, zOffB, 7); + if (rightLow) generateSmallDoorChildRight(static_cast(startPiece), pieces, random, zOffA, 1); + if (rightHigh) generateSmallDoorChildRight(static_cast(startPiece), pieces, random, zOffB, 7); } StrongholdPieces::FiveCrossing *StrongholdPieces::FiveCrossing::createPiece(list *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) @@ -1477,7 +1477,7 @@ StrongholdPieces::FiveCrossing *StrongholdPieces::FiveCrossing::createPiece(list BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -4, -3, 0, width, height, depth, direction); StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = ((StrongholdPieces::StartPiece *) pieces->front()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { @@ -1563,7 +1563,7 @@ void StrongholdPieces::PortalRoom::addChildren(StructurePiece *startPiece, list< { if (startPiece != NULL) { - ((StartPiece *) startPiece)->portalRoomPiece = this; + static_cast(startPiece)->portalRoomPiece = this; } } @@ -1573,7 +1573,7 @@ StrongholdPieces::PortalRoom *StrongholdPieces::PortalRoom::createPiece(listfront()); + if(pieces != NULL) startPiece = static_cast(pieces->front()); if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { diff --git a/Minecraft.World/StructurePiece.cpp b/Minecraft.World/StructurePiece.cpp index 85a19ab43..be0822bf5 100644 --- a/Minecraft.World/StructurePiece.cpp +++ b/Minecraft.World/StructurePiece.cpp @@ -730,15 +730,15 @@ void StructurePiece::maybeGenerateBlock( Level* level, BoundingBox* chunkBB, Ran void StructurePiece::generateUpperHalfSphere( Level* level, BoundingBox* chunkBB, int x0, int y0, int z0, int x1, int y1, int z1, int fillTile, bool skipAir ) { - float diagX = (float)( x1 - x0 + 1 ); - float diagY = (float)( y1 - y0 + 1 ); - float diagZ = (float)( z1 - z0 + 1 ); + float diagX = static_cast(x1 - x0 + 1); + float diagY = static_cast(y1 - y0 + 1); + float diagZ = static_cast(z1 - z0 + 1); float cx = x0 + diagX / 2; float cz = z0 + diagZ / 2; for ( int y = y0; y <= y1; y++ ) { - float normalizedYDistance = ( float )( y - y0 ) / diagY; + float normalizedYDistance = static_cast(y - y0) / diagY; for ( int x = x0; x <= x1; x++ ) { diff --git a/Minecraft.World/StructureRecipies.cpp b/Minecraft.World/StructureRecipies.cpp index c3e628638..1706a7ced 100644 --- a/Minecraft.World/StructureRecipies.cpp +++ b/Minecraft.World/StructureRecipies.cpp @@ -66,7 +66,7 @@ void StructureRecipies::addRecipes(Recipes *r) L'#', Tile::cobblestone, L'S'); - r->addShapedRecipy(new ItemInstance((Tile*)Tile::chest), // + r->addShapedRecipy(new ItemInstance(static_cast(Tile::chest)), // L"sssctg", L"###", // L"# #", // diff --git a/Minecraft.World/SynchedEntityData.cpp b/Minecraft.World/SynchedEntityData.cpp index 655fa0c30..577063db6 100644 --- a/Minecraft.World/SynchedEntityData.cpp +++ b/Minecraft.World/SynchedEntityData.cpp @@ -485,7 +485,7 @@ int SynchedEntityData::getSizeInBytes() size += 4; break; case TYPE_STRING: - size += (int)dataItem->getValue_wstring().length() + 2; // Estimate, assuming all ascii chars + size += static_cast(dataItem->getValue_wstring().length()) + 2; // Estimate, assuming all ascii chars break; case TYPE_ITEMINSTANCE: // short + byte + short diff --git a/Minecraft.World/TakeFlowerGoal.cpp b/Minecraft.World/TakeFlowerGoal.cpp index 48db34d38..0774374be 100644 --- a/Minecraft.World/TakeFlowerGoal.cpp +++ b/Minecraft.World/TakeFlowerGoal.cpp @@ -58,7 +58,7 @@ bool TakeFlowerGoal::canContinueToUse() void TakeFlowerGoal::start() { - pickupTick = villager->getRandom()->nextInt((int) (OfferFlowerGoal::OFFER_TICKS * 0.8)); + pickupTick = villager->getRandom()->nextInt(static_cast(OfferFlowerGoal::OFFER_TICKS * 0.8)); takeFlower = false; golem.lock()->getNavigation()->stop(); } diff --git a/Minecraft.World/TamableAnimal.cpp b/Minecraft.World/TamableAnimal.cpp index 2a3ea037f..a938cc293 100644 --- a/Minecraft.World/TamableAnimal.cpp +++ b/Minecraft.World/TamableAnimal.cpp @@ -19,7 +19,7 @@ TamableAnimal::~TamableAnimal() void TamableAnimal::defineSynchedData() { Animal::defineSynchedData(); - entityData->define(DATA_FLAGS_ID, (byte) 0); + entityData->define(DATA_FLAGS_ID, static_cast(0)); entityData->define(DATA_OWNERUUID_ID, L""); } @@ -113,11 +113,11 @@ void TamableAnimal::setTame(bool value) byte current = entityData->getByte(DATA_FLAGS_ID); if (value) { - entityData->set(DATA_FLAGS_ID, (byte) (current | 0x04)); + entityData->set(DATA_FLAGS_ID, static_cast(current | 0x04)); } else { - entityData->set(DATA_FLAGS_ID, (byte) (current & ~0x04)); + entityData->set(DATA_FLAGS_ID, static_cast(current & ~0x04)); } } @@ -131,11 +131,11 @@ void TamableAnimal::setSitting(bool value) byte current = entityData->getByte(DATA_FLAGS_ID); if (value) { - entityData->set(DATA_FLAGS_ID, (byte) (current | 0x01)); + entityData->set(DATA_FLAGS_ID, static_cast(current | 0x01)); } else { - entityData->set(DATA_FLAGS_ID, (byte) (current & ~0x01)); + entityData->set(DATA_FLAGS_ID, static_cast(current & ~0x01)); } } diff --git a/Minecraft.World/TeleportEntityPacket.cpp b/Minecraft.World/TeleportEntityPacket.cpp index d31f5bc2f..ccac5e515 100644 --- a/Minecraft.World/TeleportEntityPacket.cpp +++ b/Minecraft.World/TeleportEntityPacket.cpp @@ -23,8 +23,8 @@ TeleportEntityPacket::TeleportEntityPacket(shared_ptr e) x = Mth::floor(e->x * 32); y = Mth::floor(e->y * 32); z = Mth::floor(e->z * 32); - yRot = (byte) (e->yRot * 256 / 360); - xRot = (byte) (e->xRot * 256 / 360); + yRot = static_cast(e->yRot * 256 / 360); + xRot = static_cast(e->xRot * 256 / 360); } TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, byte yRot, byte xRot) diff --git a/Minecraft.World/TextureAndGeometryChangePacket.cpp b/Minecraft.World/TextureAndGeometryChangePacket.cpp index 04c88bed5..ec84031f0 100644 --- a/Minecraft.World/TextureAndGeometryChangePacket.cpp +++ b/Minecraft.World/TextureAndGeometryChangePacket.cpp @@ -49,5 +49,5 @@ void TextureAndGeometryChangePacket::handle(PacketListener *listener) int TextureAndGeometryChangePacket::getEstimatedSize() { - return 8 + (int)path.size(); + return 8 + static_cast(path.size()); } diff --git a/Minecraft.World/TextureAndGeometryPacket.cpp b/Minecraft.World/TextureAndGeometryPacket.cpp index d28fc8628..5386bd12b 100644 --- a/Minecraft.World/TextureAndGeometryPacket.cpp +++ b/Minecraft.World/TextureAndGeometryPacket.cpp @@ -100,7 +100,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P } else { - this->dwBoxC = (DWORD)pvSkinBoxes->size(); + this->dwBoxC = static_cast(pvSkinBoxes->size()); this->BoxDataA= new SKIN_BOX [this->dwBoxC]; int iCount=0; @@ -120,8 +120,8 @@ void TextureAndGeometryPacket::handle(PacketListener *listener) void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException { textureName = dis->readUTF(); - dwSkinID = (DWORD)dis->readInt(); - dwTextureBytes = (DWORD)dis->readShort(); + dwSkinID = static_cast(dis->readInt()); + dwTextureBytes = static_cast(dis->readShort()); if(dwTextureBytes>0) { @@ -134,7 +134,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException } uiAnimOverrideBitmask = dis->readInt(); - dwBoxC = (DWORD)dis->readShort(); + dwBoxC = static_cast(dis->readShort()); if(dwBoxC>0) { @@ -143,7 +143,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException for(DWORD i=0;iBoxDataA[i].ePart = (eBodyPart) dis->readShort(); + this->BoxDataA[i].ePart = static_cast(dis->readShort()); this->BoxDataA[i].fX = dis->readFloat(); this->BoxDataA[i].fY = dis->readFloat(); this->BoxDataA[i].fZ = dis->readFloat(); @@ -159,17 +159,17 @@ void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException { dos->writeUTF(textureName); dos->writeInt(dwSkinID); - dos->writeShort((short)dwTextureBytes); + dos->writeShort(static_cast(dwTextureBytes)); for(DWORD i=0;iwriteByte(this->pbData[i]); } dos->writeInt(uiAnimOverrideBitmask); - dos->writeShort((short)dwBoxC); + dos->writeShort(static_cast(dwBoxC)); for(DWORD i=0;iwriteShort((short)this->BoxDataA[i].ePart); + dos->writeShort(static_cast(this->BoxDataA[i].ePart)); dos->writeFloat(this->BoxDataA[i].fX); dos->writeFloat(this->BoxDataA[i].fY); dos->writeFloat(this->BoxDataA[i].fZ); diff --git a/Minecraft.World/TextureChangePacket.cpp b/Minecraft.World/TextureChangePacket.cpp index 2368136c4..cea04d254 100644 --- a/Minecraft.World/TextureChangePacket.cpp +++ b/Minecraft.World/TextureChangePacket.cpp @@ -24,7 +24,7 @@ TextureChangePacket::TextureChangePacket(shared_ptr e, ETextureChangeTyp void TextureChangePacket::read(DataInputStream *dis) //throws IOException { id = dis->readInt(); - action = (ETextureChangeType)dis->readByte(); + action = static_cast(dis->readByte()); path = dis->readUTF(); } @@ -42,5 +42,5 @@ void TextureChangePacket::handle(PacketListener *listener) int TextureChangePacket::getEstimatedSize() { - return 5 + (int)path.size(); + return 5 + static_cast(path.size()); } diff --git a/Minecraft.World/TexturePacket.cpp b/Minecraft.World/TexturePacket.cpp index 77dfdc38c..061c6fc1e 100644 --- a/Minecraft.World/TexturePacket.cpp +++ b/Minecraft.World/TexturePacket.cpp @@ -37,7 +37,7 @@ void TexturePacket::handle(PacketListener *listener) void TexturePacket::read(DataInputStream *dis) //throws IOException { textureName = dis->readUTF(); - dwBytes = (DWORD)dis->readShort(); + dwBytes = static_cast(dis->readShort()); if(dwBytes>0) { @@ -53,7 +53,7 @@ void TexturePacket::read(DataInputStream *dis) //throws IOException void TexturePacket::write(DataOutputStream *dos) //throws IOException { dos->writeUTF(textureName); - dos->writeShort((short)dwBytes); + dos->writeShort(static_cast(dwBytes)); for(DWORD i=0;iwriteByte(this->pbData[i]); diff --git a/Minecraft.World/TheEndBiome.cpp b/Minecraft.World/TheEndBiome.cpp index 9e2359ed0..d54efb36e 100644 --- a/Minecraft.World/TheEndBiome.cpp +++ b/Minecraft.World/TheEndBiome.cpp @@ -14,8 +14,8 @@ TheEndBiome::TheEndBiome(int id) : Biome(id) ambientFriendlies.clear(); enemies.push_back(new MobSpawnerData(eTYPE_ENDERMAN, 10, 4, 4)); - topMaterial = (byte) Tile::dirt_Id; - material = (byte) Tile::dirt_Id; + topMaterial = static_cast(Tile::dirt_Id); + material = static_cast(Tile::dirt_Id); decorator = new TheEndBiomeDecorator(this); } diff --git a/Minecraft.World/TheEndLevelRandomLevelSource.cpp b/Minecraft.World/TheEndLevelRandomLevelSource.cpp index 67d85a923..5b965ef79 100644 --- a/Minecraft.World/TheEndLevelRandomLevelSource.cpp +++ b/Minecraft.World/TheEndLevelRandomLevelSource.cpp @@ -53,7 +53,7 @@ void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArra { for (int yc = 0; yc < Level::genDepth / CHUNK_HEIGHT; yc++) { - double yStep = 1 / (double) CHUNK_HEIGHT; + double yStep = 1 / static_cast(CHUNK_HEIGHT); double s0 = buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 0)]; double s1 = buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 0)]; double s2 = buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 0)]; @@ -66,7 +66,7 @@ void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArra for (int y = 0; y < CHUNK_HEIGHT; y++) { - double xStep = 1 / (double) CHUNK_WIDTH; + double xStep = 1 / static_cast(CHUNK_WIDTH); double _s0 = s0; double _s1 = s1; @@ -77,7 +77,7 @@ void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArra { int offs = (x + xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | (0 + zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y); int step = 1 << Level::genDepthBits; - double zStep = 1 / (double) CHUNK_WIDTH; + double zStep = 1 / static_cast(CHUNK_WIDTH); double val = _s0; double vala = (_s1 - _s0) * zStep; @@ -90,7 +90,7 @@ void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArra } else { } - blocks[offs] = (byte) tileId; + blocks[offs] = static_cast(tileId); offs += step; val += vala; } @@ -139,7 +139,7 @@ void TheEndLevelRandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray if (runDepth <= 0) { top = 0; - material = (byte) Tile::endStone_Id; + material = static_cast(Tile::endStone_Id); } run = runDepth; @@ -169,7 +169,7 @@ LevelChunk *TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs) BiomeArray biomes; // 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed unsigned int blocksSize = Level::genDepth * 16 * 16; - byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + byte *tileData = static_cast(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); XMemSet128(tileData,0,blocksSize); byteArray blocks = byteArray(tileData,blocksSize); // byteArray blocks = byteArray(16 * level->depth * 16); diff --git a/Minecraft.World/Throwable.cpp b/Minecraft.World/Throwable.cpp index 7d30b898d..4aecacfda 100644 --- a/Minecraft.World/Throwable.cpp +++ b/Minecraft.World/Throwable.cpp @@ -106,10 +106,10 @@ void Throwable::shoot(double xd, double yd, double zd, float pow, float uncertai this->yd = yd; this->zd = zd; - float sd = (float) sqrt(xd * xd + zd * zd); + float sd = static_cast(sqrt(xd * xd + zd * zd)); - yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI); - xRotO = xRot = (float) (atan2(yd, (double)sd) * 180 / PI); + yRotO = yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRotO = xRot = static_cast(atan2(yd, (double)sd) * 180 / PI); life = 0; } @@ -120,9 +120,9 @@ void Throwable::lerpMotion(double xd, double yd, double zd) this->zd = zd; if (xRotO == 0 && yRotO == 0) { - float sd = (float) sqrt(xd * xd + zd * zd); - yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI); - xRotO = xRot = (float) (atan2(yd, (double)sd) * 180 / PI); + float sd = static_cast(sqrt(xd * xd + zd * zd)); + yRotO = yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRotO = xRot = static_cast(atan2(yd, (double)sd) * 180 / PI); } } @@ -220,9 +220,9 @@ void Throwable::tick() y += yd; z += zd; - float sd = (float) sqrt(xd * xd + zd * zd); - yRot = (float) (atan2(xd, zd) * 180 / PI); - xRot = (float) (atan2(yd, (double)sd) * 180 / PI); + float sd = static_cast(sqrt(xd * xd + zd * zd)); + yRot = static_cast(atan2(xd, zd) * 180 / PI); + xRot = static_cast(atan2(yd, (double)sd) * 180 / PI); while (xRot - xRotO < -180) xRotO -= 360; @@ -267,12 +267,12 @@ float Throwable::getGravity() void Throwable::addAdditonalSaveData(CompoundTag *tag) { - tag->putShort(L"xTile", (short) xTile); - tag->putShort(L"yTile", (short) yTile); - tag->putShort(L"zTile", (short) zTile); - tag->putByte(L"inTile", (byte) lastTile); - tag->putByte(L"shake", (byte) shakeTime); - tag->putByte(L"inGround", (byte) (inGround ? 1 : 0)); + tag->putShort(L"xTile", static_cast(xTile)); + tag->putShort(L"yTile", static_cast(yTile)); + tag->putShort(L"zTile", static_cast(zTile)); + tag->putByte(L"inTile", static_cast(lastTile)); + tag->putByte(L"shake", static_cast(shakeTime)); + tag->putByte(L"inGround", static_cast(inGround ? 1 : 0)); if (ownerName.empty() && (owner != NULL) && owner->instanceof(eTYPE_PLAYER) ) { diff --git a/Minecraft.World/ThrownExpBottle.cpp b/Minecraft.World/ThrownExpBottle.cpp index b8dbef96b..c700bdc56 100644 --- a/Minecraft.World/ThrownExpBottle.cpp +++ b/Minecraft.World/ThrownExpBottle.cpp @@ -40,7 +40,7 @@ void ThrownExpBottle::onHit(HitResult *res) if (!level->isClientSide) { - level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), 0); + level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, static_cast(Math::round(x)), static_cast(Math::round(y)), static_cast(Math::round(z)), 0); int xpCount = 3 + level->random->nextInt(5) + level->random->nextInt(5); while (xpCount > 0) diff --git a/Minecraft.World/ThrownPotion.cpp b/Minecraft.World/ThrownPotion.cpp index 69c096a2c..fbab11d8f 100644 --- a/Minecraft.World/ThrownPotion.cpp +++ b/Minecraft.World/ThrownPotion.cpp @@ -117,7 +117,7 @@ void ThrownPotion::onHit(HitResult *res) } else { - int duration = (int) (scale * (double) effect->getDuration() + .5); + int duration = static_cast(scale * (double)effect->getDuration() + .5); if (duration > SharedConstants::TICKS_PER_SECOND) { e->addEffect(new MobEffectInstance(id, duration, effect->getAmplifier())); @@ -129,7 +129,7 @@ void ThrownPotion::onHit(HitResult *res) } delete entitiesOfClass; } - level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), getPotionValue() ); + level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, static_cast(Math::round(x)), static_cast(Math::round(y)), static_cast(Math::round(z)), getPotionValue() ); remove(); } diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp index a07fdfe43..ef1b7e358 100644 --- a/Minecraft.World/Tile.cpp +++ b/Minecraft.World/Tile.cpp @@ -236,7 +236,7 @@ void Tile::CreateNewThreadStorage() void Tile::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); delete tls; } @@ -259,15 +259,15 @@ void Tile::staticCtor() memset( tiles, 0, sizeof( Tile *)*TILE_NUM_COUNT ); Tile::stone = (new StoneTile(1)) ->setDestroyTime(1.5f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stone")->setDescriptionId(IDS_TILE_STONE)->setUseDescriptionId(IDS_DESC_STONE); - Tile::grass = (GrassTile *) (new GrassTile(2)) ->setDestroyTime(0.6f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"grass")->setDescriptionId(IDS_TILE_GRASS)->setUseDescriptionId(IDS_DESC_GRASS); + Tile::grass = static_cast((new GrassTile(2))->setDestroyTime(0.6f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"grass")->setDescriptionId(IDS_TILE_GRASS)->setUseDescriptionId(IDS_DESC_GRASS)); Tile::dirt = (new DirtTile(3)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_GRAVEL)->setIconName(L"dirt")->setDescriptionId(IDS_TILE_DIRT)->setUseDescriptionId(IDS_DESC_DIRT); Tile::cobblestone = (new Tile(4, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"cobblestone")->setDescriptionId(IDS_TILE_STONE_BRICK)->setUseDescriptionId(IDS_DESC_STONE_BRICK); Tile::wood = (new WoodTile(5)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structwoodstuff, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"planks")->setDescriptionId(IDS_TILE_OAKWOOD_PLANKS)->sendTileData()->setUseDescriptionId(IDS_DESC_WOODENPLANKS); Tile::sapling = (new Sapling(6)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"sapling")->setDescriptionId(IDS_TILE_SAPLING)->sendTileData()->setUseDescriptionId(IDS_DESC_SAPLING)->disableMipmap(); Tile::unbreakable = (new Tile(7, Material::stone)) ->setIndestructible()->setExplodeable(6000000)->setSoundType(Tile::SOUND_STONE)->setIconName(L"bedrock")->setDescriptionId(IDS_TILE_BEDROCK)->setNotCollectStatistics()->setUseDescriptionId(IDS_DESC_BEDROCK); - Tile::water = (LiquidTile *)(new LiquidTileDynamic(8, Material::water)) ->setDestroyTime(100.0f)->setLightBlock(3)->setIconName(L"water_flow")->setDescriptionId(IDS_TILE_WATER)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_WATER); + Tile::water = static_cast((new LiquidTileDynamic(8, Material::water))->setDestroyTime(100.0f)->setLightBlock(3)->setIconName(L"water_flow")->setDescriptionId(IDS_TILE_WATER)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_WATER)); Tile::calmWater = (new LiquidTileStatic(9, Material::water)) ->setDestroyTime(100.0f)->setLightBlock(3)->setIconName(L"water_still")->setDescriptionId(IDS_TILE_WATER)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_WATER); - Tile::lava = (LiquidTile *)(new LiquidTileDynamic(10, Material::lava)) ->setDestroyTime(00.0f)->setLightEmission(1.0f)->setLightBlock(255)->setIconName(L"lava_flow")->setDescriptionId(IDS_TILE_LAVA)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_LAVA); + Tile::lava = static_cast((new LiquidTileDynamic(10, Material::lava))->setDestroyTime(00.0f)->setLightEmission(1.0f)->setLightBlock(255)->setIconName(L"lava_flow")->setDescriptionId(IDS_TILE_LAVA)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_LAVA)); Tile::calmLava = (new LiquidTileStatic(11, Material::lava)) ->setDestroyTime(100.0f)->setLightEmission(1.0f)->setLightBlock(255)->setIconName(L"lava_still")->setDescriptionId(IDS_TILE_LAVA)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_LAVA); Tile::sand = (new HeavyTile(12)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_SAND)->setIconName(L"sand")->setDescriptionId(IDS_TILE_SAND)->setUseDescriptionId(IDS_DESC_SAND); @@ -277,7 +277,7 @@ void Tile::staticCtor() Tile::coalOre = (new OreTile(16)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(Tile::SOUND_STONE)->setIconName(L"coal_ore")->setDescriptionId(IDS_TILE_ORE_COAL)->setUseDescriptionId(IDS_DESC_ORE_COAL); Tile::treeTrunk = (new TreeTile(17))->setDestroyTime(2.0f) ->setSoundType(Tile::SOUND_WOOD)->setIconName(L"log")->setDescriptionId(IDS_TILE_LOG)->sendTileData()->setUseDescriptionId(IDS_DESC_LOG); // 4J - for leaves, have specified that only the data bits that encode the type of leaf are important to be sent - Tile::leaves = (LeafTile *)(new LeafTile(18)) ->setDestroyTime(0.2f)->setLightBlock(1)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"leaves")->setDescriptionId(IDS_TILE_LEAVES)->sendTileData(LeafTile::LEAF_TYPE_MASK)->setUseDescriptionId(IDS_DESC_LEAVES); + Tile::leaves = static_cast((new LeafTile(18))->setDestroyTime(0.2f)->setLightBlock(1)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"leaves")->setDescriptionId(IDS_TILE_LEAVES)->sendTileData(LeafTile::LEAF_TYPE_MASK)->setUseDescriptionId(IDS_DESC_LEAVES)); Tile::sponge = (new Sponge(19)) ->setDestroyTime(0.6f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"sponge")->setDescriptionId(IDS_TILE_SPONGE)->setUseDescriptionId(IDS_DESC_SPONGE); Tile::glass = (new GlassTile(20, Material::glass, false)) ->setDestroyTime(0.3f)->setSoundType(Tile::SOUND_GLASS)->setIconName(L"glass")->setDescriptionId(IDS_TILE_GLASS)->setUseDescriptionId(IDS_DESC_GLASS); @@ -289,24 +289,24 @@ void Tile::staticCtor() Tile::bed = (new BedTile(26)) ->setDestroyTime(0.2f)->setIconName(L"bed")->setDescriptionId(IDS_TILE_BED)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_BED); Tile::goldenRail = (new PoweredRailTile(27)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_rail, Item::eMaterial_gold)->setDestroyTime(0.7f)->setSoundType(Tile::SOUND_METAL)->setIconName(L"rail_golden")->setDescriptionId(IDS_TILE_GOLDEN_RAIL)->sendTileData()->setUseDescriptionId(IDS_DESC_POWEREDRAIL)->disableMipmap(); Tile::detectorRail = (new DetectorRailTile(28)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_rail, Item::eMaterial_detector)->setDestroyTime(0.7f)->setSoundType(Tile::SOUND_METAL)->setIconName(L"rail_detector")->setDescriptionId(IDS_TILE_DETECTOR_RAIL)->sendTileData()->setUseDescriptionId(IDS_DESC_DETECTORRAIL)->disableMipmap(); - Tile::pistonStickyBase = (PistonBaseTile *)(new PistonBaseTile(29, true)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_piston, Item::eMaterial_stickypiston)->setIconName(L"pistonStickyBase")->setDescriptionId(IDS_TILE_PISTON_STICK_BASE)->setUseDescriptionId(IDS_DESC_STICKY_PISTON)->sendTileData(); + Tile::pistonStickyBase = static_cast((new PistonBaseTile(29, true))->setBaseItemTypeAndMaterial(Item::eBaseItemType_piston, Item::eMaterial_stickypiston)->setIconName(L"pistonStickyBase")->setDescriptionId(IDS_TILE_PISTON_STICK_BASE)->setUseDescriptionId(IDS_DESC_STICKY_PISTON)->sendTileData()); Tile::web = (new WebTile(30)) ->setLightBlock(1)->setDestroyTime(4.0f)->setIconName(L"web")->setDescriptionId(IDS_TILE_WEB)->setUseDescriptionId(IDS_DESC_WEB); - Tile::tallgrass = (TallGrass *)(new TallGrass(31)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tallgrass")->setDescriptionId(IDS_TILE_TALL_GRASS)->setUseDescriptionId(IDS_DESC_TALL_GRASS)->disableMipmap(); - Tile::deadBush = (DeadBushTile *)(new DeadBushTile(32)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"deadbush")->setDescriptionId(IDS_TILE_DEAD_BUSH)->setUseDescriptionId(IDS_DESC_DEAD_BUSH)->disableMipmap(); - Tile::pistonBase = (PistonBaseTile *)(new PistonBaseTile(33,false)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_piston, Item::eMaterial_piston)->setIconName(L"pistonBase")->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(IDS_DESC_PISTON)->sendTileData(); - Tile::pistonExtension = (PistonExtensionTile *)(new PistonExtensionTile(34))->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(-1)->sendTileData(); + Tile::tallgrass = static_cast((new TallGrass(31))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tallgrass")->setDescriptionId(IDS_TILE_TALL_GRASS)->setUseDescriptionId(IDS_DESC_TALL_GRASS)->disableMipmap()); + Tile::deadBush = static_cast((new DeadBushTile(32))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"deadbush")->setDescriptionId(IDS_TILE_DEAD_BUSH)->setUseDescriptionId(IDS_DESC_DEAD_BUSH)->disableMipmap()); + Tile::pistonBase = static_cast((new PistonBaseTile(33, false))->setBaseItemTypeAndMaterial(Item::eBaseItemType_piston, Item::eMaterial_piston)->setIconName(L"pistonBase")->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(IDS_DESC_PISTON)->sendTileData()); + Tile::pistonExtension = static_cast((new PistonExtensionTile(34))->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(-1)->sendTileData()); Tile::wool = (new ColoredTile(35, Material::cloth)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_cloth, Item::eMaterial_cloth)->setDestroyTime(0.8f)->setSoundType(Tile::SOUND_CLOTH)->setIconName(L"wool_colored")->setDescriptionId(IDS_TILE_CLOTH)->sendTileData()->setUseDescriptionId(IDS_DESC_WOOL); - Tile::pistonMovingPiece = (PistonMovingPiece *)(new PistonMovingPiece(36)) ->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(-1); - Tile::flower = (Bush *) (new Bush(37)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"flower_dandelion")->setDescriptionId(IDS_TILE_FLOWER)->setUseDescriptionId(IDS_DESC_FLOWER)->disableMipmap(); - Tile::rose = (Bush *) (new Bush(38)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"flower_rose")->setDescriptionId(IDS_TILE_ROSE)->setUseDescriptionId(IDS_DESC_FLOWER)->disableMipmap(); - Tile::mushroom_brown = (Bush *) (new Mushroom(39)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setLightEmission(2 / 16.0f)->setIconName(L"mushroom_brown")->setDescriptionId(IDS_TILE_MUSHROOM)->setUseDescriptionId(IDS_DESC_MUSHROOM)->disableMipmap(); - Tile::mushroom_red = (Bush *) (new Mushroom(40)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"mushroom_red")->setDescriptionId(IDS_TILE_MUSHROOM)->setUseDescriptionId(IDS_DESC_MUSHROOM)->disableMipmap(); + Tile::pistonMovingPiece = static_cast((new PistonMovingPiece(36))->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(-1)); + Tile::flower = static_cast((new Bush(37))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"flower_dandelion")->setDescriptionId(IDS_TILE_FLOWER)->setUseDescriptionId(IDS_DESC_FLOWER)->disableMipmap()); + Tile::rose = static_cast((new Bush(38))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"flower_rose")->setDescriptionId(IDS_TILE_ROSE)->setUseDescriptionId(IDS_DESC_FLOWER)->disableMipmap()); + Tile::mushroom_brown = static_cast((new Mushroom(39))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setLightEmission(2 / 16.0f)->setIconName(L"mushroom_brown")->setDescriptionId(IDS_TILE_MUSHROOM)->setUseDescriptionId(IDS_DESC_MUSHROOM)->disableMipmap()); + Tile::mushroom_red = static_cast((new Mushroom(40))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"mushroom_red")->setDescriptionId(IDS_TILE_MUSHROOM)->setUseDescriptionId(IDS_DESC_MUSHROOM)->disableMipmap()); Tile::goldBlock = (new MetalTile(41)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_gold)->setDestroyTime(3.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_METAL)->setIconName(L"gold_block")->setDescriptionId(IDS_TILE_BLOCK_GOLD)->setUseDescriptionId(IDS_DESC_BLOCK_GOLD); Tile::ironBlock = (new MetalTile(42)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_iron)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_METAL)->setIconName(L"iron_block")->setDescriptionId(IDS_TILE_BLOCK_IRON)->setUseDescriptionId(IDS_DESC_BLOCK_IRON); - Tile::stoneSlab = (HalfSlabTile *) (new StoneSlabTile(Tile::stoneSlab_Id, true)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_SLAB); - Tile::stoneSlabHalf = (HalfSlabTile *) (new StoneSlabTile(Tile::stoneSlabHalf_Id, false)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_HALFSLAB); + Tile::stoneSlab = static_cast((new StoneSlabTile(Tile::stoneSlab_Id, true))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_SLAB)); + Tile::stoneSlabHalf = static_cast((new StoneSlabTile(Tile::stoneSlabHalf_Id, false))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_HALFSLAB)); Tile::redBrick = (new Tile(45, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_brick)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"brick")->setDescriptionId(IDS_TILE_BRICK)->setUseDescriptionId(IDS_DESC_BRICK); Tile::tnt = (new TntTile(46)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tnt")->setDescriptionId(IDS_TILE_TNT)->setUseDescriptionId(IDS_DESC_TNT); Tile::bookshelf = (new BookshelfTile(47)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_paper, Item::eMaterial_bookshelf)->setDestroyTime(1.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"bookshelf")->setDescriptionId(IDS_TILE_BOOKSHELF)->setUseDescriptionId(IDS_DESC_BOOKSHELF); @@ -314,11 +314,11 @@ void Tile::staticCtor() Tile::obsidian = (new ObsidianTile(49)) ->setDestroyTime(50.0f)->setExplodeable(2000)->setSoundType(Tile::SOUND_STONE)->setIconName(L"obsidian")->setDescriptionId(IDS_TILE_OBSIDIAN)->setUseDescriptionId(IDS_DESC_OBSIDIAN); Tile::torch = (new TorchTile(50)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_torch, Item::eMaterial_wood)->setDestroyTime(0.0f)->setLightEmission(15 / 16.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"torch_on")->setDescriptionId(IDS_TILE_TORCH)->setUseDescriptionId(IDS_DESC_TORCH)->disableMipmap(); - Tile::fire = (FireTile *) ((new FireTile(51)) ->setDestroyTime(0.0f)->setLightEmission(1.0f)->setSoundType(Tile::SOUND_WOOD))->setIconName(L"fire")->setDescriptionId(IDS_TILE_FIRE)->setNotCollectStatistics()->setUseDescriptionId(-1); + Tile::fire = static_cast(((new FireTile(51))->setDestroyTime(0.0f)->setLightEmission(1.0f)->setSoundType(Tile::SOUND_WOOD))->setIconName(L"fire")->setDescriptionId(IDS_TILE_FIRE)->setNotCollectStatistics()->setUseDescriptionId(-1)); Tile::mobSpawner = (new MobSpawnerTile(52)) ->setDestroyTime(5.0f)->setSoundType(Tile::SOUND_METAL)->setIconName(L"mob_spawner")->setDescriptionId(IDS_TILE_MOB_SPAWNER)->setNotCollectStatistics()->setUseDescriptionId(IDS_DESC_MOB_SPAWNER); Tile::stairs_wood = (new StairTile(53, Tile::wood,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_wood) ->setIconName(L"stairsWood")->setDescriptionId(IDS_TILE_STAIRS_WOOD) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); - Tile::chest = (ChestTile *)(new ChestTile(54, ChestTile::TYPE_BASIC)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_chest, Item::eMaterial_wood)->setDestroyTime(2.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"chest")->setDescriptionId(IDS_TILE_CHEST)->sendTileData()->setUseDescriptionId(IDS_DESC_CHEST); - Tile::redStoneDust = (RedStoneDustTile *)(new RedStoneDustTile(55)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_NORMAL)->setIconName(L"redstone_dust")->setDescriptionId(IDS_TILE_REDSTONE_DUST)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONE_DUST); + Tile::chest = static_cast((new ChestTile(54, ChestTile::TYPE_BASIC))->setBaseItemTypeAndMaterial(Item::eBaseItemType_chest, Item::eMaterial_wood)->setDestroyTime(2.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"chest")->setDescriptionId(IDS_TILE_CHEST)->sendTileData()->setUseDescriptionId(IDS_DESC_CHEST)); + Tile::redStoneDust = static_cast((new RedStoneDustTile(55))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_NORMAL)->setIconName(L"redstone_dust")->setDescriptionId(IDS_TILE_REDSTONE_DUST)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONE_DUST)); Tile::diamondOre = (new OreTile(56)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(Tile::SOUND_STONE)->setIconName(L"diamond_ore")->setDescriptionId(IDS_TILE_ORE_DIAMOND)->setUseDescriptionId(IDS_DESC_ORE_DIAMOND); Tile::diamondBlock = (new MetalTile(57)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_diamond)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_METAL)->setIconName(L"diamond_block")->setDescriptionId(IDS_TILE_BLOCK_DIAMOND)->setUseDescriptionId(IDS_DESC_BLOCK_DIAMOND); Tile::workBench = (new WorkbenchTile(58)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_device, Item::eMaterial_wood)->setDestroyTime(2.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"crafting_table")->setDescriptionId(IDS_TILE_WORKBENCH)->setUseDescriptionId(IDS_DESC_CRAFTINGTABLE); @@ -356,12 +356,12 @@ void Tile::staticCtor() Tile::netherRack = (new NetherrackTile(87)) ->setDestroyTime(0.4f)->setSoundType(Tile::SOUND_STONE)->setIconName(L"netherrack")->setDescriptionId(IDS_TILE_HELL_ROCK)->setUseDescriptionId(IDS_DESC_HELL_ROCK); Tile::soulsand = (new SoulSandTile(88)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_SAND)->setIconName(L"soul_sand")->setDescriptionId(IDS_TILE_HELL_SAND)->setUseDescriptionId(IDS_DESC_HELL_SAND); Tile::glowstone = (new Glowstonetile(89, Material::glass)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_torch, Item::eMaterial_glowstone)->setDestroyTime(0.3f)->setSoundType(Tile::SOUND_GLASS)->setLightEmission(1.0f)->setIconName(L"glowstone")->setDescriptionId(IDS_TILE_LIGHT_GEM)->setUseDescriptionId(IDS_DESC_GLOWSTONE); - Tile::portalTile = (PortalTile *) ((new PortalTile(90)) ->setDestroyTime(-1)->setSoundType(Tile::SOUND_GLASS)->setLightEmission(0.75f))->setIconName(L"portal")->setDescriptionId(IDS_TILE_PORTAL)->setUseDescriptionId(IDS_DESC_PORTAL); + Tile::portalTile = static_cast(((new PortalTile(90))->setDestroyTime(-1)->setSoundType(Tile::SOUND_GLASS)->setLightEmission(0.75f))->setIconName(L"portal")->setDescriptionId(IDS_TILE_PORTAL)->setUseDescriptionId(IDS_DESC_PORTAL)); Tile::litPumpkin = (new PumpkinTile(91, true)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_torch, Item::eMaterial_pumpkin)->setDestroyTime(1.0f)->setSoundType(Tile::SOUND_WOOD)->setLightEmission(1.0f)->setIconName(L"pumpkin")->setDescriptionId(IDS_TILE_LIT_PUMPKIN)->sendTileData()->setUseDescriptionId(IDS_DESC_JACKOLANTERN); Tile::cake = (new CakeTile(92)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_CLOTH)->setIconName(L"cake")->setDescriptionId(IDS_TILE_CAKE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_CAKE); - Tile::diode_off = (RepeaterTile *)(new RepeaterTile(93, false)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"repeater_off")->setDescriptionId(IDS_ITEM_DIODE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER)->disableMipmap(); - Tile::diode_on = (RepeaterTile *)(new RepeaterTile(94, true)) ->setDestroyTime(0.0f)->setLightEmission(10 / 16.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"repeater_on")->setDescriptionId(IDS_ITEM_DIODE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER)->disableMipmap(); + Tile::diode_off = static_cast((new RepeaterTile(93, false))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"repeater_off")->setDescriptionId(IDS_ITEM_DIODE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER)->disableMipmap()); + Tile::diode_on = static_cast((new RepeaterTile(94, true))->setDestroyTime(0.0f)->setLightEmission(10 / 16.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"repeater_on")->setDescriptionId(IDS_ITEM_DIODE)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_REDSTONEREPEATER)->disableMipmap()); Tile::stained_glass = (new StainedGlassBlock(95, Material::glass))->setBaseItemTypeAndMaterial(Item::eBaseItemType_glass, Item::eMaterial_glass)->setDestroyTime(0.3f)->setSoundType(SOUND_GLASS)->setIconName(L"glass")->setDescriptionId(IDS_TILE_STAINED_GLASS)->setUseDescriptionId(IDS_DESC_STAINED_GLASS); Tile::trapdoor = (new TrapDoorTile(96, Material::wood)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_door, Item::eMaterial_trap)->setDestroyTime(3.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"trapdoor")->setDescriptionId(IDS_TILE_TRAPDOOR)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_TRAPDOOR); Tile::monsterStoneEgg = (new StoneMonsterTile(97)) ->setDestroyTime(0.75f)->setIconName(L"monsterStoneEgg")->setDescriptionId(IDS_TILE_STONE_SILVERFISH)->setUseDescriptionId(IDS_DESC_STONE_SILVERFISH); @@ -379,7 +379,7 @@ void Tile::staticCtor() Tile::fenceGate = (new FenceGateTile(107)) ->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"fenceGate")->setDescriptionId(IDS_TILE_FENCE_GATE)->sendTileData()->setUseDescriptionId(IDS_DESC_FENCE_GATE); Tile::stairs_bricks = (new StairTile(108, Tile::redBrick,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_brick) ->setIconName(L"stairsBrick")->setDescriptionId(IDS_TILE_STAIRS_BRICKS) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); Tile::stairs_stoneBrickSmooth = (new StairTile(109, Tile::stoneBrick,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_stoneSmooth)->setIconName(L"stairsStoneBrickSmooth")->setDescriptionId(IDS_TILE_STAIRS_STONE_BRICKS_SMOOTH) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); - Tile::mycel = (MycelTile *)(new MycelTile(110)) ->setDestroyTime(0.6f)->setSoundType(SOUND_GRASS)->setIconName(L"mycelium")->setDescriptionId(IDS_TILE_MYCEL)->setUseDescriptionId(IDS_DESC_MYCEL); + Tile::mycel = static_cast((new MycelTile(110))->setDestroyTime(0.6f)->setSoundType(SOUND_GRASS)->setIconName(L"mycelium")->setDescriptionId(IDS_TILE_MYCEL)->setUseDescriptionId(IDS_DESC_MYCEL)); Tile::waterLily = (new WaterlilyTile(111)) ->setDestroyTime(0.0f)->setSoundType(SOUND_GRASS)->setIconName(L"waterlily")->setDescriptionId(IDS_TILE_WATERLILY)->setUseDescriptionId(IDS_DESC_WATERLILY); Tile::netherBrick = (new Tile(112, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_netherbrick)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(SOUND_STONE)->setIconName(L"nether_brick")->setDescriptionId(IDS_TILE_NETHERBRICK)->setUseDescriptionId(IDS_DESC_NETHERBRICK); @@ -388,7 +388,7 @@ void Tile::staticCtor() Tile::netherStalk = (new NetherWartTile(115)) ->setIconName(L"nether_wart")->setDescriptionId(IDS_TILE_NETHERSTALK)->sendTileData()->setUseDescriptionId(IDS_DESC_NETHERSTALK); Tile::enchantTable = (new EnchantmentTableTile(116)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_device, Item::eMaterial_magic)->setDestroyTime(5.0f)->setExplodeable(2000)->setIconName(L"enchanting_table")->setDescriptionId(IDS_TILE_ENCHANTMENTTABLE)->setUseDescriptionId(IDS_DESC_ENCHANTMENTTABLE); Tile::brewingStand = (new BrewingStandTile(117)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_device, Item::eMaterial_blaze)->setDestroyTime(0.5f)->setLightEmission(2 / 16.0f)->setIconName(L"brewing_stand")->setDescriptionId(IDS_TILE_BREWINGSTAND)->sendTileData()->setUseDescriptionId(IDS_DESC_BREWING_STAND); - Tile::cauldron = (CauldronTile *)(new CauldronTile(118)) ->setDestroyTime(2.0f)->setIconName(L"cauldron")->setDescriptionId(IDS_TILE_CAULDRON)->sendTileData()->setUseDescriptionId(IDS_DESC_CAULDRON); + Tile::cauldron = static_cast((new CauldronTile(118))->setDestroyTime(2.0f)->setIconName(L"cauldron")->setDescriptionId(IDS_TILE_CAULDRON)->sendTileData()->setUseDescriptionId(IDS_DESC_CAULDRON)); Tile::endPortalTile = (new TheEndPortal(119, Material::portal)) ->setDestroyTime(INDESTRUCTIBLE_DESTROY_TIME)->setExplodeable(6000000)->setDescriptionId(IDS_TILE_END_PORTAL)->setUseDescriptionId(IDS_DESC_END_PORTAL); Tile::endPortalFrameTile = (new TheEndPortalFrameTile(120)) ->setSoundType(SOUND_GLASS)->setLightEmission(2 / 16.0f)->setDestroyTime(INDESTRUCTIBLE_DESTROY_TIME)->setIconName(L"endframe")->setDescriptionId(IDS_TILE_ENDPORTALFRAME)->sendTileData()->setExplodeable(6000000)->setUseDescriptionId(IDS_DESC_ENDPORTALFRAME); @@ -396,22 +396,22 @@ void Tile::staticCtor() Tile::dragonEgg = (new EggTile(122)) ->setDestroyTime(3.0f)->setExplodeable(15)->setSoundType(SOUND_STONE)->setLightEmission(2.0f / 16.0f)->setIconName(L"dragon_egg")->setDescriptionId(IDS_TILE_DRAGONEGG)->setUseDescriptionId(IDS_DESC_DRAGONEGG); Tile::redstoneLight = (new RedlightTile(123, false)) ->setDestroyTime(0.3f)->setSoundType(SOUND_GLASS)->setIconName(L"redstone_lamp_off")->setDescriptionId(IDS_TILE_REDSTONE_LIGHT)->setUseDescriptionId(IDS_DESC_REDSTONE_LIGHT); Tile::redstoneLight_lit = (new RedlightTile(124, true)) ->setDestroyTime(0.3f)->setSoundType(SOUND_GLASS)->setIconName(L"redstone_lamp_on")->setDescriptionId(IDS_TILE_REDSTONE_LIGHT)->setUseDescriptionId(IDS_DESC_REDSTONE_LIGHT); - Tile::woodSlab = (HalfSlabTile *) (new WoodSlabTile(Tile::woodSlab_Id, true)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB); - Tile::woodSlabHalf = (HalfSlabTile *) (new WoodSlabTile(Tile::woodSlabHalf_Id, false)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB); + Tile::woodSlab = static_cast((new WoodSlabTile(Tile::woodSlab_Id, true))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB)); + Tile::woodSlabHalf = static_cast((new WoodSlabTile(Tile::woodSlabHalf_Id, false))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB)); Tile::cocoa = (new CocoaTile(127)) ->setDestroyTime(0.2f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"cocoa")->sendTileData()->setDescriptionId(IDS_TILE_COCOA)->setUseDescriptionId(IDS_DESC_COCOA); Tile::stairs_sandstone = (new StairTile(128, Tile::sandStone,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_sand) ->setIconName(L"stairsSandstone")->setDescriptionId(IDS_TILE_STAIRS_SANDSTONE) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); Tile::emeraldOre = (new OreTile(129)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(SOUND_STONE)->setIconName(L"emerald_ore")->setDescriptionId(IDS_TILE_EMERALDORE)->setUseDescriptionId(IDS_DESC_EMERALDORE); Tile::enderChest = (new EnderChestTile(130)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_chest, Item::eMaterial_ender)->setDestroyTime(22.5f)->setExplodeable(1000)->setSoundType(SOUND_STONE)->setIconName(L"enderChest")->sendTileData()->setLightEmission(.5f)->setDescriptionId(IDS_TILE_ENDERCHEST)->setUseDescriptionId(IDS_DESC_ENDERCHEST); - Tile::tripWireSource = (TripWireSourceTile *)( new TripWireSourceTile(131) ) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_lever, Item::eMaterial_undefined)->setIconName(L"trip_wire_source")->sendTileData()->setDescriptionId(IDS_TILE_TRIPWIRE_SOURCE)->setUseDescriptionId(IDS_DESC_TRIPWIRE_SOURCE); + Tile::tripWireSource = static_cast((new TripWireSourceTile(131))->setBaseItemTypeAndMaterial(Item::eBaseItemType_lever, Item::eMaterial_undefined)->setIconName(L"trip_wire_source")->sendTileData()->setDescriptionId(IDS_TILE_TRIPWIRE_SOURCE)->setUseDescriptionId(IDS_DESC_TRIPWIRE_SOURCE)); Tile::tripWire = (new TripWireTile(132)) ->setIconName(L"trip_wire")->sendTileData()->setDescriptionId(IDS_TILE_TRIPWIRE)->setUseDescriptionId(IDS_DESC_TRIPWIRE); Tile::emeraldBlock = (new MetalTile(133)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_emerald)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(SOUND_METAL)->setIconName(L"emerald_block")->setDescriptionId(IDS_TILE_EMERALDBLOCK)->setUseDescriptionId(IDS_DESC_EMERALDBLOCK); Tile::woodStairsDark = (new StairTile(134, Tile::wood, TreeTile::DARK_TRUNK)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_sprucewood)->setIconName(L"stairsWoodSpruce")->setDescriptionId(IDS_TILE_STAIRS_SPRUCEWOOD) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); Tile::woodStairsBirch = (new StairTile(135, Tile::wood, TreeTile::BIRCH_TRUNK)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_birchwood)->setIconName(L"stairsWoodBirch")->setDescriptionId(IDS_TILE_STAIRS_BIRCHWOOD) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); Tile::woodStairsJungle =(new StairTile(136, Tile::wood, TreeTile::JUNGLE_TRUNK))->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_junglewood)->setIconName(L"stairsWoodJungle")->setDescriptionId(IDS_TILE_STAIRS_JUNGLEWOOD) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); Tile::commandBlock = (new CommandBlock(137)) ->setIndestructible()->setExplodeable(6000000)->setIconName(L"command_block")->setDescriptionId(IDS_TILE_COMMAND_BLOCK)->setUseDescriptionId(IDS_DESC_COMMAND_BLOCK); - Tile::beacon = (BeaconTile *) (new BeaconTile(138)) ->setLightEmission(1.0f)->setIconName(L"beacon")->setDescriptionId(IDS_TILE_BEACON)->setUseDescriptionId(IDS_DESC_BEACON); + Tile::beacon = static_cast((new BeaconTile(138))->setLightEmission(1.0f)->setIconName(L"beacon")->setDescriptionId(IDS_TILE_BEACON)->setUseDescriptionId(IDS_DESC_BEACON)); Tile::cobbleWall = (new WallTile(139, Tile::stoneBrick)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_fence, Item::eMaterial_stone)->setIconName(L"cobbleWall")->setDescriptionId(IDS_TILE_COBBLESTONE_WALL)->setUseDescriptionId(IDS_DESC_COBBLESTONE_WALL); Tile::flowerPot = (new FlowerPotTile(140)) ->setDestroyTime(0.0f)->setSoundType(SOUND_NORMAL)->setIconName(L"flower_pot")->setDescriptionId(IDS_TILE_FLOWERPOT)->setUseDescriptionId(IDS_DESC_FLOWERPOT); @@ -423,13 +423,13 @@ void Tile::staticCtor() Tile::chest_trap = (new ChestTile(146, ChestTile::TYPE_TRAP)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_chest, Item::eMaterial_trap)->setDestroyTime(2.5f)->setSoundType(SOUND_WOOD)->setDescriptionId(IDS_TILE_CHEST_TRAP)->setUseDescriptionId(IDS_DESC_CHEST_TRAP); Tile::weightedPlate_light = (new WeightedPressurePlateTile(147, L"gold_block", Material::metal, Redstone::SIGNAL_MAX)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_pressureplate, Item::eMaterial_gold)->setDestroyTime(0.5f)->setSoundType(SOUND_WOOD)->setDescriptionId(IDS_TILE_WEIGHTED_PLATE_LIGHT)->setUseDescriptionId(IDS_DESC_WEIGHTED_PLATE_LIGHT); Tile::weightedPlate_heavy = (new WeightedPressurePlateTile(148, L"iron_block", Material::metal, Redstone::SIGNAL_MAX * 10))->setBaseItemTypeAndMaterial(Item::eBaseItemType_pressureplate, Item::eMaterial_iron)->setDestroyTime(0.5f)->setSoundType(SOUND_WOOD)->setDescriptionId(IDS_TILE_WEIGHTED_PLATE_HEAVY)->setUseDescriptionId(IDS_DESC_WEIGHTED_PLATE_HEAVY); - Tile::comparator_off = (ComparatorTile *) (new ComparatorTile(149, false)) ->setDestroyTime(0.0f)->setSoundType(SOUND_WOOD)->setIconName(L"comparator_off")->setDescriptionId(IDS_TILE_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR); - Tile::comparator_on = (ComparatorTile *) (new ComparatorTile(150, true)) ->setDestroyTime(0.0f)->setLightEmission(10 / 16.0f)->setSoundType(SOUND_WOOD)->setIconName(L"comparator_on")->setDescriptionId(IDS_TILE_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR); + Tile::comparator_off = static_cast((new ComparatorTile(149, false))->setDestroyTime(0.0f)->setSoundType(SOUND_WOOD)->setIconName(L"comparator_off")->setDescriptionId(IDS_TILE_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR)); + Tile::comparator_on = static_cast((new ComparatorTile(150, true))->setDestroyTime(0.0f)->setLightEmission(10 / 16.0f)->setSoundType(SOUND_WOOD)->setIconName(L"comparator_on")->setDescriptionId(IDS_TILE_COMPARATOR)->setUseDescriptionId(IDS_DESC_COMPARATOR)); - Tile::daylightDetector = (DaylightDetectorTile *) (new DaylightDetectorTile(151))->setDestroyTime(0.2f)->setSoundType(SOUND_WOOD)->setIconName(L"daylight_detector")->setDescriptionId(IDS_TILE_DAYLIGHT_DETECTOR)->setUseDescriptionId(IDS_DESC_DAYLIGHT_DETECTOR); + Tile::daylightDetector = static_cast((new DaylightDetectorTile(151))->setDestroyTime(0.2f)->setSoundType(SOUND_WOOD)->setIconName(L"daylight_detector")->setDescriptionId(IDS_TILE_DAYLIGHT_DETECTOR)->setUseDescriptionId(IDS_DESC_DAYLIGHT_DETECTOR)); Tile::redstoneBlock = (new PoweredMetalTile(152)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_redstone)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(SOUND_METAL)->setIconName(L"redstone_block")->setDescriptionId(IDS_TILE_REDSTONE_BLOCK)->setUseDescriptionId(IDS_DESC_REDSTONE_BLOCK); Tile::netherQuartz = (new OreTile(153)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(SOUND_STONE)->setIconName(L"quartz_ore")->setDescriptionId(IDS_TILE_NETHER_QUARTZ)->setUseDescriptionId(IDS_DESC_NETHER_QUARTZ_ORE); - Tile::hopper = (HopperTile *)(new HopperTile(154)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_redstoneContainer, Item::eMaterial_undefined)->setDestroyTime(3.0f)->setExplodeable(8)->setSoundType(SOUND_WOOD)->setIconName(L"hopper")->setDescriptionId(IDS_TILE_HOPPER)->setUseDescriptionId(IDS_DESC_HOPPER); + Tile::hopper = static_cast((new HopperTile(154))->setBaseItemTypeAndMaterial(Item::eBaseItemType_redstoneContainer, Item::eMaterial_undefined)->setDestroyTime(3.0f)->setExplodeable(8)->setSoundType(SOUND_WOOD)->setIconName(L"hopper")->setDescriptionId(IDS_TILE_HOPPER)->setUseDescriptionId(IDS_DESC_HOPPER)); Tile::quartzBlock = (new QuartzBlockTile(155)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_quartz)->setSoundType(SOUND_STONE)->setDestroyTime(0.8f)->setIconName(L"quartz_block")->setDescriptionId(IDS_TILE_QUARTZ_BLOCK)->setUseDescriptionId(IDS_DESC_QUARTZ_BLOCK); Tile::stairs_quartz = (new StairTile(156, Tile::quartzBlock, QuartzBlockTile::TYPE_DEFAULT)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_quartz)->setIconName(L"stairsQuartz")->setDescriptionId(IDS_TILE_STAIRS_QUARTZ)->setUseDescriptionId(IDS_DESC_STAIRS); Tile::activatorRail = (new PoweredRailTile(157)) ->setDestroyTime(0.7f)->setSoundType(SOUND_METAL)->setIconName(L"rail_activator")->setDescriptionId(IDS_TILE_ACTIVATOR_RAIL)->setUseDescriptionId(IDS_DESC_ACTIVATOR_RAIL); @@ -464,7 +464,7 @@ void Tile::staticCtor() Item::items[vine_Id] = ( new ColoredTileItem(Tile::vine_Id - 256, false))->setDescriptionId(IDS_TILE_VINE)->setUseDescriptionId(IDS_DESC_VINE); int idsData[3] = {IDS_TILE_SHRUB, IDS_TILE_TALL_GRASS, IDS_TILE_FERN}; intArray ids = intArray(idsData, 3); - Item::items[tallgrass_Id] = ( (ColoredTileItem *)(new ColoredTileItem(Tile::tallgrass_Id - 256, true))->setDescriptionId(IDS_TILE_TALL_GRASS))->setDescriptionPostfixes(ids); + Item::items[tallgrass_Id] = static_cast((new ColoredTileItem(Tile::tallgrass_Id - 256, true))->setDescriptionId(IDS_TILE_TALL_GRASS))->setDescriptionPostfixes(ids); Item::items[topSnow_Id] = ( new SnowItem(topSnow_Id - 256, topSnow) ); Item::items[waterLily_Id] = ( new WaterLilyTileItem(Tile::waterLily_Id - 256)); Item::items[pistonBase_Id] = ( new PistonTileItem(Tile::pistonBase_Id - 256) )->setDescriptionId(IDS_TILE_PISTON_BASE)->setUseDescriptionId(IDS_DESC_PISTON); @@ -597,7 +597,7 @@ Tile *Tile::setLightBlock(int i) Tile *Tile::setLightEmission(float f) { - Tile::lightEmission[id] = (int) (Level::MAX_BRIGHTNESS * f); + Tile::lightEmission[id] = static_cast(Level::MAX_BRIGHTNESS * f); return this; } @@ -671,7 +671,7 @@ Tile *Tile::disableMipmap() void Tile::setShape(float x0, float y0, float z0, float x1, float y1, float z1) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); tls->xx0 = x0; tls->yy0 = y0; tls->zz0 = z0; @@ -721,7 +721,7 @@ bool Tile::isFaceVisible(Level *level, int x, int y, int z, int f) bool Tile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); if (face == 0 && tls->yy0 > 0) return true; @@ -738,7 +738,7 @@ int Tile::getFaceFlags(LevelSource *level, int x, int y, int z) { int faceFlags = 0; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); @@ -813,7 +813,7 @@ Icon *Tile::getTexture(int face) AABB *Tile::getTileAABB(Level *level, int x, int y, int z) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1); @@ -827,7 +827,7 @@ void Tile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxe AABB *Tile::getAABB(Level *level, int x, int y, int z) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1); @@ -965,7 +965,7 @@ HitResult *Tile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b) a = a->add(-xt, -yt, -zt); b = b->add(-xt, -yt, -zt); - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); Vec3 *xh0 = a->clipX(b, tls->xx0); Vec3 *xh1 = a->clipX(b, tls->xx1); @@ -1002,7 +1002,7 @@ bool Tile::containsX(Vec3 *v) { if( v == NULL) return false; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return v->y >= tls->yy0 && v->y <= tls->yy1 && v->z >= tls->zz0 && v->z <= tls->zz1; @@ -1012,7 +1012,7 @@ bool Tile::containsY(Vec3 *v) { if( v == NULL) return false; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return v->x >= tls->xx0 && v->x <= tls->xx1 && v->z >= tls->zz0 && v->z <= tls->zz1; @@ -1022,7 +1022,7 @@ bool Tile::containsZ(Vec3 *v) { if( v == NULL) return false; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return v->x >= tls->xx0 && v->x <= tls->xx1 && v->y >= tls->yy0 && v->y <= tls->yy1; @@ -1092,14 +1092,14 @@ void Tile::handleEntityInside(Level *level, int x, int y, int z, shared_ptr forceEntity) // 4J added forceData, forceEntity param { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); } double Tile::getShapeX0() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->xx0; @@ -1107,7 +1107,7 @@ double Tile::getShapeX0() double Tile::getShapeX1() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->xx1; @@ -1115,7 +1115,7 @@ double Tile::getShapeX1() double Tile::getShapeY0() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->yy0; @@ -1123,7 +1123,7 @@ double Tile::getShapeY0() double Tile::getShapeY1() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->yy1; @@ -1131,7 +1131,7 @@ double Tile::getShapeY1() double Tile::getShapeZ0() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->zz0; @@ -1139,7 +1139,7 @@ double Tile::getShapeZ0() double Tile::getShapeZ1() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->zz1; diff --git a/Minecraft.World/TileEntityDataPacket.cpp b/Minecraft.World/TileEntityDataPacket.cpp index 41be45267..10d64bb0a 100644 --- a/Minecraft.World/TileEntityDataPacket.cpp +++ b/Minecraft.World/TileEntityDataPacket.cpp @@ -50,7 +50,7 @@ void TileEntityDataPacket::write(DataOutputStream *dos) dos->writeInt(x); dos->writeShort(y); dos->writeInt(z); - dos->writeByte((byte) type); + dos->writeByte(static_cast(type)); writeNbt(tag, dos); } diff --git a/Minecraft.World/TileUpdatePacket.cpp b/Minecraft.World/TileUpdatePacket.cpp index a14231290..067d0615f 100644 --- a/Minecraft.World/TileUpdatePacket.cpp +++ b/Minecraft.World/TileUpdatePacket.cpp @@ -31,7 +31,7 @@ void TileUpdatePacket::read(DataInputStream *dis) //throws IOException y = dis->readUnsignedByte(); z = dis->readInt(); - block = (int)dis->readShort() & 0xffff; + block = static_cast(dis->readShort()) & 0xffff; BYTE dataLevel = dis->readByte(); data = dataLevel & 0xf; diff --git a/Minecraft.World/ToolRecipies.cpp b/Minecraft.World/ToolRecipies.cpp index 8ee4bbab6..82b02df1c 100644 --- a/Minecraft.World/ToolRecipies.cpp +++ b/Minecraft.World/ToolRecipies.cpp @@ -103,7 +103,7 @@ void ToolRecipies::addRecipes(Recipes *r) } } } - r->addShapedRecipy(new ItemInstance((Item *)Item::shears), + r->addShapedRecipy(new ItemInstance(static_cast(Item::shears)), L"sscig", L" #", // L"# ", // diff --git a/Minecraft.World/TopSnowTile.cpp b/Minecraft.World/TopSnowTile.cpp index 033b4eb24..d165500cf 100644 --- a/Minecraft.World/TopSnowTile.cpp +++ b/Minecraft.World/TopSnowTile.cpp @@ -27,7 +27,7 @@ AABB *TopSnowTile::getAABB(Level *level, int x, int y, int z) { int height = level->getData(x, y, z) & HEIGHT_MASK; float offset = 2.0f / SharedConstants::WORLD_RESOLUTION; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1); } diff --git a/Minecraft.World/TripWireTile.cpp b/Minecraft.World/TripWireTile.cpp index b8ae9f330..fb3fe150c 100644 --- a/Minecraft.World/TripWireTile.cpp +++ b/Minecraft.World/TripWireTile.cpp @@ -165,7 +165,7 @@ void TripWireTile::checkPressed(Level *level, int x, int y, int z) bool wasPressed = (data & MASK_POWERED) == MASK_POWERED; bool shouldBePressed = false; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); vector > *entities = level->getEntities(nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1)); if (!entities->empty()) { diff --git a/Minecraft.World/UpdateGameRuleProgressPacket.cpp b/Minecraft.World/UpdateGameRuleProgressPacket.cpp index 9459ed2b1..6f6530d4f 100644 --- a/Minecraft.World/UpdateGameRuleProgressPacket.cpp +++ b/Minecraft.World/UpdateGameRuleProgressPacket.cpp @@ -35,7 +35,7 @@ UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket(ConsoleGameRules::EGa void UpdateGameRuleProgressPacket::read(DataInputStream *dis) //throws IOException { - m_definitionType = (ConsoleGameRules::EGameRuleType)dis->readInt(); + m_definitionType = static_cast(dis->readInt()); m_messageId = readUtf(dis,64); m_icon = dis->readInt(); m_auxValue = dis->readByte(); @@ -71,5 +71,5 @@ void UpdateGameRuleProgressPacket::handle(PacketListener *listener) int UpdateGameRuleProgressPacket::getEstimatedSize() { - return (int)m_messageId.length() + 4 + m_data.length; + return static_cast(m_messageId.length()) + 4 + m_data.length; } \ No newline at end of file diff --git a/Minecraft.World/UpdateMobEffectPacket.cpp b/Minecraft.World/UpdateMobEffectPacket.cpp index e2f6233ec..e8879d761 100644 --- a/Minecraft.World/UpdateMobEffectPacket.cpp +++ b/Minecraft.World/UpdateMobEffectPacket.cpp @@ -19,8 +19,8 @@ UpdateMobEffectPacket::UpdateMobEffectPacket() UpdateMobEffectPacket::UpdateMobEffectPacket(int entityId, MobEffectInstance *effect) { this->entityId = entityId; - effectId = (BYTE) (effect->getId() & 0xff); - effectAmplifier = (char) (effect->getAmplifier() & 0xff); + effectId = static_cast(effect->getId() & 0xff); + effectAmplifier = static_cast(effect->getAmplifier() & 0xff); if (effect->getDuration() > Short::MAX_VALUE) { @@ -28,7 +28,7 @@ UpdateMobEffectPacket::UpdateMobEffectPacket(int entityId, MobEffectInstance *ef } else { - effectDurationTicks = (short) effect->getDuration(); + effectDurationTicks = static_cast(effect->getDuration()); } } diff --git a/Minecraft.World/UseItemPacket.cpp b/Minecraft.World/UseItemPacket.cpp index 55e44342a..f8a5dac8a 100644 --- a/Minecraft.World/UseItemPacket.cpp +++ b/Minecraft.World/UseItemPacket.cpp @@ -56,9 +56,9 @@ void UseItemPacket::write(DataOutputStream *dos) //throws IOException dos->write(face); writeItem(item, dos); - dos->write((int) (clickX * CLICK_ACCURACY)); - dos->write((int) (clickY * CLICK_ACCURACY)); - dos->write((int) (clickZ * CLICK_ACCURACY)); + dos->write(static_cast(clickX * CLICK_ACCURACY)); + dos->write(static_cast(clickY * CLICK_ACCURACY)); + dos->write(static_cast(clickZ * CLICK_ACCURACY)); } void UseItemPacket::handle(PacketListener *listener) diff --git a/Minecraft.World/Vec3.cpp b/Minecraft.World/Vec3.cpp index 1fc26fd5b..69a332ccf 100644 --- a/Minecraft.World/Vec3.cpp +++ b/Minecraft.World/Vec3.cpp @@ -34,7 +34,7 @@ void Vec3::UseDefaultThreadStorage() void Vec3::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); if( tls == tlsDefault ) return; delete tls; @@ -55,7 +55,7 @@ void Vec3::resetPool() Vec3 *Vec3::newTemp(double x, double y, double z) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); Vec3 *thisVec = &tls->pool[tls->poolPointer]; thisVec->set(x, y, z); tls->poolPointer = ( tls->poolPointer + 1 ) % ThreadStorage::POOL_SIZE; diff --git a/Minecraft.World/VillageFeature.cpp b/Minecraft.World/VillageFeature.cpp index 5249256cd..e1ad19270 100644 --- a/Minecraft.World/VillageFeature.cpp +++ b/Minecraft.World/VillageFeature.cpp @@ -134,7 +134,7 @@ VillageFeature::VillageStart::VillageStart(Level *level, Random *random, int chu // prioritize roads if (pendingRoads->empty()) { - int pos = random->nextInt((int)pendingHouses->size()); + int pos = random->nextInt(static_cast(pendingHouses->size())); auto it = pendingHouses->begin() + pos; StructurePiece *structurePiece = *it; pendingHouses->erase(it); @@ -142,7 +142,7 @@ VillageFeature::VillageStart::VillageStart(Level *level, Random *random, int chu } else { - int pos = random->nextInt((int)pendingRoads->size()); + int pos = random->nextInt(static_cast(pendingRoads->size())); auto it = pendingRoads->begin() + pos; StructurePiece *structurePiece = *it; pendingRoads->erase(it); diff --git a/Minecraft.World/VillagePieces.cpp b/Minecraft.World/VillagePieces.cpp index 1737d6e05..cee09e800 100644 --- a/Minecraft.World/VillagePieces.cpp +++ b/Minecraft.World/VillagePieces.cpp @@ -512,10 +512,10 @@ VillagePieces::Well::Well(StartPiece *startPiece, int genDepth, Random *random, void VillagePieces::Well::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::WEST, getGenDepth()); - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::EAST, getGenDepth()); - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::WEST, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::EAST, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); } bool VillagePieces::Well::postProcess(Level *level, Random *random, BoundingBox *chunkBB) @@ -628,7 +628,7 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, listnextInt(5); while (depth < length - 8) { - StructurePiece *piece = generateHouseNorthernLeft((StartPiece *) startPiece, pieces, random, 0, depth); + StructurePiece *piece = generateHouseNorthernLeft(static_cast(startPiece), pieces, random, 0, depth); if (piece != NULL) { depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan()); @@ -641,7 +641,7 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, listnextInt(5); while (depth < length - 8) { - StructurePiece *piece = generateHouseNorthernRight((StartPiece *) startPiece, pieces, random, 0, depth); + StructurePiece *piece = generateHouseNorthernRight(static_cast(startPiece), pieces, random, 0, depth); if (piece != NULL) { depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan()); @@ -655,16 +655,16 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, listx0 - 1, boundingBox->y0, boundingBox->z0, Direction::WEST, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z0, Direction::WEST, getGenDepth()); break; case Direction::SOUTH: - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z1 - 2, Direction::WEST, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z1 - 2, Direction::WEST, getGenDepth()); break; case Direction::EAST: - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); break; case Direction::WEST: - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); break; } } @@ -673,16 +673,16 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, listx1 + 1, boundingBox->y0, boundingBox->z0, Direction::EAST, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z0, Direction::EAST, getGenDepth()); break; case Direction::SOUTH: - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z1 - 2, Direction::EAST, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z1 - 2, Direction::EAST, getGenDepth()); break; case Direction::EAST: - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); break; case Direction::WEST: - generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); + generateAndAddRoadPiece(static_cast(startPiece), pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); break; } } diff --git a/Minecraft.World/VillageSiege.cpp b/Minecraft.World/VillageSiege.cpp index e3d20ef34..0ce8a4e12 100644 --- a/Minecraft.World/VillageSiege.cpp +++ b/Minecraft.World/VillageSiege.cpp @@ -80,7 +80,7 @@ bool VillageSiege::tryToSetupSiege() vector > *players = &level->players; for(auto& player : *players) { - shared_ptr _village = level->villages->getClosestVillage((int) player->x, (int) player->y, (int) player->z, 1); + shared_ptr _village = level->villages->getClosestVillage(static_cast(player->x), static_cast(player->y), static_cast(player->z), 1); village = _village; if (_village == NULL) continue; @@ -95,9 +95,9 @@ bool VillageSiege::tryToSetupSiege() bool overlaps = false; for (int i = 0; i < 10; ++i) { - spawnX = center->x + (int) (Mth::cos(level->random->nextFloat() * PI * 2.f) * radius * 0.9); + spawnX = center->x + static_cast(Mth::cos(level->random->nextFloat() * PI * 2.f) * radius * 0.9); spawnY = center->y; - spawnZ = center->z + (int) (Mth::sin(level->random->nextFloat() * PI * 2.f) * radius * 0.9); + spawnZ = center->z + static_cast(Mth::sin(level->random->nextFloat() * PI * 2.f) * radius * 0.9); overlaps = false; vector > *villages = level->villages->getVillages(); //for (Village v : level.villages.getVillages()) diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp index 18ed71785..cc17104f1 100644 --- a/Minecraft.World/Villager.cpp +++ b/Minecraft.World/Villager.cpp @@ -105,7 +105,7 @@ void Villager::serverAiMobStep() else { Pos *center = _village->getCenter(); - restrictTo(center->x, center->y, center->z, (int)((float)_village->getRadius() * 0.6f)); + restrictTo(center->x, center->y, center->z, static_cast((float)_village->getRadius() * 0.6f)); if (rewardPlayersOnFirstVillage) { rewardPlayersOnFirstVillage = false; diff --git a/Minecraft.World/VillagerGolem.cpp b/Minecraft.World/VillagerGolem.cpp index dba80ffa7..691bade8e 100644 --- a/Minecraft.World/VillagerGolem.cpp +++ b/Minecraft.World/VillagerGolem.cpp @@ -53,7 +53,7 @@ VillagerGolem::VillagerGolem(Level *level) : Golem(level) void VillagerGolem::defineSynchedData() { Golem::defineSynchedData(); - entityData->define(DATA_FLAGS_ID, (byte) 0); + entityData->define(DATA_FLAGS_ID, static_cast(0)); } bool VillagerGolem::useNewAi() @@ -72,7 +72,7 @@ void VillagerGolem::serverAiMobStep() else { Pos *center = _village->getCenter(); - restrictTo(center->x, center->y, center->z, (int)((float)_village->getRadius()) * 0.6f); + restrictTo(center->x, center->y, center->z, static_cast((float)_village->getRadius()) * 0.6f); } } @@ -234,11 +234,11 @@ void VillagerGolem::setPlayerCreated(bool value) byte current = entityData->getByte(DATA_FLAGS_ID); if (value) { - entityData->set(DATA_FLAGS_ID, (byte) (current | 0x01)); + entityData->set(DATA_FLAGS_ID, static_cast(current | 0x01)); } else { - entityData->set(DATA_FLAGS_ID, (byte) (current & ~0x01)); + entityData->set(DATA_FLAGS_ID, static_cast(current & ~0x01)); } } diff --git a/Minecraft.World/Villages.cpp b/Minecraft.World/Villages.cpp index e636ed74e..b5fb1b471 100644 --- a/Minecraft.World/Villages.cpp +++ b/Minecraft.World/Villages.cpp @@ -117,7 +117,7 @@ void Villages::cluster() bool found = false; for(auto& village : villages) { - int dist = (int) village->getCenter()->distSqr(di->x, di->y, di->z); + int dist = static_cast(village->getCenter()->distSqr(di->x, di->y, di->z)); int radius = MaxDoorDist + village->getRadius(); if (dist > radius * radius) continue; village->addDoorInfo(di); @@ -173,7 +173,7 @@ shared_ptr Villages::getDoorInfo(int x, int y, int z) void Villages::createDoorInfo(int x, int y, int z) { - int dir = ((DoorTile *) Tile::door_wood)->getDir(level, x, y, z); + int dir = static_cast(Tile::door_wood)->getDir(level, x, y, z); if (dir == 0 || dir == 2) { int canSeeX = 0; diff --git a/Minecraft.World/WaterLilyTile.cpp b/Minecraft.World/WaterLilyTile.cpp index 15e43b9db..ec789afc7 100644 --- a/Minecraft.World/WaterLilyTile.cpp +++ b/Minecraft.World/WaterLilyTile.cpp @@ -33,7 +33,7 @@ void WaterlilyTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBL AABB *WaterlilyTile::getAABB(Level *level, int x, int y, int z) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1); diff --git a/Minecraft.World/WeighedTreasure.cpp b/Minecraft.World/WeighedTreasure.cpp index ec4280e4f..37b04fffc 100644 --- a/Minecraft.World/WeighedTreasure.cpp +++ b/Minecraft.World/WeighedTreasure.cpp @@ -22,7 +22,7 @@ void WeighedTreasure::addChestItems(Random *random, WeighedTreasureArray items, { for (int r = 0; r < numRolls; r++) { - WeighedTreasure *treasure = (WeighedTreasure *) WeighedRandom::getRandomItem(random, *((WeighedRandomItemArray *)&items)); + WeighedTreasure *treasure = static_cast(WeighedRandom::getRandomItem(random, *((WeighedRandomItemArray *)&items))); int count = treasure->minCount + random->nextInt(treasure->maxCount - treasure->minCount + 1); if (treasure->item->getMaxStackSize() >= count) @@ -48,7 +48,7 @@ void WeighedTreasure::addDispenserItems(Random *random, WeighedTreasureArray ite { for (int r = 0; r < numRolls; r++) { - WeighedTreasure *treasure = (WeighedTreasure *) WeighedRandom::getRandomItem(random, *((WeighedRandomItemArray *)&items)); + WeighedTreasure *treasure = static_cast(WeighedRandom::getRandomItem(random, *((WeighedRandomItemArray *)&items))); int count = treasure->minCount + random->nextInt(treasure->maxCount - treasure->minCount + 1); if (treasure->item->getMaxStackSize() >= count) diff --git a/Minecraft.World/WeightedPressurePlateTile.cpp b/Minecraft.World/WeightedPressurePlateTile.cpp index 352747ce8..c9b7d5c88 100644 --- a/Minecraft.World/WeightedPressurePlateTile.cpp +++ b/Minecraft.World/WeightedPressurePlateTile.cpp @@ -25,7 +25,7 @@ int WeightedPressurePlateTile::getSignalStrength(Level *level, int x, int y, int } else { - float pct = min(maxWeight, count) / (float) maxWeight; + float pct = min(maxWeight, count) / static_cast(maxWeight); return Mth::ceil(pct * Redstone::SIGNAL_MAX); } } diff --git a/Minecraft.World/Witch.cpp b/Minecraft.World/Witch.cpp index c697d4676..592fc5cd8 100644 --- a/Minecraft.World/Witch.cpp +++ b/Minecraft.World/Witch.cpp @@ -43,7 +43,7 @@ void Witch::defineSynchedData() { Monster::defineSynchedData(); - getEntityData()->define(DATA_USING_ITEM, (byte) 0); + getEntityData()->define(DATA_USING_ITEM, static_cast(0)); } int Witch::getAmbientSound() @@ -63,7 +63,7 @@ int Witch::getDeathSound() void Witch::setUsingItem(bool isUsing) { - getEntityData()->set(DATA_USING_ITEM, isUsing ? (byte) 1 : (byte) 0); + getEntityData()->set(DATA_USING_ITEM, isUsing ? static_cast(1) : static_cast(0)); } bool Witch::isUsingItem() diff --git a/Minecraft.World/WitherBoss.cpp b/Minecraft.World/WitherBoss.cpp index 84cf13825..8a568b894 100644 --- a/Minecraft.World/WitherBoss.cpp +++ b/Minecraft.World/WitherBoss.cpp @@ -148,7 +148,7 @@ void WitherBoss::aiStep() } if ((xd * xd + zd * zd) > .05f) { - yRot = (float) atan2(zd, xd) * Mth::RADDEG - 90; + yRot = static_cast(atan2(zd, xd)) * Mth::RADDEG - 90; } Monster::aiStep(); @@ -178,8 +178,8 @@ void WitherBoss::aiStep() double zd = e->z - hz; double sd = Mth::sqrt(xd * xd + zd * zd); - float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90; - float xRotD = (float) -(atan2(yd, sd) * 180 / PI); + float yRotD = static_cast(atan2(zd, xd) * 180 / PI) - 90; + float xRotD = static_cast(-(atan2(yd, sd) * 180 / PI)); xRotHeads[i] = rotlerp(xRotHeads[i], xRotD, 40); yRotHeads[i] = rotlerp(yRotHeads[i], yRotD, 10); @@ -221,7 +221,7 @@ void WitherBoss::newServerAiStep() if (newCount <= 0) { level->explode(shared_from_this(), x, y + getHeadHeight(), z, 7, false, level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)); - level->globalLevelEvent(LevelEvent::SOUND_WITHER_BOSS_SPAWN, (int) x, (int) y, (int) z, 0); + level->globalLevelEvent(LevelEvent::SOUND_WITHER_BOSS_SPAWN, static_cast(x), static_cast(y), static_cast(z), 0); } setInvulnerableTicks(newCount); @@ -346,7 +346,7 @@ void WitherBoss::newServerAiStep() } if (destroyed) { - level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_DOOR_CRASH, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_DOOR_CRASH, static_cast(x), static_cast(y), static_cast(z), 0); } } } @@ -427,7 +427,7 @@ void WitherBoss::performRangedAttack(int head, shared_ptr target) void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz, bool dangerous) { - level->levelEvent(nullptr, LevelEvent::SOUND_WITHER_BOSS_SHOOT, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_WITHER_BOSS_SHOOT, static_cast(x), static_cast(y), static_cast(z), 0); double hx = getHeadX(head); double hy = getHeadY(head); diff --git a/Minecraft.World/WitherSkull.cpp b/Minecraft.World/WitherSkull.cpp index d67660c40..92f810df7 100644 --- a/Minecraft.World/WitherSkull.cpp +++ b/Minecraft.World/WitherSkull.cpp @@ -111,7 +111,7 @@ bool WitherSkull::hurt(DamageSource *source, float damage) void WitherSkull::defineSynchedData() { - entityData->define(DATA_DANGEROUS, (byte) 0); + entityData->define(DATA_DANGEROUS, static_cast(0)); } bool WitherSkull::isDangerous() @@ -121,7 +121,7 @@ bool WitherSkull::isDangerous() void WitherSkull::setDangerous(bool value) { - entityData->set(DATA_DANGEROUS, value ? (byte) 1 : (byte) 0); + entityData->set(DATA_DANGEROUS, value ? static_cast(1) : static_cast(0)); } bool WitherSkull::shouldBurn() diff --git a/Minecraft.World/Wolf.cpp b/Minecraft.World/Wolf.cpp index 1988382e1..2443c6632 100644 --- a/Minecraft.World/Wolf.cpp +++ b/Minecraft.World/Wolf.cpp @@ -100,8 +100,8 @@ void Wolf::defineSynchedData() { TamableAnimal::defineSynchedData(); entityData->define(DATA_HEALTH_ID, getHealth()); - entityData->define(DATA_INTERESTED_ID, (byte)0); - entityData->define(DATA_COLLAR_COLOR, (byte) ColoredTile::getTileDataForItemAuxValue(DyePowderItem::RED)); + entityData->define(DATA_INTERESTED_ID, static_cast(0)); + entityData->define(DATA_COLLAR_COLOR, static_cast(ColoredTile::getTileDataForItemAuxValue(DyePowderItem::RED))); } void Wolf::playStepSound(int xt, int yt, int zt, int t) @@ -114,7 +114,7 @@ void Wolf::addAdditonalSaveData(CompoundTag *tag) TamableAnimal::addAdditonalSaveData(tag); tag->putBoolean(L"Angry", isAngry()); - tag->putByte(L"CollarColor", (byte) getCollarColor()); + tag->putByte(L"CollarColor", static_cast(getCollarColor())); } void Wolf::readAdditionalSaveData(CompoundTag *tag) @@ -224,8 +224,8 @@ void Wolf::tick() if (shakeAnim > 0.4f) { - float yt = (float) bb->y0; - int shakeCount = (int) (Mth::sin((shakeAnim - 0.4f) * PI) * 7.0f); + float yt = static_cast(bb->y0); + int shakeCount = static_cast(Mth::sin((shakeAnim - 0.4f) * PI) * 7.0f); for (int i = 0; i < shakeCount; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth * 0.5f; @@ -469,7 +469,7 @@ bool Wolf::isFood(shared_ptr item) { if (item == NULL) return false; if (dynamic_cast(Item::items[item->id]) == NULL) return false; - return ((FoodItem *) Item::items[item->id])->isMeat(); + return static_cast(Item::items[item->id])->isMeat(); } int Wolf::getMaxSpawnClusterSize() @@ -488,11 +488,11 @@ void Wolf::setAngry(bool value) byte current = entityData->getByte(DATA_FLAGS_ID); if (value) { - entityData->set(DATA_FLAGS_ID, (byte) (current | 0x02)); + entityData->set(DATA_FLAGS_ID, static_cast(current | 0x02)); } else { - entityData->set(DATA_FLAGS_ID, (byte) (current & ~0x02)); + entityData->set(DATA_FLAGS_ID, static_cast(current & ~0x02)); } } @@ -503,7 +503,7 @@ int Wolf::getCollarColor() void Wolf::setCollarColor(int color) { - entityData->set(DATA_COLLAR_COLOR, (byte) (color & 0xF)); + entityData->set(DATA_COLLAR_COLOR, static_cast(color & 0xF)); } // 4J-PB added for tooltips @@ -536,11 +536,11 @@ void Wolf::setIsInterested(bool value) { if (value) { - entityData->set(DATA_INTERESTED_ID, (byte) 1); + entityData->set(DATA_INTERESTED_ID, static_cast(1)); } else { - entityData->set(DATA_INTERESTED_ID, (byte) 0); + entityData->set(DATA_INTERESTED_ID, static_cast(0)); } } diff --git a/Minecraft.World/WoolCarpetTile.cpp b/Minecraft.World/WoolCarpetTile.cpp index b509a312c..370b40100 100644 --- a/Minecraft.World/WoolCarpetTile.cpp +++ b/Minecraft.World/WoolCarpetTile.cpp @@ -20,7 +20,7 @@ AABB *WoolCarpetTile::getAABB(Level *level, int x, int y, int z) { int height = 0; float offset = 1.0f / SharedConstants::WORLD_RESOLUTION; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1); diff --git a/Minecraft.World/Zombie.cpp b/Minecraft.World/Zombie.cpp index 7cdc31809..d13f18fe1 100644 --- a/Minecraft.World/Zombie.cpp +++ b/Minecraft.World/Zombie.cpp @@ -68,9 +68,9 @@ void Zombie::defineSynchedData() { Monster::defineSynchedData(); - getEntityData()->define(DATA_BABY_ID, (byte) 0); - getEntityData()->define(DATA_VILLAGER_ID, (byte) 0); - getEntityData()->define(DATA_CONVERTING_ID, (byte) 0); + getEntityData()->define(DATA_BABY_ID, static_cast(0)); + getEntityData()->define(DATA_VILLAGER_ID, static_cast(0)); + getEntityData()->define(DATA_CONVERTING_ID, static_cast(0)); } int Zombie::getArmorValue() @@ -87,12 +87,12 @@ bool Zombie::useNewAi() bool Zombie::isBaby() { - return getEntityData()->getByte(DATA_BABY_ID) == (byte) 1; + return getEntityData()->getByte(DATA_BABY_ID) == static_cast(1); } void Zombie::setBaby(bool baby) { - getEntityData()->set(DATA_BABY_ID, (byte) (baby ? 1 : 0)); + getEntityData()->set(DATA_BABY_ID, static_cast(baby ? 1 : 0)); if (level != NULL && !level->isClientSide) { @@ -107,12 +107,12 @@ void Zombie::setBaby(bool baby) bool Zombie::isVillager() { - return getEntityData()->getByte(DATA_VILLAGER_ID) == (byte) 1; + return getEntityData()->getByte(DATA_VILLAGER_ID) == static_cast(1); } void Zombie::setVillager(bool villager) { - getEntityData()->set(DATA_VILLAGER_ID, (byte) (villager ? 1 : 0)); + getEntityData()->set(DATA_VILLAGER_ID, static_cast(villager ? 1 : 0)); } void Zombie::aiStep() @@ -120,7 +120,7 @@ void Zombie::aiStep() if (level->isDay() && !level->isClientSide && !isBaby()) { float br = getBrightness(1); - if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && level->canSeeSky(Mth::floor(x), (int)floor( y + 0.5 ), Mth::floor(z))) + if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && level->canSeeSky(Mth::floor(x), static_cast(floor(y + 0.5)), Mth::floor(z))) { bool burn = true; @@ -324,7 +324,7 @@ void Zombie::killed(shared_ptr mob) if (mob->isBaby()) zombie->setBaby(true); level->addEntity(zombie); - level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_INFECTED, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_INFECTED, static_cast(x), static_cast(y), static_cast(z), 0); } } @@ -342,7 +342,7 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /* if ( dynamic_cast( groupData ) != NULL) { - ZombieGroupData *zombieData = (ZombieGroupData *) groupData; + ZombieGroupData *zombieData = static_cast(groupData); if (zombieData->isVillager) { @@ -414,7 +414,7 @@ bool Zombie::mobInteract(shared_ptr player) void Zombie::startConverting(int time) { villagerConversionTime = time; - getEntityData()->set(DATA_CONVERTING_ID, (byte) 1); + getEntityData()->set(DATA_CONVERTING_ID, static_cast(1)); removeEffect(MobEffect::weakness->id); addEffect(new MobEffectInstance(MobEffect::damageBoost->id, time, min(level->difficulty - 1, 0))); @@ -441,7 +441,7 @@ bool Zombie::removeWhenFarAway() bool Zombie::isConverting() { - return getEntityData()->getByte(DATA_CONVERTING_ID) == (byte) 1; + return getEntityData()->getByte(DATA_CONVERTING_ID) == static_cast(1); } void Zombie::finishConversion() @@ -455,7 +455,7 @@ void Zombie::finishConversion() level->addEntity(villager); villager->addEffect(new MobEffectInstance(MobEffect::confusion->id, SharedConstants::TICKS_PER_SECOND * 10, 0)); - level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_CONVERTED, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_CONVERTED, static_cast(x), static_cast(y), static_cast(z), 0); } int Zombie::getConversionProgress() @@ -466,11 +466,11 @@ int Zombie::getConversionProgress() { int specialBlocksCount = 0; - for (int xx = (int) x - SPECIAL_BLOCK_RADIUS; xx < (int) x + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; xx++) + for (int xx = static_cast(x) - SPECIAL_BLOCK_RADIUS; xx < static_cast(x) + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; xx++) { - for (int yy = (int) y - SPECIAL_BLOCK_RADIUS; yy < (int) y + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; yy++) + for (int yy = static_cast(y) - SPECIAL_BLOCK_RADIUS; yy < static_cast(y) + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; yy++) { - for (int zz = (int) z - SPECIAL_BLOCK_RADIUS; zz < (int) z + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; zz++) + for (int zz = static_cast(z) - SPECIAL_BLOCK_RADIUS; zz < static_cast(z) + SPECIAL_BLOCK_RADIUS && specialBlocksCount < MAX_SPECIAL_BLOCKS_COUNT; zz++) { int tile = level->getTile(xx, yy, zz); diff --git a/Minecraft.World/ZoneIo.cpp b/Minecraft.World/ZoneIo.cpp index f1838c869..5860b10c9 100644 --- a/Minecraft.World/ZoneIo.cpp +++ b/Minecraft.World/ZoneIo.cpp @@ -22,7 +22,7 @@ void ZoneIo::write(byteArray bb, int size) void ZoneIo::write(ByteBuffer *bb, int size) { DWORD numberOfBytesWritten; - SetFilePointer(channel,(int)pos,NULL,NULL); + SetFilePointer(channel,static_cast(pos),NULL,NULL); WriteFile(channel,bb->getBuffer(), bb->getSize(),&numberOfBytesWritten,NULL); pos += size; } @@ -31,7 +31,7 @@ ByteBuffer *ZoneIo::read(int size) { DWORD numberOfBytesRead; byteArray bb = byteArray(size); - SetFilePointer(channel,(int)pos,NULL,NULL); + SetFilePointer(channel,static_cast(pos),NULL,NULL); ByteBuffer *buff = ByteBuffer::wrap(bb); // 4J - to investigate - why is this buffer flipped before anything goes in it? buff->order(ZonedChunkStorage::BYTEORDER); diff --git a/Minecraft.World/compression.cpp b/Minecraft.World/compression.cpp index 99c5228ab..6a43e112c 100644 --- a/Minecraft.World/compression.cpp +++ b/Minecraft.World/compression.cpp @@ -42,7 +42,7 @@ void Compression::UseDefaultThreadStorage() void Compression::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); if( tls == tlsDefault ) return; delete tls; @@ -50,7 +50,7 @@ void Compression::ReleaseThreadStorage() Compression *Compression::getCompression() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); return tls->compression; } @@ -59,7 +59,7 @@ HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize, EnterCriticalSection(&rleCompressLock); //static unsigned char rleBuf[1024*100]; - unsigned char *pucIn = (unsigned char *)pSource; + unsigned char *pucIn = static_cast(pSource); unsigned char *pucEnd = pucIn + SrcSize; unsigned char *pucOut = (unsigned char *)rleCompressBuf; @@ -101,7 +101,7 @@ HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize, *pucOut++ = thisOne; } } while (pucIn != pucEnd); - unsigned int rleSize = (unsigned int)(pucOut - rleCompressBuf); + unsigned int rleSize = static_cast(pucOut - rleCompressBuf); PIXEndNamedEvent(); PIXBeginNamedEvent(0,"Secondary compression"); @@ -118,7 +118,7 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo EnterCriticalSection(&rleCompressLock); //static unsigned char rleBuf[1024*100]; - unsigned char *pucIn = (unsigned char *)pSource; + unsigned char *pucIn = static_cast(pSource); unsigned char *pucEnd = pucIn + SrcSize; unsigned char *pucOut = (unsigned char *)rleCompressBuf; @@ -160,7 +160,7 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo *pucOut++ = thisOne; } } while (pucIn != pucEnd); - unsigned int rleSize = (unsigned int)(pucOut - rleCompressBuf); + unsigned int rleSize = static_cast(pucOut - rleCompressBuf); PIXEndNamedEvent(); LeaveCriticalSection(&rleCompressLock); @@ -206,12 +206,12 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz else { Decompress(rleDecompressBuf, &rleSize, pSource, SrcSize); - pucIn = (unsigned char *)rleDecompressBuf; + pucIn = static_cast(rleDecompressBuf); } //unsigned char *pucIn = (unsigned char *)rleDecompressBuf; unsigned char *pucEnd = pucIn + rleSize; - unsigned char *pucOut = (unsigned char *)pDestination; + unsigned char *pucOut = static_cast(pDestination); while( pucIn != pucEnd ) { @@ -242,7 +242,7 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz *pucOut++ = thisOne; } } - *pDestSize = (unsigned int)(pucOut - (unsigned char *)pDestination); + *pDestSize = static_cast(pucOut - (unsigned char *)pDestination); // printf("Decompressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize); @@ -257,9 +257,9 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize, EnterCriticalSection(&rleDecompressLock); //unsigned char *pucIn = (unsigned char *)rleDecompressBuf; - unsigned char *pucIn = (unsigned char *)pSource; + unsigned char *pucIn = static_cast(pSource); unsigned char *pucEnd = pucIn + SrcSize; - unsigned char *pucOut = (unsigned char *)pDestination; + unsigned char *pucOut = static_cast(pDestination); while( pucIn != pucEnd ) { @@ -290,7 +290,7 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize, *pucOut++ = thisOne; } } - *pDestSize = (unsigned int)(pucOut - (unsigned char *)pDestination); + *pDestSize = static_cast(pucOut - (unsigned char *)pDestination); LeaveCriticalSection(&rleDecompressLock); return S_OK; @@ -302,8 +302,8 @@ HRESULT Compression::Compress(void *pDestination, unsigned int *pDestSize, void // Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this #if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ SIZE_T destSize = (SIZE_T)(*pDestSize); - int res = ::compress((Bytef *)pDestination, (uLongf *)&destSize, (Bytef *)pSource, SrcSize); - *pDestSize = (unsigned int)destSize; + int res = ::compress(static_cast(pDestination), (uLongf *)&destSize, static_cast(pSource), SrcSize); + *pDestSize = static_cast(destSize); return ( ( res == Z_OK ) ? S_OK : -1 ); #elif defined __PS3__ uint32_t destSize = (uint32_t)(*pDestSize); @@ -330,8 +330,8 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi // Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this #if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ SIZE_T destSize = (SIZE_T)(*pDestSize); - int res = ::uncompress((Bytef *)pDestination, (uLongf *)&destSize, (Bytef *)pSource, SrcSize); - *pDestSize = (unsigned int)destSize; + int res = ::uncompress(static_cast(pDestination), (uLongf *)&destSize, static_cast(pSource), SrcSize); + *pDestSize = static_cast(destSize); return ( ( res == Z_OK ) ? S_OK : -1 ); #elif defined __PS3__ uint32_t destSize = (uint32_t)(*pDestSize); @@ -350,11 +350,11 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi #ifndef _XBOX VOID Compression::VitaVirtualDecompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) // (LPVOID buf, SIZE_T dwSize, LPVOID dst) { - uint8_t *pSrc = (uint8_t *)pSource; + uint8_t *pSrc = static_cast(pSource); int Offset = 0; int Page = 0; int Index = 0; - uint8_t* Data = (uint8_t*)pDestination; + uint8_t* Data = static_cast(pDestination); while( Index != SrcSize ) { // is this a normal value @@ -397,7 +397,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS #if (defined _XBOX || defined _DURANGO || defined _WIN64) SIZE_T destSize = (SIZE_T)(*pDestSize); HRESULT res = XMemDecompress(decompressionContext, pDestination, (SIZE_T *)&destSize, pSource, SrcSize); - *pDestSize = (unsigned int)destSize; + *pDestSize = static_cast(destSize); return res; #else assert(0); @@ -407,7 +407,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS case eCompressionType_ZLIBRLE: #if (defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64) if (pDestination != NULL) - return ::uncompress((PBYTE)pDestination, (unsigned long *) pDestSize, (PBYTE) pSource, SrcSize); // Decompress + return ::uncompress(static_cast(pDestination), (unsigned long *) pDestSize, static_cast(pSource), SrcSize); // Decompress else break; // Cannot decompress when destination is NULL #else assert(0); @@ -421,7 +421,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS { // Read big-endian srcize from array PBYTE pbDestSize = (PBYTE) pDestSize; - PBYTE pbSource = (PBYTE) pSource; + PBYTE pbSource = static_cast(pSource); for (int i = 3; i >= 0; i--) { pbDestSize[3-i] = pbSource[i]; } @@ -436,7 +436,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS strm.next_out = uncompr.data; strm.avail_out = uncompr.length; // Skip those first 4 bytes - strm.next_in = (PBYTE) pSource + 4; + strm.next_in = static_cast(pSource) + 4; strm.avail_in = SrcSize - 4; int hr = inflateInit2(&strm, -15); diff --git a/Minecraft.World/system.cpp b/Minecraft.World/system.cpp index b6dd56d96..7db2e0b88 100644 --- a/Minecraft.World/system.cpp +++ b/Minecraft.World/system.cpp @@ -64,7 +64,7 @@ __int64 System::nanoTime() // Using double to avoid 64-bit overflow during multiplication for long uptime // Precision is sufficient for ~100 days of uptime. - return (__int64)((double)counter.QuadPart * 1000000000.0 / (double)s_frequency.QuadPart); + return static_cast<__int64>((double)counter.QuadPart * 1000000000.0 / (double)s_frequency.QuadPart); #else return GetTickCount() * 1000000LL; #endif From d965a71464407f163596a4ae5c41f5159cfd3302 Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Thu, 5 Mar 2026 17:43:29 -0500 Subject: [PATCH 3/9] Replaced every C-style cast with C++ ones --- Minecraft.World/Boat.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Minecraft.World/Boat.cpp b/Minecraft.World/Boat.cpp index e33875817..1783a8d90 100644 --- a/Minecraft.World/Boat.cpp +++ b/Minecraft.World/Boat.cpp @@ -224,8 +224,8 @@ void Boat::tick() double yrd = Mth::wrapDegrees(lyr - yRot); - yRot += (float) ( (yrd) / lSteps ); - xRot += (float) ( (lxr - xRot) / lSteps ); + yRot += static_cast((yrd) / lSteps); + xRot += static_cast((lxr - xRot) / lSteps); lSteps--; setPos(xt, yt, zt); @@ -342,7 +342,7 @@ void Boat::tick() double zDiff = zo - z; if (xDiff * xDiff + zDiff * zDiff > 0.001) { - yRotT = (float) (atan2(zDiff, xDiff) * 180 / PI); + yRotT = static_cast(atan2(zDiff, xDiff) * 180 / PI); } double rotDiff = Mth::wrapDegrees(yRotT - yRot); @@ -350,7 +350,7 @@ void Boat::tick() if (rotDiff > 20) rotDiff = 20; if (rotDiff < -20) rotDiff = -20; - yRot += (float) rotDiff; + yRot += static_cast(rotDiff); setRot(yRot, xRot); // Server only code below From 31c2699a323904459817d12e64d0480474da0973 Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Thu, 5 Mar 2026 16:25:52 -0500 Subject: [PATCH 4/9] Fixed boats falling and a TP glitch #266 --- Minecraft.World/Boat.cpp | 107 ++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 42 deletions(-) diff --git a/Minecraft.World/Boat.cpp b/Minecraft.World/Boat.cpp index 1783a8d90..1811c2094 100644 --- a/Minecraft.World/Boat.cpp +++ b/Minecraft.World/Boat.cpp @@ -74,7 +74,7 @@ bool Boat::isPushable() Boat::Boat(Level *level, double x, double y, double z) : Entity( level ) { _init(); - setPos(x, y + heightOffset + 0.1, z); + setPos(x, y + heightOffset, z); xd = 0; yd = 0; @@ -209,9 +209,30 @@ void Boat::tick() } double lastSpeed = sqrt(xd * xd + zd * zd); - if (lastSpeed > MAX_COLLISION_SPEED && waterPercentage > 1) + if (lastSpeed > MAX_COLLISION_SPEED) { - createSplash(lastSpeed); + double xa = cos(yRot * PI / 180); + double za = sin(yRot * PI / 180); + + for (int i = 0; i < 1 + lastSpeed * 60; i++) + { + + double side = (random->nextFloat() * 2 - 1); + + double side2 = (random->nextInt(2) * 2 - 1) * 0.7; + if (random->nextBoolean()) + { + double xx = x - xa * side * 0.8 + za * side2; + double zz = z - za * side * 0.8 - xa * side2; + level->addParticle(eParticleType_splash, xx, y - 2 / 16.0f, zz, +xd, yd, +zd); + } + else + { + double xx = x + xa + za * side * 0.7; + double zz = z + za - xa * side * 0.7; + level->addParticle(eParticleType_splash, xx, y - 2 / 16.0f, zz, +xd, yd, +zd); + } + } } if (level->isClientSide && doLerp) @@ -224,8 +245,8 @@ void Boat::tick() double yrd = Mth::wrapDegrees(lyr - yRot); - yRot += static_cast((yrd) / lSteps); - xRot += static_cast((lxr - xRot) / lSteps); + yRot += (float) ( (yrd) / lSteps ); + xRot += (float) ( (lxr - xRot) / lSteps ); lSteps--; setPos(xt, yt, zt); @@ -233,6 +254,7 @@ void Boat::tick() } else { +#if 1 // Original //double xt = x + xd; //double yt = y + yd; @@ -251,23 +273,51 @@ void Boat::tick() xd *= 0.99f; yd *= 0.95f; zd *= 0.99f; +#else + // 4J Stu - Fix for #8280 - Gameplay : Boats behave erratically when exited next to land. + // The client shouldn't change the position of the boat + double xt = x;// + xd; + double yt = y + yd; + double zt = z;// + zd; + this->setPos(xt, yt, zt); + + // 4J Stu - Fix for #9579 - GAMEPLAY: Boats with a player in them slowly sink under the water over time, and with no player in them they float into the sky. + // Just make the boats bob up and down rather than any other client-side movement when not receiving packets from server + if (waterPercentage > 0) + { + double bob = waterPercentage * 2 - 1; + yd += 0.04f * bob; + } + else + { + if (yd < 0) yd /= 2; + yd += 0.007f; + } + //if (onGround) + //{ + xd *= 0.5f; + yd *= 0.5f; + zd *= 0.5f; + //} + //xd *= 0.99f; + //yd *= 0.95f; + //zd *= 0.99f; +#endif } return; } - // Bob on water if (waterPercentage > 0) { double bob = waterPercentage * 2 - 1; yd += 0.04f * bob; } - - // Reimplement "gravity" - if (level->getTile(x, Mth::floor(y - 0.15), z) == 0 && !onGround) { - yd += 0.04f * -1.0; // -1.0 is what bob should return in this situation, just hardcoded. + else + { + yd = 0; } - // Rider Controls + if ( rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY) ) { shared_ptr livingRider = dynamic_pointer_cast(rider.lock()); @@ -284,7 +334,6 @@ void Boat::tick() double curSpeed = sqrt(xd * xd + zd * zd); - // Speed Clamp if (curSpeed > MAX_SPEED) { double ratio = MAX_SPEED / curSpeed; @@ -305,15 +354,14 @@ void Boat::tick() if (acceleration < MIN_ACCELERATION) acceleration = MIN_ACCELERATION; } - // Slow speed on ground if (onGround) { xd *= 0.5f; + yd *= 0.5f; zd *= 0.5f; } move(xd, yd, zd); - // Break boat if ((horizontalCollision && lastSpeed > 0.20)) { if (!level->isClientSide && !removed) @@ -342,7 +390,7 @@ void Boat::tick() double zDiff = zo - z; if (xDiff * xDiff + zDiff * zDiff > 0.001) { - yRotT = static_cast(atan2(zDiff, xDiff) * 180 / PI); + yRotT = (float) (atan2(zDiff, xDiff) * 180 / PI); } double rotDiff = Mth::wrapDegrees(yRotT - yRot); @@ -350,10 +398,9 @@ void Boat::tick() if (rotDiff > 20) rotDiff = 20; if (rotDiff < -20) rotDiff = -20; - yRot += static_cast(rotDiff); + yRot += (float) rotDiff; setRot(yRot, xRot); - // Server only code below if(level->isClientSide) return; vector > *entities = level->getEntities(shared_from_this(), bb->grow(0.2f, 0, 0.2f)); @@ -397,37 +444,13 @@ void Boat::tick() } } -void Boat::createSplash(double particleStrengh) { - double xa = cos(yRot * PI / 180); - double za = sin(yRot * PI / 180); - - for (int i = 0; i < 1 + particleStrengh * 60; i++) - { - double side = (random->nextFloat() * 2 - 1); - - double side2 = (random->nextInt(2) * 2 - 1) * 0.7; - if (random->nextBoolean()) - { - double xx = x - xa * side * 0.8 + za * side2; - double zz = z - za * side * 0.8 - xa * side2; - level->addParticle(eParticleType_splash, xx, y - 2 / 16.0f, zz, +xd, yd, +zd); - } - else - { - double xx = x + xa + za * side * 0.7; - double zz = z + za - xa * side * 0.7; - level->addParticle(eParticleType_splash, xx, y - 2 / 16.0f, zz, +xd, yd, +zd); - } - } -} - void Boat::positionRider() { if (rider.lock() == NULL) return; double xa = cos(yRot * PI / 180) * 0.4; double za = sin(yRot * PI / 180) * 0.4; - rider.lock()->setPos(x + xa, y + getRideHeight() + rider.lock()->getRidingHeight()-0.5, z + za); + rider.lock()->setPos(x + xa, y + getRideHeight() + rider.lock()->getRidingHeight(), z + za); } From 6d1d3b59cb9774d1d599cae3fb365a6d1f5190f7 Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Fri, 6 Mar 2026 13:59:42 -0500 Subject: [PATCH 5/9] Updated NULL to nullptr and fixing some type issues --- Minecraft.Client/AbstractContainerScreen.cpp | 14 +- Minecraft.Client/AbstractTexturePack.cpp | 48 +- Minecraft.Client/AbstractTexturePack.h | 2 +- Minecraft.Client/AchievementPopup.cpp | 4 +- Minecraft.Client/AchievementScreen.cpp | 8 +- Minecraft.Client/ArchiveFile.cpp | 20 +- Minecraft.Client/BreakingItemParticle.cpp | 2 +- Minecraft.Client/BufferedImage.cpp | 16 +- Minecraft.Client/BufferedImage.h | 2 +- Minecraft.Client/ChatScreen.cpp | 6 +- Minecraft.Client/ChestRenderer.cpp | 14 +- Minecraft.Client/Chunk.cpp | 6 +- Minecraft.Client/ClientConnection.cpp | 236 +- Minecraft.Client/ClockTexture.cpp | 12 +- Minecraft.Client/Common/Audio/SoundEngine.cpp | 32 +- Minecraft.Client/Common/Audio/miniaudio.h | 7378 ++++++++--------- Minecraft.Client/Common/Audio/stb_vorbis.h | 148 +- Minecraft.Client/Common/Consoles_App.cpp | 238 +- Minecraft.Client/Common/Consoles_App.h | 8 +- Minecraft.Client/Common/DLC/DLCAudioFile.cpp | 4 +- .../Common/DLC/DLCColourTableFile.cpp | 4 +- Minecraft.Client/Common/DLC/DLCFile.h | 2 +- .../Common/DLC/DLCGameRulesFile.cpp | 2 +- .../Common/DLC/DLCGameRulesHeader.cpp | 4 +- .../Common/DLC/DLCLocalisationFile.cpp | 2 +- Minecraft.Client/Common/DLC/DLCManager.cpp | 64 +- Minecraft.Client/Common/DLC/DLCPack.cpp | 32 +- .../Common/DLC/DLCTextureFile.cpp | 2 +- Minecraft.Client/Common/DLC/DLCUIDataFile.cpp | 4 +- .../AddEnchantmentRuleDefinition.cpp | 4 +- .../GameRules/AddItemRuleDefinition.cpp | 6 +- .../ApplySchematicRuleDefinition.cpp | 24 +- .../GameRules/CollectItemRuleDefinition.cpp | 8 +- .../GameRules/CompleteAllRuleDefinition.cpp | 6 +- .../GameRules/CompoundGameRuleDefinition.cpp | 8 +- .../GameRules/ConsoleGenerateStructure.cpp | 6 +- .../Common/GameRules/ConsoleSchematicFile.cpp | 40 +- Minecraft.Client/Common/GameRules/GameRule.h | 2 +- .../Common/GameRules/GameRuleDefinition.cpp | 2 +- .../Common/GameRules/GameRuleDefinition.h | 2 +- .../Common/GameRules/GameRuleManager.cpp | 56 +- .../GameRules/LevelGenerationOptions.cpp | 56 +- .../Common/GameRules/LevelGenerationOptions.h | 4 +- .../Common/GameRules/LevelRuleset.cpp | 6 +- .../Common/GameRules/StartFeature.cpp | 2 +- .../GameRules/UpdatePlayerRuleDefinition.cpp | 14 +- .../XboxStructureActionPlaceContainer.cpp | 6 +- .../XboxStructureActionPlaceSpawner.cpp | 4 +- .../Leaderboards/LeaderboardInterface.cpp | 2 +- .../Leaderboards/LeaderboardManager.cpp | 4 +- .../Leaderboards/SonyLeaderboardManager.cpp | 60 +- .../Common/Network/GameNetworkManager.cpp | 122 +- .../Common/Network/GameNetworkManager.h | 8 +- .../Network/PlatformNetworkManagerInterface.h | 2 +- .../Network/PlatformNetworkManagerStub.cpp | 60 +- .../Network/PlatformNetworkManagerStub.h | 2 +- Minecraft.Client/Common/Network/SessionInfo.h | 4 +- .../Common/Network/Sony/NetworkPlayerSony.cpp | 2 +- .../Sony/PlatformNetworkManagerSony.cpp | 76 +- .../Network/Sony/PlatformNetworkManagerSony.h | 2 +- .../Common/Network/Sony/SQRNetworkManager.cpp | 4 +- .../Common/Network/Sony/SQRNetworkPlayer.cpp | 18 +- .../Common/Network/Sony/SonyRemoteStorage.cpp | 16 +- .../Common/Network/Sony/SonyRemoteStorage.h | 2 +- .../Common/Telemetry/TelemetryManager.cpp | 4 +- .../Common/Tutorial/ChangeStateConstraint.cpp | 8 +- .../Common/Tutorial/ChangeStateConstraint.h | 2 +- .../Common/Tutorial/ChoiceTask.cpp | 2 +- .../Common/Tutorial/CompleteUsingItemTask.cpp | 2 +- .../Common/Tutorial/ControllerTask.cpp | 2 +- .../Common/Tutorial/ControllerTask.h | 2 +- .../Common/Tutorial/CraftTask.cpp | 4 +- Minecraft.Client/Common/Tutorial/CraftTask.h | 4 +- .../Common/Tutorial/DiggerItemHint.cpp | 4 +- .../Common/Tutorial/EffectChangedTask.cpp | 2 +- .../Common/Tutorial/FullTutorial.cpp | 78 +- .../Tutorial/FullTutorialActiveTask.cpp | 2 +- Minecraft.Client/Common/Tutorial/InfoTask.cpp | 2 +- Minecraft.Client/Common/Tutorial/PickupTask.h | 2 +- .../Common/Tutorial/ProcedureCompoundTask.cpp | 2 +- .../Common/Tutorial/ProcedureCompoundTask.h | 2 +- .../Common/Tutorial/ProgressFlagTask.h | 2 +- .../Common/Tutorial/RideEntityTask.h | 2 +- Minecraft.Client/Common/Tutorial/StatTask.cpp | 2 +- .../Common/Tutorial/StateChangeTask.h | 2 +- .../Common/Tutorial/TakeItemHint.cpp | 2 +- Minecraft.Client/Common/Tutorial/Tutorial.cpp | 90 +- Minecraft.Client/Common/Tutorial/Tutorial.h | 4 +- .../Common/Tutorial/TutorialHint.cpp | 2 +- .../Common/Tutorial/TutorialMode.cpp | 8 +- .../Common/Tutorial/TutorialMode.h | 2 +- .../Common/Tutorial/TutorialTask.cpp | 2 +- .../Common/Tutorial/UseItemTask.h | 2 +- .../Common/Tutorial/UseTileTask.h | 4 +- .../Common/Tutorial/XuiCraftingTask.cpp | 4 +- .../Common/Tutorial/XuiCraftingTask.h | 4 +- Minecraft.Client/Common/UI/IUIController.h | 2 +- .../UI/IUIScene_AbstractContainerMenu.cpp | 50 +- .../Common/UI/IUIScene_AnvilMenu.cpp | 10 +- .../Common/UI/IUIScene_BeaconMenu.cpp | 10 +- .../Common/UI/IUIScene_CraftingMenu.cpp | 24 +- .../Common/UI/IUIScene_CreativeMenu.cpp | 42 +- .../Common/UI/IUIScene_CreativeMenu.h | 2 +- Minecraft.Client/Common/UI/IUIScene_HUD.cpp | 6 +- .../Common/UI/IUIScene_PauseMenu.cpp | 26 +- .../Common/UI/IUIScene_StartGame.cpp | 24 +- .../Common/UI/IUIScene_TradingMenu.cpp | 28 +- Minecraft.Client/Common/UI/UIBitmapFont.cpp | 2 +- .../Common/UI/UIComponent_Chat.cpp | 2 +- .../Common/UI/UIComponent_Panorama.cpp | 2 +- .../Common/UI/UIComponent_Tooltips.cpp | 2 +- .../Common/UI/UIComponent_TutorialPopup.cpp | 16 +- Minecraft.Client/Common/UI/UIControl.cpp | 24 +- Minecraft.Client/Common/UI/UIControl_Base.cpp | 2 +- .../Common/UI/UIControl_ButtonList.cpp | 2 +- .../Common/UI/UIControl_CheckBox.cpp | 2 +- .../Common/UI/UIControl_DynamicLabel.cpp | 4 +- .../Common/UI/UIControl_EnchantmentBook.cpp | 6 +- .../Common/UI/UIControl_HTMLLabel.cpp | 6 +- .../Common/UI/UIControl_LeaderboardList.cpp | 2 +- .../Common/UI/UIControl_PlayerSkinPreview.cpp | 8 +- .../Common/UI/UIControl_Slider.cpp | 2 +- .../Common/UI/UIControl_TexturePackList.cpp | 4 +- Minecraft.Client/Common/UI/UIController.cpp | 94 +- Minecraft.Client/Common/UI/UIController.h | 12 +- Minecraft.Client/Common/UI/UIFontData.cpp | 6 +- Minecraft.Client/Common/UI/UIGroup.cpp | 18 +- Minecraft.Client/Common/UI/UILayer.cpp | 22 +- Minecraft.Client/Common/UI/UILayer.h | 2 +- Minecraft.Client/Common/UI/UIScene.cpp | 40 +- Minecraft.Client/Common/UI/UIScene.h | 2 +- .../UI/UIScene_AbstractContainerMenu.cpp | 16 +- .../Common/UI/UIScene_AbstractContainerMenu.h | 2 +- .../Common/UI/UIScene_AnvilMenu.cpp | 6 +- .../Common/UI/UIScene_BeaconMenu.cpp | 10 +- .../Common/UI/UIScene_BrewingStandMenu.cpp | 6 +- .../Common/UI/UIScene_ConnectingProgress.cpp | 2 +- .../Common/UI/UIScene_ContainerMenu.cpp | 6 +- .../Common/UI/UIScene_ControlsMenu.cpp | 2 +- .../Common/UI/UIScene_CraftingMenu.cpp | 18 +- .../Common/UI/UIScene_CreateWorldMenu.cpp | 34 +- .../Common/UI/UIScene_CreativeMenu.cpp | 6 +- .../Common/UI/UIScene_Credits.cpp | 2 +- .../Common/UI/UIScene_DLCOffersMenu.cpp | 22 +- .../Common/UI/UIScene_DeathMenu.cpp | 6 +- .../Common/UI/UIScene_DebugOverlay.cpp | 12 +- .../Common/UI/UIScene_DebugSetCamera.cpp | 2 +- .../Common/UI/UIScene_DispenserMenu.cpp | 6 +- .../Common/UI/UIScene_EnchantingMenu.cpp | 8 +- .../Common/UI/UIScene_EndPoem.cpp | 6 +- .../Common/UI/UIScene_FireworksMenu.cpp | 6 +- .../Common/UI/UIScene_FullscreenProgress.cpp | 6 +- .../Common/UI/UIScene_FurnaceMenu.cpp | 6 +- Minecraft.Client/Common/UI/UIScene_HUD.cpp | 14 +- .../Common/UI/UIScene_HelpAndOptionsMenu.cpp | 8 +- .../Common/UI/UIScene_HopperMenu.cpp | 6 +- .../Common/UI/UIScene_HorseInventoryMenu.cpp | 8 +- .../Common/UI/UIScene_HowToPlayMenu.cpp | 2 +- .../Common/UI/UIScene_InGameInfoMenu.cpp | 20 +- .../UI/UIScene_InGamePlayerOptionsMenu.cpp | 12 +- .../UI/UIScene_InGameSaveManagementMenu.cpp | 18 +- .../Common/UI/UIScene_InventoryMenu.cpp | 10 +- .../Common/UI/UIScene_JoinMenu.cpp | 14 +- .../Common/UI/UIScene_Keyboard.cpp | 20 +- .../Common/UI/UIScene_LanguageSelector.cpp | 2 +- .../UI/UIScene_LaunchMoreOptionsMenu.cpp | 4 +- .../Common/UI/UIScene_LeaderboardsMenu.cpp | 6 +- .../Common/UI/UIScene_LoadMenu.cpp | 40 +- .../Common/UI/UIScene_LoadOrJoinMenu.cpp | 114 +- .../Common/UI/UIScene_MainMenu.cpp | 36 +- .../Common/UI/UIScene_MessageBox.cpp | 4 +- .../Common/UI/UIScene_PauseMenu.cpp | 30 +- .../Common/UI/UIScene_QuadrantSignin.cpp | 2 +- .../Common/UI/UIScene_ReinstallMenu.cpp | 2 +- .../Common/UI/UIScene_SaveMessage.cpp | 2 +- .../Common/UI/UIScene_SettingsAudioMenu.cpp | 2 +- .../Common/UI/UIScene_SettingsControlMenu.cpp | 2 +- .../UI/UIScene_SettingsGraphicsMenu.cpp | 6 +- .../Common/UI/UIScene_SettingsMenu.cpp | 6 +- .../Common/UI/UIScene_SettingsOptionsMenu.cpp | 8 +- .../Common/UI/UIScene_SettingsUIMenu.cpp | 6 +- .../Common/UI/UIScene_SignEntryMenu.cpp | 2 +- .../Common/UI/UIScene_SkinSelectMenu.cpp | 72 +- .../Common/UI/UIScene_TeleportMenu.cpp | 12 +- .../Common/UI/UIScene_TradingMenu.cpp | 12 +- .../Common/UI/UIScene_TrialExitUpsell.cpp | 2 +- Minecraft.Client/Common/UI/UIString.cpp | 8 +- Minecraft.Client/Common/UI/UIStructs.h | 24 +- Minecraft.Client/Common/UI/UITTFFont.cpp | 6 +- Minecraft.Client/Common/XUI/XUI_Chat.cpp | 2 +- .../Common/XUI/XUI_ConnectingProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_4JEdit.cpp | 4 +- .../Common/XUI/XUI_Ctrl_4JIcon.cpp | 2 +- .../Common/XUI/XUI_Ctrl_4JList.cpp | 4 +- .../Common/XUI/XUI_Ctrl_BrewProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_BubblesProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_BurnProgress.cpp | 2 +- .../XUI/XUI_Ctrl_CraftIngredientSlot.cpp | 8 +- .../Common/XUI/XUI_Ctrl_EnchantButton.cpp | 4 +- .../Common/XUI/XUI_Ctrl_EnchantmentBook.cpp | 16 +- .../XUI/XUI_Ctrl_EnchantmentButtonText.cpp | 4 +- .../Common/XUI/XUI_Ctrl_FireProgress.cpp | 2 +- .../Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp | 6 +- .../XUI/XUI_Ctrl_MinecraftSkinPreview.cpp | 8 +- .../Common/XUI/XUI_Ctrl_MinecraftSlot.cpp | 14 +- .../Common/XUI/XUI_Ctrl_MobEffect.cpp | 4 +- .../Common/XUI/XUI_Ctrl_SliderWrapper.cpp | 6 +- .../Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp | 36 +- .../Common/XUI/XUI_Ctrl_SlotItemCtrlBase.h | 2 +- .../Common/XUI/XUI_Ctrl_SlotList.cpp | 2 +- .../Common/XUI/XUI_CustomMessages.h | 2 +- Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp | 56 +- Minecraft.Client/Common/XUI/XUI_Death.cpp | 4 +- .../Common/XUI/XUI_DebugItemEditor.cpp | 12 +- .../Common/XUI/XUI_DebugOverlay.cpp | 30 +- .../Common/XUI/XUI_DebugSetCamera.cpp | 4 +- .../Common/XUI/XUI_FullscreenProgress.cpp | 10 +- Minecraft.Client/Common/XUI/XUI_HUD.cpp | 56 +- .../Common/XUI/XUI_HelpAndOptions.cpp | 10 +- .../Common/XUI/XUI_HelpControls.cpp | 14 +- .../Common/XUI/XUI_HelpCredits.cpp | 2 +- .../Common/XUI/XUI_HelpHowToPlay.cpp | 2 +- .../Common/XUI/XUI_HowToPlayMenu.cpp | 4 +- .../Common/XUI/XUI_InGameHostOptions.cpp | 2 +- .../Common/XUI/XUI_InGameInfo.cpp | 18 +- .../Common/XUI/XUI_InGamePlayerOptions.cpp | 50 +- .../Common/XUI/XUI_Leaderboards.cpp | 70 +- .../Common/XUI/XUI_LoadSettings.cpp | 76 +- Minecraft.Client/Common/XUI/XUI_MainMenu.cpp | 10 +- .../Common/XUI/XUI_MultiGameCreate.cpp | 56 +- .../Common/XUI/XUI_MultiGameInfo.cpp | 16 +- .../Common/XUI/XUI_MultiGameJoinLoad.cpp | 78 +- .../XUI/XUI_MultiGameLaunchMoreOptions.cpp | 2 +- Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp | 34 +- Minecraft.Client/Common/XUI/XUI_Reinstall.cpp | 4 +- .../XUI/XUI_Scene_AbstractContainer.cpp | 6 +- .../Common/XUI/XUI_Scene_Anvil.cpp | 12 +- .../Common/XUI/XUI_Scene_Base.cpp | 86 +- .../Common/XUI/XUI_Scene_BrewingStand.cpp | 12 +- .../Common/XUI/XUI_Scene_Container.cpp | 12 +- .../Common/XUI/XUI_Scene_CraftingPanel.cpp | 18 +- .../Common/XUI/XUI_Scene_Enchant.cpp | 12 +- .../Common/XUI/XUI_Scene_Furnace.cpp | 12 +- .../Common/XUI/XUI_Scene_Inventory.cpp | 14 +- .../XUI/XUI_Scene_Inventory_Creative.cpp | 14 +- .../Common/XUI/XUI_Scene_Trading.cpp | 10 +- .../Common/XUI/XUI_Scene_Trap.cpp | 12 +- Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp | 8 +- .../Common/XUI/XUI_SettingsAll.cpp | 6 +- .../Common/XUI/XUI_SettingsAudio.cpp | 6 +- .../Common/XUI/XUI_SettingsControl.cpp | 6 +- .../Common/XUI/XUI_SettingsGraphics.cpp | 6 +- .../Common/XUI/XUI_SettingsOptions.cpp | 6 +- .../Common/XUI/XUI_SettingsUI.cpp | 6 +- Minecraft.Client/Common/XUI/XUI_SignEntry.cpp | 2 +- .../Common/XUI/XUI_SkinSelect.cpp | 62 +- .../Common/XUI/XUI_SocialPost.cpp | 2 +- Minecraft.Client/Common/XUI/XUI_Teleport.cpp | 6 +- .../Common/XUI/XUI_TransferToXboxOne.cpp | 20 +- .../Common/XUI/XUI_TutorialPopup.cpp | 12 +- Minecraft.Client/Common/zlib/crc32.c | 2 +- Minecraft.Client/Common/zlib/trees.c | 10 +- Minecraft.Client/Common/zlib/zlib.h | 10 +- Minecraft.Client/Common/zlib/zutil.c | 2 +- Minecraft.Client/Common/zlib/zutil.h | 6 +- Minecraft.Client/CompassTexture.cpp | 18 +- Minecraft.Client/ConnectScreen.cpp | 8 +- Minecraft.Client/CreateWorldScreen.cpp | 6 +- Minecraft.Client/DLCTexturePack.cpp | 74 +- Minecraft.Client/DLCTexturePack.h | 2 +- Minecraft.Client/DeathScreen.cpp | 6 +- Minecraft.Client/DefaultRenderer.h | 2 +- Minecraft.Client/DefaultTexturePack.cpp | 6 +- Minecraft.Client/DefaultTexturePack.h | 2 +- Minecraft.Client/DerivedServerLevel.cpp | 4 +- Minecraft.Client/DisconnectedScreen.cpp | 2 +- .../Durango/4JLibs/inc/4J_Input.h | 8 +- .../Durango/4JLibs/inc/4J_Profile.h | 2 +- .../Durango/4JLibs/inc/4J_Render.h | 6 +- .../Durango/4JLibs/inc/4J_Storage.h | 10 +- Minecraft.Client/Durango/Durango_App.cpp | 32 +- Minecraft.Client/Durango/Durango_App.h | 2 +- .../Durango/Durango_Minecraft.cpp | 10 +- .../Durango/Durango_UIController.cpp | 4 +- .../Iggy/gdraw/gdraw_d3d10_shaders.inl | 22 +- .../Durango/Iggy/gdraw/gdraw_d3d11.cpp | 16 +- .../Durango/Iggy/gdraw/gdraw_d3d11.h | 4 +- .../Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl | 146 +- .../Durango/Iggy/gdraw/gdraw_shared.inl | 76 +- Minecraft.Client/Durango/Iggy/include/gdraw.h | 8 +- .../Durango/Iggy/include/iggyexpruntime.h | 4 +- .../DurangoLeaderboardManager.cpp | 16 +- .../Leaderboards/DurangoStatsDebugger.cpp | 4 +- .../Durango/Leaderboards/GameProgress.cpp | 6 +- Minecraft.Client/Durango/Miles/include/mss.h | 14 +- .../Durango/Network/DQRNetworkManager.cpp | 48 +- .../Durango/Network/DQRNetworkManager.h | 2 +- .../DQRNetworkManager_FriendSessions.cpp | 4 +- .../Network/DQRNetworkManager_SendReceive.cpp | 8 +- .../Network/DQRNetworkManager_XRNSEvent.cpp | 6 +- .../Durango/Network/NetworkPlayerDurango.cpp | 2 +- .../Durango/Network/PartyController.cpp | 8 +- .../Network/PlatformNetworkManagerDurango.cpp | 54 +- .../Network/PlatformNetworkManagerDurango.h | 2 +- .../Durango/Sentient/DurangoTelemetry.cpp | 4 +- .../Events-XBLA.8-149E11AEEvents.h | 96 +- Minecraft.Client/Durango/XML/ATGXmlParser.cpp | 22 +- Minecraft.Client/Durango/XML/ATGXmlParser.h | 2 +- .../Durango/XML/xmlFilesCallback.h | 8 +- Minecraft.Client/EnderDragonRenderer.cpp | 2 +- Minecraft.Client/EntityRenderDispatcher.cpp | 4 +- Minecraft.Client/EntityRenderer.cpp | 6 +- Minecraft.Client/EntityTracker.cpp | 12 +- Minecraft.Client/Extrax64Stubs.cpp | 30 +- Minecraft.Client/FallingTileRenderer.cpp | 2 +- Minecraft.Client/FileTexturePack.cpp | 2 +- Minecraft.Client/FireworksParticles.cpp | 16 +- Minecraft.Client/FishingHookRenderer.cpp | 2 +- Minecraft.Client/FolderTexturePack.cpp | 4 +- Minecraft.Client/FolderTexturePack.h | 2 +- Minecraft.Client/Font.cpp | 4 +- Minecraft.Client/Font.h | 2 +- Minecraft.Client/GameRenderer.cpp | 54 +- Minecraft.Client/Gui.cpp | 22 +- .../HugeExplosionSeedParticle.cpp | 2 +- Minecraft.Client/HumanoidMobRenderer.cpp | 22 +- Minecraft.Client/HumanoidModel.cpp | 8 +- Minecraft.Client/Input.cpp | 2 +- Minecraft.Client/ItemFrameRenderer.cpp | 4 +- Minecraft.Client/ItemInHandRenderer.cpp | 22 +- Minecraft.Client/ItemRenderer.cpp | 18 +- Minecraft.Client/ItemSpriteRenderer.cpp | 2 +- Minecraft.Client/JoinMultiplayerScreen.cpp | 2 +- Minecraft.Client/LevelRenderer.cpp | 98 +- Minecraft.Client/LivingEntityRenderer.cpp | 10 +- Minecraft.Client/LocalPlayer.cpp | 52 +- Minecraft.Client/MemTexture.cpp | 2 +- Minecraft.Client/MinecartRenderer.cpp | 8 +- Minecraft.Client/Minecraft.cpp | 446 +- Minecraft.Client/Minecraft.h | 2 +- Minecraft.Client/MinecraftServer.cpp | 140 +- Minecraft.Client/MinecraftServer.h | 6 +- Minecraft.Client/Minimap.cpp | 14 +- Minecraft.Client/MobRenderer.cpp | 2 +- .../MobSkinMemTextureProcessor.cpp | 4 +- Minecraft.Client/MobSkinTextureProcessor.cpp | 4 +- Minecraft.Client/MobSpawnerRenderer.cpp | 2 +- Minecraft.Client/Model.h | 2 +- Minecraft.Client/ModelHorse.cpp | 4 +- Minecraft.Client/ModelPart.cpp | 10 +- Minecraft.Client/MultiPlayerChunkCache.cpp | 14 +- Minecraft.Client/MultiPlayerGameMode.cpp | 24 +- Minecraft.Client/MultiPlayerGameMode.h | 4 +- Minecraft.Client/MultiPlayerLevel.cpp | 18 +- Minecraft.Client/MultiPlayerLocalPlayer.cpp | 22 +- Minecraft.Client/NameEntryScreen.cpp | 2 +- Minecraft.Client/Options.cpp | 6 +- Minecraft.Client/OptionsScreen.cpp | 2 +- .../Orbis/4JLibs/inc/4J_Profile.h | 2 +- Minecraft.Client/Orbis/4JLibs/inc/4J_Render.h | 6 +- .../Orbis/4JLibs/inc/4J_Storage.h | 8 +- .../Orbis/Iggy/gdraw/gdraw_orbis.cpp | 100 +- .../Orbis/Iggy/gdraw/gdraw_orbis.h | 6 +- .../Orbis/Iggy/gdraw/gdraw_orbis_shaders.inl | 160 +- .../Orbis/Iggy/gdraw/gdraw_shared.inl | 76 +- Minecraft.Client/Orbis/Iggy/include/gdraw.h | 8 +- .../Orbis/Iggy/include/iggyexpruntime.h | 4 +- .../Leaderboards/OrbisLeaderboardManager.cpp | 60 +- Minecraft.Client/Orbis/Miles/include/mss.h | 14 +- .../Orbis/Network/Orbis_NPToolkit.cpp | 4 +- .../Orbis/Network/SQRNetworkManager_Orbis.cpp | 128 +- .../Orbis/Network/SQRNetworkManager_Orbis.h | 2 +- .../Orbis/Network/SonyCommerce_Orbis.cpp | 56 +- .../Orbis/Network/SonyCommerce_Orbis.h | 4 +- .../Orbis/Network/SonyHttp_Orbis.cpp | 8 +- .../Orbis/Network/SonyRemoteStorage_Orbis.cpp | 4 +- .../Orbis/Network/SonyVoiceChat_Orbis.cpp | 14 +- .../Orbis/OrbisExtras/OrbisStubs.cpp | 40 +- .../Orbis/OrbisExtras/TLSStorage.cpp | 10 +- Minecraft.Client/Orbis/OrbisExtras/winerror.h | 2 +- Minecraft.Client/Orbis/Orbis_App.cpp | 66 +- Minecraft.Client/Orbis/Orbis_App.h | 2 +- Minecraft.Client/Orbis/Orbis_Minecraft.cpp | 44 +- Minecraft.Client/Orbis/Orbis_UIController.cpp | 4 +- Minecraft.Client/Orbis/XML/ATGXmlParser.h | 2 +- Minecraft.Client/Orbis/user_malloc.cpp | 6 +- .../Orbis/user_malloc_for_tls.cpp | 6 +- Minecraft.Client/Orbis/user_new.cpp | 28 +- .../PS3/4JLibs/STO_TitleSmallStorage.cpp | 16 +- Minecraft.Client/PS3/4JLibs/inc/4J_Input.h | 4 +- Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h | 2 +- Minecraft.Client/PS3/4JLibs/inc/4J_Render.h | 6 +- Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h | 10 +- .../PS3/Audio/PS3_SoundEngine.cpp | 8 +- .../PS3/Iggy/gdraw/gdraw_ps3gcm.cpp | 84 +- .../PS3/Iggy/gdraw/gdraw_ps3gcm.h | 2 +- .../PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl | 154 +- .../PS3/Iggy/gdraw/gdraw_shared.inl | 76 +- Minecraft.Client/PS3/Iggy/include/gdraw.h | 8 +- .../PS3/Iggy/include/iggyexpruntime.h | 4 +- .../Leaderboards/PS3LeaderboardManager.cpp | 52 +- Minecraft.Client/PS3/Miles/include/mss.h | 14 +- .../PS3/Network/SQRNetworkManager_PS3.cpp | 128 +- .../PS3/Network/SQRNetworkManager_PS3.h | 2 +- .../PS3/Network/SonyCommerce_PS3.cpp | 48 +- .../PS3/Network/SonyCommerce_PS3.h | 4 +- Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp | 48 +- .../PS3/Network/SonyRemoteStorage_PS3.cpp | 10 +- .../PS3/Network/SonyVoiceChat.cpp | 14 +- .../PS3/PS3Extras/C4JSpursJob.cpp | 14 +- Minecraft.Client/PS3/PS3Extras/C4JSpursJob.h | 4 +- .../PS3/PS3Extras/C4JThread_SPU.cpp | 2 +- Minecraft.Client/PS3/PS3Extras/EdgeZLib.cpp | 10 +- Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp | 6 +- Minecraft.Client/PS3/PS3Extras/Ps3Stubs.cpp | 18 +- .../PS3/PS3Extras/ShutdownManager.cpp | 4 +- Minecraft.Client/PS3/PS3Extras/TLSStorage.cpp | 10 +- Minecraft.Client/PS3/PS3Extras/winerror.h | 2 +- Minecraft.Client/PS3/PS3_App.cpp | 56 +- Minecraft.Client/PS3/PS3_App.h | 2 +- Minecraft.Client/PS3/PS3_Minecraft.cpp | 32 +- .../PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h | 4 +- .../SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h | 2 +- .../PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h | 2 +- .../SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h | 2 +- .../ChunkUpdate/ChunkRebuildData.cpp | 4 +- .../PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h | 2 +- .../SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h | 2 +- .../SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp | 2 +- .../PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h | 2 +- .../ChunkUpdate/HalfSlabTile_SPU.cpp | 2 +- .../SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h | 2 +- .../ChunkUpdate/PistonBaseTile_SPU.h | 2 +- .../ChunkUpdate/PistonExtensionTile_SPU.h | 2 +- .../ChunkUpdate/PistonMovingPiece_SPU.h | 2 +- .../SPU_Tasks/ChunkUpdate/PortalTile_SPU.h | 2 +- .../ChunkUpdate/PressurePlateTile_SPU.h | 2 +- .../PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h | 2 +- .../ChunkUpdate/RedStoneDustTile_SPU.h | 2 +- .../PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h | 2 +- .../PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h | 2 +- .../PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h | 2 +- .../SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp | 2 +- .../ChunkUpdate/TheEndPortalFrameTile_SPU.h | 2 +- .../ChunkUpdate/ThinFenceTile_SPU.cpp | 2 +- .../SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h | 2 +- .../ChunkUpdate/TileRenderer_SPU.cpp | 20 +- .../SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h | 4 +- .../PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp | 36 +- .../PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h | 4 +- .../SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h | 2 +- .../SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h | 2 +- .../PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h | 2 +- .../PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h | 6 +- .../CompressedTileStorage_SPU.cpp | 8 +- Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h | 4 +- .../PSVita/4JLibs/inc/4J_Profile.h | 2 +- .../PSVita/4JLibs/inc/4J_Render.h | 6 +- .../PSVita/4JLibs/inc/4J_Storage.h | 6 +- .../PSVita/Iggy/gdraw/gdraw_psp2.cpp | 108 +- .../PSVita/Iggy/gdraw/gdraw_psp2.h | 4 +- .../PSVita/Iggy/gdraw/gdraw_psp2_shaders.inl | 46 +- .../PSVita/Iggy/gdraw/gdraw_shared.inl | 76 +- Minecraft.Client/PSVita/Iggy/include/gdraw.h | 8 +- .../PSVita/Iggy/include/iggyexpruntime.h | 4 +- .../Leaderboards/PSVitaLeaderboardManager.cpp | 2 +- Minecraft.Client/PSVita/Miles/include/mss.h | 14 +- .../PSVita/Network/PSVita_NPToolkit.cpp | 6 +- .../Network/SQRNetworkManager_AdHoc_Vita.cpp | 102 +- .../Network/SQRNetworkManager_AdHoc_Vita.h | 2 +- .../PSVita/Network/SQRNetworkManager_Vita.cpp | 138 +- .../PSVita/Network/SQRNetworkManager_Vita.h | 2 +- .../PSVita/Network/SonyCommerce_Vita.cpp | 60 +- .../PSVita/Network/SonyCommerce_Vita.h | 4 +- .../PSVita/Network/SonyHttp_Vita.cpp | 2 +- .../PSVita/Network/SonyRemoteStorage_Vita.cpp | 4 +- .../PSVita/Network/SonyVoiceChat_Vita.cpp | 14 +- .../PSVita/PSVitaExtras/CustomMap.cpp | 4 +- .../PSVita/PSVitaExtras/CustomSet.cpp | 4 +- .../PSVita/PSVitaExtras/PSVitaStrings.cpp | 4 +- .../PSVita/PSVitaExtras/PSVitaTLSStorage.cpp | 14 +- .../PSVita/PSVitaExtras/PsVitaStubs.cpp | 36 +- .../PSVita/PSVitaExtras/ShutdownManager.cpp | 4 +- .../PSVita/PSVitaExtras/libdivide.h | 12 +- .../PSVita/PSVitaExtras/user_malloc.c | 26 +- .../PSVita/PSVitaExtras/user_malloc_for_tls.c | 6 +- .../PSVita/PSVitaExtras/user_new.cpp | 26 +- Minecraft.Client/PSVita/PSVitaExtras/zlib.h | 10 +- Minecraft.Client/PSVita/PSVita_App.cpp | 80 +- Minecraft.Client/PSVita/PSVita_App.h | 2 +- Minecraft.Client/PSVita/PSVita_Minecraft.cpp | 16 +- .../PSVita/PSVita_UIController.cpp | 2 +- Minecraft.Client/PSVita/XML/ATGXmlParser.h | 2 +- Minecraft.Client/Particle.cpp | 4 +- Minecraft.Client/ParticleEngine.cpp | 6 +- Minecraft.Client/PauseScreen.cpp | 4 +- Minecraft.Client/PendingConnection.cpp | 10 +- Minecraft.Client/PistonPieceRenderer.cpp | 4 +- Minecraft.Client/PlayerChunkMap.cpp | 34 +- Minecraft.Client/PlayerCloudParticle.cpp | 2 +- Minecraft.Client/PlayerConnection.cpp | 92 +- Minecraft.Client/PlayerList.cpp | 114 +- Minecraft.Client/PlayerRenderer.cpp | 28 +- Minecraft.Client/PreStitchedTextureMap.cpp | 20 +- Minecraft.Client/ReceivingLevelScreen.cpp | 2 +- Minecraft.Client/RemotePlayer.cpp | 2 +- Minecraft.Client/RenameWorldScreen.cpp | 2 +- Minecraft.Client/Screen.cpp | 18 +- Minecraft.Client/SelectWorldScreen.cpp | 20 +- Minecraft.Client/ServerChunkCache.cpp | 62 +- Minecraft.Client/ServerConnection.cpp | 4 +- Minecraft.Client/ServerLevel.cpp | 32 +- Minecraft.Client/ServerPlayer.cpp | 70 +- Minecraft.Client/ServerPlayerGameMode.cpp | 24 +- Minecraft.Client/ServerPlayerGameMode.h | 2 +- Minecraft.Client/ServerScoreboard.cpp | 10 +- Minecraft.Client/Settings.cpp | 2 +- Minecraft.Client/SkullTileRenderer.cpp | 2 +- Minecraft.Client/SlimeModel.cpp | 8 +- Minecraft.Client/SmallButton.cpp | 4 +- Minecraft.Client/SnowManRenderer.cpp | 2 +- Minecraft.Client/StatsCounter.cpp | 48 +- Minecraft.Client/StatsScreen.cpp | 20 +- Minecraft.Client/StitchSlot.cpp | 10 +- Minecraft.Client/StitchedTexture.cpp | 16 +- Minecraft.Client/Stitcher.cpp | 4 +- Minecraft.Client/TeleportCommand.cpp | 2 +- Minecraft.Client/TerrainParticle.cpp | 2 +- Minecraft.Client/TextEditScreen.cpp | 2 +- Minecraft.Client/Texture.cpp | 20 +- Minecraft.Client/Texture.h | 2 +- Minecraft.Client/TextureManager.cpp | 12 +- Minecraft.Client/TextureMap.cpp | 20 +- Minecraft.Client/TexturePack.cpp | 6 +- Minecraft.Client/TexturePack.h | 4 +- Minecraft.Client/TexturePackRepository.cpp | 36 +- Minecraft.Client/Textures.cpp | 76 +- .../TileEntityRenderDispatcher.cpp | 20 +- Minecraft.Client/TileEntityRenderer.cpp | 4 +- Minecraft.Client/TileRenderer.cpp | 26 +- Minecraft.Client/TitleScreen.cpp | 4 +- Minecraft.Client/TrackedEntity.cpp | 40 +- Minecraft.Client/VideoSettingsScreen.cpp | 2 +- .../Windows64/4JLibs/inc/4J_Input.h | 4 +- .../Windows64/4JLibs/inc/4J_Profile.h | 2 +- .../Windows64/4JLibs/inc/4J_Render.h | 6 +- .../Windows64/4JLibs/inc/4J_Storage.h | 18 +- .../Iggy/gdraw/gdraw_d3d10_shaders.inl | 22 +- .../Windows64/Iggy/gdraw/gdraw_d3d11.cpp | 16 +- .../Windows64/Iggy/gdraw/gdraw_d3d11.h | 4 +- .../Iggy/gdraw/gdraw_d3d1x_shared.inl | 146 +- .../Windows64/Iggy/gdraw/gdraw_gl_shaders.inl | 40 +- .../Windows64/Iggy/gdraw/gdraw_gl_shared.inl | 96 +- .../Windows64/Iggy/gdraw/gdraw_shared.inl | 76 +- .../Windows64/Iggy/include/gdraw.h | 8 +- .../Windows64/Iggy/include/iggyexpruntime.h | 4 +- .../Windows64/KeyboardMouseInput.cpp | 8 +- .../Windows64/Network/WinsockNetLayer.cpp | 56 +- .../Windows64/Network/WinsockNetLayer.h | 2 +- Minecraft.Client/Windows64/Windows64_App.cpp | 8 +- Minecraft.Client/Windows64/Windows64_App.h | 2 +- .../Windows64/Windows64_Minecraft.cpp | 76 +- .../Windows64/Windows64_UIController.cpp | 4 +- Minecraft.Client/Windows64/XML/ATGXmlParser.h | 2 +- Minecraft.Client/WitchRenderer.cpp | 4 +- Minecraft.Client/Xbox/4JLibs/inc/4J_Input.h | 4 +- Minecraft.Client/Xbox/4JLibs/inc/4J_Profile.h | 2 +- Minecraft.Client/Xbox/4JLibs/inc/4J_Render.h | 2 +- Minecraft.Client/Xbox/4JLibs/inc/4J_Storage.h | 24 +- Minecraft.Client/Xbox/Audio/SoundEngine.cpp | 106 +- Minecraft.Client/Xbox/Font/XUI_Font.cpp | 10 +- Minecraft.Client/Xbox/Font/XUI_FontData.cpp | 12 +- .../Xbox/Font/XUI_FontRenderer.cpp | 16 +- .../Leaderboards/XboxLeaderboardManager.cpp | 104 +- .../Xbox/Network/NetworkPlayerXbox.cpp | 6 +- .../Network/PlatformNetworkManagerXbox.cpp | 126 +- .../Xbox/Network/PlatformNetworkManagerXbox.h | 2 +- .../Xbox/Sentient/DynamicConfigurations.cpp | 14 +- .../Xbox/Sentient/Include/SenClientAvatar.h | 18 +- .../Xbox/Sentient/Include/SenClientBoxArt.h | 38 +- .../Xbox/Sentient/Include/SenClientConfig.h | 4 +- .../Xbox/Sentient/Include/SenClientCore.h | 2 +- .../SenClientCultureBackCompat_SenClientUGC.h | 4 +- .../Sentient/Include/SenClientDynamicConfig.h | 8 +- .../Xbox/Sentient/Include/SenClientFame.h | 24 +- .../Xbox/Sentient/Include/SenClientUGC.h | 10 +- .../Xbox/Sentient/Include/SenClientUser.h | 4 +- .../Xbox/Sentient/SentientManager.cpp | 8 +- .../Xbox/Sentient/SentientStats.cpp | 72 +- .../Xbox/Social/SocialManager.cpp | 28 +- Minecraft.Client/Xbox/XML/ATGXmlParser.cpp | 22 +- Minecraft.Client/Xbox/XML/ATGXmlParser.h | 2 +- Minecraft.Client/Xbox/XML/xmlFilesCallback.h | 12 +- Minecraft.Client/Xbox/Xbox_App.cpp | 358 +- Minecraft.Client/Xbox/Xbox_App.h | 4 +- Minecraft.Client/Xbox/Xbox_Minecraft.cpp | 6 +- Minecraft.Client/Xbox/Xbox_UIController.cpp | 10 +- Minecraft.Client/Xbox/Xbox_UIController.h | 6 +- Minecraft.Client/ZombieRenderer.cpp | 8 +- Minecraft.Client/stubs.h | 6 +- Minecraft.World/AABB.cpp | 38 +- Minecraft.World/AbstractContainerMenu.cpp | 66 +- Minecraft.World/Achievement.cpp | 2 +- Minecraft.World/Achievements.cpp | 160 +- Minecraft.World/AddMobPacket.cpp | 10 +- Minecraft.World/AddPlayerPacket.cpp | 14 +- Minecraft.World/AgableMob.cpp | 6 +- Minecraft.World/Animal.cpp | 20 +- Minecraft.World/AnvilMenu.cpp | 16 +- Minecraft.World/AnvilTile.cpp | 2 +- Minecraft.World/ArmorDyeRecipe.cpp | 20 +- Minecraft.World/ArmorItem.cpp | 10 +- Minecraft.World/ArmorSlot.cpp | 8 +- Minecraft.World/ArrayWithLength.h | 6 +- Minecraft.World/Arrow.cpp | 28 +- Minecraft.World/AttributeModifier.cpp | 2 +- Minecraft.World/AvoidPlayerGoal.cpp | 16 +- Minecraft.World/AwardStatPacket.cpp | 8 +- Minecraft.World/BaseAttributeMap.cpp | 6 +- Minecraft.World/BaseEntityTile.cpp | 2 +- Minecraft.World/BaseMobSpawner.cpp | 46 +- Minecraft.World/BasePressurePlateTile.cpp | 2 +- Minecraft.World/BaseRailTile.cpp | 14 +- Minecraft.World/BasicTree.cpp | 6 +- Minecraft.World/BasicTypeContainers.cpp | 2 +- Minecraft.World/Bat.cpp | 10 +- Minecraft.World/BeaconMenu.cpp | 4 +- Minecraft.World/BeaconTile.cpp | 2 +- Minecraft.World/BeaconTileEntity.cpp | 10 +- Minecraft.World/BedTile.cpp | 10 +- Minecraft.World/BegGoal.cpp | 6 +- Minecraft.World/BinaryHeap.cpp | 6 +- Minecraft.World/Biome.cpp | 52 +- Minecraft.World/BiomeCache.cpp | 4 +- Minecraft.World/BiomeDecorator.cpp | 14 +- Minecraft.World/BiomeOverrideLayer.cpp | 8 +- Minecraft.World/BiomeSource.cpp | 32 +- Minecraft.World/BirchFeature.cpp | 2 +- Minecraft.World/Blaze.cpp | 2 +- Minecraft.World/BlockReplacements.cpp | 2 +- Minecraft.World/Boat.cpp | 16 +- Minecraft.World/BoatItem.cpp | 4 +- Minecraft.World/BonusChestFeature.cpp | 2 +- Minecraft.World/BottleItem.cpp | 4 +- Minecraft.World/BoundingBox.cpp | 2 +- Minecraft.World/BowItem.cpp | 2 +- Minecraft.World/BreedGoal.cpp | 12 +- Minecraft.World/BrewingStandMenu.cpp | 6 +- Minecraft.World/BrewingStandTile.cpp | 8 +- Minecraft.World/BrewingStandTileEntity.cpp | 32 +- Minecraft.World/BucketItem.cpp | 6 +- Minecraft.World/Bush.cpp | 2 +- Minecraft.World/ButtonTile.cpp | 2 +- Minecraft.World/ByteArrayInputStream.cpp | 2 +- Minecraft.World/ByteArrayOutputStream.cpp | 2 +- Minecraft.World/ByteArrayTag.h | 2 +- Minecraft.World/C4JThread.cpp | 74 +- Minecraft.World/CactusTile.cpp | 4 +- Minecraft.World/CakeTile.cpp | 6 +- Minecraft.World/CauldronTile.cpp | 10 +- Minecraft.World/CaveFeature.cpp | 2 +- Minecraft.World/ChestTile.cpp | 10 +- Minecraft.World/ChestTileEntity.cpp | 38 +- Minecraft.World/ChunkSource.h | 2 +- Minecraft.World/ClientSideMerchant.cpp | 4 +- Minecraft.World/ClockItem.cpp | 4 +- Minecraft.World/ColoredTileItem.cpp | 6 +- Minecraft.World/CombatEntry.cpp | 6 +- Minecraft.World/CombatTracker.cpp | 32 +- Minecraft.World/Command.cpp | 4 +- Minecraft.World/CommandBlock.cpp | 6 +- Minecraft.World/CommandBlockEntity.cpp | 2 +- Minecraft.World/CommonStats.cpp | 24 +- Minecraft.World/ComparatorTile.cpp | 2 +- Minecraft.World/CompassItem.cpp | 4 +- Minecraft.World/CompoundContainer.cpp | 4 +- Minecraft.World/CompoundTag.h | 2 +- Minecraft.World/CompressedTileStorage.cpp | 28 +- Minecraft.World/Connection.cpp | 44 +- Minecraft.World/ConsoleSaveFile.h | 4 +- Minecraft.World/ConsoleSaveFileConverter.cpp | 2 +- .../ConsoleSaveFileInputStream.cpp | 8 +- Minecraft.World/ConsoleSaveFileOriginal.cpp | 72 +- Minecraft.World/ConsoleSaveFileOriginal.h | 4 +- .../ConsoleSaveFileOutputStream.cpp | 8 +- Minecraft.World/ContainerMenu.cpp | 4 +- Minecraft.World/ContainerSetContentPacket.cpp | 2 +- Minecraft.World/ContainerSetSlotPacket.cpp | 2 +- Minecraft.World/ControlledByPlayerGoal.cpp | 6 +- Minecraft.World/Cow.cpp | 2 +- Minecraft.World/CraftingContainer.cpp | 4 +- Minecraft.World/CraftingMenu.cpp | 4 +- Minecraft.World/Creeper.cpp | 6 +- Minecraft.World/CropTile.cpp | 2 +- Minecraft.World/CustomLevelSource.cpp | 38 +- Minecraft.World/CustomPayloadPacket.cpp | 6 +- Minecraft.World/DamageEnchantment.cpp | 2 +- Minecraft.World/DamageSource.cpp | 6 +- Minecraft.World/DataLayer.cpp | 2 +- .../DaylightDetectorTileEntity.cpp | 4 +- Minecraft.World/DeadBushTile.cpp | 2 +- Minecraft.World/DefendVillageTargetGoal.cpp | 2 +- Minecraft.World/DetectorRailTile.cpp | 2 +- Minecraft.World/Dimension.cpp | 8 +- Minecraft.World/DiodeTile.cpp | 2 +- Minecraft.World/DirectoryLevelStorage.cpp | 18 +- .../DirectoryLevelStorageSource.cpp | 4 +- Minecraft.World/DispenserTile.cpp | 12 +- Minecraft.World/DispenserTileEntity.cpp | 22 +- Minecraft.World/DoorInteractGoal.cpp | 10 +- Minecraft.World/DropperTile.cpp | 8 +- Minecraft.World/DurangoStats.cpp | 20 +- Minecraft.World/DyePowderItem.cpp | 8 +- Minecraft.World/EnchantItemCommand.cpp | 12 +- Minecraft.World/EnchantedBookItem.cpp | 6 +- Minecraft.World/Enchantment.cpp | 48 +- Minecraft.World/EnchantmentCategory.cpp | 8 +- Minecraft.World/EnchantmentHelper.cpp | 26 +- Minecraft.World/EnchantmentMenu.cpp | 10 +- Minecraft.World/EnchantmentTableEntity.cpp | 2 +- Minecraft.World/EnchantmentTableTile.cpp | 4 +- Minecraft.World/EnderChestTile.cpp | 2 +- Minecraft.World/EnderCrystal.cpp | 2 +- Minecraft.World/EnderDragon.cpp | 86 +- Minecraft.World/EnderDragon.h | 2 +- Minecraft.World/EnderEyeItem.cpp | 10 +- Minecraft.World/EnderMan.cpp | 14 +- Minecraft.World/EnderpearlItem.cpp | 2 +- Minecraft.World/Enemy.cpp | 2 +- Minecraft.World/Entity.cpp | 44 +- Minecraft.World/EntityDamageSource.cpp | 6 +- Minecraft.World/EntityHorse.cpp | 62 +- Minecraft.World/EntityIO.cpp | 20 +- Minecraft.World/EntityPos.cpp | 2 +- Minecraft.World/EntitySelector.cpp | 4 +- Minecraft.World/ExperienceOrb.cpp | 4 +- Minecraft.World/Explosion.cpp | 10 +- Minecraft.World/Explosion.h | 2 +- Minecraft.World/FallingTile.cpp | 8 +- Minecraft.World/FarmTile.cpp | 4 +- Minecraft.World/FastNoise.cpp | 2 +- Minecraft.World/FenceGateTile.cpp | 4 +- Minecraft.World/FenceTile.cpp | 2 +- Minecraft.World/File.cpp | 38 +- Minecraft.World/FileHeader.cpp | 40 +- Minecraft.World/FileInputStream.cpp | 14 +- Minecraft.World/FileOutputStream.cpp | 14 +- Minecraft.World/FireChargeItem.cpp | 2 +- Minecraft.World/FireTile.cpp | 4 +- Minecraft.World/Fireball.cpp | 16 +- Minecraft.World/FireworksChargeItem.cpp | 8 +- Minecraft.World/FireworksItem.cpp | 4 +- Minecraft.World/FireworksMenu.cpp | 6 +- Minecraft.World/FireworksRecipe.cpp | 26 +- Minecraft.World/FireworksRocketEntity.cpp | 16 +- Minecraft.World/FishingHook.cpp | 18 +- Minecraft.World/FishingRodItem.cpp | 4 +- Minecraft.World/FixedBiomeSource.cpp | 16 +- Minecraft.World/FlatGeneratorInfo.cpp | 10 +- Minecraft.World/FlatLevelSource.cpp | 6 +- Minecraft.World/FleeSunGoal.cpp | 4 +- Minecraft.World/FlowerFeature.cpp | 2 +- Minecraft.World/FlowerPotTile.cpp | 8 +- Minecraft.World/FollowOwnerGoal.cpp | 4 +- Minecraft.World/FollowParentGoal.cpp | 4 +- Minecraft.World/FurnaceMenu.cpp | 4 +- Minecraft.World/FurnaceRecipes.cpp | 4 +- Minecraft.World/FurnaceTile.cpp | 12 +- Minecraft.World/FurnaceTileEntity.cpp | 28 +- Minecraft.World/GameCommandPacket.cpp | 6 +- Minecraft.World/GameModeCommand.cpp | 2 +- Minecraft.World/GenericStats.cpp | 142 +- Minecraft.World/Ghast.cpp | 10 +- Minecraft.World/GiveItemCommand.cpp | 4 +- Minecraft.World/GrassTile.cpp | 6 +- Minecraft.World/HangingEntity.cpp | 10 +- Minecraft.World/HangingEntityItem.cpp | 2 +- Minecraft.World/HatchetItem.cpp | 4 +- Minecraft.World/HellFlatLevelSource.cpp | 6 +- Minecraft.World/HellRandomLevelSource.cpp | 10 +- Minecraft.World/HopperMenu.cpp | 2 +- Minecraft.World/HopperTile.cpp | 8 +- Minecraft.World/HopperTileEntity.cpp | 60 +- Minecraft.World/HorseInventoryMenu.cpp | 2 +- Minecraft.World/HtmlString.cpp | 2 +- Minecraft.World/HugeMushroomTile.cpp | 6 +- Minecraft.World/HurtByTargetGoal.cpp | 2 +- Minecraft.World/IceTile.cpp | 2 +- .../IndirectEntityDamageSource.cpp | 6 +- Minecraft.World/InputStream.cpp | 2 +- Minecraft.World/IntArrayTag.h | 2 +- Minecraft.World/IntCache.cpp | 6 +- Minecraft.World/Inventory.cpp | 86 +- Minecraft.World/InventoryMenu.cpp | 6 +- Minecraft.World/Item.cpp | 414 +- Minecraft.World/ItemDispenseBehaviors.cpp | 2 +- Minecraft.World/ItemEntity.cpp | 12 +- Minecraft.World/ItemFrame.cpp | 18 +- Minecraft.World/ItemInstance.cpp | 86 +- Minecraft.World/JukeboxTile.cpp | 10 +- Minecraft.World/LakeFeature.cpp | 4 +- Minecraft.World/LargeFireball.cpp | 2 +- Minecraft.World/Layer.cpp | 2 +- Minecraft.World/LeafTile.cpp | 6 +- Minecraft.World/LeapAtTargetGoal.cpp | 4 +- Minecraft.World/LeashFenceKnotEntity.cpp | 10 +- Minecraft.World/LeashItem.cpp | 8 +- Minecraft.World/Level.cpp | 182 +- Minecraft.World/Level.h | 2 +- Minecraft.World/LevelChunk.cpp | 126 +- Minecraft.World/LevelData.cpp | 8 +- Minecraft.World/LevelSettings.cpp | 8 +- Minecraft.World/LevelStorage.h | 2 +- Minecraft.World/LevelType.cpp | 14 +- Minecraft.World/LeverTile.cpp | 2 +- Minecraft.World/LiquidTile.cpp | 6 +- Minecraft.World/LivingEntity.cpp | 74 +- Minecraft.World/LivingEntity.h | 2 +- Minecraft.World/LoginPacket.cpp | 10 +- Minecraft.World/LookAtPlayerGoal.cpp | 6 +- Minecraft.World/MakeLoveGoal.cpp | 8 +- Minecraft.World/MapItem.cpp | 8 +- Minecraft.World/MapItemSavedData.cpp | 8 +- Minecraft.World/Material.cpp | 66 +- Minecraft.World/MaterialColor.cpp | 28 +- Minecraft.World/McRegionChunkStorage.cpp | 24 +- Minecraft.World/McRegionLevelStorage.cpp | 8 +- .../McRegionLevelStorageSource.cpp | 8 +- Minecraft.World/MegaTreeFeature.cpp | 2 +- Minecraft.World/MeleeAttackGoal.cpp | 16 +- Minecraft.World/MelonTile.cpp | 2 +- Minecraft.World/MemoryChunkStorage.cpp | 2 +- Minecraft.World/MemoryLevelStorage.cpp | 4 +- Minecraft.World/MemoryLevelStorageSource.cpp | 2 +- Minecraft.World/MerchantContainer.cpp | 22 +- Minecraft.World/MerchantMenu.cpp | 6 +- Minecraft.World/MerchantRecipe.cpp | 8 +- Minecraft.World/MerchantRecipeList.cpp | 16 +- Minecraft.World/MerchantResultSlot.cpp | 8 +- Minecraft.World/MineShaftFeature.cpp | 2 +- Minecraft.World/MineShaftPieces.cpp | 36 +- Minecraft.World/Minecart.cpp | 54 +- Minecraft.World/MinecartContainer.cpp | 12 +- Minecraft.World/MinecartFurnace.cpp | 2 +- Minecraft.World/MinecartRideable.cpp | 4 +- Minecraft.World/Mob.cpp | 78 +- Minecraft.World/Mob.h | 2 +- Minecraft.World/MobCategory.cpp | 14 +- Minecraft.World/MobEffect.cpp | 24 +- Minecraft.World/MobSpawner.cpp | 12 +- Minecraft.World/MobSpawnerTileEntity.cpp | 2 +- Minecraft.World/MockedLevelStorage.cpp | 6 +- Minecraft.World/MockedLevelStorage.h | 2 +- .../ModifiableAttributeInstance.cpp | 6 +- Minecraft.World/Monster.cpp | 2 +- Minecraft.World/Monster.h | 2 +- Minecraft.World/MonsterRoomFeature.cpp | 4 +- Minecraft.World/MoveEntityPacket.cpp | 2 +- Minecraft.World/MoveEntityPacketSmall.cpp | 2 +- Minecraft.World/MoveIndoorsGoal.cpp | 10 +- Minecraft.World/MoveThroughVillageGoal.cpp | 20 +- .../MoveTowardsRestrictionGoal.cpp | 2 +- Minecraft.World/MoveTowardsTargetGoal.cpp | 6 +- Minecraft.World/Mth.cpp | 6 +- Minecraft.World/Mushroom.cpp | 8 +- Minecraft.World/MushroomCow.cpp | 4 +- Minecraft.World/MycelTile.cpp | 4 +- Minecraft.World/NameTagItem.cpp | 2 +- Minecraft.World/NbtIo.cpp | 4 +- Minecraft.World/NbtSlotFile.cpp | 40 +- .../NearestAttackableTargetGoal.cpp | 6 +- Minecraft.World/NearestAttackableTargetGoal.h | 2 +- Minecraft.World/NetherBridgeFeature.cpp | 6 +- Minecraft.World/NetherBridgePieces.cpp | 132 +- Minecraft.World/Node.cpp | 4 +- Minecraft.World/NotGateTile.cpp | 2 +- Minecraft.World/NoteBlockTile.cpp | 6 +- Minecraft.World/Ocelot.cpp | 6 +- Minecraft.World/OcelotAttackGoal.cpp | 4 +- Minecraft.World/OfferFlowerGoal.cpp | 4 +- Minecraft.World/OldChunkStorage.cpp | 28 +- Minecraft.World/OreFeature.cpp | 6 +- Minecraft.World/OwnerHurtByTargetGoal.cpp | 4 +- Minecraft.World/OwnerHurtTargetGoal.cpp | 4 +- Minecraft.World/Packet.cpp | 10 +- Minecraft.World/Painting.cpp | 6 +- Minecraft.World/Path.cpp | 8 +- Minecraft.World/PathFinder.cpp | 28 +- Minecraft.World/PathNavigation.cpp | 28 +- Minecraft.World/PathfinderMob.cpp | 34 +- Minecraft.World/PerlinNoise.cpp | 2 +- Minecraft.World/PerlinSimplexNoise.cpp | 4 +- Minecraft.World/PickaxeItem.cpp | 2 +- Minecraft.World/Pig.cpp | 8 +- Minecraft.World/PigZombie.cpp | 4 +- Minecraft.World/PineFeature.cpp | 2 +- Minecraft.World/PistonBaseTile.cpp | 16 +- Minecraft.World/PistonExtensionTile.cpp | 6 +- Minecraft.World/PistonMovingPiece.cpp | 26 +- Minecraft.World/PistonPieceEntity.cpp | 4 +- Minecraft.World/PlayGoal.cpp | 12 +- Minecraft.World/Player.cpp | 132 +- Minecraft.World/PlayerEnderChestContainer.cpp | 6 +- Minecraft.World/PlayerInfoPacket.cpp | 2 +- Minecraft.World/PlayerTeam.cpp | 2 +- Minecraft.World/PortalForcer.cpp | 2 +- Minecraft.World/PortalTile.cpp | 6 +- Minecraft.World/Pos.cpp | 4 +- Minecraft.World/PotionBrewing.cpp | 10 +- Minecraft.World/PotionItem.cpp | 34 +- Minecraft.World/PreLoginPacket.cpp | 6 +- Minecraft.World/PressurePlateTile.cpp | 4 +- Minecraft.World/ProtectionEnchantment.cpp | 2 +- Minecraft.World/PumpkinTile.cpp | 4 +- Minecraft.World/RandomLevelSource.cpp | 30 +- Minecraft.World/RandomPos.cpp | 6 +- .../RandomScatteredLargeFeature.cpp | 8 +- Minecraft.World/RandomStrollGoal.cpp | 4 +- Minecraft.World/RangedAttackGoal.cpp | 4 +- Minecraft.World/ReadOnlyChunkCache.cpp | 8 +- Minecraft.World/Recipes.cpp | 28 +- Minecraft.World/Recipes.h | 2 +- Minecraft.World/RecordingItem.cpp | 2 +- Minecraft.World/RedStoneDustTile.cpp | 12 +- Minecraft.World/ReedTile.cpp | 2 +- Minecraft.World/ReedsFeature.cpp | 2 +- Minecraft.World/Region.cpp | 22 +- Minecraft.World/RegionFile.cpp | 34 +- Minecraft.World/RegionFileCache.cpp | 6 +- Minecraft.World/RepairResultSlot.cpp | 2 +- Minecraft.World/RespawnPacket.cpp | 10 +- Minecraft.World/RestrictOpenDoorGoal.cpp | 6 +- Minecraft.World/ResultContainer.cpp | 4 +- Minecraft.World/ResultSlot.cpp | 4 +- Minecraft.World/RunAroundLikeCrazyGoal.cpp | 6 +- Minecraft.World/SaddleItem.cpp | 2 +- Minecraft.World/SandFeature.cpp | 2 +- Minecraft.World/SandStoneTile.cpp | 6 +- Minecraft.World/Sapling.cpp | 10 +- Minecraft.World/SavedDataStorage.cpp | 14 +- Minecraft.World/ScatteredFeaturePieces.cpp | 4 +- Minecraft.World/Scoreboard.cpp | 44 +- Minecraft.World/ServersideAttributeMap.cpp | 4 +- Minecraft.World/SetDisplayObjectivePacket.cpp | 2 +- Minecraft.World/SetEntityDataPacket.cpp | 2 +- Minecraft.World/SetEntityLinkPacket.cpp | 2 +- Minecraft.World/SetEquippedItemPacket.cpp | 2 +- Minecraft.World/SetPlayerTeamPacket.cpp | 2 +- Minecraft.World/ShapedRecipy.cpp | 14 +- Minecraft.World/SharedMonsterAttributes.cpp | 4 +- Minecraft.World/Sheep.cpp | 4 +- Minecraft.World/ShovelItem.cpp | 2 +- Minecraft.World/SignItem.cpp | 2 +- Minecraft.World/SignTile.cpp | 2 +- Minecraft.World/Silverfish.cpp | 8 +- Minecraft.World/SimpleContainer.cpp | 12 +- Minecraft.World/SitGoal.cpp | 4 +- Minecraft.World/Skeleton.cpp | 14 +- Minecraft.World/SkullItem.cpp | 2 +- Minecraft.World/SkullTile.cpp | 4 +- Minecraft.World/SkyIslandDimension.cpp | 2 +- Minecraft.World/Slime.cpp | 4 +- Minecraft.World/Slot.cpp | 22 +- Minecraft.World/SmallFireball.cpp | 2 +- Minecraft.World/SmoothStoneBrickTile.cpp | 2 +- Minecraft.World/Snowball.cpp | 2 +- Minecraft.World/Socket.cpp | 26 +- Minecraft.World/SparseDataStorage.cpp | 2 +- Minecraft.World/SparseLightStorage.cpp | 2 +- Minecraft.World/SpawnEggItem.cpp | 20 +- Minecraft.World/Spider.cpp | 8 +- Minecraft.World/SpringFeature.cpp | 2 +- Minecraft.World/SpruceFeature.cpp | 2 +- Minecraft.World/StairTile.cpp | 10 +- Minecraft.World/Stats.cpp | 50 +- Minecraft.World/StemTile.cpp | 4 +- Minecraft.World/StrongholdFeature.cpp | 10 +- Minecraft.World/StrongholdPieces.cpp | 132 +- Minecraft.World/StructureFeature.cpp | 18 +- Minecraft.World/StructureFeatureIO.cpp | 8 +- Minecraft.World/StructurePiece.cpp | 14 +- Minecraft.World/StructureStart.cpp | 4 +- Minecraft.World/SwampTreeFeature.cpp | 2 +- Minecraft.World/SwellGoal.cpp | 4 +- Minecraft.World/SynchedEntityData.cpp | 26 +- Minecraft.World/Tag.cpp | 4 +- Minecraft.World/TakeFlowerGoal.cpp | 2 +- Minecraft.World/TallGrass.cpp | 2 +- Minecraft.World/TamableAnimal.cpp | 6 +- Minecraft.World/TargetGoal.cpp | 14 +- Minecraft.World/Team.cpp | 2 +- Minecraft.World/TemptGoal.cpp | 6 +- Minecraft.World/TextureAndGeometryPacket.cpp | 16 +- Minecraft.World/TexturePacket.cpp | 4 +- Minecraft.World/TheEndDimension.cpp | 2 +- .../TheEndLevelRandomLevelSource.cpp | 8 +- Minecraft.World/TheEndPortal.cpp | 4 +- Minecraft.World/TheEndPortalFrameTile.cpp | 4 +- Minecraft.World/ThinFenceTile.cpp | 2 +- Minecraft.World/ThornsEnchantment.cpp | 4 +- Minecraft.World/Throwable.cpp | 14 +- Minecraft.World/ThrownEgg.cpp | 2 +- Minecraft.World/ThrownEnderpearl.cpp | 4 +- Minecraft.World/ThrownPotion.cpp | 12 +- Minecraft.World/TickNextTickData.cpp | 2 +- Minecraft.World/Tile.cpp | 422 +- Minecraft.World/TileEntity.cpp | 16 +- Minecraft.World/TileEntityDataPacket.cpp | 2 +- Minecraft.World/TileItem.cpp | 8 +- Minecraft.World/TntTile.cpp | 6 +- Minecraft.World/TorchTile.cpp | 2 +- Minecraft.World/TradeWithPlayerGoal.cpp | 2 +- Minecraft.World/TrapDoorTile.cpp | 2 +- Minecraft.World/TrapMenu.cpp | 2 +- Minecraft.World/TreeFeature.cpp | 2 +- Minecraft.World/TripWireSourceTile.cpp | 2 +- Minecraft.World/TripWireTile.cpp | 4 +- Minecraft.World/Vec3.cpp | 16 +- Minecraft.World/Village.cpp | 14 +- Minecraft.World/VillageFeature.cpp | 2 +- Minecraft.World/VillagePieces.cpp | 90 +- Minecraft.World/VillageSiege.cpp | 14 +- Minecraft.World/Villager.cpp | 32 +- Minecraft.World/VillagerGolem.cpp | 6 +- Minecraft.World/Villages.cpp | 4 +- Minecraft.World/VineTile.cpp | 6 +- Minecraft.World/WallTile.cpp | 2 +- Minecraft.World/WaterLevelChunk.cpp | 2 +- Minecraft.World/WaterLilyTile.cpp | 2 +- Minecraft.World/WaterLilyTileItem.cpp | 4 +- Minecraft.World/WebTile.cpp | 2 +- Minecraft.World/WeighedRandom.cpp | 4 +- Minecraft.World/Witch.cpp | 8 +- Minecraft.World/WitherBoss.cpp | 12 +- Minecraft.World/WitherSkull.cpp | 4 +- Minecraft.World/Wolf.cpp | 24 +- Minecraft.World/WoodTile.cpp | 2 +- Minecraft.World/WorkbenchTile.cpp | 4 +- Minecraft.World/Zombie.cpp | 26 +- Minecraft.World/ZoneFile.cpp | 2 +- Minecraft.World/ZoneIo.cpp | 8 +- Minecraft.World/ZonedChunkStorage.cpp | 10 +- Minecraft.World/compression.cpp | 18 +- Minecraft.World/x64headers/extraX64.h | 2 +- tall cloc | 324 + 1045 files changed, 12995 insertions(+), 12671 deletions(-) create mode 100644 tall cloc diff --git a/Minecraft.Client/AbstractContainerScreen.cpp b/Minecraft.Client/AbstractContainerScreen.cpp index fbf1331d0..c2de6dc9a 100644 --- a/Minecraft.Client/AbstractContainerScreen.cpp +++ b/Minecraft.Client/AbstractContainerScreen.cpp @@ -51,7 +51,7 @@ void AbstractContainerScreen::render(int xm, int ym, float a) glColor4f(1, 1, 1, 1); glEnable(GL_RESCALE_NORMAL); - Slot *hoveredSlot = NULL; + Slot *hoveredSlot = nullptr; for ( Slot *slot : *menu->slots ) { @@ -73,7 +73,7 @@ void AbstractContainerScreen::render(int xm, int ym, float a) } shared_ptr inventory = minecraft->player->inventory; - if (inventory->getCarried() != NULL) + if (inventory->getCarried() != nullptr) { glTranslatef(0, 0, 32); // Slot old = carriedSlot; @@ -90,7 +90,7 @@ void AbstractContainerScreen::render(int xm, int ym, float a) renderLabels(); - if (inventory->getCarried() == NULL && hoveredSlot != NULL && hoveredSlot->hasItem()) + if (inventory->getCarried() == nullptr && hoveredSlot != nullptr && hoveredSlot->hasItem()) { wstring elementName = trimString(Language::getInstance()->getElementName(hoveredSlot->getItem()->getDescriptionId())); @@ -127,7 +127,7 @@ void AbstractContainerScreen::renderSlot(Slot *slot) int y = slot->y; shared_ptr item = slot->getItem(); - if (item == NULL) + if (item == nullptr) { int icon = slot->getNoItemIcon(); if (icon >= 0) @@ -151,7 +151,7 @@ Slot *AbstractContainerScreen::findSlot(int x, int y) { if (isHovering(slot, x, y)) return slot; } - return NULL; + return nullptr; } bool AbstractContainerScreen::isHovering(Slot *slot, int xm, int ym) @@ -177,7 +177,7 @@ void AbstractContainerScreen::mouseClicked(int x, int y, int buttonNum) bool clickedOutside = (x < xo || y < yo || x >= xo + imageWidth || y >= yo + imageHeight); int slotId = -1; - if (slot != NULL) slotId = slot->index; + if (slot != nullptr) slotId = slot->index; if (clickedOutside) { @@ -210,7 +210,7 @@ void AbstractContainerScreen::keyPressed(wchar_t eventCharacter, int eventKey) void AbstractContainerScreen::removed() { - if (minecraft->player == NULL) return; + if (minecraft->player == nullptr) return; } void AbstractContainerScreen::slotsChanged(shared_ptr container) diff --git a/Minecraft.Client/AbstractTexturePack.cpp b/Minecraft.Client/AbstractTexturePack.cpp index 80799a4c5..16d1b14e6 100644 --- a/Minecraft.Client/AbstractTexturePack.cpp +++ b/Minecraft.Client/AbstractTexturePack.cpp @@ -8,16 +8,16 @@ AbstractTexturePack::AbstractTexturePack(DWORD id, File *file, const wstring &na { // 4J init textureId = -1; - m_colourTable = NULL; + m_colourTable = nullptr; this->file = file; this->fallback = fallback; - m_iconData = NULL; + m_iconData = nullptr; m_iconSize = 0; - m_comparisonData = NULL; + m_comparisonData = nullptr; m_comparisonSize = 0; // 4J Stu - These calls need to be in the most derived version of the class @@ -41,7 +41,7 @@ void AbstractTexturePack::loadIcon() const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/TexturePackIcon.png"); UINT size = 0; @@ -57,7 +57,7 @@ void AbstractTexturePack::loadComparison() const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/DefaultPack_Comparison.png"); UINT size = 0; @@ -70,8 +70,8 @@ void AbstractTexturePack::loadDescription() { // 4J Unused currently #if 0 - InputStream *inputStream = NULL; - BufferedReader *br = NULL; + InputStream *inputStream = nullptr; + BufferedReader *br = nullptr; //try { inputStream = getResourceImplementation(L"/pack.txt"); br = new BufferedReader(new InputStreamReader(inputStream)); @@ -81,12 +81,12 @@ void AbstractTexturePack::loadDescription() //} finally { // TODO [EB]: use IOUtils.closeSilently() // try { - if (br != NULL) + if (br != nullptr) { br->close(); delete br; } - if (inputStream != NULL) + if (inputStream != nullptr) { inputStream->close(); delete inputStream; @@ -105,7 +105,7 @@ InputStream *AbstractTexturePack::getResource(const wstring &name, bool allowFal { app.DebugPrintf("texture - %ls\n",name.c_str()); InputStream *is = getResourceImplementation(name); - if (is == NULL && fallback != NULL && allowFallback) + if (is == nullptr && fallback != nullptr && allowFallback) { is = fallback->getResource(name, true); } @@ -121,7 +121,7 @@ InputStream *AbstractTexturePack::getResource(const wstring &name, bool allowFal void AbstractTexturePack::unload(Textures *textures) { - if (iconImage != NULL && textureId != -1) + if (iconImage != nullptr && textureId != -1) { textures->releaseTexture(textureId); } @@ -129,7 +129,7 @@ void AbstractTexturePack::unload(Textures *textures) void AbstractTexturePack::load(Textures *textures) { - if (iconImage != NULL) + if (iconImage != nullptr) { if (textureId == -1) { @@ -149,7 +149,7 @@ bool AbstractTexturePack::hasFile(const wstring &name, bool allowFallback) { bool hasFile = this->hasFile(name); - return !hasFile && (allowFallback && fallback != NULL) ? fallback->hasFile(name, allowFallback) : hasFile; + return !hasFile && (allowFallback && fallback != nullptr) ? fallback->hasFile(name, allowFallback) : hasFile; } DWORD AbstractTexturePack::getId() @@ -231,7 +231,7 @@ void AbstractTexturePack::loadDefaultUI() { #ifdef _XBOX // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); // Load new skin const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string @@ -240,7 +240,7 @@ void AbstractTexturePack::loadDefaultUI() swprintf(szResourceLocator, LOCATOR_SIZE,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/skin_Minecraft.xur"); XuiFreeVisuals(L""); - app.LoadSkin(szResourceLocator,NULL);//L"TexturePack"); + app.LoadSkin(szResourceLocator,nullptr);//L"TexturePack"); //CXuiSceneBase::GetInstance()->SetVisualPrefix(L"TexturePack"); CXuiSceneBase::GetInstance()->SkinChanged(CXuiSceneBase::GetInstance()->m_hObj); #else @@ -259,7 +259,7 @@ void AbstractTexturePack::loadDefaultColourTable() // Load the file #ifdef __PS3__ // need to check if it's a BD build, so pass in the name - File coloursFile(AbstractTexturePack::getPath(true,app.GetBootedFromDiscPatch()?"colours.col":NULL).append(L"res/colours.col")); + File coloursFile(AbstractTexturePack::getPath(true,app.GetBootedFromDiscPatch()?"colours.col":nullptr).append(L"res/colours.col")); #else File coloursFile(AbstractTexturePack::getPath(true).append(L"res/colours.col")); @@ -269,12 +269,12 @@ void AbstractTexturePack::loadDefaultColourTable() if(coloursFile.exists()) { DWORD dwLength = coloursFile.length(); - byteArray data(dwLength); + byteArray data(static_cast(dwLength)); FileInputStream fis(coloursFile); fis.read(data,0,dwLength); fis.close(); - if(m_colourTable != NULL) delete m_colourTable; + if(m_colourTable != nullptr) delete m_colourTable; m_colourTable = new ColourTable(data.data, dwLength); delete [] data.data; @@ -290,7 +290,7 @@ void AbstractTexturePack::loadDefaultHTMLColourTable() { #ifdef _XBOX // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; @@ -309,7 +309,7 @@ void AbstractTexturePack::loadDefaultHTMLColourTable() { wsprintfW(szResourceLocator,L"section://%X,%s#%s",c_ModuleHandle,L"media", L"media/"); HXUIOBJ hScene; - HRESULT hr = XuiSceneCreate(szResourceLocator,L"xuiscene_colourtable.xur", NULL, &hScene); + HRESULT hr = XuiSceneCreate(szResourceLocator,L"xuiscene_colourtable.xur", nullptr, &hScene); if(HRESULT_SUCCEEDED(hr)) { @@ -333,7 +333,7 @@ void AbstractTexturePack::loadHTMLColourTableFromXuiScene(HXUIOBJ hObj) HXUIOBJ child; HRESULT hr = XuiElementGetFirstChild(hObj, &child); - while(HRESULT_SUCCEEDED(hr) && child != NULL) + while(HRESULT_SUCCEEDED(hr) && child != nullptr) { LPCWSTR childName; XuiElementGetId(child,&childName); @@ -374,7 +374,7 @@ void AbstractTexturePack::unloadUI() wstring AbstractTexturePack::getXuiRootPath() { - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); // Load new skin const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string @@ -386,14 +386,14 @@ wstring AbstractTexturePack::getXuiRootPath() PBYTE AbstractTexturePack::getPackIcon(DWORD &dwImageBytes) { - if(m_iconSize == 0 || m_iconData == NULL) loadIcon(); + if(m_iconSize == 0 || m_iconData == nullptr) loadIcon(); dwImageBytes = m_iconSize; return m_iconData; } PBYTE AbstractTexturePack::getPackComparison(DWORD &dwImageBytes) { - if(m_comparisonSize == 0 || m_comparisonData == NULL) loadComparison(); + if(m_comparisonSize == 0 || m_comparisonData == nullptr) loadComparison(); dwImageBytes = m_comparisonSize; return m_comparisonData; diff --git a/Minecraft.Client/AbstractTexturePack.h b/Minecraft.Client/AbstractTexturePack.h index e6410c193..6386ecf1e 100644 --- a/Minecraft.Client/AbstractTexturePack.h +++ b/Minecraft.Client/AbstractTexturePack.h @@ -89,5 +89,5 @@ class AbstractTexturePack : public TexturePack virtual unsigned int getDLCParentPackId(); virtual unsigned char getDLCSubPackId(); virtual ColourTable *getColourTable() { return m_colourTable; } - virtual ArchiveFile *getArchiveFile() { return NULL; } + virtual ArchiveFile *getArchiveFile() { return nullptr; } }; diff --git a/Minecraft.Client/AchievementPopup.cpp b/Minecraft.Client/AchievementPopup.cpp index c10ebde32..4e08f3b81 100644 --- a/Minecraft.Client/AchievementPopup.cpp +++ b/Minecraft.Client/AchievementPopup.cpp @@ -14,7 +14,7 @@ AchievementPopup::AchievementPopup(Minecraft *mc) // 4J - added initialisers width = 0; height = 0; - ach = NULL; + ach = nullptr; startTime = 0; isHelper = false; @@ -88,7 +88,7 @@ void AchievementPopup::render() glDepthMask(true); glEnable(GL_DEPTH_TEST); } - if (ach == NULL || startTime == 0) return; + if (ach == nullptr || startTime == 0) return; double time = (System::currentTimeMillis() - startTime) / 3000.0; if (isHelper) diff --git a/Minecraft.Client/AchievementScreen.cpp b/Minecraft.Client/AchievementScreen.cpp index 902aed174..baafce30a 100644 --- a/Minecraft.Client/AchievementScreen.cpp +++ b/Minecraft.Client/AchievementScreen.cpp @@ -52,7 +52,7 @@ void AchievementScreen::buttonClicked(Button *button) { if (button->id == 1) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J removed } Screen::buttonClicked(button); @@ -62,7 +62,7 @@ void AchievementScreen::keyPressed(char eventCharacter, int eventKey) { if (eventKey == minecraft->options->keyBuild->key) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J removed } else @@ -286,7 +286,7 @@ void AchievementScreen::renderBg(int xm, int ym, float a) vLine(x2, y1, y2, color); } - Achievement *hoveredAchievement = NULL; + Achievement *hoveredAchievement = nullptr; ItemRenderer *ir = new ItemRenderer(); glPushMatrix(); @@ -372,7 +372,7 @@ void AchievementScreen::renderBg(int xm, int ym, float a) glEnable(GL_TEXTURE_2D); Screen::render(xm, ym, a); - if (hoveredAchievement != NULL) + if (hoveredAchievement != nullptr) { Achievement *ach = hoveredAchievement; wstring name = ach->name; diff --git a/Minecraft.Client/ArchiveFile.cpp b/Minecraft.Client/ArchiveFile.cpp index 2e57a5bb7..608428b6e 100644 --- a/Minecraft.Client/ArchiveFile.cpp +++ b/Minecraft.Client/ArchiveFile.cpp @@ -30,7 +30,7 @@ void ArchiveFile::_readHeader(DataInputStream *dis) ArchiveFile::ArchiveFile(File file) { - m_cachedData = NULL; + m_cachedData = nullptr; m_sourcefile = file; app.DebugPrintf("Loading archive file...\n"); #ifndef _CONTENT_PACKAGE @@ -48,7 +48,7 @@ ArchiveFile::ArchiveFile(File file) FileInputStream fis(file); #if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - byteArray readArray(file.length()); + byteArray readArray(static_cast(file.length())); fis.read(readArray,0,file.length()); ByteArrayInputStream bais(readArray); @@ -122,20 +122,20 @@ byteArray ArchiveFile::getFile(const wstring &filename) HANDLE hfile = CreateFile( m_sourcefile.getPath().c_str(), GENERIC_READ, 0, - NULL, + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - NULL + nullptr ); #else app.DebugPrintf("Createfile archive\n"); HANDLE hfile = CreateFile( wstringtofilename(m_sourcefile.getPath()), GENERIC_READ, 0, - NULL, + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - NULL + nullptr ); #endif @@ -144,7 +144,7 @@ byteArray ArchiveFile::getFile(const wstring &filename) app.DebugPrintf("hfile ok\n"); DWORD ok = SetFilePointer( hfile, data->ptr, - NULL, + nullptr, FILE_BEGIN ); @@ -157,7 +157,7 @@ byteArray ArchiveFile::getFile(const wstring &filename) (LPVOID) pbData, data->filesize, &bytesRead, - NULL + nullptr ); if(bSuccess==FALSE) @@ -182,7 +182,7 @@ byteArray ArchiveFile::getFile(const wstring &filename) #endif // Compressed filenames are preceeded with an asterisk. - if ( data->isCompressed && out.data != NULL ) + if ( data->isCompressed && out.data != nullptr ) { /* 4J-JEV: * If a compressed file is accessed before compression object is @@ -204,7 +204,7 @@ byteArray ArchiveFile::getFile(const wstring &filename) out.length = decompressedSize; } - assert(out.data != NULL); // THERE IS NO FILE WITH THIS NAME! + assert(out.data != nullptr); // THERE IS NO FILE WITH THIS NAME! } diff --git a/Minecraft.Client/BreakingItemParticle.cpp b/Minecraft.Client/BreakingItemParticle.cpp index 2eab8616d..8842209b8 100644 --- a/Minecraft.Client/BreakingItemParticle.cpp +++ b/Minecraft.Client/BreakingItemParticle.cpp @@ -42,7 +42,7 @@ void BreakingItemParticle::render(Tesselator *t, float a, float xa, float ya, fl float v1 = v0 + 0.999f / 16.0f / 4; float r = 0.1f * size; - if (tex != NULL) + if (tex != nullptr) { u0 = tex->getU((uo / 4.0f) * SharedConstants::WORLD_RESOLUTION); u1 = tex->getU(((uo + 1) / 4.0f) * SharedConstants::WORLD_RESOLUTION); diff --git a/Minecraft.Client/BufferedImage.cpp b/Minecraft.Client/BufferedImage.cpp index 0b95c763d..8777d307b 100644 --- a/Minecraft.Client/BufferedImage.cpp +++ b/Minecraft.Client/BufferedImage.cpp @@ -31,7 +31,7 @@ BufferedImage::BufferedImage(int width,int height,int type) for( int i = 1 ; i < 10; i++ ) { - data[i] = NULL; + data[i] = nullptr; } this->width = width; this->height = height; @@ -140,7 +140,7 @@ BufferedImage::BufferedImage(const wstring& File, bool filenameHasExtension /*=f for( int l = 0 ; l < 10; l++ ) { - data[l] = NULL; + data[l] = nullptr; } for( int l = 0; l < 10; l++ ) @@ -193,12 +193,12 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const wstring& File, bool filenam { HRESULT hr; wstring filePath = File; - BYTE *pbData = NULL; + BYTE *pbData = nullptr; DWORD dwBytes = 0; for( int l = 0 ; l < 10; l++ ) { - data[l] = NULL; + data[l] = nullptr; } for( int l = 0; l < 10; l++ ) @@ -230,7 +230,7 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const wstring& File, bool filenam DLCFile *dlcFile = dlcPack->getFile(DLCManager::e_DLCType_All, name); pbData = dlcFile->getData(dwBytes); - if(pbData == NULL || dwBytes == 0) + if(pbData == nullptr || dwBytes == 0) { // 4J - If we haven't loaded the non-mipmap version then exit the game if( l == 0 ) @@ -269,7 +269,7 @@ BufferedImage::BufferedImage(BYTE *pbData, DWORD dwBytes) int iCurrentByte=0; for( int l = 0 ; l < 10; l++ ) { - data[l] = NULL; + data[l] = nullptr; } D3DXIMAGE_INFO ImageInfo; @@ -329,7 +329,7 @@ int *BufferedImage::getData(int level) Graphics *BufferedImage::getGraphics() { - return NULL; + return nullptr; } //Returns the transparency. Returns either OPAQUE, BITMASK, or TRANSLUCENT. @@ -359,7 +359,7 @@ BufferedImage *BufferedImage::getSubimage(int x ,int y, int w, int h) this->getRGB(x, y, w, h, arrayWrapper,0,w); int level = 1; - while(getData(level) != NULL) + while(getData(level) != nullptr) { int ww = w >> level; int hh = h >> level; diff --git a/Minecraft.Client/BufferedImage.h b/Minecraft.Client/BufferedImage.h index a0227fe29..3a08383fc 100644 --- a/Minecraft.Client/BufferedImage.h +++ b/Minecraft.Client/BufferedImage.h @@ -7,7 +7,7 @@ class DLCPack; class BufferedImage { private: - int *data[10]; // Arrays for mipmaps - NULL if not used + int *data[10]; // Arrays for mipmaps - nullptr if not used int width; int height; void ByteFlip4(unsigned int &data); // 4J added diff --git a/Minecraft.Client/ChatScreen.cpp b/Minecraft.Client/ChatScreen.cpp index b68e6cac0..21c223749 100644 --- a/Minecraft.Client/ChatScreen.cpp +++ b/Minecraft.Client/ChatScreen.cpp @@ -30,7 +30,7 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey) { if (eventKey == Keyboard::KEY_ESCAPE) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); return; } if (eventKey == Keyboard::KEY_RETURN) @@ -44,7 +44,7 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey) minecraft->player->chat(trim); } } - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); return; } if (eventKey == Keyboard::KEY_BACK && message.length() > 0) message = message.substr(0, message.length() - 1); @@ -67,7 +67,7 @@ void ChatScreen::mouseClicked(int x, int y, int buttonNum) { if (buttonNum == 0) { - if (minecraft->gui->selectedName != L"") // 4J - was NULL comparison + if (minecraft->gui->selectedName != L"") // 4J - was nullptr comparison { if (message.length() > 0 && message[message.length()-1]!=L' ') { diff --git a/Minecraft.Client/ChestRenderer.cpp b/Minecraft.Client/ChestRenderer.cpp index 5b59eb411..7d306f45d 100644 --- a/Minecraft.Client/ChestRenderer.cpp +++ b/Minecraft.Client/ChestRenderer.cpp @@ -52,7 +52,7 @@ void ChestRenderer::render(shared_ptr _chest, double x, double y, d Tile *tile = chest->getTile(); data = chest->getData(); - if (dynamic_cast(tile) != NULL && data == 0) + if (dynamic_cast(tile) != nullptr && data == 0) { static_cast(tile)->recalcLockDir(chest->getLevel(), chest->x, chest->y, chest->z); data = chest->getData(); @@ -60,11 +60,11 @@ void ChestRenderer::render(shared_ptr _chest, double x, double y, d chest->checkNeighbors(); } - if (chest->n.lock() != NULL || chest->w.lock() != NULL) return; + if (chest->n.lock() != nullptr || chest->w.lock() != nullptr) return; ChestModel *model; - if (chest->e.lock() != NULL || chest->s.lock() != NULL) + if (chest->e.lock() != nullptr || chest->s.lock() != nullptr) { model = largeChestModel; @@ -112,11 +112,11 @@ void ChestRenderer::render(shared_ptr _chest, double x, double y, d if (data == 4) rot = 90; if (data == 5) rot = -90; - if (data == 2 && chest->e.lock() != NULL) + if (data == 2 && chest->e.lock() != nullptr) { glTranslatef(1, 0, 0); } - if (data == 5 && chest->s.lock() != NULL) + if (data == 5 && chest->s.lock() != nullptr) { glTranslatef(0, 0, -1); } @@ -124,12 +124,12 @@ void ChestRenderer::render(shared_ptr _chest, double x, double y, d glTranslatef(-0.5f, -0.5f, -0.5f); float open = chest->oOpenness + (chest->openness - chest->oOpenness) * a; - if (chest->n.lock() != NULL) + if (chest->n.lock() != nullptr) { float open2 = chest->n.lock()->oOpenness + (chest->n.lock()->openness - chest->n.lock()->oOpenness) * a; if (open2 > open) open = open2; } - if (chest->w.lock() != NULL) + if (chest->w.lock() != nullptr) { float open2 = chest->w.lock()->oOpenness + (chest->w.lock()->openness - chest->w.lock()->oOpenness) * a; if (open2 > open) open = open2; diff --git a/Minecraft.Client/Chunk.cpp b/Minecraft.Client/Chunk.cpp index 58ee7f484..265f58701 100644 --- a/Minecraft.Client/Chunk.cpp +++ b/Minecraft.Client/Chunk.cpp @@ -173,7 +173,7 @@ void Chunk::makeCopyForRebuild(Chunk *source) this->ym = source->ym; this->zm = source->zm; this->bb = source->bb; - this->clipChunk = NULL; + this->clipChunk = nullptr; this->id = source->id; this->globalRenderableTileEntities = source->globalRenderableTileEntities; this->globalRenderableTileEntities_cs = source->globalRenderableTileEntities_cs; @@ -680,7 +680,7 @@ void Chunk::rebuild_SPU() // render chunk is 16 x 16 x 16. We wouldn't have to actually get all of it if the data was ordered differently, but currently // it is ordered by x then z then y so just getting a small range of y out of it would involve getting the whole thing into // the cache anyway. - ChunkRebuildData* pOutData = NULL; + ChunkRebuildData* pOutData = nullptr; g_rebuildDataIn.buildForChunk(®ion, level, x0, y0, z0); Tesselator::Bounds bounds; @@ -981,7 +981,7 @@ void Chunk::reset() void Chunk::_delete() { reset(); - level = NULL; + level = nullptr; } int Chunk::getList(int layer) diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index 9b9bb86a7..09a57759e 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -95,7 +95,7 @@ ClientConnection::ClientConnection(Minecraft *minecraft, const wstring& ip, int } else { - connection = NULL; + connection = nullptr; delete socket; } #endif @@ -106,9 +106,9 @@ ClientConnection::ClientConnection(Minecraft *minecraft, Socket *socket, int iUs // 4J - added initiliasers random = new Random(); done = false; - level = NULL; + level = nullptr; started = false; - savedDataStorage = new SavedDataStorage(NULL); + savedDataStorage = new SavedDataStorage(nullptr); maxPlayers = 20; this->minecraft = minecraft; @@ -122,7 +122,7 @@ ClientConnection::ClientConnection(Minecraft *minecraft, Socket *socket, int iUs m_userIndex = iUserIndex; } - if( socket == NULL ) + if( socket == nullptr ) { socket = new Socket(); // 4J - Local connection } @@ -134,7 +134,7 @@ ClientConnection::ClientConnection(Minecraft *minecraft, Socket *socket, int iUs } else { - connection = NULL; + connection = nullptr; // TODO 4J Stu - This will cause issues since the session player owns the socket //delete socket; } @@ -157,8 +157,8 @@ void ClientConnection::tick() INetworkPlayer *ClientConnection::getNetworkPlayer() { - if( connection != NULL && connection->getSocket() != NULL) return connection->getSocket()->getPlayer(); - else return NULL; + if( connection != nullptr && connection->getSocket() != nullptr) return connection->getSocket()->getPlayer(); + else return nullptr; } void ClientConnection::handleLogin(shared_ptr packet) @@ -167,7 +167,7 @@ void ClientConnection::handleLogin(shared_ptr packet) PlayerUID OnlineXuid; ProfileManager.GetXUID(m_userIndex,&OnlineXuid,true); // online xuid - MOJANG_DATA *pMojangData = NULL; + MOJANG_DATA *pMojangData = nullptr; if(!g_NetworkManager.IsLocalGame()) { @@ -208,7 +208,7 @@ void ClientConnection::handleLogin(shared_ptr packet) if(iUserID!=-1) { - BYTE *pBuffer=NULL; + BYTE *pBuffer=nullptr; DWORD dwSize=0; bool bRes; @@ -285,17 +285,17 @@ void ClientConnection::handleLogin(shared_ptr packet) Level *dimensionLevel = minecraft->getLevel( packet->dimension ); - if( dimensionLevel == NULL ) + if( dimensionLevel == nullptr ) { level = new MultiPlayerLevel(this, new LevelSettings(packet->seed, GameType::byId(packet->gameType), false, false, packet->m_newSeaLevel, packet->m_pLevelType, packet->m_xzSize, packet->m_hellScale), packet->dimension, packet->difficulty); // 4J Stu - We want to share the SavedDataStorage between levels int otherDimensionId = packet->dimension == 0 ? -1 : 0; Level *activeLevel = minecraft->getLevel(otherDimensionId); - if( activeLevel != NULL ) + if( activeLevel != nullptr ) { // Don't need to delete it here as it belongs to a client connection while will delete it when it's done - //if( level->savedDataStorage != NULL ) delete level->savedDataStorage; + //if( level->savedDataStorage != nullptr ) delete level->savedDataStorage; level->savedDataStorage = activeLevel->savedDataStorage; } @@ -341,12 +341,12 @@ void ClientConnection::handleLogin(shared_ptr packet) level = (MultiPlayerLevel *)minecraft->getLevel( packet->dimension ); shared_ptr player; - if(level==NULL) + if(level==nullptr) { int otherDimensionId = packet->dimension == 0 ? -1 : 0; MultiPlayerLevel *activeLevel = minecraft->getLevel(otherDimensionId); - if(activeLevel == NULL) + if(activeLevel == nullptr) { otherDimensionId = packet->dimension == 0 ? 1 : (packet->dimension == -1 ? 1 : -1); activeLevel = minecraft->getLevel(otherDimensionId); @@ -433,7 +433,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) shared_ptr owner = getEntity(packet->data); // 4J - check all local players to find match - if( owner == NULL ) + if( owner == nullptr ) { for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { @@ -449,7 +449,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) } } - if (owner != NULL && owner->instanceof(eTYPE_PLAYER)) + if (owner != nullptr && owner->instanceof(eTYPE_PLAYER)) { shared_ptr player = dynamic_pointer_cast(owner); shared_ptr hook = shared_ptr( new FishingHook(level, x, y, z, player) ); @@ -549,7 +549,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) shared_ptr owner = getEntity(packet->data); // 4J - check all local players to find match - if( owner == NULL ) + if( owner == nullptr ) { for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { @@ -565,7 +565,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) } } shared_ptr player = dynamic_pointer_cast(owner); - if (player != NULL) + if (player != nullptr) { shared_ptr hook = shared_ptr( new FishingHook(level, x, y, z, player) ); e = hook; @@ -609,7 +609,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) */ - if (e != NULL) + if (e != nullptr) { e->xp = packet->x; e->yp = packet->y; @@ -661,7 +661,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) shared_ptr owner = getEntity(packet->data); // 4J - check all local players to find match - if( owner == NULL ) + if( owner == nullptr ) { for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { @@ -676,7 +676,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) } } - if ( owner != NULL && owner->instanceof(eTYPE_LIVINGENTITY) ) + if ( owner != nullptr && owner->instanceof(eTYPE_LIVINGENTITY) ) { dynamic_pointer_cast(e)->owner = dynamic_pointer_cast(owner); } @@ -709,7 +709,7 @@ void ClientConnection::handleAddGlobalEntity(shared_ptr p double z = packet->z / 32.0; shared_ptr e;// = nullptr; if (packet->type == AddGlobalEntityPacket::LIGHTNING) e = shared_ptr( new LightningBolt(level, x, y, z) ); - if (e != NULL) + if (e != nullptr) { e->xp = packet->x; e->yp = packet->y; @@ -730,14 +730,14 @@ void ClientConnection::handleAddPainting(shared_ptr packet) void ClientConnection::handleSetEntityMotion(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; e->lerpMotion(packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); } void ClientConnection::handleSetEntityData(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e != NULL && packet->getUnpackedData() != NULL) + if (e != nullptr && packet->getUnpackedData() != nullptr) { e->getEntityData()->assignValues(packet->getUnpackedData()); } @@ -764,7 +764,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) // a duplicate remote player for a local slot by checking the username directly. for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if (minecraft->localplayers[idx] != NULL && minecraft->localplayers[idx]->name == packet->name) + if (minecraft->localplayers[idx] != nullptr && minecraft->localplayers[idx]->name == packet->name) { app.DebugPrintf("AddPlayerPacket received for local player name %ls\n", packet->name.c_str()); return; @@ -778,7 +778,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) // their stored server index rather than using it directly as an array subscript. for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(minecraft->localplayers[idx] != NULL && + if(minecraft->localplayers[idx] != nullptr && minecraft->localplayers[idx]->getPlayerIndex() == packet->m_playerIndex) { app.DebugPrintf("AddPlayerPacket received for local player (controller %d, server index %d), skipping RemotePlayer creation\n", idx, packet->m_playerIndex); @@ -804,7 +804,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) #ifdef _DURANGO // On Durango request player display name from network manager INetworkPlayer *networkPlayer = g_NetworkManager.GetPlayerByXuid(player->getXuid()); - if (networkPlayer != NULL) player->m_displayName = networkPlayer->GetDisplayName(); + if (networkPlayer != nullptr) player->m_displayName = networkPlayer->GetDisplayName(); #else // On all other platforms display name is just gamertag so don't check with the network manager player->m_displayName = player->getName(); @@ -812,7 +812,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) #ifdef _WINDOWS64 { - IQNetPlayer* matchedQNetPlayer = NULL; + IQNetPlayer* matchedQNetPlayer = nullptr; PlayerUID pktXuid = player->getXuid(); const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e; // Legacy compatibility path for peers still using embedded smallId XUIDs. @@ -820,7 +820,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) { BYTE smallId = (BYTE)(pktXuid - WIN64_XUID_BASE); INetworkPlayer* np = g_NetworkManager.GetPlayerBySmallId(smallId); - if (np != NULL) + if (np != nullptr) { NetworkPlayerXbox* npx = (NetworkPlayerXbox*)np; matchedQNetPlayer = npx->GetQNetPlayer(); @@ -828,17 +828,17 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) } // Current Win64 path: identify QNet player by name and attach packet XUID. - if (matchedQNetPlayer == NULL) + if (matchedQNetPlayer == nullptr) { for (BYTE smallId = 0; smallId < MINECRAFT_NET_MAX_PLAYERS; ++smallId) { INetworkPlayer* np = g_NetworkManager.GetPlayerBySmallId(smallId); - if (np == NULL) + if (np == nullptr) continue; NetworkPlayerXbox* npx = (NetworkPlayerXbox*)np; IQNetPlayer* qp = npx->GetQNetPlayer(); - if (qp != NULL && _wcsicmp(qp->m_gamertag, packet->name.c_str()) == 0) + if (qp != nullptr && _wcsicmp(qp->m_gamertag, packet->name.c_str()) == 0) { matchedQNetPlayer = qp; break; @@ -846,7 +846,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) } } - if (matchedQNetPlayer != NULL) + if (matchedQNetPlayer != nullptr) { // Store packet-authoritative XUID on this network slot so later lookups by XUID // (e.g. remove player, display mapping) work for both legacy and uid.dat clients. @@ -864,7 +864,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) int item = packet->carriedItem; if (item == 0) { - player->inventory->items[player->inventory->selected] = shared_ptr(); // NULL; + player->inventory->items[player->inventory->selected] = shared_ptr(); // nullptr; } else { @@ -883,13 +883,13 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) { app.DebugPrintf("Client sending TextureAndGeometryPacket to get custom skin %ls for player %ls\n",player->customTextureUrl.c_str(), player->name.c_str()); - send(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) ); + send(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,nullptr,0) ) ); } } else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl,NULL,0); + app.AddMemoryTextureFile(player->customTextureUrl,nullptr,0); } app.DebugPrintf("Custom skin for player %ls is %ls\n",player->name.c_str(),player->customTextureUrl.c_str()); @@ -899,13 +899,13 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) if( minecraft->addPendingClientTextureRequest(player->customTextureUrl2) ) { app.DebugPrintf("Client sending texture packet to get custom cape %ls for player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str()); - send(shared_ptr( new TexturePacket(player->customTextureUrl2,NULL,0) ) ); + send(shared_ptr( new TexturePacket(player->customTextureUrl2,nullptr,0) ) ); } } else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl2,NULL,0); + app.AddMemoryTextureFile(player->customTextureUrl2,nullptr,0); } app.DebugPrintf("Custom cape for player %ls is %ls\n",player->name.c_str(),player->customTextureUrl2.c_str()); @@ -913,7 +913,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) level->putEntity(packet->id, player); vector > *unpackedData = packet->getUnpackedData(); - if (unpackedData != NULL) + if (unpackedData != nullptr) { player->getEntityData()->assignValues(unpackedData); } @@ -923,7 +923,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) void ClientConnection::handleTeleportEntity(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; e->xp = packet->x; e->yp = packet->y; e->zp = packet->z; @@ -952,7 +952,7 @@ void ClientConnection::handleSetCarriedItem(shared_ptr pac void ClientConnection::handleMoveEntity(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; e->xp += packet->xa; e->yp += packet->ya; e->zp += packet->za; @@ -973,7 +973,7 @@ void ClientConnection::handleMoveEntity(shared_ptr packet) void ClientConnection::handleRotateMob(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; float yHeadRot = packet->yHeadRot * 360 / 256.f; e->setYHeadRot(yHeadRot); } @@ -981,7 +981,7 @@ void ClientConnection::handleRotateMob(shared_ptr packet) void ClientConnection::handleMoveEntitySmall(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; e->xp += packet->xa; e->yp += packet->ya; e->zp += packet->za; @@ -1007,18 +1007,18 @@ void ClientConnection::handleRemoveEntity(shared_ptr packe for (int i = 0; i < packet->ids.length; i++) { shared_ptr entity = getEntity(packet->ids[i]); - if (entity != NULL && entity->GetType() == eTYPE_PLAYER) + if (entity != nullptr && entity->GetType() == eTYPE_PLAYER) { shared_ptr player = dynamic_pointer_cast(entity); - if (player != NULL) + if (player != nullptr) { PlayerUID xuid = player->getXuid(); INetworkPlayer* np = g_NetworkManager.GetPlayerByXuid(xuid); - if (np != NULL) + if (np != nullptr) { NetworkPlayerXbox* npx = (NetworkPlayerXbox*)np; IQNetPlayer* qp = npx->GetQNetPlayer(); - if (qp != NULL) + if (qp != nullptr) { extern CPlatformNetworkManagerStub* g_pPlatformNetworkManager; g_pPlatformNetworkManager->NotifyPlayerLeaving(qp); @@ -1088,7 +1088,7 @@ void ClientConnection::handleMovePlayer(shared_ptr packet) player->zOld = player->z; started = true; - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // Fix for #105852 - TU12: Content: Gameplay: Local splitscreen Players are spawned at incorrect places after re-joining previously saved and loaded "Mass Effect World". // Move this check from Minecraft::createExtraLocalPlayer @@ -1298,7 +1298,7 @@ void ClientConnection::handleDisconnect(shared_ptr packet) app.SetDisconnectReason( packet->reason ); app.SetAction(m_userIndex,eAppAction_ExitWorld,(void *)TRUE); - //minecraft->setLevel(NULL); + //minecraft->setLevel(nullptr); //minecraft->setScreen(new DisconnectedScreen(L"disconnect.disconnected", L"disconnect.genericReason", &packet->reason)); } @@ -1321,14 +1321,14 @@ void ClientConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, { UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1, ProfileManager.GetPrimaryPad(),&ClientConnection::HostDisconnectReturned,NULL); + ui.RequestErrorMessage(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1, ProfileManager.GetPrimaryPad(),&ClientConnection::HostDisconnectReturned,nullptr); } else { app.SetAction(m_userIndex,eAppAction_ExitWorld,(void *)TRUE); } - //minecraft->setLevel(NULL); + //minecraft->setLevel(nullptr); //minecraft->setScreen(new DisconnectedScreen(L"disconnect.lost", reason, reasonObjects)); } @@ -1366,7 +1366,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr pac } } - if (to == NULL) + if (to == nullptr) { // Don't know if this should ever really happen, but seems safest to try and remove the entity that has been collected even if we can't // create a particle as we don't know what really collected it @@ -1374,7 +1374,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr pac return; } - if (from != NULL) + if (from != nullptr) { // If this is a local player, then we only want to do processing for it if this connection is associated with the player it is for. In // particular, we don't want to remove the item entity until we are processing it for the right connection, or else we won't have a valid @@ -1388,7 +1388,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr pac // the tutorial for the player that actually picked up the item int playerPad = player->GetXboxPad(); - if( minecraft->localgameModes[playerPad] != NULL ) + if( minecraft->localgameModes[playerPad] != nullptr ) { // 4J-PB - add in the XP orb sound if(from->GetType() == eTYPE_EXPERIENCEORB) @@ -1830,7 +1830,7 @@ void ClientConnection::handleChat(shared_ptr packet) void ClientConnection::handleAnimate(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; if (packet->action == AnimatePacket::SWING) { if (e->instanceof(eTYPE_LIVINGENTITY)) dynamic_pointer_cast(e)->swing(); @@ -1867,7 +1867,7 @@ void ClientConnection::handleAnimate(shared_ptr packet) void ClientConnection::handleEntityActionAtPosition(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; if (packet->action == EntityActionAtPositionPacket::START_SLEEP) { shared_ptr player = dynamic_pointer_cast(e); @@ -1927,7 +1927,7 @@ void ClientConnection::handlePreLogin(shared_ptr packet) // Is this user friends with the host player? BOOL result; DWORD error; - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[packet->m_hostIndex],1,&result,NULL); + error = XUserAreUsersFriends(idx,&packet->m_playerXuids[packet->m_hostIndex],1,&result,nullptr); if(error == ERROR_SUCCESS && result != TRUE) { canPlay = FALSE; @@ -1957,7 +1957,7 @@ void ClientConnection::handlePreLogin(shared_ptr packet) // Is this user friends with the host player? BOOL result; DWORD error; - error = XUserAreUsersFriends(m_userIndex,&packet->m_playerXuids[packet->m_hostIndex],1,&result,NULL); + error = XUserAreUsersFriends(m_userIndex,&packet->m_playerXuids[packet->m_hostIndex],1,&result,nullptr); if(error == ERROR_SUCCESS && result != TRUE) { canPlay = FALSE; @@ -2009,7 +2009,7 @@ void ClientConnection::handlePreLogin(shared_ptr packet) { if( ProfileManager.IsSignedIn(idx) && !ProfileManager.IsGuest(idx) ) { - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,NULL); + error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,nullptr); if(error == ERROR_SUCCESS && result == TRUE) isAtLeastOneFriend = TRUE; } } @@ -2037,7 +2037,7 @@ void ClientConnection::handlePreLogin(shared_ptr packet) { if( (!thisQuadrantOnly || m_userIndex == idx) && ProfileManager.IsSignedIn(idx) && !ProfileManager.IsGuest(idx) ) { - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,NULL); + error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,nullptr); if(error == ERROR_SUCCESS) canPlay &= result; } if(!canPlay) break; @@ -2060,7 +2060,7 @@ void ClientConnection::handlePreLogin(shared_ptr packet) { bool bChatRestricted=false; - ProfileManager.GetChatAndContentRestrictions(m_userIndex,true,&bChatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(m_userIndex,true,&bChatRestricted,nullptr,nullptr); // Chat restricted orbis players can still play online #ifndef __ORBIS__ @@ -2149,11 +2149,11 @@ void ClientConnection::handlePreLogin(shared_ptr packet) // which seems to be very unstable at the point of starting up the game if(m_userIndex == ProfileManager.GetPrimaryPad()) { - ProfileManager.GetChatAndContentRestrictions(m_userIndex,false,&bChatRestricted,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(m_userIndex,false,&bChatRestricted,&bContentRestricted,nullptr); } else { - ProfileManager.GetChatAndContentRestrictions(m_userIndex,true,&bChatRestricted,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(m_userIndex,true,&bChatRestricted,&bContentRestricted,nullptr); } // Chat restricted orbis players can still play online @@ -2404,7 +2404,7 @@ void ClientConnection::handleAddMob(shared_ptr packet) level->putEntity(packet->id, mob); vector > *unpackedData = packet->getUnpackedData(); - if (unpackedData != NULL) + if (unpackedData != nullptr) { mob->getEntityData()->assignValues(unpackedData); } @@ -2439,10 +2439,10 @@ void ClientConnection::handleEntityLinkPacket(shared_ptr pa // 4J: If the destination entity couldn't be found, defer handling of this packet // This was added to support leashing (the entity link packet is sent before the add entity packet) - if (destEntity == NULL && packet->destId >= 0) + if (destEntity == nullptr && packet->destId >= 0) { // We don't handle missing source entities because it shouldn't happen - assert(!(sourceEntity == NULL && packet->sourceId >= 0)); + assert(!(sourceEntity == nullptr && packet->sourceId >= 0)); deferredEntityLinkPackets.push_back(DeferredEntityLinkPacket(packet)); return; @@ -2455,16 +2455,16 @@ void ClientConnection::handleEntityLinkPacket(shared_ptr pa { sourceEntity = Minecraft::GetInstance()->localplayers[m_userIndex]; - if (destEntity != NULL && destEntity->instanceof(eTYPE_BOAT)) (dynamic_pointer_cast(destEntity))->setDoLerp(false); + if (destEntity != nullptr && destEntity->instanceof(eTYPE_BOAT)) (dynamic_pointer_cast(destEntity))->setDoLerp(false); - displayMountMessage = (sourceEntity->riding == NULL && destEntity != NULL); + displayMountMessage = (sourceEntity->riding == nullptr && destEntity != nullptr); } - else if (destEntity != NULL && destEntity->instanceof(eTYPE_BOAT)) + else if (destEntity != nullptr && destEntity->instanceof(eTYPE_BOAT)) { (dynamic_pointer_cast(destEntity))->setDoLerp(true); } - if (sourceEntity == NULL) return; + if (sourceEntity == nullptr) return; sourceEntity->ride(destEntity); @@ -2478,9 +2478,9 @@ void ClientConnection::handleEntityLinkPacket(shared_ptr pa } else if (packet->type == SetEntityLinkPacket::LEASH) { - if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_MOB) ) + if ( (sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_MOB) ) { - if (destEntity != NULL) + if (destEntity != nullptr) { (dynamic_pointer_cast(sourceEntity))->setLeashedTo(destEntity, false); @@ -2496,7 +2496,7 @@ void ClientConnection::handleEntityLinkPacket(shared_ptr pa void ClientConnection::handleEntityEvent(shared_ptr packet) { shared_ptr e = getEntity(packet->entityId); - if (e != NULL) e->handleEntityEvent(packet->eventId); + if (e != nullptr) e->handleEntityEvent(packet->eventId); } shared_ptr ClientConnection::getEntity(int entityId) @@ -2520,7 +2520,7 @@ void ClientConnection::handleSetHealth(shared_ptr packet) // We need food if(packet->food < FoodConstants::HEAL_LEVEL - 1) { - if(minecraft->localgameModes[m_userIndex] != NULL && !minecraft->localgameModes[m_userIndex]->hasInfiniteItems() ) + if(minecraft->localgameModes[m_userIndex] != nullptr && !minecraft->localgameModes[m_userIndex]->hasInfiniteItems() ) { minecraft->localgameModes[m_userIndex]->getTutorial()->changeTutorialState(e_Tutorial_State_Food_Bar); } @@ -2544,7 +2544,7 @@ void ClientConnection::handleTexture(shared_ptr packet) #ifndef _CONTENT_PACKAGE wprintf(L"Client received request for custom texture %ls\n",packet->textureName.c_str()); #endif - PBYTE pbData=NULL; + PBYTE pbData=nullptr; DWORD dwBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwBytes); @@ -2576,7 +2576,7 @@ void ClientConnection::handleTextureAndGeometry(shared_ptrtextureName.c_str()); #endif - PBYTE pbData=NULL; + PBYTE pbData=nullptr; DWORD dwBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwBytes); DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(packet->textureName); @@ -2626,7 +2626,7 @@ void ClientConnection::handleTextureAndGeometry(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if ( (e == NULL) || !e->instanceof(eTYPE_PLAYER) ) return; + if ( (e == nullptr) || !e->instanceof(eTYPE_PLAYER) ) return; shared_ptr player = dynamic_pointer_cast(e); bool isLocalPlayer = false; @@ -2667,22 +2667,22 @@ void ClientConnection::handleTextureChange(shared_ptr packe #ifndef _CONTENT_PACKAGE wprintf(L"handleTextureChange - Client sending texture packet to get custom skin %ls for player %ls\n",packet->path.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TexturePacket(packet->path,NULL,0) ) ); + send(shared_ptr( new TexturePacket(packet->path,nullptr,0) ) ); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path,NULL,0); + app.AddMemoryTextureFile(packet->path,nullptr,0); } } void ClientConnection::handleTextureAndGeometryChange(shared_ptr packet) { shared_ptr e = getEntity(packet->id); - if (e == NULL) return; + if (e == nullptr) return; shared_ptr player = dynamic_pointer_cast(e); - if( e == NULL) return; + if( e == nullptr) return; bool isLocalPlayer = false; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) @@ -2712,13 +2712,13 @@ void ClientConnection::handleTextureAndGeometryChange(shared_ptrpath.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TextureAndGeometryPacket(packet->path,NULL,0) ) ); + send(shared_ptr( new TextureAndGeometryPacket(packet->path,nullptr,0) ) ); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path,NULL,0); + app.AddMemoryTextureFile(packet->path,nullptr,0); } } @@ -2739,12 +2739,12 @@ void ClientConnection::handleRespawn(shared_ptr packet) level->removeClientConnection(this, false); MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->getLevel( packet->dimension ); - if( dimensionLevel == NULL ) + if( dimensionLevel == nullptr ) { dimensionLevel = new MultiPlayerLevel(this, new LevelSettings(packet->mapSeed, packet->playerGameType, false, minecraft->level->getLevelData()->isHardcore(), packet->m_newSeaLevel, packet->m_pLevelType, packet->m_xzSize, packet->m_hellScale), packet->dimension, packet->difficulty); // 4J Stu - We want to shared the savedDataStorage between both levels - //if( dimensionLevel->savedDataStorage != NULL ) + //if( dimensionLevel->savedDataStorage != nullptr ) //{ // Don't need to delete it here as it belongs to a client connection while will delete it when it's done // delete dimensionLevel->savedDataStorage;+ @@ -2784,7 +2784,7 @@ void ClientConnection::handleRespawn(shared_ptr packet) TelemetryManager->RecordLevelStart(m_userIndex, eSen_FriendOrMatch_Playing_With_Invited_Friends, eSen_CompeteOrCoop_Coop_and_Competitive, Minecraft::GetInstance()->getLevel(packet->dimension)->difficulty, app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount()); #endif - if( minecraft->localgameModes[m_userIndex] != NULL ) + if( minecraft->localgameModes[m_userIndex] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_userIndex]; gameMode->getTutorial()->showTutorialPopup(false); @@ -3111,9 +3111,9 @@ void ClientConnection::handleContainerSetSlot(shared_ptr if(packet->slot >= 36 && packet->slot < 36 + 9) { shared_ptr lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem(); - if (packet->item != NULL) + if (packet->item != nullptr) { - if (lastItem == NULL || lastItem->count < packet->item->count) + if (lastItem == nullptr || lastItem->count < packet->item->count) { packet->item->popTime = Inventory::POP_TIME_DURATION; } @@ -3131,7 +3131,7 @@ void ClientConnection::handleContainerSetSlot(shared_ptr void ClientConnection::handleContainerAck(shared_ptr packet) { shared_ptr player = minecraft->localplayers[m_userIndex]; - AbstractContainerMenu *menu = NULL; + AbstractContainerMenu *menu = nullptr; if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_INVENTORY) { menu = player->inventoryMenu; @@ -3140,7 +3140,7 @@ void ClientConnection::handleContainerAck(shared_ptr packet) { menu = player->containerMenu; } - if (menu != NULL) + if (menu != nullptr) { if (!packet->accepted) { @@ -3165,7 +3165,7 @@ void ClientConnection::handleContainerContent(shared_ptr packet) { shared_ptr tileEntity = level->getTileEntity(packet->x, packet->y, packet->z); - if (tileEntity != NULL) + if (tileEntity != nullptr) { minecraft->localplayers[m_userIndex]->openTextEdit(tileEntity); } @@ -3188,7 +3188,7 @@ void ClientConnection::handleSignUpdate(shared_ptr packet) shared_ptr te = minecraft->level->getTileEntity(packet->x, packet->y, packet->z); // 4J-PB - on a client connecting, the line below fails - if (dynamic_pointer_cast(te) != NULL) + if (dynamic_pointer_cast(te) != nullptr) { shared_ptr ste = dynamic_pointer_cast(te); for (int i = 0; i < MAX_SIGN_LINES; i++) @@ -3204,7 +3204,7 @@ void ClientConnection::handleSignUpdate(shared_ptr packet) } else { - app.DebugPrintf("dynamic_pointer_cast(te) == NULL\n"); + app.DebugPrintf("dynamic_pointer_cast(te) == nullptr\n"); } } else @@ -3219,21 +3219,21 @@ void ClientConnection::handleTileEntityData(shared_ptr pac { shared_ptr te = minecraft->level->getTileEntity(packet->x, packet->y, packet->z); - if (te != NULL) + if (te != nullptr) { - if (packet->type == TileEntityDataPacket::TYPE_MOB_SPAWNER && dynamic_pointer_cast(te) != NULL) + if (packet->type == TileEntityDataPacket::TYPE_MOB_SPAWNER && dynamic_pointer_cast(te) != nullptr) { dynamic_pointer_cast(te)->load(packet->tag); } - else if (packet->type == TileEntityDataPacket::TYPE_ADV_COMMAND && dynamic_pointer_cast(te) != NULL) + else if (packet->type == TileEntityDataPacket::TYPE_ADV_COMMAND && dynamic_pointer_cast(te) != nullptr) { dynamic_pointer_cast(te)->load(packet->tag); } - else if (packet->type == TileEntityDataPacket::TYPE_BEACON && dynamic_pointer_cast(te) != NULL) + else if (packet->type == TileEntityDataPacket::TYPE_BEACON && dynamic_pointer_cast(te) != nullptr) { dynamic_pointer_cast(te)->load(packet->tag); } - else if (packet->type == TileEntityDataPacket::TYPE_SKULL && dynamic_pointer_cast(te) != NULL) + else if (packet->type == TileEntityDataPacket::TYPE_SKULL && dynamic_pointer_cast(te) != nullptr) { dynamic_pointer_cast(te)->load(packet->tag); } @@ -3244,7 +3244,7 @@ void ClientConnection::handleTileEntityData(shared_ptr pac void ClientConnection::handleContainerSetData(shared_ptr packet) { onUnhandledPacket(packet); - if (minecraft->localplayers[m_userIndex]->containerMenu != NULL && minecraft->localplayers[m_userIndex]->containerMenu->containerId == packet->containerId) + if (minecraft->localplayers[m_userIndex]->containerMenu != nullptr && minecraft->localplayers[m_userIndex]->containerMenu->containerId == packet->containerId) { minecraft->localplayers[m_userIndex]->containerMenu->setData(packet->id, packet->value); } @@ -3253,7 +3253,7 @@ void ClientConnection::handleContainerSetData(shared_ptr void ClientConnection::handleSetEquippedItem(shared_ptr packet) { shared_ptr entity = getEntity(packet->entity); - if (entity != NULL) + if (entity != nullptr) { // 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game entity->setEquippedSlot(packet->slot, packet->getItem() ); @@ -3279,7 +3279,7 @@ void ClientConnection::handleTileDestruction(shared_ptr p bool ClientConnection::canHandleAsyncPackets() { - return minecraft != NULL && minecraft->level != NULL && minecraft->localplayers[m_userIndex] != NULL && level != NULL; + return minecraft != nullptr && minecraft->level != nullptr && minecraft->localplayers[m_userIndex] != nullptr && level != nullptr; } void ClientConnection::handleGameEvent(shared_ptr gameEventPacket) @@ -3288,7 +3288,7 @@ void ClientConnection::handleGameEvent(shared_ptr gameEventPack int param = gameEventPacket->param; if (event >= 0 && event < GameEventPacket::EVENT_LANGUAGE_ID_LENGTH) { - if (GameEventPacket::EVENT_LANGUAGE_ID[event] > 0) // 4J - was NULL check + if (GameEventPacket::EVENT_LANGUAGE_ID[event] > 0) // 4J - was nullptr check { minecraft->localplayers[m_userIndex]->displayClientMessage(GameEventPacket::EVENT_LANGUAGE_ID[event]); } @@ -3320,7 +3320,7 @@ void ClientConnection::handleGameEvent(shared_ptr gameEventPack ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), false); // This just allows it to be shown - if(minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) minecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); + if(minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) minecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); // Temporarily make this scene fullscreen CXuiSceneBase::SetPlayerBaseScenePosition( ProfileManager.GetPrimaryPad(), CXuiSceneBase::e_BaseScene_Fullscreen ); @@ -3328,8 +3328,8 @@ void ClientConnection::handleGameEvent(shared_ptr gameEventPack #else app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", m_userIndex); // This just allows it to be shown - if(minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) minecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_EndPoem, NULL, eUILayer_Scene, eUIGroup_Fullscreen); + if(minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) minecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_EndPoem, nullptr, eUILayer_Scene, eUIGroup_Fullscreen); #endif } else if( event == GameEventPacket::START_SAVING ) @@ -3373,7 +3373,7 @@ void ClientConnection::handleLevelEvent(shared_ptr packet) { for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if(minecraft->localplayers[i] != NULL && minecraft->localplayers[i]->level != NULL && minecraft->localplayers[i]->level->dimension->id == 1) + if(minecraft->localplayers[i] != nullptr && minecraft->localplayers[i]->level != nullptr && minecraft->localplayers[i]->level->dimension->id == 1) { minecraft->localplayers[i]->awardStat(GenericStats::completeTheEnd(),GenericStats::param_noArgs()); } @@ -3400,7 +3400,7 @@ void ClientConnection::handleAwardStat(shared_ptr packet) void ClientConnection::handleUpdateMobEffect(shared_ptr packet) { shared_ptr e = getEntity(packet->entityId); - if ( (e == NULL) || !e->instanceof(eTYPE_LIVINGENTITY) ) return; + if ( (e == nullptr) || !e->instanceof(eTYPE_LIVINGENTITY) ) return; //( dynamic_pointer_cast(e) )->addEffect(new MobEffectInstance(packet->effectId, packet->effectDurationTicks, packet->effectAmplifier)); @@ -3412,7 +3412,7 @@ void ClientConnection::handleUpdateMobEffect(shared_ptr p void ClientConnection::handleRemoveMobEffect(shared_ptr packet) { shared_ptr e = getEntity(packet->entityId); - if ( (e == NULL) || !e->instanceof(eTYPE_LIVINGENTITY) ) return; + if ( (e == nullptr) || !e->instanceof(eTYPE_LIVINGENTITY) ) return; ( dynamic_pointer_cast(e) )->removeEffectNoUpdate(packet->effectId); } @@ -3428,7 +3428,7 @@ void ClientConnection::handlePlayerInfo(shared_ptr packet) INetworkPlayer *networkPlayer = g_NetworkManager.GetPlayerBySmallId(packet->m_networkSmallId); - if(networkPlayer != NULL && networkPlayer->IsHost()) + if(networkPlayer != nullptr && networkPlayer->IsHost()) { // Some settings should always be considered on for the host player Player::enableAllPlayerPrivileges(startingPrivileges,true); @@ -3439,17 +3439,17 @@ void ClientConnection::handlePlayerInfo(shared_ptr packet) app.UpdatePlayerInfo(packet->m_networkSmallId, packet->m_playerColourIndex, packet->m_playerPrivileges); shared_ptr entity = getEntity(packet->m_entityId); - if(entity != NULL && entity->instanceof(eTYPE_PLAYER)) + if(entity != nullptr && entity->instanceof(eTYPE_PLAYER)) { shared_ptr player = dynamic_pointer_cast(entity); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All, packet->m_playerPrivileges); } - if(networkPlayer != NULL && networkPlayer->IsLocal()) + if(networkPlayer != nullptr && networkPlayer->IsLocal()) { for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { shared_ptr localPlayer = minecraft->localplayers[i]; - if(localPlayer != NULL && localPlayer->connection != NULL && localPlayer->connection->getNetworkPlayer() == networkPlayer ) + if(localPlayer != nullptr && localPlayer->connection != nullptr && localPlayer->connection->getNetworkPlayer() == networkPlayer ) { localPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All,packet->m_playerPrivileges); displayPrivilegeChanges(localPlayer,startingPrivileges); @@ -3647,7 +3647,7 @@ void ClientConnection::handleServerSettingsChanged(shared_ptrlevels.length; ++i) { - if( minecraft->levels[i] != NULL ) + if( minecraft->levels[i] != nullptr ) { app.DebugPrintf("ClientConnection::handleServerSettingsChanged - Difficulty = %d",packet->data); minecraft->levels[i]->difficulty = packet->data; @@ -3681,11 +3681,11 @@ void ClientConnection::handleUpdateProgress(shared_ptr pac void ClientConnection::handleUpdateGameRuleProgressPacket(shared_ptr packet) { LPCWSTR string = app.GetGameRulesString(packet->m_messageId); - if(string != NULL) + if(string != nullptr) { wstring message(string); message = GameRuleDefinition::generateDescriptionString(packet->m_definitionType,message,packet->m_data.data,packet->m_data.length); - if(minecraft->localgameModes[m_userIndex]!=NULL) + if(minecraft->localgameModes[m_userIndex]!=nullptr) { minecraft->localgameModes[m_userIndex]->getTutorial()->setMessage(message, packet->m_icon, packet->m_auxValue); } @@ -3731,7 +3731,7 @@ int ClientConnection::HostDisconnectReturned(void *pParam,int iPad,C4JStorage::E UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,NULL); + ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,nullptr); } else #else @@ -3746,7 +3746,7 @@ int ClientConnection::HostDisconnectReturned(void *pParam,int iPad,C4JStorage::E UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,NULL); + ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,nullptr); } else #endif @@ -3924,7 +3924,7 @@ void ClientConnection::handleParticleEvent(shared_ptr pack void ClientConnection::handleUpdateAttributes(shared_ptr packet) { shared_ptr entity = getEntity(packet->getEntityId()); - if (entity == NULL) return; + if (entity == nullptr) return; if ( !entity->instanceof(eTYPE_LIVINGENTITY) ) { diff --git a/Minecraft.Client/ClockTexture.cpp b/Minecraft.Client/ClockTexture.cpp index 37efc1839..5febeff34 100644 --- a/Minecraft.Client/ClockTexture.cpp +++ b/Minecraft.Client/ClockTexture.cpp @@ -10,7 +10,7 @@ ClockTexture::ClockTexture() : StitchedTexture(L"clock", L"clock") { rot = rota = 0.0; - m_dataTexture = NULL; + m_dataTexture = nullptr; m_iPad = XUSER_INDEX_ANY; } @@ -27,7 +27,7 @@ void ClockTexture::cycleFrames() Minecraft *mc = Minecraft::GetInstance(); double rott = 0; - if (m_iPad >= 0 && m_iPad < XUSER_MAX_COUNT && mc->level != NULL && mc->localplayers[m_iPad] != NULL) + if (m_iPad >= 0 && m_iPad < XUSER_MAX_COUNT && mc->level != nullptr && mc->localplayers[m_iPad] != nullptr) { float time = mc->localplayers[m_iPad]->level->getTimeOfDay(1); rott = time; @@ -55,7 +55,7 @@ void ClockTexture::cycleFrames() rot += rota; // 4J Stu - We share data with another texture - if(m_dataTexture != NULL) + if(m_dataTexture != nullptr) { int newFrame = static_cast((rot + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); while (newFrame < 0) @@ -95,7 +95,7 @@ int ClockTexture::getSourceHeight() const int ClockTexture::getFrames() { - if(m_dataTexture == NULL) + if(m_dataTexture == nullptr) { return StitchedTexture::getFrames(); } @@ -107,7 +107,7 @@ int ClockTexture::getFrames() void ClockTexture::freeFrameTextures() { - if(m_dataTexture == NULL) + if(m_dataTexture == nullptr) { StitchedTexture::freeFrameTextures(); } @@ -115,5 +115,5 @@ void ClockTexture::freeFrameTextures() bool ClockTexture::hasOwnData() { - return m_dataTexture == NULL; + return m_dataTexture == nullptr; } \ No newline at end of file diff --git a/Minecraft.Client/Common/Audio/SoundEngine.cpp b/Minecraft.Client/Common/Audio/SoundEngine.cpp index b2ca2be33..7aec7b7c4 100644 --- a/Minecraft.Client/Common/Audio/SoundEngine.cpp +++ b/Minecraft.Client/Common/Audio/SoundEngine.cpp @@ -57,7 +57,7 @@ void SoundEngine::updateSoundEffectVolume(float fVal) {} void SoundEngine::add(const wstring& name, File *file) {} void SoundEngine::addMusic(const wstring& name, File *file) {} void SoundEngine::addStreaming(const wstring& name, File *file) {} -char *SoundEngine::ConvertSoundPathToName(const wstring& name, bool bConvertSpaces) { return NULL; } +char *SoundEngine::ConvertSoundPathToName(const wstring& name, bool bConvertSpaces) { return nullptr; } bool SoundEngine::isStreamingWavebankReady() { return true; } void SoundEngine::playMusicTick() {}; @@ -335,7 +335,7 @@ void SoundEngine::tick(shared_ptr *players, float a) bool bListenerPostionSet = false; for( size_t i = 0; i < MAX_LOCAL_PLAYERS; i++ ) { - if( players[i] != NULL ) + if( players[i] != nullptr ) { m_ListenerA[i].bValid=true; F32 x,y,z; @@ -402,7 +402,7 @@ SoundEngine::SoundEngine() m_iMusicDelay=0; m_validListenerCount=0; - m_bHeardTrackA=NULL; + m_bHeardTrackA=nullptr; // Start the streaming music playing some music from the overworld SetStreamingSounds(eStream_Overworld_Calm1,eStream_Overworld_piano3, @@ -551,8 +551,8 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume, floa &m_engine, finalPath, MA_SOUND_FLAG_ASYNC, - NULL, - NULL, + nullptr, + nullptr, &s->sound) != MA_SUCCESS) { app.DebugPrintf("Failed to initialize sound from file: %s\n", finalPath); @@ -635,8 +635,8 @@ void SoundEngine::playUI(int iSound, float volume, float pitch) &m_engine, finalPath, MA_SOUND_FLAG_ASYNC, - NULL, - NULL, + nullptr, + nullptr, &s->sound) != MA_SUCCESS) { delete s; @@ -703,7 +703,7 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y , float z, for(unsigned int i=0;ilocalplayers[i]!=NULL) + if(pMinecraft->localplayers[i]!=nullptr) { if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_END) { @@ -797,7 +797,7 @@ int SoundEngine::getMusicID(int iDomain) Minecraft *pMinecraft=Minecraft::GetInstance(); // Before the game has started? - if(pMinecraft==NULL) + if(pMinecraft==nullptr) { // any track from the overworld return GetRandomishTrack(m_iStream_Overworld_Min,m_iStream_Overworld_Max); @@ -930,8 +930,8 @@ int SoundEngine::OpenStreamThreadProc(void* lpParameter) &soundEngine->m_engine, soundEngine->m_szStreamName, MA_SOUND_FLAG_STREAM, - NULL, - NULL, + nullptr, + nullptr, &soundEngine->m_musicStream); if (result != MA_SUCCESS) @@ -1189,7 +1189,7 @@ void SoundEngine::playMusicUpdate() if( !m_openStreamThread->isRunning() ) { delete m_openStreamThread; - m_openStreamThread = NULL; + m_openStreamThread = nullptr; app.DebugPrintf("OpenStreamThreadProc finished. m_musicStreamActive=%d\n", m_musicStreamActive); @@ -1246,7 +1246,7 @@ void SoundEngine::playMusicUpdate() if( !m_openStreamThread->isRunning() ) { delete m_openStreamThread; - m_openStreamThread = NULL; + m_openStreamThread = nullptr; m_StreamState = eMusicStreamState_Stop; } break; @@ -1282,14 +1282,14 @@ void SoundEngine::playMusicUpdate() } if(GetIsPlayingStreamingGameMusic()) { - //if(m_MusicInfo.pCue!=NULL) + //if(m_MusicInfo.pCue!=nullptr) { bool playerInEnd = false; bool playerInNether=false; Minecraft *pMinecraft = Minecraft::GetInstance(); for(unsigned int i = 0; i < MAX_LOCAL_PLAYERS; ++i) { - if(pMinecraft->localplayers[i]!=NULL) + if(pMinecraft->localplayers[i]!=nullptr) { if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_END) { @@ -1420,7 +1420,7 @@ void SoundEngine::playMusicUpdate() for(unsigned int i=0;ilocalplayers[i]!=NULL) + if(pMinecraft->localplayers[i]!=nullptr) { if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_END) { diff --git a/Minecraft.Client/Common/Audio/miniaudio.h b/Minecraft.Client/Common/Audio/miniaudio.h index 24e676bb2..f5997a42b 100644 --- a/Minecraft.Client/Common/Audio/miniaudio.h +++ b/Minecraft.Client/Common/Audio/miniaudio.h @@ -74,7 +74,7 @@ device on the stack, but you could allocate it on the heap if that suits your si config.pUserData = pMyCustomData; // Can be accessed from the device object (device.pUserData). ma_device device; - if (ma_device_init(NULL, &config, &device) != MA_SUCCESS) { + if (ma_device_init(nullptr, &config, &device) != MA_SUCCESS) { return -1; // Failed to initialize the device. } @@ -168,7 +168,7 @@ same for capture. All you need to do is change the device type from `ma_device_t ``` In the data callback you just read from the input buffer (`pInput` in the example above) and leave -the output buffer alone (it will be set to NULL when the device type is set to +the output buffer alone (it will be set to nullptr when the device type is set to `ma_device_type_capture`). These are the available device types and how you should handle the buffers in the callback: @@ -208,7 +208,7 @@ enumerating devices. The example below shows how to enumerate devices. ```c ma_context context; - if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) { + if (ma_context_init(nullptr, 0, nullptr, &context) != MA_SUCCESS) { // Error. } @@ -247,10 +247,10 @@ enumerating devices. The example below shows how to enumerate devices. The first thing we do in this example is initialize a `ma_context` object with `ma_context_init()`. The first parameter is a pointer to a list of `ma_backend` values which are used to override the -default backend priorities. When this is NULL, as in this example, miniaudio's default priorities +default backend priorities. When this is nullptr, as in this example, miniaudio's default priorities are used. The second parameter is the number of backends listed in the array pointed to by the first parameter. The third parameter is a pointer to a `ma_context_config` object which can be -NULL, in which case defaults are used. The context configuration is used for setting the logging +nullptr, in which case defaults are used. The context configuration is used for setting the logging callback, custom memory allocation callbacks, user-defined data and some backend-specific configurations. @@ -267,7 +267,7 @@ config. It also contains the name of the device which is useful for presenting a to the user via the UI. When creating your own context you will want to pass it to `ma_device_init()` when initializing the -device. Passing in NULL, like we do in the first example, will result in miniaudio creating the +device. Passing in nullptr, like we do in the first example, will result in miniaudio creating the context for you, which you don't want to do since you've already created a context. Note that internally the context is only tracked by it's pointer which means you must not change the location of the `ma_context` object. If this is an issue, consider using `malloc()` to allocate memory for @@ -301,7 +301,7 @@ The code below shows how you can initialize an engine using its default configur ma_result result; ma_engine engine; - result = ma_engine_init(NULL, &engine); + result = ma_engine_init(nullptr, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } @@ -352,7 +352,7 @@ By default the engine will be started, but nothing will be playing because no so initialized. The easiest but least flexible way of playing a sound is like so: ```c - ma_engine_play_sound(&engine, "my_sound.wav", NULL); + ma_engine_play_sound(&engine, "my_sound.wav", nullptr); ``` This plays what miniaudio calls an "inline" sound. It plays the sound once, and then puts the @@ -365,7 +365,7 @@ initialize a sound: ma_result result; ma_sound sound; - result = ma_sound_init_from_file(&engine, "my_sound.wav", 0, NULL, NULL, &sound); + result = ma_sound_init_from_file(&engine, "my_sound.wav", 0, nullptr, nullptr, &sound); if (result != MA_SUCCESS) { return result; } @@ -789,7 +789,7 @@ To read data from a data source: } ``` -If you don't need the number of frames that were successfully read you can pass in `NULL` to the +If you don't need the number of frames that were successfully read you can pass in `nullptr` to the `pFramesRead` parameter. If this returns a value less than the number of frames requested it means the end of the file has been reached. `MA_AT_END` will be returned only when the number of frames read is 0. @@ -809,7 +809,7 @@ you could plug in a decoder like so: } ``` -If you want to seek forward you can pass in `NULL` to the `pFramesOut` parameter. Alternatively you +If you want to seek forward you can pass in `nullptr` to the `pFramesOut` parameter. Alternatively you can use `ma_data_source_seek_pcm_frames()`. To seek to a specific PCM frame: @@ -864,7 +864,7 @@ retrieved like so: } ``` -If you do not need a specific data format property, just pass in NULL to the respective parameter. +If you do not need a specific data format property, just pass in nullptr to the respective parameter. There may be cases where you want to implement something like a sound bank where you only want to read data within a certain range of the underlying data. To do this you can use a range: @@ -1041,7 +1041,7 @@ The most basic way to initialize the engine is with a default config, like so: ma_result result; ma_engine engine; - result = ma_engine_init(NULL, &engine); + result = ma_engine_init(nullptr, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } @@ -1072,7 +1072,7 @@ control of the device's data callback, it's their responsibility to manually cal ```c void playback_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) { - ma_engine_read_pcm_frames(&g_Engine, pOutput, frameCount, NULL); + ma_engine_read_pcm_frames(&g_Engine, pOutput, frameCount, nullptr); } ``` @@ -1200,7 +1200,7 @@ you'll want to initialize a sound object: ```c ma_sound sound; - result = ma_sound_init_from_file(&engine, "my_sound.wav", flags, pGroup, NULL, &sound); + result = ma_sound_init_from_file(&engine, "my_sound.wav", flags, pGroup, nullptr, &sound); if (result != MA_SUCCESS) { return result; // Failed to load sound. } @@ -1232,8 +1232,8 @@ standard config/init pattern: ma_sound_config soundConfig; soundConfig = ma_sound_config_init(); - soundConfig.pFilePath = NULL; // Set this to load from a file path. - soundConfig.pDataSource = NULL; // Set this to initialize from an existing data source. + soundConfig.pFilePath = nullptr; // Set this to load from a file path. + soundConfig.pDataSource = nullptr; // Set this to initialize from an existing data source. soundConfig.pInitialAttachment = &someNodeInTheNodeGraph; soundConfig.initialAttachmentInputBusIndex = 0; soundConfig.channelsIn = 1; @@ -1258,7 +1258,7 @@ will be decoded dynamically on the fly. In order to save processing time on the might be beneficial to pre-decode the sound. You can do this with the `MA_SOUND_FLAG_DECODE` flag: ```c - ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE, pGroup, NULL, &sound); + ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE, pGroup, nullptr, &sound); ``` By default, sounds will be loaded synchronously, meaning `ma_sound_init_*()` will not return until @@ -1266,7 +1266,7 @@ the sound has been fully loaded. If this is prohibitive you can instead load sou by specifying the `MA_SOUND_FLAG_ASYNC` flag: ```c - ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_ASYNC, pGroup, NULL, &sound); + ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_ASYNC, pGroup, nullptr, &sound); ``` This will result in `ma_sound_init_*()` returning quickly, but the sound won't yet have been fully @@ -1303,7 +1303,7 @@ If loading the entire sound into memory is prohibitive, you can also configure t the audio data: ```c - ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_STREAM, pGroup, NULL, &sound); + ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_STREAM, pGroup, nullptr, &sound); ``` When streaming sounds, 2 seconds worth of audio data is stored in memory. Although it should work @@ -1323,7 +1323,7 @@ only works for sounds that were initialized with `ma_sound_init_from_file()` and `MA_SOUND_FLAG_STREAM` flag. When you initialize a sound, if you specify a sound group the sound will be attached to that group -automatically. If you set it to NULL, it will be automatically attached to the engine's endpoint. +automatically. If you set it to nullptr, it will be automatically attached to the engine's endpoint. If you would instead rather leave the sound unattached by default, you can specify the `MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT` flag. This is useful if you want to set up a complex node graph. @@ -1345,7 +1345,7 @@ to disable spatialization of a sound: ```c // Disable spatialization at initialization time via a flag: - ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_NO_SPATIALIZATION, NULL, NULL, &sound); + ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_NO_SPATIALIZATION, nullptr, nullptr, &sound); // Dynamically disable or enable spatialization post-initialization: ma_sound_set_spatialization_enabled(&sound, isSpatializationEnabled); @@ -1589,7 +1589,7 @@ vtables into the resource manager config: resourceManagerConfig.ppCustomDecodingBackendVTables = pCustomBackendVTables; resourceManagerConfig.customDecodingBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]); - resourceManagerConfig.pCustomDecodingBackendUserData = NULL; + resourceManagerConfig.pCustomDecodingBackendUserData = nullptr; ``` This system can allow you to support any kind of file format. See the "Decoding" section for @@ -2074,7 +2074,7 @@ standard config/init system: ```c ma_node_graph_config nodeGraphConfig = ma_node_graph_config_init(myChannelCount); - result = ma_node_graph_init(&nodeGraphConfig, NULL, &nodeGraph); // Second parameter is a pointer to allocation callbacks. + result = ma_node_graph_init(&nodeGraphConfig, nullptr, &nodeGraph); // Second parameter is a pointer to allocation callbacks. if (result != MA_SUCCESS) { // Failed to initialize node graph. } @@ -2114,7 +2114,7 @@ of the stock nodes that comes with miniaudio: ma_data_source_node_config config = ma_data_source_node_config_init(pMyDataSource); ma_data_source_node dataSourceNode; - result = ma_data_source_node_init(&nodeGraph, &config, NULL, &dataSourceNode); + result = ma_data_source_node_init(&nodeGraph, &config, nullptr, &dataSourceNode); if (result != MA_SUCCESS) { // Failed to create data source node. } @@ -2172,7 +2172,7 @@ pointer to the processing function and the number of input and output buses. Exa static ma_node_vtable my_custom_node_vtable = { my_custom_node_process_pcm_frames, // The function that will be called to process your custom node. This is where you'd implement your effect processing. - NULL, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames. + nullptr, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames. 2, // 2 input buses. 1, // 1 output bus. 0 // Default flags. @@ -2195,7 +2195,7 @@ pointer to the processing function and the number of input and output buses. Exa nodeConfig.pOutputChannels = outputChannels; ma_node_base node; - result = ma_node_init(&nodeGraph, &nodeConfig, NULL, &node); + result = ma_node_init(&nodeGraph, &nodeConfig, nullptr, &node); if (result != MA_SUCCESS) { // Failed to initialize node. } @@ -2210,7 +2210,7 @@ to `MA_NODE_BUS_COUNT_UNKNOWN`. In this case, the bus count should be set in the static ma_node_vtable my_custom_node_vtable = { my_custom_node_process_pcm_frames, // The function that will be called process your custom node. This is where you'd implement your effect processing. - NULL, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames. + nullptr, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames. MA_NODE_BUS_COUNT_UNKNOWN, // The number of input buses is determined on a per-node basis. 1, // 1 output bus. 0 // Default flags. @@ -2284,7 +2284,7 @@ and include the following: | MA_NODE_FLAG_ALLOW_NULL_INPUT | Used in conjunction with | | | `MA_NODE_FLAG_CONTINUOUS_PROCESSING`. When this | | | is set, the `ppFramesIn` parameter of the | - | | processing callback will be set to NULL when | + | | processing callback will be set to nullptr when | | | there are no input frames are available. When | | | this is unset, silence will be posted to the | | | processing callback. | @@ -2313,7 +2313,7 @@ You can use it like this: ma_splitter_node_config splitterNodeConfig = ma_splitter_node_config_init(channels); ma_splitter_node splitterNode; - result = ma_splitter_node_init(&nodeGraph, &splitterNodeConfig, NULL, &splitterNode); + result = ma_splitter_node_init(&nodeGraph, &splitterNodeConfig, nullptr, &splitterNode); if (result != MA_SUCCESS) { // Failed to create node. } @@ -2526,7 +2526,7 @@ an example for loading a decoder from a file: ```c ma_decoder decoder; - ma_result result = ma_decoder_init_file("MySong.mp3", NULL, &decoder); + ma_result result = ma_decoder_init_file("MySong.mp3", nullptr, &decoder); if (result != MA_SUCCESS) { return false; // An error occurred. } @@ -2537,14 +2537,14 @@ an example for loading a decoder from a file: ``` When initializing a decoder, you can optionally pass in a pointer to a `ma_decoder_config` object -(the `NULL` argument in the example above) which allows you to configure the output format, channel +(the `nullptr` argument in the example above) which allows you to configure the output format, channel count, sample rate and channel map: ```c ma_decoder_config config = ma_decoder_config_init(ma_format_f32, 2, 48000); ``` -When passing in `NULL` for decoder config in `ma_decoder_init*()`, the output format will be the +When passing in `nullptr` for decoder config in `ma_decoder_init*()`, the output format will be the same as that defined by the decoding backend. Data is read from the decoder as PCM frames. This will output the number of PCM frames actually @@ -2610,7 +2610,7 @@ to be implemented which is then passed into the decoder config: ... decoderConfig = ma_decoder_config_init_default(); - decoderConfig.pCustomBackendUserData = NULL; + decoderConfig.pCustomBackendUserData = nullptr; decoderConfig.ppCustomBackendVTables = pCustomBackendVTables; decoderConfig.customBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]); ``` @@ -2647,7 +2647,7 @@ If memory allocation is required, it should be done so via the specified allocat possible (the `pAllocationCallbacks` parameter). If an error occurs when initializing the decoder, you should leave `ppBackend` unset, or set to -NULL, and make sure everything is cleaned up appropriately and an appropriate result code returned. +nullptr, and make sure everything is cleaned up appropriately and an appropriate result code returned. When multiple custom backends are specified, miniaudio will cycle through the vtables in the order they're listed in the array that's passed into the decoder config so it's important that your initialization routine is clean. @@ -2707,7 +2707,7 @@ example below: ``` The `framesWritten` variable will contain the number of PCM frames that were actually written. This -is optionally and you can pass in `NULL` if you need this. +is optionally and you can pass in `nullptr` if you need this. Encoders must be uninitialized with `ma_encoder_uninit()`. @@ -2772,12 +2772,12 @@ initializing a simple channel converter which converts from mono to stereo. ma_channel_converter_config config = ma_channel_converter_config_init( ma_format, // Sample format 1, // Input channels - NULL, // Input channel map + nullptr, // Input channel map 2, // Output channels - NULL, // Output channel map + nullptr, // Output channel map ma_channel_mix_mode_default); // The mixing algorithm to use when combining channels. - result = ma_channel_converter_init(&config, NULL, &converter); + result = ma_channel_converter_init(&config, nullptr, &converter); if (result != MA_SUCCESS) { // Error. } @@ -2914,7 +2914,7 @@ like the following: ma_resample_algorithm_linear); ma_resampler resampler; - ma_result result = ma_resampler_init(&config, NULL, &resampler); + ma_result result = ma_resampler_init(&config, nullptr, &resampler); if (result != MA_SUCCESS) { // An error occurred... } @@ -2971,9 +2971,9 @@ De-interleaved processing is not supported. To process frames, use `ma_resampler_process_pcm_frames()`. On input, this function takes the number of output frames you can fit in the output buffer and the number of input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer -and the number of input frames that were consumed in the process. You can pass in NULL for the +and the number of input frames that were consumed in the process. You can pass in nullptr for the input buffer in which case it will be treated as an infinitely large buffer of zeros. The output -buffer can also be NULL, in which case the processing will be treated as seek. +buffer can also be nullptr, in which case the processing will be treated as seek. The sample rate can be changed dynamically on the fly. You can change this with explicit sample rates with `ma_resampler_set_rate()` and also with a decimal ratio with @@ -3041,17 +3041,17 @@ On output, `pFrameCountIn` should be set to the number of input frames that were whereas `pFrameCountOut` should be set to the number of frames that were written to `pFramesOut`. The `onSetRate` callback is optional and is used for dynamically changing the sample rate. If -dynamic rate changes are not supported, you can set this callback to NULL. +dynamic rate changes are not supported, you can set this callback to nullptr. The `onGetInputLatency` and `onGetOutputLatency` functions are used for retrieving the latency in -input and output rates respectively. These can be NULL in which case latency calculations will be -assumed to be NULL. +input and output rates respectively. These can be nullptr in which case latency calculations will be +assumed to be nullptr. The `onGetRequiredInputFrameCount` callback is used to give miniaudio a hint as to how many input frames are required to be available to produce the given number of output frames. Likewise, the `onGetExpectedOutputFrameCount` callback is used to determine how many output frames will be produced given the specified number of input frames. miniaudio will use these as a hint, but they -are optional and can be set to NULL if you're unable to implement them. +are optional and can be set to nullptr if you're unable to implement them. @@ -3074,7 +3074,7 @@ object like this: ); ma_data_converter converter; - ma_result result = ma_data_converter_init(&config, NULL, &converter); + ma_result result = ma_data_converter_init(&config, nullptr, &converter); if (result != MA_SUCCESS) { // An error occurred... } @@ -3099,7 +3099,7 @@ Something like the following may be more suitable depending on your requirements Do the following to uninitialize the data converter: ```c - ma_data_converter_uninit(&converter, NULL); + ma_data_converter_uninit(&converter, nullptr); ``` The following example shows how data can be processed @@ -3131,9 +3131,9 @@ De-interleaved processing is not supported. To process frames, use `ma_data_converter_process_pcm_frames()`. On input, this function takes the number of output frames you can fit in the output buffer and the number of input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer -and the number of input frames that were consumed in the process. You can pass in NULL for the +and the number of input frames that were consumed in the process. You can pass in nullptr for the input buffer in which case it will be treated as an infinitely large -buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated +buffer of zeros. The output buffer can also be nullptr, in which case the processing will be treated as seek. Sometimes it's useful to know exactly how many input frames will be required to output a specific @@ -3156,7 +3156,7 @@ Biquad filtering is achieved with the `ma_biquad` API. Example: ```c ma_biquad_config config = ma_biquad_config_init(ma_format_f32, channels, b0, b1, b2, a0, a1, a2); - ma_result result = ma_biquad_init(&config, NULL, &biquad); + ma_result result = ma_biquad_init(&config, nullptr, &biquad); if (result != MA_SUCCESS) { // Error. } @@ -3553,7 +3553,7 @@ you will want to use. To initialize a ring buffer, do something like the followi ```c ma_pcm_rb rb; - ma_result result = ma_pcm_rb_init(FORMAT, CHANNELS, BUFFER_SIZE_IN_FRAMES, NULL, NULL, &rb); + ma_result result = ma_pcm_rb_init(FORMAT, CHANNELS, BUFFER_SIZE_IN_FRAMES, nullptr, nullptr, &rb); if (result != MA_SUCCESS) { // Error } @@ -3564,7 +3564,7 @@ it's the PCM variant of the ring buffer API. For the regular ring buffer that op would call `ma_rb_init()` which leaves these out and just takes the size of the buffer in bytes instead of frames. The fourth parameter is an optional pre-allocated buffer and the fifth parameter is a pointer to a `ma_allocation_callbacks` structure for custom memory allocation routines. -Passing in `NULL` for this results in `MA_MALLOC()` and `MA_FREE()` being used. +Passing in `nullptr` for this results in `MA_MALLOC()` and `MA_FREE()` being used. Use `ma_pcm_rb_init_ex()` if you need a deinterleaved buffer. The data for each sub-buffer is offset from each other based on the stride. To manage your sub-buffers you can use @@ -3843,9 +3843,9 @@ typedef void* ma_proc; typedef ma_uint16 wchar_t; #endif -/* Define NULL for some compilers. */ -#ifndef NULL -#define NULL 0 +/* Define nullptr for some compilers. */ +#ifndef nullptr +#define nullptr 0 #endif #if defined(SIZE_MAX) @@ -4503,7 +4503,7 @@ typedef ma_uint32 ma_spinlock; /* -Retrieves the version of miniaudio as separated integers. Each component can be NULL if it's not required. +Retrieves the version of miniaudio as separated integers. Each component can be nullptr if it's not required. */ MA_API void ma_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision); @@ -5464,16 +5464,16 @@ ma_resampler_get_expected_output_frame_count() to know how many output frames wi On input, [pFrameCountIn] contains the number of input frames contained in [pFramesIn]. On output it contains the number of whole input frames that were actually processed. You can use ma_resampler_get_required_input_frame_count() to know how many input frames -you should provide for a given number of output frames. [pFramesIn] can be NULL, in which case zeroes will be used instead. +you should provide for a given number of output frames. [pFramesIn] can be nullptr, in which case zeroes will be used instead. -If [pFramesOut] is NULL, a seek is performed. In this case, if [pFrameCountOut] is not NULL it will seek by the specified number of -output frames. Otherwise, if [pFramesCountOut] is NULL and [pFrameCountIn] is not NULL, it will seek by the specified number of input -frames. When seeking, [pFramesIn] is allowed to NULL, in which case the internal timing state will be updated, but no input will be +If [pFramesOut] is nullptr, a seek is performed. In this case, if [pFrameCountOut] is not nullptr it will seek by the specified number of +output frames. Otherwise, if [pFramesCountOut] is nullptr and [pFrameCountIn] is not nullptr, it will seek by the specified number of input +frames. When seeking, [pFramesIn] is allowed to nullptr, in which case the internal timing state will be updated, but no input will be processed. In this case, any internal filter state will be updated as if zeroes were passed in. -It is an error for [pFramesOut] to be non-NULL and [pFrameCountOut] to be NULL. +It is an error for [pFramesOut] to be non-nullptr and [pFrameCountOut] to be nullptr. -It is an error for both [pFrameCountOut] and [pFrameCountIn] to be NULL. +It is an error for both [pFrameCountOut] and [pFrameCountIn] to be nullptr. */ MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut); @@ -5744,7 +5744,7 @@ MA_API void ma_channel_map_copy(ma_channel* pOut, const ma_channel* pIn, ma_uint /* Copies a channel map if one is specified, otherwise copies the default channel map. -The output buffer must have a capacity of at least `channels`. If not NULL, the input channel map must also have a capacity of at least `channels`. +The output buffer must have a capacity of at least `channels`. If not nullptr, the input channel map must also have a capacity of at least `channels`. */ MA_API void ma_channel_map_copy_or_default(ma_channel* pOut, size_t channelMapCapOut, const ma_channel* pIn, ma_uint32 channels); @@ -5816,8 +5816,8 @@ Conversion Helpers ************************************************************************************************************************************************************/ /* -High-level helper for doing a full format conversion in one go. Returns the number of output frames. Call this with pOut set to NULL to -determine the required size of the output buffer. frameCountOut should be set to the capacity of pOut. If pOut is NULL, frameCountOut is +High-level helper for doing a full format conversion in one go. Returns the number of output frames. Call this with pOut set to nullptr to +determine the required size of the output buffer. frameCountOut should be set to the capacity of pOut. If pOut is nullptr, frameCountOut is ignored. A return value of 0 indicates an error. @@ -5865,16 +5865,16 @@ typedef struct ma_uint64 rangeEndInFrames; /* Set to -1 for unranged (default). */ ma_uint64 loopBegInFrames; /* Relative to rangeBegInFrames. */ ma_uint64 loopEndInFrames; /* Relative to rangeBegInFrames. Set to -1 for the end of the range. */ - ma_data_source* pCurrent; /* When non-NULL, the data source being initialized will act as a proxy and will route all operations to pCurrent. Used in conjunction with pNext/onGetNext for seamless chaining. */ - ma_data_source* pNext; /* When set to NULL, onGetNext will be used. */ - ma_data_source_get_next_proc onGetNext; /* Will be used when pNext is NULL. If both are NULL, no next will be used. */ + ma_data_source* pCurrent; /* When non-nullptr, the data source being initialized will act as a proxy and will route all operations to pCurrent. Used in conjunction with pNext/onGetNext for seamless chaining. */ + ma_data_source* pNext; /* When set to nullptr, onGetNext will be used. */ + ma_data_source_get_next_proc onGetNext; /* Will be used when pNext is nullptr. If both are nullptr, no next will be used. */ MA_ATOMIC(4, ma_bool32) isLooping; } ma_data_source_base; MA_API ma_result ma_data_source_init(const ma_data_source_config* pConfig, ma_data_source* pDataSource); MA_API void ma_data_source_uninit(ma_data_source* pDataSource); -MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Must support pFramesOut = NULL in which case a forward seek should be performed. */ -MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked); /* Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount, &framesRead); */ +MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Must support pFramesOut = nullptr in which case a forward seek should be performed. */ +MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked); /* Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, nullptr, frameCount, &framesRead); */ MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex); MA_API ma_result ma_data_source_seek_seconds(ma_data_source* pDataSource, float secondCount, float* pSecondsSeeked); /* Can only seek forward. Abstraction to ma_data_source_seek_pcm_frames() */ MA_API ma_result ma_data_source_seek_to_second(ma_data_source* pDataSource, float seekPointInSeconds); /* Abstraction to ma_data_source_seek_to_pcm_frame() */ @@ -5928,7 +5928,7 @@ typedef struct ma_uint32 channels; ma_uint32 sampleRate; ma_uint64 sizeInFrames; - const void* pData; /* If set to NULL, will allocate a block of memory for you. */ + const void* pData; /* If set to nullptr, will allocate a block of memory for you. */ ma_allocation_callbacks allocationCallbacks; } ma_audio_buffer_config; @@ -6499,7 +6499,7 @@ struct ma_job { /*ma_resource_manager_data_stream**/ void* pDataStream; char* pFilePath; /* Allocated when the job is posted, freed by the job thread after loading. */ - wchar_t* pFilePathW; /* ^ As above ^. Only used if pFilePath is NULL. */ + wchar_t* pFilePathW; /* ^ As above ^. Only used if pFilePath is nullptr. */ ma_uint64 initialSeekPoint; ma_async_notification* pInitNotification; /* Signalled after the first two pages have been decoded and frames can be read from the stream. */ ma_fence* pInitFence; @@ -7248,7 +7248,7 @@ needs to stop and the `onContextEnumerateDevices()` function returns with a succ Detailed device information can be retrieved from a device ID using `onContextGetDeviceInfo()`. This takes as input the device type and ID, and on output returns detailed information about the device in `ma_device_info`. The `onContextGetDeviceInfo()` callback must handle the -case when the device ID is NULL, in which case information about the default device needs to be retrieved. +case when the device ID is nullptr, in which case information about the default device needs to be retrieved. Once the context has been created and the device ID retrieved (if using anything other than the default device), the device can be created. This is a little bit more complicated than initialization of the context due to its more complicated configuration. When initializing a @@ -7794,7 +7794,7 @@ struct ma_device ma_event stopEvent; ma_thread thread; ma_result workResult; /* This is set by the worker thread after it's finished doing a job. */ - ma_bool8 isOwnerOfContext; /* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */ + ma_bool8 isOwnerOfContext; /* When set to true, uninitializing the device will also uninitialize the context. Set to true when nullptr is passed into ma_device_init(). */ ma_bool8 noPreSilencedOutputBuffer; ma_bool8 noClip; ma_bool8 noDisableDenormals; @@ -7813,7 +7813,7 @@ struct ma_device } resampling; struct { - ma_device_id* pID; /* Set to NULL if using default ID, otherwise set to the address of "id". */ + ma_device_id* pID; /* Set to nullptr if using default ID, otherwise set to the address of "id". */ ma_device_id id; /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */ char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; /* Maybe temporary. Likely to be replaced with a query API. */ ma_share_mode shareMode; /* Set to whatever was passed in when the device was initialized. */ @@ -7839,7 +7839,7 @@ struct ma_device } playback; struct { - ma_device_id* pID; /* Set to NULL if using default ID, otherwise set to the address of "id". */ + ma_device_id* pID; /* Set to nullptr if using default ID, otherwise set to the address of "id". */ ma_device_id id; /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */ char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; /* Maybe temporary. Likely to be replaced with a query API. */ ma_share_mode shareMode; /* Set to whatever was passed in when the device was initialized. */ @@ -8114,10 +8114,10 @@ device. There is one context to many devices, and a device is created from a con Parameters ---------- backends (in, optional) - A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order. + A list of backends to try initializing, in priority order. Can be nullptr, in which case it uses default priority order. backendCount (in, optional) - The number of items in `backend`. Ignored if `backend` is NULL. + The number of items in `backend`. Ignored if `backend` is nullptr. pConfig (in, optional) The context configuration. @@ -8138,7 +8138,7 @@ Unsafe. Do not call this function across multiple threads as some backends read Remarks ------- -When `backends` is NULL, the default priority order will be used. Below is a list of backends in priority order: +When `backends` is nullptr, the default priority order will be used. Below is a list of backends in priority order: |-------------|-----------------------|--------------------------------------------------------| | Name | Enum Name | Supported Operating Systems | @@ -8163,7 +8163,7 @@ The context can be configured via the `pConfig` argument. The config object is i can then be set directly on the structure. Below are the members of the `ma_context_config` object. pLog - A pointer to the `ma_log` to post log messages to. Can be NULL if the application does not + A pointer to the `ma_log` to post log messages to. Can be nullptr if the application does not require logging. See the `ma_log` API for details on how to use the logging system. threadPriority @@ -8265,7 +8265,7 @@ The example below shows how to initialize the context using the default configur ```c ma_context context; -ma_result result = ma_context_init(NULL, 0, NULL, &context); +ma_result result = ma_context_init(nullptr, 0, nullptr, &context); if (result != MA_SUCCESS) { // Error. } @@ -8363,7 +8363,7 @@ You can attach your own logging callback to the log with `ma_log_register_callba Return Value ------------ A pointer to the `ma_log` object that the context uses to post log messages. If some error occurs, -NULL will be returned. +nullptr will be returned. */ MA_API ma_log* ma_context_get_log(ma_context* pContext); @@ -8478,7 +8478,7 @@ Remarks ------- It is _not_ safe to assume the first device in the list is the default device. -You can pass in NULL for the playback or capture lists in which case they'll be ignored. +You can pass in nullptr for the playback or capture lists in which case they'll be ignored. The returned pointers will become invalid upon the next call this this function, or when the context is uninitialized. Do not free the returned pointers. @@ -8666,13 +8666,13 @@ Unsafe. It is not safe to call this inside any callback. Remarks ------- -Setting `pContext` to NULL will result in miniaudio creating a default context internally and is equivalent to passing in a context initialized like so: +Setting `pContext` to nullptr will result in miniaudio creating a default context internally and is equivalent to passing in a context initialized like so: ```c - ma_context_init(NULL, 0, NULL, &context); + ma_context_init(nullptr, 0, nullptr, &context); ``` -Do not set `pContext` to NULL if you are needing to open multiple devices. You can, however, use NULL when initializing the first device, and then use +Do not set `pContext` to nullptr if you are needing to open multiple devices. You can, however, use nullptr when initializing the first device, and then use device.pContext for the initialization of other devices. The device can be configured via the `pConfig` argument. The config object is initialized with `ma_device_config_init()`. Individual configuration settings can @@ -8743,7 +8743,7 @@ then be set directly on the structure. Below are the members of the `ma_device_c `MA_MAX_FILTER_ORDER`. The default value is `min(4, MA_MAX_FILTER_ORDER)`. playback.pDeviceID - A pointer to a `ma_device_id` structure containing the ID of the playback device to initialize. Setting this NULL (default) will use the system's + A pointer to a `ma_device_id` structure containing the ID of the playback device to initialize. Setting this nullptr (default) will use the system's default playback device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration. playback.format @@ -8764,7 +8764,7 @@ then be set directly on the structure. Below are the members of the `ma_device_c ma_share_mode_shared and reinitializing. capture.pDeviceID - A pointer to a `ma_device_id` structure containing the ID of the capture device to initialize. Setting this NULL (default) will use the system's + A pointer to a `ma_device_id` structure containing the ID of the capture device to initialize. Setting this nullptr (default) will use the system's default capture device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration. capture.format @@ -8890,7 +8890,7 @@ config.dataCallback = ma_data_callback; config.pMyUserData = pMyUserData; ma_device device; -ma_result result = ma_device_init(NULL, &config, &device); +ma_result result = ma_device_init(nullptr, &config, &device); if (result != MA_SUCCESS) { // Error } @@ -8905,14 +8905,14 @@ enumeration. ```c ma_context context; -ma_result result = ma_context_init(NULL, 0, NULL, &context); +ma_result result = ma_context_init(nullptr, 0, nullptr, &context); if (result != MA_SUCCESS) { // Error } ma_device_info* pPlaybackDeviceInfos; ma_uint32 playbackDeviceCount; -result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, NULL); +result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, nullptr, nullptr); if (result != MA_SUCCESS) { // Error } @@ -8958,10 +8958,10 @@ allows you to configure the internally created context. Parameters ---------- backends (in, optional) - A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order. + A list of backends to try initializing, in priority order. Can be nullptr, in which case it uses default priority order. backendCount (in, optional) - The number of items in `backend`. Ignored if `backend` is NULL. + The number of items in `backend`. Ignored if `backend` is nullptr. pContextConfig (in, optional) The context configuration. @@ -9131,7 +9131,7 @@ which may or may not be safe. Remarks ------- -If the name does not fully fit into the output buffer, it'll be truncated. You can pass in NULL to +If the name does not fully fit into the output buffer, it'll be truncated. You can pass in nullptr to `pName` if you want to first get the length of the name for the purpose of memory allocation of the output buffer. Allocating a buffer of size `MA_MAX_DEVICE_NAME_LENGTH + 1` should be enough for most cases and will avoid the need for the inefficiency of calling this function twice. @@ -9387,7 +9387,7 @@ volume (in) Return Value ------------ MA_SUCCESS if the volume was set successfully. -MA_INVALID_ARGS if pDevice is NULL. +MA_INVALID_ARGS if pDevice is nullptr. MA_INVALID_ARGS if volume is negative. @@ -9432,8 +9432,8 @@ pVolume (in) Return Value ------------ MA_SUCCESS if successful. -MA_INVALID_ARGS if pDevice is NULL. -MA_INVALID_ARGS if pVolume is NULL. +MA_INVALID_ARGS if pDevice is nullptr. +MA_INVALID_ARGS if pVolume is nullptr. Thread Safety @@ -9477,7 +9477,7 @@ gainDB (in) Return Value ------------ MA_SUCCESS if the volume was set successfully. -MA_INVALID_ARGS if pDevice is NULL. +MA_INVALID_ARGS if pDevice is nullptr. MA_INVALID_ARGS if the gain is > 0. @@ -9522,8 +9522,8 @@ pGainDB (in) Return Value ------------ MA_SUCCESS if successful. -MA_INVALID_ARGS if pDevice is NULL. -MA_INVALID_ARGS if pGainDB is NULL. +MA_INVALID_ARGS if pDevice is nullptr. +MA_INVALID_ARGS if pGainDB is nullptr. Thread Safety @@ -9560,12 +9560,12 @@ pDevice (in) A pointer to device whose processing the data callback. pOutput (out) - A pointer to the buffer that will receive the output PCM frame data. On a playback device this must not be NULL. On a duplex device - this can be NULL, in which case pInput must not be NULL. + A pointer to the buffer that will receive the output PCM frame data. On a playback device this must not be nullptr. On a duplex device + this can be nullptr, in which case pInput must not be nullptr. pInput (in) - A pointer to the buffer containing input PCM frame data. On a capture device this must not be NULL. On a duplex device this can be - NULL, in which case `pOutput` must not be NULL. + A pointer to the buffer containing input PCM frame data. On a capture device this must not be nullptr. On a duplex device this can be + nullptr, in which case `pOutput` must not be nullptr. frameCount (in) The number of frames being processed. @@ -9589,7 +9589,7 @@ Do not call this from the miniaudio data callback. It should only ever be called Remarks ------- -If both `pOutput` and `pInput` are NULL, and error will be returned. In duplex scenarios, both `pOutput` and `pInput` can be non-NULL, in +If both `pOutput` and `pInput` are nullptr, and error will be returned. In duplex scenarios, both `pOutput` and `pInput` can be non-nullptr, in which case `pInput` will be processed first, followed by `pOutput`. If you are implementing a custom backend, and that backend uses a callback for data delivery, you'll need to call this from inside that @@ -9674,7 +9674,7 @@ Retrieves compile-time enabled backends. Parameters ---------- pBackends (out, optional) - A pointer to the buffer that will receive the enabled backends. Set to NULL to retrieve the backend count. Setting + A pointer to the buffer that will receive the enabled backends. Set to nullptr to retrieve the backend count. Setting the capacity of the buffer to `MA_BACKEND_COUNT` will guarantee it's large enough for all backends. backendCap (in) @@ -9687,7 +9687,7 @@ pBackendCount (out) Return Value ------------ MA_SUCCESS if successful. -MA_INVALID_ARGS if `pBackendCount` is NULL. +MA_INVALID_ARGS if `pBackendCount` is nullptr. MA_NO_SPACE if the capacity of `pBackends` is not large enough. If `MA_NO_SPACE` is returned, the `pBackends` buffer will be filled with `*pBackendCount` values. @@ -9706,7 +9706,7 @@ Safe. Remarks ------- If you want to retrieve the number of backends so you can determine the capacity of `pBackends` buffer, you can call -this function with `pBackends` set to NULL. +this function with `pBackends` set to nullptr. This will also enumerate the null backend. If you don't want to include this you need to check for `ma_backend_null` when you enumerate over the returned backends and handle it appropriately. Alternatively, you can disable it at @@ -10516,7 +10516,7 @@ typedef struct size_t jobThreadStackSize; ma_uint32 jobQueueCapacity; /* The maximum number of jobs that can fit in the queue at a time. Defaults to MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_CAPACITY. Cannot be zero. */ ma_uint32 flags; - ma_vfs* pVFS; /* Can be NULL in which case defaults will be used. */ + ma_vfs* pVFS; /* Can be nullptr in which case defaults will be used. */ ma_decoding_backend_vtable** ppCustomDecodingBackendVTables; ma_uint32 customDecodingBackendCount; void* pCustomDecodingBackendUserData; @@ -11213,7 +11213,7 @@ typedef struct const char* pFilePath; /* Set this to load from the resource manager. */ const wchar_t* pFilePathW; /* Set this to load from the resource manager. */ ma_data_source* pDataSource; /* Set this to load from an existing data source. */ - ma_node* pInitialAttachment; /* If set, the sound will be attached to an input of this node. This can be set to a ma_sound. If set to NULL, the sound will be attached directly to the endpoint unless MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT is set in `flags`. */ + ma_node* pInitialAttachment; /* If set, the sound will be attached to an input of this node. This can be set to a ma_sound. If set to nullptr, the sound will be attached directly to the endpoint unless MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT is set in `flags`. */ ma_uint32 initialAttachmentInputBusIndex; /* The index of the input bus of pInitialAttachment to attach the sound to. */ ma_uint32 channelsIn; /* Ignored if using a data source as input (the data source's channel count will be used always). Otherwise, setting to 0 will cause the engine's channel count to be used. */ ma_uint32 channelsOut; /* Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). */ @@ -11290,7 +11290,7 @@ typedef struct ma_device_data_proc dataCallback; /* Can be null. Can be used to provide a custom device data callback. */ ma_device_notification_proc notificationCallback; #endif - ma_log* pLog; /* When set to NULL, will use the context's log. */ + ma_log* pLog; /* When set to nullptr, will use the context's log. */ ma_uint32 listenerCount; /* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */ ma_uint32 channels; /* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */ ma_uint32 sampleRate; /* The sample rate. When set to 0 will use the native sample rate of the device. */ @@ -11304,7 +11304,7 @@ typedef struct ma_bool32 noAutoStart; /* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */ ma_bool32 noDevice; /* When set to true, don't create a default device. ma_engine_read_pcm_frames() can be called manually to read data. */ ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */ - ma_vfs* pResourceManagerVFS; /* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. */ + ma_vfs* pResourceManagerVFS; /* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not nullptr. */ ma_engine_process_proc onProcess; /* Fired at the end of each call to ma_engine_read_pcm_frames(). For engine's that manage their own internal device (the default configuration), this will be fired from the audio thread, and you do not need to call ma_engine_read_pcm_frames() manually in order to trigger this. */ void* pProcessUserData; /* User data that's passed into onProcess. */ ma_resampler_config resourceManagerResampling; /* The resampling config to use with the resource manager. */ @@ -12010,12 +12010,12 @@ static void ma_sleep__posix(ma_uint32 milliseconds) struct timespec ts; ts.tv_sec = milliseconds / 1000; ts.tv_nsec = milliseconds % 1000 * 1000000; - nanosleep(&ts, NULL); + nanosleep(&ts, nullptr); #else struct timeval tv; tv.tv_sec = milliseconds / 1000; tv.tv_usec = milliseconds % 1000 * 1000; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); #endif #endif } @@ -12337,7 +12337,7 @@ Standard Library Stuff static MA_INLINE void ma_zero_memory_default(void* p, size_t sz) { - if (p == NULL) { + if (p == nullptr) { MA_ASSERT(sz == 0); /* If this is triggered there's an error with the calling code. */ return; } @@ -12684,7 +12684,7 @@ MA_API MA_NO_INLINE int ma_itoa_s(int value, char* dst, size_t dstSizeInBytes, i unsigned int valueU; char* dstEnd; - if (dst == NULL || dstSizeInBytes == 0) { + if (dst == nullptr || dstSizeInBytes == 0) { return 22; } if (radix < 2 || radix > 36) { @@ -12752,8 +12752,8 @@ MA_API MA_NO_INLINE int ma_strcmp(const char* str1, const char* str2) if (str1 == str2) return 0; /* These checks differ from the standard implementation. It's not important, but I prefer it just for sanity. */ - if (str1 == NULL) return -1; - if (str2 == NULL) return 1; + if (str1 == nullptr) return -1; + if (str2 == nullptr) return 1; for (;;) { if (str1[0] == '\0') { @@ -12775,8 +12775,8 @@ MA_API MA_NO_INLINE int ma_wcscmp(const wchar_t* str1, const wchar_t* str2) if (str1 == str2) return 0; /* These checks differ from the standard implementation. It's not important, but I prefer it just for sanity. */ - if (str1 == NULL) return -1; - if (str2 == NULL) return 1; + if (str1 == nullptr) return -1; + if (str2 == nullptr) return 1; for (;;) { if (str1[0] == L'\0') { @@ -12814,7 +12814,7 @@ MA_API MA_NO_INLINE size_t ma_wcslen(const wchar_t* str) { const wchar_t* end; - if (str == NULL) { + if (str == nullptr) { return 0; } @@ -12831,14 +12831,14 @@ MA_API MA_NO_INLINE char* ma_copy_string(const char* src, const ma_allocation_ca size_t sz; char* dst; - if (src == NULL) { - return NULL; + if (src == nullptr) { + return nullptr; } sz = strlen(src)+1; dst = (char*)ma_malloc(sz, pAllocationCallbacks); - if (dst == NULL) { - return NULL; + if (dst == nullptr) { + return nullptr; } ma_strcpy_s(dst, sz, src); @@ -12850,8 +12850,8 @@ MA_API MA_NO_INLINE wchar_t* ma_copy_string_w(const wchar_t* src, const ma_alloc { size_t sz = ma_wcslen(src)+1; wchar_t* dst = (wchar_t*)ma_malloc(sz * sizeof(*dst), pAllocationCallbacks); - if (dst == NULL) { - return NULL; + if (dst == nullptr) { + return nullptr; } ma_wcscpy_s(dst, sz, src); @@ -13271,11 +13271,11 @@ MA_API ma_result ma_fopen(FILE** ppFile, const char* pFilePath, const char* pOpe errno_t err; #endif - if (ppFile != NULL) { - *ppFile = NULL; /* Safety. */ + if (ppFile != nullptr) { + *ppFile = nullptr; /* Safety. */ } - if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) { + if (pFilePath == nullptr || pOpenMode == nullptr || ppFile == nullptr) { return MA_INVALID_ARGS; } @@ -13294,10 +13294,10 @@ MA_API ma_result ma_fopen(FILE** ppFile, const char* pFilePath, const char* pOpe *ppFile = fopen(pFilePath, pOpenMode); #endif #endif - if (*ppFile == NULL) { + if (*ppFile == nullptr) { ma_result result = ma_result_from_errno(errno); if (result == MA_SUCCESS) { - result = MA_ERROR; /* Just a safety check to make sure we never ever return success when pFile == NULL. */ + result = MA_ERROR; /* Just a safety check to make sure we never ever return success when pFile == nullptr. */ } return result; @@ -13329,11 +13329,11 @@ fallback, so if you notice your compiler not detecting this properly I'm happy t MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const ma_allocation_callbacks* pAllocationCallbacks) { - if (ppFile != NULL) { - *ppFile = NULL; /* Safety. */ + if (ppFile != nullptr) { + *ppFile = nullptr; /* Safety. */ } - if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) { + if (pFilePath == nullptr || pOpenMode == nullptr || ppFile == nullptr) { return MA_INVALID_ARGS; } @@ -13350,7 +13350,7 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_ #else { *ppFile = _wfopen(pFilePath, pOpenMode); - if (*ppFile == NULL) { + if (*ppFile == nullptr) { return ma_result_from_errno(errno); } } @@ -13368,18 +13368,18 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_ mbstate_t mbs; size_t lenMB; const wchar_t* pFilePathTemp = pFilePath; - char* pFilePathMB = NULL; + char* pFilePathMB = nullptr; char pOpenModeMB[32] = {0}; /* Get the length first. */ MA_ZERO_OBJECT(&mbs); - lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs); + lenMB = wcsrtombs(nullptr, &pFilePathTemp, 0, &mbs); if (lenMB == (size_t)-1) { return ma_result_from_errno(errno); } pFilePathMB = (char*)ma_malloc(lenMB + 1, pAllocationCallbacks); - if (pFilePathMB == NULL) { + if (pFilePathMB == nullptr) { return MA_OUT_OF_MEMORY; } @@ -13408,11 +13408,11 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_ #else { /* Getting here means there is no way to open the file with a wide character string. */ - *ppFile = NULL; + *ppFile = nullptr; } #endif - if (*ppFile == NULL) { + if (*ppFile == nullptr) { return MA_ERROR; } @@ -13533,7 +13533,7 @@ static void ma__free_default(void* p, void* pUserData) static ma_allocation_callbacks ma_allocation_callbacks_init_default(void) { ma_allocation_callbacks callbacks; - callbacks.pUserData = NULL; + callbacks.pUserData = nullptr; callbacks.onMalloc = ma__malloc_default; callbacks.onRealloc = ma__realloc_default; callbacks.onFree = ma__free_default; @@ -13543,17 +13543,17 @@ static ma_allocation_callbacks ma_allocation_callbacks_init_default(void) static ma_result ma_allocation_callbacks_init_copy(ma_allocation_callbacks* pDst, const ma_allocation_callbacks* pSrc) { - if (pDst == NULL) { + if (pDst == nullptr) { return MA_INVALID_ARGS; } - if (pSrc == NULL) { + if (pSrc == nullptr) { *pDst = ma_allocation_callbacks_init_default(); } else { - if (pSrc->pUserData == NULL && pSrc->onFree == NULL && pSrc->onMalloc == NULL && pSrc->onRealloc == NULL) { + if (pSrc->pUserData == nullptr && pSrc->onFree == nullptr && pSrc->onMalloc == nullptr && pSrc->onRealloc == nullptr) { *pDst = ma_allocation_callbacks_init_default(); } else { - if (pSrc->onFree == NULL || (pSrc->onMalloc == NULL && pSrc->onRealloc == NULL)) { + if (pSrc->onFree == nullptr || (pSrc->onMalloc == nullptr && pSrc->onRealloc == nullptr)) { return MA_INVALID_ARGS; /* Invalid allocation callbacks. */ } else { *pDst = *pSrc; @@ -13639,7 +13639,7 @@ MA_API ma_log_callback ma_log_callback_init(ma_log_callback_proc onLog, void* pU MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks, ma_log* pLog) { - if (pLog == NULL) { + if (pLog == nullptr) { return MA_INVALID_ARGS; } @@ -13659,7 +13659,7 @@ MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks /* If we're using debug output, enable it. */ #if defined(MA_DEBUG_OUTPUT) { - ma_log_register_callback(pLog, ma_log_callback_init(ma_log_callback_debug, NULL)); /* Doesn't really matter if this fails. */ + ma_log_register_callback(pLog, ma_log_callback_init(ma_log_callback_debug, nullptr)); /* Doesn't really matter if this fails. */ } #endif @@ -13668,7 +13668,7 @@ MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks MA_API void ma_log_uninit(ma_log* pLog) { - if (pLog == NULL) { + if (pLog == nullptr) { return; } @@ -13699,7 +13699,7 @@ MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback { ma_result result = MA_SUCCESS; - if (pLog == NULL || callback.onLog == NULL) { + if (pLog == nullptr || callback.onLog == nullptr) { return MA_INVALID_ARGS; } @@ -13719,7 +13719,7 @@ MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback MA_API ma_result ma_log_unregister_callback(ma_log* pLog, ma_log_callback callback) { - if (pLog == NULL) { + if (pLog == nullptr) { return MA_INVALID_ARGS; } @@ -13748,7 +13748,7 @@ MA_API ma_result ma_log_unregister_callback(ma_log* pLog, ma_log_callback callba MA_API ma_result ma_log_post(ma_log* pLog, ma_uint32 level, const char* pMessage) { - if (pLog == NULL || pMessage == NULL) { + if (pLog == nullptr || pMessage == nullptr) { return MA_INVALID_ARGS; } @@ -13778,17 +13778,17 @@ static int ma_vscprintf(const ma_allocation_callbacks* pAllocationCallbacks, con return _vscprintf(format, args); #else int result; - char* pTempBuffer = NULL; + char* pTempBuffer = nullptr; size_t tempBufferCap = 1024; - if (format == NULL) { + if (format == nullptr) { errno = EINVAL; return -1; } for (;;) { char* pNewTempBuffer = (char*)ma_realloc(pTempBuffer, tempBufferCap, pAllocationCallbacks); - if (pNewTempBuffer == NULL) { + if (pNewTempBuffer == nullptr) { ma_free(pTempBuffer, pAllocationCallbacks); errno = ENOMEM; return -1; /* Out of memory. */ @@ -13797,7 +13797,7 @@ static int ma_vscprintf(const ma_allocation_callbacks* pAllocationCallbacks, con pTempBuffer = pNewTempBuffer; result = _vsnprintf(pTempBuffer, tempBufferCap, format, args); - ma_free(pTempBuffer, NULL); + ma_free(pTempBuffer, nullptr); if (result != -1) { break; /* Got it. */ @@ -13814,7 +13814,7 @@ static int ma_vscprintf(const ma_allocation_callbacks* pAllocationCallbacks, con MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat, va_list args) { - if (pLog == NULL || pFormat == NULL) { + if (pLog == nullptr || pFormat == nullptr) { return MA_INVALID_ARGS; } @@ -13823,7 +13823,7 @@ MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat ma_result result; int length; char pFormattedMessageStack[1024]; - char* pFormattedMessageHeap = NULL; + char* pFormattedMessageHeap = nullptr; va_list args2; /* First try formatting into our fixed sized stack allocated buffer. If this is too small we'll fallback to a heap allocation. */ @@ -13843,7 +13843,7 @@ MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat } else { /* The stack buffer was too small, try the heap. */ pFormattedMessageHeap = (char*)ma_malloc(length + 1, &pLog->allocationCallbacks); - if (pFormattedMessageHeap == NULL) { + if (pFormattedMessageHeap == nullptr) { return MA_OUT_OF_MEMORY; } @@ -13870,7 +13870,7 @@ MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat { ma_result result; int formattedLen; - char* pFormattedMessage = NULL; + char* pFormattedMessage = nullptr; va_list args2; ma_va_copy(args2, args); @@ -13884,7 +13884,7 @@ MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat } pFormattedMessage = (char*)ma_malloc(formattedLen + 1, &pLog->allocationCallbacks); - if (pFormattedMessage == NULL) { + if (pFormattedMessage == nullptr) { return MA_OUT_OF_MEMORY; } @@ -13922,7 +13922,7 @@ MA_API ma_result ma_log_postf(ma_log* pLog, ma_uint32 level, const char* pFormat ma_result result; va_list args; - if (pLog == NULL || pFormat == NULL) { + if (pLog == nullptr || pFormat == nullptr) { return MA_INVALID_ARGS; } @@ -14079,7 +14079,7 @@ static ma_lcg g_maLCG = {MA_DEFAULT_LCG_SEED}; /* Non-zero initial seed. Use ma_ static MA_INLINE void ma_lcg_seed(ma_lcg* pLCG, ma_int32 seed) { - MA_ASSERT(pLCG != NULL); + MA_ASSERT(pLCG != nullptr); pLCG->state = seed; } @@ -17522,7 +17522,7 @@ Threading *******************************************************************************/ static MA_INLINE ma_result ma_spinlock_lock_ex(volatile ma_spinlock* pSpinlock, ma_bool32 yield) { - if (pSpinlock == NULL) { + if (pSpinlock == nullptr) { return MA_INVALID_ARGS; } @@ -17553,7 +17553,7 @@ MA_API ma_result ma_spinlock_lock_noyield(volatile ma_spinlock* pSpinlock) MA_API ma_result ma_spinlock_unlock(volatile ma_spinlock* pSpinlock) { - if (pSpinlock == NULL) { + if (pSpinlock == nullptr) { return MA_INVALID_ARGS; } @@ -17577,7 +17577,7 @@ typedef ma_thread_result (MA_THREADCALL * ma_thread_entry_proc)(void* pData); static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData) { int result; - pthread_attr_t* pAttr = NULL; + pthread_attr_t* pAttr = nullptr; #if !defined(MA_EMSCRIPTEN) && !defined(MA_3DS) && !defined(MA_SWITCH) /* Try setting the thread priority. It's not critical if anything fails here. */ @@ -17674,7 +17674,7 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority result = pthread_create((pthread_t*)pThread, pAttr, entryProc, pData); /* The thread attributes object is no longer required. */ - if (pAttr != NULL) { + if (pAttr != nullptr) { pthread_attr_destroy(pAttr); } @@ -17702,7 +17702,7 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority static void ma_thread_wait__posix(ma_thread* pThread) { - pthread_join((pthread_t)*pThread, NULL); + pthread_join((pthread_t)*pThread, nullptr); } @@ -17710,13 +17710,13 @@ static ma_result ma_mutex_init__posix(ma_mutex* pMutex) { int result; - if (pMutex == NULL) { + if (pMutex == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pMutex); - result = pthread_mutex_init((pthread_mutex_t*)pMutex, NULL); + result = pthread_mutex_init((pthread_mutex_t*)pMutex, nullptr); if (result != 0) { return ma_result_from_errno(result); } @@ -17744,12 +17744,12 @@ static ma_result ma_event_init__posix(ma_event* pEvent) { int result; - result = pthread_mutex_init((pthread_mutex_t*)&pEvent->lock, NULL); + result = pthread_mutex_init((pthread_mutex_t*)&pEvent->lock, nullptr); if (result != 0) { return ma_result_from_errno(result); } - result = pthread_cond_init((pthread_cond_t*)&pEvent->cond, NULL); + result = pthread_cond_init((pthread_cond_t*)&pEvent->cond, nullptr); if (result != 0) { pthread_mutex_destroy((pthread_mutex_t*)&pEvent->lock); return ma_result_from_errno(result); @@ -17796,18 +17796,18 @@ static ma_result ma_semaphore_init__posix(int initialValue, ma_semaphore* pSemap { int result; - if (pSemaphore == NULL) { + if (pSemaphore == nullptr) { return MA_INVALID_ARGS; } pSemaphore->value = initialValue; - result = pthread_mutex_init((pthread_mutex_t*)&pSemaphore->lock, NULL); + result = pthread_mutex_init((pthread_mutex_t*)&pSemaphore->lock, nullptr); if (result != 0) { return ma_result_from_errno(result); /* Failed to create mutex. */ } - result = pthread_cond_init((pthread_cond_t*)&pSemaphore->cond, NULL); + result = pthread_cond_init((pthread_cond_t*)&pSemaphore->cond, nullptr); if (result != 0) { pthread_mutex_destroy((pthread_mutex_t*)&pSemaphore->lock); return ma_result_from_errno(result); /* Failed to create condition variable. */ @@ -17818,7 +17818,7 @@ static ma_result ma_semaphore_init__posix(int initialValue, ma_semaphore* pSemap static void ma_semaphore_uninit__posix(ma_semaphore* pSemaphore) { - if (pSemaphore == NULL) { + if (pSemaphore == nullptr) { return; } @@ -17828,7 +17828,7 @@ static void ma_semaphore_uninit__posix(ma_semaphore* pSemaphore) static ma_result ma_semaphore_wait__posix(ma_semaphore* pSemaphore) { - if (pSemaphore == NULL) { + if (pSemaphore == nullptr) { return MA_INVALID_ARGS; } @@ -17848,7 +17848,7 @@ static ma_result ma_semaphore_wait__posix(ma_semaphore* pSemaphore) static ma_result ma_semaphore_release__posix(ma_semaphore* pSemaphore) { - if (pSemaphore == NULL) { + if (pSemaphore == nullptr) { return MA_INVALID_ARGS; } @@ -17880,8 +17880,8 @@ static ma_result ma_thread_create__win32(ma_thread* pThread, ma_thread_priority { DWORD threadID; /* Not used. Only used for passing into CreateThread() so it doesn't fail on Windows 98. */ - *pThread = CreateThread(NULL, stackSize, entryProc, pData, 0, &threadID); - if (*pThread == NULL) { + *pThread = CreateThread(nullptr, stackSize, entryProc, pData, 0, &threadID); + if (*pThread == nullptr) { return ma_result_from_GetLastError(GetLastError()); } @@ -17899,8 +17899,8 @@ static void ma_thread_wait__win32(ma_thread* pThread) static ma_result ma_mutex_init__win32(ma_mutex* pMutex) { - *pMutex = CreateEventA(NULL, FALSE, TRUE, NULL); - if (*pMutex == NULL) { + *pMutex = CreateEventA(nullptr, FALSE, TRUE, nullptr); + if (*pMutex == nullptr) { return ma_result_from_GetLastError(GetLastError()); } @@ -17925,8 +17925,8 @@ static void ma_mutex_unlock__win32(ma_mutex* pMutex) static ma_result ma_event_init__win32(ma_event* pEvent) { - *pEvent = CreateEventA(NULL, FALSE, FALSE, NULL); - if (*pEvent == NULL) { + *pEvent = CreateEventA(nullptr, FALSE, FALSE, nullptr); + if (*pEvent == nullptr) { return ma_result_from_GetLastError(GetLastError()); } @@ -17965,8 +17965,8 @@ static ma_result ma_event_signal__win32(ma_event* pEvent) static ma_result ma_semaphore_init__win32(int initialValue, ma_semaphore* pSemaphore) { - *pSemaphore = CreateSemaphore(NULL, (LONG)initialValue, LONG_MAX, NULL); - if (*pSemaphore == NULL) { + *pSemaphore = CreateSemaphore(nullptr, (LONG)initialValue, LONG_MAX, nullptr); + if (*pSemaphore == nullptr) { return ma_result_from_GetLastError(GetLastError()); } @@ -17994,7 +17994,7 @@ static ma_result ma_semaphore_wait__win32(ma_semaphore* pSemaphore) static ma_result ma_semaphore_release__win32(ma_semaphore* pSemaphore) { - BOOL result = ReleaseSemaphore((HANDLE)*pSemaphore, 1, NULL); + BOOL result = ReleaseSemaphore((HANDLE)*pSemaphore, 1, nullptr); if (result == 0) { return ma_result_from_GetLastError(GetLastError()); } @@ -18041,12 +18041,12 @@ static ma_result ma_thread_create(ma_thread* pThread, ma_thread_priority priorit ma_result result; ma_thread_proxy_data* pProxyData; - if (pThread == NULL || entryProc == NULL) { + if (pThread == nullptr || entryProc == nullptr) { return MA_INVALID_ARGS; } pProxyData = (ma_thread_proxy_data*)ma_malloc(sizeof(*pProxyData), pAllocationCallbacks); /* Will be freed by the proxy entry proc. */ - if (pProxyData == NULL) { + if (pProxyData == nullptr) { return MA_OUT_OF_MEMORY; } @@ -18076,7 +18076,7 @@ static ma_result ma_thread_create(ma_thread* pThread, ma_thread_priority priorit static void ma_thread_wait(ma_thread* pThread) { - if (pThread == NULL) { + if (pThread == nullptr) { return; } @@ -18090,7 +18090,7 @@ static void ma_thread_wait(ma_thread* pThread) MA_API ma_result ma_mutex_init(ma_mutex* pMutex) { - if (pMutex == NULL) { + if (pMutex == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } @@ -18104,7 +18104,7 @@ MA_API ma_result ma_mutex_init(ma_mutex* pMutex) MA_API void ma_mutex_uninit(ma_mutex* pMutex) { - if (pMutex == NULL) { + if (pMutex == nullptr) { return; } @@ -18117,7 +18117,7 @@ MA_API void ma_mutex_uninit(ma_mutex* pMutex) MA_API void ma_mutex_lock(ma_mutex* pMutex) { - if (pMutex == NULL) { + if (pMutex == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return; } @@ -18131,7 +18131,7 @@ MA_API void ma_mutex_lock(ma_mutex* pMutex) MA_API void ma_mutex_unlock(ma_mutex* pMutex) { - if (pMutex == NULL) { + if (pMutex == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return; } @@ -18146,7 +18146,7 @@ MA_API void ma_mutex_unlock(ma_mutex* pMutex) MA_API ma_result ma_event_init(ma_event* pEvent) { - if (pEvent == NULL) { + if (pEvent == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } @@ -18164,14 +18164,14 @@ static ma_result ma_event_alloc_and_init(ma_event** ppEvent, ma_allocation_callb ma_result result; ma_event* pEvent; - if (ppEvent == NULL) { + if (ppEvent == nullptr) { return MA_INVALID_ARGS; } - *ppEvent = NULL; + *ppEvent = nullptr; pEvent = ma_malloc(sizeof(*pEvent), pAllocationCallbacks); - if (pEvent == NULL) { + if (pEvent == nullptr) { return MA_OUT_OF_MEMORY; } @@ -18188,7 +18188,7 @@ static ma_result ma_event_alloc_and_init(ma_event** ppEvent, ma_allocation_callb MA_API void ma_event_uninit(ma_event* pEvent) { - if (pEvent == NULL) { + if (pEvent == nullptr) { return; } @@ -18202,7 +18202,7 @@ MA_API void ma_event_uninit(ma_event* pEvent) #if 0 static void ma_event_uninit_and_free(ma_event* pEvent, ma_allocation_callbacks* pAllocationCallbacks) { - if (pEvent == NULL) { + if (pEvent == nullptr) { return; } @@ -18213,7 +18213,7 @@ static void ma_event_uninit_and_free(ma_event* pEvent, ma_allocation_callbacks* MA_API ma_result ma_event_wait(ma_event* pEvent) { - if (pEvent == NULL) { + if (pEvent == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert to the caller is aware of this bug. */ return MA_INVALID_ARGS; } @@ -18227,7 +18227,7 @@ MA_API ma_result ma_event_wait(ma_event* pEvent) MA_API ma_result ma_event_signal(ma_event* pEvent) { - if (pEvent == NULL) { + if (pEvent == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert to the caller is aware of this bug. */ return MA_INVALID_ARGS; } @@ -18242,7 +18242,7 @@ MA_API ma_result ma_event_signal(ma_event* pEvent) MA_API ma_result ma_semaphore_init(int initialValue, ma_semaphore* pSemaphore) { - if (pSemaphore == NULL) { + if (pSemaphore == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } @@ -18256,7 +18256,7 @@ MA_API ma_result ma_semaphore_init(int initialValue, ma_semaphore* pSemaphore) MA_API void ma_semaphore_uninit(ma_semaphore* pSemaphore) { - if (pSemaphore == NULL) { + if (pSemaphore == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return; } @@ -18270,7 +18270,7 @@ MA_API void ma_semaphore_uninit(ma_semaphore* pSemaphore) MA_API ma_result ma_semaphore_wait(ma_semaphore* pSemaphore) { - if (pSemaphore == NULL) { + if (pSemaphore == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } @@ -18284,7 +18284,7 @@ MA_API ma_result ma_semaphore_wait(ma_semaphore* pSemaphore) MA_API ma_result ma_semaphore_release(ma_semaphore* pSemaphore) { - if (pSemaphore == NULL) { + if (pSemaphore == nullptr) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } @@ -18308,7 +18308,7 @@ MA_API ma_result ma_semaphore_release(ma_semaphore* pSemaphore) MA_API ma_result ma_fence_init(ma_fence* pFence) { - if (pFence == NULL) { + if (pFence == nullptr) { return MA_INVALID_ARGS; } @@ -18331,7 +18331,7 @@ MA_API ma_result ma_fence_init(ma_fence* pFence) MA_API void ma_fence_uninit(ma_fence* pFence) { - if (pFence == NULL) { + if (pFence == nullptr) { return; } @@ -18346,7 +18346,7 @@ MA_API void ma_fence_uninit(ma_fence* pFence) MA_API ma_result ma_fence_acquire(ma_fence* pFence) { - if (pFence == NULL) { + if (pFence == nullptr) { return MA_INVALID_ARGS; } @@ -18376,7 +18376,7 @@ MA_API ma_result ma_fence_acquire(ma_fence* pFence) MA_API ma_result ma_fence_release(ma_fence* pFence) { - if (pFence == NULL) { + if (pFence == nullptr) { return MA_INVALID_ARGS; } @@ -18413,7 +18413,7 @@ MA_API ma_result ma_fence_release(ma_fence* pFence) MA_API ma_result ma_fence_wait(ma_fence* pFence) { - if (pFence == NULL) { + if (pFence == nullptr) { return MA_INVALID_ARGS; } @@ -18451,11 +18451,11 @@ MA_API ma_result ma_async_notification_signal(ma_async_notification* pNotificati { ma_async_notification_callbacks* pNotificationCallbacks = (ma_async_notification_callbacks*)pNotification; - if (pNotification == NULL) { + if (pNotification == nullptr) { return MA_INVALID_ARGS; } - if (pNotificationCallbacks->onSignal == NULL) { + if (pNotificationCallbacks->onSignal == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -18471,7 +18471,7 @@ static void ma_async_notification_poll__on_signal(ma_async_notification* pNotifi MA_API ma_result ma_async_notification_poll_init(ma_async_notification_poll* pNotificationPoll) { - if (pNotificationPoll == NULL) { + if (pNotificationPoll == nullptr) { return MA_INVALID_ARGS; } @@ -18483,7 +18483,7 @@ MA_API ma_result ma_async_notification_poll_init(ma_async_notification_poll* pNo MA_API ma_bool32 ma_async_notification_poll_is_signalled(const ma_async_notification_poll* pNotificationPoll) { - if (pNotificationPoll == NULL) { + if (pNotificationPoll == nullptr) { return MA_FALSE; } @@ -18498,7 +18498,7 @@ static void ma_async_notification_event__on_signal(ma_async_notification* pNotif MA_API ma_result ma_async_notification_event_init(ma_async_notification_event* pNotificationEvent) { - if (pNotificationEvent == NULL) { + if (pNotificationEvent == nullptr) { return MA_INVALID_ARGS; } @@ -18524,7 +18524,7 @@ MA_API ma_result ma_async_notification_event_init(ma_async_notification_event* p MA_API ma_result ma_async_notification_event_uninit(ma_async_notification_event* pNotificationEvent) { - if (pNotificationEvent == NULL) { + if (pNotificationEvent == nullptr) { return MA_INVALID_ARGS; } @@ -18542,7 +18542,7 @@ MA_API ma_result ma_async_notification_event_uninit(ma_async_notification_event* MA_API ma_result ma_async_notification_event_wait(ma_async_notification_event* pNotificationEvent) { - if (pNotificationEvent == NULL) { + if (pNotificationEvent == nullptr) { return MA_INVALID_ARGS; } @@ -18559,7 +18559,7 @@ MA_API ma_result ma_async_notification_event_wait(ma_async_notification_event* p MA_API ma_result ma_async_notification_event_signal(ma_async_notification_event* pNotificationEvent) { - if (pNotificationEvent == NULL) { + if (pNotificationEvent == nullptr) { return MA_INVALID_ARGS; } @@ -18617,11 +18617,11 @@ typedef struct static ma_result ma_slot_allocator_get_heap_layout(const ma_slot_allocator_config* pConfig, ma_slot_allocator_heap_layout* pHeapLayout) { - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -18647,7 +18647,7 @@ MA_API ma_result ma_slot_allocator_get_heap_size(const ma_slot_allocator_config* ma_result result; ma_slot_allocator_heap_layout layout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -18668,13 +18668,13 @@ MA_API ma_result ma_slot_allocator_init_preallocated(const ma_slot_allocator_con ma_result result; ma_slot_allocator_heap_layout heapLayout; - if (pAllocator == NULL) { + if (pAllocator == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pAllocator); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_INVALID_ARGS; } @@ -18706,11 +18706,11 @@ MA_API ma_result ma_slot_allocator_init(const ma_slot_allocator_config* pConfig, if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_slot_allocator_init_preallocated(pConfig, pHeap, pAllocator); @@ -18725,7 +18725,7 @@ MA_API ma_result ma_slot_allocator_init(const ma_slot_allocator_config* pConfig, MA_API void ma_slot_allocator_uninit(ma_slot_allocator* pAllocator, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocator == NULL) { + if (pAllocator == nullptr) { return; } @@ -18739,7 +18739,7 @@ MA_API ma_result ma_slot_allocator_alloc(ma_slot_allocator* pAllocator, ma_uint6 ma_uint32 iAttempt; const ma_uint32 maxAttempts = 2; /* The number of iterations to perform until returning MA_OUT_OF_MEMORY if no slots can be found. */ - if (pAllocator == NULL || pSlot == NULL) { + if (pAllocator == nullptr || pSlot == nullptr) { return MA_INVALID_ARGS; } @@ -18805,7 +18805,7 @@ MA_API ma_result ma_slot_allocator_free(ma_slot_allocator* pAllocator, ma_uint64 ma_uint32 iGroup; ma_uint32 iBit; - if (pAllocator == NULL) { + if (pAllocator == nullptr) { return MA_INVALID_ARGS; } @@ -18936,7 +18936,7 @@ static ma_job_proc g_jobVTable[MA_JOB_TYPE_COUNT] = MA_API ma_result ma_job_process(ma_job* pJob) { - if (pJob == NULL) { + if (pJob == nullptr) { return MA_INVALID_ARGS; } @@ -18949,7 +18949,7 @@ MA_API ma_result ma_job_process(ma_job* pJob) static ma_result ma_job_process__noop(ma_job* pJob) { - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); /* No-op. */ (void)pJob; @@ -18964,10 +18964,10 @@ static ma_result ma_job_process__quit(ma_job* pJob) static ma_result ma_job_process__custom(ma_job* pJob) { - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); /* No-op if there's no callback. */ - if (pJob->data.custom.proc == NULL) { + if (pJob->data.custom.proc == nullptr) { return MA_SUCCESS; } @@ -18998,11 +18998,11 @@ static ma_result ma_job_queue_get_heap_layout(const ma_job_queue_config* pConfig { ma_result result; - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -19039,7 +19039,7 @@ MA_API ma_result ma_job_queue_get_heap_size(const ma_job_queue_config* pConfig, ma_result result; ma_job_queue_heap_layout layout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -19061,7 +19061,7 @@ MA_API ma_result ma_job_queue_init_preallocated(const ma_job_queue_config* pConf ma_job_queue_heap_layout heapLayout; ma_slot_allocator_config allocatorConfig; - if (pQueue == NULL) { + if (pQueue == nullptr) { return MA_INVALID_ARGS; } @@ -19123,11 +19123,11 @@ MA_API ma_result ma_job_queue_init(const ma_job_queue_config* pConfig, const ma_ if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_job_queue_init_preallocated(pConfig, pHeap, pQueue); @@ -19142,7 +19142,7 @@ MA_API ma_result ma_job_queue_init(const ma_job_queue_config* pConfig, const ma_ MA_API void ma_job_queue_uninit(ma_job_queue* pQueue, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pQueue == NULL) { + if (pQueue == nullptr) { return; } @@ -19182,7 +19182,7 @@ MA_API ma_result ma_job_queue_post(ma_job_queue* pQueue, const ma_job* pJob) ma_uint64 tail; ma_uint64 next; - if (pQueue == NULL || pJob == NULL) { + if (pQueue == nullptr || pJob == nullptr) { return MA_INVALID_ARGS; } @@ -19249,7 +19249,7 @@ MA_API ma_result ma_job_queue_next(ma_job_queue* pQueue, ma_job* pJob) ma_uint64 tail; ma_uint64 next; - if (pQueue == NULL || pJob == NULL) { + if (pQueue == nullptr || pJob == nullptr) { return MA_INVALID_ARGS; } @@ -19359,7 +19359,7 @@ MA_API ma_handle ma_dlopen(ma_log* pLog, const char* filename) /* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */ WCHAR filenameW[4096]; if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, sizeof(filenameW)) == 0) { - handle = NULL; + handle = nullptr; } else { handle = (ma_handle)LoadPackagedLibrary(filenameW, 0); } @@ -19372,7 +19372,7 @@ MA_API ma_handle ma_dlopen(ma_log* pLog, const char* filename) I'm not considering failure to load a library an error nor a warning because seamlessly falling through to a lower-priority backend is a deliberate design choice. Instead I'm logging it as an informational message. */ - if (handle == NULL) { + if (handle == nullptr) { ma_log_postf(pLog, MA_LOG_LEVEL_INFO, "Failed to load library: %s\n", filename); } @@ -19383,7 +19383,7 @@ MA_API ma_handle ma_dlopen(ma_log* pLog, const char* filename) /* Runtime linking is disabled. */ (void)pLog; (void)filename; - return NULL; + return nullptr; } #endif } @@ -19447,7 +19447,7 @@ MA_API ma_proc ma_dlsym(ma_log* pLog, ma_handle handle, const char* symbol) } #endif - if (proc == NULL) { + if (proc == nullptr) { ma_log_postf(pLog, MA_LOG_LEVEL_WARNING, "Failed to load symbol: %s\n", symbol); } @@ -19460,7 +19460,7 @@ MA_API ma_proc ma_dlsym(ma_log* pLog, ma_handle handle, const char* symbol) (void)pLog; (void)handle; (void)symbol; - return NULL; + return nullptr; } #endif } @@ -19498,7 +19498,7 @@ DEVICE I/O MA_API void ma_device_info_add_native_data_format(ma_device_info* pDeviceInfo, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags) { - if (pDeviceInfo == NULL) { + if (pDeviceInfo == nullptr) { return; } @@ -19550,13 +19550,13 @@ MA_API ma_result ma_get_backend_from_name(const char* pBackendName, ma_backend* { size_t iBackend; - if (pBackendName == NULL) { + if (pBackendName == nullptr) { return MA_INVALID_ARGS; } for (iBackend = 0; iBackend < ma_countof(gBackendInfo); iBackend += 1) { if (ma_strcmp(pBackendName, gBackendInfo[iBackend].pName) == 0) { - if (pBackend != NULL) { + if (pBackend != nullptr) { *pBackend = gBackendInfo[iBackend].backend; } @@ -19689,7 +19689,7 @@ MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCa size_t iBackend; ma_result result = MA_SUCCESS; - if (pBackendCount == NULL) { + if (pBackendCount == nullptr) { return MA_INVALID_ARGS; } @@ -19710,7 +19710,7 @@ MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCa } } - if (pBackendCount != NULL) { + if (pBackendCount != nullptr) { *pBackendCount = backendCount; } @@ -20107,7 +20107,7 @@ Timing static MA_INLINE void ma_timer_init(ma_timer* pTimer) { struct timeval newTime; - gettimeofday(&newTime, NULL); + gettimeofday(&newTime, nullptr); pTimer->counter = ((ma_int64)newTime.tv_sec * 1000000) + newTime.tv_usec; } @@ -20118,7 +20118,7 @@ Timing ma_uint64 oldTimeCounter; struct timeval newTime; - gettimeofday(&newTime, NULL); + gettimeofday(&newTime, nullptr); newTimeCounter = ((ma_uint64)newTime.tv_sec * 1000000) + newTime.tv_usec; oldTimeCounter = pTimer->counter; @@ -20164,7 +20164,7 @@ static ma_uint32 ma_get_closest_standard_sample_rate(ma_uint32 sampleRateIn) static MA_INLINE unsigned int ma_device_disable_denormals(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (!pDevice->noDisableDenormals) { return ma_disable_denormals(); @@ -20175,7 +20175,7 @@ static MA_INLINE unsigned int ma_device_disable_denormals(ma_device* pDevice) static MA_INLINE void ma_device_restore_denormals(ma_device* pDevice, unsigned int prevState) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (!pDevice->noDisableDenormals) { ma_restore_denormals(prevState); @@ -20198,14 +20198,14 @@ static ma_device_notification ma_device_notification_init(ma_device* pDevice, ma static void ma_device__on_notification(ma_device_notification notification) { - MA_ASSERT(notification.pDevice != NULL); + MA_ASSERT(notification.pDevice != nullptr); - if (notification.pDevice->onNotification != NULL) { + if (notification.pDevice->onNotification != nullptr) { notification.pDevice->onNotification(¬ification); } /* TEMP FOR COMPATIBILITY: If it's a stopped notification, fire the onStop callback as well. This is only for backwards compatibility and will be removed. */ - if (notification.pDevice->onStop != NULL && notification.type == ma_device_notification_type_stopped) { + if (notification.pDevice->onStop != nullptr && notification.type == ma_device_notification_type_stopped) { notification.pDevice->onStop(notification.pDevice); } } @@ -20244,10 +20244,10 @@ void EMSCRIPTEN_KEEPALIVE ma_device__on_notification_unlocked(ma_device* pDevice static void ma_device__on_data_inner(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount) { - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pDevice->onData != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pDevice->onData != nullptr); - if (!pDevice->noPreSilencedOutputBuffer && pFramesOut != NULL) { + if (!pDevice->noPreSilencedOutputBuffer && pFramesOut != nullptr) { ma_silence_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels); } @@ -20256,7 +20256,7 @@ static void ma_device__on_data_inner(ma_device* pDevice, void* pFramesOut, const static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Don't read more data from the client if we're in the process of stopping. */ if (ma_device_get_state(pDevice) == ma_device_state_stopping) { @@ -20274,7 +20274,7 @@ static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void* ma_uint32 totalFramesRemaining = frameCount - totalFramesProcessed; ma_uint32 framesToProcessThisIteration = 0; - if (pFramesIn != NULL) { + if (pFramesIn != nullptr) { /* Capturing. Write to the intermediary buffer. If there's no room, fire the callback to empty it. */ if (pDevice->capture.intermediaryBufferLen < pDevice->capture.intermediaryBufferCap) { /* There's some room left in the intermediary buffer. Write to it without firing the callback. */ @@ -20297,7 +20297,7 @@ static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void* if (pDevice->type == ma_device_type_duplex) { /* We'll do the duplex data callback later after we've processed the playback data. */ } else { - ma_device__on_data_inner(pDevice, NULL, pDevice->capture.pIntermediaryBuffer, pDevice->capture.intermediaryBufferCap); + ma_device__on_data_inner(pDevice, nullptr, pDevice->capture.pIntermediaryBuffer, pDevice->capture.intermediaryBufferCap); /* The intermediary buffer has just been drained. */ pDevice->capture.intermediaryBufferLen = 0; @@ -20305,7 +20305,7 @@ static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void* } } - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { /* Playing back. Read from the intermediary buffer. If there's nothing in it, fire the callback to fill it. */ if (pDevice->playback.intermediaryBufferLen > 0) { /* There's some content in the intermediary buffer. Read from that without firing the callback. */ @@ -20332,7 +20332,7 @@ static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void* if (pDevice->type == ma_device_type_duplex) { /* In duplex mode, the data callback will be fired later. Nothing to do here. */ } else { - ma_device__on_data_inner(pDevice, pDevice->playback.pIntermediaryBuffer, NULL, pDevice->playback.intermediaryBufferCap); + ma_device__on_data_inner(pDevice, pDevice->playback.pIntermediaryBuffer, nullptr, pDevice->playback.intermediaryBufferCap); /* The intermediary buffer has just been filled. */ pDevice->playback.intermediaryBufferLen = pDevice->playback.intermediaryBufferCap; @@ -20366,7 +20366,7 @@ static void ma_device__handle_data_callback(ma_device* pDevice, void* pFramesOut unsigned int prevDenormalState = ma_device_disable_denormals(pDevice); { /* Volume control of input makes things a bit awkward because the input buffer is read-only. We'll need to use a temp buffer and loop in this case. */ - if (pFramesIn != NULL && masterVolumeFactor != 1) { + if (pFramesIn != nullptr && masterVolumeFactor != 1) { ma_uint8 tempFramesIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 bpfCapture = ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels); ma_uint32 bpfPlayback = ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); @@ -20388,9 +20388,9 @@ static void ma_device__handle_data_callback(ma_device* pDevice, void* pFramesOut } /* Volume control and clipping for playback devices. */ - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { if (masterVolumeFactor != 1) { - if (pFramesIn == NULL) { /* <-- In full-duplex situations, the volume will have been applied to the input samples before the data callback. Applying it again post-callback will incorrectly compound it. */ + if (pFramesIn == nullptr) { /* <-- In full-duplex situations, the volume will have been applied to the input samples before the data callback. Applying it again post-callback will incorrectly compound it. */ ma_apply_volume_factor_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels, masterVolumeFactor); } } @@ -20403,7 +20403,7 @@ static void ma_device__handle_data_callback(ma_device* pDevice, void* pFramesOut ma_device_restore_denormals(pDevice, prevDenormalState); } else { /* No data callback. Just silence the output. */ - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { ma_silence_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels); } } @@ -20414,12 +20414,12 @@ static void ma_device__handle_data_callback(ma_device* pDevice, void* pFramesOut /* A helper function for reading sample data from the client. */ static void ma_device__read_frames_from_client(ma_device* pDevice, ma_uint32 frameCount, void* pFramesOut) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(frameCount > 0); - MA_ASSERT(pFramesOut != NULL); + MA_ASSERT(pFramesOut != nullptr); if (pDevice->playback.converter.isPassthrough) { - ma_device__handle_data_callback(pDevice, pFramesOut, NULL, frameCount); + ma_device__handle_data_callback(pDevice, pFramesOut, nullptr, frameCount); } else { ma_result result; ma_uint64 totalFramesReadOut; @@ -20433,7 +20433,7 @@ static void ma_device__read_frames_from_client(ma_device* pDevice, ma_uint32 fra buffer for caching input data. This will be the case if the data converter does not have the ability to retrieve the required input frame count for a given output frame count. */ - if (pDevice->playback.pInputCache != NULL) { + if (pDevice->playback.pInputCache != nullptr) { while (totalFramesReadOut < frameCount) { ma_uint64 framesToReadThisIterationIn; ma_uint64 framesToReadThisIterationOut; @@ -20464,7 +20464,7 @@ static void ma_device__read_frames_from_client(ma_device* pDevice, ma_uint32 fra /* Getting here means there's no data in the cache and we need to fill it up with data from the client. */ if (pDevice->playback.inputCacheRemaining == 0) { - ma_device__handle_data_callback(pDevice, pDevice->playback.pInputCache, NULL, (ma_uint32)pDevice->playback.inputCacheCap); + ma_device__handle_data_callback(pDevice, pDevice->playback.pInputCache, nullptr, (ma_uint32)pDevice->playback.inputCacheCap); pDevice->playback.inputCacheConsumed = 0; pDevice->playback.inputCacheRemaining = pDevice->playback.inputCacheCap; @@ -20491,7 +20491,7 @@ static void ma_device__read_frames_from_client(ma_device* pDevice, ma_uint32 fra framesToReadThisIterationIn = requiredInputFrameCount; } - ma_device__handle_data_callback(pDevice, pIntermediaryBuffer, NULL, (ma_uint32)framesToReadThisIterationIn); + ma_device__handle_data_callback(pDevice, pIntermediaryBuffer, nullptr, (ma_uint32)framesToReadThisIterationIn); /* At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any @@ -20518,12 +20518,12 @@ static void ma_device__read_frames_from_client(ma_device* pDevice, ma_uint32 fra /* A helper for sending sample data to the client. */ static void ma_device__send_frames_to_client(ma_device* pDevice, ma_uint32 frameCountInDeviceFormat, const void* pFramesInDeviceFormat) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(frameCountInDeviceFormat > 0); - MA_ASSERT(pFramesInDeviceFormat != NULL); + MA_ASSERT(pFramesInDeviceFormat != nullptr); if (pDevice->capture.converter.isPassthrough) { - ma_device__handle_data_callback(pDevice, NULL, pFramesInDeviceFormat, frameCountInDeviceFormat); + ma_device__handle_data_callback(pDevice, nullptr, pFramesInDeviceFormat, frameCountInDeviceFormat); } else { ma_result result; ma_uint8 pFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; @@ -20546,7 +20546,7 @@ static void ma_device__send_frames_to_client(ma_device* pDevice, ma_uint32 frame } if (clientFramesProcessedThisIteration > 0) { - ma_device__handle_data_callback(pDevice, NULL, pFramesInClientFormat, (ma_uint32)clientFramesProcessedThisIteration); /* Safe cast. */ + ma_device__handle_data_callback(pDevice, nullptr, pFramesInClientFormat, (ma_uint32)clientFramesProcessedThisIteration); /* Safe cast. */ } pRunningFramesInDeviceFormat = ma_offset_ptr(pRunningFramesInDeviceFormat, deviceFramesProcessedThisIteration * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); @@ -20569,10 +20569,10 @@ static ma_result ma_device__handle_duplex_callback_capture(ma_device* pDevice, m ma_uint32 totalDeviceFramesProcessed = 0; const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(frameCountInDeviceFormat > 0); - MA_ASSERT(pFramesInDeviceFormat != NULL); - MA_ASSERT(pRB != NULL); + MA_ASSERT(pFramesInDeviceFormat != nullptr); + MA_ASSERT(pRB != nullptr); /* Write to the ring buffer. The ring buffer is in the client format which means we need to convert. */ for (;;) { @@ -20626,11 +20626,11 @@ static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice, ma_uint8 silentInputFrames[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 totalFramesReadOut = 0; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(frameCount > 0); - MA_ASSERT(pFramesInInternalFormat != NULL); - MA_ASSERT(pRB != NULL); - MA_ASSERT(pDevice->playback.pInputCache != NULL); + MA_ASSERT(pFramesInInternalFormat != nullptr); + MA_ASSERT(pRB != nullptr); + MA_ASSERT(pDevice->playback.pInputCache != nullptr); /* Sitting in the ring buffer should be captured data from the capture callback in external format. If there's not enough data in there for @@ -20714,7 +20714,7 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d static ma_bool32 ma_device_descriptor_is_valid(const ma_device_descriptor* pDeviceDescriptor) { - if (pDeviceDescriptor == NULL) { + if (pDeviceDescriptor == nullptr) { return MA_FALSE; } @@ -20743,11 +20743,11 @@ static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice) ma_uint32 capturedDeviceDataCapInFrames = 0; ma_uint32 playbackDeviceDataCapInFrames = 0; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Just some quick validation on the device type and the available callbacks. */ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { - if (pDevice->pContext->callbacks.onDeviceRead == NULL) { + if (pDevice->pContext->callbacks.onDeviceRead == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -20755,7 +20755,7 @@ static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice) } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { - if (pDevice->pContext->callbacks.onDeviceWrite == NULL) { + if (pDevice->pContext->callbacks.onDeviceWrite == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -20828,7 +20828,7 @@ static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice) break; } - result = pDevice->pContext->callbacks.onDeviceWrite(pDevice, playbackDeviceData, (ma_uint32)convertedDeviceFrameCount, NULL); /* Safe cast. */ + result = pDevice->pContext->callbacks.onDeviceWrite(pDevice, playbackDeviceData, (ma_uint32)convertedDeviceFrameCount, nullptr); /* Safe cast. */ if (result != MA_SUCCESS) { exitLoop = MA_TRUE; break; @@ -20941,7 +20941,7 @@ Null Backend static ma_thread_result MA_THREADCALL ma_device_thread__null(void* pData) { ma_device* pDevice = (ma_device*)pData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); for (;;) { /* Keep the thread alive until the device is uninitialized. */ ma_uint32 operation; @@ -21052,14 +21052,14 @@ static ma_result ma_context_enumerate_devices__null(ma_context* pContext, ma_enu { ma_bool32 cbResult = MA_TRUE; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); /* Playback. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); - ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "NULL Playback Device", (size_t)-1); + ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "nullptr Playback Device", (size_t)-1); deviceInfo.isDefault = MA_TRUE; /* Only one playback and capture device for the null backend, so might as well mark as default. */ cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } @@ -21068,7 +21068,7 @@ static ma_result ma_context_enumerate_devices__null(ma_context* pContext, ma_enu if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); - ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "NULL Capture Device", (size_t)-1); + ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "nullptr Capture Device", (size_t)-1); deviceInfo.isDefault = MA_TRUE; /* Only one playback and capture device for the null backend, so might as well mark as default. */ cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } @@ -21080,17 +21080,17 @@ static ma_result ma_context_enumerate_devices__null(ma_context* pContext, ma_enu static ma_result ma_context_get_device_info__null(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); - if (pDeviceID != NULL && pDeviceID->nullbackend != 0) { + if (pDeviceID != nullptr && pDeviceID->nullbackend != 0) { return MA_NO_DEVICE; /* Don't know the device. */ } /* Name / Description */ if (deviceType == ma_device_type_playback) { - ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "NULL Playback Device", (size_t)-1); + ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "nullptr Playback Device", (size_t)-1); } else { - ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "NULL Capture Device", (size_t)-1); + ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "nullptr Capture Device", (size_t)-1); } pDeviceInfo->isDefault = MA_TRUE; /* Only one playback and capture device for the null backend, so might as well mark as default. */ @@ -21109,7 +21109,7 @@ static ma_result ma_context_get_device_info__null(ma_context* pContext, ma_devic static ma_result ma_device_uninit__null(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Keep it clean and wait for the device thread to finish before returning. */ ma_device_do_operation__null(pDevice, MA_DEVICE_OP_KILL__NULL); @@ -21129,7 +21129,7 @@ static ma_result ma_device_init__null(ma_device* pDevice, const ma_device_config { ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->null_device); @@ -21191,7 +21191,7 @@ static ma_result ma_device_init__null(ma_device* pDevice, const ma_device_config static ma_result ma_device_start__null(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_device_do_operation__null(pDevice, MA_DEVICE_OP_START__NULL); @@ -21201,7 +21201,7 @@ static ma_result ma_device_start__null(ma_device* pDevice) static ma_result ma_device_stop__null(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_device_do_operation__null(pDevice, MA_DEVICE_OP_SUSPEND__NULL); @@ -21211,7 +21211,7 @@ static ma_result ma_device_stop__null(ma_device* pDevice) static ma_bool32 ma_device_is_started__null(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); return ma_atomic_bool32_get(&pDevice->null_device.isStarted); } @@ -21222,7 +21222,7 @@ static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrame ma_uint32 totalPCMFramesProcessed; ma_bool32 wasStartedOnEntry; - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = 0; } @@ -21289,7 +21289,7 @@ static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrame pDevice->null_device.currentPeriodFramesRemainingPlayback = pDevice->playback.internalPeriodSizeInFrames; } - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = totalPCMFramesProcessed; } @@ -21301,7 +21301,7 @@ static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_u ma_result result = MA_SUCCESS; ma_uint32 totalPCMFramesProcessed; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -21360,7 +21360,7 @@ static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_u pDevice->null_device.currentPeriodFramesRemainingCapture = pDevice->capture.internalPeriodSizeInFrames; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalPCMFramesProcessed; } @@ -21369,7 +21369,7 @@ static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_u static ma_result ma_context_uninit__null(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_null); (void)pContext; @@ -21378,7 +21378,7 @@ static ma_result ma_context_uninit__null(ma_context* pContext) static ma_result ma_context_init__null(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); (void)pConfig; (void)pContext; @@ -21393,7 +21393,7 @@ static ma_result ma_context_init__null(ma_context* pContext, const ma_context_co pCallbacks->onDeviceStop = ma_device_stop__null; pCallbacks->onDeviceRead = ma_device_read__null; pCallbacks->onDeviceWrite = ma_device_write__null; - pCallbacks->onDeviceDataLoop = NULL; /* Our backend is asynchronous with a blocking read-write API which means we can get miniaudio to deal with the audio thread. */ + pCallbacks->onDeviceDataLoop = nullptr; /* Our backend is asynchronous with a blocking read-write API which means we can get miniaudio to deal with the audio thread. */ /* The null backend always works. */ return MA_SUCCESS; @@ -21637,7 +21637,7 @@ static MA_INLINE ma_bool32 ma_is_guid_null(const void* guid) static ma_format ma_format_from_WAVEFORMATEX(const MA_WAVEFORMATEX* pWF) { - MA_ASSERT(pWF != NULL); + MA_ASSERT(pWF != nullptr); if (pWF->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { const MA_WAVEFORMATEXTENSIBLE* pWFEX = (const MA_WAVEFORMATEXTENSIBLE*)pWF; @@ -22262,7 +22262,7 @@ static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_QueryInterface(ma_com "implement" this, we just make sure we return pThis when the IAgileObject is requested. */ if (!ma_is_guid_equal(riid, &MA_IID_IUnknown) && !ma_is_guid_equal(riid, &MA_IID_IActivateAudioInterfaceCompletionHandler) && !ma_is_guid_equal(riid, &MA_IID_IAgileObject)) { - *ppObject = NULL; + *ppObject = nullptr; return E_NOINTERFACE; } @@ -22304,13 +22304,13 @@ static ma_completion_handler_uwp_vtbl g_maCompletionHandlerVtblInstance = { static ma_result ma_completion_handler_uwp_init(ma_completion_handler_uwp* pHandler) { - MA_ASSERT(pHandler != NULL); + MA_ASSERT(pHandler != nullptr); MA_ZERO_OBJECT(pHandler); pHandler->lpVtbl = &g_maCompletionHandlerVtblInstance; pHandler->counter = 1; - pHandler->hEvent = CreateEventA(NULL, FALSE, FALSE, NULL); - if (pHandler->hEvent == NULL) { + pHandler->hEvent = CreateEventA(nullptr, FALSE, FALSE, nullptr); + if (pHandler->hEvent == nullptr) { return ma_result_from_GetLastError(GetLastError()); } @@ -22319,7 +22319,7 @@ static ma_result ma_completion_handler_uwp_init(ma_completion_handler_uwp* pHand static void ma_completion_handler_uwp_uninit(ma_completion_handler_uwp* pHandler) { - if (pHandler->hEvent != NULL) { + if (pHandler->hEvent != nullptr) { CloseHandle(pHandler->hEvent); } } @@ -22339,7 +22339,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_QueryInterface(ma_IMMN we just return E_NOINTERFACE. Otherwise we need to increment the reference counter and return S_OK. */ if (!ma_is_guid_equal(riid, &MA_IID_IUnknown) && !ma_is_guid_equal(riid, &MA_IID_IMMNotificationClient)) { - *ppObject = NULL; + *ppObject = nullptr; return E_NOINTERFACE; } @@ -22371,7 +22371,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(m ma_bool32 isPlayback = MA_FALSE; #ifdef MA_DEBUG_OUTPUT - /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceStateChanged(pDeviceID=%S, dwNewState=%u)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)", (unsigned int)dwNewState);*/ + /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceStateChanged(pDeviceID=%S, dwNewState=%u)\n", (pDeviceID != nullptr) ? pDeviceID : L"(nullptr)", (unsigned int)dwNewState);*/ #endif /* @@ -22451,7 +22451,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(m static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceAdded(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID) { #ifdef MA_DEBUG_OUTPUT - /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceAdded(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/ + /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceAdded(pDeviceID=%S)\n", (pDeviceID != nullptr) ? pDeviceID : L"(nullptr)");*/ #endif /* We don't need to worry about this event for our purposes. */ @@ -22463,7 +22463,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceAdded(ma_IMMNo static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID) { #ifdef MA_DEBUG_OUTPUT - /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceRemoved(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/ + /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceRemoved(pDeviceID=%S)\n", (pDeviceID != nullptr) ? pDeviceID : L"(nullptr)");*/ #endif /* We don't need to worry about this event for our purposes. */ @@ -22475,7 +22475,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMM static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, const WCHAR* pDefaultDeviceID) { #ifdef MA_DEBUG_OUTPUT - /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != NULL) ? pDefaultDeviceID : L"(NULL)");*/ + /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != nullptr) ? pDefaultDeviceID : L"(nullptr)");*/ #endif (void)role; @@ -22532,7 +22532,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged restartDevice = MA_TRUE; } - if (pDefaultDeviceID != NULL) { /* <-- The input device ID will be null if there's no other device available. */ + if (pDefaultDeviceID != nullptr) { /* <-- The input device ID will be null if there's no other device available. */ ma_mutex_lock(&pThis->pDevice->wasapi.rerouteLock); { if (dataFlow == ma_eRender) { @@ -22578,7 +22578,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnPropertyValueChanged(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, const PROPERTYKEY key) { #ifdef MA_DEBUG_OUTPUT - /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnPropertyValueChanged(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/ + /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnPropertyValueChanged(pDeviceID=%S)\n", (pDeviceID != nullptr) ? pDeviceID : L"(nullptr)");*/ #endif (void)pThis; @@ -22603,13 +22603,13 @@ static const char* ma_to_usage_string__wasapi(ma_wasapi_usage usage) { switch (usage) { - case ma_wasapi_usage_default: return NULL; + case ma_wasapi_usage_default: return nullptr; case ma_wasapi_usage_games: return "Games"; case ma_wasapi_usage_pro_audio: return "Pro Audio"; default: break; } - return NULL; + return nullptr; } #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) @@ -22640,10 +22640,10 @@ static ma_result ma_context_post_command__wasapi(ma_context* pContext, const ma_ ma_bool32 isUsingLocalEvent = MA_FALSE; ma_event localEvent; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pCmd != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pCmd != nullptr); - if (pCmd->pEvent == NULL) { + if (pCmd->pEvent == nullptr) { isUsingLocalEvent = MA_TRUE; result = ma_event_init(&localEvent); @@ -22685,8 +22685,8 @@ static ma_result ma_context_next_command__wasapi(ma_context* pContext, ma_contex { ma_result result = MA_SUCCESS; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pCmd != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pCmd != nullptr); result = ma_semaphore_wait(&pContext->wasapi.commandSem); if (result == MA_SUCCESS) { @@ -22706,7 +22706,7 @@ static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pU { ma_result result; ma_context* pContext = (ma_context*)pUserData; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); for (;;) { ma_context_command__wasapi cmd; @@ -22734,16 +22734,16 @@ static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pU case MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI: { if (cmd.data.releaseAudioClient.deviceType == ma_device_type_playback) { - if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback != NULL) { + if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback != nullptr) { ma_IAudioClient_Release((ma_IAudioClient*)cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback); - cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback = NULL; + cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback = nullptr; } } if (cmd.data.releaseAudioClient.deviceType == ma_device_type_capture) { - if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture != NULL) { + if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture != nullptr) { ma_IAudioClient_Release((ma_IAudioClient*)cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture); - cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture = NULL; + cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture = nullptr; } } } break; @@ -22755,7 +22755,7 @@ static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pU } break; } - if (cmd.pEvent != NULL) { + if (cmd.pEvent != nullptr) { ma_event_signal(cmd.pEvent); } @@ -22805,8 +22805,8 @@ static ma_result ma_device_release_IAudioClient_service__wasapi(ma_device* pDevi static void ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(const MA_WAVEFORMATEX* pWF, ma_share_mode shareMode, ma_device_info* pInfo) { - MA_ASSERT(pWF != NULL); - MA_ASSERT(pInfo != NULL); + MA_ASSERT(pWF != nullptr); + MA_ASSERT(pInfo != nullptr); if (pInfo->nativeDataFormatCount >= ma_countof(pInfo->nativeDataFormats)) { return; /* Too many data formats. Need to ignore this one. Don't think this should ever happen with WASAPI. */ @@ -22822,10 +22822,10 @@ static void ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(const MA_ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context* pContext, /*ma_IMMDevice**/void* pMMDevice, ma_IAudioClient* pAudioClient, ma_device_info* pInfo) { HRESULT hr; - MA_WAVEFORMATEX* pWF = NULL; + MA_WAVEFORMATEX* pWF = nullptr; - MA_ASSERT(pAudioClient != NULL); - MA_ASSERT(pInfo != NULL); + MA_ASSERT(pAudioClient != nullptr); + MA_ASSERT(pInfo != nullptr); /* Shared Mode. We use GetMixFormat() here. */ hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pAudioClient, (MA_WAVEFORMATEX**)&pWF); @@ -22862,7 +22862,7 @@ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context In my testing, the format returned by PKEY_AudioEngine_DeviceFormat is suitable for exclusive mode so we check this format first. If this fails, fall back to a search. */ - hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pWF, NULL); + hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pWF, nullptr); if (SUCCEEDED(hr)) { /* The format returned by PKEY_AudioEngine_DeviceFormat is supported. */ ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(pWF, ma_share_mode_exclusive, pInfo); @@ -22908,7 +22908,7 @@ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); ++iSampleRate) { wf.nSamplesPerSec = g_maStandardSampleRatePriorities[iSampleRate]; - hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, (MA_WAVEFORMATEX*)&wf, NULL); + hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, (MA_WAVEFORMATEX*)&wf, nullptr); if (SUCCEEDED(hr)) { ma_add_native_data_format_to_device_info_from_WAVEFORMATEX((MA_WAVEFORMATEX*)&wf, ma_share_mode_exclusive, pInfo); found = MA_TRUE; @@ -22963,12 +22963,12 @@ static ma_result ma_context_create_IMMDeviceEnumerator__wasapi(ma_context* pCont HRESULT hr; ma_IMMDeviceEnumerator* pDeviceEnumerator; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppDeviceEnumerator != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppDeviceEnumerator != nullptr); - *ppDeviceEnumerator = NULL; /* Safety. */ + *ppDeviceEnumerator = nullptr; /* Safety. */ - hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); + hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator."); return ma_result_from_HRESULT(hr); @@ -22982,13 +22982,13 @@ static ma_result ma_context_create_IMMDeviceEnumerator__wasapi(ma_context* pCont static WCHAR* ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType) { HRESULT hr; - ma_IMMDevice* pMMDefaultDevice = NULL; - WCHAR* pDefaultDeviceID = NULL; + ma_IMMDevice* pMMDefaultDevice = nullptr; + WCHAR* pDefaultDeviceID = nullptr; ma_EDataFlow dataFlow; ma_ERole role; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pDeviceEnumerator != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pDeviceEnumerator != nullptr); (void)pContext; @@ -23000,16 +23000,16 @@ static WCHAR* ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi( hr = ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(pDeviceEnumerator, dataFlow, role, &pMMDefaultDevice); if (FAILED(hr)) { - return NULL; + return nullptr; } hr = ma_IMMDevice_GetId(pMMDefaultDevice, &pDefaultDeviceID); ma_IMMDevice_Release(pMMDefaultDevice); - pMMDefaultDevice = NULL; + pMMDefaultDevice = nullptr; if (FAILED(hr)) { - return NULL; + return nullptr; } return pDefaultDeviceID; @@ -23019,13 +23019,13 @@ static WCHAR* ma_context_get_default_device_id__wasapi(ma_context* pContext, ma_ { ma_result result; ma_IMMDeviceEnumerator* pDeviceEnumerator; - WCHAR* pDefaultDeviceID = NULL; + WCHAR* pDefaultDeviceID = nullptr; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); result = ma_context_create_IMMDeviceEnumerator__wasapi(pContext, &pDeviceEnumerator); if (result != MA_SUCCESS) { - return NULL; + return nullptr; } pDefaultDeviceID = ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(pContext, pDeviceEnumerator, deviceType); @@ -23040,8 +23040,8 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device HRESULT hr; HRESULT CoInitializeResult; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppMMDevice != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppMMDevice != nullptr); /* This weird COM init/uninit here is a hack to work around a crash when changing devices. What is happening is @@ -23058,9 +23058,9 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device called with a different COINIT value, and we don't call CoUninitialize in that case. Other errors are possible, so we check for S_OK and S_FALSE specifically. */ - CoInitializeResult = ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE); + CoInitializeResult = ma_CoInitializeEx(pContext, nullptr, MA_COINIT_VALUE); { - hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); + hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); } if (CoInitializeResult == S_OK || CoInitializeResult == S_FALSE) { ma_CoUninitialize(pContext); } @@ -23069,7 +23069,7 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device return ma_result_from_HRESULT(hr); } - if (pDeviceID == NULL) { + if (pDeviceID == nullptr) { hr = ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(pDeviceEnumerator, (deviceType == ma_device_type_capture) ? ma_eCapture : ma_eRender, ma_eConsole, ppMMDevice); } else { hr = ma_IMMDeviceEnumerator_GetDevice(pDeviceEnumerator, pDeviceID->wasapi, ppMMDevice); @@ -23089,7 +23089,7 @@ static ma_result ma_context_get_device_id_from_MMDevice__wasapi(ma_context* pCon WCHAR* pDeviceIDString; HRESULT hr; - MA_ASSERT(pDeviceID != NULL); + MA_ASSERT(pDeviceID != nullptr); hr = ma_IMMDevice_GetId(pMMDevice, &pDeviceIDString); if (SUCCEEDED(hr)) { @@ -23116,14 +23116,14 @@ static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pC ma_result result; HRESULT hr; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pMMDevice != NULL); - MA_ASSERT(pInfo != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pMMDevice != nullptr); + MA_ASSERT(pInfo != nullptr); /* ID. */ result = ma_context_get_device_id_from_MMDevice__wasapi(pContext, pMMDevice, &pInfo->id); if (result == MA_SUCCESS) { - if (pDefaultDeviceID != NULL) { + if (pDefaultDeviceID != nullptr) { if (ma_strcmp_WCHAR(pInfo->id.wasapi, pDefaultDeviceID) == 0) { pInfo->isDefault = MA_TRUE; } @@ -23151,7 +23151,7 @@ static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pC /* Format */ if (!onlySimpleInfo) { ma_IAudioClient* pAudioClient; - hr = ma_IMMDevice_Activate(pMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient); + hr = ma_IMMDevice_Activate(pMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, nullptr, (void**)&pAudioClient); if (SUCCEEDED(hr)) { result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, pMMDevice, pAudioClient, pInfo); @@ -23172,11 +23172,11 @@ static ma_result ma_context_enumerate_devices_by_type__wasapi(ma_context* pConte UINT deviceCount; HRESULT hr; ma_uint32 iDevice; - WCHAR* pDefaultDeviceID = NULL; - ma_IMMDeviceCollection* pDeviceCollection = NULL; + WCHAR* pDefaultDeviceID = nullptr; + ma_IMMDeviceCollection* pDeviceCollection = nullptr; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); /* Grab the default device. We use this to know whether or not flag the returned device info as being the default. */ pDefaultDeviceID = ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(pContext, pDeviceEnumerator, deviceType); @@ -23213,14 +23213,14 @@ static ma_result ma_context_enumerate_devices_by_type__wasapi(ma_context* pConte } done: - if (pDefaultDeviceID != NULL) { + if (pDefaultDeviceID != nullptr) { ma_CoTaskMemFree(pContext, pDefaultDeviceID); - pDefaultDeviceID = NULL; + pDefaultDeviceID = nullptr; } - if (pDeviceCollection != NULL) { + if (pDeviceCollection != nullptr) { ma_IMMDeviceCollection_Release(pDeviceCollection); - pDeviceCollection = NULL; + pDeviceCollection = nullptr; } return result; @@ -23231,9 +23231,9 @@ static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContex ma_result result; HRESULT hr; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppAudioClient != NULL); - MA_ASSERT(ppMMDevice != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppAudioClient != nullptr); + MA_ASSERT(ppMMDevice != nullptr); result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, ppMMDevice); if (result != MA_SUCCESS) { @@ -23250,7 +23250,7 @@ static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContex #else static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, MA_PROPVARIANT* pActivationParams, ma_IAudioClient** ppAudioClient, ma_IUnknown** ppActivatedInterface) { - ma_IActivateAudioInterfaceAsyncOperation *pAsyncOp = NULL; + ma_IActivateAudioInterfaceAsyncOperation *pAsyncOp = nullptr; ma_completion_handler_uwp completionHandler; IID iid; WCHAR* iidStr; @@ -23259,10 +23259,10 @@ static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, m HRESULT activateResult; ma_IUnknown* pActivatedInterface; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppAudioClient != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppAudioClient != nullptr); - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { iidStr = (WCHAR*)pDeviceID->wasapi; } else { if (deviceType == ma_device_type_capture) { @@ -23297,7 +23297,7 @@ static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, m return ma_result_from_HRESULT(hr); } - if (pDeviceID == NULL) { + if (pDeviceID == nullptr) { ma_CoTaskMemFree(pContext, iidStr); } @@ -23385,11 +23385,11 @@ static ma_result ma_context_get_IAudioClient__wasapi(ma_context* pContext, ma_de ma_bool32 usingProcessLoopback = MA_FALSE; MA_AUDIOCLIENT_ACTIVATION_PARAMS audioclientActivationParams; MA_PROPVARIANT activationParams; - MA_PROPVARIANT* pActivationParams = NULL; + MA_PROPVARIANT* pActivationParams = nullptr; ma_device_id virtualDeviceID; /* Activation parameters specific to loopback mode. Note that process-specific loopback will only work when a default device ID is specified. */ - if (deviceType == ma_device_type_loopback && loopbackProcessID != 0 && pDeviceID == NULL) { + if (deviceType == ma_device_type_loopback && loopbackProcessID != 0 && pDeviceID == nullptr) { usingProcessLoopback = MA_TRUE; } @@ -23409,7 +23409,7 @@ static ma_result ma_context_get_IAudioClient__wasapi(ma_context* pContext, ma_de MA_COPY_MEMORY(virtualDeviceID.wasapi, MA_VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK, (ma_wcslen(MA_VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK) + 1) * sizeof(wchar_t)); /* +1 for the null terminator. */ pDeviceID = &virtualDeviceID; } else { - pActivationParams = NULL; /* No activation parameters required. */ + pActivationParams = nullptr; /* No activation parameters required. */ } #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) @@ -23441,7 +23441,7 @@ static ma_result ma_context_enumerate_devices__wasapi(ma_context* pContext, ma_e HRESULT hr; ma_IMMDeviceEnumerator* pDeviceEnumerator; - hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); + hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator."); return ma_result_from_HRESULT(hr); @@ -23490,8 +23490,8 @@ static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_dev { #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) ma_result result; - ma_IMMDevice* pMMDevice = NULL; - WCHAR* pDefaultDeviceID = NULL; + ma_IMMDevice* pMMDevice = nullptr; + WCHAR* pDefaultDeviceID = nullptr; result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, &pMMDevice); if (result != MA_SUCCESS) { @@ -23503,9 +23503,9 @@ static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_dev result = ma_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, pDefaultDeviceID, MA_FALSE, pDeviceInfo); /* MA_FALSE = !onlySimpleInfo. */ - if (pDefaultDeviceID != NULL) { + if (pDefaultDeviceID != nullptr) { ma_CoTaskMemFree(pContext, pDefaultDeviceID); - pDefaultDeviceID = NULL; + pDefaultDeviceID = nullptr; } ma_IMMDevice_Release(pMMDevice); @@ -23522,12 +23522,12 @@ static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_dev ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } - result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, NULL, &pAudioClient, NULL); + result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, nullptr, &pAudioClient, nullptr); if (result != MA_SUCCESS) { return result; } - result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, NULL, pAudioClient, pDeviceInfo); + result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, nullptr, pAudioClient, pDeviceInfo); pDeviceInfo->isDefault = MA_TRUE; /* UWP only supports default devices. */ @@ -23538,7 +23538,7 @@ static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_dev static ma_result ma_device_uninit__wasapi(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) { @@ -23552,9 +23552,9 @@ static ma_result ma_device_uninit__wasapi(ma_device* pDevice) #endif if (pDevice->wasapi.pRenderClient) { - if (pDevice->wasapi.pMappedBufferPlayback != NULL) { + if (pDevice->wasapi.pMappedBufferPlayback != nullptr) { ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, pDevice->wasapi.mappedBufferPlaybackCap, 0); - pDevice->wasapi.pMappedBufferPlayback = NULL; + pDevice->wasapi.pMappedBufferPlayback = nullptr; pDevice->wasapi.mappedBufferPlaybackCap = 0; pDevice->wasapi.mappedBufferPlaybackLen = 0; } @@ -23562,9 +23562,9 @@ static ma_result ma_device_uninit__wasapi(ma_device* pDevice) ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient); } if (pDevice->wasapi.pCaptureClient) { - if (pDevice->wasapi.pMappedBufferCapture != NULL) { + if (pDevice->wasapi.pMappedBufferCapture != nullptr) { ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); - pDevice->wasapi.pMappedBufferCapture = NULL; + pDevice->wasapi.pMappedBufferCapture = nullptr; pDevice->wasapi.mappedBufferCaptureCap = 0; pDevice->wasapi.mappedBufferCaptureLen = 0; } @@ -23633,24 +23633,24 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device MA_REFERENCE_TIME periodDurationInMicroseconds; ma_bool32 wasInitializedUsingIAudioClient3 = MA_FALSE; MA_WAVEFORMATEXTENSIBLE wf; - ma_WASAPIDeviceInterface* pDeviceInterface = NULL; + ma_WASAPIDeviceInterface* pDeviceInterface = nullptr; ma_IAudioClient2* pAudioClient2; ma_uint32 nativeSampleRate; ma_bool32 usingProcessLoopback = MA_FALSE; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pData != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pData != nullptr); /* This function is only used to initialize one device type: either playback, capture or loopback. Never full-duplex. */ if (deviceType == ma_device_type_duplex) { return MA_INVALID_ARGS; } - usingProcessLoopback = deviceType == ma_device_type_loopback && pData->loopbackProcessID != 0 && pDeviceID == NULL; + usingProcessLoopback = deviceType == ma_device_type_loopback && pData->loopbackProcessID != 0 && pDeviceID == nullptr; - pData->pAudioClient = NULL; - pData->pRenderClient = NULL; - pData->pCaptureClient = NULL; + pData->pAudioClient = nullptr; + pData->pRenderClient = nullptr; + pData->pCaptureClient = nullptr; streamFlags = MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK; if (!pData->noAutoConvertSRC && pData->sampleRateIn != 0 && pData->shareMode != ma_share_mode_exclusive) { /* <-- Exclusive streams must use the native sample rate. */ @@ -23694,7 +23694,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device if (pData->shareMode == ma_share_mode_exclusive) { #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) /* In exclusive mode on desktop we always use the backend's native format. */ - ma_IPropertyStore* pStore = NULL; + ma_IPropertyStore* pStore = nullptr; hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pStore); if (SUCCEEDED(hr)) { MA_PROPVARIANT prop; @@ -23702,7 +23702,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device hr = ma_IPropertyStore_GetValue(pStore, &MA_PKEY_AudioEngine_DeviceFormat, &prop); if (SUCCEEDED(hr)) { MA_WAVEFORMATEX* pActualFormat = (MA_WAVEFORMATEX*)prop.blob.pBlobData; - hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pData->pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pActualFormat, NULL); + hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pData->pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pActualFormat, nullptr); if (SUCCEEDED(hr)) { MA_COPY_MEMORY(&wf, pActualFormat, sizeof(MA_WAVEFORMATEXTENSIBLE)); } @@ -23731,7 +23731,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device } } else { /* In shared mode we are always using the format reported by the operating system. */ - MA_WAVEFORMATEXTENSIBLE* pNativeFormat = NULL; + MA_WAVEFORMATEXTENSIBLE* pNativeFormat = nullptr; hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pData->pAudioClient, (MA_WAVEFORMATEX**)&pNativeFormat); if (hr != S_OK) { /* When using process-specific loopback, GetMixFormat() seems to always fail. */ @@ -23855,7 +23855,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device */ hr = E_FAIL; for (;;) { - hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, NULL); + hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, nullptr); if (hr == MA_AUDCLNT_E_INVALID_DEVICE_PERIOD) { if (bufferDuration > 500*10000) { break; @@ -23882,13 +23882,13 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient); #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) - hr = ma_IMMDevice_Activate(pDeviceInterface, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pData->pAudioClient); + hr = ma_IMMDevice_Activate(pDeviceInterface, &MA_IID_IAudioClient, CLSCTX_ALL, nullptr, (void**)&pData->pAudioClient); #else hr = ma_IUnknown_QueryInterface(pDeviceInterface, &MA_IID_IAudioClient, (void**)&pData->pAudioClient); #endif if (SUCCEEDED(hr)) { - hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, NULL); + hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, nullptr); } } } @@ -23920,7 +23920,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device #ifndef MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE { if ((streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) == 0 || nativeSampleRate == wf.nSamplesPerSec) { - ma_IAudioClient3* pAudioClient3 = NULL; + ma_IAudioClient3* pAudioClient3 = nullptr; hr = ma_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient3, (void**)&pAudioClient3); if (SUCCEEDED(hr)) { ma_uint32 defaultPeriodInFrames; @@ -23951,7 +23951,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY must not be in the stream flags. If either of these are specified, IAudioClient3_InitializeSharedAudioStream() will fail. */ - hr = ma_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, streamFlags & ~(MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY), actualPeriodInFrames, (MA_WAVEFORMATEX*)&wf, NULL); + hr = ma_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, streamFlags & ~(MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY), actualPeriodInFrames, (MA_WAVEFORMATEX*)&wf, nullptr); if (SUCCEEDED(hr)) { wasInitializedUsingIAudioClient3 = MA_TRUE; pData->periodSizeInFramesOut = actualPeriodInFrames; @@ -23969,7 +23969,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device } ma_IAudioClient3_Release(pAudioClient3); - pAudioClient3 = NULL; + pAudioClient3 = nullptr; } } } @@ -23982,7 +23982,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device /* If we don't have an IAudioClient3 then we need to use the normal initialization routine. */ if (!wasInitializedUsingIAudioClient3) { MA_REFERENCE_TIME bufferDuration = periodDurationInMicroseconds * pData->periodsOut * 10; /* <-- Multiply by 10 for microseconds to 100-nanoseconds. */ - hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, 0, (const MA_WAVEFORMATEX*)&wf, NULL); + hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, 0, (const MA_WAVEFORMATEX*)&wf, nullptr); if (FAILED(hr)) { if (hr == E_ACCESSDENIED) { errorMsg = "[WASAPI] Failed to initialize device. Access denied.", result = MA_ACCESS_DENIED; @@ -24072,11 +24072,11 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device done: /* Clean up. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) - if (pDeviceInterface != NULL) { + if (pDeviceInterface != nullptr) { ma_IMMDevice_Release(pDeviceInterface); } #else - if (pDeviceInterface != NULL) { + if (pDeviceInterface != nullptr) { ma_IUnknown_Release(pDeviceInterface); } #endif @@ -24084,18 +24084,18 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device if (result != MA_SUCCESS) { if (pData->pRenderClient) { ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pData->pRenderClient); - pData->pRenderClient = NULL; + pData->pRenderClient = nullptr; } if (pData->pCaptureClient) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pData->pCaptureClient); - pData->pCaptureClient = NULL; + pData->pCaptureClient = nullptr; } if (pData->pAudioClient) { ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient); - pData->pAudioClient = NULL; + pData->pAudioClient = nullptr; } - if (errorMsg != NULL && errorMsg[0] != '\0') { + if (errorMsg != nullptr && errorMsg[0] != '\0') { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "%s\n", errorMsg); } @@ -24110,7 +24110,7 @@ static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type dev ma_device_init_internal_data__wasapi data; ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* We only re-initialize the playback or capture device. Never a full-duplex device. */ if (deviceType == ma_device_type_duplex) { @@ -24131,24 +24131,24 @@ static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type dev if (deviceType == ma_device_type_capture || deviceType == ma_device_type_loopback) { if (pDevice->wasapi.pCaptureClient) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); - pDevice->wasapi.pCaptureClient = NULL; + pDevice->wasapi.pCaptureClient = nullptr; } if (pDevice->wasapi.pAudioClientCapture) { /*ma_device_release_IAudioClient_service__wasapi(pDevice, ma_device_type_capture);*/ - pDevice->wasapi.pAudioClientCapture = NULL; + pDevice->wasapi.pAudioClientCapture = nullptr; } } if (deviceType == ma_device_type_playback) { if (pDevice->wasapi.pRenderClient) { ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient); - pDevice->wasapi.pRenderClient = NULL; + pDevice->wasapi.pRenderClient = nullptr; } if (pDevice->wasapi.pAudioClientPlayback) { /*ma_device_release_IAudioClient_service__wasapi(pDevice, ma_device_type_playback);*/ - pDevice->wasapi.pAudioClientPlayback = NULL; + pDevice->wasapi.pAudioClientPlayback = nullptr; } } @@ -24175,7 +24175,7 @@ static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type dev data.noHardwareOffloading = pDevice->wasapi.noHardwareOffloading; data.loopbackProcessID = pDevice->wasapi.loopbackProcessID; data.loopbackProcessExclude = pDevice->wasapi.loopbackProcessExclude; - result = ma_device_init_internal__wasapi(pDevice->pContext, deviceType, NULL, &data); + result = ma_device_init_internal__wasapi(pDevice->pContext, deviceType, nullptr, &data); if (result != MA_SUCCESS) { return result; } @@ -24235,7 +24235,7 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf ma_IMMDeviceEnumerator* pDeviceEnumerator; #endif - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->wasapi); pDevice->wasapi.usage = pConfig->wasapi.usage; @@ -24283,17 +24283,17 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf The event for capture needs to be manual reset for the same reason as playback. We keep the initial state set to unsignaled, however, because we want to block until we actually have something for the first call to ma_device_read(). */ - pDevice->wasapi.hEventCapture = (ma_handle)CreateEventA(NULL, FALSE, FALSE, NULL); /* Auto reset, unsignaled by default. */ - if (pDevice->wasapi.hEventCapture == NULL) { + pDevice->wasapi.hEventCapture = (ma_handle)CreateEventA(nullptr, FALSE, FALSE, nullptr); /* Auto reset, unsignaled by default. */ + if (pDevice->wasapi.hEventCapture == nullptr) { result = ma_result_from_GetLastError(GetLastError()); - if (pDevice->wasapi.pCaptureClient != NULL) { + if (pDevice->wasapi.pCaptureClient != nullptr) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); - pDevice->wasapi.pCaptureClient = NULL; + pDevice->wasapi.pCaptureClient = nullptr; } - if (pDevice->wasapi.pAudioClientCapture != NULL) { + if (pDevice->wasapi.pAudioClientCapture != nullptr) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); - pDevice->wasapi.pAudioClientCapture = NULL; + pDevice->wasapi.pAudioClientCapture = nullptr; } ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for capture."); @@ -24336,17 +24336,17 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf result = ma_device_init_internal__wasapi(pDevice->pContext, ma_device_type_playback, pDescriptorPlayback->pDeviceID, &data); if (result != MA_SUCCESS) { if (pConfig->deviceType == ma_device_type_duplex) { - if (pDevice->wasapi.pCaptureClient != NULL) { + if (pDevice->wasapi.pCaptureClient != nullptr) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); - pDevice->wasapi.pCaptureClient = NULL; + pDevice->wasapi.pCaptureClient = nullptr; } - if (pDevice->wasapi.pAudioClientCapture != NULL) { + if (pDevice->wasapi.pAudioClientCapture != nullptr) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); - pDevice->wasapi.pAudioClientCapture = NULL; + pDevice->wasapi.pAudioClientCapture = nullptr; } CloseHandle((HANDLE)pDevice->wasapi.hEventCapture); - pDevice->wasapi.hEventCapture = NULL; + pDevice->wasapi.hEventCapture = nullptr; } return result; } @@ -24365,31 +24365,31 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf The playback event also needs to be initially set to a signaled state so that the first call to ma_device_write() is able to get passed WaitForMultipleObjects(). */ - pDevice->wasapi.hEventPlayback = (ma_handle)CreateEventA(NULL, FALSE, TRUE, NULL); /* Auto reset, signaled by default. */ - if (pDevice->wasapi.hEventPlayback == NULL) { + pDevice->wasapi.hEventPlayback = (ma_handle)CreateEventA(nullptr, FALSE, TRUE, nullptr); /* Auto reset, signaled by default. */ + if (pDevice->wasapi.hEventPlayback == nullptr) { result = ma_result_from_GetLastError(GetLastError()); if (pConfig->deviceType == ma_device_type_duplex) { - if (pDevice->wasapi.pCaptureClient != NULL) { + if (pDevice->wasapi.pCaptureClient != nullptr) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); - pDevice->wasapi.pCaptureClient = NULL; + pDevice->wasapi.pCaptureClient = nullptr; } - if (pDevice->wasapi.pAudioClientCapture != NULL) { + if (pDevice->wasapi.pAudioClientCapture != nullptr) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); - pDevice->wasapi.pAudioClientCapture = NULL; + pDevice->wasapi.pAudioClientCapture = nullptr; } CloseHandle((HANDLE)pDevice->wasapi.hEventCapture); - pDevice->wasapi.hEventCapture = NULL; + pDevice->wasapi.hEventCapture = nullptr; } - if (pDevice->wasapi.pRenderClient != NULL) { + if (pDevice->wasapi.pRenderClient != nullptr) { ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient); - pDevice->wasapi.pRenderClient = NULL; + pDevice->wasapi.pRenderClient = nullptr; } - if (pDevice->wasapi.pAudioClientPlayback != NULL) { + if (pDevice->wasapi.pAudioClientPlayback != nullptr) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); - pDevice->wasapi.pAudioClientPlayback = NULL; + pDevice->wasapi.pAudioClientPlayback = nullptr; } ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for playback."); @@ -24419,17 +24419,17 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) if (pConfig->wasapi.noAutoStreamRouting == MA_FALSE) { - if ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) && pConfig->capture.pDeviceID == NULL) { + if ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) && pConfig->capture.pDeviceID == nullptr) { pDevice->wasapi.allowCaptureAutoStreamRouting = MA_TRUE; } - if ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.pDeviceID == NULL) { + if ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.pDeviceID == nullptr) { pDevice->wasapi.allowPlaybackAutoStreamRouting = MA_TRUE; } } ma_mutex_init(&pDevice->wasapi.rerouteLock); - hr = ma_CoCreateInstance(pDevice->pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); + hr = ma_CoCreateInstance(pDevice->pContext, &MA_CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { ma_device_uninit__wasapi(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator."); @@ -24461,8 +24461,8 @@ static ma_result ma_device__get_available_frames__wasapi(ma_device* pDevice, ma_ HRESULT hr; ma_share_mode shareMode; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pFrameCount != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pFrameCount != nullptr); *pFrameCount = 0; @@ -24574,7 +24574,7 @@ static ma_result ma_device_start__wasapi(ma_device* pDevice) { ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Wait for any rerouting to finish before attempting to start the device. */ ma_mutex_lock(&pDevice->wasapi.rerouteLock); @@ -24591,18 +24591,18 @@ static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice) ma_result result; HRESULT hr; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->wasapi.hAvrtHandle) { ((MA_PFN_AvRevertMmThreadCharacteristics)pDevice->pContext->wasapi.AvRevertMmThreadcharacteristics)((HANDLE)pDevice->wasapi.hAvrtHandle); - pDevice->wasapi.hAvrtHandle = NULL; + pDevice->wasapi.hAvrtHandle = nullptr; } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { /* If we have a mapped buffer we need to release it. */ - if (pDevice->wasapi.pMappedBufferCapture != NULL) { + if (pDevice->wasapi.pMappedBufferCapture != nullptr) { ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); - pDevice->wasapi.pMappedBufferCapture = NULL; + pDevice->wasapi.pMappedBufferCapture = nullptr; pDevice->wasapi.mappedBufferCaptureCap = 0; pDevice->wasapi.mappedBufferCaptureLen = 0; } @@ -24624,14 +24624,14 @@ static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice) } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { - if (pDevice->wasapi.pMappedBufferPlayback != NULL) { + if (pDevice->wasapi.pMappedBufferPlayback != nullptr) { ma_silence_pcm_frames( ma_offset_pcm_frames_ptr(pDevice->wasapi.pMappedBufferPlayback, pDevice->wasapi.mappedBufferPlaybackLen, pDevice->playback.internalFormat, pDevice->playback.internalChannels), pDevice->wasapi.mappedBufferPlaybackCap - pDevice->wasapi.mappedBufferPlaybackLen, pDevice->playback.internalFormat, pDevice->playback.internalChannels ); ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, pDevice->wasapi.mappedBufferPlaybackCap, 0); - pDevice->wasapi.pMappedBufferPlayback = NULL; + pDevice->wasapi.pMappedBufferPlayback = nullptr; pDevice->wasapi.mappedBufferPlaybackCap = 0; pDevice->wasapi.mappedBufferPlaybackLen = 0; } @@ -24705,7 +24705,7 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice) { ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Wait for any rerouting to finish before attempting to stop the device. */ ma_mutex_lock(&pDevice->wasapi.rerouteLock); @@ -24738,7 +24738,7 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui ma_uint32 framesRemaining = frameCount - totalFramesProcessed; /* If we have a mapped data buffer, consume that first. */ - if (pDevice->wasapi.pMappedBufferCapture != NULL) { + if (pDevice->wasapi.pMappedBufferCapture != nullptr) { /* We have a cached data pointer so consume that before grabbing another one from WASAPI. */ ma_uint32 framesToProcessNow = framesRemaining; if (framesToProcessNow > pDevice->wasapi.mappedBufferCaptureLen) { @@ -24759,7 +24759,7 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui /* If the data buffer has been fully consumed we need to release it. */ if (pDevice->wasapi.mappedBufferCaptureLen == 0) { ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); - pDevice->wasapi.pMappedBufferCapture = NULL; + pDevice->wasapi.pMappedBufferCapture = nullptr; pDevice->wasapi.mappedBufferCaptureCap = 0; } } else { @@ -24768,7 +24768,7 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui DWORD flags = 0; /* First just ask WASAPI for a data buffer. If it's not available, we'll wait for more. */ - hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pDevice->wasapi.pMappedBufferCapture, &pDevice->wasapi.mappedBufferCaptureCap, &flags, NULL, NULL); + hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pDevice->wasapi.pMappedBufferCapture, &pDevice->wasapi.mappedBufferCaptureCap, &flags, nullptr, nullptr); if (hr == S_OK) { /* We got a data buffer. Continue to the next loop iteration which will then read from the mapped pointer. */ pDevice->wasapi.mappedBufferCaptureLen = pDevice->wasapi.mappedBufferCaptureCap; @@ -24828,14 +24828,14 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui } flags = 0; - hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pDevice->wasapi.pMappedBufferCapture, &pDevice->wasapi.mappedBufferCaptureCap, &flags, NULL, NULL); + hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pDevice->wasapi.pMappedBufferCapture, &pDevice->wasapi.mappedBufferCaptureCap, &flags, nullptr, nullptr); if (hr == MA_AUDCLNT_S_BUFFER_EMPTY || FAILED(hr)) { /* The buffer has been completely emptied or an error occurred. In this case we'll need to reset the state of the mapped buffer which will trigger the next iteration to get a fresh buffer from WASAPI. */ - pDevice->wasapi.pMappedBufferCapture = NULL; + pDevice->wasapi.pMappedBufferCapture = nullptr; pDevice->wasapi.mappedBufferCaptureCap = 0; pDevice->wasapi.mappedBufferCaptureLen = 0; @@ -24856,7 +24856,7 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui } /* If at this point we have a valid buffer mapped, make sure the buffer length is set appropriately. */ - if (pDevice->wasapi.pMappedBufferCapture != NULL) { + if (pDevice->wasapi.pMappedBufferCapture != nullptr) { pDevice->wasapi.mappedBufferCaptureLen = pDevice->wasapi.mappedBufferCaptureCap; } } @@ -24905,14 +24905,14 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui there's a good chance either an error occurred or the device was stopped mid-read. In this case we'll need to make sure the buffer is released. */ - if (totalFramesProcessed < frameCount && pDevice->wasapi.pMappedBufferCapture != NULL) { + if (totalFramesProcessed < frameCount && pDevice->wasapi.pMappedBufferCapture != nullptr) { ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); - pDevice->wasapi.pMappedBufferCapture = NULL; + pDevice->wasapi.pMappedBufferCapture = nullptr; pDevice->wasapi.mappedBufferCaptureCap = 0; pDevice->wasapi.mappedBufferCaptureLen = 0; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesProcessed; } @@ -24934,7 +24934,7 @@ static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames a requested buffer size equal to our actual period size. If it returns AUDCLNT_E_BUFFER_TOO_LARGE it means we need to wait for some data to become available. */ - if (pDevice->wasapi.pMappedBufferPlayback != NULL) { + if (pDevice->wasapi.pMappedBufferPlayback != nullptr) { /* We still have some space available in the mapped data buffer. Write to it. */ ma_uint32 framesToProcessNow = framesRemaining; if (framesToProcessNow > (pDevice->wasapi.mappedBufferPlaybackCap - pDevice->wasapi.mappedBufferPlaybackLen)) { @@ -24955,7 +24955,7 @@ static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames /* If the data buffer has been fully consumed we need to release it. */ if (pDevice->wasapi.mappedBufferPlaybackLen == pDevice->wasapi.mappedBufferPlaybackCap) { ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, pDevice->wasapi.mappedBufferPlaybackCap, 0); - pDevice->wasapi.pMappedBufferPlayback = NULL; + pDevice->wasapi.pMappedBufferPlayback = nullptr; pDevice->wasapi.mappedBufferPlaybackCap = 0; pDevice->wasapi.mappedBufferPlaybackLen = 0; @@ -25005,7 +25005,7 @@ static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames } } - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = totalFramesProcessed; } @@ -25014,7 +25014,7 @@ static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames static ma_result ma_device_data_loop_wakeup__wasapi(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { SetEvent((HANDLE)pDevice->wasapi.hEventCapture); @@ -25032,7 +25032,7 @@ static ma_result ma_context_uninit__wasapi(ma_context* pContext) { ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_QUIT__WASAPI); - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_wasapi); ma_context_post_command__wasapi(pContext, &cmd); @@ -25040,14 +25040,14 @@ static ma_result ma_context_uninit__wasapi(ma_context* pContext) if (pContext->wasapi.hAvrt) { ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hAvrt); - pContext->wasapi.hAvrt = NULL; + pContext->wasapi.hAvrt = nullptr; } #if defined(MA_WIN32_UWP) { if (pContext->wasapi.hMMDevapi) { ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi); - pContext->wasapi.hMMDevapi = NULL; + pContext->wasapi.hMMDevapi = nullptr; } } #endif @@ -25063,7 +25063,7 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_ { ma_result result = MA_SUCCESS; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); (void)pConfig; @@ -25081,13 +25081,13 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_ ma_PFNVerSetConditionMask _VerSetConditionMask; kernel32DLL = ma_dlopen(ma_context_get_log(pContext), "kernel32.dll"); - if (kernel32DLL == NULL) { + if (kernel32DLL == nullptr) { return MA_NO_BACKEND; } _VerifyVersionInfoW = (ma_PFNVerifyVersionInfoW )ma_dlsym(ma_context_get_log(pContext), kernel32DLL, "VerifyVersionInfoW"); _VerSetConditionMask = (ma_PFNVerSetConditionMask)ma_dlsym(ma_context_get_log(pContext), kernel32DLL, "VerSetConditionMask"); - if (_VerifyVersionInfoW == NULL || _VerSetConditionMask == NULL) { + if (_VerifyVersionInfoW == nullptr || _VerSetConditionMask == nullptr) { ma_dlclose(ma_context_get_log(pContext), kernel32DLL); return MA_NO_BACKEND; } @@ -25120,7 +25120,7 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_ pContext->wasapi.hMMDevapi = ma_dlopen(ma_context_get_log(pContext), "mmdevapi.dll"); if (pContext->wasapi.hMMDevapi) { pContext->wasapi.ActivateAudioInterfaceAsync = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi, "ActivateAudioInterfaceAsync"); - if (pContext->wasapi.ActivateAudioInterfaceAsync == NULL) { + if (pContext->wasapi.ActivateAudioInterfaceAsync == nullptr) { ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi); return MA_NO_BACKEND; /* ActivateAudioInterfaceAsync() could not be loaded. */ } @@ -25138,10 +25138,10 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_ /* If either function could not be found, disable use of avrt entirely. */ if (!pContext->wasapi.AvSetMmThreadCharacteristicsA || !pContext->wasapi.AvRevertMmThreadcharacteristics) { - pContext->wasapi.AvSetMmThreadCharacteristicsA = NULL; - pContext->wasapi.AvRevertMmThreadcharacteristics = NULL; + pContext->wasapi.AvSetMmThreadCharacteristicsA = nullptr; + pContext->wasapi.AvRevertMmThreadcharacteristics = nullptr; ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hAvrt); - pContext->wasapi.hAvrt = NULL; + pContext->wasapi.hAvrt = nullptr; } } @@ -25202,7 +25202,7 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_ pCallbacks->onDeviceStop = ma_device_stop__wasapi; pCallbacks->onDeviceRead = ma_device_read__wasapi; pCallbacks->onDeviceWrite = ma_device_write__wasapi; - pCallbacks->onDeviceDataLoop = NULL; + pCallbacks->onDeviceDataLoop = nullptr; pCallbacks->onDeviceDataLoopWakeup = ma_device_data_loop_wakeup__wasapi; return MA_SUCCESS; @@ -25583,12 +25583,12 @@ static void ma_get_channels_from_speaker_config__dsound(DWORD speakerConfig, WOR DWORD channelMap; channels = 0; - if (pChannelsOut != NULL) { + if (pChannelsOut != nullptr) { channels = *pChannelsOut; } channelMap = 0; - if (pChannelMapOut != NULL) { + if (pChannelMapOut != nullptr) { channelMap = *pChannelMapOut; } @@ -25609,11 +25609,11 @@ static void ma_get_channels_from_speaker_config__dsound(DWORD speakerConfig, WOR default: break; } - if (pChannelsOut != NULL) { + if (pChannelsOut != nullptr) { *pChannelsOut = channels; } - if (pChannelMapOut != NULL) { + if (pChannelMapOut != nullptr) { *pChannelMapOut = channelMap; } } @@ -25625,13 +25625,13 @@ static ma_result ma_context_create_IDirectSound__dsound(ma_context* pContext, ma HWND hWnd; HRESULT hr; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppDirectSound != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppDirectSound != nullptr); - *ppDirectSound = NULL; - pDirectSound = NULL; + *ppDirectSound = nullptr; + pDirectSound = nullptr; - if (FAILED(((ma_DirectSoundCreateProc)pContext->dsound.DirectSoundCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSound, NULL))) { + if (FAILED(((ma_DirectSoundCreateProc)pContext->dsound.DirectSoundCreate)((pDeviceID == nullptr) ? nullptr : (const GUID*)pDeviceID->dsound, &pDirectSound, nullptr))) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCreate() failed for playback device."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } @@ -25660,18 +25660,18 @@ static ma_result ma_context_create_IDirectSoundCapture__dsound(ma_context* pCont ma_IDirectSoundCapture* pDirectSoundCapture; HRESULT hr; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppDirectSoundCapture != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppDirectSoundCapture != nullptr); /* DirectSound does not support exclusive mode for capture. */ if (shareMode == ma_share_mode_exclusive) { return MA_SHARE_MODE_NOT_SUPPORTED; } - *ppDirectSoundCapture = NULL; - pDirectSoundCapture = NULL; + *ppDirectSoundCapture = nullptr; + pDirectSoundCapture = nullptr; - hr = ((ma_DirectSoundCaptureCreateProc)pContext->dsound.DirectSoundCaptureCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSoundCapture, NULL); + hr = ((ma_DirectSoundCaptureCreateProc)pContext->dsound.DirectSoundCaptureCreate)((pDeviceID == nullptr) ? nullptr : (const GUID*)pDeviceID->dsound, &pDirectSoundCapture, nullptr); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCaptureCreate() failed for capture device."); return ma_result_from_HRESULT(hr); @@ -25688,8 +25688,8 @@ static ma_result ma_context_get_format_info_for_IDirectSoundCapture__dsound(ma_c WORD bitsPerSample; DWORD sampleRate; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pDirectSoundCapture != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pDirectSoundCapture != nullptr); if (pChannels) { *pChannels = 0; @@ -25803,7 +25803,7 @@ static BOOL CALLBACK ma_context_enumerate_devices_callback__dsound(GUID* lpGuid, MA_ZERO_OBJECT(&deviceInfo); /* ID. */ - if (lpGuid != NULL) { + if (lpGuid != nullptr) { MA_COPY_MEMORY(deviceInfo.id.dsound, lpGuid, 16); } else { MA_ZERO_MEMORY(deviceInfo.id.dsound, 16); @@ -25815,7 +25815,7 @@ static BOOL CALLBACK ma_context_enumerate_devices_callback__dsound(GUID* lpGuid, /* Call the callback function, but make sure we stop enumerating if the callee requested so. */ - MA_ASSERT(pData != NULL); + MA_ASSERT(pData != nullptr); pData->terminated = (pData->callback(pData->pContext, pData->deviceType, &deviceInfo, pData->pUserData) == MA_FALSE); if (pData->terminated) { return FALSE; /* Stop enumeration. */ @@ -25828,8 +25828,8 @@ static ma_result ma_context_enumerate_devices__dsound(ma_context* pContext, ma_e { ma_context_enumerate_devices_callback_data__dsound data; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); data.pContext = pContext; data.callback = callback; @@ -25862,9 +25862,9 @@ typedef struct static BOOL CALLBACK ma_context_get_device_info_callback__dsound(GUID* lpGuid, const char* lpcstrDescription, const char* lpcstrModule, void* lpContext) { ma_context_get_device_info_callback_data__dsound* pData = (ma_context_get_device_info_callback_data__dsound*)lpContext; - MA_ASSERT(pData != NULL); + MA_ASSERT(pData != nullptr); - if ((pData->pDeviceID == NULL || ma_is_guid_null(pData->pDeviceID->dsound)) && (lpGuid == NULL || ma_is_guid_null(lpGuid))) { + if ((pData->pDeviceID == nullptr || ma_is_guid_null(pData->pDeviceID->dsound)) && (lpGuid == nullptr || ma_is_guid_null(lpGuid))) { /* Default device. */ ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1); pData->pDeviceInfo->isDefault = MA_TRUE; @@ -25872,7 +25872,7 @@ static BOOL CALLBACK ma_context_get_device_info_callback__dsound(GUID* lpGuid, c return FALSE; /* Stop enumeration. */ } else { /* Not the default device. */ - if (lpGuid != NULL && pData->pDeviceID != NULL) { + if (lpGuid != nullptr && pData->pDeviceID != nullptr) { if (memcmp(pData->pDeviceID->dsound, lpGuid, sizeof(pData->pDeviceID->dsound)) == 0) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1); pData->found = MA_TRUE; @@ -25890,7 +25890,7 @@ static ma_result ma_context_get_device_info__dsound(ma_context* pContext, ma_dev ma_result result; HRESULT hr; - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { ma_context_get_device_info_callback_data__dsound data; /* ID. */ @@ -25956,7 +25956,7 @@ static ma_result ma_context_get_device_info__dsound(ma_context* pContext, ma_dev /* Look at the speaker configuration to get a better idea on the channel count. */ hr = ma_IDirectSound_GetSpeakerConfig(pDirectSound, &speakerConfig); if (SUCCEEDED(hr)) { - ma_get_channels_from_speaker_config__dsound(speakerConfig, &channels, NULL); + ma_get_channels_from_speaker_config__dsound(speakerConfig, &channels, nullptr); } } else { /* It does not support stereo, which means we are stuck with mono. */ @@ -26042,22 +26042,22 @@ static ma_result ma_context_get_device_info__dsound(ma_context* pContext, ma_dev static ma_result ma_device_uninit__dsound(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); - if (pDevice->dsound.pCaptureBuffer != NULL) { + if (pDevice->dsound.pCaptureBuffer != nullptr) { ma_IDirectSoundCaptureBuffer_Release((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); } - if (pDevice->dsound.pCapture != NULL) { + if (pDevice->dsound.pCapture != nullptr) { ma_IDirectSoundCapture_Release((ma_IDirectSoundCapture*)pDevice->dsound.pCapture); } - if (pDevice->dsound.pPlaybackBuffer != NULL) { + if (pDevice->dsound.pPlaybackBuffer != nullptr) { ma_IDirectSoundBuffer_Release((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer); } - if (pDevice->dsound.pPlaybackPrimaryBuffer != NULL) { + if (pDevice->dsound.pPlaybackPrimaryBuffer != nullptr) { ma_IDirectSoundBuffer_Release((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer); } - if (pDevice->dsound.pPlayback != NULL) { + if (pDevice->dsound.pPlayback != nullptr) { ma_IDirectSound_Release((ma_IDirectSound*)pDevice->dsound.pPlayback); } @@ -26137,7 +26137,7 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf ma_result result; HRESULT hr; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->dsound); @@ -26189,7 +26189,7 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf descDS.dwFlags = 0; descDS.dwBufferBytes = periodSizeInFrames * periodCount * wf.nBlockAlign; descDS.lpwfxFormat = (MA_WAVEFORMATEX*)&wf; - hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL); + hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, nullptr); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_CreateCaptureBuffer() failed for capture device."); @@ -26198,7 +26198,7 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf /* Get the _actual_ properties of the buffer. */ pActualFormat = (MA_WAVEFORMATEXTENSIBLE*)rawdata; - hr = ma_IDirectSoundCaptureBuffer_GetFormat((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, (MA_WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL); + hr = ma_IDirectSoundCaptureBuffer_GetFormat((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, (MA_WAVEFORMATEX*)pActualFormat, sizeof(rawdata), nullptr); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the capture device's buffer."); @@ -26225,7 +26225,7 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf descDS.dwBufferBytes = periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) * periodCount; ma_IDirectSoundCaptureBuffer_Release((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); - hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL); + hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, nullptr); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Second attempt at IDirectSoundCapture_CreateCaptureBuffer() failed for capture device."); @@ -26264,7 +26264,7 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf MA_ZERO_OBJECT(&descDSPrimary); descDSPrimary.dwSize = sizeof(MA_DSBUFFERDESC); descDSPrimary.dwFlags = MA_DSBCAPS_PRIMARYBUFFER | MA_DSBCAPS_CTRLVOLUME; - hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDSPrimary, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackPrimaryBuffer, NULL); + hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDSPrimary, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackPrimaryBuffer, nullptr); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's primary buffer."); @@ -26348,7 +26348,7 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf /* Get the _actual_ properties of the buffer. */ pActualFormat = (MA_WAVEFORMATEXTENSIBLE*)rawdata; - hr = ma_IDirectSoundBuffer_GetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (MA_WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL); + hr = ma_IDirectSoundBuffer_GetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (MA_WAVEFORMATEX*)pActualFormat, sizeof(rawdata), nullptr); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the playback device's primary buffer."); @@ -26391,7 +26391,7 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf descDS.dwFlags = MA_DSBCAPS_CTRLPOSITIONNOTIFY | MA_DSBCAPS_GLOBALFOCUS | MA_DSBCAPS_GETCURRENTPOSITION2; descDS.dwBufferBytes = periodSizeInFrames * periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels); descDS.lpwfxFormat = (MA_WAVEFORMATEX*)pActualFormat; - hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDS, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackBuffer, NULL); + hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDS, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackBuffer, nullptr); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's secondary buffer."); @@ -26432,7 +26432,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) ma_uint32 waitTimeInMilliseconds = 1; DWORD playbackBufferStatus = 0; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* The first thing to do is start the capture device. The playback device is only started after the first period is written. */ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { @@ -26490,7 +26490,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) continue; /* Nothing is available in the capture buffer. */ } - hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0); + hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, nullptr, nullptr, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device."); return ma_result_from_HRESULT(hr); @@ -26589,7 +26589,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) lockSizeInBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } - hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0); + hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, nullptr, nullptr, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device."); result = ma_result_from_HRESULT(hr); @@ -26632,7 +26632,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) } - hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, framesWrittenThisIteration*bpfDevicePlayback, NULL, 0); + hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, framesWrittenThisIteration*bpfDevicePlayback, nullptr, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device."); result = ma_result_from_HRESULT(hr); @@ -26672,7 +26672,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) /* At this point we're done with the mapped portion of the capture buffer. */ - hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, NULL, 0); + hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, nullptr, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device."); return ma_result_from_HRESULT(hr); @@ -26723,7 +26723,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) continue; /* Nothing is available in the capture buffer. */ } - hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0); + hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, nullptr, nullptr, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device."); result = ma_result_from_HRESULT(hr); @@ -26735,7 +26735,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) ma_device__send_frames_to_client(pDevice, mappedSizeInBytesCapture/bpfDeviceCapture, pMappedDeviceBufferCapture); - hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, NULL, 0); + hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, nullptr, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device."); return ma_result_from_HRESULT(hr); @@ -26826,7 +26826,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) lockSizeInBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } - hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0); + hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, nullptr, nullptr, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device."); result = ma_result_from_HRESULT(hr); @@ -26836,7 +26836,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) /* At this point we have a buffer for output. */ ma_device__read_frames_from_client(pDevice, (mappedSizeInBytesPlayback/bpfDevicePlayback), pMappedDeviceBufferPlayback); - hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, mappedSizeInBytesPlayback, NULL, 0); + hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, mappedSizeInBytesPlayback, nullptr, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device."); result = ma_result_from_HRESULT(hr); @@ -26938,7 +26938,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice) static ma_result ma_context_uninit__dsound(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_dsound); ma_dlclose(ma_context_get_log(pContext), pContext->dsound.hDSoundDLL); @@ -26948,12 +26948,12 @@ static ma_result ma_context_uninit__dsound(ma_context* pContext) static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); (void)pConfig; pContext->dsound.hDSoundDLL = ma_dlopen(ma_context_get_log(pContext), "dsound.dll"); - if (pContext->dsound.hDSoundDLL == NULL) { + if (pContext->dsound.hDSoundDLL == nullptr) { return MA_API_NOT_FOUND; } @@ -26967,10 +26967,10 @@ static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_ well in my testing. For example, it's missing DirectSoundCaptureEnumerateA(). This is a convenient place to just disable the DirectSound backend for Windows 95. */ - if (pContext->dsound.DirectSoundCreate == NULL || - pContext->dsound.DirectSoundEnumerateA == NULL || - pContext->dsound.DirectSoundCaptureCreate == NULL || - pContext->dsound.DirectSoundCaptureEnumerateA == NULL) { + if (pContext->dsound.DirectSoundCreate == nullptr || + pContext->dsound.DirectSoundEnumerateA == nullptr || + pContext->dsound.DirectSoundCaptureCreate == nullptr || + pContext->dsound.DirectSoundCaptureEnumerateA == nullptr) { return MA_API_NOT_FOUND; } @@ -26982,10 +26982,10 @@ static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_ pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__dsound; pCallbacks->onDeviceInit = ma_device_init__dsound; pCallbacks->onDeviceUninit = ma_device_uninit__dsound; - pCallbacks->onDeviceStart = NULL; /* Not used. Started in onDeviceDataLoop. */ - pCallbacks->onDeviceStop = NULL; /* Not used. Stopped in onDeviceDataLoop. */ - pCallbacks->onDeviceRead = NULL; /* Not used. Data is read directly in onDeviceDataLoop. */ - pCallbacks->onDeviceWrite = NULL; /* Not used. Data is written directly in onDeviceDataLoop. */ + pCallbacks->onDeviceStart = nullptr; /* Not used. Started in onDeviceDataLoop. */ + pCallbacks->onDeviceStop = nullptr; /* Not used. Stopped in onDeviceDataLoop. */ + pCallbacks->onDeviceRead = nullptr; /* Not used. Data is read directly in onDeviceDataLoop. */ + pCallbacks->onDeviceWrite = nullptr; /* Not used. Data is written directly in onDeviceDataLoop. */ pCallbacks->onDeviceDataLoop = ma_device_data_loop__dsound; return MA_SUCCESS; @@ -27132,11 +27132,11 @@ static char* ma_find_last_character(char* str, char ch) { char* last; - if (str == NULL) { - return NULL; + if (str == nullptr) { + return nullptr; } - last = NULL; + last = nullptr; while (*str != '\0') { if (*str == ch) { last = str; @@ -27250,7 +27250,7 @@ static ma_result ma_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD c { ma_result result; - MA_ASSERT(pWF != NULL); + MA_ASSERT(pWF != nullptr); MA_ZERO_OBJECT(pWF); pWF->cbSize = sizeof(*pWF); @@ -27277,9 +27277,9 @@ static ma_result ma_context_get_device_info_from_WAVECAPS(ma_context* pContext, DWORD sampleRate; ma_result result; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pCaps != NULL); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pCaps != nullptr); + MA_ASSERT(pDeviceInfo != nullptr); /* Name / Description @@ -27317,7 +27317,7 @@ static ma_result ma_context_get_device_info_from_WAVECAPS(ma_context* pContext, if (((MA_PFN_RegOpenKeyExA)pContext->win32.RegOpenKeyExA)(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { BYTE nameFromReg[512]; DWORD nameFromRegSize = sizeof(nameFromReg); - LONG resultWin32 = ((MA_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (BYTE*)nameFromReg, (DWORD*)&nameFromRegSize); + LONG resultWin32 = ((MA_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, nullptr, (BYTE*)nameFromReg, (DWORD*)&nameFromRegSize); ((MA_PFN_RegCloseKey)pContext->win32.RegCloseKey)(hKey); if (resultWin32 == ERROR_SUCCESS) { @@ -27325,7 +27325,7 @@ static ma_result ma_context_get_device_info_from_WAVECAPS(ma_context* pContext, char name[1024]; if (ma_strcpy_s(name, sizeof(name), pDeviceInfo->name) == 0) { char* nameBeg = ma_find_last_character(name, '('); - if (nameBeg != NULL) { + if (nameBeg != nullptr) { size_t leadingLen = (nameBeg - name); ma_strncpy_s(nameBeg + 1, sizeof(name) - leadingLen, (const char*)nameFromReg, (size_t)-1); @@ -27371,9 +27371,9 @@ static ma_result ma_context_get_device_info_from_WAVEOUTCAPS2(ma_context* pConte { MA_WAVECAPSA caps; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pCaps != NULL); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pCaps != nullptr); + MA_ASSERT(pDeviceInfo != nullptr); MA_COPY_MEMORY(caps.szPname, pCaps->szPname, sizeof(caps.szPname)); caps.dwFormats = pCaps->dwFormats; @@ -27386,9 +27386,9 @@ static ma_result ma_context_get_device_info_from_WAVEINCAPS2(ma_context* pContex { MA_WAVECAPSA caps; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pCaps != NULL); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pCaps != nullptr); + MA_ASSERT(pDeviceInfo != nullptr); MA_COPY_MEMORY(caps.szPname, pCaps->szPname, sizeof(caps.szPname)); caps.dwFormats = pCaps->dwFormats; @@ -27405,8 +27405,8 @@ static ma_result ma_context_enumerate_devices__winmm(ma_context* pContext, ma_en UINT iPlaybackDevice; UINT iCaptureDevice; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); /* Playback. */ playbackDeviceCount = ((MA_PFN_waveOutGetNumDevs)pContext->winmm.waveOutGetNumDevs)(); @@ -27473,10 +27473,10 @@ static ma_result ma_context_get_device_info__winmm(ma_context* pContext, ma_devi { UINT winMMDeviceID; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); winMMDeviceID = 0; - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { winMMDeviceID = (UINT)pDeviceID->winmm; } @@ -27515,7 +27515,7 @@ static ma_result ma_context_get_device_info__winmm(ma_context* pContext, ma_devi static ma_result ma_device_uninit__winmm(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture); @@ -27558,7 +27558,7 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi UINT winMMDeviceIDPlayback = 0; UINT winMMDeviceIDCapture = 0; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->winmm); @@ -27572,10 +27572,10 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi return MA_SHARE_MODE_NOT_SUPPORTED; } - if (pDescriptorPlayback->pDeviceID != NULL) { + if (pDescriptorPlayback->pDeviceID != nullptr) { winMMDeviceIDPlayback = (UINT)pDescriptorPlayback->pDeviceID->winmm; } - if (pDescriptorCapture->pDeviceID != NULL) { + if (pDescriptorCapture->pDeviceID != nullptr) { winMMDeviceIDCapture = (UINT)pDescriptorCapture->pDeviceID->winmm; } @@ -27586,8 +27586,8 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi MA_MMRESULT resultMM; /* We use an event to know when a new fragment needs to be enqueued. */ - pDevice->winmm.hEventCapture = (ma_handle)CreateEventA(NULL, TRUE, TRUE, NULL); - if (pDevice->winmm.hEventCapture == NULL) { + pDevice->winmm.hEventCapture = (ma_handle)CreateEventA(nullptr, TRUE, TRUE, nullptr); + if (pDevice->winmm.hEventCapture == nullptr) { errorMsg = "[WinMM] Failed to create event for fragment enqueuing for the capture device.", errorCode = ma_result_from_GetLastError(GetLastError()); goto on_error; } @@ -27624,8 +27624,8 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi MA_MMRESULT resultMM; /* We use an event to know when a new fragment needs to be enqueued. */ - pDevice->winmm.hEventPlayback = (ma_handle)CreateEventA(NULL, TRUE, TRUE, NULL); - if (pDevice->winmm.hEventPlayback == NULL) { + pDevice->winmm.hEventPlayback = (ma_handle)CreateEventA(nullptr, TRUE, TRUE, nullptr); + if (pDevice->winmm.hEventPlayback == nullptr) { errorMsg = "[WinMM] Failed to create event for fragment enqueuing for the playback device.", errorCode = ma_result_from_GetLastError(GetLastError()); goto on_error; } @@ -27670,7 +27670,7 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi } pDevice->winmm._pHeapData = (ma_uint8*)ma_calloc(heapSize, &pDevice->pContext->allocationCallbacks); - if (pDevice->winmm._pHeapData == NULL) { + if (pDevice->winmm._pHeapData == nullptr) { errorMsg = "[WinMM] Failed to allocate memory for the intermediary buffer.", errorCode = MA_OUT_OF_MEMORY; goto on_error; } @@ -27739,7 +27739,7 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi on_error: if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { - if (pDevice->winmm.pWAVEHDRCapture != NULL) { + if (pDevice->winmm.pWAVEHDRCapture != nullptr) { ma_uint32 iPeriod; for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) { ((MA_PFN_waveInUnprepareHeader)pDevice->pContext->winmm.waveInUnprepareHeader)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR)); @@ -27750,7 +27750,7 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { - if (pDevice->winmm.pWAVEHDRCapture != NULL) { + if (pDevice->winmm.pWAVEHDRCapture != nullptr) { ma_uint32 iPeriod; for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) { ((MA_PFN_waveOutUnprepareHeader)pDevice->pContext->winmm.waveOutUnprepareHeader)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(MA_WAVEHDR)); @@ -27762,7 +27762,7 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi ma_free(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks); - if (errorMsg != NULL && errorMsg[0] != '\0') { + if (errorMsg != nullptr && errorMsg[0] != '\0') { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "%s", errorMsg); } @@ -27771,7 +27771,7 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi static ma_result ma_device_start__winmm(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { MA_MMRESULT resultMM; @@ -27814,10 +27814,10 @@ static ma_result ma_device_stop__winmm(ma_device* pDevice) { MA_MMRESULT resultMM; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { - if (pDevice->winmm.hDeviceCapture == NULL) { + if (pDevice->winmm.hDeviceCapture == nullptr) { return MA_INVALID_ARGS; } @@ -27831,7 +27831,7 @@ static ma_result ma_device_stop__winmm(ma_device* pDevice) ma_uint32 iPeriod; MA_WAVEHDR* pWAVEHDR; - if (pDevice->winmm.hDevicePlayback == NULL) { + if (pDevice->winmm.hDevicePlayback == nullptr) { return MA_INVALID_ARGS; } @@ -27863,10 +27863,10 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram ma_uint32 totalFramesWritten; MA_WAVEHDR* pWAVEHDR; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pPCMFrames != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pPCMFrames != nullptr); - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = 0; } @@ -27941,7 +27941,7 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram } } - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = totalFramesWritten; } @@ -27955,10 +27955,10 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_ ma_uint32 totalFramesRead; MA_WAVEHDR* pWAVEHDR; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pPCMFrames != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pPCMFrames != nullptr); - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -28030,7 +28030,7 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_ } } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesRead; } @@ -28039,7 +28039,7 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_ static ma_result ma_context_uninit__winmm(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_winmm); ma_dlclose(ma_context_get_log(pContext), pContext->winmm.hWinMM); @@ -28048,12 +28048,12 @@ static ma_result ma_context_uninit__winmm(ma_context* pContext) static ma_result ma_context_init__winmm(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); (void)pConfig; pContext->winmm.hWinMM = ma_dlopen(ma_context_get_log(pContext), "winmm.dll"); - if (pContext->winmm.hWinMM == NULL) { + if (pContext->winmm.hWinMM == nullptr) { return MA_NO_BACKEND; } @@ -28085,7 +28085,7 @@ static ma_result ma_context_init__winmm(ma_context* pContext, const ma_context_c pCallbacks->onDeviceStop = ma_device_stop__winmm; pCallbacks->onDeviceRead = ma_device_read__winmm; pCallbacks->onDeviceWrite = ma_device_write__winmm; - pCallbacks->onDeviceDataLoop = NULL; /* This is a blocking read-write API, so this can be NULL since miniaudio will manage the audio thread for us. */ + pCallbacks->onDeviceDataLoop = nullptr; /* This is a blocking read-write API, so this can be nullptr since miniaudio will manage the audio thread for us. */ return MA_SUCCESS; } @@ -28546,7 +28546,7 @@ static const char* ma_find_char(const char* str, char c, int* index) for (;;) { if (str[i] == '\0') { if (index) *index = -1; - return NULL; + return nullptr; } if (str[i] == c) { @@ -28559,7 +28559,7 @@ static const char* ma_find_char(const char* str, char c, int* index) /* Should never get here, but treat it as though the character was not found to make me feel better inside. */ if (index) *index = -1; - return NULL; + return nullptr; } static ma_bool32 ma_is_device_name_in_hw_format__alsa(const char* hwid) @@ -28570,7 +28570,7 @@ static ma_bool32 ma_is_device_name_in_hw_format__alsa(const char* hwid) const char* dev; int i; - if (hwid == NULL) { + if (hwid == nullptr) { return MA_FALSE; } @@ -28581,7 +28581,7 @@ static ma_bool32 ma_is_device_name_in_hw_format__alsa(const char* hwid) hwid += 3; dev = ma_find_char(hwid, ',', &commaPos); - if (dev == NULL) { + if (dev == nullptr) { return MA_FALSE; } else { dev += 1; /* Skip past the ",". */ @@ -28616,7 +28616,7 @@ static int ma_convert_device_name_to_hw_format__alsa(ma_context* pContext, char* const char* dev; int cardIndex; - if (dst == NULL) { + if (dst == nullptr) { return -1; } if (dstSize < 7) { @@ -28624,7 +28624,7 @@ static int ma_convert_device_name_to_hw_format__alsa(ma_context* pContext, char* } *dst = '\0'; /* Safety. */ - if (src == NULL) { + if (src == nullptr) { return -1; } @@ -28634,12 +28634,12 @@ static int ma_convert_device_name_to_hw_format__alsa(ma_context* pContext, char* } src = ma_find_char(src, ':', &colonPos); - if (src == NULL) { + if (src == nullptr) { return -1; /* Couldn't find a colon */ } dev = ma_find_char(src, ',', &commaPos); - if (dev == NULL) { + if (dev == nullptr) { dev = "0"; ma_strncpy_s(card, sizeof(card), src+6, (size_t)-1); /* +6 = ":CARD=" */ } else { @@ -28672,7 +28672,7 @@ static ma_bool32 ma_does_id_exist_in_list__alsa(ma_device_id* pUniqueIDs, ma_uin { ma_uint32 i; - MA_ASSERT(pHWID != NULL); + MA_ASSERT(pHWID != nullptr); for (i = 0; i < count; ++i) { if (ma_strcmp(pUniqueIDs[i].alsa, pHWID) == 0) { @@ -28689,15 +28689,15 @@ static ma_result ma_context_open_pcm__alsa(ma_context* pContext, ma_share_mode s ma_snd_pcm_t* pPCM; ma_snd_pcm_stream_t stream; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppPCM != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppPCM != nullptr); - *ppPCM = NULL; - pPCM = NULL; + *ppPCM = nullptr; + pPCM = nullptr; stream = (deviceType == ma_device_type_playback) ? MA_SND_PCM_STREAM_PLAYBACK : MA_SND_PCM_STREAM_CAPTURE; - if (pDeviceID == NULL) { + if (pDeviceID == nullptr) { ma_bool32 isDeviceOpen; size_t i; @@ -28707,12 +28707,12 @@ static ma_result ma_context_open_pcm__alsa(ma_context* pContext, ma_share_mode s */ const char* defaultDeviceNames[] = { "default", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr }; if (shareMode == ma_share_mode_exclusive) { @@ -28736,7 +28736,7 @@ static ma_result ma_context_open_pcm__alsa(ma_context* pContext, ma_share_mode s isDeviceOpen = MA_FALSE; for (i = 0; i < ma_countof(defaultDeviceNames); ++i) { - if (defaultDeviceNames[i] != NULL && defaultDeviceNames[i][0] != '\0') { + if (defaultDeviceNames[i] != nullptr && defaultDeviceNames[i][0] != '\0') { if (((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, defaultDeviceNames[i], stream, openMode) == 0) { isDeviceOpen = MA_TRUE; break; @@ -28809,12 +28809,12 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu int resultALSA; ma_bool32 cbResult = MA_TRUE; char** ppDeviceHints; - ma_device_id* pUniqueIDs = NULL; + ma_device_id* pUniqueIDs = nullptr; ma_uint32 uniqueIDCount = 0; char** ppNextDeviceHint; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); ma_mutex_lock(&pContext->alsa.internalDeviceEnumLock); @@ -28825,7 +28825,7 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu } ppNextDeviceHint = ppDeviceHints; - while (*ppNextDeviceHint != NULL) { + while (*ppNextDeviceHint != nullptr) { char* NAME = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "NAME"); char* DESC = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "DESC"); char* IOID = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "IOID"); @@ -28834,14 +28834,14 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu char hwid[sizeof(pUniqueIDs->alsa)]; ma_device_info deviceInfo; - if ((IOID == NULL || ma_strcmp(IOID, "Output") == 0)) { + if ((IOID == nullptr || ma_strcmp(IOID, "Output") == 0)) { deviceType = ma_device_type_playback; } - if ((IOID != NULL && ma_strcmp(IOID, "Input" ) == 0)) { + if ((IOID != nullptr && ma_strcmp(IOID, "Input" ) == 0)) { deviceType = ma_device_type_capture; } - if (NAME != NULL) { + if (NAME != nullptr) { if (pContext->alsa.useVerboseDeviceEnumeration) { /* Verbose mode. Use the name exactly as-is. */ ma_strncpy_s(hwid, sizeof(hwid), NAME, (size_t)-1); @@ -28868,7 +28868,7 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu /* The device has not yet been enumerated. Make sure it's added to our list so that it's not enumerated again. */ size_t newCapacity = sizeof(*pUniqueIDs) * (uniqueIDCount + 1); ma_device_id* pNewUniqueIDs = (ma_device_id*)ma_realloc(pUniqueIDs, newCapacity, &pContext->allocationCallbacks); - if (pNewUniqueIDs == NULL) { + if (pNewUniqueIDs == nullptr) { goto next_device; /* Failed to allocate memory. */ } @@ -28904,10 +28904,10 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu it makes formatting ugly and annoying. I'm therefore deciding to put it all on a single line with the second line being put into parentheses. In simplified mode I'm just stripping the second line entirely. */ - if (DESC != NULL) { + if (DESC != nullptr) { int lfPos; const char* line2 = ma_find_char(DESC, '\n', &lfPos); - if (line2 != NULL) { + if (line2 != nullptr) { line2 += 1; /* Skip past the new-line character. */ if (pContext->alsa.useVerboseDeviceEnumeration) { @@ -28932,11 +28932,11 @@ static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enu /* Some devices are both playback and capture, but they are only enumerated by ALSA once. We need to fire the callback - again for the other device type in this case. We do this for known devices and where the IOID hint is NULL, which + again for the other device type in this case. We do this for known devices and where the IOID hint is nullptr, which means both Input and Output. */ if (cbResult) { - if (ma_is_common_device_name__alsa(NAME) || IOID == NULL) { + if (ma_is_common_device_name__alsa(NAME) || IOID == nullptr) { if (deviceType == ma_device_type_playback) { if (!ma_is_capture_device_blacklisted__alsa(NAME)) { cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); @@ -28986,15 +28986,15 @@ typedef struct static ma_bool32 ma_context_get_device_info_enum_callback__alsa(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pDeviceInfo, void* pUserData) { ma_context_get_device_info_enum_callback_data__alsa* pData = (ma_context_get_device_info_enum_callback_data__alsa*)pUserData; - MA_ASSERT(pData != NULL); + MA_ASSERT(pData != nullptr); (void)pContext; - if (pData->pDeviceID == NULL && ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) { + if (pData->pDeviceID == nullptr && ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1); pData->foundDevice = MA_TRUE; } else { - if (pData->deviceType == deviceType && (pData->pDeviceID != NULL && ma_strcmp(pData->pDeviceID->alsa, pDeviceInfo->id.alsa) == 0)) { + if (pData->deviceType == deviceType && (pData->pDeviceID != nullptr && ma_strcmp(pData->pDeviceID->alsa, pDeviceInfo->id.alsa) == 0)) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1); pData->foundDevice = MA_TRUE; } @@ -29006,9 +29006,9 @@ static ma_bool32 ma_context_get_device_info_enum_callback__alsa(ma_context* pCon static void ma_context_test_rate_and_add_native_data_format__alsa(ma_context* pContext, ma_snd_pcm_t* pPCM, ma_snd_pcm_hw_params_t* pHWParams, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags, ma_device_info* pDeviceInfo) { - MA_ASSERT(pPCM != NULL); - MA_ASSERT(pHWParams != NULL); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pPCM != nullptr); + MA_ASSERT(pHWParams != nullptr); + MA_ASSERT(pDeviceInfo != nullptr); if (pDeviceInfo->nativeDataFormatCount < ma_countof(pDeviceInfo->nativeDataFormats) && ((ma_snd_pcm_hw_params_test_rate_proc)pContext->alsa.snd_pcm_hw_params_test_rate)(pPCM, pHWParams, sampleRate, 0) == 0) { pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = format; @@ -29062,7 +29062,7 @@ static ma_result ma_context_get_device_info__alsa(ma_context* pContext, ma_devic ma_uint32 iFormat; ma_uint32 iChannel; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); /* We just enumerate to find basic information about the device. */ data.deviceType = deviceType; @@ -29090,7 +29090,7 @@ static ma_result ma_context_get_device_info__alsa(ma_context* pContext, ma_devic /* We need to initialize a HW parameters object in order to know what formats are supported. */ pHWParams = (ma_snd_pcm_hw_params_t*)ma_calloc(((ma_snd_pcm_hw_params_sizeof_proc)pContext->alsa.snd_pcm_hw_params_sizeof)(), &pContext->allocationCallbacks); - if (pHWParams == NULL) { + if (pHWParams == nullptr) { ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM); return MA_OUT_OF_MEMORY; } @@ -29192,7 +29192,7 @@ static ma_result ma_context_get_device_info__alsa(ma_context* pContext, ma_devic static ma_result ma_device_uninit__alsa(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if ((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture); @@ -29230,9 +29230,9 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic struct pollfd* pPollDescriptors; int wakeupfd; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); MA_ASSERT(deviceType != ma_device_type_duplex); /* This function should only be called for playback _or_ capture, never duplex. */ - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); formatALSA = ma_convert_ma_format_to_alsa_format(pDescriptor->format); @@ -29255,7 +29255,7 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic /* Hardware parameters. */ pHWParams = (ma_snd_pcm_hw_params_t*)ma_calloc(((ma_snd_pcm_hw_params_sizeof_proc)pDevice->pContext->alsa.snd_pcm_hw_params_sizeof)(), &pDevice->pContext->allocationCallbacks); - if (pHWParams == NULL) { + if (pHWParams == nullptr) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to allocate memory for hardware parameters."); return MA_OUT_OF_MEMORY; @@ -29400,7 +29400,7 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic { ma_uint32 periods = pDescriptor->periodCount; - resultALSA = ((ma_snd_pcm_hw_params_set_periods_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_periods_near)(pPCM, pHWParams, &periods, NULL); + resultALSA = ((ma_snd_pcm_hw_params_set_periods_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_periods_near)(pPCM, pHWParams, &periods, nullptr); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); @@ -29436,12 +29436,12 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic } ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); - pHWParams = NULL; + pHWParams = nullptr; /* Software parameters. */ pSWParams = (ma_snd_pcm_sw_params_t*)ma_calloc(((ma_snd_pcm_sw_params_sizeof_proc)pDevice->pContext->alsa.snd_pcm_sw_params_sizeof)(), &pDevice->pContext->allocationCallbacks); - if (pSWParams == NULL) { + if (pSWParams == nullptr) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to allocate memory for software parameters."); return MA_OUT_OF_MEMORY; @@ -29499,17 +29499,17 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic } ma_free(pSWParams, &pDevice->pContext->allocationCallbacks); - pSWParams = NULL; + pSWParams = nullptr; /* Grab the internal channel map. For now we're not going to bother trying to change the channel map and instead just do it ourselves. */ { - ma_snd_pcm_chmap_t* pChmap = NULL; - if (pDevice->pContext->alsa.snd_pcm_get_chmap != NULL) { + ma_snd_pcm_chmap_t* pChmap = nullptr; + if (pDevice->pContext->alsa.snd_pcm_get_chmap != nullptr) { pChmap = ((ma_snd_pcm_get_chmap_proc)pDevice->pContext->alsa.snd_pcm_get_chmap)(pPCM); } - if (pChmap != NULL) { + if (pChmap != nullptr) { ma_uint32 iChannel; /* There are cases where the returned channel map can have a different channel count than was returned by snd_pcm_hw_params_set_channels_near(). */ @@ -29553,7 +29553,7 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic } free(pChmap); - pChmap = NULL; + pChmap = nullptr; } else { /* Could not retrieve the channel map. Fall back to a hard-coded assumption. */ ma_channel_map_init_standard(ma_standard_channel_map_alsa, internalChannelMap, ma_countof(internalChannelMap), internalChannels); @@ -29574,7 +29574,7 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic } pPollDescriptors = (struct pollfd*)ma_malloc(sizeof(*pPollDescriptors) * (pollDescriptorCount + 1), &pDevice->pContext->allocationCallbacks); /* +1 because we want room for the wakeup descriptor. */ - if (pPollDescriptors == NULL) { + if (pPollDescriptors == nullptr) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to allocate memory for poll descriptors."); return MA_OUT_OF_MEMORY; @@ -29649,7 +29649,7 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic static ma_result ma_device_init__alsa(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->alsa); @@ -29843,10 +29843,10 @@ static ma_result ma_device_read__alsa(ma_device* pDevice, void* pFramesOut, ma_u { ma_snd_pcm_sframes_t resultALSA = 0; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pFramesOut != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pFramesOut != nullptr); - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -29888,7 +29888,7 @@ static ma_result ma_device_read__alsa(ma_device* pDevice, void* pFramesOut, ma_u } } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = resultALSA; } @@ -29899,10 +29899,10 @@ static ma_result ma_device_write__alsa(ma_device* pDevice, const void* pFrames, { ma_snd_pcm_sframes_t resultALSA = 0; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pFrames != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pFrames != nullptr); - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = 0; } @@ -29950,7 +29950,7 @@ static ma_result ma_device_write__alsa(ma_device* pDevice, const void* pFrames, } } - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = resultALSA; } @@ -29962,15 +29962,15 @@ static ma_result ma_device_data_loop_wakeup__alsa(ma_device* pDevice) ma_uint64 t = 1; int resultWrite = 0; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Waking up...\n"); /* Write to an eventfd to trigger a wakeup from poll() and abort any reading or writing. */ - if (pDevice->alsa.pPollDescriptorsCapture != NULL) { + if (pDevice->alsa.pPollDescriptorsCapture != nullptr) { resultWrite = write(pDevice->alsa.wakeupfdCapture, &t, sizeof(t)); } - if (pDevice->alsa.pPollDescriptorsPlayback != NULL) { + if (pDevice->alsa.pPollDescriptorsPlayback != nullptr) { resultWrite = write(pDevice->alsa.wakeupfdPlayback, &t, sizeof(t)); } @@ -29986,7 +29986,7 @@ static ma_result ma_device_data_loop_wakeup__alsa(ma_device* pDevice) static ma_result ma_context_uninit__alsa(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_alsa); /* Clean up memory for memory leak checkers. */ @@ -30013,12 +30013,12 @@ static ma_result ma_context_init__alsa(ma_context* pContext, const ma_context_co for (i = 0; i < ma_countof(libasoundNames); ++i) { pContext->alsa.asoundSO = ma_dlopen(ma_context_get_log(pContext), libasoundNames[i]); - if (pContext->alsa.asoundSO != NULL) { + if (pContext->alsa.asoundSO != nullptr) { break; } } - if (pContext->alsa.asoundSO == NULL) { + if (pContext->alsa.asoundSO == nullptr) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "[ALSA] Failed to open shared object.\n"); return MA_NO_BACKEND; } @@ -30246,7 +30246,7 @@ static ma_result ma_context_init__alsa(ma_context* pContext, const ma_context_co pCallbacks->onDeviceStop = ma_device_stop__alsa; pCallbacks->onDeviceRead = ma_device_read__alsa; pCallbacks->onDeviceWrite = ma_device_write__alsa; - pCallbacks->onDeviceDataLoop = NULL; + pCallbacks->onDeviceDataLoop = nullptr; pCallbacks->onDeviceDataLoopWakeup = ma_device_data_loop_wakeup__alsa; return MA_SUCCESS; @@ -31131,8 +31131,8 @@ static ma_result ma_wait_for_operation__pulse(ma_context* pContext, ma_ptr pMain int resultPA; ma_pa_operation_state_t state; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pOP != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pOP != nullptr); for (;;) { state = ((ma_pa_operation_get_state_proc)pContext->pulse.pa_operation_get_state)(pOP); @@ -31140,7 +31140,7 @@ static ma_result ma_wait_for_operation__pulse(ma_context* pContext, ma_ptr pMain break; /* Done. */ } - resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, NULL); + resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, nullptr); if (resultPA < 0) { return ma_result_from_pulse(resultPA); } @@ -31153,7 +31153,7 @@ static ma_result ma_wait_for_operation_and_unref__pulse(ma_context* pContext, ma { ma_result result; - if (pOP == NULL) { + if (pOP == nullptr) { return MA_INVALID_ARGS; } @@ -31179,7 +31179,7 @@ static ma_result ma_wait_for_pa_context_to_connect__pulse(ma_context* pContext, return MA_ERROR; } - resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, NULL); + resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, nullptr); if (resultPA < 0) { return ma_result_from_pulse(resultPA); } @@ -31205,7 +31205,7 @@ static ma_result ma_wait_for_pa_stream_to_connect__pulse(ma_context* pContext, m return MA_ERROR; } - resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, NULL); + resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, nullptr); if (resultPA < 0) { return ma_result_from_pulse(resultPA); } @@ -31221,25 +31221,25 @@ static ma_result ma_init_pa_mainloop_and_pa_context__pulse(ma_context* pContext, ma_ptr pMainLoop; ma_ptr pPulseContext; - MA_ASSERT(ppMainLoop != NULL); - MA_ASSERT(ppPulseContext != NULL); + MA_ASSERT(ppMainLoop != nullptr); + MA_ASSERT(ppPulseContext != nullptr); /* The PulseAudio context maps well to miniaudio's notion of a context. The pa_context object will be initialized as part of the ma_context. */ pMainLoop = ((ma_pa_mainloop_new_proc)pContext->pulse.pa_mainloop_new)(); - if (pMainLoop == NULL) { + if (pMainLoop == nullptr) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create mainloop."); return MA_FAILED_TO_INIT_BACKEND; } pPulseContext = ((ma_pa_context_new_proc)pContext->pulse.pa_context_new)(((ma_pa_mainloop_get_api_proc)pContext->pulse.pa_mainloop_get_api)((ma_pa_mainloop*)pMainLoop), pApplicationName); - if (pPulseContext == NULL) { + if (pPulseContext == nullptr) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio context."); ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pMainLoop)); return MA_FAILED_TO_INIT_BACKEND; } /* Now we need to connect to the context. Everything is asynchronous so we need to wait for it to connect before returning. */ - result = ma_result_from_pulse(((ma_pa_context_connect_proc)pContext->pulse.pa_context_connect)((ma_pa_context*)pPulseContext, pServerName, (tryAutoSpawn) ? MA_PA_CONTEXT_NOFLAGS : MA_PA_CONTEXT_NOAUTOSPAWN, NULL)); + result = ma_result_from_pulse(((ma_pa_context_connect_proc)pContext->pulse.pa_context_connect)((ma_pa_context*)pPulseContext, pServerName, (tryAutoSpawn) ? MA_PA_CONTEXT_NOFLAGS : MA_PA_CONTEXT_NOAUTOSPAWN, nullptr)); if (result != MA_SUCCESS) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio context."); ((ma_pa_context_unref_proc)pContext->pulse.pa_context_unref)((ma_pa_context*)(pPulseContext)); @@ -31275,12 +31275,12 @@ static void ma_device_sink_info_callback(ma_pa_context* pPulseContext, const ma_ There has been a report that indicates that pInfo can be null which results in a null pointer dereference below. We'll check for this for safety. */ - if (pInfo == NULL) { + if (pInfo == nullptr) { return; } pInfoOut = (ma_pa_sink_info*)pUserData; - MA_ASSERT(pInfoOut != NULL); + MA_ASSERT(pInfoOut != nullptr); *pInfoOut = *pInfo; @@ -31299,12 +31299,12 @@ static void ma_device_source_info_callback(ma_pa_context* pPulseContext, const m There has been a report that indicates that pInfo can be null which results in a null pointer dereference below. We'll check for this for safety. */ - if (pInfo == NULL) { + if (pInfo == nullptr) { return; } pInfoOut = (ma_pa_source_info*)pUserData; - MA_ASSERT(pInfoOut != NULL); + MA_ASSERT(pInfoOut != nullptr); *pInfoOut = *pInfo; @@ -31321,7 +31321,7 @@ static void ma_device_sink_name_callback(ma_pa_context* pPulseContext, const ma_ } pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), pInfo->description, (size_t)-1); @@ -31337,7 +31337,7 @@ static void ma_device_source_name_callback(ma_pa_context* pPulseContext, const m } pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), pInfo->description, (size_t)-1); @@ -31350,7 +31350,7 @@ static ma_result ma_context_get_sink_info__pulse(ma_context* pContext, const cha ma_pa_operation* pOP; pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, pDeviceName, ma_device_sink_info_callback, pSinkInfo); - if (pOP == NULL) { + if (pOP == nullptr) { return MA_ERROR; } @@ -31362,7 +31362,7 @@ static ma_result ma_context_get_source_info__pulse(ma_context* pContext, const c ma_pa_operation* pOP; pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, pDeviceName, ma_device_source_info_callback, pSourceInfo); - if (pOP == NULL) { + if (pOP == nullptr) { return MA_ERROR; } @@ -31373,33 +31373,33 @@ static ma_result ma_context_get_default_device_index__pulse(ma_context* pContext { ma_result result; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pIndex != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pIndex != nullptr); - if (pIndex != NULL) { + if (pIndex != nullptr) { *pIndex = (ma_uint32)-1; } if (deviceType == ma_device_type_playback) { ma_pa_sink_info sinkInfo; - result = ma_context_get_sink_info__pulse(pContext, NULL, &sinkInfo); + result = ma_context_get_sink_info__pulse(pContext, nullptr, &sinkInfo); if (result != MA_SUCCESS) { return result; } - if (pIndex != NULL) { + if (pIndex != nullptr) { *pIndex = sinkInfo.index; } } if (deviceType == ma_device_type_capture) { ma_pa_source_info sourceInfo; - result = ma_context_get_source_info__pulse(pContext, NULL, &sourceInfo); + result = ma_context_get_source_info__pulse(pContext, nullptr, &sourceInfo); if (result != MA_SUCCESS) { return result; } - if (pIndex != NULL) { + if (pIndex != nullptr) { *pIndex = sourceInfo.index; } } @@ -31423,7 +31423,7 @@ static void ma_context_enumerate_devices_sink_callback__pulse(ma_pa_context* pPu ma_context_enumerate_devices_callback_data__pulse* pData = (ma_context_enumerate_devices_callback_data__pulse*)pUserData; ma_device_info deviceInfo; - MA_ASSERT(pData != NULL); + MA_ASSERT(pData != nullptr); if (endOfList || pData->isTerminated) { return; @@ -31432,12 +31432,12 @@ static void ma_context_enumerate_devices_sink_callback__pulse(ma_pa_context* pPu MA_ZERO_OBJECT(&deviceInfo); /* The name from PulseAudio is the ID for miniaudio. */ - if (pSinkInfo->name != NULL) { + if (pSinkInfo->name != nullptr) { ma_strncpy_s(deviceInfo.id.pulse, sizeof(deviceInfo.id.pulse), pSinkInfo->name, (size_t)-1); } /* The description from PulseAudio is the name for miniaudio. */ - if (pSinkInfo->description != NULL) { + if (pSinkInfo->description != nullptr) { ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), pSinkInfo->description, (size_t)-1); } @@ -31455,7 +31455,7 @@ static void ma_context_enumerate_devices_source_callback__pulse(ma_pa_context* p ma_context_enumerate_devices_callback_data__pulse* pData = (ma_context_enumerate_devices_callback_data__pulse*)pUserData; ma_device_info deviceInfo; - MA_ASSERT(pData != NULL); + MA_ASSERT(pData != nullptr); if (endOfList || pData->isTerminated) { return; @@ -31464,12 +31464,12 @@ static void ma_context_enumerate_devices_source_callback__pulse(ma_pa_context* p MA_ZERO_OBJECT(&deviceInfo); /* The name from PulseAudio is the ID for miniaudio. */ - if (pSourceInfo->name != NULL) { + if (pSourceInfo->name != nullptr) { ma_strncpy_s(deviceInfo.id.pulse, sizeof(deviceInfo.id.pulse), pSourceInfo->name, (size_t)-1); } /* The description from PulseAudio is the name for miniaudio. */ - if (pSourceInfo->description != NULL) { + if (pSourceInfo->description != nullptr) { ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), pSourceInfo->description, (size_t)-1); } @@ -31486,10 +31486,10 @@ static ma_result ma_context_enumerate_devices__pulse(ma_context* pContext, ma_en { ma_result result = MA_SUCCESS; ma_context_enumerate_devices_callback_data__pulse callbackData; - ma_pa_operation* pOP = NULL; + ma_pa_operation* pOP = nullptr; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); callbackData.pContext = pContext; callbackData.callback = callback; @@ -31505,7 +31505,7 @@ static ma_result ma_context_enumerate_devices__pulse(ma_context* pContext, ma_en /* Playback. */ if (!callbackData.isTerminated) { pOP = ((ma_pa_context_get_sink_info_list_proc)pContext->pulse.pa_context_get_sink_info_list)((ma_pa_context*)(pContext->pulse.pPulseContext), ma_context_enumerate_devices_sink_callback__pulse, &callbackData); - if (pOP == NULL) { + if (pOP == nullptr) { result = MA_ERROR; goto done; } @@ -31522,7 +31522,7 @@ static ma_result ma_context_enumerate_devices__pulse(ma_context* pContext, ma_en /* Capture. */ if (!callbackData.isTerminated) { pOP = ((ma_pa_context_get_source_info_list_proc)pContext->pulse.pa_context_get_source_info_list)((ma_pa_context*)(pContext->pulse.pPulseContext), ma_context_enumerate_devices_source_callback__pulse, &callbackData); - if (pOP == NULL) { + if (pOP == nullptr) { result = MA_ERROR; goto done; } @@ -31555,14 +31555,14 @@ static void ma_context_get_device_info_sink_callback__pulse(ma_pa_context* pPuls return; } - MA_ASSERT(pData != NULL); + MA_ASSERT(pData != nullptr); pData->foundDevice = MA_TRUE; - if (pInfo->name != NULL) { + if (pInfo->name != nullptr) { ma_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1); } - if (pInfo->description != NULL) { + if (pInfo->description != nullptr) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pInfo->description, (size_t)-1); } @@ -31592,14 +31592,14 @@ static void ma_context_get_device_info_source_callback__pulse(ma_pa_context* pPu return; } - MA_ASSERT(pData != NULL); + MA_ASSERT(pData != nullptr); pData->foundDevice = MA_TRUE; - if (pInfo->name != NULL) { + if (pInfo->name != nullptr) { ma_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1); } - if (pInfo->description != NULL) { + if (pInfo->description != nullptr) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pInfo->description, (size_t)-1); } @@ -31625,18 +31625,18 @@ static ma_result ma_context_get_device_info__pulse(ma_context* pContext, ma_devi { ma_result result = MA_SUCCESS; ma_context_get_device_info_callback_data__pulse callbackData; - ma_pa_operation* pOP = NULL; - const char* pDeviceName = NULL; + ma_pa_operation* pOP = nullptr; + const char* pDeviceName = nullptr; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); callbackData.pDeviceInfo = pDeviceInfo; callbackData.foundDevice = MA_FALSE; - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { pDeviceName = pDeviceID->pulse; } else { - pDeviceName = NULL; + pDeviceName = nullptr; } result = ma_context_get_default_device_index__pulse(pContext, deviceType, &callbackData.defaultDeviceIndex); @@ -31647,7 +31647,7 @@ static ma_result ma_context_get_device_info__pulse(ma_context* pContext, ma_devi pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceName, ma_context_get_device_info_source_callback__pulse, &callbackData); } - if (pOP != NULL) { + if (pOP != nullptr) { ma_wait_for_operation_and_unref__pulse(pContext, pContext->pulse.pMainLoop, pOP); } else { result = MA_ERROR; @@ -31667,10 +31667,10 @@ static ma_result ma_device_uninit__pulse(ma_device* pDevice) { ma_context* pContext; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); pContext = pDevice->pContext; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((ma_pa_stream_disconnect_proc)pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamCapture); @@ -31710,7 +31710,7 @@ static ma_pa_stream* ma_device__pa_stream_new__pulse(ma_device* pDevice, const c static ma_atomic_uint32 g_StreamCounter = { 0 }; char actualStreamName[256]; - if (pStreamName != NULL) { + if (pStreamName != nullptr) { ma_strncpy_s(actualStreamName, sizeof(actualStreamName), pStreamName, (size_t)-1); } else { const char* pBaseName = "miniaudio:"; @@ -31732,7 +31732,7 @@ static void ma_device_on_read__pulse(ma_pa_stream* pStream, size_t byteCount, vo ma_uint64 frameCount; ma_uint64 framesProcessed; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Don't do anything if the device isn't initialized yet. Yes, this can happen because PulseAudio @@ -31761,8 +31761,8 @@ static void ma_device_on_read__pulse(ma_pa_stream* pStream, size_t byteCount, vo framesMapped = bytesMapped / bpf; if (framesMapped > 0) { - if (pMappedPCMFrames != NULL) { - ma_device_handle_backend_data_callback(pDevice, NULL, pMappedPCMFrames, framesMapped); + if (pMappedPCMFrames != nullptr) { + ma_device_handle_backend_data_callback(pDevice, nullptr, pMappedPCMFrames, framesMapped); } else { /* It's a hole. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[PulseAudio] ma_device_on_read__pulse: Hole.\n"); @@ -31790,8 +31790,8 @@ static ma_result ma_device_write_to_stream__pulse(ma_device* pDevice, ma_pa_stre ma_uint32 bpf; ma_uint32 deviceState; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pStream != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pStream != nullptr); bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); MA_ASSERT(bpf > 0); @@ -31812,13 +31812,13 @@ static ma_result ma_device_write_to_stream__pulse(ma_device* pDevice, ma_pa_stre framesMapped = bytesMapped / bpf; if (deviceState == ma_device_state_started || deviceState == ma_device_state_starting) { /* Check for starting state just in case this is being used to do the initial fill. */ - ma_device_handle_backend_data_callback(pDevice, pMappedPCMFrames, NULL, framesMapped); + ma_device_handle_backend_data_callback(pDevice, pMappedPCMFrames, nullptr, framesMapped); } else { /* Device is not started. Write silence. */ ma_silence_pcm_frames(pMappedPCMFrames, framesMapped, pDevice->playback.format, pDevice->playback.channels); } - pulseResult = ((ma_pa_stream_write_proc)pDevice->pContext->pulse.pa_stream_write)(pStream, pMappedPCMFrames, bytesMapped, NULL, 0, MA_PA_SEEK_RELATIVE); + pulseResult = ((ma_pa_stream_write_proc)pDevice->pContext->pulse.pa_stream_write)(pStream, pMappedPCMFrames, bytesMapped, nullptr, 0, MA_PA_SEEK_RELATIVE); if (pulseResult < 0) { result = ma_result_from_pulse(pulseResult); goto done; /* Failed to write data to stream. */ @@ -31835,7 +31835,7 @@ static ma_result ma_device_write_to_stream__pulse(ma_device* pDevice, ma_pa_stre } done: - if (pFramesProcessed != NULL) { + if (pFramesProcessed != nullptr) { *pFramesProcessed = framesProcessed; } @@ -31851,7 +31851,7 @@ static void ma_device_on_write__pulse(ma_pa_stream* pStream, size_t byteCount, v ma_uint32 deviceState; ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Don't do anything if the device isn't initialized yet. Yes, this can happen because PulseAudio @@ -31960,8 +31960,8 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi ma_result result = MA_SUCCESS; int error = 0; - const char* devPlayback = NULL; - const char* devCapture = NULL; + const char* devPlayback = nullptr; + const char* devCapture = nullptr; ma_format format = ma_format_unknown; ma_uint32 channels = 0; ma_uint32 sampleRate = 0; @@ -31970,13 +31970,13 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi ma_pa_sample_spec ss; ma_pa_channel_map cmap; ma_pa_buffer_attr attr; - const ma_pa_sample_spec* pActualSS = NULL; - const ma_pa_buffer_attr* pActualAttr = NULL; - const ma_pa_channel_map* pActualChannelMap = NULL; + const ma_pa_sample_spec* pActualSS = nullptr; + const ma_pa_buffer_attr* pActualAttr = nullptr; + const ma_pa_channel_map* pActualChannelMap = nullptr; ma_uint32 iChannel; int streamFlags; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->pulse); if (pConfig->deviceType == ma_device_type_loopback) { @@ -31990,7 +31990,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { - if (pDescriptorPlayback->pDeviceID != NULL) { + if (pDescriptorPlayback->pDeviceID != nullptr) { devPlayback = pDescriptorPlayback->pDeviceID->pulse; } @@ -32000,7 +32000,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi } if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { - if (pDescriptorCapture->pDeviceID != NULL) { + if (pDescriptorCapture->pDeviceID != nullptr) { devCapture = pDescriptorCapture->pDeviceID->pulse; } @@ -32073,7 +32073,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Capture attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames); pDevice->pulse.pStreamCapture = ma_device__pa_stream_new__pulse(pDevice, pConfig->pulse.pStreamNameCapture, &ss, &cmap); - if (pDevice->pulse.pStreamCapture == NULL) { + if (pDevice->pulse.pStreamCapture == nullptr) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio capture stream.\n"); result = MA_ERROR; goto on_error0; @@ -32091,7 +32091,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi /* Connect after we've got all of our internal state set up. */ - if (devCapture != NULL) { + if (devCapture != nullptr) { streamFlags |= MA_PA_STREAM_DONT_MOVE; } @@ -32110,7 +32110,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi /* Internal format. */ pActualSS = ((ma_pa_stream_get_sample_spec_proc)pDevice->pContext->pulse.pa_stream_get_sample_spec)((ma_pa_stream*)pDevice->pulse.pStreamCapture); - if (pActualSS != NULL) { + if (pActualSS != nullptr) { ss = *pActualSS; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Capture sample spec: format=%s, channels=%d, rate=%d\n", ma_get_format_name(ma_format_from_pulse(ss.format)), ss.channels, ss.rate); } else { @@ -32130,7 +32130,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi /* Internal channel map. */ pActualChannelMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamCapture); - if (pActualChannelMap == NULL) { + if (pActualChannelMap == nullptr) { pActualChannelMap = &cmap; /* Fallback just in case. */ } @@ -32160,7 +32160,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi /* Buffer. */ pActualAttr = ((ma_pa_stream_get_buffer_attr_proc)pDevice->pContext->pulse.pa_stream_get_buffer_attr)((ma_pa_stream*)pDevice->pulse.pStreamCapture); - if (pActualAttr != NULL) { + if (pActualAttr != nullptr) { attr = *pActualAttr; } @@ -32232,7 +32232,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Playback attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorPlayback->periodSizeInFrames); pDevice->pulse.pStreamPlayback = ma_device__pa_stream_new__pulse(pDevice, pConfig->pulse.pStreamNamePlayback, &ss, &cmap); - if (pDevice->pulse.pStreamPlayback == NULL) { + if (pDevice->pulse.pStreamPlayback == nullptr) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio playback stream.\n"); result = MA_ERROR; goto on_error2; @@ -32253,11 +32253,11 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi /* Connect after we've got all of our internal state set up. */ - if (devPlayback != NULL) { + if (devPlayback != nullptr) { streamFlags |= MA_PA_STREAM_DONT_MOVE; } - error = ((ma_pa_stream_connect_playback_proc)pDevice->pContext->pulse.pa_stream_connect_playback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, devPlayback, &attr, (ma_pa_stream_flags_t)streamFlags, NULL, NULL); + error = ((ma_pa_stream_connect_playback_proc)pDevice->pContext->pulse.pa_stream_connect_playback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, devPlayback, &attr, (ma_pa_stream_flags_t)streamFlags, nullptr, nullptr); if (error != MA_PA_OK) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio playback stream."); result = ma_result_from_pulse(error); @@ -32272,7 +32272,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi /* Internal format. */ pActualSS = ((ma_pa_stream_get_sample_spec_proc)pDevice->pContext->pulse.pa_stream_get_sample_spec)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); - if (pActualSS != NULL) { + if (pActualSS != nullptr) { ss = *pActualSS; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Playback sample spec: format=%s, channels=%d, rate=%d\n", ma_get_format_name(ma_format_from_pulse(ss.format)), ss.channels, ss.rate); } else { @@ -32292,7 +32292,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi /* Internal channel map. */ pActualChannelMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); - if (pActualChannelMap == NULL) { + if (pActualChannelMap == nullptr) { pActualChannelMap = &cmap; /* Fallback just in case. */ } @@ -32322,7 +32322,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi /* Buffer. */ pActualAttr = ((ma_pa_stream_get_buffer_attr_proc)pDevice->pContext->pulse.pa_stream_get_buffer_attr)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); - if (pActualAttr != NULL) { + if (pActualAttr != nullptr) { attr = *pActualAttr; } @@ -32341,7 +32341,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi We need a ring buffer for handling duplex mode. We can use the main duplex ring buffer in the main part of the ma_device struct. We cannot, however, depend on ma_device_init() initializing this for us later on because that will only do it if it's a fully asynchronous backend - i.e. the - onDeviceDataLoop callback is NULL, which is not the case for PulseAudio. + onDeviceDataLoop callback is nullptr, which is not the case for PulseAudio. */ if (pConfig->deviceType == ma_device_type_duplex) { ma_format rbFormat = (format != ma_format_unknown) ? format : pDescriptorCapture->format; @@ -32382,7 +32382,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi static void ma_pulse_operation_complete_callback(ma_pa_stream* pStream, int success, void* pUserData) { ma_bool32* pIsSuccessful = (ma_bool32*)pUserData; - MA_ASSERT(pIsSuccessful != NULL); + MA_ASSERT(pIsSuccessful != nullptr); *pIsSuccessful = (ma_bool32)success; @@ -32405,10 +32405,10 @@ static ma_result ma_device__cork_stream__pulse(ma_device* pDevice, ma_device_typ wasSuccessful = MA_FALSE; pStream = (ma_pa_stream*)((deviceType == ma_device_type_capture) ? pDevice->pulse.pStreamCapture : pDevice->pulse.pStreamPlayback); - MA_ASSERT(pStream != NULL); + MA_ASSERT(pStream != nullptr); pOP = ((ma_pa_stream_cork_proc)pContext->pulse.pa_stream_cork)(pStream, cork, ma_pulse_operation_complete_callback, &wasSuccessful); - if (pOP == NULL) { + if (pOP == nullptr) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to cork PulseAudio stream."); return MA_ERROR; } @@ -32431,7 +32431,7 @@ static ma_result ma_device_start__pulse(ma_device* pDevice) { ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { result = ma_device__cork_stream__pulse(pDevice, ma_device_type_capture, 0); @@ -32446,7 +32446,7 @@ static ma_result ma_device_start__pulse(ma_device* pDevice) never getting fired. We're not going to abort if writing fails because I still want the device to get uncorked. */ - ma_device_write_to_stream__pulse(pDevice, (ma_pa_stream*)(pDevice->pulse.pStreamPlayback), NULL); /* No need to check the result here. Always want to fall through an uncork.*/ + ma_device_write_to_stream__pulse(pDevice, (ma_pa_stream*)(pDevice->pulse.pStreamPlayback), nullptr); /* No need to check the result here. Always want to fall through an uncork.*/ result = ma_device__cork_stream__pulse(pDevice, ma_device_type_playback, 0); if (result != MA_SUCCESS) { @@ -32461,7 +32461,7 @@ static ma_result ma_device_stop__pulse(ma_device* pDevice) { ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { result = ma_device__cork_stream__pulse(pDevice, ma_device_type_capture, 1); @@ -32495,7 +32495,7 @@ static ma_result ma_device_data_loop__pulse(ma_device* pDevice) { int resultPA; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* NOTE: Don't start the device here. It'll be done at a higher level. */ @@ -32504,7 +32504,7 @@ static ma_result ma_device_data_loop__pulse(ma_device* pDevice) the callbacks deal with it. */ while (ma_device_get_state(pDevice) == ma_device_state_started) { - resultPA = ((ma_pa_mainloop_iterate_proc)pDevice->pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pDevice->pulse.pMainLoop, 1, NULL); + resultPA = ((ma_pa_mainloop_iterate_proc)pDevice->pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pDevice->pulse.pMainLoop, 1, nullptr); if (resultPA < 0) { break; } @@ -32516,7 +32516,7 @@ static ma_result ma_device_data_loop__pulse(ma_device* pDevice) static ma_result ma_device_data_loop_wakeup__pulse(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ((ma_pa_mainloop_wakeup_proc)pDevice->pContext->pulse.pa_mainloop_wakeup)((ma_pa_mainloop*)pDevice->pulse.pMainLoop); @@ -32525,7 +32525,7 @@ static ma_result ma_device_data_loop_wakeup__pulse(ma_device* pDevice) static ma_result ma_context_uninit__pulse(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_pulseaudio); ((ma_pa_context_disconnect_proc)pContext->pulse.pa_context_disconnect)((ma_pa_context*)pContext->pulse.pPulseContext); @@ -32554,12 +32554,12 @@ static ma_result ma_context_init__pulse(ma_context* pContext, const ma_context_c for (i = 0; i < ma_countof(libpulseNames); ++i) { pContext->pulse.pulseSO = ma_dlopen(ma_context_get_log(pContext), libpulseNames[i]); - if (pContext->pulse.pulseSO != NULL) { + if (pContext->pulse.pulseSO != nullptr) { break; } } - if (pContext->pulse.pulseSO == NULL) { + if (pContext->pulse.pulseSO == nullptr) { return MA_NO_BACKEND; } @@ -32753,12 +32753,12 @@ static ma_result ma_context_init__pulse(ma_context* pContext, const ma_context_c /* We need to make a copy of the application and server names so we can pass them to the pa_context of each device. */ pContext->pulse.pApplicationName = ma_copy_string(pConfig->pulse.pApplicationName, &pContext->allocationCallbacks); - if (pContext->pulse.pApplicationName == NULL && pConfig->pulse.pApplicationName != NULL) { + if (pContext->pulse.pApplicationName == nullptr && pConfig->pulse.pApplicationName != nullptr) { return MA_OUT_OF_MEMORY; } pContext->pulse.pServerName = ma_copy_string(pConfig->pulse.pServerName, &pContext->allocationCallbacks); - if (pContext->pulse.pServerName == NULL && pConfig->pulse.pServerName != NULL) { + if (pContext->pulse.pServerName == nullptr && pConfig->pulse.pServerName != nullptr) { ma_free(pContext->pulse.pApplicationName, &pContext->allocationCallbacks); return MA_OUT_OF_MEMORY; } @@ -32782,8 +32782,8 @@ static ma_result ma_context_init__pulse(ma_context* pContext, const ma_context_c pCallbacks->onDeviceUninit = ma_device_uninit__pulse; pCallbacks->onDeviceStart = ma_device_start__pulse; pCallbacks->onDeviceStop = ma_device_stop__pulse; - pCallbacks->onDeviceRead = NULL; /* Not used because we're implementing onDeviceDataLoop. */ - pCallbacks->onDeviceWrite = NULL; /* Not used because we're implementing onDeviceDataLoop. */ + pCallbacks->onDeviceRead = nullptr; /* Not used because we're implementing onDeviceDataLoop. */ + pCallbacks->onDeviceWrite = nullptr; /* Not used because we're implementing onDeviceDataLoop. */ pCallbacks->onDeviceDataLoop = ma_device_data_loop__pulse; pCallbacks->onDeviceDataLoopWakeup = ma_device_data_loop_wakeup__pulse; @@ -32858,18 +32858,18 @@ static ma_result ma_context_open_client__jack(ma_context* pContext, ma_jack_clie ma_jack_status_t status; ma_jack_client_t* pClient; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppClient != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppClient != nullptr); if (ppClient) { - *ppClient = NULL; + *ppClient = nullptr; } maxClientNameSize = ((ma_jack_client_name_size_proc)pContext->jack.jack_client_name_size)(); /* Includes null terminator. */ - ma_strncpy_s(clientName, ma_min(sizeof(clientName), maxClientNameSize), (pContext->jack.pClientName != NULL) ? pContext->jack.pClientName : "miniaudio", (size_t)-1); + ma_strncpy_s(clientName, ma_min(sizeof(clientName), maxClientNameSize), (pContext->jack.pClientName != nullptr) ? pContext->jack.pClientName : "miniaudio", (size_t)-1); - pClient = ((ma_jack_client_open_proc)pContext->jack.jack_client_open)(clientName, (pContext->jack.tryStartServer) ? ma_JackNullOption : ma_JackNoStartServer, &status, NULL); - if (pClient == NULL) { + pClient = ((ma_jack_client_open_proc)pContext->jack.jack_client_open)(clientName, (pContext->jack.tryStartServer) ? ma_JackNullOption : ma_JackNoStartServer, &status, nullptr); + if (pClient == nullptr) { return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } @@ -32885,8 +32885,8 @@ static ma_result ma_context_enumerate_devices__jack(ma_context* pContext, ma_enu { ma_bool32 cbResult = MA_TRUE; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); /* Playback. */ if (cbResult) { @@ -32917,9 +32917,9 @@ static ma_result ma_context_get_device_info__jack(ma_context* pContext, ma_devic ma_result result; const char** ppPorts; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); - if (pDeviceID != NULL && pDeviceID->jack != 0) { + if (pDeviceID != nullptr && pDeviceID->jack != 0) { return MA_NO_DEVICE; /* Don't know the device. */ } @@ -32946,14 +32946,14 @@ static ma_result ma_context_get_device_info__jack(ma_context* pContext, ma_devic pDeviceInfo->nativeDataFormats[0].sampleRate = ((ma_jack_get_sample_rate_proc)pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pClient); pDeviceInfo->nativeDataFormats[0].channels = 0; - ppPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ((deviceType == ma_device_type_playback) ? ma_JackPortIsInput : ma_JackPortIsOutput)); - if (ppPorts == NULL) { + ppPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pClient, nullptr, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ((deviceType == ma_device_type_playback) ? ma_JackPortIsInput : ma_JackPortIsOutput)); + if (ppPorts == nullptr) { ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pClient); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } - while (ppPorts[pDeviceInfo->nativeDataFormats[0].channels] != NULL) { + while (ppPorts[pDeviceInfo->nativeDataFormats[0].channels] != nullptr) { pDeviceInfo->nativeDataFormats[0].channels += 1; } @@ -32972,12 +32972,12 @@ static ma_result ma_device_uninit__jack(ma_device* pDevice) { ma_context* pContext; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); pContext = pDevice->pContext; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); - if (pDevice->jack.pClient != NULL) { + if (pDevice->jack.pClient != nullptr) { ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pDevice->jack.pClient); } @@ -32998,7 +32998,7 @@ static void ma_device__jack_shutdown_callback(void* pUserData) { /* JACK died. Stop the device. */ ma_device* pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_device_stop(pDevice); } @@ -33006,12 +33006,12 @@ static void ma_device__jack_shutdown_callback(void* pUserData) static int ma_device__jack_buffer_size_callback(ma_jack_nframes_t frameCount, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { size_t newBufferSize = frameCount * (pDevice->capture.internalChannels * ma_get_bytes_per_sample(pDevice->capture.internalFormat)); float* pNewBuffer = (float*)ma_calloc(newBufferSize, &pDevice->pContext->allocationCallbacks); - if (pNewBuffer == NULL) { + if (pNewBuffer == nullptr) { return MA_OUT_OF_MEMORY; } @@ -33024,7 +33024,7 @@ static int ma_device__jack_buffer_size_callback(ma_jack_nframes_t frameCount, vo if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { size_t newBufferSize = frameCount * (pDevice->playback.internalChannels * ma_get_bytes_per_sample(pDevice->playback.internalFormat)); float* pNewBuffer = (float*)ma_calloc(newBufferSize, &pDevice->pContext->allocationCallbacks); - if (pNewBuffer == NULL) { + if (pNewBuffer == nullptr) { return MA_OUT_OF_MEMORY; } @@ -33044,16 +33044,16 @@ static int ma_device__jack_process_callback(ma_jack_nframes_t frameCount, void* ma_uint32 iChannel; pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); pContext = pDevice->pContext; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { /* Channels need to be interleaved. */ for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) { const float* pSrc = (const float*)((ma_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((ma_jack_port_t*)pDevice->jack.ppPortsCapture[iChannel], frameCount); - if (pSrc != NULL) { + if (pSrc != nullptr) { float* pDst = pDevice->jack.pIntermediaryBufferCapture + iChannel; ma_jack_nframes_t iFrame; for (iFrame = 0; iFrame < frameCount; ++iFrame) { @@ -33065,16 +33065,16 @@ static int ma_device__jack_process_callback(ma_jack_nframes_t frameCount, void* } } - ma_device_handle_backend_data_callback(pDevice, NULL, pDevice->jack.pIntermediaryBufferCapture, frameCount); + ma_device_handle_backend_data_callback(pDevice, nullptr, pDevice->jack.pIntermediaryBufferCapture, frameCount); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { - ma_device_handle_backend_data_callback(pDevice, pDevice->jack.pIntermediaryBufferPlayback, NULL, frameCount); + ma_device_handle_backend_data_callback(pDevice, pDevice->jack.pIntermediaryBufferPlayback, nullptr, frameCount); /* Channels need to be deinterleaved. */ for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) { float* pDst = (float*)((ma_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((ma_jack_port_t*)pDevice->jack.ppPortsPlayback[iChannel], frameCount); - if (pDst != NULL) { + if (pDst != nullptr) { const float* pSrc = pDevice->jack.pIntermediaryBufferPlayback + iChannel; ma_jack_nframes_t iFrame; for (iFrame = 0; iFrame < frameCount; ++iFrame) { @@ -33095,8 +33095,8 @@ static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config ma_result result; ma_uint32 periodSizeInFrames; - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDevice != nullptr); if (pConfig->deviceType == ma_device_type_loopback) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Loopback mode not supported."); @@ -33104,8 +33104,8 @@ static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config } /* Only supporting default devices with JACK. */ - if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->pDeviceID != NULL && pDescriptorPlayback->pDeviceID->jack != 0) || - ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->pDeviceID != NULL && pDescriptorCapture->pDeviceID->jack != 0)) { + if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->pDeviceID != nullptr && pDescriptorPlayback->pDeviceID->jack != 0) || + ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->pDeviceID != nullptr && pDescriptorCapture->pDeviceID->jack != 0)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Only default devices are supported."); return MA_NO_DEVICE; } @@ -33149,19 +33149,19 @@ static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config pDescriptorCapture->sampleRate = ((ma_jack_get_sample_rate_proc)pDevice->pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pDevice->jack.pClient); ma_channel_map_init_standard(ma_standard_channel_map_alsa, pDescriptorCapture->channelMap, ma_countof(pDescriptorCapture->channelMap), pDescriptorCapture->channels); - ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput); - if (ppPorts == NULL) { + ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, nullptr, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput); + if (ppPorts == nullptr) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } /* Need to count the number of ports first so we can allocate some memory. */ - while (ppPorts[pDescriptorCapture->channels] != NULL) { + while (ppPorts[pDescriptorCapture->channels] != nullptr) { pDescriptorCapture->channels += 1; } pDevice->jack.ppPortsCapture = (ma_ptr*)ma_malloc(sizeof(*pDevice->jack.ppPortsCapture) * pDescriptorCapture->channels, &pDevice->pContext->allocationCallbacks); - if (pDevice->jack.ppPortsCapture == NULL) { + if (pDevice->jack.ppPortsCapture == nullptr) { return MA_OUT_OF_MEMORY; } @@ -33171,7 +33171,7 @@ static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config ma_itoa_s((int)iPort, name+7, sizeof(name)-7, 10); /* 7 = length of "capture" */ pDevice->jack.ppPortsCapture[iPort] = ((ma_jack_port_register_proc)pDevice->pContext->jack.jack_port_register)((ma_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsInput, 0); - if (pDevice->jack.ppPortsCapture[iPort] == NULL) { + if (pDevice->jack.ppPortsCapture[iPort] == nullptr) { ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts); ma_device_uninit__jack(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports."); @@ -33185,7 +33185,7 @@ static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config pDescriptorCapture->periodCount = 1; /* There's no notion of a period in JACK. Just set to 1. */ pDevice->jack.pIntermediaryBufferCapture = (float*)ma_calloc(pDescriptorCapture->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels), &pDevice->pContext->allocationCallbacks); - if (pDevice->jack.pIntermediaryBufferCapture == NULL) { + if (pDevice->jack.pIntermediaryBufferCapture == nullptr) { ma_device_uninit__jack(pDevice); return MA_OUT_OF_MEMORY; } @@ -33200,19 +33200,19 @@ static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config pDescriptorPlayback->sampleRate = ((ma_jack_get_sample_rate_proc)pDevice->pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pDevice->jack.pClient); ma_channel_map_init_standard(ma_standard_channel_map_alsa, pDescriptorPlayback->channelMap, ma_countof(pDescriptorPlayback->channelMap), pDescriptorPlayback->channels); - ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput); - if (ppPorts == NULL) { + ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, nullptr, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput); + if (ppPorts == nullptr) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } /* Need to count the number of ports first so we can allocate some memory. */ - while (ppPorts[pDescriptorPlayback->channels] != NULL) { + while (ppPorts[pDescriptorPlayback->channels] != nullptr) { pDescriptorPlayback->channels += 1; } pDevice->jack.ppPortsPlayback = (ma_ptr*)ma_malloc(sizeof(*pDevice->jack.ppPortsPlayback) * pDescriptorPlayback->channels, &pDevice->pContext->allocationCallbacks); - if (pDevice->jack.ppPortsPlayback == NULL) { + if (pDevice->jack.ppPortsPlayback == nullptr) { ma_free(pDevice->jack.ppPortsCapture, &pDevice->pContext->allocationCallbacks); return MA_OUT_OF_MEMORY; } @@ -33223,7 +33223,7 @@ static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config ma_itoa_s((int)iPort, name+8, sizeof(name)-8, 10); /* 8 = length of "playback" */ pDevice->jack.ppPortsPlayback[iPort] = ((ma_jack_port_register_proc)pDevice->pContext->jack.jack_port_register)((ma_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsOutput, 0); - if (pDevice->jack.ppPortsPlayback[iPort] == NULL) { + if (pDevice->jack.ppPortsPlayback[iPort] == nullptr) { ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts); ma_device_uninit__jack(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports."); @@ -33237,7 +33237,7 @@ static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config pDescriptorPlayback->periodCount = 1; /* There's no notion of a period in JACK. Just set to 1. */ pDevice->jack.pIntermediaryBufferPlayback = (float*)ma_calloc(pDescriptorPlayback->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels), &pDevice->pContext->allocationCallbacks); - if (pDevice->jack.pIntermediaryBufferPlayback == NULL) { + if (pDevice->jack.pIntermediaryBufferPlayback == nullptr) { ma_device_uninit__jack(pDevice); return MA_OUT_OF_MEMORY; } @@ -33260,14 +33260,14 @@ static ma_result ma_device_start__jack(ma_device* pDevice) } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { - const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput); - if (ppServerPorts == NULL) { + const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, nullptr, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput); + if (ppServerPorts == nullptr) { ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports."); return MA_ERROR; } - for (i = 0; ppServerPorts[i] != NULL; ++i) { + for (i = 0; ppServerPorts[i] != nullptr; ++i) { const char* pServerPort = ppServerPorts[i]; const char* pClientPort = ((ma_jack_port_name_proc)pContext->jack.jack_port_name)((ma_jack_port_t*)pDevice->jack.ppPortsCapture[i]); @@ -33284,14 +33284,14 @@ static ma_result ma_device_start__jack(ma_device* pDevice) } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { - const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput); - if (ppServerPorts == NULL) { + const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, nullptr, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput); + if (ppServerPorts == nullptr) { ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports."); return MA_ERROR; } - for (i = 0; ppServerPorts[i] != NULL; ++i) { + for (i = 0; ppServerPorts[i] != nullptr; ++i) { const char* pServerPort = ppServerPorts[i]; const char* pClientPort = ((ma_jack_port_name_proc)pContext->jack.jack_port_name)((ma_jack_port_t*)pDevice->jack.ppPortsPlayback[i]); @@ -33327,11 +33327,11 @@ static ma_result ma_device_stop__jack(ma_device* pDevice) static ma_result ma_context_uninit__jack(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_jack); ma_free(pContext->jack.pClientName, &pContext->allocationCallbacks); - pContext->jack.pClientName = NULL; + pContext->jack.pClientName = nullptr; #ifndef MA_NO_RUNTIME_LINKING ma_dlclose(ma_context_get_log(pContext), pContext->jack.jackSO); @@ -33357,12 +33357,12 @@ static ma_result ma_context_init__jack(ma_context* pContext, const ma_context_co for (i = 0; i < ma_countof(libjackNames); ++i) { pContext->jack.jackSO = ma_dlopen(ma_context_get_log(pContext), libjackNames[i]); - if (pContext->jack.jackSO != NULL) { + if (pContext->jack.jackSO != nullptr) { break; } } - if (pContext->jack.jackSO == NULL) { + if (pContext->jack.jackSO == nullptr) { return MA_NO_BACKEND; } @@ -33422,7 +33422,7 @@ static ma_result ma_context_init__jack(ma_context* pContext, const ma_context_co pContext->jack.jack_free = (ma_proc)_jack_free; #endif - if (pConfig->jack.pClientName != NULL) { + if (pConfig->jack.pClientName != nullptr) { pContext->jack.pClientName = ma_copy_string(pConfig->jack.pClientName, &pContext->allocationCallbacks); } pContext->jack.tryStartServer = pConfig->jack.tryStartServer; @@ -33454,9 +33454,9 @@ static ma_result ma_context_init__jack(ma_context* pContext, const ma_context_co pCallbacks->onDeviceUninit = ma_device_uninit__jack; pCallbacks->onDeviceStart = ma_device_start__jack; pCallbacks->onDeviceStop = ma_device_stop__jack; - pCallbacks->onDeviceRead = NULL; /* Not used because JACK is asynchronous. */ - pCallbacks->onDeviceWrite = NULL; /* Not used because JACK is asynchronous. */ - pCallbacks->onDeviceDataLoop = NULL; /* Not used because JACK is asynchronous. */ + pCallbacks->onDeviceRead = nullptr; /* Not used because JACK is asynchronous. */ + pCallbacks->onDeviceWrite = nullptr; /* Not used because JACK is asynchronous. */ + pCallbacks->onDeviceDataLoop = nullptr; /* Not used because JACK is asynchronous. */ return MA_SUCCESS; } @@ -33635,8 +33635,8 @@ static ma_channel ma_channel_from_AudioChannelBitmap(AudioChannelBitmap bit) static ma_result ma_format_from_AudioStreamBasicDescription(const AudioStreamBasicDescription* pDescription, ma_format* pFormatOut) { - MA_ASSERT(pDescription != NULL); - MA_ASSERT(pFormatOut != NULL); + MA_ASSERT(pDescription != nullptr); + MA_ASSERT(pFormatOut != nullptr); *pFormatOut = ma_format_unknown; /* Safety. */ @@ -33795,7 +33795,7 @@ static ma_channel ma_channel_from_AudioChannelLabel(AudioChannelLabel label) static ma_result ma_get_channel_map_from_AudioChannelLayout(AudioChannelLayout* pChannelLayout, ma_channel* pChannelMap, size_t channelMapCap) { - MA_ASSERT(pChannelLayout != NULL); + MA_ASSERT(pChannelLayout != nullptr); if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) { UInt32 iChannel; @@ -33899,29 +33899,29 @@ static ma_result ma_get_device_object_ids__coreaudio(ma_context* pContext, UInt3 OSStatus status; AudioObjectID* pDeviceObjectIDs; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pDeviceCount != NULL); - MA_ASSERT(ppDeviceObjectIDs != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pDeviceCount != nullptr); + MA_ASSERT(ppDeviceObjectIDs != nullptr); /* Safety. */ *pDeviceCount = 0; - *ppDeviceObjectIDs = NULL; + *ppDeviceObjectIDs = nullptr; propAddressDevices.mSelector = kAudioHardwarePropertyDevices; propAddressDevices.mScope = kAudioObjectPropertyScopeGlobal; propAddressDevices.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; - status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize); + status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(kAudioObjectSystemObject, &propAddressDevices, 0, nullptr, &deviceObjectsDataSize); if (status != noErr) { return ma_result_from_OSStatus(status); } pDeviceObjectIDs = (AudioObjectID*)ma_malloc(deviceObjectsDataSize, &pContext->allocationCallbacks); - if (pDeviceObjectIDs == NULL) { + if (pDeviceObjectIDs == nullptr) { return MA_OUT_OF_MEMORY; } - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize, pDeviceObjectIDs); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDevices, 0, nullptr, &deviceObjectsDataSize, pDeviceObjectIDs); if (status != noErr) { ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); @@ -33939,14 +33939,14 @@ static ma_result ma_get_AudioObject_uid_as_CFStringRef(ma_context* pContext, Aud UInt32 dataSize; OSStatus status; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); propAddress.mSelector = kAudioDevicePropertyDeviceUID; propAddress.mScope = kAudioObjectPropertyScopeGlobal; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; dataSize = sizeof(*pUID); - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, pUID); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, nullptr, &dataSize, pUID); if (status != noErr) { return ma_result_from_OSStatus(status); } @@ -33959,7 +33959,7 @@ static ma_result ma_get_AudioObject_uid(ma_context* pContext, AudioObjectID obje CFStringRef uid; ma_result result; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); result = ma_get_AudioObject_uid_as_CFStringRef(pContext, objectID, &uid); if (result != MA_SUCCESS) { @@ -33977,18 +33977,18 @@ static ma_result ma_get_AudioObject_uid(ma_context* pContext, AudioObjectID obje static ma_result ma_get_AudioObject_name(ma_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut) { AudioObjectPropertyAddress propAddress; - CFStringRef deviceName = NULL; + CFStringRef deviceName = nullptr; UInt32 dataSize; OSStatus status; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); propAddress.mSelector = kAudioDevicePropertyDeviceNameCFString; propAddress.mScope = kAudioObjectPropertyScopeGlobal; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; dataSize = sizeof(deviceName); - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, &deviceName); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, nullptr, &dataSize, &deviceName); if (status != noErr) { return ma_result_from_OSStatus(status); } @@ -34009,24 +34009,24 @@ static ma_bool32 ma_does_AudioObject_support_scope(ma_context* pContext, AudioOb AudioBufferList* pBufferList; ma_bool32 isSupported; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); /* To know whether or not a device is an input device we need ot look at the stream configuration. If it has an output channel it's a playback device. */ propAddress.mSelector = kAudioDevicePropertyStreamConfiguration; propAddress.mScope = scope; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; - status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); + status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, nullptr, &dataSize); if (status != noErr) { return MA_FALSE; } pBufferList = (AudioBufferList*)ma_malloc(dataSize, &pContext->allocationCallbacks); - if (pBufferList == NULL) { + if (pBufferList == nullptr) { return MA_FALSE; /* Out of memory. */ } - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pBufferList); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, nullptr, &dataSize, pBufferList); if (status != noErr) { ma_free(pBufferList, &pContext->allocationCallbacks); return MA_FALSE; @@ -34059,9 +34059,9 @@ static ma_result ma_get_AudioObject_stream_descriptions(ma_context* pContext, Au OSStatus status; AudioStreamRangedDescription* pDescriptions; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pDescriptionCount != NULL); - MA_ASSERT(ppDescriptions != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pDescriptionCount != nullptr); + MA_ASSERT(ppDescriptions != nullptr); /* TODO: Experiment with kAudioStreamPropertyAvailablePhysicalFormats instead of (or in addition to) kAudioStreamPropertyAvailableVirtualFormats. My @@ -34071,17 +34071,17 @@ static ma_result ma_get_AudioObject_stream_descriptions(ma_context* pContext, Au propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; - status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); + status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, nullptr, &dataSize); if (status != noErr) { return ma_result_from_OSStatus(status); } pDescriptions = (AudioStreamRangedDescription*)ma_malloc(dataSize, &pContext->allocationCallbacks); - if (pDescriptions == NULL) { + if (pDescriptions == nullptr) { return MA_OUT_OF_MEMORY; } - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pDescriptions); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, nullptr, &dataSize, pDescriptions); if (status != noErr) { ma_free(pDescriptions, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); @@ -34100,26 +34100,26 @@ static ma_result ma_get_AudioObject_channel_layout(ma_context* pContext, AudioOb OSStatus status; AudioChannelLayout* pChannelLayout; - MA_ASSERT(pContext != NULL); - MA_ASSERT(ppChannelLayout != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(ppChannelLayout != nullptr); - *ppChannelLayout = NULL; /* Safety. */ + *ppChannelLayout = nullptr; /* Safety. */ propAddress.mSelector = kAudioDevicePropertyPreferredChannelLayout; propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; - status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); + status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, nullptr, &dataSize); if (status != noErr) { return ma_result_from_OSStatus(status); } pChannelLayout = (AudioChannelLayout*)ma_malloc(dataSize, &pContext->allocationCallbacks); - if (pChannelLayout == NULL) { + if (pChannelLayout == nullptr) { return MA_OUT_OF_MEMORY; } - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pChannelLayout); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, nullptr, &dataSize, pChannelLayout); if (status != noErr) { ma_free(pChannelLayout, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); @@ -34134,8 +34134,8 @@ static ma_result ma_get_AudioObject_channel_count(ma_context* pContext, AudioObj AudioChannelLayout* pChannelLayout; ma_result result; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pChannelCount != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pChannelCount != nullptr); *pChannelCount = 0; /* Safety. */ @@ -34162,7 +34162,7 @@ static ma_result ma_get_AudioObject_channel_map(ma_context* pContext, AudioObjec AudioChannelLayout* pChannelLayout; ma_result result; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); result = ma_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout); if (result != MA_SUCCESS) { @@ -34187,29 +34187,29 @@ static ma_result ma_get_AudioObject_sample_rates(ma_context* pContext, AudioObje OSStatus status; AudioValueRange* pSampleRateRanges; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pSampleRateRangesCount != NULL); - MA_ASSERT(ppSampleRateRanges != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pSampleRateRangesCount != nullptr); + MA_ASSERT(ppSampleRateRanges != nullptr); /* Safety. */ *pSampleRateRangesCount = 0; - *ppSampleRateRanges = NULL; + *ppSampleRateRanges = nullptr; propAddress.mSelector = kAudioDevicePropertyAvailableNominalSampleRates; propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; - status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); + status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, nullptr, &dataSize); if (status != noErr) { return ma_result_from_OSStatus(status); } pSampleRateRanges = (AudioValueRange*)ma_malloc(dataSize, &pContext->allocationCallbacks); - if (pSampleRateRanges == NULL) { + if (pSampleRateRanges == nullptr) { return MA_OUT_OF_MEMORY; } - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pSampleRateRanges); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, nullptr, &dataSize, pSampleRateRanges); if (status != noErr) { ma_free(pSampleRateRanges, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); @@ -34227,8 +34227,8 @@ static ma_result ma_get_AudioObject_get_closest_sample_rate(ma_context* pContext AudioValueRange* pSampleRateRanges; ma_result result; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pSampleRateOut != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pSampleRateOut != nullptr); *pSampleRateOut = 0; /* Safety. */ @@ -34312,8 +34312,8 @@ static ma_result ma_get_AudioObject_closest_buffer_size_in_frames(ma_context* pC UInt32 dataSize; OSStatus status; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pBufferSizeInFramesOut != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pBufferSizeInFramesOut != nullptr); *pBufferSizeInFramesOut = 0; /* Safety. */ @@ -34322,7 +34322,7 @@ static ma_result ma_get_AudioObject_closest_buffer_size_in_frames(ma_context* pC propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; dataSize = sizeof(bufferSizeRange); - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &bufferSizeRange); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, nullptr, &dataSize, &bufferSizeRange); if (status != noErr) { return ma_result_from_OSStatus(status); } @@ -34347,7 +34347,7 @@ static ma_result ma_set_AudioObject_buffer_size_in_frames(ma_context* pContext, UInt32 dataSize; OSStatus status; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); result = ma_get_AudioObject_closest_buffer_size_in_frames(pContext, deviceObjectID, deviceType, *pPeriodSizeInOut, &chosenBufferSizeInFrames); if (result != MA_SUCCESS) { @@ -34359,11 +34359,11 @@ static ma_result ma_set_AudioObject_buffer_size_in_frames(ma_context* pContext, propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; - ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(chosenBufferSizeInFrames), &chosenBufferSizeInFrames); + ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, nullptr, sizeof(chosenBufferSizeInFrames), &chosenBufferSizeInFrames); /* Get the actual size of the buffer. */ dataSize = sizeof(*pPeriodSizeInOut); - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &chosenBufferSizeInFrames); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, nullptr, &dataSize, &chosenBufferSizeInFrames); if (status != noErr) { return ma_result_from_OSStatus(status); } @@ -34379,8 +34379,8 @@ static ma_result ma_find_default_AudioObjectID(ma_context* pContext, ma_device_t AudioObjectID defaultDeviceObjectID; OSStatus status; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pDeviceObjectID != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pDeviceObjectID != nullptr); /* Safety. */ *pDeviceObjectID = 0; @@ -34394,7 +34394,7 @@ static ma_result ma_find_default_AudioObjectID(ma_context* pContext, ma_device_t } defaultDeviceObjectIDSize = sizeof(AudioObjectID); - status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDefaultDevice, 0, NULL, &defaultDeviceObjectIDSize, &defaultDeviceObjectID); + status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDefaultDevice, 0, nullptr, &defaultDeviceObjectIDSize, &defaultDeviceObjectID); if (status == noErr) { *pDeviceObjectID = defaultDeviceObjectID; return MA_SUCCESS; @@ -34406,13 +34406,13 @@ static ma_result ma_find_default_AudioObjectID(ma_context* pContext, ma_device_t static ma_result ma_find_AudioObjectID(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, AudioObjectID* pDeviceObjectID) { - MA_ASSERT(pContext != NULL); - MA_ASSERT(pDeviceObjectID != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pDeviceObjectID != nullptr); /* Safety. */ *pDeviceObjectID = 0; - if (pDeviceID == NULL) { + if (pDeviceID == nullptr) { /* Default device. */ return ma_find_default_AudioObjectID(pContext, deviceType, pDeviceObjectID); } else { @@ -34651,7 +34651,7 @@ static ma_result ma_get_AudioUnit_channel_map(ma_context* pContext, AudioUnit au AudioChannelLayout* pChannelLayout; ma_result result; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); if (deviceType == ma_device_type_playback) { deviceScope = kAudioUnitScope_Input; @@ -34661,13 +34661,13 @@ static ma_result ma_get_AudioUnit_channel_map(ma_context* pContext, AudioUnit au deviceBus = MA_COREAUDIO_INPUT_BUS; } - status = ((ma_AudioUnitGetPropertyInfo_proc)pContext->coreaudio.AudioUnitGetPropertyInfo)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, &channelLayoutSize, NULL); + status = ((ma_AudioUnitGetPropertyInfo_proc)pContext->coreaudio.AudioUnitGetPropertyInfo)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, &channelLayoutSize, nullptr); if (status != noErr) { return ma_result_from_OSStatus(status); } pChannelLayout = (AudioChannelLayout*)ma_malloc(channelLayoutSize, &pContext->allocationCallbacks); - if (pChannelLayout == NULL) { + if (pChannelLayout == nullptr) { return MA_OUT_OF_MEMORY; } @@ -34776,7 +34776,7 @@ static ma_result ma_context_get_device_info__coreaudio(ma_context* pContext, ma_ { ma_result result; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); #if defined(MA_APPLE_DESKTOP) /* Desktop */ @@ -34919,7 +34919,7 @@ static ma_result ma_context_get_device_info__coreaudio(ma_context* pContext, ma_ UInt32 propSize; /* We want to ensure we use a consistent device name to device enumeration. */ - if (pDeviceID != NULL && pDeviceID->coreaudio[0] != '\0') { + if (pDeviceID != nullptr && pDeviceID->coreaudio[0] != '\0') { ma_bool32 found = MA_FALSE; if (deviceType == ma_device_type_playback) { NSArray *pOutputs = [[[AVAudioSession sharedInstance] currentRoute] outputs]; @@ -34964,8 +34964,8 @@ static ma_result ma_context_get_device_info__coreaudio(ma_context* pContext, ma_ desc.componentFlags = 0; desc.componentFlagsMask = 0; - component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc); - if (component == NULL) { + component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(nullptr, &desc); + if (component == nullptr) { return MA_FAILED_TO_INIT_BACKEND; } @@ -34985,7 +34985,7 @@ static ma_result ma_context_get_device_info__coreaudio(ma_context* pContext, ma_ } ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(audioUnit); - audioUnit = NULL; + audioUnit = nullptr; /* Only a single format is being reported for iOS. */ pDeviceInfo->nativeDataFormatCount = 1; @@ -35003,7 +35003,7 @@ static ma_result ma_context_get_device_info__coreaudio(ma_context* pContext, ma_ */ @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; - MA_ASSERT(pAudioSession != NULL); + MA_ASSERT(pAudioSession != nullptr); pDeviceInfo->nativeDataFormats[0].sampleRate = (ma_uint32)pAudioSession.sampleRate; } @@ -35036,8 +35036,8 @@ static AudioBufferList* ma_allocate_AudioBufferList__coreaudio(ma_uint32 sizeInF allocationSize += sizeInFrames * ma_get_bytes_per_frame(format, channels); pBufferList = (AudioBufferList*)ma_malloc(allocationSize, pAllocationCallbacks); - if (pBufferList == NULL) { - return NULL; + if (pBufferList == nullptr) { + return nullptr; } audioBufferSizeInBytes = (UInt32)(sizeInFrames * ma_get_bytes_per_sample(format)); @@ -35062,7 +35062,7 @@ static AudioBufferList* ma_allocate_AudioBufferList__coreaudio(ma_uint32 sizeInF static ma_result ma_device_realloc_AudioBufferList__coreaudio(ma_device* pDevice, ma_uint32 sizeInFrames, ma_format format, ma_uint32 channels, ma_stream_layout layout) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(format != ma_format_unknown); MA_ASSERT(channels > 0); @@ -35071,7 +35071,7 @@ static ma_result ma_device_realloc_AudioBufferList__coreaudio(ma_device* pDevice AudioBufferList* pNewAudioBufferList; pNewAudioBufferList = ma_allocate_AudioBufferList__coreaudio(sizeInFrames, format, channels, layout, &pDevice->pContext->allocationCallbacks); - if (pNewAudioBufferList == NULL) { + if (pNewAudioBufferList == nullptr) { return MA_OUT_OF_MEMORY; } @@ -35091,7 +35091,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl ma_device* pDevice = (ma_device*)pUserData; ma_stream_layout layout; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "INFO: Output Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", (int)busNumber, (int)frameCount, (int)pBufferList->mNumberBuffers);*/ @@ -35108,7 +35108,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl if (pBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->playback.internalChannels) { ma_uint32 frameCountForThisBuffer = pBufferList->mBuffers[iBuffer].mDataByteSize / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); if (frameCountForThisBuffer > 0) { - ma_device_handle_backend_data_callback(pDevice, pBufferList->mBuffers[iBuffer].mData, NULL, frameCountForThisBuffer); + ma_device_handle_backend_data_callback(pDevice, pBufferList->mBuffers[iBuffer].mData, nullptr, frameCountForThisBuffer); } /*a_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", (int)frameCount, (int)pBufferList->mBuffers[iBuffer].mNumberChannels, (int)pBufferList->mBuffers[iBuffer].mDataByteSize);*/ @@ -35146,7 +35146,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl framesToRead = framesRemaining; } - ma_device_handle_backend_data_callback(pDevice, tempBuffer, NULL, framesToRead); + ma_device_handle_backend_data_callback(pDevice, tempBuffer, nullptr, framesToRead); for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) { ppDeinterleavedBuffers[iChannel] = (void*)ma_offset_ptr(pBufferList->mBuffers[iBuffer+iChannel].mData, (frameCountPerBuffer - framesRemaining) * ma_get_bytes_per_sample(pDevice->playback.internalFormat)); @@ -35177,7 +35177,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla ma_uint32 iBuffer; OSStatus status; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); pRenderedBufferList = (AudioBufferList*)pDevice->coreaudio.pAudioBufferList; MA_ASSERT(pRenderedBufferList); @@ -35227,7 +35227,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla if (layout == ma_stream_layout_interleaved) { for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) { if (pRenderedBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->capture.internalChannels) { - ma_device_handle_backend_data_callback(pDevice, NULL, pRenderedBufferList->mBuffers[iBuffer].mData, frameCount); + ma_device_handle_backend_data_callback(pDevice, nullptr, pRenderedBufferList->mBuffers[iBuffer].mData, frameCount); /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " mDataByteSize=%d.\n", (int)pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);*/ } else { /* @@ -35246,7 +35246,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla framesToSend = framesRemaining; } - ma_device_handle_backend_data_callback(pDevice, NULL, silentBuffer, framesToSend); + ma_device_handle_backend_data_callback(pDevice, nullptr, silentBuffer, framesToSend); framesRemaining -= framesToSend; } @@ -35279,7 +35279,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla } ma_interleave_pcm_frames(pDevice->capture.internalFormat, pDevice->capture.internalChannels, framesToSend, (const void**)ppDeinterleavedBuffers, tempBuffer); - ma_device_handle_backend_data_callback(pDevice, NULL, tempBuffer, framesToSend); + ma_device_handle_backend_data_callback(pDevice, nullptr, tempBuffer, framesToSend); framesRemaining -= framesToSend; } @@ -35299,7 +35299,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla static void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, AudioUnitPropertyID propertyID, AudioUnitScope scope, AudioUnitElement element) { ma_device* pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Don't do anything if it looks like we're just reinitializing due to a device switch. */ if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isSwitchingPlaybackDevice) || @@ -35371,7 +35371,7 @@ static void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, Audio static ma_spinlock g_DeviceTrackingInitLock_CoreAudio = 0; /* A spinlock for mutal exclusion of the init/uninit of the global tracking data. Initialization to 0 is what we need. */ static ma_uint32 g_DeviceTrackingInitCounter_CoreAudio = 0; static ma_mutex g_DeviceTrackingMutex_CoreAudio; -static ma_device** g_ppTrackedDevices_CoreAudio = NULL; +static ma_device** g_ppTrackedDevices_CoreAudio = nullptr; static ma_uint32 g_TrackedDeviceCap_CoreAudio = 0; static ma_uint32 g_TrackedDeviceCount_CoreAudio = 0; @@ -35452,7 +35452,7 @@ static OSStatus ma_default_device_changed__coreaudio(AudioObjectID objectID, UIn static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); ma_spinlock_lock(&g_DeviceTrackingInitLock_CoreAudio); { @@ -35465,10 +35465,10 @@ static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContex ma_mutex_init(&g_DeviceTrackingMutex_CoreAudio); propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; - ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL); + ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, nullptr); propAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; - ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL); + ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, nullptr); } g_DeviceTrackingInitCounter_CoreAudio += 1; @@ -35480,7 +35480,7 @@ static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContex static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); ma_spinlock_lock(&g_DeviceTrackingInitLock_CoreAudio); { @@ -35493,13 +35493,13 @@ static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pCont propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; - ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL); + ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, nullptr); propAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; - ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL); + ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, nullptr); /* At this point there should be no tracked devices. If not there's an error somewhere. */ - if (g_ppTrackedDevices_CoreAudio != NULL) { + if (g_ppTrackedDevices_CoreAudio != nullptr) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "You have uninitialized all contexts while an associated device is still active."); ma_spinlock_unlock(&g_DeviceTrackingInitLock_CoreAudio); return MA_INVALID_OPERATION; @@ -35515,7 +35515,7 @@ static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pCont static ma_result ma_device__track__coreaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio); { @@ -35530,7 +35530,7 @@ static ma_result ma_device__track__coreaudio(ma_device* pDevice) } ppNewDevices = (ma_device**)ma_realloc(g_ppTrackedDevices_CoreAudio, sizeof(*g_ppTrackedDevices_CoreAudio)*newCap, &pDevice->pContext->allocationCallbacks); - if (ppNewDevices == NULL) { + if (ppNewDevices == nullptr) { ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio); return MA_OUT_OF_MEMORY; } @@ -35549,7 +35549,7 @@ static ma_result ma_device__track__coreaudio(ma_device* pDevice) static ma_result ma_device__untrack__coreaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio); { @@ -35567,7 +35567,7 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice) /* If there's nothing else in the list we need to free memory. */ if (g_TrackedDeviceCount_CoreAudio == 0) { ma_free(g_ppTrackedDevices_CoreAudio, &pDevice->pContext->allocationCallbacks); - g_ppTrackedDevices_CoreAudio = NULL; + g_ppTrackedDevices_CoreAudio = nullptr; g_TrackedDeviceCap_CoreAudio = 0; } @@ -35703,7 +35703,7 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice) static ma_result ma_device_uninit__coreaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(ma_device_get_state(pDevice) == ma_device_state_uninitialized); #if defined(MA_APPLE_DESKTOP) @@ -35714,16 +35714,16 @@ static ma_result ma_device_uninit__coreaudio(ma_device* pDevice) ma_device__untrack__coreaudio(pDevice); #endif #if defined(MA_APPLE_MOBILE) - if (pDevice->coreaudio.pNotificationHandler != NULL) { + if (pDevice->coreaudio.pNotificationHandler != nullptr) { ma_ios_notification_handler* pNotificationHandler = (MA_BRIDGE_TRANSFER ma_ios_notification_handler*)pDevice->coreaudio.pNotificationHandler; [pNotificationHandler remove_handler]; } #endif - if (pDevice->coreaudio.audioUnitCapture != NULL) { + if (pDevice->coreaudio.audioUnitCapture != nullptr) { ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture); } - if (pDevice->coreaudio.audioUnitPlayback != NULL) { + if (pDevice->coreaudio.audioUnitPlayback != nullptr) { ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); } @@ -35783,15 +35783,15 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev return MA_INVALID_ARGS; } - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(deviceType == ma_device_type_playback || deviceType == ma_device_type_capture); #if defined(MA_APPLE_DESKTOP) pData->deviceObjectID = 0; #endif - pData->component = NULL; - pData->audioUnit = NULL; - pData->pAudioBufferList = NULL; + pData->component = nullptr; + pData->audioUnit = nullptr; + pData->pAudioBufferList = nullptr; #if defined(MA_APPLE_DESKTOP) result = ma_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID); @@ -35851,7 +35851,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev For some reason it looks like Apple is only allowing selection of the input device. There does not appear to be any way to change the default output route. I have no idea why this is like this, but for now we'll only be able to configure capture devices. */ - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { if (deviceType == ma_device_type_capture) { ma_bool32 found = MA_FALSE; NSArray *pInputs = [[[AVAudioSession sharedInstance] currentRoute] inputs]; @@ -35943,7 +35943,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; - status = ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(sampleRateRange), &sampleRateRange); + status = ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, nullptr, sizeof(sampleRateRange), &sampleRateRange); if (status != noErr) { bestFormat.mSampleRate = origFormat.mSampleRate; } @@ -35967,7 +35967,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev */ @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; - MA_ASSERT(pAudioSession != NULL); + MA_ASSERT(pAudioSession != nullptr); [pAudioSession setPreferredSampleRate:(double)pData->sampleRateIn error:nil]; bestFormat.mSampleRate = pAudioSession.sampleRate; @@ -36079,7 +36079,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev */ @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; - MA_ASSERT(pAudioSession != NULL); + MA_ASSERT(pAudioSession != nullptr); [pAudioSession setPreferredIOBufferDuration:((float)actualPeriodSizeInFrames / pAudioSession.sampleRate) error:nil]; actualPeriodSizeInFrames = ma_next_power_of_2((ma_uint32)(pAudioSession.IOBufferDuration * pAudioSession.sampleRate)); @@ -36109,7 +36109,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev AudioBufferList* pBufferList; pBufferList = ma_allocate_AudioBufferList__coreaudio(pData->periodSizeInFramesOut, pData->formatOut, pData->channelsOut, (isInterleaved) ? ma_stream_layout_interleaved : ma_stream_layout_deinterleaved, &pContext->allocationCallbacks); - if (pBufferList == NULL) { + if (pBufferList == nullptr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return MA_OUT_OF_MEMORY; } @@ -36148,7 +36148,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev status = ((ma_AudioUnitInitialize_proc)pContext->coreaudio.AudioUnitInitialize)(pData->audioUnit); if (status != noErr) { ma_free(pData->pAudioBufferList, &pContext->allocationCallbacks); - pData->pAudioBufferList = NULL; + pData->pAudioBufferList = nullptr; ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } @@ -36219,7 +36219,7 @@ static ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_dev data.periodsIn = 3; } - result = ma_device_init_internal__coreaudio(pDevice->pContext, deviceType, NULL, &data, (void*)pDevice); + result = ma_device_init_internal__coreaudio(pDevice->pContext, deviceType, nullptr, &data, (void*)pDevice); if (result != MA_SUCCESS) { return result; } @@ -36262,8 +36262,8 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c { ma_result result; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pConfig != nullptr); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; @@ -36300,7 +36300,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c return result; } - pDevice->coreaudio.isDefaultCaptureDevice = (pConfig->capture.pDeviceID == NULL); + pDevice->coreaudio.isDefaultCaptureDevice = (pConfig->capture.pDeviceID == nullptr); #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDCapture = (ma_uint32)data.deviceObjectID; #endif @@ -36326,7 +36326,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c If we are using the default device we'll need to listen for changes to the system's default device so we can seamlessly switch the device in the background. */ - if (pConfig->capture.pDeviceID == NULL) { + if (pConfig->capture.pDeviceID == nullptr) { ma_device__track__coreaudio(pDevice); } #endif @@ -36366,7 +36366,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c return result; } - pDevice->coreaudio.isDefaultPlaybackDevice = (pConfig->playback.pDeviceID == NULL); + pDevice->coreaudio.isDefaultPlaybackDevice = (pConfig->playback.pDeviceID == nullptr); #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDPlayback = (ma_uint32)data.deviceObjectID; #endif @@ -36390,7 +36390,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c If we are using the default device we'll need to listen for changes to the system's default device so we can seamlessly switch the device in the background. */ - if (pDescriptorPlayback->pDeviceID == NULL && (pConfig->deviceType != ma_device_type_duplex || pDescriptorCapture->pDeviceID != NULL)) { + if (pDescriptorPlayback->pDeviceID == nullptr && (pConfig->deviceType != ma_device_type_duplex || pDescriptorCapture->pDeviceID != nullptr)) { ma_device__track__coreaudio(pDevice); } #endif @@ -36418,7 +36418,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c static ma_result ma_device_start__coreaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { OSStatus status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitCapture); @@ -36442,7 +36442,7 @@ static ma_result ma_device_start__coreaudio(ma_device* pDevice) static ma_result ma_device_stop__coreaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* It's not clear from the documentation whether or not AudioOutputUnitStop() actually drains the device or not. */ @@ -36468,7 +36468,7 @@ static ma_result ma_device_stop__coreaudio(ma_device* pDevice) static ma_result ma_context_uninit__coreaudio(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_coreaudio); #if defined(MA_APPLE_MOBILE) @@ -36521,15 +36521,15 @@ static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_conte ma_result result; #endif - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pContext != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pContext != nullptr); #if defined(MA_APPLE_MOBILE) @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; AVAudioSessionCategoryOptions options = pConfig->coreaudio.sessionCategoryOptions; - MA_ASSERT(pAudioSession != NULL); + MA_ASSERT(pAudioSession != nullptr); if (pConfig->coreaudio.sessionCategory == ma_ios_session_category_default) { /* @@ -36573,7 +36573,7 @@ static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_conte #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) pContext->coreaudio.hCoreFoundation = ma_dlopen(ma_context_get_log(pContext), "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"); - if (pContext->coreaudio.hCoreFoundation == NULL) { + if (pContext->coreaudio.hCoreFoundation == nullptr) { return MA_API_NOT_FOUND; } @@ -36582,7 +36582,7 @@ static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_conte pContext->coreaudio.hCoreAudio = ma_dlopen(ma_context_get_log(pContext), "/System/Library/Frameworks/CoreAudio.framework/CoreAudio"); - if (pContext->coreaudio.hCoreAudio == NULL) { + if (pContext->coreaudio.hCoreAudio == nullptr) { ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); return MA_API_NOT_FOUND; } @@ -36600,17 +36600,17 @@ static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_conte AudioToolbox. */ pContext->coreaudio.hAudioUnit = ma_dlopen(ma_context_get_log(pContext), "/System/Library/Frameworks/AudioUnit.framework/AudioUnit"); - if (pContext->coreaudio.hAudioUnit == NULL) { + if (pContext->coreaudio.hAudioUnit == nullptr) { ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); return MA_API_NOT_FOUND; } - if (ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioComponentFindNext") == NULL) { + if (ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioComponentFindNext") == nullptr) { /* Couldn't find the required symbols in AudioUnit, so fall back to AudioToolbox. */ ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit); pContext->coreaudio.hAudioUnit = ma_dlopen(ma_context_get_log(pContext), "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"); - if (pContext->coreaudio.hAudioUnit == NULL) { + if (pContext->coreaudio.hAudioUnit == nullptr) { ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); return MA_API_NOT_FOUND; @@ -36666,8 +36666,8 @@ static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_conte desc.componentFlags = 0; desc.componentFlagsMask = 0; - pContext->coreaudio.component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc); - if (pContext->coreaudio.component == NULL) { + pContext->coreaudio.component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(nullptr, &desc); + if (pContext->coreaudio.component == nullptr) { #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio); @@ -36699,9 +36699,9 @@ static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_conte pCallbacks->onDeviceUninit = ma_device_uninit__coreaudio; pCallbacks->onDeviceStart = ma_device_start__coreaudio; pCallbacks->onDeviceStop = ma_device_stop__coreaudio; - pCallbacks->onDeviceRead = NULL; - pCallbacks->onDeviceWrite = NULL; - pCallbacks->onDeviceDataLoop = NULL; + pCallbacks->onDeviceRead = nullptr; + pCallbacks->onDeviceWrite = nullptr; + pCallbacks->onDeviceDataLoop = nullptr; return MA_SUCCESS; } @@ -36842,7 +36842,7 @@ static ma_format ma_find_best_format_from_sio_cap__sndio(struct ma_sio_cap* caps ma_format bestFormat; unsigned int iConfig; - MA_ASSERT(caps != NULL); + MA_ASSERT(caps != nullptr); bestFormat = ma_format_unknown; for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) { @@ -36887,7 +36887,7 @@ static ma_uint32 ma_find_best_channels_from_sio_cap__sndio(struct ma_sio_cap* ca ma_uint32 maxChannels; unsigned int iConfig; - MA_ASSERT(caps != NULL); + MA_ASSERT(caps != nullptr); MA_ASSERT(requiredFormat != ma_format_unknown); /* Just pick whatever configuration has the most channels. */ @@ -36955,7 +36955,7 @@ static ma_uint32 ma_find_best_sample_rate_from_sio_cap__sndio(struct ma_sio_cap* ma_uint32 bestSampleRate; unsigned int iConfig; - MA_ASSERT(caps != NULL); + MA_ASSERT(caps != nullptr); MA_ASSERT(requiredFormat != ma_format_unknown); MA_ASSERT(requiredChannels > 0); MA_ASSERT(requiredChannels <= MA_MAX_CHANNELS); @@ -37052,15 +37052,15 @@ static ma_result ma_context_enumerate_devices__sndio(ma_context* pContext, ma_en ma_bool32 isTerminating = MA_FALSE; struct ma_sio_hdl* handle; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); /* sndio doesn't seem to have a good device enumeration API, so I'm therefore only enumerating over default devices for now. */ /* Playback. */ if (!isTerminating) { handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_PLAY, 0); - if (handle != NULL) { + if (handle != nullptr) { /* Supports playback. */ ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); @@ -37076,7 +37076,7 @@ static ma_result ma_context_enumerate_devices__sndio(ma_context* pContext, ma_en /* Capture. */ if (!isTerminating) { handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_REC, 0); - if (handle != NULL) { + if (handle != nullptr) { /* Supports capture. */ ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); @@ -37099,10 +37099,10 @@ static ma_result ma_context_get_device_info__sndio(ma_context* pContext, ma_devi struct ma_sio_cap caps; unsigned int iConfig; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); /* We need to open the device before we can get information about it. */ - if (pDeviceID == NULL) { + if (pDeviceID == nullptr) { ma_strcpy_s(devid, sizeof(devid), MA_SIO_DEVANY); ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (deviceType == ma_device_type_playback) ? MA_DEFAULT_PLAYBACK_DEVICE_NAME : MA_DEFAULT_CAPTURE_DEVICE_NAME); } else { @@ -37111,7 +37111,7 @@ static ma_result ma_context_get_device_info__sndio(ma_context* pContext, ma_devi } handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(devid, (deviceType == ma_device_type_playback) ? MA_SIO_PLAY : MA_SIO_REC, 0); - if (handle == NULL) { + if (handle == nullptr) { return MA_NO_DEVICE; } @@ -37191,7 +37191,7 @@ static ma_result ma_context_get_device_info__sndio(ma_context* pContext, ma_devi static ma_result ma_device_uninit__sndio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)pDevice->sndio.handleCapture); @@ -37221,9 +37221,9 @@ static ma_result ma_device_init_handle__sndio(ma_device* pDevice, const ma_devic ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriods; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); MA_ASSERT(deviceType != ma_device_type_duplex); - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (deviceType == ma_device_type_capture) { openFlags = MA_SIO_REC; @@ -37237,12 +37237,12 @@ static ma_result ma_device_init_handle__sndio(ma_device* pDevice, const ma_devic sampleRate = pDescriptor->sampleRate; pDeviceName = MA_SIO_DEVANY; - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { pDeviceName = pDeviceID->sndio; } handle = (ma_ptr)((ma_sio_open_proc)pDevice->pContext->sndio.sio_open)(pDeviceName, openFlags, 0); - if (handle == NULL) { + if (handle == nullptr) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[sndio] Failed to open device."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } @@ -37379,7 +37379,7 @@ static ma_result ma_device_init_handle__sndio(ma_device* pDevice, const ma_devic static ma_result ma_device_init__sndio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->sndio); @@ -37406,7 +37406,7 @@ static ma_result ma_device_init__sndio(ma_device* pDevice, const ma_device_confi static ma_result ma_device_start__sndio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((ma_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct ma_sio_hdl*)pDevice->sndio.handleCapture); @@ -37421,7 +37421,7 @@ static ma_result ma_device_start__sndio(ma_device* pDevice) static ma_result ma_device_stop__sndio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* From the documentation: @@ -37448,7 +37448,7 @@ static ma_result ma_device_write__sndio(ma_device* pDevice, const void* pPCMFram { int result; - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = 0; } @@ -37458,7 +37458,7 @@ static ma_result ma_device_write__sndio(ma_device* pDevice, const void* pPCMFram return MA_IO_ERROR; } - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = frameCount; } @@ -37469,7 +37469,7 @@ static ma_result ma_device_read__sndio(ma_device* pDevice, void* pPCMFrames, ma_ { int result; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -37479,7 +37479,7 @@ static ma_result ma_device_read__sndio(ma_device* pDevice, void* pPCMFrames, ma_ return MA_IO_ERROR; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = frameCount; } @@ -37488,7 +37488,7 @@ static ma_result ma_device_read__sndio(ma_device* pDevice, void* pPCMFrames, ma_ static ma_result ma_context_uninit__sndio(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_sndio); (void)pContext; @@ -37505,12 +37505,12 @@ static ma_result ma_context_init__sndio(ma_context* pContext, const ma_context_c for (i = 0; i < ma_countof(libsndioNames); ++i) { pContext->sndio.sndioSO = ma_dlopen(ma_context_get_log(pContext), libsndioNames[i]); - if (pContext->sndio.sndioSO != NULL) { + if (pContext->sndio.sndioSO != nullptr) { break; } } - if (pContext->sndio.sndioSO == NULL) { + if (pContext->sndio.sndioSO == nullptr) { return MA_NO_BACKEND; } @@ -37547,7 +37547,7 @@ static ma_result ma_context_init__sndio(ma_context* pContext, const ma_context_c pCallbacks->onDeviceStop = ma_device_stop__sndio; pCallbacks->onDeviceRead = ma_device_read__sndio; pCallbacks->onDeviceWrite = ma_device_write__sndio; - pCallbacks->onDeviceDataLoop = NULL; + pCallbacks->onDeviceDataLoop = nullptr; (void)pConfig; return MA_SUCCESS; @@ -37585,7 +37585,7 @@ static void ma_construct_device_id__audio4(char* id, size_t idSize, const char* { size_t baseLen; - MA_ASSERT(id != NULL); + MA_ASSERT(id != nullptr); MA_ASSERT(idSize > 0); MA_ASSERT(deviceIndex >= 0); @@ -37602,9 +37602,9 @@ static ma_result ma_extract_device_index_from_id__audio4(const char* id, const c size_t baseLen; const char* deviceIndexStr; - MA_ASSERT(id != NULL); - MA_ASSERT(base != NULL); - MA_ASSERT(pIndexOut != NULL); + MA_ASSERT(id != nullptr); + MA_ASSERT(base != nullptr); + MA_ASSERT(pIndexOut != nullptr); idLen = strlen(id); baseLen = strlen(base); @@ -37659,8 +37659,8 @@ static ma_format ma_format_from_encoding__audio4(unsigned int encoding, unsigned static void ma_encoding_from_format__audio4(ma_format format, unsigned int* pEncoding, unsigned int* pPrecision) { - MA_ASSERT(pEncoding != NULL); - MA_ASSERT(pPrecision != NULL); + MA_ASSERT(pEncoding != nullptr); + MA_ASSERT(pPrecision != nullptr); switch (format) { @@ -37772,9 +37772,9 @@ static ma_result ma_context_get_device_info_from_fd__audio4(ma_context* pContext { audio_device_t fdDevice; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(fd >= 0); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pDeviceInfo != nullptr); (void)pContext; (void)deviceType; @@ -37869,8 +37869,8 @@ static ma_result ma_context_enumerate_devices__audio4(ma_context* pContext, ma_e char devpath[256]; int iDevice; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); /* Every device will be named "/dev/audioN", with a "/dev/audioctlN" equivalent. We use the "/dev/audioctlN" @@ -37937,13 +37937,13 @@ static ma_result ma_context_get_device_info__audio4(ma_context* pContext, ma_dev char ctlid[256]; ma_result result; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); /* We need to open the "/dev/audioctlN" device to get the info. To do this we need to extract the number from the device ID which will be in "/dev/audioN" format. */ - if (pDeviceID == NULL) { + if (pDeviceID == nullptr) { /* Default device. */ ma_strcpy_s(ctlid, sizeof(ctlid), "/dev/audioctl"); } else { @@ -37975,7 +37975,7 @@ static ma_result ma_context_get_device_info__audio4(ma_context* pContext, ma_dev static ma_result ma_device_uninit__audio4(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { close(pDevice->audio4.fdCapture); @@ -38007,9 +38007,9 @@ static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_c ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriods; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); MA_ASSERT(deviceType != ma_device_type_duplex); - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* The first thing to do is open the file. */ if (deviceType == ma_device_type_capture) { @@ -38020,7 +38020,7 @@ static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_c /*fdFlags |= O_NONBLOCK;*/ /* Find the index of the default device as a start. We'll use this index later. Set it to (size_t)-1 otherwise. */ - if (pDescriptor->pDeviceID == NULL) { + if (pDescriptor->pDeviceID == nullptr) { /* Default device. */ for (iDefaultDevice = 0; iDefaultDevice < ma_countof(pDefaultDeviceNames); ++iDefaultDevice) { fd = open(pDefaultDeviceNames[iDefaultDevice], fdFlags, 0); @@ -38262,7 +38262,7 @@ static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_c static ma_result ma_device_init__audio4(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->audio4); @@ -38310,7 +38310,7 @@ static ma_result ma_device_init__audio4(ma_device* pDevice, const ma_device_conf static ma_result ma_device_start__audio4(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { if (pDevice->audio4.fdCapture == -1) { @@ -38350,7 +38350,7 @@ static ma_result ma_device_stop_fd__audio4(ma_device* pDevice, int fd) static ma_result ma_device_stop__audio4(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_result result; @@ -38383,7 +38383,7 @@ static ma_result ma_device_write__audio4(ma_device* pDevice, const void* pPCMFra { int result; - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = 0; } @@ -38393,7 +38393,7 @@ static ma_result ma_device_write__audio4(ma_device* pDevice, const void* pPCMFra return ma_result_from_errno(errno); } - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = (ma_uint32)result / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); } @@ -38404,7 +38404,7 @@ static ma_result ma_device_read__audio4(ma_device* pDevice, void* pPCMFrames, ma { int result; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -38414,7 +38414,7 @@ static ma_result ma_device_read__audio4(ma_device* pDevice, void* pPCMFrames, ma return ma_result_from_errno(errno); } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = (ma_uint32)result / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); } @@ -38423,7 +38423,7 @@ static ma_result ma_device_read__audio4(ma_device* pDevice, void* pPCMFrames, ma static ma_result ma_context_uninit__audio4(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_audio4); (void)pContext; @@ -38432,7 +38432,7 @@ static ma_result ma_context_uninit__audio4(ma_context* pContext) static ma_result ma_context_init__audio4(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); (void)pConfig; @@ -38446,7 +38446,7 @@ static ma_result ma_context_init__audio4(ma_context* pContext, const ma_context_ pCallbacks->onDeviceStop = ma_device_stop__audio4; pCallbacks->onDeviceRead = ma_device_read__audio4; pCallbacks->onDeviceWrite = ma_device_write__audio4; - pCallbacks->onDeviceDataLoop = NULL; + pCallbacks->onDeviceDataLoop = nullptr; return MA_SUCCESS; } @@ -38486,8 +38486,8 @@ static ma_result ma_context_open_device__oss(ma_context* pContext, ma_device_typ const char* deviceName; int flags; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pfd != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pfd != nullptr); (void)pContext; *pfd = -1; @@ -38498,7 +38498,7 @@ static ma_result ma_context_open_device__oss(ma_context* pContext, ma_device_typ } deviceName = MA_OSS_DEFAULT_DEVICE_NAME; - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { deviceName = pDeviceID->oss; } @@ -38521,8 +38521,8 @@ static ma_result ma_context_enumerate_devices__oss(ma_context* pContext, ma_enum oss_sysinfo si; int result; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); fd = ma_open_temp_device__oss(); if (fd == -1) { @@ -38588,9 +38588,9 @@ static void ma_context_add_native_data_format__oss(ma_context* pContext, oss_aud unsigned int maxChannels; unsigned int iRate; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pAudioInfo != NULL); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pAudioInfo != nullptr); + MA_ASSERT(pDeviceInfo != nullptr); /* If we support all channels we just report 0. */ minChannels = ma_clamp(pAudioInfo->min_channels, MA_MIN_CHANNELS, MA_MAX_CHANNELS); @@ -38639,10 +38639,10 @@ static ma_result ma_context_get_device_info__oss(ma_context* pContext, ma_device oss_sysinfo si; int result; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); /* Handle the default device a little differently. */ - if (pDeviceID == NULL) { + if (pDeviceID == nullptr) { if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { @@ -38733,7 +38733,7 @@ static ma_result ma_context_get_device_info__oss(ma_context* pContext, ma_device static ma_result ma_device_uninit__oss(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { close(pDevice->oss.fdCapture); @@ -38789,15 +38789,15 @@ static ma_result ma_device_init_fd__oss(ma_device* pDevice, const ma_device_conf ma_result result; int ossResult; int fd; - const ma_device_id* pDeviceID = NULL; + const ma_device_id* pDeviceID = nullptr; ma_share_mode shareMode; int ossFormat; int ossChannels; int ossSampleRate; int ossFragment; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pConfig != nullptr); MA_ASSERT(deviceType != ma_device_type_duplex); pDeviceID = pDescriptor->pDeviceID; @@ -38903,8 +38903,8 @@ static ma_result ma_device_init_fd__oss(ma_device* pDevice, const ma_device_conf static ma_result ma_device_init__oss(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pConfig != nullptr); MA_ZERO_OBJECT(&pDevice->oss); @@ -38952,7 +38952,7 @@ When starting the device, OSS will automatically start it when write() or read() */ static ma_result ma_device_start__oss(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* The device is automatically started with reading and writing. */ (void)pDevice; @@ -38962,7 +38962,7 @@ static ma_result ma_device_start__oss(ma_device* pDevice) static ma_result ma_device_stop__oss(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* See note above on why this is empty. */ (void)pDevice; @@ -38975,7 +38975,7 @@ static ma_result ma_device_write__oss(ma_device* pDevice, const void* pPCMFrames int resultOSS; ma_uint32 deviceState; - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = 0; } @@ -38991,7 +38991,7 @@ static ma_result ma_device_write__oss(ma_device* pDevice, const void* pPCMFrames return ma_result_from_errno(errno); } - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = (ma_uint32)resultOSS / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); } @@ -39003,7 +39003,7 @@ static ma_result ma_device_read__oss(ma_device* pDevice, void* pPCMFrames, ma_ui int resultOSS; ma_uint32 deviceState; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -39019,7 +39019,7 @@ static ma_result ma_device_read__oss(ma_device* pDevice, void* pPCMFrames, ma_ui return ma_result_from_errno(errno); } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = (ma_uint32)resultOSS / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); } @@ -39028,7 +39028,7 @@ static ma_result ma_device_read__oss(ma_device* pDevice, void* pPCMFrames, ma_ui static ma_result ma_context_uninit__oss(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_oss); (void)pContext; @@ -39041,7 +39041,7 @@ static ma_result ma_context_init__oss(ma_context* pContext, const ma_context_con int ossVersion; int result; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); (void)pConfig; @@ -39077,7 +39077,7 @@ static ma_result ma_context_init__oss(ma_context* pContext, const ma_context_con pCallbacks->onDeviceStop = ma_device_stop__oss; pCallbacks->onDeviceRead = ma_device_read__oss; pCallbacks->onDeviceWrite = ma_device_write__oss; - pCallbacks->onDeviceDataLoop = NULL; + pCallbacks->onDeviceDataLoop = nullptr; return MA_SUCCESS; } @@ -39306,7 +39306,7 @@ static void ma_stream_error_callback__aaudio(ma_AAudioStream* pStream, void* pUs ma_result result; ma_job job; ma_device* pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); (void)error; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[AAudio] ERROR CALLBACK: error=%d, AAudioStream_getState()=%d\n", error, ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream)); @@ -39340,10 +39340,10 @@ static void ma_stream_error_callback__aaudio(ma_AAudioStream* pStream, void* pUs static ma_aaudio_data_callback_result_t ma_stream_data_callback_capture__aaudio(ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount) { ma_device* pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (frameCount > 0) { - ma_device_handle_backend_data_callback(pDevice, NULL, pAudioData, (ma_uint32)frameCount); + ma_device_handle_backend_data_callback(pDevice, nullptr, pAudioData, (ma_uint32)frameCount); } (void)pStream; @@ -39353,7 +39353,7 @@ static ma_aaudio_data_callback_result_t ma_stream_data_callback_capture__aaudio( static ma_aaudio_data_callback_result_t ma_stream_data_callback_playback__aaudio(ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount) { ma_device* pDevice = (ma_device*)pUserData; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* I've had a report that AAudio can sometimes post a frame count of 0. We need to check for that here @@ -39361,7 +39361,7 @@ static ma_aaudio_data_callback_result_t ma_stream_data_callback_playback__aaudio though I've not yet had any reports about that one. */ if (frameCount > 0) { - ma_device_handle_backend_data_callback(pDevice, pAudioData, NULL, (ma_uint32)frameCount); + ma_device_handle_backend_data_callback(pDevice, pAudioData, nullptr, (ma_uint32)frameCount); } (void)pStream; @@ -39374,14 +39374,14 @@ static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context* ma_aaudio_result_t resultAA; /* Safety. */ - *ppBuilder = NULL; + *ppBuilder = nullptr; resultAA = ((MA_PFN_AAudio_createStreamBuilder)pContext->aaudio.AAudio_createStreamBuilder)(&pBuilder); if (resultAA != MA_AAUDIO_OK) { return ma_result_from_aaudio(resultAA); } - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { ((MA_PFN_AAudioStreamBuilder_setDeviceId)pContext->aaudio.AAudioStreamBuilder_setDeviceId)(pBuilder, pDeviceID->aaudio); } @@ -39390,8 +39390,8 @@ static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context* /* If we have a device descriptor make sure we configure the stream builder to take our requested parameters. */ - if (pDescriptor != NULL) { - MA_ASSERT(pConfig != NULL); /* We must have a device config if we also have a descriptor. The config is required for AAudio specific configuration options. */ + if (pDescriptor != nullptr) { + MA_ASSERT(pConfig != nullptr); /* We must have a device config if we also have a descriptor. The config is required for AAudio specific configuration options. */ if (pDescriptor->sampleRate != 0) { ((MA_PFN_AAudioStreamBuilder_setSampleRate)pContext->aaudio.AAudioStreamBuilder_setSampleRate)(pBuilder, pDescriptor->sampleRate); @@ -39428,21 +39428,21 @@ static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context* } if (deviceType == ma_device_type_capture) { - if (pConfig->aaudio.inputPreset != ma_aaudio_input_preset_default && pContext->aaudio.AAudioStreamBuilder_setInputPreset != NULL) { + if (pConfig->aaudio.inputPreset != ma_aaudio_input_preset_default && pContext->aaudio.AAudioStreamBuilder_setInputPreset != nullptr) { ((MA_PFN_AAudioStreamBuilder_setInputPreset)pContext->aaudio.AAudioStreamBuilder_setInputPreset)(pBuilder, ma_to_input_preset__aaudio(pConfig->aaudio.inputPreset)); } ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, ma_stream_data_callback_capture__aaudio, (void*)pDevice); } else { - if (pConfig->aaudio.usage != ma_aaudio_usage_default && pContext->aaudio.AAudioStreamBuilder_setUsage != NULL) { + if (pConfig->aaudio.usage != ma_aaudio_usage_default && pContext->aaudio.AAudioStreamBuilder_setUsage != nullptr) { ((MA_PFN_AAudioStreamBuilder_setUsage)pContext->aaudio.AAudioStreamBuilder_setUsage)(pBuilder, ma_to_usage__aaudio(pConfig->aaudio.usage)); } - if (pConfig->aaudio.contentType != ma_aaudio_content_type_default && pContext->aaudio.AAudioStreamBuilder_setContentType != NULL) { + if (pConfig->aaudio.contentType != ma_aaudio_content_type_default && pContext->aaudio.AAudioStreamBuilder_setContentType != nullptr) { ((MA_PFN_AAudioStreamBuilder_setContentType)pContext->aaudio.AAudioStreamBuilder_setContentType)(pBuilder, ma_to_content_type__aaudio(pConfig->aaudio.contentType)); } - if (pConfig->aaudio.allowedCapturePolicy != ma_aaudio_allow_capture_default && pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy != NULL) { + if (pConfig->aaudio.allowedCapturePolicy != ma_aaudio_allow_capture_default && pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy != nullptr) { ((MA_PFN_AAudioStreamBuilder_setAllowedCapturePolicy)pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy)(pBuilder, ma_to_allowed_capture_policy__aaudio(pConfig->aaudio.allowedCapturePolicy)); } @@ -39457,7 +39457,7 @@ static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context* ((MA_PFN_AAudioStreamBuilder_setPerformanceMode)pContext->aaudio.AAudioStreamBuilder_setPerformanceMode)(pBuilder, (pConfig->performanceProfile == ma_performance_profile_low_latency) ? MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY : MA_AAUDIO_PERFORMANCE_MODE_NONE); /* We need to set an error callback to detect device changes. */ - if (pDevice != NULL) { /* <-- pDevice should never be null if pDescriptor is not null, which is always the case if we hit this branch. Check anyway for safety. */ + if (pDevice != nullptr) { /* <-- pDevice should never be null if pDescriptor is not null, which is always the case if we hit this branch. Check anyway for safety. */ ((MA_PFN_AAudioStreamBuilder_setErrorCallback)pContext->aaudio.AAudioStreamBuilder_setErrorCallback)(pBuilder, ma_stream_error_callback__aaudio, (void*)pDevice); } } @@ -39482,9 +39482,9 @@ static ma_result ma_open_stream_basic__aaudio(ma_context* pContext, const ma_dev ma_result result; ma_AAudioStreamBuilder* pBuilder; - *ppStream = NULL; + *ppStream = nullptr; - result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pContext, pDeviceID, deviceType, shareMode, NULL, NULL, NULL, &pBuilder); + result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pContext, pDeviceID, deviceType, shareMode, nullptr, nullptr, nullptr, &pBuilder); if (result != MA_SUCCESS) { return result; } @@ -39500,11 +39500,11 @@ static ma_result ma_open_stream__aaudio(ma_device* pDevice, const ma_device_conf ma_result result; ma_AAudioStreamBuilder* pBuilder; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pDescriptor != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pDescriptor != nullptr); MA_ASSERT(deviceType != ma_device_type_duplex); /* This function should not be called for a full-duplex device type. */ - *ppStream = NULL; + *ppStream = nullptr; result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pDevice->pContext, pDescriptor->pDeviceID, deviceType, pDescriptor->shareMode, pDescriptor, pConfig, pDevice, &pBuilder); if (result != MA_SUCCESS) { @@ -39516,7 +39516,7 @@ static ma_result ma_open_stream__aaudio(ma_device* pDevice, const ma_device_conf static ma_result ma_close_stream__aaudio(ma_context* pContext, ma_AAudioStream* pStream) { - if (pStream == NULL) { + if (pStream == nullptr) { return MA_INVALID_ARGS; } @@ -39527,7 +39527,7 @@ static ma_bool32 ma_has_default_device__aaudio(ma_context* pContext, ma_device_t { /* The only way to know this is to try creating a stream. */ ma_AAudioStream* pStream; - ma_result result = ma_open_stream_basic__aaudio(pContext, NULL, deviceType, ma_share_mode_shared, &pStream); + ma_result result = ma_open_stream_basic__aaudio(pContext, nullptr, deviceType, ma_share_mode_shared, &pStream); if (result != MA_SUCCESS) { return MA_FALSE; } @@ -39556,8 +39556,8 @@ static ma_result ma_context_enumerate_devices__aaudio(ma_context* pContext, ma_e { ma_bool32 cbResult = MA_TRUE; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); /* Unfortunately AAudio does not have an enumeration API. Therefore I'm only going to report default devices, but only if it can instantiate a stream. */ @@ -39590,9 +39590,9 @@ static ma_result ma_context_enumerate_devices__aaudio(ma_context* pContext, ma_e static void ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_format format, ma_uint32 flags, ma_device_info* pDeviceInfo) { - MA_ASSERT(pContext != NULL); - MA_ASSERT(pStream != NULL); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pStream != nullptr); + MA_ASSERT(pDeviceInfo != nullptr); pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = format; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = ((MA_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)(pStream); @@ -39613,10 +39613,10 @@ static ma_result ma_context_get_device_info__aaudio(ma_context* pContext, ma_dev ma_AAudioStream* pStream; ma_result result; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); /* ID */ - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { pDeviceInfo->id.aaudio = pDeviceID->aaudio; } else { pDeviceInfo->id.aaudio = MA_AAUDIO_UNSPECIFIED; @@ -39641,23 +39641,23 @@ static ma_result ma_context_get_device_info__aaudio(ma_context* pContext, ma_dev ma_context_add_native_data_format_from_AAudioStream__aaudio(pContext, pStream, 0, pDeviceInfo); ma_close_stream__aaudio(pContext, pStream); - pStream = NULL; + pStream = nullptr; return MA_SUCCESS; } static ma_result ma_close_streams__aaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* When rerouting, streams may have been closed and never re-opened. Hence the extra checks below. */ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture); - pDevice->aaudio.pStreamCapture = NULL; + pDevice->aaudio.pStreamCapture = nullptr; } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback); - pDevice->aaudio.pStreamPlayback = NULL; + pDevice->aaudio.pStreamPlayback = nullptr; } return MA_SUCCESS; @@ -39665,7 +39665,7 @@ static ma_result ma_close_streams__aaudio(ma_device* pDevice) static ma_result ma_device_uninit__aaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* Note: Closing the streams may cause a timeout error, which would then trigger rerouting in our error callback. @@ -39693,11 +39693,11 @@ static ma_result ma_device_init_by_type__aaudio(ma_device* pDevice, const ma_dev int32_t framesPerDataCallback; ma_AAudioStream* pStream; - MA_ASSERT(pDevice != NULL); - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDescriptor != NULL); + MA_ASSERT(pDevice != nullptr); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDescriptor != nullptr); - *ppStream = NULL; /* Safety. */ + *ppStream = nullptr; /* Safety. */ /* First step is to open the stream. From there we'll be able to extract the internal configuration. */ result = ma_open_stream__aaudio(pDevice, pConfig, deviceType, pDescriptor, &pStream); @@ -39737,7 +39737,7 @@ static ma_result ma_device_init_streams__aaudio(ma_device* pDevice, const ma_dev { ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; @@ -39770,7 +39770,7 @@ static ma_result ma_device_init__aaudio(ma_device* pDevice, const ma_device_conf { ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); result = ma_device_init_streams__aaudio(pDevice, pConfig, pDescriptorPlayback, pDescriptorCapture); if (result != MA_SUCCESS) { @@ -39790,9 +39790,9 @@ static ma_result ma_device_start_stream__aaudio(ma_device* pDevice, ma_AAudioStr ma_aaudio_result_t resultAA; ma_aaudio_stream_state_t currentState; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); - if (pStream == NULL) { + if (pStream == nullptr) { return MA_INVALID_ARGS; } @@ -39826,9 +39826,9 @@ static ma_result ma_device_stop_stream__aaudio(ma_device* pDevice, ma_AAudioStre ma_aaudio_result_t resultAA; ma_aaudio_stream_state_t currentState; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); - if (pStream == NULL) { + if (pStream == nullptr) { return MA_INVALID_ARGS; } @@ -39869,7 +39869,7 @@ static ma_result ma_device_stop_stream__aaudio(ma_device* pDevice, ma_AAudioStre static ma_result ma_device_start__aaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_result result = ma_device_start_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture); @@ -39893,7 +39893,7 @@ static ma_result ma_device_start__aaudio(ma_device* pDevice) static ma_result ma_device_stop__aaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_result result = ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture); @@ -39921,7 +39921,7 @@ static ma_result ma_device_reinit__aaudio(ma_device* pDevice, ma_device_type dev ma_result result; ma_int32 iAttempt; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* We got disconnected! Retry a few times, until we find a connected device! */ iAttempt = 0; @@ -39941,11 +39941,11 @@ static ma_result ma_device_reinit__aaudio(ma_device* pDevice, ma_device_type dev ma_device_descriptor descriptorCapture; deviceConfig = ma_device_config_init(deviceType); - deviceConfig.playback.pDeviceID = NULL; /* Only doing rerouting with default devices. */ + deviceConfig.playback.pDeviceID = nullptr; /* Only doing rerouting with default devices. */ deviceConfig.playback.shareMode = pDevice->playback.shareMode; deviceConfig.playback.format = pDevice->playback.format; deviceConfig.playback.channels = pDevice->playback.channels; - deviceConfig.capture.pDeviceID = NULL; /* Only doing rerouting with default devices. */ + deviceConfig.capture.pDeviceID = nullptr; /* Only doing rerouting with default devices. */ deviceConfig.capture.shareMode = pDevice->capture.shareMode; deviceConfig.capture.format = pDevice->capture.format; deviceConfig.capture.channels = pDevice->capture.channels; @@ -40029,11 +40029,11 @@ static ma_result ma_device_reinit__aaudio(ma_device* pDevice, ma_device_type dev static ma_result ma_device_get_info__aaudio(ma_device* pDevice, ma_device_type type, ma_device_info* pDeviceInfo) { - ma_AAudioStream* pStream = NULL; + ma_AAudioStream* pStream = nullptr; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(type != ma_device_type_duplex); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pDeviceInfo != nullptr); if (type == ma_device_type_capture) { pStream = (ma_AAudioStream*)pDevice->aaudio.pStreamCapture; @@ -40047,7 +40047,7 @@ static ma_result ma_device_get_info__aaudio(ma_device* pDevice, ma_device_type t } /* Safety. Should never happen. */ - if (pStream == NULL) { + if (pStream == nullptr) { return MA_INVALID_OPERATION; } @@ -40060,13 +40060,13 @@ static ma_result ma_device_get_info__aaudio(ma_device* pDevice, ma_device_type t static ma_result ma_context_uninit__aaudio(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_aaudio); ma_device_job_thread_uninit(&pContext->aaudio.jobThread, &pContext->allocationCallbacks); ma_dlclose(ma_context_get_log(pContext), pContext->aaudio.hAAudio); - pContext->aaudio.hAAudio = NULL; + pContext->aaudio.hAAudio = nullptr; return MA_SUCCESS; } @@ -40081,12 +40081,12 @@ static ma_result ma_context_init__aaudio(ma_context* pContext, const ma_context_ for (i = 0; i < ma_countof(libNames); ++i) { pContext->aaudio.hAAudio = ma_dlopen(ma_context_get_log(pContext), libNames[i]); - if (pContext->aaudio.hAAudio != NULL) { + if (pContext->aaudio.hAAudio != nullptr) { break; } } - if (pContext->aaudio.hAAudio == NULL) { + if (pContext->aaudio.hAAudio == nullptr) { return MA_FAILED_TO_INIT_BACKEND; } @@ -40161,9 +40161,9 @@ static ma_result ma_context_init__aaudio(ma_context* pContext, const ma_context_ pCallbacks->onDeviceUninit = ma_device_uninit__aaudio; pCallbacks->onDeviceStart = ma_device_start__aaudio; pCallbacks->onDeviceStop = ma_device_stop__aaudio; - pCallbacks->onDeviceRead = NULL; /* Not used because AAudio is asynchronous. */ - pCallbacks->onDeviceWrite = NULL; /* Not used because AAudio is asynchronous. */ - pCallbacks->onDeviceDataLoop = NULL; /* Not used because AAudio is asynchronous. */ + pCallbacks->onDeviceRead = nullptr; /* Not used because AAudio is asynchronous. */ + pCallbacks->onDeviceWrite = nullptr; /* Not used because AAudio is asynchronous. */ + pCallbacks->onDeviceDataLoop = nullptr; /* Not used because AAudio is asynchronous. */ pCallbacks->onDeviceGetInfo = ma_device_get_info__aaudio; @@ -40177,7 +40177,7 @@ static ma_result ma_context_init__aaudio(ma_context* pContext, const ma_context_ result = ma_device_job_thread_init(&jobThreadConfig, &pContext->allocationCallbacks, &pContext->aaudio.jobThread); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->aaudio.hAAudio); - pContext->aaudio.hAAudio = NULL; + pContext->aaudio.hAAudio = nullptr; return result; } } @@ -40192,10 +40192,10 @@ static ma_result ma_job_process__device__aaudio_reroute(ma_job* pJob) ma_result result = MA_SUCCESS; ma_device* pDevice; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pDevice = (ma_device*)pJob->data.device.aaudio.reroute.pDevice; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); ma_mutex_lock(&pDevice->aaudio.rerouteLock); { @@ -40237,8 +40237,8 @@ OpenSL|ES Backend typedef SLresult (SLAPIENTRY * ma_slCreateEngine_proc)(SLObjectItf* pEngine, SLuint32 numOptions, SLEngineOption* pEngineOptions, SLuint32 numInterfaces, SLInterfaceID* pInterfaceIds, SLboolean* pInterfaceRequired); /* OpenSL|ES has one-per-application objects :( */ -static SLObjectItf g_maEngineObjectSL = NULL; -static SLEngineItf g_maEngineSL = NULL; +static SLObjectItf g_maEngineObjectSL = nullptr; +static SLEngineItf g_maEngineSL = nullptr; static ma_uint32 g_maOpenSLInitCounter = 0; static ma_spinlock g_maOpenSLSpinlock = 0; /* For init/uninit. */ @@ -40456,8 +40456,8 @@ static ma_result ma_context_enumerate_devices__opensl(ma_context* pContext, ma_e { ma_bool32 cbResult; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to enumerate devices. */ if (g_maOpenSLInitCounter == 0) { @@ -40565,8 +40565,8 @@ return_default_device:; static void ma_context_add_data_format_ex__opensl(ma_context* pContext, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_device_info* pDeviceInfo) { - MA_ASSERT(pContext != NULL); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pDeviceInfo != nullptr); pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = format; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = channels; @@ -40584,8 +40584,8 @@ static void ma_context_add_data_format__opensl(ma_context* pContext, ma_format f ma_uint32 iChannel; ma_uint32 iSampleRate; - MA_ASSERT(pContext != NULL); - MA_ASSERT(pDeviceInfo != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(pDeviceInfo != nullptr); /* Each sample format can support mono and stereo, and we'll support a small subset of standard @@ -40603,7 +40603,7 @@ static void ma_context_add_data_format__opensl(ma_context* pContext, ma_format f static ma_result ma_context_get_device_info__opensl(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to get device info. */ if (g_maOpenSLInitCounter == 0) { @@ -40647,7 +40647,7 @@ static ma_result ma_context_get_device_info__opensl(ma_context* pContext, ma_dev #endif return_default_device: - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { if ((deviceType == ma_device_type_playback && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOOUTPUT) || (deviceType == ma_device_type_capture && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOINPUT)) { return MA_NO_DEVICE; /* Don't know the device. */ @@ -40695,7 +40695,7 @@ static void ma_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBuff ma_uint8* pBuffer; SLresult resultSL; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); (void)pBufferQueue; @@ -40718,7 +40718,7 @@ static void ma_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBuff periodSizeInBytes = pDevice->capture.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); pBuffer = pDevice->opensl.pBufferCapture + (pDevice->opensl.currentBufferIndexCapture * periodSizeInBytes); - ma_device_handle_backend_data_callback(pDevice, NULL, pBuffer, pDevice->capture.internalPeriodSizeInFrames); + ma_device_handle_backend_data_callback(pDevice, nullptr, pBuffer, pDevice->capture.internalPeriodSizeInFrames); resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pBuffer, periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { @@ -40735,7 +40735,7 @@ static void ma_buffer_queue_callback_playback__opensl_android(SLAndroidSimpleBuf ma_uint8* pBuffer; SLresult resultSL; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); (void)pBufferQueue; @@ -40752,7 +40752,7 @@ static void ma_buffer_queue_callback_playback__opensl_android(SLAndroidSimpleBuf periodSizeInBytes = pDevice->playback.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); pBuffer = pDevice->opensl.pBufferPlayback + (pDevice->opensl.currentBufferIndexPlayback * periodSizeInBytes); - ma_device_handle_backend_data_callback(pDevice, pBuffer, NULL, pDevice->playback.internalPeriodSizeInFrames); + ma_device_handle_backend_data_callback(pDevice, pBuffer, nullptr, pDevice->playback.internalPeriodSizeInFrames); resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pBuffer, periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { @@ -40765,7 +40765,7 @@ static void ma_buffer_queue_callback_playback__opensl_android(SLAndroidSimpleBuf static ma_result ma_device_uninit__opensl(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before uninitializing the device. */ if (g_maOpenSLInitCounter == 0) { @@ -40937,7 +40937,7 @@ static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_conf } /* Now we can start initializing the device properly. */ - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ZERO_OBJECT(&pDevice->opensl); queue.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; @@ -40954,10 +40954,10 @@ static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_conf locatorDevice.locatorType = SL_DATALOCATOR_IODEVICE; locatorDevice.deviceType = SL_IODEVICE_AUDIOINPUT; locatorDevice.deviceID = SL_DEFAULTDEVICEID_AUDIOINPUT; /* Must always use the default device with Android. */ - locatorDevice.device = NULL; + locatorDevice.device = nullptr; source.pLocator = &locatorDevice; - source.pFormat = NULL; + source.pFormat = nullptr; queue.numBuffers = pDescriptorCapture->periodCount; @@ -41032,7 +41032,7 @@ static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_conf bufferSizeInBytes = pDescriptorCapture->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) * pDescriptorCapture->periodCount; pDevice->opensl.pBufferCapture = (ma_uint8*)ma_calloc(bufferSizeInBytes, &pDevice->pContext->allocationCallbacks); - if (pDevice->opensl.pBufferCapture == NULL) { + if (pDevice->opensl.pBufferCapture == nullptr) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer."); return MA_OUT_OF_MEMORY; @@ -41049,7 +41049,7 @@ static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_conf ma_SLDataFormat_PCM_init__opensl(pDescriptorPlayback->format, pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, &pcm); - resultSL = (*g_maEngineSL)->CreateOutputMix(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pOutputMixObj, 0, NULL, NULL); + resultSL = (*g_maEngineSL)->CreateOutputMix(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pOutputMixObj, 0, nullptr, nullptr); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create output mix."); @@ -41071,7 +41071,7 @@ static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_conf } /* Set the output device. */ - if (pDescriptorPlayback->pDeviceID != NULL) { + if (pDescriptorPlayback->pDeviceID != nullptr) { SLuint32 deviceID_OpenSL = pDescriptorPlayback->pDeviceID->opensl; MA_OPENSL_OUTPUTMIX(pDevice->opensl.pOutputMix)->ReRoute((SLOutputMixItf)pDevice->opensl.pOutputMix, 1, &deviceID_OpenSL); } @@ -41085,7 +41085,7 @@ static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_conf outmixLocator.outputMix = (SLObjectItf)pDevice->opensl.pOutputMixObj; sink.pLocator = &outmixLocator; - sink.pFormat = NULL; + sink.pFormat = nullptr; resultSL = (*g_maEngineSL)->CreateAudioPlayer(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioPlayerObj, &source, &sink, ma_countof(itfIDs), itfIDs, itfIDsRequired); if (resultSL == SL_RESULT_CONTENT_UNSUPPORTED || resultSL == SL_RESULT_PARAMETER_INVALID) { @@ -41155,7 +41155,7 @@ static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_conf bufferSizeInBytes = pDescriptorPlayback->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels) * pDescriptorPlayback->periodCount; pDevice->opensl.pBufferPlayback = (ma_uint8*)ma_calloc(bufferSizeInBytes, &pDevice->pContext->allocationCallbacks); - if (pDevice->opensl.pBufferPlayback == NULL) { + if (pDevice->opensl.pBufferPlayback == nullptr) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer."); return MA_OUT_OF_MEMORY; @@ -41175,7 +41175,7 @@ static ma_result ma_device_start__opensl(ma_device* pDevice) size_t periodSizeInBytes; ma_uint32 iPeriod; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to start the device. */ if (g_maOpenSLInitCounter == 0) { @@ -41266,7 +41266,7 @@ static ma_result ma_device_stop__opensl(ma_device* pDevice) { SLresult resultSL; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before stopping/uninitializing the device. */ if (g_maOpenSLInitCounter == 0) { @@ -41306,7 +41306,7 @@ static ma_result ma_device_stop__opensl(ma_device* pDevice) static ma_result ma_context_uninit__opensl(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_opensl); (void)pContext; @@ -41329,7 +41329,7 @@ static ma_result ma_dlsym_SLInterfaceID__opensl(ma_context* pContext, const char { /* We need to return an error if the symbol cannot be found. This is important because there have been reports that some symbols do not exist. */ ma_handle* p = (ma_handle*)ma_dlsym(ma_context_get_log(pContext), pContext->opensl.libOpenSLES, pName); - if (p == NULL) { + if (p == nullptr) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_INFO, "[OpenSL] Cannot find symbol %s", pName); return MA_NO_BACKEND; } @@ -41344,7 +41344,7 @@ static ma_result ma_context_init_engine_nolock__opensl(ma_context* pContext) if (g_maOpenSLInitCounter == 1) { SLresult resultSL; - resultSL = ((ma_slCreateEngine_proc)pContext->opensl.slCreateEngine)(&g_maEngineObjectSL, 0, NULL, 0, NULL, NULL); + resultSL = ((ma_slCreateEngine_proc)pContext->opensl.slCreateEngine)(&g_maEngineObjectSL, 0, nullptr, 0, nullptr, nullptr); if (resultSL != SL_RESULT_SUCCESS) { g_maOpenSLInitCounter -= 1; return ma_result_from_OpenSL(resultSL); @@ -41374,7 +41374,7 @@ static ma_result ma_context_init__opensl(ma_context* pContext, const ma_context_ }; #endif - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); (void)pConfig; @@ -41387,12 +41387,12 @@ static ma_result ma_context_init__opensl(ma_context* pContext, const ma_context_ */ for (i = 0; i < ma_countof(libOpenSLESNames); i += 1) { pContext->opensl.libOpenSLES = ma_dlopen(ma_context_get_log(pContext), libOpenSLESNames[i]); - if (pContext->opensl.libOpenSLES != NULL) { + if (pContext->opensl.libOpenSLES != nullptr) { break; } } - if (pContext->opensl.libOpenSLES == NULL) { + if (pContext->opensl.libOpenSLES == nullptr) { ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_INFO, "[OpenSL] Could not find libOpenSLES.so"); return MA_NO_BACKEND; } @@ -41440,7 +41440,7 @@ static ma_result ma_context_init__opensl(ma_context* pContext, const ma_context_ } pContext->opensl.slCreateEngine = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->opensl.libOpenSLES, "slCreateEngine"); - if (pContext->opensl.slCreateEngine == NULL) { + if (pContext->opensl.slCreateEngine == nullptr) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_INFO, "[OpenSL] Cannot find symbol slCreateEngine."); return MA_NO_BACKEND; @@ -41478,9 +41478,9 @@ static ma_result ma_context_init__opensl(ma_context* pContext, const ma_context_ pCallbacks->onDeviceUninit = ma_device_uninit__opensl; pCallbacks->onDeviceStart = ma_device_start__opensl; pCallbacks->onDeviceStop = ma_device_stop__opensl; - pCallbacks->onDeviceRead = NULL; /* Not needed because OpenSL|ES is asynchronous. */ - pCallbacks->onDeviceWrite = NULL; /* Not needed because OpenSL|ES is asynchronous. */ - pCallbacks->onDeviceDataLoop = NULL; /* Not needed because OpenSL|ES is asynchronous. */ + pCallbacks->onDeviceRead = nullptr; /* Not needed because OpenSL|ES is asynchronous. */ + pCallbacks->onDeviceWrite = nullptr; /* Not needed because OpenSL|ES is asynchronous. */ + pCallbacks->onDeviceDataLoop = nullptr; /* Not needed because OpenSL|ES is asynchronous. */ return MA_SUCCESS; } @@ -41544,12 +41544,12 @@ void EMSCRIPTEN_KEEPALIVE ma_free_emscripten(void* p, const ma_allocation_callba void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames) { - ma_device_handle_backend_data_callback(pDevice, NULL, pFrames, (ma_uint32)frameCount); + ma_device_handle_backend_data_callback(pDevice, nullptr, pFrames, (ma_uint32)frameCount); } void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_playback__webaudio(ma_device* pDevice, int frameCount, float* pFrames) { - ma_device_handle_backend_data_callback(pDevice, pFrames, NULL, (ma_uint32)frameCount); + ma_device_handle_backend_data_callback(pDevice, pFrames, nullptr, (ma_uint32)frameCount); } #ifdef __cplusplus } @@ -41559,8 +41559,8 @@ static ma_result ma_context_enumerate_devices__webaudio(ma_context* pContext, ma { ma_bool32 cbResult = MA_TRUE; - MA_ASSERT(pContext != NULL); - MA_ASSERT(callback != NULL); + MA_ASSERT(pContext != nullptr); + MA_ASSERT(callback != nullptr); /* Only supporting default devices for now. */ @@ -41589,7 +41589,7 @@ static ma_result ma_context_enumerate_devices__webaudio(ma_context* pContext, ma static ma_result ma_context_get_device_info__webaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); if (deviceType == ma_device_type_capture && !ma_is_capture_supported__webaudio()) { return MA_NO_DEVICE; @@ -41634,7 +41634,7 @@ static ma_result ma_context_get_device_info__webaudio(ma_context* pContext, ma_d static ma_result ma_device_uninit__webaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); #if defined(MA_USE_AUDIO_WORKLETS) { @@ -41872,7 +41872,7 @@ static void ma_audio_worklet_processor_created__webaudio(EMSCRIPTEN_WEBAUDIO_T a #endif pParameters->pDevice->webaudio.pIntermediaryBuffer = (float*)ma_malloc(intermediaryBufferSizeInFrames * (ma_uint32)channels * sizeof(float), &pParameters->pDevice->pContext->allocationCallbacks); - if (pParameters->pDevice->webaudio.pIntermediaryBuffer == NULL) { + if (pParameters->pDevice->webaudio.pIntermediaryBuffer == nullptr) { pParameters->pDevice->webaudio.initResult = MA_OUT_OF_MEMORY; ma_free(pParameters, &pParameters->pDevice->pContext->allocationCallbacks); return; @@ -41931,7 +41931,7 @@ static void ma_audio_worklet_processor_created__webaudio(EMSCRIPTEN_WEBAUDIO_T a /* We need to update the descriptors so that they reflect the internal data format. Both capture and playback should be the same. */ sampleRate = EM_ASM_INT({ return emscriptenGetAudioObject($0).sampleRate; }, audioContext); - if (pParameters->pDescriptorCapture != NULL) { + if (pParameters->pDescriptorCapture != nullptr) { pParameters->pDescriptorCapture->format = ma_format_f32; pParameters->pDescriptorCapture->channels = (ma_uint32)channels; pParameters->pDescriptorCapture->sampleRate = (ma_uint32)sampleRate; @@ -41940,7 +41940,7 @@ static void ma_audio_worklet_processor_created__webaudio(EMSCRIPTEN_WEBAUDIO_T a pParameters->pDescriptorCapture->periodCount = 1; } - if (pParameters->pDescriptorPlayback != NULL) { + if (pParameters->pDescriptorPlayback != nullptr) { pParameters->pDescriptorPlayback->format = ma_format_f32; pParameters->pDescriptorPlayback->channels = (ma_uint32)channels; pParameters->pDescriptorPlayback->sampleRate = (ma_uint32)sampleRate; @@ -41960,7 +41960,7 @@ static void ma_audio_worklet_thread_initialized__webaudio(EMSCRIPTEN_WEBAUDIO_T ma_audio_worklet_thread_initialized_data* pParameters = (ma_audio_worklet_thread_initialized_data*)pUserData; WebAudioWorkletProcessorCreateOptions workletProcessorOptions; - MA_ASSERT(pParameters != NULL); + MA_ASSERT(pParameters != nullptr); if (success == EM_FALSE) { pParameters->pDevice->webaudio.initResult = MA_ERROR; @@ -42028,14 +42028,14 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co allocate this on the heap to keep it simple. */ pStackBuffer = ma_aligned_malloc(MA_AUDIO_WORKLETS_THREAD_STACK_SIZE, 16, &pDevice->pContext->allocationCallbacks); - if (pStackBuffer == NULL) { + if (pStackBuffer == nullptr) { emscripten_destroy_audio_context(pDevice->webaudio.audioContext); return MA_OUT_OF_MEMORY; } /* Our thread initialization parameters need to be allocated on the heap so they don't go out of scope. */ pInitParameters = (ma_audio_worklet_thread_initialized_data*)ma_malloc(sizeof(*pInitParameters), &pDevice->pContext->allocationCallbacks); - if (pInitParameters == NULL) { + if (pInitParameters == nullptr) { ma_free(pStackBuffer, &pDevice->pContext->allocationCallbacks); emscripten_destroy_audio_context(pDevice->webaudio.audioContext); return MA_OUT_OF_MEMORY; @@ -42108,7 +42108,7 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co /* We need an intermediary buffer for doing interleaving and deinterleaving. */ pDevice->webaudio.pIntermediaryBuffer = (float*)ma_malloc(periodSizeInFrames * channels * sizeof(float), &pDevice->pContext->allocationCallbacks); - if (pDevice->webaudio.pIntermediaryBuffer == NULL) { + if (pDevice->webaudio.pIntermediaryBuffer == nullptr) { return MA_OUT_OF_MEMORY; } @@ -42219,7 +42219,7 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co /* Grab the sample rate from the audio context directly. */ sampleRate = (ma_uint32)EM_ASM_INT({ return window.miniaudio.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex); - if (pDescriptorCapture != NULL) { + if (pDescriptorCapture != nullptr) { pDescriptorCapture->format = ma_format_f32; pDescriptorCapture->channels = channels; pDescriptorCapture->sampleRate = sampleRate; @@ -42228,7 +42228,7 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co pDescriptorCapture->periodCount = 1; } - if (pDescriptorPlayback != NULL) { + if (pDescriptorPlayback != nullptr) { pDescriptorPlayback->format = ma_format_f32; pDescriptorPlayback->channels = channels; pDescriptorPlayback->sampleRate = sampleRate; @@ -42244,7 +42244,7 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co static ma_result ma_device_start__webaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); EM_ASM({ var device = window.miniaudio.get_device_by_index($0); @@ -42257,7 +42257,7 @@ static ma_result ma_device_start__webaudio(ma_device* pDevice) static ma_result ma_device_stop__webaudio(ma_device* pDevice) { - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); /* From the WebAudio API documentation for AudioContext.suspend(): @@ -42281,7 +42281,7 @@ static ma_result ma_device_stop__webaudio(ma_device* pDevice) static ma_result ma_context_uninit__webaudio(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); MA_ASSERT(pContext->backend == ma_backend_webaudio); (void)pContext; /* Unused. */ @@ -42307,7 +42307,7 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex { int resultFromJS; - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); (void)pConfig; /* Unused. */ @@ -42422,9 +42422,9 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex pCallbacks->onDeviceUninit = ma_device_uninit__webaudio; pCallbacks->onDeviceStart = ma_device_start__webaudio; pCallbacks->onDeviceStop = ma_device_stop__webaudio; - pCallbacks->onDeviceRead = NULL; /* Not needed because WebAudio is asynchronous. */ - pCallbacks->onDeviceWrite = NULL; /* Not needed because WebAudio is asynchronous. */ - pCallbacks->onDeviceDataLoop = NULL; /* Not needed because WebAudio is asynchronous. */ + pCallbacks->onDeviceRead = nullptr; /* Not needed because WebAudio is asynchronous. */ + pCallbacks->onDeviceWrite = nullptr; /* Not needed because WebAudio is asynchronous. */ + pCallbacks->onDeviceDataLoop = nullptr; /* Not needed because WebAudio is asynchronous. */ return MA_SUCCESS; } @@ -42435,7 +42435,7 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex static ma_bool32 ma__is_channel_map_valid(const ma_channel* pChannelMap, ma_uint32 channels) { /* A blank channel map should be allowed, in which case it should use an appropriate default which will depend on context. */ - if (pChannelMap != NULL && pChannelMap[0] != MA_CHANNEL_NONE) { + if (pChannelMap != nullptr && pChannelMap[0] != MA_CHANNEL_NONE) { ma_uint32 iChannel; if (channels == 0 || channels > MA_MAX_CHANNELS) { @@ -42459,10 +42459,10 @@ static ma_bool32 ma__is_channel_map_valid(const ma_channel* pChannelMap, ma_uint static ma_bool32 ma_context_is_backend_asynchronous(ma_context* pContext) { - MA_ASSERT(pContext != NULL); + MA_ASSERT(pContext != nullptr); - if (pContext->callbacks.onDeviceRead == NULL && pContext->callbacks.onDeviceWrite == NULL) { - if (pContext->callbacks.onDeviceDataLoop == NULL) { + if (pContext->callbacks.onDeviceRead == nullptr && pContext->callbacks.onDeviceWrite == nullptr) { + if (pContext->callbacks.onDeviceDataLoop == nullptr) { return MA_TRUE; } else { return MA_FALSE; @@ -42477,7 +42477,7 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d { ma_result result; - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) { if (pDevice->capture.format == ma_format_unknown) { @@ -42629,15 +42629,15 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d newInputCacheSizeInBytes = newInputCacheCap * ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); if (newInputCacheSizeInBytes > MA_SIZE_MAX) { ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks); - pDevice->playback.pInputCache = NULL; + pDevice->playback.pInputCache = nullptr; pDevice->playback.inputCacheCap = 0; return MA_OUT_OF_MEMORY; /* Allocation too big. Should never hit this, but makes the cast below safer for 32-bit builds. */ } pNewInputCache = ma_realloc(pDevice->playback.pInputCache, (size_t)newInputCacheSizeInBytes, &pDevice->pContext->allocationCallbacks); - if (pNewInputCache == NULL) { + if (pNewInputCache == nullptr) { ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks); - pDevice->playback.pInputCache = NULL; + pDevice->playback.pInputCache = nullptr; pDevice->playback.inputCacheCap = 0; return MA_OUT_OF_MEMORY; } @@ -42647,7 +42647,7 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d } else { /* Heap allocation not required. Make sure we clear out the old cache just in case this function was called in response to a route change. */ ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks); - pDevice->playback.pInputCache = NULL; + pDevice->playback.pInputCache = nullptr; pDevice->playback.inputCacheCap = 0; } } @@ -42659,7 +42659,7 @@ MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceTy { ma_result result; - if (pDevice == NULL) { + if (pDevice == nullptr) { return MA_INVALID_ARGS; } @@ -42712,7 +42712,7 @@ MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceTy ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), deviceInfo.name, (size_t)-1); } else { /* We failed to retrieve the device info. Fall back to a default name. */ - if (pDescriptorCapture->pDeviceID == NULL) { + if (pDescriptorCapture->pDeviceID == nullptr) { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), "Capture Device", (size_t)-1); @@ -42726,7 +42726,7 @@ MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceTy ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), deviceInfo.name, (size_t)-1); } else { /* We failed to retrieve the device info. Fall back to a default name. */ - if (pDescriptorPlayback->pDeviceID == NULL) { + if (pDescriptorPlayback->pDeviceID == nullptr) { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), "Playback Device", (size_t)-1); @@ -42747,10 +42747,10 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) HRESULT CoInitializeResult; #endif - MA_ASSERT(pDevice != NULL); + MA_ASSERT(pDevice != nullptr); #if defined(MA_WIN32) && !defined(MA_XBOX) - CoInitializeResult = ma_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE); + CoInitializeResult = ma_CoInitializeEx(pDevice->pContext, nullptr, MA_COINIT_VALUE); #endif /* @@ -42785,7 +42785,7 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) MA_ASSERT(ma_device_get_state(pDevice) == ma_device_state_starting); /* If the device has a start callback, start it now. */ - if (pDevice->pContext->callbacks.onDeviceStart != NULL) { + if (pDevice->pContext->callbacks.onDeviceStart != nullptr) { startResult = pDevice->pContext->callbacks.onDeviceStart(pDevice); } else { startResult = MA_SUCCESS; @@ -42807,7 +42807,7 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) ma_device__on_notification_started(pDevice); - if (pDevice->pContext->callbacks.onDeviceDataLoop != NULL) { + if (pDevice->pContext->callbacks.onDeviceDataLoop != nullptr) { pDevice->pContext->callbacks.onDeviceDataLoop(pDevice); } else { /* The backend is not using a custom main loop implementation, so now fall back to the blocking read-write implementation. */ @@ -42815,7 +42815,7 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) } /* Getting here means we have broken from the main loop which happens the application has requested that device be stopped. */ - if (pDevice->pContext->callbacks.onDeviceStop != NULL) { + if (pDevice->pContext->callbacks.onDeviceStop != nullptr) { stopResult = pDevice->pContext->callbacks.onDeviceStop(pDevice); } else { stopResult = MA_SUCCESS; /* No stop callback with the backend. Just assume successful. */ @@ -42853,7 +42853,7 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) /* Helper for determining whether or not the given device is initialized. */ static ma_bool32 ma_device__is_initialized(ma_device* pDevice) { - if (pDevice == NULL) { + if (pDevice == nullptr) { return MA_FALSE; } @@ -42904,7 +42904,7 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) { /* User32.dll */ pContext->win32.hUser32DLL = ma_dlopen(ma_context_get_log(pContext), "user32.dll"); - if (pContext->win32.hUser32DLL == NULL) { + if (pContext->win32.hUser32DLL == nullptr) { return MA_FAILED_TO_INIT_BACKEND; } @@ -42914,7 +42914,7 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) /* Advapi32.dll */ pContext->win32.hAdvapi32DLL = ma_dlopen(ma_context_get_log(pContext), "advapi32.dll"); - if (pContext->win32.hAdvapi32DLL == NULL) { + if (pContext->win32.hAdvapi32DLL == nullptr) { return MA_FAILED_TO_INIT_BACKEND; } @@ -42926,7 +42926,7 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) /* Ole32.dll */ pContext->win32.hOle32DLL = ma_dlopen(ma_context_get_log(pContext), "ole32.dll"); - if (pContext->win32.hOle32DLL == NULL) { + if (pContext->win32.hOle32DLL == nullptr) { return MA_FAILED_TO_INIT_BACKEND; } @@ -42947,7 +42947,7 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) /* TODO: Remove this once the new single threaded backend system is in place in 0.12. */ #if !defined(MA_XBOX) { - pContext->win32.CoInitializeResult = ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE); + pContext->win32.CoInitializeResult = ma_CoInitializeEx(pContext, nullptr, MA_COINIT_VALUE); } #endif @@ -43015,7 +43015,7 @@ MA_API ma_device_job_thread_config ma_device_job_thread_config_init(void) static ma_thread_result MA_THREADCALL ma_device_job_thread_entry(void* pUserData) { ma_device_job_thread* pJobThread = (ma_device_job_thread*)pUserData; - MA_ASSERT(pJobThread != NULL); + MA_ASSERT(pJobThread != nullptr); for (;;) { ma_result result; @@ -43041,13 +43041,13 @@ MA_API ma_result ma_device_job_thread_init(const ma_device_job_thread_config* pC ma_result result; ma_job_queue_config jobQueueConfig; - if (pJobThread == NULL) { + if (pJobThread == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pJobThread); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -43080,7 +43080,7 @@ MA_API ma_result ma_device_job_thread_init(const ma_device_job_thread_config* pC MA_API void ma_device_job_thread_uninit(ma_device_job_thread* pJobThread, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pJobThread == NULL) { + if (pJobThread == nullptr) { return; } @@ -43101,7 +43101,7 @@ MA_API void ma_device_job_thread_uninit(ma_device_job_thread* pJobThread, const MA_API ma_result ma_device_job_thread_post(ma_device_job_thread* pJobThread, const ma_job* pJob) { - if (pJobThread == NULL || pJob == NULL) { + if (pJobThread == nullptr || pJob == nullptr) { return MA_INVALID_ARGS; } @@ -43110,13 +43110,13 @@ MA_API ma_result ma_device_job_thread_post(ma_device_job_thread* pJobThread, con MA_API ma_result ma_device_job_thread_next(ma_device_job_thread* pJobThread, ma_job* pJob) { - if (pJob == NULL) { + if (pJob == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pJob); - if (pJobThread == NULL) { + if (pJobThread == nullptr) { return MA_INVALID_ARGS; } @@ -43128,7 +43128,7 @@ MA_API ma_bool32 ma_device_id_equal(const ma_device_id* pA, const ma_device_id* { size_t i; - if (pA == NULL || pB == NULL) { + if (pA == nullptr || pB == nullptr) { return MA_FALSE; } @@ -43160,14 +43160,14 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC ma_backend* pBackendsToIterate; ma_uint32 backendsToIterateCount; - if (pContext == NULL) { + if (pContext == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pContext); /* Always make sure the config is set first to ensure properties are available as soon as possible. */ - if (pConfig == NULL) { + if (pConfig == nullptr) { defaultConfig = ma_context_config_init(); pConfig = &defaultConfig; } @@ -43179,14 +43179,14 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC } /* Get a lot set up first so we can start logging ASAP. */ - if (pConfig->pLog != NULL) { + if (pConfig->pLog != nullptr) { pContext->pLog = pConfig->pLog; } else { result = ma_log_init(&pContext->allocationCallbacks, &pContext->log); if (result == MA_SUCCESS) { pContext->pLog = &pContext->log; } else { - pContext->pLog = NULL; /* Logging is not available. */ + pContext->pLog = nullptr; /* Logging is not available. */ } } @@ -43206,12 +43206,12 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC pBackendsToIterate = (ma_backend*)backends; backendsToIterateCount = backendCount; - if (pBackendsToIterate == NULL) { + if (pBackendsToIterate == nullptr) { pBackendsToIterate = (ma_backend*)defaultBackends; backendsToIterateCount = ma_countof(defaultBackends); } - MA_ASSERT(pBackendsToIterate != NULL); + MA_ASSERT(pBackendsToIterate != nullptr); for (iBackend = 0; iBackend < backendsToIterateCount; iBackend += 1) { ma_backend backend = pBackendsToIterate[iBackend]; @@ -43320,7 +43320,7 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC default: break; } - if (pContext->callbacks.onContextInit != NULL) { + if (pContext->callbacks.onContextInit != nullptr) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "Attempting to initialize %s backend...\n", ma_get_backend_name(backend)); result = pContext->callbacks.onContextInit(pContext, pConfig, &pContext->callbacks); } else { @@ -43372,11 +43372,11 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC MA_API ma_result ma_context_uninit(ma_context* pContext) { - if (pContext == NULL) { + if (pContext == nullptr) { return MA_INVALID_ARGS; } - if (pContext->callbacks.onContextUninit != NULL) { + if (pContext->callbacks.onContextUninit != nullptr) { pContext->callbacks.onContextUninit(pContext); } @@ -43400,8 +43400,8 @@ MA_API size_t ma_context_sizeof(void) MA_API ma_log* ma_context_get_log(ma_context* pContext) { - if (pContext == NULL) { - return NULL; + if (pContext == nullptr) { + return nullptr; } return pContext->pLog; @@ -43412,11 +43412,11 @@ MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devi { ma_result result; - if (pContext == NULL || callback == NULL) { + if (pContext == nullptr || callback == nullptr) { return MA_INVALID_ARGS; } - if (pContext->callbacks.onContextEnumerateDevices == NULL) { + if (pContext->callbacks.onContextEnumerateDevices == nullptr) { return MA_INVALID_OPERATION; } @@ -43447,7 +43447,7 @@ static ma_bool32 ma_context_get_devices__enum_callback(ma_context* pContext, ma_ if (totalDeviceInfoCount >= pContext->deviceInfoCapacity) { ma_uint32 newCapacity = pContext->deviceInfoCapacity + bufferExpansionCount; ma_device_info* pNewInfos = (ma_device_info*)ma_realloc(pContext->pDeviceInfos, sizeof(*pContext->pDeviceInfos)*newCapacity, &pContext->allocationCallbacks); - if (pNewInfos == NULL) { + if (pNewInfos == nullptr) { return MA_FALSE; /* Out of memory. */ } @@ -43483,16 +43483,16 @@ MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** p ma_result result; /* Safety. */ - if (ppPlaybackDeviceInfos != NULL) *ppPlaybackDeviceInfos = NULL; - if (pPlaybackDeviceCount != NULL) *pPlaybackDeviceCount = 0; - if (ppCaptureDeviceInfos != NULL) *ppCaptureDeviceInfos = NULL; - if (pCaptureDeviceCount != NULL) *pCaptureDeviceCount = 0; + if (ppPlaybackDeviceInfos != nullptr) *ppPlaybackDeviceInfos = nullptr; + if (pPlaybackDeviceCount != nullptr) *pPlaybackDeviceCount = 0; + if (ppCaptureDeviceInfos != nullptr) *ppCaptureDeviceInfos = nullptr; + if (pCaptureDeviceCount != nullptr) *pCaptureDeviceCount = 0; - if (pContext == NULL) { + if (pContext == nullptr) { return MA_INVALID_ARGS; } - if (pContext->callbacks.onContextEnumerateDevices == NULL) { + if (pContext->callbacks.onContextEnumerateDevices == nullptr) { return MA_INVALID_OPERATION; } @@ -43504,26 +43504,26 @@ MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** p pContext->captureDeviceInfoCount = 0; /* Now enumerate over available devices. */ - result = pContext->callbacks.onContextEnumerateDevices(pContext, ma_context_get_devices__enum_callback, NULL); + result = pContext->callbacks.onContextEnumerateDevices(pContext, ma_context_get_devices__enum_callback, nullptr); if (result == MA_SUCCESS) { /* Playback devices. */ - if (ppPlaybackDeviceInfos != NULL) { + if (ppPlaybackDeviceInfos != nullptr) { *ppPlaybackDeviceInfos = pContext->pDeviceInfos; } - if (pPlaybackDeviceCount != NULL) { + if (pPlaybackDeviceCount != nullptr) { *pPlaybackDeviceCount = pContext->playbackDeviceInfoCount; } /* Capture devices. */ - if (ppCaptureDeviceInfos != NULL) { + if (ppCaptureDeviceInfos != nullptr) { *ppCaptureDeviceInfos = pContext->pDeviceInfos; /* Capture devices come after playback devices. */ if (pContext->playbackDeviceInfoCount > 0) { - /* Conditional, because NULL+0 is undefined behavior. */ + /* Conditional, because nullptr+0 is undefined behavior. */ *ppCaptureDeviceInfos += pContext->playbackDeviceInfoCount; } } - if (pCaptureDeviceCount != NULL) { + if (pCaptureDeviceCount != nullptr) { *pCaptureDeviceCount = pContext->captureDeviceInfoCount; } } @@ -43539,18 +43539,18 @@ MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type ma_device_info deviceInfo; /* NOTE: Do not clear pDeviceInfo on entry. The reason is the pDeviceID may actually point to pDeviceInfo->id which will break things. */ - if (pContext == NULL || pDeviceInfo == NULL) { + if (pContext == nullptr || pDeviceInfo == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(&deviceInfo); /* Help the backend out by copying over the device ID if we have one. */ - if (pDeviceID != NULL) { + if (pDeviceID != nullptr) { MA_COPY_MEMORY(&deviceInfo.id, pDeviceID, sizeof(*pDeviceID)); } - if (pContext->callbacks.onContextGetDeviceInfo == NULL) { + if (pContext->callbacks.onContextGetDeviceInfo == nullptr) { return MA_INVALID_OPERATION; } @@ -43566,7 +43566,7 @@ MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type MA_API ma_bool32 ma_context_is_loopback_supported(ma_context* pContext) { - if (pContext == NULL) { + if (pContext == nullptr) { return MA_FALSE; } @@ -43591,22 +43591,22 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC ma_device_descriptor descriptorCapture; /* The context can be null, in which case we self-manage it. */ - if (pContext == NULL) { - return ma_device_init_ex(NULL, 0, NULL, pConfig, pDevice); + if (pContext == nullptr) { + return ma_device_init_ex(nullptr, 0, nullptr, pConfig, pDevice); } - if (pDevice == NULL) { + if (pDevice == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDevice); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } /* Check that we have our callbacks defined. */ - if (pContext->callbacks.onDeviceInit == NULL) { + if (pContext->callbacks.onDeviceInit == nullptr) { return MA_INVALID_OPERATION; } @@ -43639,18 +43639,18 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC pDevice->onNotification = pConfig->notificationCallback; pDevice->onStop = pConfig->stopCallback; - if (pConfig->playback.pDeviceID != NULL) { + if (pConfig->playback.pDeviceID != nullptr) { MA_COPY_MEMORY(&pDevice->playback.id, pConfig->playback.pDeviceID, sizeof(pDevice->playback.id)); pDevice->playback.pID = &pDevice->playback.id; } else { - pDevice->playback.pID = NULL; + pDevice->playback.pID = nullptr; } - if (pConfig->capture.pDeviceID != NULL) { + if (pConfig->capture.pDeviceID != nullptr) { MA_COPY_MEMORY(&pDevice->capture.id, pConfig->capture.pDeviceID, sizeof(pDevice->capture.id)); pDevice->capture.pID = &pDevice->capture.id; } else { - pDevice->capture.pID = NULL; + pDevice->capture.pID = nullptr; } pDevice->noPreSilencedOutputBuffer = pConfig->noPreSilencedOutputBuffer; @@ -43809,7 +43809,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), deviceInfo.name, (size_t)-1); } else { /* We failed to retrieve the device info. Fall back to a default name. */ - if (descriptorCapture.pDeviceID == NULL) { + if (descriptorCapture.pDeviceID == nullptr) { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), "Capture Device", (size_t)-1); @@ -43823,7 +43823,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), deviceInfo.name, (size_t)-1); } else { /* We failed to retrieve the device info. Fall back to a default name. */ - if (descriptorPlayback.pDeviceID == NULL) { + if (descriptorPlayback.pDeviceID == nullptr) { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), "Playback Device", (size_t)-1); @@ -43866,7 +43866,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC intermediaryBufferSizeInBytes = pDevice->capture.intermediaryBufferCap * ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels); pDevice->capture.pIntermediaryBuffer = ma_malloc((size_t)intermediaryBufferSizeInBytes, &pContext->allocationCallbacks); - if (pDevice->capture.pIntermediaryBuffer == NULL) { + if (pDevice->capture.pIntermediaryBuffer == nullptr) { ma_device_uninit(pDevice); return MA_OUT_OF_MEMORY; } @@ -43892,7 +43892,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC intermediaryBufferSizeInBytes = pDevice->playback.intermediaryBufferCap * ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); pDevice->playback.pIntermediaryBuffer = ma_malloc((size_t)intermediaryBufferSizeInBytes, &pContext->allocationCallbacks); - if (pDevice->playback.pIntermediaryBuffer == NULL) { + if (pDevice->playback.pIntermediaryBuffer == nullptr) { ma_device_uninit(pDevice); return MA_OUT_OF_MEMORY; } @@ -43941,7 +43941,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[%s]\n", ma_get_backend_name(pDevice->pContext->backend)); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; - ma_device_get_name(pDevice, ma_device_type_capture, name, sizeof(name), NULL); + ma_device_get_name(pDevice, ma_device_type_capture, name, sizeof(name), nullptr); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " %s (%s)\n", name, "Capture"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Format: %s -> %s\n", ma_get_format_name(pDevice->capture.internalFormat), ma_get_format_name(pDevice->capture.format)); @@ -43965,7 +43965,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; - ma_device_get_name(pDevice, ma_device_type_playback, name, sizeof(name), NULL); + ma_device_get_name(pDevice, ma_device_type_playback, name, sizeof(name), nullptr); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " %s (%s)\n", name, "Playback"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Format: %s -> %s\n", ma_get_format_name(pDevice->playback.format), ma_get_format_name(pDevice->playback.internalFormat)); @@ -44003,11 +44003,11 @@ MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backen ma_uint32 backendsToIterateCount; ma_allocation_callbacks allocationCallbacks; - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - if (pContextConfig != NULL) { + if (pContextConfig != nullptr) { result = ma_allocation_callbacks_init_copy(&allocationCallbacks, &pContextConfig->allocationCallbacks); if (result != MA_SUCCESS) { return result; @@ -44017,7 +44017,7 @@ MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backen } pContext = (ma_context*)ma_malloc(sizeof(*pContext), &allocationCallbacks); - if (pContext == NULL) { + if (pContext == nullptr) { return MA_OUT_OF_MEMORY; } @@ -44027,7 +44027,7 @@ MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backen pBackendsToIterate = (ma_backend*)backends; backendsToIterateCount = backendCount; - if (pBackendsToIterate == NULL) { + if (pBackendsToIterate == nullptr) { pBackendsToIterate = (ma_backend*)defaultBackends; backendsToIterateCount = ma_countof(defaultBackends); } @@ -44037,13 +44037,13 @@ MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backen for (iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) { /* This is a hack for iOS. If the context config is null, there's a good chance the - `ma_device_init(NULL, &deviceConfig, pDevice);` pattern is being used. In this + `ma_device_init(nullptr, &deviceConfig, pDevice);` pattern is being used. In this case, set the session category based on the device type. */ #if defined(MA_APPLE_MOBILE) ma_context_config contextConfig; - if (pContextConfig == NULL) { + if (pContextConfig == nullptr) { contextConfig = ma_context_config_init(); switch (pConfig->deviceType) { case ma_device_type_duplex: { @@ -44115,7 +44115,7 @@ MA_API void ma_device_uninit(ma_device* pDevice) ma_thread_wait(&pDevice->thread); } - if (pDevice->pContext->callbacks.onDeviceUninit != NULL) { + if (pDevice->pContext->callbacks.onDeviceUninit != nullptr) { pDevice->pContext->callbacks.onDeviceUninit(pDevice); } @@ -44138,14 +44138,14 @@ MA_API void ma_device_uninit(ma_device* pDevice) ma_data_converter_uninit(&pDevice->playback.converter, &pDevice->pContext->allocationCallbacks); } - if (pDevice->playback.pInputCache != NULL) { + if (pDevice->playback.pInputCache != nullptr) { ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks); } - if (pDevice->capture.pIntermediaryBuffer != NULL) { + if (pDevice->capture.pIntermediaryBuffer != nullptr) { ma_free(pDevice->capture.pIntermediaryBuffer, &pDevice->pContext->allocationCallbacks); } - if (pDevice->playback.pIntermediaryBuffer != NULL) { + if (pDevice->playback.pIntermediaryBuffer != nullptr) { ma_free(pDevice->playback.pIntermediaryBuffer, &pDevice->pContext->allocationCallbacks); } @@ -44161,8 +44161,8 @@ MA_API void ma_device_uninit(ma_device* pDevice) MA_API ma_context* ma_device_get_context(ma_device* pDevice) { - if (pDevice == NULL) { - return NULL; + if (pDevice == nullptr) { + return nullptr; } return pDevice->pContext; @@ -44175,18 +44175,18 @@ MA_API ma_log* ma_device_get_log(ma_device* pDevice) MA_API ma_result ma_device_get_info(ma_device* pDevice, ma_device_type type, ma_device_info* pDeviceInfo) { - if (pDeviceInfo == NULL) { + if (pDeviceInfo == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDeviceInfo); - if (pDevice == NULL) { + if (pDevice == nullptr) { return MA_INVALID_ARGS; } /* If the onDeviceGetInfo() callback is set, use that. Otherwise we'll fall back to ma_context_get_device_info(). */ - if (pDevice->pContext->callbacks.onDeviceGetInfo != NULL) { + if (pDevice->pContext->callbacks.onDeviceGetInfo != nullptr) { return pDevice->pContext->callbacks.onDeviceGetInfo(pDevice, type, pDeviceInfo); } @@ -44201,7 +44201,7 @@ MA_API ma_result ma_device_get_info(ma_device* pDevice, ma_device_type type, ma_ capture device, where in fact for loopback we want the default *playback* device. We'll do a bit of a hack here to make sure we get the correct info. */ - if (pDevice->type == ma_device_type_loopback && pDevice->capture.pID == NULL) { + if (pDevice->type == ma_device_type_loopback && pDevice->capture.pID == nullptr) { type = ma_device_type_playback; } @@ -44214,11 +44214,11 @@ MA_API ma_result ma_device_get_name(ma_device* pDevice, ma_device_type type, cha ma_result result; ma_device_info deviceInfo; - if (pLengthNotIncludingNullTerminator != NULL) { + if (pLengthNotIncludingNullTerminator != nullptr) { *pLengthNotIncludingNullTerminator = 0; } - if (pName != NULL && nameCap > 0) { + if (pName != nullptr && nameCap > 0) { pName[0] = '\0'; } @@ -44227,7 +44227,7 @@ MA_API ma_result ma_device_get_name(ma_device* pDevice, ma_device_type type, cha return result; } - if (pName != NULL) { + if (pName != nullptr) { ma_strncpy_s(pName, nameCap, deviceInfo.name, (size_t)-1); /* @@ -44235,12 +44235,12 @@ MA_API ma_result ma_device_get_name(ma_device* pDevice, ma_device_type type, cha source. Otherwise the caller might assume the output buffer contains more content than it actually does. */ - if (pLengthNotIncludingNullTerminator != NULL) { + if (pLengthNotIncludingNullTerminator != nullptr) { *pLengthNotIncludingNullTerminator = strlen(pName); } } else { /* Name not specified. Just report the length of the source string. */ - if (pLengthNotIncludingNullTerminator != NULL) { + if (pLengthNotIncludingNullTerminator != nullptr) { *pLengthNotIncludingNullTerminator = strlen(deviceInfo.name); } } @@ -44252,7 +44252,7 @@ MA_API ma_result ma_device_start(ma_device* pDevice) { ma_result result; - if (pDevice == NULL) { + if (pDevice == nullptr) { return MA_INVALID_ARGS; } @@ -44282,7 +44282,7 @@ MA_API ma_result ma_device_start(ma_device* pDevice) /* Asynchronous backends need to be handled differently. */ if (ma_context_is_backend_asynchronous(pDevice->pContext)) { - if (pDevice->pContext->callbacks.onDeviceStart != NULL) { + if (pDevice->pContext->callbacks.onDeviceStart != nullptr) { result = pDevice->pContext->callbacks.onDeviceStart(pDevice); } else { result = MA_INVALID_OPERATION; @@ -44321,7 +44321,7 @@ MA_API ma_result ma_device_stop(ma_device* pDevice) { ma_result result; - if (pDevice == NULL) { + if (pDevice == nullptr) { return MA_INVALID_ARGS; } @@ -44352,7 +44352,7 @@ MA_API ma_result ma_device_stop(ma_device* pDevice) /* Asynchronous backends need to be handled differently. */ if (ma_context_is_backend_asynchronous(pDevice->pContext)) { /* Asynchronous backends must have a stop operation. */ - if (pDevice->pContext->callbacks.onDeviceStop != NULL) { + if (pDevice->pContext->callbacks.onDeviceStop != nullptr) { result = pDevice->pContext->callbacks.onDeviceStop(pDevice); } else { result = MA_INVALID_OPERATION; @@ -44368,7 +44368,7 @@ MA_API ma_result ma_device_stop(ma_device* pDevice) */ MA_ASSERT(ma_device_get_state(pDevice) != ma_device_state_started); - if (pDevice->pContext->callbacks.onDeviceDataLoopWakeup != NULL) { + if (pDevice->pContext->callbacks.onDeviceDataLoopWakeup != nullptr) { pDevice->pContext->callbacks.onDeviceDataLoopWakeup(pDevice); } @@ -44401,7 +44401,7 @@ MA_API ma_bool32 ma_device_is_started(const ma_device* pDevice) MA_API ma_device_state ma_device_get_state(const ma_device* pDevice) { - if (pDevice == NULL) { + if (pDevice == nullptr) { return ma_device_state_uninitialized; } @@ -44410,7 +44410,7 @@ MA_API ma_device_state ma_device_get_state(const ma_device* pDevice) MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume) { - if (pDevice == NULL) { + if (pDevice == nullptr) { return MA_INVALID_ARGS; } @@ -44425,11 +44425,11 @@ MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume) MA_API ma_result ma_device_get_master_volume(ma_device* pDevice, float* pVolume) { - if (pVolume == NULL) { + if (pVolume == nullptr) { return MA_INVALID_ARGS; } - if (pDevice == NULL) { + if (pDevice == nullptr) { *pVolume = 0; return MA_INVALID_ARGS; } @@ -44453,7 +44453,7 @@ MA_API ma_result ma_device_get_master_volume_db(ma_device* pDevice, float* pGain float factor; ma_result result; - if (pGainDB == NULL) { + if (pGainDB == nullptr) { return MA_INVALID_ARGS; } @@ -44471,11 +44471,11 @@ MA_API ma_result ma_device_get_master_volume_db(ma_device* pDevice, float* pGain MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) { - if (pDevice == NULL) { + if (pDevice == nullptr) { return MA_INVALID_ARGS; } - if (pOutput == NULL && pInput == NULL) { + if (pOutput == nullptr && pInput == nullptr) { return MA_INVALID_ARGS; } @@ -44489,16 +44489,16 @@ MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void } if (pDevice->type == ma_device_type_duplex) { - if (pInput != NULL) { + if (pInput != nullptr) { ma_device__handle_duplex_callback_capture(pDevice, frameCount, pInput, &pDevice->duplexRB.rb); } - if (pOutput != NULL) { + if (pOutput != nullptr) { ma_device__handle_duplex_callback_playback(pDevice, frameCount, pOutput, &pDevice->duplexRB.rb); } } else { if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_loopback) { - if (pInput == NULL) { + if (pInput == nullptr) { return MA_INVALID_ARGS; } @@ -44506,7 +44506,7 @@ MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void } if (pDevice->type == ma_device_type_playback) { - if (pOutput == NULL) { + if (pOutput == nullptr) { return MA_INVALID_ARGS; } @@ -44519,7 +44519,7 @@ MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_descriptor(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile) { - if (pDescriptor == NULL) { + if (pDescriptor == nullptr) { return 0; } @@ -44612,8 +44612,8 @@ MA_API void ma_clip_samples_u8(ma_uint8* pDst, const ma_int16* pSrc, ma_uint64 c { ma_uint64 iSample; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_u8(pSrc[iSample]); @@ -44624,8 +44624,8 @@ MA_API void ma_clip_samples_s16(ma_int16* pDst, const ma_int32* pSrc, ma_uint64 { ma_uint64 iSample; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_s16(pSrc[iSample]); @@ -44636,8 +44636,8 @@ MA_API void ma_clip_samples_s24(ma_uint8* pDst, const ma_int64* pSrc, ma_uint64 { ma_uint64 iSample; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); for (iSample = 0; iSample < count; iSample += 1) { ma_int64 s = ma_clip_s24(pSrc[iSample]); @@ -44651,8 +44651,8 @@ MA_API void ma_clip_samples_s32(ma_int32* pDst, const ma_int64* pSrc, ma_uint64 { ma_uint64 iSample; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_s32(pSrc[iSample]); @@ -44663,8 +44663,8 @@ MA_API void ma_clip_samples_f32(float* pDst, const float* pSrc, ma_uint64 count) { ma_uint64 iSample; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_f32(pSrc[iSample]); @@ -44675,8 +44675,8 @@ MA_API void ma_clip_pcm_frames(void* pDst, const void* pSrc, ma_uint64 frameCoun { ma_uint64 sampleCount; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); sampleCount = frameCount * channels; @@ -44699,7 +44699,7 @@ MA_API void ma_copy_and_apply_volume_factor_u8(ma_uint8* pSamplesOut, const ma_u { ma_uint64 iSample; - if (pSamplesOut == NULL || pSamplesIn == NULL) { + if (pSamplesOut == nullptr || pSamplesIn == nullptr) { return; } @@ -44712,7 +44712,7 @@ MA_API void ma_copy_and_apply_volume_factor_s16(ma_int16* pSamplesOut, const ma_ { ma_uint64 iSample; - if (pSamplesOut == NULL || pSamplesIn == NULL) { + if (pSamplesOut == nullptr || pSamplesIn == nullptr) { return; } @@ -44727,7 +44727,7 @@ MA_API void ma_copy_and_apply_volume_factor_s24(void* pSamplesOut, const void* p ma_uint8* pSamplesOut8; ma_uint8* pSamplesIn8; - if (pSamplesOut == NULL || pSamplesIn == NULL) { + if (pSamplesOut == nullptr || pSamplesIn == nullptr) { return; } @@ -44750,7 +44750,7 @@ MA_API void ma_copy_and_apply_volume_factor_s32(ma_int32* pSamplesOut, const ma_ { ma_uint64 iSample; - if (pSamplesOut == NULL || pSamplesIn == NULL) { + if (pSamplesOut == nullptr || pSamplesIn == nullptr) { return; } @@ -44763,7 +44763,7 @@ MA_API void ma_copy_and_apply_volume_factor_f32(float* pSamplesOut, const float* { ma_uint64 iSample; - if (pSamplesOut == NULL || pSamplesIn == NULL) { + if (pSamplesOut == nullptr || pSamplesIn == nullptr) { return; } @@ -44926,8 +44926,8 @@ MA_API void ma_copy_and_apply_volume_and_clip_samples_u8(ma_uint8* pDst, const m ma_uint64 iSample; ma_int16 volumeFixed; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); volumeFixed = ma_float_to_fixed_16(volume); @@ -44941,8 +44941,8 @@ MA_API void ma_copy_and_apply_volume_and_clip_samples_s16(ma_int16* pDst, const ma_uint64 iSample; ma_int16 volumeFixed; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); volumeFixed = ma_float_to_fixed_16(volume); @@ -44956,8 +44956,8 @@ MA_API void ma_copy_and_apply_volume_and_clip_samples_s24(ma_uint8* pDst, const ma_uint64 iSample; ma_int16 volumeFixed; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); volumeFixed = ma_float_to_fixed_16(volume); @@ -44974,8 +44974,8 @@ MA_API void ma_copy_and_apply_volume_and_clip_samples_s32(ma_int32* pDst, const ma_uint64 iSample; ma_int16 volumeFixed; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); volumeFixed = ma_float_to_fixed_16(volume); @@ -44988,8 +44988,8 @@ MA_API void ma_copy_and_apply_volume_and_clip_samples_f32(float* pDst, const flo { ma_uint64 iSample; - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); /* For the f32 case we need to make sure this supports in-place processing where the input and output buffers are the same. */ @@ -45000,8 +45000,8 @@ MA_API void ma_copy_and_apply_volume_and_clip_samples_f32(float* pDst, const flo MA_API void ma_copy_and_apply_volume_and_clip_pcm_frames(void* pDst, const void* pSrc, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float volume) { - MA_ASSERT(pDst != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(pDst != nullptr); + MA_ASSERT(pSrc != nullptr); if (volume == 1) { ma_clip_pcm_frames(pDst, pSrc, frameCount, format, channels); /* Optimized case for volume = 1. */ @@ -45043,7 +45043,7 @@ MA_API ma_result ma_mix_pcm_frames_f32(float* pDst, const float* pSrc, ma_uint64 ma_uint64 iSample; ma_uint64 sampleCount; - if (pDst == NULL || pSrc == NULL || channels == 0) { + if (pDst == nullptr || pSrc == nullptr || channels == 0) { return MA_INVALID_ARGS; } @@ -47035,7 +47035,7 @@ MA_API void ma_convert_pcm_frames_format(void* pOut, ma_format formatOut, const MA_API void ma_deinterleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void* pInterleavedPCMFrames, void** ppDeinterleavedPCMFrames) { - if (pInterleavedPCMFrames == NULL || ppDeinterleavedPCMFrames == NULL) { + if (pInterleavedPCMFrames == nullptr || ppDeinterleavedPCMFrames == nullptr) { return; /* Invalid args. */ } @@ -47171,11 +47171,11 @@ typedef struct static ma_result ma_biquad_get_heap_layout(const ma_biquad_config* pConfig, ma_biquad_heap_layout* pHeapLayout) { - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -47204,7 +47204,7 @@ MA_API ma_result ma_biquad_get_heap_size(const ma_biquad_config* pConfig, size_t ma_result result; ma_biquad_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -47225,7 +47225,7 @@ MA_API ma_result ma_biquad_init_preallocated(const ma_biquad_config* pConfig, vo ma_result result; ma_biquad_heap_layout heapLayout; - if (pBQ == NULL) { + if (pBQ == nullptr) { return MA_INVALID_ARGS; } @@ -47258,11 +47258,11 @@ MA_API ma_result ma_biquad_init(const ma_biquad_config* pConfig, const ma_alloca if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_biquad_init_preallocated(pConfig, pHeap, pBQ); @@ -47277,7 +47277,7 @@ MA_API ma_result ma_biquad_init(const ma_biquad_config* pConfig, const ma_alloca MA_API void ma_biquad_uninit(ma_biquad* pBQ, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pBQ == NULL) { + if (pBQ == nullptr) { return; } @@ -47288,7 +47288,7 @@ MA_API void ma_biquad_uninit(ma_biquad* pBQ, const ma_allocation_callbacks* pAll MA_API ma_result ma_biquad_reinit(const ma_biquad_config* pConfig, ma_biquad* pBQ) { - if (pBQ == NULL || pConfig == NULL) { + if (pBQ == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -47335,7 +47335,7 @@ MA_API ma_result ma_biquad_reinit(const ma_biquad_config* pConfig, ma_biquad* pB MA_API ma_result ma_biquad_clear_cache(ma_biquad* pBQ) { - if (pBQ == NULL) { + if (pBQ == nullptr) { return MA_INVALID_ARGS; } @@ -47418,7 +47418,7 @@ MA_API ma_result ma_biquad_process_pcm_frames(ma_biquad* pBQ, void* pFramesOut, { ma_uint32 n; - if (pBQ == NULL || pFramesOut == NULL || pFramesIn == NULL) { + if (pBQ == nullptr || pFramesOut == nullptr || pFramesIn == nullptr) { return MA_INVALID_ARGS; } @@ -47452,7 +47452,7 @@ MA_API ma_result ma_biquad_process_pcm_frames(ma_biquad* pBQ, void* pFramesOut, MA_API ma_uint32 ma_biquad_get_latency(const ma_biquad* pBQ) { - if (pBQ == NULL) { + if (pBQ == nullptr) { return 0; } @@ -47507,11 +47507,11 @@ typedef struct static ma_result ma_lpf1_get_heap_layout(const ma_lpf1_config* pConfig, ma_lpf1_heap_layout* pHeapLayout) { - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -47536,7 +47536,7 @@ MA_API ma_result ma_lpf1_get_heap_size(const ma_lpf1_config* pConfig, size_t* pH ma_result result; ma_lpf1_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -47555,7 +47555,7 @@ MA_API ma_result ma_lpf1_init_preallocated(const ma_lpf1_config* pConfig, void* ma_result result; ma_lpf1_heap_layout heapLayout; - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -47587,11 +47587,11 @@ MA_API ma_result ma_lpf1_init(const ma_lpf1_config* pConfig, const ma_allocation if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_lpf1_init_preallocated(pConfig, pHeap, pLPF); @@ -47606,7 +47606,7 @@ MA_API ma_result ma_lpf1_init(const ma_lpf1_config* pConfig, const ma_allocation MA_API void ma_lpf1_uninit(ma_lpf1* pLPF, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return; } @@ -47619,7 +47619,7 @@ MA_API ma_result ma_lpf1_reinit(const ma_lpf1_config* pConfig, ma_lpf1* pLPF) { double a; - if (pLPF == NULL || pConfig == NULL) { + if (pLPF == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -47653,7 +47653,7 @@ MA_API ma_result ma_lpf1_reinit(const ma_lpf1_config* pConfig, ma_lpf1* pLPF) MA_API ma_result ma_lpf1_clear_cache(ma_lpf1* pLPF) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -47710,7 +47710,7 @@ MA_API ma_result ma_lpf1_process_pcm_frames(ma_lpf1* pLPF, void* pFramesOut, con { ma_uint32 n; - if (pLPF == NULL || pFramesOut == NULL || pFramesIn == NULL) { + if (pLPF == nullptr || pFramesOut == nullptr || pFramesIn == nullptr) { return MA_INVALID_ARGS; } @@ -47744,7 +47744,7 @@ MA_API ma_result ma_lpf1_process_pcm_frames(ma_lpf1* pLPF, void* pFramesOut, con MA_API ma_uint32 ma_lpf1_get_latency(const ma_lpf1* pLPF) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return 0; } @@ -47761,7 +47761,7 @@ static MA_INLINE ma_biquad_config ma_lpf2__get_biquad_config(const ma_lpf2_confi double c; double a; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); q = pConfig->q; w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate; @@ -47795,13 +47795,13 @@ MA_API ma_result ma_lpf2_init_preallocated(const ma_lpf2_config* pConfig, void* ma_result result; ma_biquad_config bqConfig; - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pLPF); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -47827,11 +47827,11 @@ MA_API ma_result ma_lpf2_init(const ma_lpf2_config* pConfig, const ma_allocation if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_lpf2_init_preallocated(pConfig, pHeap, pLPF); @@ -47846,7 +47846,7 @@ MA_API ma_result ma_lpf2_init(const ma_lpf2_config* pConfig, const ma_allocation MA_API void ma_lpf2_uninit(ma_lpf2* pLPF, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return; } @@ -47858,7 +47858,7 @@ MA_API ma_result ma_lpf2_reinit(const ma_lpf2_config* pConfig, ma_lpf2* pLPF) ma_result result; ma_biquad_config bqConfig; - if (pLPF == NULL || pConfig == NULL) { + if (pLPF == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -47873,7 +47873,7 @@ MA_API ma_result ma_lpf2_reinit(const ma_lpf2_config* pConfig, ma_lpf2* pLPF) MA_API ma_result ma_lpf2_clear_cache(ma_lpf2* pLPF) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -47894,7 +47894,7 @@ static MA_INLINE void ma_lpf2_process_pcm_frame_f32(ma_lpf2* pLPF, float* pFrame MA_API ma_result ma_lpf2_process_pcm_frames(ma_lpf2* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -47903,7 +47903,7 @@ MA_API ma_result ma_lpf2_process_pcm_frames(ma_lpf2* pLPF, void* pFramesOut, con MA_API ma_uint32 ma_lpf2_get_latency(const ma_lpf2* pLPF) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return 0; } @@ -47935,8 +47935,8 @@ typedef struct static void ma_lpf_calculate_sub_lpf_counts(ma_uint32 order, ma_uint32* pLPF1Count, ma_uint32* pLPF2Count) { - MA_ASSERT(pLPF1Count != NULL); - MA_ASSERT(pLPF2Count != NULL); + MA_ASSERT(pLPF1Count != nullptr); + MA_ASSERT(pLPF2Count != nullptr); *pLPF1Count = order % 2; *pLPF2Count = order / 2; @@ -47950,11 +47950,11 @@ static ma_result ma_lpf_get_heap_layout(const ma_lpf_config* pConfig, ma_lpf_hea ma_uint32 ilpf1; ma_uint32 ilpf2; - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -48013,7 +48013,7 @@ static ma_result ma_lpf_reinit__internal(const ma_lpf_config* pConfig, void* pHe ma_uint32 ilpf2; ma_lpf_heap_layout heapLayout; /* Only used if isNew is true. */ - if (pLPF == NULL || pConfig == NULL) { + if (pLPF == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -48078,7 +48078,7 @@ static ma_result ma_lpf_reinit__internal(const ma_lpf_config* pConfig, void* pHe ma_uint32 jlpf1; for (jlpf1 = 0; jlpf1 < ilpf1; jlpf1 += 1) { - ma_lpf1_uninit(&pLPF->pLPF1[jlpf1], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ + ma_lpf1_uninit(&pLPF->pLPF1[jlpf1], nullptr); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } return result; @@ -48116,11 +48116,11 @@ static ma_result ma_lpf_reinit__internal(const ma_lpf_config* pConfig, void* pHe ma_uint32 jlpf2; for (jlpf1 = 0; jlpf1 < lpf1Count; jlpf1 += 1) { - ma_lpf1_uninit(&pLPF->pLPF1[jlpf1], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ + ma_lpf1_uninit(&pLPF->pLPF1[jlpf1], nullptr); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } for (jlpf2 = 0; jlpf2 < ilpf2; jlpf2 += 1) { - ma_lpf2_uninit(&pLPF->pLPF2[jlpf2], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ + ma_lpf2_uninit(&pLPF->pLPF2[jlpf2], nullptr); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } return result; @@ -48141,7 +48141,7 @@ MA_API ma_result ma_lpf_get_heap_size(const ma_lpf_config* pConfig, size_t* pHea ma_result result; ma_lpf_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -48159,7 +48159,7 @@ MA_API ma_result ma_lpf_get_heap_size(const ma_lpf_config* pConfig, size_t* pHea MA_API ma_result ma_lpf_init_preallocated(const ma_lpf_config* pConfig, void* pHeap, ma_lpf* pLPF) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -48181,11 +48181,11 @@ MA_API ma_result ma_lpf_init(const ma_lpf_config* pConfig, const ma_allocation_c if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_lpf_init_preallocated(pConfig, pHeap, pLPF); @@ -48203,7 +48203,7 @@ MA_API void ma_lpf_uninit(ma_lpf* pLPF, const ma_allocation_callbacks* pAllocati ma_uint32 ilpf1; ma_uint32 ilpf2; - if (pLPF == NULL) { + if (pLPF == nullptr) { return; } @@ -48222,7 +48222,7 @@ MA_API void ma_lpf_uninit(ma_lpf* pLPF, const ma_allocation_callbacks* pAllocati MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF) { - return ma_lpf_reinit__internal(pConfig, NULL, pLPF, /*isNew*/MA_FALSE); + return ma_lpf_reinit__internal(pConfig, nullptr, pLPF, /*isNew*/MA_FALSE); } MA_API ma_result ma_lpf_clear_cache(ma_lpf* pLPF) @@ -48230,7 +48230,7 @@ MA_API ma_result ma_lpf_clear_cache(ma_lpf* pLPF) ma_uint32 ilpf1; ma_uint32 ilpf2; - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -48287,7 +48287,7 @@ MA_API ma_result ma_lpf_process_pcm_frames(ma_lpf* pLPF, void* pFramesOut, const ma_uint32 ilpf1; ma_uint32 ilpf2; - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -48341,7 +48341,7 @@ MA_API ma_result ma_lpf_process_pcm_frames(ma_lpf* pLPF, void* pFramesOut, const MA_API ma_uint32 ma_lpf_get_latency(const ma_lpf* pLPF) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return 0; } @@ -48395,11 +48395,11 @@ typedef struct static ma_result ma_hpf1_get_heap_layout(const ma_hpf1_config* pConfig, ma_hpf1_heap_layout* pHeapLayout) { - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -48424,7 +48424,7 @@ MA_API ma_result ma_hpf1_get_heap_size(const ma_hpf1_config* pConfig, size_t* pH ma_result result; ma_hpf1_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -48443,7 +48443,7 @@ MA_API ma_result ma_hpf1_init_preallocated(const ma_hpf1_config* pConfig, void* ma_result result; ma_hpf1_heap_layout heapLayout; - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -48475,11 +48475,11 @@ MA_API ma_result ma_hpf1_init(const ma_hpf1_config* pConfig, const ma_allocation if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_hpf1_init_preallocated(pConfig, pHeap, pLPF); @@ -48494,7 +48494,7 @@ MA_API ma_result ma_hpf1_init(const ma_hpf1_config* pConfig, const ma_allocation MA_API void ma_hpf1_uninit(ma_hpf1* pHPF, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pHPF == NULL) { + if (pHPF == nullptr) { return; } @@ -48507,7 +48507,7 @@ MA_API ma_result ma_hpf1_reinit(const ma_hpf1_config* pConfig, ma_hpf1* pHPF) { double a; - if (pHPF == NULL || pConfig == NULL) { + if (pHPF == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -48583,7 +48583,7 @@ MA_API ma_result ma_hpf1_process_pcm_frames(ma_hpf1* pHPF, void* pFramesOut, con { ma_uint32 n; - if (pHPF == NULL || pFramesOut == NULL || pFramesIn == NULL) { + if (pHPF == nullptr || pFramesOut == nullptr || pFramesIn == nullptr) { return MA_INVALID_ARGS; } @@ -48617,7 +48617,7 @@ MA_API ma_result ma_hpf1_process_pcm_frames(ma_hpf1* pHPF, void* pFramesOut, con MA_API ma_uint32 ma_hpf1_get_latency(const ma_hpf1* pHPF) { - if (pHPF == NULL) { + if (pHPF == nullptr) { return 0; } @@ -48634,7 +48634,7 @@ static MA_INLINE ma_biquad_config ma_hpf2__get_biquad_config(const ma_hpf2_confi double c; double a; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); q = pConfig->q; w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate; @@ -48668,13 +48668,13 @@ MA_API ma_result ma_hpf2_init_preallocated(const ma_hpf2_config* pConfig, void* ma_result result; ma_biquad_config bqConfig; - if (pHPF == NULL) { + if (pHPF == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pHPF); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -48700,11 +48700,11 @@ MA_API ma_result ma_hpf2_init(const ma_hpf2_config* pConfig, const ma_allocation if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_hpf2_init_preallocated(pConfig, pHeap, pHPF); @@ -48719,7 +48719,7 @@ MA_API ma_result ma_hpf2_init(const ma_hpf2_config* pConfig, const ma_allocation MA_API void ma_hpf2_uninit(ma_hpf2* pHPF, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pHPF == NULL) { + if (pHPF == nullptr) { return; } @@ -48731,7 +48731,7 @@ MA_API ma_result ma_hpf2_reinit(const ma_hpf2_config* pConfig, ma_hpf2* pHPF) ma_result result; ma_biquad_config bqConfig; - if (pHPF == NULL || pConfig == NULL) { + if (pHPF == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -48756,7 +48756,7 @@ static MA_INLINE void ma_hpf2_process_pcm_frame_f32(ma_hpf2* pHPF, float* pFrame MA_API ma_result ma_hpf2_process_pcm_frames(ma_hpf2* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pHPF == NULL) { + if (pHPF == nullptr) { return MA_INVALID_ARGS; } @@ -48765,7 +48765,7 @@ MA_API ma_result ma_hpf2_process_pcm_frames(ma_hpf2* pHPF, void* pFramesOut, con MA_API ma_uint32 ma_hpf2_get_latency(const ma_hpf2* pHPF) { - if (pHPF == NULL) { + if (pHPF == nullptr) { return 0; } @@ -48797,8 +48797,8 @@ typedef struct static void ma_hpf_calculate_sub_hpf_counts(ma_uint32 order, ma_uint32* pHPF1Count, ma_uint32* pHPF2Count) { - MA_ASSERT(pHPF1Count != NULL); - MA_ASSERT(pHPF2Count != NULL); + MA_ASSERT(pHPF1Count != nullptr); + MA_ASSERT(pHPF2Count != nullptr); *pHPF1Count = order % 2; *pHPF2Count = order / 2; @@ -48812,11 +48812,11 @@ static ma_result ma_hpf_get_heap_layout(const ma_hpf_config* pConfig, ma_hpf_hea ma_uint32 ihpf1; ma_uint32 ihpf2; - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -48875,7 +48875,7 @@ static ma_result ma_hpf_reinit__internal(const ma_hpf_config* pConfig, void* pHe ma_uint32 ihpf2; ma_hpf_heap_layout heapLayout; /* Only used if isNew is true. */ - if (pHPF == NULL || pConfig == NULL) { + if (pHPF == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -48940,7 +48940,7 @@ static ma_result ma_hpf_reinit__internal(const ma_hpf_config* pConfig, void* pHe ma_uint32 jhpf1; for (jhpf1 = 0; jhpf1 < ihpf1; jhpf1 += 1) { - ma_hpf1_uninit(&pHPF->pHPF1[jhpf1], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ + ma_hpf1_uninit(&pHPF->pHPF1[jhpf1], nullptr); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } return result; @@ -48978,11 +48978,11 @@ static ma_result ma_hpf_reinit__internal(const ma_hpf_config* pConfig, void* pHe ma_uint32 jhpf2; for (jhpf1 = 0; jhpf1 < hpf1Count; jhpf1 += 1) { - ma_hpf1_uninit(&pHPF->pHPF1[jhpf1], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ + ma_hpf1_uninit(&pHPF->pHPF1[jhpf1], nullptr); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } for (jhpf2 = 0; jhpf2 < ihpf2; jhpf2 += 1) { - ma_hpf2_uninit(&pHPF->pHPF2[jhpf2], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ + ma_hpf2_uninit(&pHPF->pHPF2[jhpf2], nullptr); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } return result; @@ -49003,7 +49003,7 @@ MA_API ma_result ma_hpf_get_heap_size(const ma_hpf_config* pConfig, size_t* pHea ma_result result; ma_hpf_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -49021,7 +49021,7 @@ MA_API ma_result ma_hpf_get_heap_size(const ma_hpf_config* pConfig, size_t* pHea MA_API ma_result ma_hpf_init_preallocated(const ma_hpf_config* pConfig, void* pHeap, ma_hpf* pLPF) { - if (pLPF == NULL) { + if (pLPF == nullptr) { return MA_INVALID_ARGS; } @@ -49043,11 +49043,11 @@ MA_API ma_result ma_hpf_init(const ma_hpf_config* pConfig, const ma_allocation_c if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_hpf_init_preallocated(pConfig, pHeap, pHPF); @@ -49065,7 +49065,7 @@ MA_API void ma_hpf_uninit(ma_hpf* pHPF, const ma_allocation_callbacks* pAllocati ma_uint32 ihpf1; ma_uint32 ihpf2; - if (pHPF == NULL) { + if (pHPF == nullptr) { return; } @@ -49084,7 +49084,7 @@ MA_API void ma_hpf_uninit(ma_hpf* pHPF, const ma_allocation_callbacks* pAllocati MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF) { - return ma_hpf_reinit__internal(pConfig, NULL, pHPF, /*isNew*/MA_FALSE); + return ma_hpf_reinit__internal(pConfig, nullptr, pHPF, /*isNew*/MA_FALSE); } MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) @@ -49093,7 +49093,7 @@ MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const ma_uint32 ihpf1; ma_uint32 ihpf2; - if (pHPF == NULL) { + if (pHPF == nullptr) { return MA_INVALID_ARGS; } @@ -49165,7 +49165,7 @@ MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const MA_API ma_uint32 ma_hpf_get_latency(const ma_hpf* pHPF) { - if (pHPF == NULL) { + if (pHPF == nullptr) { return 0; } @@ -49207,7 +49207,7 @@ static MA_INLINE ma_biquad_config ma_bpf2__get_biquad_config(const ma_bpf2_confi double c; double a; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); q = pConfig->q; w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate; @@ -49241,13 +49241,13 @@ MA_API ma_result ma_bpf2_init_preallocated(const ma_bpf2_config* pConfig, void* ma_result result; ma_biquad_config bqConfig; - if (pBPF == NULL) { + if (pBPF == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pBPF); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -49273,11 +49273,11 @@ MA_API ma_result ma_bpf2_init(const ma_bpf2_config* pConfig, const ma_allocation if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_bpf2_init_preallocated(pConfig, pHeap, pBPF); @@ -49292,7 +49292,7 @@ MA_API ma_result ma_bpf2_init(const ma_bpf2_config* pConfig, const ma_allocation MA_API void ma_bpf2_uninit(ma_bpf2* pBPF, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pBPF == NULL) { + if (pBPF == nullptr) { return; } @@ -49304,7 +49304,7 @@ MA_API ma_result ma_bpf2_reinit(const ma_bpf2_config* pConfig, ma_bpf2* pBPF) ma_result result; ma_biquad_config bqConfig; - if (pBPF == NULL || pConfig == NULL) { + if (pBPF == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -49329,7 +49329,7 @@ static MA_INLINE void ma_bpf2_process_pcm_frame_f32(ma_bpf2* pBPF, float* pFrame MA_API ma_result ma_bpf2_process_pcm_frames(ma_bpf2* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pBPF == NULL) { + if (pBPF == nullptr) { return MA_INVALID_ARGS; } @@ -49338,7 +49338,7 @@ MA_API ma_result ma_bpf2_process_pcm_frames(ma_bpf2* pBPF, void* pFramesOut, con MA_API ma_uint32 ma_bpf2_get_latency(const ma_bpf2* pBPF) { - if (pBPF == NULL) { + if (pBPF == nullptr) { return 0; } @@ -49373,11 +49373,11 @@ static ma_result ma_bpf_get_heap_layout(const ma_bpf_config* pConfig, ma_bpf_hea ma_uint32 bpf2Count; ma_uint32 ibpf2; - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -49421,7 +49421,7 @@ static ma_result ma_bpf_reinit__internal(const ma_bpf_config* pConfig, void* pHe ma_uint32 ibpf2; ma_bpf_heap_layout heapLayout; /* Only used if isNew is true. */ - if (pBPF == NULL || pConfig == NULL) { + if (pBPF == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -49510,7 +49510,7 @@ MA_API ma_result ma_bpf_get_heap_size(const ma_bpf_config* pConfig, size_t* pHea ma_result result; ma_bpf_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -49528,7 +49528,7 @@ MA_API ma_result ma_bpf_get_heap_size(const ma_bpf_config* pConfig, size_t* pHea MA_API ma_result ma_bpf_init_preallocated(const ma_bpf_config* pConfig, void* pHeap, ma_bpf* pBPF) { - if (pBPF == NULL) { + if (pBPF == nullptr) { return MA_INVALID_ARGS; } @@ -49550,11 +49550,11 @@ MA_API ma_result ma_bpf_init(const ma_bpf_config* pConfig, const ma_allocation_c if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_bpf_init_preallocated(pConfig, pHeap, pBPF); @@ -49571,7 +49571,7 @@ MA_API void ma_bpf_uninit(ma_bpf* pBPF, const ma_allocation_callbacks* pAllocati { ma_uint32 ibpf2; - if (pBPF == NULL) { + if (pBPF == nullptr) { return; } @@ -49586,7 +49586,7 @@ MA_API void ma_bpf_uninit(ma_bpf* pBPF, const ma_allocation_callbacks* pAllocati MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF) { - return ma_bpf_reinit__internal(pConfig, NULL, pBPF, /*isNew*/MA_FALSE); + return ma_bpf_reinit__internal(pConfig, nullptr, pBPF, /*isNew*/MA_FALSE); } MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) @@ -49594,7 +49594,7 @@ MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const ma_result result; ma_uint32 ibpf2; - if (pBPF == NULL) { + if (pBPF == nullptr) { return MA_INVALID_ARGS; } @@ -49651,7 +49651,7 @@ MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const MA_API ma_uint32 ma_bpf_get_latency(const ma_bpf* pBPF) { - if (pBPF == NULL) { + if (pBPF == nullptr) { return 0; } @@ -49692,7 +49692,7 @@ static MA_INLINE ma_biquad_config ma_notch2__get_biquad_config(const ma_notch2_c double c; double a; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); q = pConfig->q; w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate; @@ -49726,13 +49726,13 @@ MA_API ma_result ma_notch2_init_preallocated(const ma_notch2_config* pConfig, vo ma_result result; ma_biquad_config bqConfig; - if (pFilter == NULL) { + if (pFilter == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFilter); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -49758,11 +49758,11 @@ MA_API ma_result ma_notch2_init(const ma_notch2_config* pConfig, const ma_alloca if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_notch2_init_preallocated(pConfig, pHeap, pFilter); @@ -49777,7 +49777,7 @@ MA_API ma_result ma_notch2_init(const ma_notch2_config* pConfig, const ma_alloca MA_API void ma_notch2_uninit(ma_notch2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return; } @@ -49789,7 +49789,7 @@ MA_API ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pF ma_result result; ma_biquad_config bqConfig; - if (pFilter == NULL || pConfig == NULL) { + if (pFilter == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -49814,7 +49814,7 @@ static MA_INLINE void ma_notch2_process_pcm_frame_f32(ma_notch2* pFilter, float* MA_API ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return MA_INVALID_ARGS; } @@ -49823,7 +49823,7 @@ MA_API ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesO MA_API ma_uint32 ma_notch2_get_latency(const ma_notch2* pFilter) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return 0; } @@ -49867,7 +49867,7 @@ static MA_INLINE ma_biquad_config ma_peak2__get_biquad_config(const ma_peak2_con double a; double A; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); q = pConfig->q; w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate; @@ -49902,13 +49902,13 @@ MA_API ma_result ma_peak2_init_preallocated(const ma_peak2_config* pConfig, void ma_result result; ma_biquad_config bqConfig; - if (pFilter == NULL) { + if (pFilter == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFilter); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -49934,11 +49934,11 @@ MA_API ma_result ma_peak2_init(const ma_peak2_config* pConfig, const ma_allocati if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_peak2_init_preallocated(pConfig, pHeap, pFilter); @@ -49953,7 +49953,7 @@ MA_API ma_result ma_peak2_init(const ma_peak2_config* pConfig, const ma_allocati MA_API void ma_peak2_uninit(ma_peak2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return; } @@ -49965,7 +49965,7 @@ MA_API ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilt ma_result result; ma_biquad_config bqConfig; - if (pFilter == NULL || pConfig == NULL) { + if (pFilter == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -49990,7 +49990,7 @@ static MA_INLINE void ma_peak2_process_pcm_frame_f32(ma_peak2* pFilter, float* p MA_API ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return MA_INVALID_ARGS; } @@ -49999,7 +49999,7 @@ MA_API ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut MA_API ma_uint32 ma_peak2_get_latency(const ma_peak2* pFilter) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return 0; } @@ -50039,7 +50039,7 @@ static MA_INLINE ma_biquad_config ma_loshelf2__get_biquad_config(const ma_loshel double a; double sqrtA; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate; s = ma_sind(w); @@ -50075,13 +50075,13 @@ MA_API ma_result ma_loshelf2_init_preallocated(const ma_loshelf2_config* pConfig ma_result result; ma_biquad_config bqConfig; - if (pFilter == NULL) { + if (pFilter == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFilter); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -50107,11 +50107,11 @@ MA_API ma_result ma_loshelf2_init(const ma_loshelf2_config* pConfig, const ma_al if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_loshelf2_init_preallocated(pConfig, pHeap, pFilter); @@ -50126,7 +50126,7 @@ MA_API ma_result ma_loshelf2_init(const ma_loshelf2_config* pConfig, const ma_al MA_API void ma_loshelf2_uninit(ma_loshelf2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return; } @@ -50138,7 +50138,7 @@ MA_API ma_result ma_loshelf2_reinit(const ma_loshelf2_config* pConfig, ma_loshel ma_result result; ma_biquad_config bqConfig; - if (pFilter == NULL || pConfig == NULL) { + if (pFilter == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -50163,7 +50163,7 @@ static MA_INLINE void ma_loshelf2_process_pcm_frame_f32(ma_loshelf2* pFilter, fl MA_API ma_result ma_loshelf2_process_pcm_frames(ma_loshelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return MA_INVALID_ARGS; } @@ -50172,7 +50172,7 @@ MA_API ma_result ma_loshelf2_process_pcm_frames(ma_loshelf2* pFilter, void* pFra MA_API ma_uint32 ma_loshelf2_get_latency(const ma_loshelf2* pFilter) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return 0; } @@ -50212,7 +50212,7 @@ static MA_INLINE ma_biquad_config ma_hishelf2__get_biquad_config(const ma_hishel double a; double sqrtA; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate; s = ma_sind(w); @@ -50248,13 +50248,13 @@ MA_API ma_result ma_hishelf2_init_preallocated(const ma_hishelf2_config* pConfig ma_result result; ma_biquad_config bqConfig; - if (pFilter == NULL) { + if (pFilter == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFilter); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -50280,11 +50280,11 @@ MA_API ma_result ma_hishelf2_init(const ma_hishelf2_config* pConfig, const ma_al if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_hishelf2_init_preallocated(pConfig, pHeap, pFilter); @@ -50299,7 +50299,7 @@ MA_API ma_result ma_hishelf2_init(const ma_hishelf2_config* pConfig, const ma_al MA_API void ma_hishelf2_uninit(ma_hishelf2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return; } @@ -50311,7 +50311,7 @@ MA_API ma_result ma_hishelf2_reinit(const ma_hishelf2_config* pConfig, ma_hishel ma_result result; ma_biquad_config bqConfig; - if (pFilter == NULL || pConfig == NULL) { + if (pFilter == nullptr || pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -50336,7 +50336,7 @@ static MA_INLINE void ma_hishelf2_process_pcm_frame_f32(ma_hishelf2* pFilter, fl MA_API ma_result ma_hishelf2_process_pcm_frames(ma_hishelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return MA_INVALID_ARGS; } @@ -50345,7 +50345,7 @@ MA_API ma_result ma_hishelf2_process_pcm_frames(ma_hishelf2* pFilter, void* pFra MA_API ma_uint32 ma_hishelf2_get_latency(const ma_hishelf2* pFilter) { - if (pFilter == NULL) { + if (pFilter == nullptr) { return 0; } @@ -50376,13 +50376,13 @@ MA_API ma_delay_config ma_delay_config_init(ma_uint32 channels, ma_uint32 sample MA_API ma_result ma_delay_init(const ma_delay_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_delay* pDelay) { - if (pDelay == NULL) { + if (pDelay == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDelay); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -50395,7 +50395,7 @@ MA_API ma_result ma_delay_init(const ma_delay_config* pConfig, const ma_allocati pDelay->cursor = 0; pDelay->pBuffer = (float*)ma_malloc((size_t)(pDelay->bufferSizeInFrames * ma_get_bytes_per_frame(ma_format_f32, pConfig->channels)), pAllocationCallbacks); - if (pDelay->pBuffer == NULL) { + if (pDelay->pBuffer == nullptr) { return MA_OUT_OF_MEMORY; } @@ -50406,7 +50406,7 @@ MA_API ma_result ma_delay_init(const ma_delay_config* pConfig, const ma_allocati MA_API void ma_delay_uninit(ma_delay* pDelay, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pDelay == NULL) { + if (pDelay == nullptr) { return; } @@ -50420,7 +50420,7 @@ MA_API ma_result ma_delay_process_pcm_frames(ma_delay* pDelay, void* pFramesOut, float* pFramesOutF32 = (float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; - if (pDelay == NULL || pFramesOut == NULL || pFramesIn == NULL) { + if (pDelay == nullptr || pFramesOut == nullptr || pFramesIn == nullptr) { return MA_INVALID_ARGS; } @@ -50458,7 +50458,7 @@ MA_API ma_result ma_delay_process_pcm_frames(ma_delay* pDelay, void* pFramesOut, MA_API void ma_delay_set_wet(ma_delay* pDelay, float value) { - if (pDelay == NULL) { + if (pDelay == nullptr) { return; } @@ -50467,7 +50467,7 @@ MA_API void ma_delay_set_wet(ma_delay* pDelay, float value) MA_API float ma_delay_get_wet(const ma_delay* pDelay) { - if (pDelay == NULL) { + if (pDelay == nullptr) { return 0; } @@ -50476,7 +50476,7 @@ MA_API float ma_delay_get_wet(const ma_delay* pDelay) MA_API void ma_delay_set_dry(ma_delay* pDelay, float value) { - if (pDelay == NULL) { + if (pDelay == nullptr) { return; } @@ -50485,7 +50485,7 @@ MA_API void ma_delay_set_dry(ma_delay* pDelay, float value) MA_API float ma_delay_get_dry(const ma_delay* pDelay) { - if (pDelay == NULL) { + if (pDelay == nullptr) { return 0; } @@ -50494,7 +50494,7 @@ MA_API float ma_delay_get_dry(const ma_delay* pDelay) MA_API void ma_delay_set_decay(ma_delay* pDelay, float value) { - if (pDelay == NULL) { + if (pDelay == nullptr) { return; } @@ -50503,7 +50503,7 @@ MA_API void ma_delay_set_decay(ma_delay* pDelay, float value) MA_API float ma_delay_get_decay(const ma_delay* pDelay) { - if (pDelay == NULL) { + if (pDelay == nullptr) { return 0; } @@ -50532,11 +50532,11 @@ typedef struct static ma_result ma_gainer_get_heap_layout(const ma_gainer_config* pConfig, ma_gainer_heap_layout* pHeapLayout) { - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -50566,7 +50566,7 @@ MA_API ma_result ma_gainer_get_heap_size(const ma_gainer_config* pConfig, size_t ma_result result; ma_gainer_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -50589,13 +50589,13 @@ MA_API ma_result ma_gainer_init_preallocated(const ma_gainer_config* pConfig, vo ma_gainer_heap_layout heapLayout; ma_uint32 iChannel; - if (pGainer == NULL) { + if (pGainer == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pGainer); - if (pConfig == NULL || pHeap == NULL) { + if (pConfig == nullptr || pHeap == nullptr) { return MA_INVALID_ARGS; } @@ -50635,11 +50635,11 @@ MA_API ma_result ma_gainer_init(const ma_gainer_config* pConfig, const ma_alloca if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_gainer_init_preallocated(pConfig, pHeap, pGainer); @@ -50654,7 +50654,7 @@ MA_API ma_result ma_gainer_init(const ma_gainer_config* pConfig, const ma_alloca MA_API void ma_gainer_uninit(ma_gainer* pGainer, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pGainer == NULL) { + if (pGainer == nullptr) { return; } @@ -50675,7 +50675,7 @@ static /*__attribute__((noinline))*/ ma_result ma_gainer_process_pcm_frames_inte ma_uint32 iChannel; ma_uint64 interpolatedFrameCount; - MA_ASSERT(pGainer != NULL); + MA_ASSERT(pGainer != nullptr); /* We don't necessarily need to apply a linear interpolation for the entire frameCount frames. When @@ -50701,7 +50701,7 @@ static /*__attribute__((noinline))*/ ma_result ma_gainer_process_pcm_frames_inte */ if (interpolatedFrameCount > 0) { /* We can allow the input and output buffers to be null in which case we'll just update the internal timer. */ - if (pFramesOut != NULL && pFramesIn != NULL) { + if (pFramesOut != nullptr && pFramesIn != nullptr) { /* All we're really doing here is moving the old gains towards the new gains. We don't want to be modifying the gains inside the ma_gainer object because that will break things. Instead @@ -50891,7 +50891,7 @@ static /*__attribute__((noinline))*/ ma_result ma_gainer_process_pcm_frames_inte } /* All we need to do here is apply the new gains using an optimized path. */ - if (pFramesOut != NULL && pFramesIn != NULL) { + if (pFramesOut != nullptr && pFramesIn != nullptr) { if (pGainer->config.channels <= 32) { float gains[32]; for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { @@ -50928,7 +50928,7 @@ static /*__attribute__((noinline))*/ ma_result ma_gainer_process_pcm_frames_inte /* Slow path. Need to interpolate the gain for each channel individually. */ /* We can allow the input and output buffers to be null in which case we'll just update the internal timer. */ - if (pFramesOut != NULL && pFramesIn != NULL) { + if (pFramesOut != nullptr && pFramesIn != nullptr) { float a = (float)pGainer->t / pGainer->config.smoothTimeInFrames; float d = 1.0f / pGainer->config.smoothTimeInFrames; ma_uint32 channelCount = pGainer->config.channels; @@ -50953,7 +50953,7 @@ static /*__attribute__((noinline))*/ ma_result ma_gainer_process_pcm_frames_inte #if 0 /* Reference implementation. */ for (iFrame = 0; iFrame < frameCount; iFrame += 1) { /* We can allow the input and output buffers to be null in which case we'll just update the internal timer. */ - if (pFramesOut != NULL && pFramesIn != NULL) { + if (pFramesOut != nullptr && pFramesIn != nullptr) { for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { pFramesOutF32[iFrame * pGainer->config.channels + iChannel] = pFramesInF32[iFrame * pGainer->config.channels + iChannel] * ma_gainer_calculate_current_gain(pGainer, iChannel) * pGainer->masterVolume; } @@ -50971,7 +50971,7 @@ static /*__attribute__((noinline))*/ ma_result ma_gainer_process_pcm_frames_inte MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pGainer == NULL) { + if (pGainer == nullptr) { return MA_INVALID_ARGS; } @@ -51001,7 +51001,7 @@ MA_API ma_result ma_gainer_set_gain(ma_gainer* pGainer, float newGain) { ma_uint32 iChannel; - if (pGainer == NULL) { + if (pGainer == nullptr) { return MA_INVALID_ARGS; } @@ -51019,7 +51019,7 @@ MA_API ma_result ma_gainer_set_gains(ma_gainer* pGainer, float* pNewGains) { ma_uint32 iChannel; - if (pGainer == NULL || pNewGains == NULL) { + if (pGainer == nullptr || pNewGains == nullptr) { return MA_INVALID_ARGS; } @@ -51035,7 +51035,7 @@ MA_API ma_result ma_gainer_set_gains(ma_gainer* pGainer, float* pNewGains) MA_API ma_result ma_gainer_set_master_volume(ma_gainer* pGainer, float volume) { - if (pGainer == NULL) { + if (pGainer == nullptr) { return MA_INVALID_ARGS; } @@ -51046,7 +51046,7 @@ MA_API ma_result ma_gainer_set_master_volume(ma_gainer* pGainer, float volume) MA_API ma_result ma_gainer_get_master_volume(const ma_gainer* pGainer, float* pVolume) { - if (pGainer == NULL || pVolume == NULL) { + if (pGainer == nullptr || pVolume == nullptr) { return MA_INVALID_ARGS; } @@ -51072,13 +51072,13 @@ MA_API ma_panner_config ma_panner_config_init(ma_format format, ma_uint32 channe MA_API ma_result ma_panner_init(const ma_panner_config* pConfig, ma_panner* pPanner) { - if (pPanner == NULL) { + if (pPanner == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pPanner); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -51201,7 +51201,7 @@ static void ma_stereo_pan_pcm_frames(void* pFramesOut, const void* pFramesIn, ma MA_API ma_result ma_panner_process_pcm_frames(ma_panner* pPanner, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pPanner == NULL || pFramesOut == NULL || pFramesIn == NULL) { + if (pPanner == nullptr || pFramesOut == nullptr || pFramesIn == nullptr) { return MA_INVALID_ARGS; } @@ -51227,7 +51227,7 @@ MA_API ma_result ma_panner_process_pcm_frames(ma_panner* pPanner, void* pFramesO MA_API void ma_panner_set_mode(ma_panner* pPanner, ma_pan_mode mode) { - if (pPanner == NULL) { + if (pPanner == nullptr) { return; } @@ -51236,7 +51236,7 @@ MA_API void ma_panner_set_mode(ma_panner* pPanner, ma_pan_mode mode) MA_API ma_pan_mode ma_panner_get_mode(const ma_panner* pPanner) { - if (pPanner == NULL) { + if (pPanner == nullptr) { return ma_pan_mode_balance; } @@ -51245,7 +51245,7 @@ MA_API ma_pan_mode ma_panner_get_mode(const ma_panner* pPanner) MA_API void ma_panner_set_pan(ma_panner* pPanner, float pan) { - if (pPanner == NULL) { + if (pPanner == nullptr) { return; } @@ -51254,7 +51254,7 @@ MA_API void ma_panner_set_pan(ma_panner* pPanner, float pan) MA_API float ma_panner_get_pan(const ma_panner* pPanner) { - if (pPanner == NULL) { + if (pPanner == nullptr) { return 0; } @@ -51279,13 +51279,13 @@ MA_API ma_fader_config ma_fader_config_init(ma_format format, ma_uint32 channels MA_API ma_result ma_fader_init(const ma_fader_config* pConfig, ma_fader* pFader) { - if (pFader == NULL) { + if (pFader == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFader); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -51305,7 +51305,7 @@ MA_API ma_result ma_fader_init(const ma_fader_config* pConfig, ma_fader* pFader) MA_API ma_result ma_fader_process_pcm_frames(ma_fader* pFader, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pFader == NULL) { + if (pFader == nullptr) { return MA_INVALID_ARGS; } @@ -51379,19 +51379,19 @@ MA_API ma_result ma_fader_process_pcm_frames(ma_fader* pFader, void* pFramesOut, MA_API void ma_fader_get_data_format(const ma_fader* pFader, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate) { - if (pFader == NULL) { + if (pFader == nullptr) { return; } - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = pFader->config.format; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = pFader->config.channels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = pFader->config.sampleRate; } } @@ -51403,7 +51403,7 @@ MA_API void ma_fader_set_fade(ma_fader* pFader, float volumeBeg, float volumeEnd MA_API void ma_fader_set_fade_ex(ma_fader* pFader, float volumeBeg, float volumeEnd, ma_uint64 lengthInFrames, ma_int64 startOffsetInFrames) { - if (pFader == NULL) { + if (pFader == nullptr) { return; } @@ -51433,7 +51433,7 @@ MA_API void ma_fader_set_fade_ex(ma_fader* pFader, float volumeBeg, float volume MA_API float ma_fader_get_current_volume(const ma_fader* pFader) { - if (pFader == NULL) { + if (pFader == nullptr) { return 0.0f; } @@ -51730,7 +51730,7 @@ MA_API ma_spatializer_listener_config ma_spatializer_listener_config_init(ma_uin MA_ZERO_OBJECT(&config); config.channelsOut = channelsOut; - config.pChannelMapOut = NULL; + config.pChannelMapOut = nullptr; config.handedness = ma_handedness_right; config.worldUp = ma_vec3f_init_3f(0, 1, 0); config.coneInnerAngleInRadians = 6.283185f; /* 360 degrees. */ @@ -51750,11 +51750,11 @@ typedef struct static ma_result ma_spatializer_listener_get_heap_layout(const ma_spatializer_listener_config* pConfig, ma_spatializer_listener_heap_layout* pHeapLayout) { - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -51777,7 +51777,7 @@ MA_API ma_result ma_spatializer_listener_get_heap_size(const ma_spatializer_list ma_result result; ma_spatializer_listener_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -51798,7 +51798,7 @@ MA_API ma_result ma_spatializer_listener_init_preallocated(const ma_spatializer_ ma_result result; ma_spatializer_listener_heap_layout heapLayout; - if (pListener == NULL) { + if (pListener == nullptr) { return MA_INVALID_ARGS; } @@ -51829,7 +51829,7 @@ MA_API ma_result ma_spatializer_listener_init_preallocated(const ma_spatializer_ pListener->config.pChannelMapOut = (ma_channel*)ma_offset_ptr(pHeap, heapLayout.channelMapOutOffset); /* Use a slightly different default channel map for stereo. */ - if (pConfig->pChannelMapOut == NULL) { + if (pConfig->pChannelMapOut == nullptr) { ma_get_default_channel_map_for_spatializer(pListener->config.pChannelMapOut, pConfig->channelsOut, pConfig->channelsOut); } else { ma_channel_map_copy_or_default(pListener->config.pChannelMapOut, pConfig->channelsOut, pConfig->pChannelMapOut, pConfig->channelsOut); @@ -51851,11 +51851,11 @@ MA_API ma_result ma_spatializer_listener_init(const ma_spatializer_listener_conf if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_spatializer_listener_init_preallocated(pConfig, pHeap, pListener); @@ -51870,7 +51870,7 @@ MA_API ma_result ma_spatializer_listener_init(const ma_spatializer_listener_conf MA_API void ma_spatializer_listener_uninit(ma_spatializer_listener* pListener, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } @@ -51881,8 +51881,8 @@ MA_API void ma_spatializer_listener_uninit(ma_spatializer_listener* pListener, c MA_API ma_channel* ma_spatializer_listener_get_channel_map(ma_spatializer_listener* pListener) { - if (pListener == NULL) { - return NULL; + if (pListener == nullptr) { + return nullptr; } return pListener->config.pChannelMapOut; @@ -51890,7 +51890,7 @@ MA_API ma_channel* ma_spatializer_listener_get_channel_map(ma_spatializer_listen MA_API void ma_spatializer_listener_set_cone(ma_spatializer_listener* pListener, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } @@ -51901,26 +51901,26 @@ MA_API void ma_spatializer_listener_set_cone(ma_spatializer_listener* pListener, MA_API void ma_spatializer_listener_get_cone(const ma_spatializer_listener* pListener, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } - if (pInnerAngleInRadians != NULL) { + if (pInnerAngleInRadians != nullptr) { *pInnerAngleInRadians = pListener->config.coneInnerAngleInRadians; } - if (pOuterAngleInRadians != NULL) { + if (pOuterAngleInRadians != nullptr) { *pOuterAngleInRadians = pListener->config.coneOuterAngleInRadians; } - if (pOuterGain != NULL) { + if (pOuterGain != nullptr) { *pOuterGain = pListener->config.coneOuterGain; } } MA_API void ma_spatializer_listener_set_position(ma_spatializer_listener* pListener, float x, float y, float z) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } @@ -51929,7 +51929,7 @@ MA_API void ma_spatializer_listener_set_position(ma_spatializer_listener* pListe MA_API ma_vec3f ma_spatializer_listener_get_position(const ma_spatializer_listener* pListener) { - if (pListener == NULL) { + if (pListener == nullptr) { return ma_vec3f_init_3f(0, 0, 0); } @@ -51938,7 +51938,7 @@ MA_API ma_vec3f ma_spatializer_listener_get_position(const ma_spatializer_listen MA_API void ma_spatializer_listener_set_direction(ma_spatializer_listener* pListener, float x, float y, float z) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } @@ -51947,7 +51947,7 @@ MA_API void ma_spatializer_listener_set_direction(ma_spatializer_listener* pList MA_API ma_vec3f ma_spatializer_listener_get_direction(const ma_spatializer_listener* pListener) { - if (pListener == NULL) { + if (pListener == nullptr) { return ma_vec3f_init_3f(0, 0, -1); } @@ -51956,7 +51956,7 @@ MA_API ma_vec3f ma_spatializer_listener_get_direction(const ma_spatializer_liste MA_API void ma_spatializer_listener_set_velocity(ma_spatializer_listener* pListener, float x, float y, float z) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } @@ -51965,7 +51965,7 @@ MA_API void ma_spatializer_listener_set_velocity(ma_spatializer_listener* pListe MA_API ma_vec3f ma_spatializer_listener_get_velocity(const ma_spatializer_listener* pListener) { - if (pListener == NULL) { + if (pListener == nullptr) { return ma_vec3f_init_3f(0, 0, 0); } @@ -51974,7 +51974,7 @@ MA_API ma_vec3f ma_spatializer_listener_get_velocity(const ma_spatializer_listen MA_API void ma_spatializer_listener_set_speed_of_sound(ma_spatializer_listener* pListener, float speedOfSound) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } @@ -51983,7 +51983,7 @@ MA_API void ma_spatializer_listener_set_speed_of_sound(ma_spatializer_listener* MA_API float ma_spatializer_listener_get_speed_of_sound(const ma_spatializer_listener* pListener) { - if (pListener == NULL) { + if (pListener == nullptr) { return 0; } @@ -51992,7 +51992,7 @@ MA_API float ma_spatializer_listener_get_speed_of_sound(const ma_spatializer_lis MA_API void ma_spatializer_listener_set_world_up(ma_spatializer_listener* pListener, float x, float y, float z) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } @@ -52001,7 +52001,7 @@ MA_API void ma_spatializer_listener_set_world_up(ma_spatializer_listener* pListe MA_API ma_vec3f ma_spatializer_listener_get_world_up(const ma_spatializer_listener* pListener) { - if (pListener == NULL) { + if (pListener == nullptr) { return ma_vec3f_init_3f(0, 1, 0); } @@ -52010,7 +52010,7 @@ MA_API ma_vec3f ma_spatializer_listener_get_world_up(const ma_spatializer_listen MA_API void ma_spatializer_listener_set_enabled(ma_spatializer_listener* pListener, ma_bool32 isEnabled) { - if (pListener == NULL) { + if (pListener == nullptr) { return; } @@ -52019,7 +52019,7 @@ MA_API void ma_spatializer_listener_set_enabled(ma_spatializer_listener* pListen MA_API ma_bool32 ma_spatializer_listener_is_enabled(const ma_spatializer_listener* pListener) { - if (pListener == NULL) { + if (pListener == nullptr) { return MA_FALSE; } @@ -52036,7 +52036,7 @@ MA_API ma_spatializer_config ma_spatializer_config_init(ma_uint32 channelsIn, ma MA_ZERO_OBJECT(&config); config.channelsIn = channelsIn; config.channelsOut = channelsOut; - config.pChannelMapIn = NULL; + config.pChannelMapIn = nullptr; config.attenuationModel = ma_attenuation_model_inverse; config.positioning = ma_positioning_absolute; config.handedness = ma_handedness_right; @@ -52059,13 +52059,13 @@ MA_API ma_spatializer_config ma_spatializer_config_init(ma_uint32 channelsIn, ma static ma_gainer_config ma_spatializer_gainer_config_init(const ma_spatializer_config* pConfig) { - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); return ma_gainer_config_init(pConfig->channelsOut, pConfig->gainSmoothTimeInFrames); } static ma_result ma_spatializer_validate_config(const ma_spatializer_config* pConfig) { - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); if (pConfig->channelsIn == 0 || pConfig->channelsOut == 0) { return MA_INVALID_ARGS; @@ -52086,11 +52086,11 @@ static ma_result ma_spatializer_get_heap_layout(const ma_spatializer_config* pCo { ma_result result; - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -52103,7 +52103,7 @@ static ma_result ma_spatializer_get_heap_layout(const ma_spatializer_config* pCo /* Channel map. */ pHeapLayout->channelMapInOffset = MA_SIZE_MAX; /* <-- MA_SIZE_MAX indicates no allocation necessary. */ - if (pConfig->pChannelMapIn != NULL) { + if (pConfig->pChannelMapIn != nullptr) { pHeapLayout->channelMapInOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(sizeof(*pConfig->pChannelMapIn) * pConfig->channelsIn); } @@ -52136,7 +52136,7 @@ MA_API ma_result ma_spatializer_get_heap_size(const ma_spatializer_config* pConf ma_result result; ma_spatializer_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -52159,13 +52159,13 @@ MA_API ma_result ma_spatializer_init_preallocated(const ma_spatializer_config* p ma_spatializer_heap_layout heapLayout; ma_gainer_config gainerConfig; - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pSpatializer); - if (pConfig == NULL || pHeap == NULL) { + if (pConfig == nullptr || pHeap == nullptr) { return MA_INVALID_ARGS; } @@ -52206,7 +52206,7 @@ MA_API ma_result ma_spatializer_init_preallocated(const ma_spatializer_config* p } /* Channel map. This will be on the heap. */ - if (pConfig->pChannelMapIn != NULL) { + if (pConfig->pChannelMapIn != nullptr) { pSpatializer->pChannelMapIn = (ma_channel*)ma_offset_ptr(pHeap, heapLayout.channelMapInOffset); ma_channel_map_copy_or_default(pSpatializer->pChannelMapIn, pSpatializer->channelsIn, pConfig->pChannelMapIn, pSpatializer->channelsIn); } @@ -52239,11 +52239,11 @@ MA_API ma_result ma_spatializer_init(const ma_spatializer_config* pConfig, const if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_spatializer_init_preallocated(pConfig, pHeap, pSpatializer); @@ -52258,7 +52258,7 @@ MA_API ma_result ma_spatializer_init(const ma_spatializer_config* pConfig, const MA_API void ma_spatializer_uninit(ma_spatializer* pSpatializer, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52318,7 +52318,7 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer, ma_channel* pChannelMapIn; ma_channel* pChannelMapOut; - if (pSpatializer == NULL || pListener == NULL) { + if (pSpatializer == nullptr || pListener == nullptr) { return MA_INVALID_ARGS; } @@ -52444,7 +52444,7 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer, We're supporting angular gain on the listener as well for those who want to reduce the volume of sounds that are positioned behind the listener. On default settings, this will have no effect. */ - if (pListener != NULL && pListener->config.coneInnerAngleInRadians < 6.283185f) { + if (pListener != nullptr && pListener->config.coneInnerAngleInRadians < 6.283185f) { ma_vec3f listenerDirection; float listenerInnerAngle; float listenerOuterAngle; @@ -52498,7 +52498,7 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer, /*printf("distance=%f; gain=%f\n", distance, gain);*/ /* We must have a valid channel map here to ensure we spatialize properly. */ - MA_ASSERT(pChannelMapOut != NULL); + MA_ASSERT(pChannelMapOut != nullptr); /* We're not converting to mono so we'll want to apply some panning. This is where the feeling of something being @@ -52621,7 +52621,7 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer, MA_API ma_result ma_spatializer_set_master_volume(ma_spatializer* pSpatializer, float volume) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return MA_INVALID_ARGS; } @@ -52630,7 +52630,7 @@ MA_API ma_result ma_spatializer_set_master_volume(ma_spatializer* pSpatializer, MA_API ma_result ma_spatializer_get_master_volume(const ma_spatializer* pSpatializer, float* pVolume) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return MA_INVALID_ARGS; } @@ -52639,7 +52639,7 @@ MA_API ma_result ma_spatializer_get_master_volume(const ma_spatializer* pSpatial MA_API ma_uint32 ma_spatializer_get_input_channels(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 0; } @@ -52648,7 +52648,7 @@ MA_API ma_uint32 ma_spatializer_get_input_channels(const ma_spatializer* pSpatia MA_API ma_uint32 ma_spatializer_get_output_channels(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 0; } @@ -52657,7 +52657,7 @@ MA_API ma_uint32 ma_spatializer_get_output_channels(const ma_spatializer* pSpati MA_API void ma_spatializer_set_attenuation_model(ma_spatializer* pSpatializer, ma_attenuation_model attenuationModel) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52666,7 +52666,7 @@ MA_API void ma_spatializer_set_attenuation_model(ma_spatializer* pSpatializer, m MA_API ma_attenuation_model ma_spatializer_get_attenuation_model(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return ma_attenuation_model_none; } @@ -52675,7 +52675,7 @@ MA_API ma_attenuation_model ma_spatializer_get_attenuation_model(const ma_spatia MA_API void ma_spatializer_set_positioning(ma_spatializer* pSpatializer, ma_positioning positioning) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52684,7 +52684,7 @@ MA_API void ma_spatializer_set_positioning(ma_spatializer* pSpatializer, ma_posi MA_API ma_positioning ma_spatializer_get_positioning(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return ma_positioning_absolute; } @@ -52693,7 +52693,7 @@ MA_API ma_positioning ma_spatializer_get_positioning(const ma_spatializer* pSpat MA_API void ma_spatializer_set_rolloff(ma_spatializer* pSpatializer, float rolloff) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52702,7 +52702,7 @@ MA_API void ma_spatializer_set_rolloff(ma_spatializer* pSpatializer, float rollo MA_API float ma_spatializer_get_rolloff(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 0; } @@ -52711,7 +52711,7 @@ MA_API float ma_spatializer_get_rolloff(const ma_spatializer* pSpatializer) MA_API void ma_spatializer_set_min_gain(ma_spatializer* pSpatializer, float minGain) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52720,7 +52720,7 @@ MA_API void ma_spatializer_set_min_gain(ma_spatializer* pSpatializer, float minG MA_API float ma_spatializer_get_min_gain(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 0; } @@ -52729,7 +52729,7 @@ MA_API float ma_spatializer_get_min_gain(const ma_spatializer* pSpatializer) MA_API void ma_spatializer_set_max_gain(ma_spatializer* pSpatializer, float maxGain) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52738,7 +52738,7 @@ MA_API void ma_spatializer_set_max_gain(ma_spatializer* pSpatializer, float maxG MA_API float ma_spatializer_get_max_gain(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 0; } @@ -52747,7 +52747,7 @@ MA_API float ma_spatializer_get_max_gain(const ma_spatializer* pSpatializer) MA_API void ma_spatializer_set_min_distance(ma_spatializer* pSpatializer, float minDistance) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52756,7 +52756,7 @@ MA_API void ma_spatializer_set_min_distance(ma_spatializer* pSpatializer, float MA_API float ma_spatializer_get_min_distance(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 0; } @@ -52765,7 +52765,7 @@ MA_API float ma_spatializer_get_min_distance(const ma_spatializer* pSpatializer) MA_API void ma_spatializer_set_max_distance(ma_spatializer* pSpatializer, float maxDistance) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52774,7 +52774,7 @@ MA_API void ma_spatializer_set_max_distance(ma_spatializer* pSpatializer, float MA_API float ma_spatializer_get_max_distance(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 0; } @@ -52783,7 +52783,7 @@ MA_API float ma_spatializer_get_max_distance(const ma_spatializer* pSpatializer) MA_API void ma_spatializer_set_cone(ma_spatializer* pSpatializer, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52794,26 +52794,26 @@ MA_API void ma_spatializer_set_cone(ma_spatializer* pSpatializer, float innerAng MA_API void ma_spatializer_get_cone(const ma_spatializer* pSpatializer, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } - if (pInnerAngleInRadians != NULL) { + if (pInnerAngleInRadians != nullptr) { *pInnerAngleInRadians = ma_atomic_load_f32(&pSpatializer->coneInnerAngleInRadians); } - if (pOuterAngleInRadians != NULL) { + if (pOuterAngleInRadians != nullptr) { *pOuterAngleInRadians = ma_atomic_load_f32(&pSpatializer->coneOuterAngleInRadians); } - if (pOuterGain != NULL) { + if (pOuterGain != nullptr) { *pOuterGain = ma_atomic_load_f32(&pSpatializer->coneOuterGain); } } MA_API void ma_spatializer_set_doppler_factor(ma_spatializer* pSpatializer, float dopplerFactor) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52822,7 +52822,7 @@ MA_API void ma_spatializer_set_doppler_factor(ma_spatializer* pSpatializer, floa MA_API float ma_spatializer_get_doppler_factor(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 1; } @@ -52831,7 +52831,7 @@ MA_API float ma_spatializer_get_doppler_factor(const ma_spatializer* pSpatialize MA_API void ma_spatializer_set_directional_attenuation_factor(ma_spatializer* pSpatializer, float directionalAttenuationFactor) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52840,7 +52840,7 @@ MA_API void ma_spatializer_set_directional_attenuation_factor(ma_spatializer* pS MA_API float ma_spatializer_get_directional_attenuation_factor(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return 1; } @@ -52849,7 +52849,7 @@ MA_API float ma_spatializer_get_directional_attenuation_factor(const ma_spatiali MA_API void ma_spatializer_set_position(ma_spatializer* pSpatializer, float x, float y, float z) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52858,7 +52858,7 @@ MA_API void ma_spatializer_set_position(ma_spatializer* pSpatializer, float x, f MA_API ma_vec3f ma_spatializer_get_position(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return ma_vec3f_init_3f(0, 0, 0); } @@ -52867,7 +52867,7 @@ MA_API ma_vec3f ma_spatializer_get_position(const ma_spatializer* pSpatializer) MA_API void ma_spatializer_set_direction(ma_spatializer* pSpatializer, float x, float y, float z) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52876,7 +52876,7 @@ MA_API void ma_spatializer_set_direction(ma_spatializer* pSpatializer, float x, MA_API ma_vec3f ma_spatializer_get_direction(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return ma_vec3f_init_3f(0, 0, -1); } @@ -52885,7 +52885,7 @@ MA_API ma_vec3f ma_spatializer_get_direction(const ma_spatializer* pSpatializer) MA_API void ma_spatializer_set_velocity(ma_spatializer* pSpatializer, float x, float y, float z) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } @@ -52894,7 +52894,7 @@ MA_API void ma_spatializer_set_velocity(ma_spatializer* pSpatializer, float x, f MA_API ma_vec3f ma_spatializer_get_velocity(const ma_spatializer* pSpatializer) { - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return ma_vec3f_init_3f(0, 0, 0); } @@ -52903,28 +52903,28 @@ MA_API ma_vec3f ma_spatializer_get_velocity(const ma_spatializer* pSpatializer) MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatializer* pSpatializer, const ma_spatializer_listener* pListener, ma_vec3f* pRelativePos, ma_vec3f* pRelativeDir) { - if (pRelativePos != NULL) { + if (pRelativePos != nullptr) { pRelativePos->x = 0; pRelativePos->y = 0; pRelativePos->z = 0; } - if (pRelativeDir != NULL) { + if (pRelativeDir != nullptr) { pRelativeDir->x = 0; pRelativeDir->y = 0; pRelativeDir->z = -1; } - if (pSpatializer == NULL) { + if (pSpatializer == nullptr) { return; } - if (pListener == NULL || ma_spatializer_get_positioning(pSpatializer) == ma_positioning_relative) { + if (pListener == nullptr || ma_spatializer_get_positioning(pSpatializer) == ma_positioning_relative) { /* There's no listener or we're using relative positioning. */ - if (pRelativePos != NULL) { + if (pRelativePos != nullptr) { *pRelativePos = ma_spatializer_get_position(pSpatializer); } - if (pRelativeDir != NULL) { + if (pRelativeDir != nullptr) { *pRelativeDir = ma_spatializer_get_direction(pSpatializer); } } else { @@ -52982,7 +52982,7 @@ MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatiali space. This allows calculations to work based on the sound being relative to the origin which makes things simpler. */ - if (pRelativePos != NULL) { + if (pRelativePos != nullptr) { v = spatializerPosition; pRelativePos->x = m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * 1; pRelativePos->y = m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * 1; @@ -52993,7 +52993,7 @@ MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatiali The direction of the sound needs to also be transformed so that it's relative to the rotation of the listener. */ - if (pRelativeDir != NULL) { + if (pRelativeDir != nullptr) { v = spatializerDirection; pRelativeDir->x = m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z; pRelativeDir->y = m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z; @@ -53061,7 +53061,7 @@ static ma_result ma_linear_resampler_set_rate_internal(ma_linear_resampler* pRes ma_lpf_config lpfConfig; ma_uint32 oldSampleRateOut; /* Required for adjusting time advance down the bottom. */ - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -53115,11 +53115,11 @@ static ma_result ma_linear_resampler_set_rate_internal(ma_linear_resampler* pRes static ma_result ma_linear_resampler_get_heap_layout(const ma_linear_resampler_config* pConfig, ma_linear_resampler_heap_layout* pHeapLayout) { - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -53175,7 +53175,7 @@ MA_API ma_result ma_linear_resampler_get_heap_size(const ma_linear_resampler_con ma_result result; ma_linear_resampler_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -53196,7 +53196,7 @@ MA_API ma_result ma_linear_resampler_init_preallocated(const ma_linear_resampler ma_result result; ma_linear_resampler_heap_layout heapLayout; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -53245,11 +53245,11 @@ MA_API ma_result ma_linear_resampler_init(const ma_linear_resampler_config* pCon if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_linear_resampler_init_preallocated(pConfig, pHeap, pResampler); @@ -53264,7 +53264,7 @@ MA_API ma_result ma_linear_resampler_init(const ma_linear_resampler_config* pCon MA_API void ma_linear_resampler_uninit(ma_linear_resampler* pResampler, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return; } @@ -53297,8 +53297,8 @@ static void ma_linear_resampler_interpolate_frame_s16(ma_linear_resampler* pResa const ma_uint32 channels = pResampler->config.channels; const ma_uint32 shift = 12; - MA_ASSERT(pResampler != NULL); - MA_ASSERT(pFrameOut != NULL); + MA_ASSERT(pResampler != nullptr); + MA_ASSERT(pFrameOut != nullptr); a = (pResampler->inTimeFrac << shift) / pResampler->config.sampleRateOut; @@ -53316,8 +53316,8 @@ static void ma_linear_resampler_interpolate_frame_f32(ma_linear_resampler* pResa float a; const ma_uint32 channels = pResampler->config.channels; - MA_ASSERT(pResampler != NULL); - MA_ASSERT(pFrameOut != NULL); + MA_ASSERT(pResampler != nullptr); + MA_ASSERT(pFrameOut != nullptr); a = (float)pResampler->inTimeFrac / pResampler->config.sampleRateOut; @@ -53337,9 +53337,9 @@ static ma_result ma_linear_resampler_process_pcm_frames_s16_downsample(ma_linear ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; - MA_ASSERT(pResampler != NULL); - MA_ASSERT(pFrameCountIn != NULL); - MA_ASSERT(pFrameCountOut != NULL); + MA_ASSERT(pResampler != nullptr); + MA_ASSERT(pFrameCountIn != nullptr); + MA_ASSERT(pFrameCountOut != nullptr); pFramesInS16 = (const ma_int16*)pFramesIn; pFramesOutS16 = ( ma_int16*)pFramesOut; @@ -53353,7 +53353,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_s16_downsample(ma_linear while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) { ma_uint32 iChannel; - if (pFramesInS16 != NULL) { + if (pFramesInS16 != nullptr) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel]; pResampler->x1.s16[iChannel] = pFramesInS16[iChannel]; @@ -53380,7 +53380,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_s16_downsample(ma_linear } /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */ - if (pFramesOutS16 != NULL) { + if (pFramesOutS16 != nullptr) { MA_ASSERT(pResampler->inTimeInt == 0); ma_linear_resampler_interpolate_frame_s16(pResampler, pFramesOutS16); @@ -53413,9 +53413,9 @@ static ma_result ma_linear_resampler_process_pcm_frames_s16_upsample(ma_linear_r ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; - MA_ASSERT(pResampler != NULL); - MA_ASSERT(pFrameCountIn != NULL); - MA_ASSERT(pFrameCountOut != NULL); + MA_ASSERT(pResampler != nullptr); + MA_ASSERT(pFrameCountIn != nullptr); + MA_ASSERT(pFrameCountOut != nullptr); pFramesInS16 = (const ma_int16*)pFramesIn; pFramesOutS16 = ( ma_int16*)pFramesOut; @@ -53429,7 +53429,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_s16_upsample(ma_linear_r while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) { ma_uint32 iChannel; - if (pFramesInS16 != NULL) { + if (pFramesInS16 != nullptr) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel]; pResampler->x1.s16[iChannel] = pFramesInS16[iChannel]; @@ -53451,7 +53451,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_s16_upsample(ma_linear_r } /* Getting here means the frames have been loaded and we can generate the next output frame. */ - if (pFramesOutS16 != NULL) { + if (pFramesOutS16 != nullptr) { MA_ASSERT(pResampler->inTimeInt == 0); ma_linear_resampler_interpolate_frame_s16(pResampler, pFramesOutS16); @@ -53482,7 +53482,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_s16_upsample(ma_linear_r static ma_result ma_linear_resampler_process_pcm_frames_s16(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { - MA_ASSERT(pResampler != NULL); + MA_ASSERT(pResampler != nullptr); if (pResampler->config.sampleRateIn > pResampler->config.sampleRateOut) { return ma_linear_resampler_process_pcm_frames_s16_downsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); @@ -53501,9 +53501,9 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; - MA_ASSERT(pResampler != NULL); - MA_ASSERT(pFrameCountIn != NULL); - MA_ASSERT(pFrameCountOut != NULL); + MA_ASSERT(pResampler != nullptr); + MA_ASSERT(pFrameCountIn != nullptr); + MA_ASSERT(pFrameCountOut != nullptr); pFramesInF32 = (const float*)pFramesIn; pFramesOutF32 = ( float*)pFramesOut; @@ -53517,7 +53517,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) { ma_uint32 iChannel; - if (pFramesInF32 != NULL) { + if (pFramesInF32 != nullptr) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel]; pResampler->x1.f32[iChannel] = pFramesInF32[iChannel]; @@ -53544,7 +53544,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear } /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */ - if (pFramesOutF32 != NULL) { + if (pFramesOutF32 != nullptr) { MA_ASSERT(pResampler->inTimeInt == 0); ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32); @@ -53577,9 +53577,9 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_r ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; - MA_ASSERT(pResampler != NULL); - MA_ASSERT(pFrameCountIn != NULL); - MA_ASSERT(pFrameCountOut != NULL); + MA_ASSERT(pResampler != nullptr); + MA_ASSERT(pFrameCountIn != nullptr); + MA_ASSERT(pFrameCountOut != nullptr); pFramesInF32 = (const float*)pFramesIn; pFramesOutF32 = ( float*)pFramesOut; @@ -53593,7 +53593,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_r while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) { ma_uint32 iChannel; - if (pFramesInF32 != NULL) { + if (pFramesInF32 != nullptr) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel]; pResampler->x1.f32[iChannel] = pFramesInF32[iChannel]; @@ -53615,7 +53615,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_r } /* Getting here means the frames have been loaded and we can generate the next output frame. */ - if (pFramesOutF32 != NULL) { + if (pFramesOutF32 != nullptr) { MA_ASSERT(pResampler->inTimeInt == 0); ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32); @@ -53646,7 +53646,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_r static ma_result ma_linear_resampler_process_pcm_frames_f32(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { - MA_ASSERT(pResampler != NULL); + MA_ASSERT(pResampler != nullptr); if (pResampler->config.sampleRateIn > pResampler->config.sampleRateOut) { return ma_linear_resampler_process_pcm_frames_f32_downsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); @@ -53658,7 +53658,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32(ma_linear_resampler* MA_API ma_result ma_linear_resampler_process_pcm_frames(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -53676,7 +53676,7 @@ MA_API ma_result ma_linear_resampler_process_pcm_frames(ma_linear_resampler* pRe MA_API ma_result ma_linear_resampler_set_rate(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut) { - return ma_linear_resampler_set_rate_internal(pResampler, NULL, NULL, sampleRateIn, sampleRateOut, /* isResamplerAlreadyInitialized = */ MA_TRUE); + return ma_linear_resampler_set_rate_internal(pResampler, nullptr, nullptr, sampleRateIn, sampleRateOut, /* isResamplerAlreadyInitialized = */ MA_TRUE); } MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResampler, float ratioInOut) @@ -53684,7 +53684,7 @@ MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResamp ma_uint32 n; ma_uint32 d; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -53706,7 +53706,7 @@ MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResamp MA_API ma_uint64 ma_linear_resampler_get_input_latency(const ma_linear_resampler* pResampler) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return 0; } @@ -53715,7 +53715,7 @@ MA_API ma_uint64 ma_linear_resampler_get_input_latency(const ma_linear_resampler MA_API ma_uint64 ma_linear_resampler_get_output_latency(const ma_linear_resampler* pResampler) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return 0; } @@ -53726,13 +53726,13 @@ MA_API ma_result ma_linear_resampler_get_required_input_frame_count(const ma_lin { ma_uint64 inputFrameCount; - if (pInputFrameCount == NULL) { + if (pInputFrameCount == nullptr) { return MA_INVALID_ARGS; } *pInputFrameCount = 0; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -53759,13 +53759,13 @@ MA_API ma_result ma_linear_resampler_get_expected_output_frame_count(const ma_li ma_uint64 preliminaryInputFrameCountFromFrac; ma_uint64 preliminaryInputFrameCount; - if (pOutputFrameCount == NULL) { + if (pOutputFrameCount == nullptr) { return MA_INVALID_ARGS; } *pOutputFrameCount = 0; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -53802,7 +53802,7 @@ MA_API ma_result ma_linear_resampler_reset(ma_linear_resampler* pResampler) { ma_uint32 iChannel; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -53964,13 +53964,13 @@ MA_API ma_resampler_config ma_resampler_config_init(ma_format format, ma_uint32 static ma_result ma_resampler_get_vtable(const ma_resampler_config* pConfig, ma_resampler* pResampler, ma_resampling_backend_vtable** ppVTable, void** ppUserData) { - MA_ASSERT(pConfig != NULL); - MA_ASSERT(ppVTable != NULL); - MA_ASSERT(ppUserData != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(ppVTable != nullptr); + MA_ASSERT(ppUserData != nullptr); /* Safety. */ - *ppVTable = NULL; - *ppUserData = NULL; + *ppVTable = nullptr; + *ppUserData = nullptr; switch (pConfig->algorithm) { @@ -53998,22 +53998,22 @@ MA_API ma_result ma_resampler_get_heap_size(const ma_resampler_config* pConfig, ma_resampling_backend_vtable* pVTable; void* pVTableUserData; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - result = ma_resampler_get_vtable(pConfig, NULL, &pVTable, &pVTableUserData); + result = ma_resampler_get_vtable(pConfig, nullptr, &pVTable, &pVTableUserData); if (result != MA_SUCCESS) { return result; } - if (pVTable == NULL || pVTable->onGetHeapSize == NULL) { + if (pVTable == nullptr || pVTable->onGetHeapSize == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -54029,13 +54029,13 @@ MA_API ma_result ma_resampler_init_preallocated(const ma_resampler_config* pConf { ma_result result; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pResampler); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -54050,7 +54050,7 @@ MA_API ma_result ma_resampler_init_preallocated(const ma_resampler_config* pConf return result; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onInit == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onInit == nullptr) { return MA_NOT_IMPLEMENTED; /* onInit not implemented. */ } @@ -54075,11 +54075,11 @@ MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, const ma_ if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_resampler_init_preallocated(pConfig, pHeap, pResampler); @@ -54094,11 +54094,11 @@ MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, const ma_ MA_API void ma_resampler_uninit(ma_resampler* pResampler, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onUninit == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onUninit == nullptr) { return; } @@ -54111,15 +54111,15 @@ MA_API void ma_resampler_uninit(ma_resampler* pResampler, const ma_allocation_ca MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } - if (pFrameCountOut == NULL && pFrameCountIn == NULL) { + if (pFrameCountOut == nullptr && pFrameCountIn == nullptr) { return MA_INVALID_ARGS; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onProcess == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onProcess == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -54130,7 +54130,7 @@ MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampl { ma_result result; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -54138,7 +54138,7 @@ MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampl return MA_INVALID_ARGS; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onSetRate == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onSetRate == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -54158,7 +54158,7 @@ MA_API ma_result ma_resampler_set_rate_ratio(ma_resampler* pResampler, float rat ma_uint32 n; ma_uint32 d; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } @@ -54180,11 +54180,11 @@ MA_API ma_result ma_resampler_set_rate_ratio(ma_resampler* pResampler, float rat MA_API ma_uint64 ma_resampler_get_input_latency(const ma_resampler* pResampler) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return 0; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onGetInputLatency == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onGetInputLatency == nullptr) { return 0; } @@ -54193,11 +54193,11 @@ MA_API ma_uint64 ma_resampler_get_input_latency(const ma_resampler* pResampler) MA_API ma_uint64 ma_resampler_get_output_latency(const ma_resampler* pResampler) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return 0; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onGetOutputLatency == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onGetOutputLatency == nullptr) { return 0; } @@ -54206,17 +54206,17 @@ MA_API ma_uint64 ma_resampler_get_output_latency(const ma_resampler* pResampler) MA_API ma_result ma_resampler_get_required_input_frame_count(const ma_resampler* pResampler, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount) { - if (pInputFrameCount == NULL) { + if (pInputFrameCount == nullptr) { return MA_INVALID_ARGS; } *pInputFrameCount = 0; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onGetRequiredInputFrameCount == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onGetRequiredInputFrameCount == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -54225,17 +54225,17 @@ MA_API ma_result ma_resampler_get_required_input_frame_count(const ma_resampler* MA_API ma_result ma_resampler_get_expected_output_frame_count(const ma_resampler* pResampler, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount) { - if (pOutputFrameCount == NULL) { + if (pOutputFrameCount == nullptr) { return MA_INVALID_ARGS; } *pOutputFrameCount = 0; - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onGetExpectedOutputFrameCount == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onGetExpectedOutputFrameCount == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -54244,11 +54244,11 @@ MA_API ma_result ma_resampler_get_expected_output_frame_count(const ma_resampler MA_API ma_result ma_resampler_reset(ma_resampler* pResampler) { - if (pResampler == NULL) { + if (pResampler == nullptr) { return MA_INVALID_ARGS; } - if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onReset == NULL) { + if (pResampler->pBackendVTable == nullptr || pResampler->pBackendVTable->onReset == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -54394,7 +54394,7 @@ static ma_uint32 ma_channel_map_get_spatial_channel_count(const ma_channel* pCha ma_uint32 spatialChannelCount = 0; ma_uint32 iChannel; - MA_ASSERT(pChannelMap != NULL); + MA_ASSERT(pChannelMap != nullptr); MA_ASSERT(channels > 0); for (iChannel = 0; iChannel < channels; ++iChannel) { @@ -54443,11 +54443,11 @@ static ma_channel_conversion_path ma_channel_map_get_conversion_path(const ma_ch return ma_channel_conversion_path_passthrough; } - if (channelsOut == 1 && (pChannelMapOut == NULL || pChannelMapOut[0] == MA_CHANNEL_MONO)) { + if (channelsOut == 1 && (pChannelMapOut == nullptr || pChannelMapOut[0] == MA_CHANNEL_MONO)) { return ma_channel_conversion_path_mono_out; } - if (channelsIn == 1 && (pChannelMapIn == NULL || pChannelMapIn[0] == MA_CHANNEL_MONO)) { + if (channelsIn == 1 && (pChannelMapIn == nullptr || pChannelMapIn[0] == MA_CHANNEL_MONO)) { return ma_channel_conversion_path_mono_in; } @@ -54485,7 +54485,7 @@ static ma_result ma_channel_map_build_shuffle_table(const ma_channel* pChannelMa ma_uint32 iChannelIn; ma_uint32 iChannelOut; - if (pShuffleTable == NULL || channelCountIn == 0 || channelCountOut == 0) { + if (pShuffleTable == nullptr || channelCountIn == 0 || channelCountOut == 0) { return MA_INVALID_ARGS; } @@ -54658,7 +54658,7 @@ static void ma_channel_map_apply_shuffle_table_f32(float* pFramesOut, ma_uint32 static ma_result ma_channel_map_apply_shuffle_table(void* pFramesOut, ma_uint32 channelsOut, const void* pFramesIn, ma_uint32 channelsIn, ma_uint64 frameCount, const ma_uint8* pShuffleTable, ma_format format) { - if (pFramesOut == NULL || pFramesIn == NULL || channelsOut == 0 || pShuffleTable == NULL) { + if (pFramesOut == nullptr || pFramesIn == nullptr || channelsOut == 0 || pShuffleTable == nullptr) { return MA_INVALID_ARGS; } @@ -54701,7 +54701,7 @@ static ma_result ma_channel_map_apply_mono_out_f32(float* pFramesOut, const floa ma_uint32 iChannelIn; ma_uint32 accumulationCount; - if (pFramesOut == NULL || pFramesIn == NULL || channelsIn == 0) { + if (pFramesOut == nullptr || pFramesIn == nullptr || channelsIn == 0) { return MA_INVALID_ARGS; } @@ -54742,7 +54742,7 @@ static ma_result ma_channel_map_apply_mono_in_f32(float* MA_RESTRICT pFramesOut, ma_uint64 iFrame; ma_uint32 iChannelOut; - if (pFramesOut == NULL || channelsOut == 0 || pFramesIn == NULL) { + if (pFramesOut == nullptr || channelsOut == 0 || pFramesIn == nullptr) { return MA_INVALID_ARGS; } @@ -55167,9 +55167,9 @@ static ma_result ma_channel_converter_get_heap_layout(const ma_channel_converter { ma_channel_conversion_path conversionPath; - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -55189,13 +55189,13 @@ static ma_result ma_channel_converter_get_heap_layout(const ma_channel_converter /* Input channel map. Only need to allocate this if we have an input channel map (otherwise default channel map is assumed). */ pHeapLayout->channelMapInOffset = pHeapLayout->sizeInBytes; - if (pConfig->pChannelMapIn != NULL) { + if (pConfig->pChannelMapIn != nullptr) { pHeapLayout->sizeInBytes += sizeof(ma_channel) * pConfig->channelsIn; } /* Output channel map. Only need to allocate this if we have an output channel map (otherwise default channel map is assumed). */ pHeapLayout->channelMapOutOffset = pHeapLayout->sizeInBytes; - if (pConfig->pChannelMapOut != NULL) { + if (pConfig->pChannelMapOut != nullptr) { pHeapLayout->sizeInBytes += sizeof(ma_channel) * pConfig->channelsOut; } @@ -55229,7 +55229,7 @@ MA_API ma_result ma_channel_converter_get_heap_size(const ma_channel_converter_c ma_result result; ma_channel_converter_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -55250,7 +55250,7 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert ma_result result; ma_channel_converter_heap_layout heapLayout; - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } @@ -55269,18 +55269,18 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert pConverter->channelsOut = pConfig->channelsOut; pConverter->mixingMode = pConfig->mixingMode; - if (pConfig->pChannelMapIn != NULL) { + if (pConfig->pChannelMapIn != nullptr) { pConverter->pChannelMapIn = (ma_channel*)ma_offset_ptr(pHeap, heapLayout.channelMapInOffset); ma_channel_map_copy_or_default(pConverter->pChannelMapIn, pConfig->channelsIn, pConfig->pChannelMapIn, pConfig->channelsIn); } else { - pConverter->pChannelMapIn = NULL; /* Use default channel map. */ + pConverter->pChannelMapIn = nullptr; /* Use default channel map. */ } - if (pConfig->pChannelMapOut != NULL) { + if (pConfig->pChannelMapOut != nullptr) { pConverter->pChannelMapOut = (ma_channel*)ma_offset_ptr(pHeap, heapLayout.channelMapOutOffset); ma_channel_map_copy_or_default(pConverter->pChannelMapOut, pConfig->channelsOut, pConfig->pChannelMapOut, pConfig->channelsOut); } else { - pConverter->pChannelMapOut = NULL; /* Use default channel map. */ + pConverter->pChannelMapOut = nullptr; /* Use default channel map. */ } pConverter->conversionPath = ma_channel_converter_config_get_conversion_path(pConfig); @@ -55344,7 +55344,7 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert { case ma_channel_mix_mode_custom_weights: { - if (pConfig->ppWeights == NULL) { + if (pConfig->ppWeights == nullptr) { return MA_INVALID_ARGS; /* Config specified a custom weights mixing mode, but no custom weights have been specified. */ } @@ -55479,11 +55479,11 @@ MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pC if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_channel_converter_init_preallocated(pConfig, pHeap, pConverter); @@ -55498,7 +55498,7 @@ MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pC MA_API void ma_channel_converter_uninit(ma_channel_converter* pConverter, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return; } @@ -55509,9 +55509,9 @@ MA_API void ma_channel_converter_uninit(ma_channel_converter* pConverter, const static ma_result ma_channel_converter_process_pcm_frames__passthrough(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - MA_ASSERT(pConverter != NULL); - MA_ASSERT(pFramesOut != NULL); - MA_ASSERT(pFramesIn != NULL); + MA_ASSERT(pConverter != nullptr); + MA_ASSERT(pFramesOut != nullptr); + MA_ASSERT(pFramesIn != nullptr); ma_copy_memory_64(pFramesOut, pFramesIn, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut)); return MA_SUCCESS; @@ -55519,9 +55519,9 @@ static ma_result ma_channel_converter_process_pcm_frames__passthrough(ma_channel static ma_result ma_channel_converter_process_pcm_frames__shuffle(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - MA_ASSERT(pConverter != NULL); - MA_ASSERT(pFramesOut != NULL); - MA_ASSERT(pFramesIn != NULL); + MA_ASSERT(pConverter != nullptr); + MA_ASSERT(pFramesOut != nullptr); + MA_ASSERT(pFramesIn != nullptr); MA_ASSERT(pConverter->channelsIn == pConverter->channelsOut); return ma_channel_map_apply_shuffle_table(pFramesOut, pConverter->channelsOut, pFramesIn, pConverter->channelsIn, frameCount, pConverter->pShuffleTable, pConverter->format); @@ -55531,9 +55531,9 @@ static ma_result ma_channel_converter_process_pcm_frames__mono_in(ma_channel_con { ma_uint64 iFrame; - MA_ASSERT(pConverter != NULL); - MA_ASSERT(pFramesOut != NULL); - MA_ASSERT(pFramesIn != NULL); + MA_ASSERT(pConverter != nullptr); + MA_ASSERT(pFramesOut != nullptr); + MA_ASSERT(pFramesIn != nullptr); MA_ASSERT(pConverter->channelsIn == 1); switch (pConverter->format) @@ -55632,9 +55632,9 @@ static ma_result ma_channel_converter_process_pcm_frames__mono_out(ma_channel_co ma_uint64 iFrame; ma_uint32 iChannel; - MA_ASSERT(pConverter != NULL); - MA_ASSERT(pFramesOut != NULL); - MA_ASSERT(pFramesIn != NULL); + MA_ASSERT(pConverter != nullptr); + MA_ASSERT(pFramesOut != nullptr); + MA_ASSERT(pFramesIn != nullptr); MA_ASSERT(pConverter->channelsOut == 1); switch (pConverter->format) @@ -55726,9 +55726,9 @@ static ma_result ma_channel_converter_process_pcm_frames__weights(ma_channel_con ma_uint32 iChannelIn; ma_uint32 iChannelOut; - MA_ASSERT(pConverter != NULL); - MA_ASSERT(pFramesOut != NULL); - MA_ASSERT(pFramesIn != NULL); + MA_ASSERT(pConverter != nullptr); + MA_ASSERT(pFramesOut != nullptr); + MA_ASSERT(pFramesIn != nullptr); /* This is the more complicated case. Each of the output channels is accumulated with 0 or more input channels. */ @@ -55828,15 +55828,15 @@ static ma_result ma_channel_converter_process_pcm_frames__weights(ma_channel_con MA_API ma_result ma_channel_converter_process_pcm_frames(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } - if (pFramesOut == NULL) { + if (pFramesOut == nullptr) { return MA_INVALID_ARGS; } - if (pFramesIn == NULL) { + if (pFramesIn == nullptr) { ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut)); return MA_SUCCESS; } @@ -55857,7 +55857,7 @@ MA_API ma_result ma_channel_converter_process_pcm_frames(ma_channel_converter* p MA_API ma_result ma_channel_converter_get_input_channel_map(const ma_channel_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap) { - if (pConverter == NULL || pChannelMap == NULL) { + if (pConverter == nullptr || pChannelMap == nullptr) { return MA_INVALID_ARGS; } @@ -55868,7 +55868,7 @@ MA_API ma_result ma_channel_converter_get_input_channel_map(const ma_channel_con MA_API ma_result ma_channel_converter_get_output_channel_map(const ma_channel_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap) { - if (pConverter == NULL || pChannelMap == NULL) { + if (pConverter == nullptr || pChannelMap == nullptr) { return MA_INVALID_ARGS; } @@ -55921,14 +55921,14 @@ typedef struct static ma_bool32 ma_data_converter_config_is_resampler_required(const ma_data_converter_config* pConfig) { - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); return pConfig->allowDynamicSampleRate || pConfig->sampleRateIn != pConfig->sampleRateOut; } static ma_format ma_data_converter_config_get_mid_format(const ma_data_converter_config* pConfig) { - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); /* We want to avoid as much data conversion as possible. The channel converter and linear @@ -55956,7 +55956,7 @@ static ma_channel_converter_config ma_channel_converter_config_init_from_data_co { ma_channel_converter_config channelConverterConfig; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); channelConverterConfig = ma_channel_converter_config_init(ma_data_converter_config_get_mid_format(pConfig), pConfig->channelsIn, pConfig->pChannelMapIn, pConfig->channelsOut, pConfig->pChannelMapOut, pConfig->channelMixMode); channelConverterConfig.ppWeights = pConfig->ppChannelWeights; @@ -55970,7 +55970,7 @@ static ma_resampler_config ma_resampler_config_init_from_data_converter_config(c ma_resampler_config resamplerConfig; ma_uint32 resamplerChannels; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); /* The resampler is the most expensive part of the conversion process, so we need to do it at the stage where the channel count is at it's lowest. */ if (pConfig->channelsIn < pConfig->channelsOut) { @@ -55991,11 +55991,11 @@ static ma_result ma_data_converter_get_heap_layout(const ma_data_converter_confi { ma_result result; - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -56044,7 +56044,7 @@ MA_API ma_result ma_data_converter_get_heap_size(const ma_data_converter_config* ma_result result; ma_data_converter_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -56067,7 +56067,7 @@ MA_API ma_result ma_data_converter_init_preallocated(const ma_data_converter_con ma_format midFormat; ma_bool32 isResamplingRequired; - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } @@ -56206,11 +56206,11 @@ MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_data_converter_init_preallocated(pConfig, pHeap, pConverter); @@ -56225,7 +56225,7 @@ MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, MA_API void ma_data_converter_uninit(ma_data_converter* pConverter, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return; } @@ -56246,32 +56246,32 @@ static ma_result ma_data_converter_process_pcm_frames__passthrough(ma_data_conve ma_uint64 frameCountOut; ma_uint64 frameCount; - MA_ASSERT(pConverter != NULL); + MA_ASSERT(pConverter != nullptr); frameCountIn = 0; - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { frameCountOut = *pFrameCountOut; } frameCount = ma_min(frameCountIn, frameCountOut); - if (pFramesOut != NULL) { - if (pFramesIn != NULL) { + if (pFramesOut != nullptr) { + if (pFramesIn != nullptr) { ma_copy_memory_64(pFramesOut, pFramesIn, frameCount * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } else { ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } } - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { *pFrameCountIn = frameCount; } - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = frameCount; } @@ -56284,32 +56284,32 @@ static ma_result ma_data_converter_process_pcm_frames__format_only(ma_data_conve ma_uint64 frameCountOut; ma_uint64 frameCount; - MA_ASSERT(pConverter != NULL); + MA_ASSERT(pConverter != nullptr); frameCountIn = 0; - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { frameCountOut = *pFrameCountOut; } frameCount = ma_min(frameCountIn, frameCountOut); - if (pFramesOut != NULL) { - if (pFramesIn != NULL) { + if (pFramesOut != nullptr) { + if (pFramesIn != nullptr) { ma_convert_pcm_frames_format(pFramesOut, pConverter->formatOut, pFramesIn, pConverter->formatIn, frameCount, pConverter->channelsIn, pConverter->ditherMode); } else { ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } } - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { *pFrameCountIn = frameCount; } - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = frameCount; } @@ -56325,15 +56325,15 @@ static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conv ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; - MA_ASSERT(pConverter != NULL); + MA_ASSERT(pConverter != nullptr); frameCountIn = 0; - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { frameCountOut = *pFrameCountOut; } @@ -56348,16 +56348,16 @@ static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conv ma_uint64 frameCountInThisIteration; ma_uint64 frameCountOutThisIteration; - if (pFramesIn != NULL) { + if (pFramesIn != nullptr) { pFramesInThisIteration = ma_offset_ptr(pFramesIn, framesProcessedIn * ma_get_bytes_per_frame(pConverter->formatIn, pConverter->channelsIn)); } else { - pFramesInThisIteration = NULL; + pFramesInThisIteration = nullptr; } - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } else { - pFramesOutThisIteration = NULL; + pFramesOutThisIteration = nullptr; } /* Do a pre format conversion if necessary. */ @@ -56376,7 +56376,7 @@ static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conv } } - if (pFramesInThisIteration != NULL) { + if (pFramesInThisIteration != nullptr) { ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.format, pFramesInThisIteration, pConverter->formatIn, frameCountInThisIteration, pConverter->channelsIn, pConverter->ditherMode); } else { MA_ZERO_MEMORY(pTempBufferIn, sizeof(pTempBufferIn)); @@ -56417,7 +56417,7 @@ static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conv /* If we are doing a post format conversion we need to do that now. */ if (pConverter->hasPostFormatConversion) { - if (pFramesOutThisIteration != NULL) { + if (pFramesOutThisIteration != nullptr) { ma_convert_pcm_frames_format(pFramesOutThisIteration, pConverter->formatOut, pTempBufferOut, pConverter->resampler.format, frameCountOutThisIteration, pConverter->resampler.channels, pConverter->ditherMode); } } @@ -56433,10 +56433,10 @@ static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conv } } - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { *pFrameCountIn = framesProcessedIn; } - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = framesProcessedOut; } @@ -56445,7 +56445,7 @@ static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conv static ma_result ma_data_converter_process_pcm_frames__resample_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { - MA_ASSERT(pConverter != NULL); + MA_ASSERT(pConverter != nullptr); if (pConverter->hasPreFormatConversion == MA_FALSE && pConverter->hasPostFormatConversion == MA_FALSE) { /* Neither pre- nor post-format required. This is simple case where only resampling is required. */ @@ -56463,15 +56463,15 @@ static ma_result ma_data_converter_process_pcm_frames__channels_only(ma_data_con ma_uint64 frameCountOut; ma_uint64 frameCount; - MA_ASSERT(pConverter != NULL); + MA_ASSERT(pConverter != nullptr); frameCountIn = 0; - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { frameCountOut = *pFrameCountOut; } @@ -56494,16 +56494,16 @@ static ma_result ma_data_converter_process_pcm_frames__channels_only(ma_data_con /* */ void* pFramesOutThisIteration; ma_uint64 frameCountThisIteration; - if (pFramesIn != NULL) { + if (pFramesIn != nullptr) { pFramesInThisIteration = ma_offset_ptr(pFramesIn, framesProcessed * ma_get_bytes_per_frame(pConverter->formatIn, pConverter->channelsIn)); } else { - pFramesInThisIteration = NULL; + pFramesInThisIteration = nullptr; } - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessed * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } else { - pFramesOutThisIteration = NULL; + pFramesOutThisIteration = nullptr; } /* Do a pre format conversion if necessary. */ @@ -56522,7 +56522,7 @@ static ma_result ma_data_converter_process_pcm_frames__channels_only(ma_data_con } } - if (pFramesInThisIteration != NULL) { + if (pFramesInThisIteration != nullptr) { ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pFramesInThisIteration, pConverter->formatIn, frameCountThisIteration, pConverter->channelsIn, pConverter->ditherMode); } else { MA_ZERO_MEMORY(pTempBufferIn, sizeof(pTempBufferIn)); @@ -56556,7 +56556,7 @@ static ma_result ma_data_converter_process_pcm_frames__channels_only(ma_data_con /* If we are doing a post format conversion we need to do that now. */ if (pConverter->hasPostFormatConversion) { - if (pFramesOutThisIteration != NULL) { + if (pFramesOutThisIteration != nullptr) { ma_convert_pcm_frames_format(pFramesOutThisIteration, pConverter->formatOut, pTempBufferOut, pConverter->channelConverter.format, frameCountThisIteration, pConverter->channelConverter.channelsOut, pConverter->ditherMode); } } @@ -56565,10 +56565,10 @@ static ma_result ma_data_converter_process_pcm_frames__channels_only(ma_data_con } } - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { *pFrameCountIn = frameCount; } - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = frameCount; } @@ -56589,18 +56589,18 @@ static ma_result ma_data_converter_process_pcm_frames__resample_first(ma_data_co ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In channel converter output format. */ ma_uint64 tempBufferOutCap; - MA_ASSERT(pConverter != NULL); + MA_ASSERT(pConverter != nullptr); MA_ASSERT(pConverter->resampler.format == pConverter->channelConverter.format); MA_ASSERT(pConverter->resampler.channels == pConverter->channelConverter.channelsIn); MA_ASSERT(pConverter->resampler.channels < pConverter->channelConverter.channelsOut); frameCountIn = 0; - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { frameCountOut = *pFrameCountOut; } @@ -56614,15 +56614,15 @@ static ma_result ma_data_converter_process_pcm_frames__resample_first(ma_data_co while (framesProcessedOut < frameCountOut) { ma_uint64 frameCountInThisIteration; ma_uint64 frameCountOutThisIteration; - const void* pRunningFramesIn = NULL; - void* pRunningFramesOut = NULL; + const void* pRunningFramesIn = nullptr; + void* pRunningFramesOut = nullptr; const void* pResampleBufferIn; void* pChannelsBufferOut; - if (pFramesIn != NULL) { + if (pFramesIn != nullptr) { pRunningFramesIn = ma_offset_ptr(pFramesIn, framesProcessedIn * ma_get_bytes_per_frame(pConverter->formatIn, pConverter->channelsIn)); } - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { pRunningFramesOut = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } @@ -56671,11 +56671,11 @@ static ma_result ma_data_converter_process_pcm_frames__resample_first(ma_data_co #endif if (pConverter->hasPreFormatConversion) { - if (pFramesIn != NULL) { + if (pFramesIn != nullptr) { ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.format, pRunningFramesIn, pConverter->formatIn, frameCountInThisIteration, pConverter->channelsIn, pConverter->ditherMode); pResampleBufferIn = pTempBufferIn; } else { - pResampleBufferIn = NULL; + pResampleBufferIn = nullptr; } } else { pResampleBufferIn = pRunningFramesIn; @@ -56691,7 +56691,7 @@ static ma_result ma_data_converter_process_pcm_frames__resample_first(ma_data_co The input data has been resampled so now we need to run it through the channel converter. The input data is always contained in pTempBufferMid. We only need to do this part if we have an output buffer. */ - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { if (pConverter->hasPostFormatConversion) { pChannelsBufferOut = pTempBufferOut; } else { @@ -56721,10 +56721,10 @@ static ma_result ma_data_converter_process_pcm_frames__resample_first(ma_data_co } } - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { *pFrameCountIn = framesProcessedIn; } - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = framesProcessedOut; } @@ -56745,18 +56745,18 @@ static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_co ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In channel converter output format. */ ma_uint64 tempBufferOutCap; - MA_ASSERT(pConverter != NULL); + MA_ASSERT(pConverter != nullptr); MA_ASSERT(pConverter->resampler.format == pConverter->channelConverter.format); MA_ASSERT(pConverter->resampler.channels == pConverter->channelConverter.channelsOut); MA_ASSERT(pConverter->resampler.channels <= pConverter->channelConverter.channelsIn); frameCountIn = 0; - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { frameCountOut = *pFrameCountOut; } @@ -56770,15 +56770,15 @@ static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_co while (framesProcessedOut < frameCountOut) { ma_uint64 frameCountInThisIteration; ma_uint64 frameCountOutThisIteration; - const void* pRunningFramesIn = NULL; - void* pRunningFramesOut = NULL; + const void* pRunningFramesIn = nullptr; + void* pRunningFramesOut = nullptr; const void* pChannelsBufferIn; void* pResampleBufferOut; - if (pFramesIn != NULL) { + if (pFramesIn != nullptr) { pRunningFramesIn = ma_offset_ptr(pFramesIn, framesProcessedIn * ma_get_bytes_per_frame(pConverter->formatIn, pConverter->channelsIn)); } - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { pRunningFramesOut = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } @@ -56835,11 +56835,11 @@ static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_co /* Pre format conversion. */ if (pConverter->hasPreFormatConversion) { - if (pRunningFramesIn != NULL) { + if (pRunningFramesIn != nullptr) { ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pRunningFramesIn, pConverter->formatIn, frameCountInThisIteration, pConverter->channelsIn, pConverter->ditherMode); pChannelsBufferIn = pTempBufferIn; } else { - pChannelsBufferIn = NULL; + pChannelsBufferIn = nullptr; } } else { pChannelsBufferIn = pRunningFramesIn; @@ -56868,7 +56868,7 @@ static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_co /* Post format conversion. */ if (pConverter->hasPostFormatConversion) { - if (pRunningFramesOut != NULL) { + if (pRunningFramesOut != nullptr) { ma_convert_pcm_frames_format(pRunningFramesOut, pConverter->formatOut, pResampleBufferOut, pConverter->resampler.format, frameCountOutThisIteration, pConverter->channelsOut, pConverter->ditherMode); } } @@ -56885,10 +56885,10 @@ static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_co } } - if (pFrameCountIn != NULL) { + if (pFrameCountIn != nullptr) { *pFrameCountIn = framesProcessedIn; } - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = framesProcessedOut; } @@ -56897,7 +56897,7 @@ static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_co MA_API ma_result ma_data_converter_process_pcm_frames(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } @@ -56915,7 +56915,7 @@ MA_API ma_result ma_data_converter_process_pcm_frames(ma_data_converter* pConver MA_API ma_result ma_data_converter_set_rate(ma_data_converter* pConverter, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } @@ -56928,7 +56928,7 @@ MA_API ma_result ma_data_converter_set_rate(ma_data_converter* pConverter, ma_ui MA_API ma_result ma_data_converter_set_rate_ratio(ma_data_converter* pConverter, float ratioInOut) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } @@ -56941,7 +56941,7 @@ MA_API ma_result ma_data_converter_set_rate_ratio(ma_data_converter* pConverter, MA_API ma_uint64 ma_data_converter_get_input_latency(const ma_data_converter* pConverter) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return 0; } @@ -56954,7 +56954,7 @@ MA_API ma_uint64 ma_data_converter_get_input_latency(const ma_data_converter* pC MA_API ma_uint64 ma_data_converter_get_output_latency(const ma_data_converter* pConverter) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return 0; } @@ -56967,13 +56967,13 @@ MA_API ma_uint64 ma_data_converter_get_output_latency(const ma_data_converter* p MA_API ma_result ma_data_converter_get_required_input_frame_count(const ma_data_converter* pConverter, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount) { - if (pInputFrameCount == NULL) { + if (pInputFrameCount == nullptr) { return MA_INVALID_ARGS; } *pInputFrameCount = 0; - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } @@ -56987,13 +56987,13 @@ MA_API ma_result ma_data_converter_get_required_input_frame_count(const ma_data_ MA_API ma_result ma_data_converter_get_expected_output_frame_count(const ma_data_converter* pConverter, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount) { - if (pOutputFrameCount == NULL) { + if (pOutputFrameCount == nullptr) { return MA_INVALID_ARGS; } *pOutputFrameCount = 0; - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } @@ -57007,7 +57007,7 @@ MA_API ma_result ma_data_converter_get_expected_output_frame_count(const ma_data MA_API ma_result ma_data_converter_get_input_channel_map(const ma_data_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap) { - if (pConverter == NULL || pChannelMap == NULL) { + if (pConverter == nullptr || pChannelMap == nullptr) { return MA_INVALID_ARGS; } @@ -57022,7 +57022,7 @@ MA_API ma_result ma_data_converter_get_input_channel_map(const ma_data_converter MA_API ma_result ma_data_converter_get_output_channel_map(const ma_data_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap) { - if (pConverter == NULL || pChannelMap == NULL) { + if (pConverter == nullptr || pChannelMap == nullptr) { return MA_INVALID_ARGS; } @@ -57037,7 +57037,7 @@ MA_API ma_result ma_data_converter_get_output_channel_map(const ma_data_converte MA_API ma_result ma_data_converter_reset(ma_data_converter* pConverter) { - if (pConverter == NULL) { + if (pConverter == nullptr) { return MA_INVALID_ARGS; } @@ -57060,7 +57060,7 @@ static ma_channel ma_channel_map_init_standard_channel(ma_standard_channel_map s MA_API ma_channel ma_channel_map_get_channel(const ma_channel* pChannelMap, ma_uint32 channelCount, ma_uint32 channelIndex) { - if (pChannelMap == NULL) { + if (pChannelMap == nullptr) { return ma_channel_map_init_standard_channel(ma_standard_channel_map_default, channelCount, channelIndex); } else { if (channelIndex >= channelCount) { @@ -57073,7 +57073,7 @@ MA_API ma_channel ma_channel_map_get_channel(const ma_channel* pChannelMap, ma_u MA_API void ma_channel_map_init_blank(ma_channel* pChannelMap, ma_uint32 channels) { - if (pChannelMap == NULL) { + if (pChannelMap == nullptr) { return; } @@ -57793,7 +57793,7 @@ MA_API void ma_channel_map_init_standard(ma_standard_channel_map standardChannel { ma_uint32 iChannel; - if (pChannelMap == NULL || channelMapCap == 0 || channels == 0) { + if (pChannelMap == nullptr || channelMapCap == 0 || channels == 0) { return; } @@ -57810,18 +57810,18 @@ MA_API void ma_channel_map_init_standard(ma_standard_channel_map standardChannel MA_API void ma_channel_map_copy(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels) { - if (pOut != NULL && pIn != NULL && channels > 0) { + if (pOut != nullptr && pIn != nullptr && channels > 0) { MA_COPY_MEMORY(pOut, pIn, sizeof(*pOut) * channels); } } MA_API void ma_channel_map_copy_or_default(ma_channel* pOut, size_t channelMapCapOut, const ma_channel* pIn, ma_uint32 channels) { - if (pOut == NULL || channels == 0) { + if (pOut == nullptr || channels == 0) { return; } - if (pIn != NULL) { + if (pIn != nullptr) { ma_channel_map_copy(pOut, pIn, channels); } else { ma_channel_map_init_standard(ma_standard_channel_map_default, pOut, channelMapCapOut, channels); @@ -57870,7 +57870,7 @@ MA_API ma_bool32 ma_channel_map_is_blank(const ma_channel* pChannelMap, ma_uint3 ma_uint32 iChannel; /* A null channel map is equivalent to the default channel map. */ - if (pChannelMap == NULL) { + if (pChannelMap == nullptr) { return MA_FALSE; } @@ -57885,20 +57885,20 @@ MA_API ma_bool32 ma_channel_map_is_blank(const ma_channel* pChannelMap, ma_uint3 MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition) { - return ma_channel_map_find_channel_position(channels, pChannelMap, channelPosition, NULL); + return ma_channel_map_find_channel_position(channels, pChannelMap, channelPosition, nullptr); } MA_API ma_bool32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition, ma_uint32* pChannelIndex) { ma_uint32 iChannel; - if (pChannelIndex != NULL) { + if (pChannelIndex != nullptr) { *pChannelIndex = (ma_uint32)-1; } for (iChannel = 0; iChannel < channels; ++iChannel) { if (ma_channel_map_get_channel(pChannelMap, channels, iChannel) == channelPosition) { - if (pChannelIndex != NULL) { + if (pChannelIndex != nullptr) { *pChannelIndex = iChannel; } @@ -57922,14 +57922,14 @@ MA_API size_t ma_channel_map_to_string(const ma_channel* pChannelMap, ma_uint32 size_t channelStrLen = strlen(pChannelStr); /* Append the string if necessary. */ - if (pBufferOut != NULL && bufferCap > len + channelStrLen) { + if (pBufferOut != nullptr && bufferCap > len + channelStrLen) { MA_COPY_MEMORY(pBufferOut + len, pChannelStr, channelStrLen); } len += channelStrLen; /* Append a space if it's not the last item. */ if (iChannel+1 < channels) { - if (pBufferOut != NULL && bufferCap > len + 1) { + if (pBufferOut != nullptr && bufferCap > len + 1) { pBufferOut[len] = ' '; } len += 1; @@ -57937,7 +57937,7 @@ MA_API size_t ma_channel_map_to_string(const ma_channel* pChannelMap, ma_uint32 } /* Null terminate. Don't increment the length here. */ - if (pBufferOut != NULL) { + if (pBufferOut != nullptr) { if (bufferCap > len) { pBufferOut[len] = '\0'; } else if (bufferCap > 0) { @@ -58032,16 +58032,16 @@ MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const ma_result result; ma_data_converter converter; - if (frameCountIn == 0 || pConfig == NULL) { + if (frameCountIn == 0 || pConfig == nullptr) { return 0; } - result = ma_data_converter_init(pConfig, NULL, &converter); + result = ma_data_converter_init(pConfig, nullptr, &converter); if (result != MA_SUCCESS) { return 0; /* Failed to initialize the data converter. */ } - if (pOut == NULL) { + if (pOut == nullptr) { result = ma_data_converter_get_expected_output_frame_count(&converter, frameCountIn, &frameCountOut); if (result != MA_SUCCESS) { if (result == MA_NOT_IMPLEMENTED) { @@ -58052,7 +58052,7 @@ MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const ma_uint64 framesProcessedIn = frameCountIn; ma_uint64 framesProcessedOut = 0xFFFFFFFF; - result = ma_data_converter_process_pcm_frames(&converter, pIn, &framesProcessedIn, NULL, &framesProcessedOut); + result = ma_data_converter_process_pcm_frames(&converter, pIn, &framesProcessedIn, nullptr, &framesProcessedOut); if (result != MA_SUCCESS) { break; } @@ -58068,7 +58068,7 @@ MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const } } - ma_data_converter_uninit(&converter, NULL); + ma_data_converter_uninit(&converter, nullptr); return frameCountOut; } @@ -58090,13 +58090,13 @@ static MA_INLINE ma_uint32 ma_rb__extract_offset_loop_flag(ma_uint32 encodedOffs static MA_INLINE void* ma_rb__get_read_ptr(ma_rb* pRB) { - MA_ASSERT(pRB != NULL); + MA_ASSERT(pRB != nullptr); return ma_offset_ptr(pRB->pBuffer, ma_rb__extract_offset_in_bytes(ma_atomic_load_32(&pRB->encodedReadOffset))); } static MA_INLINE void* ma_rb__get_write_ptr(ma_rb* pRB) { - MA_ASSERT(pRB != NULL); + MA_ASSERT(pRB != nullptr); return ma_offset_ptr(pRB->pBuffer, ma_rb__extract_offset_in_bytes(ma_atomic_load_32(&pRB->encodedWriteOffset))); } @@ -58107,8 +58107,8 @@ static MA_INLINE ma_uint32 ma_rb__construct_offset(ma_uint32 offsetInBytes, ma_u static MA_INLINE void ma_rb__deconstruct_offset(ma_uint32 encodedOffset, ma_uint32* pOffsetInBytes, ma_uint32* pOffsetLoopFlag) { - MA_ASSERT(pOffsetInBytes != NULL); - MA_ASSERT(pOffsetLoopFlag != NULL); + MA_ASSERT(pOffsetInBytes != nullptr); + MA_ASSERT(pOffsetLoopFlag != nullptr); *pOffsetInBytes = ma_rb__extract_offset_in_bytes(encodedOffset); *pOffsetLoopFlag = ma_rb__extract_offset_loop_flag(encodedOffset); @@ -58120,7 +58120,7 @@ MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCoun ma_result result; const ma_uint32 maxSubBufferSize = 0x7FFFFFFF - (MA_SIMD_ALIGNMENT-1); - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58143,7 +58143,7 @@ MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCoun pRB->subbufferSizeInBytes = (ma_uint32)subbufferSizeInBytes; pRB->subbufferCount = (ma_uint32)subbufferCount; - if (pOptionalPreallocatedBuffer != NULL) { + if (pOptionalPreallocatedBuffer != nullptr) { pRB->subbufferStrideInBytes = (ma_uint32)subbufferStrideInBytes; pRB->pBuffer = pOptionalPreallocatedBuffer; } else { @@ -58157,7 +58157,7 @@ MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCoun bufferSizeInBytes = (size_t)pRB->subbufferCount*pRB->subbufferStrideInBytes; pRB->pBuffer = ma_aligned_malloc(bufferSizeInBytes, MA_SIMD_ALIGNMENT, &pRB->allocationCallbacks); - if (pRB->pBuffer == NULL) { + if (pRB->pBuffer == nullptr) { return MA_OUT_OF_MEMORY; } @@ -58175,7 +58175,7 @@ MA_API ma_result ma_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocate MA_API void ma_rb_uninit(ma_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return; } @@ -58186,7 +58186,7 @@ MA_API void ma_rb_uninit(ma_rb* pRB) MA_API void ma_rb_reset(ma_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return; } @@ -58205,7 +58205,7 @@ MA_API ma_result ma_rb_acquire_read(ma_rb* pRB, size_t* pSizeInBytes, void** ppB size_t bytesAvailable; size_t bytesRequested; - if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) { + if (pRB == nullptr || pSizeInBytes == nullptr || ppBufferOut == nullptr) { return MA_INVALID_ARGS; } @@ -58245,7 +58245,7 @@ MA_API ma_result ma_rb_commit_read(ma_rb* pRB, size_t sizeInBytes) ma_uint32 newReadOffsetInBytes; ma_uint32 newReadOffsetLoopFlag; - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58281,7 +58281,7 @@ MA_API ma_result ma_rb_acquire_write(ma_rb* pRB, size_t* pSizeInBytes, void** pp size_t bytesAvailable; size_t bytesRequested; - if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) { + if (pRB == nullptr || pSizeInBytes == nullptr || ppBufferOut == nullptr) { return MA_INVALID_ARGS; } @@ -58327,7 +58327,7 @@ MA_API ma_result ma_rb_commit_write(ma_rb* pRB, size_t sizeInBytes) ma_uint32 newWriteOffsetInBytes; ma_uint32 newWriteOffsetLoopFlag; - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58363,7 +58363,7 @@ MA_API ma_result ma_rb_seek_read(ma_rb* pRB, size_t offsetInBytes) ma_uint32 newReadOffsetInBytes; ma_uint32 newReadOffsetLoopFlag; - if (pRB == NULL || offsetInBytes > pRB->subbufferSizeInBytes) { + if (pRB == nullptr || offsetInBytes > pRB->subbufferSizeInBytes) { return MA_INVALID_ARGS; } @@ -58407,7 +58407,7 @@ MA_API ma_result ma_rb_seek_write(ma_rb* pRB, size_t offsetInBytes) ma_uint32 newWriteOffsetInBytes; ma_uint32 newWriteOffsetLoopFlag; - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58449,7 +58449,7 @@ MA_API ma_int32 ma_rb_pointer_distance(ma_rb* pRB) ma_uint32 writeOffsetInBytes; ma_uint32 writeOffsetLoopFlag; - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58470,7 +58470,7 @@ MA_API ma_uint32 ma_rb_available_read(ma_rb* pRB) { ma_int32 dist; - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58484,7 +58484,7 @@ MA_API ma_uint32 ma_rb_available_read(ma_rb* pRB) MA_API ma_uint32 ma_rb_available_write(ma_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58493,7 +58493,7 @@ MA_API ma_uint32 ma_rb_available_write(ma_rb* pRB) MA_API size_t ma_rb_get_subbuffer_size(ma_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58502,7 +58502,7 @@ MA_API size_t ma_rb_get_subbuffer_size(ma_rb* pRB) MA_API size_t ma_rb_get_subbuffer_stride(ma_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58515,7 +58515,7 @@ MA_API size_t ma_rb_get_subbuffer_stride(ma_rb* pRB) MA_API size_t ma_rb_get_subbuffer_offset(ma_rb* pRB, size_t subbufferIndex) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58524,8 +58524,8 @@ MA_API size_t ma_rb_get_subbuffer_offset(ma_rb* pRB, size_t subbufferIndex) MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pBuffer) { - if (pRB == NULL) { - return NULL; + if (pRB == nullptr) { + return nullptr; } return ma_offset_ptr(pBuffer, ma_rb_get_subbuffer_offset(pRB, subbufferIndex)); @@ -58540,7 +58540,7 @@ static ma_result ma_pcm_rb_data_source__on_read(ma_data_source* pDataSource, voi ma_result result; ma_uint64 totalFramesRead; - MA_ASSERT(pRB != NULL); + MA_ASSERT(pRB != nullptr); /* We need to run this in a loop since the ring buffer itself may loop. */ totalFramesRead = 0; @@ -58589,22 +58589,22 @@ static ma_result ma_pcm_rb_data_source__on_read(ma_data_source* pDataSource, voi static ma_result ma_pcm_rb_data_source__on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { ma_pcm_rb* pRB = (ma_pcm_rb*)pDataSource; - MA_ASSERT(pRB != NULL); + MA_ASSERT(pRB != nullptr); - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = pRB->format; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = pRB->channels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = pRB->sampleRate; } /* Just assume the default channel map. */ - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pRB->channels); } @@ -58614,17 +58614,17 @@ static ma_result ma_pcm_rb_data_source__on_get_data_format(ma_data_source* pData static ma_data_source_vtable ma_gRBDataSourceVTable = { ma_pcm_rb_data_source__on_read, - NULL, /* onSeek */ + nullptr, /* onSeek */ ma_pcm_rb_data_source__on_get_data_format, - NULL, /* onGetCursor */ - NULL, /* onGetLength */ - NULL, /* onSetLooping */ + nullptr, /* onGetCursor */ + nullptr, /* onGetLength */ + nullptr, /* onSetLooping */ 0 }; static MA_INLINE ma_uint32 ma_pcm_rb_get_bpf(ma_pcm_rb* pRB) { - MA_ASSERT(pRB != NULL); + MA_ASSERT(pRB != nullptr); return ma_get_bytes_per_frame(pRB->format, pRB->channels); } @@ -58634,7 +58634,7 @@ MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint ma_uint32 bpf; ma_result result; - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58676,7 +58676,7 @@ MA_API ma_result ma_pcm_rb_init(ma_format format, ma_uint32 channels, ma_uint32 MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return; } @@ -58686,7 +58686,7 @@ MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB) MA_API void ma_pcm_rb_reset(ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return; } @@ -58698,7 +58698,7 @@ MA_API ma_result ma_pcm_rb_acquire_read(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames size_t sizeInBytes; ma_result result; - if (pRB == NULL || pSizeInFrames == NULL) { + if (pRB == nullptr || pSizeInFrames == nullptr) { return MA_INVALID_ARGS; } @@ -58715,7 +58715,7 @@ MA_API ma_result ma_pcm_rb_acquire_read(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames MA_API ma_result ma_pcm_rb_commit_read(ma_pcm_rb* pRB, ma_uint32 sizeInFrames) { - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58727,7 +58727,7 @@ MA_API ma_result ma_pcm_rb_acquire_write(ma_pcm_rb* pRB, ma_uint32* pSizeInFrame size_t sizeInBytes; ma_result result; - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58744,7 +58744,7 @@ MA_API ma_result ma_pcm_rb_acquire_write(ma_pcm_rb* pRB, ma_uint32* pSizeInFrame MA_API ma_result ma_pcm_rb_commit_write(ma_pcm_rb* pRB, ma_uint32 sizeInFrames) { - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58753,7 +58753,7 @@ MA_API ma_result ma_pcm_rb_commit_write(ma_pcm_rb* pRB, ma_uint32 sizeInFrames) MA_API ma_result ma_pcm_rb_seek_read(ma_pcm_rb* pRB, ma_uint32 offsetInFrames) { - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58762,7 +58762,7 @@ MA_API ma_result ma_pcm_rb_seek_read(ma_pcm_rb* pRB, ma_uint32 offsetInFrames) MA_API ma_result ma_pcm_rb_seek_write(ma_pcm_rb* pRB, ma_uint32 offsetInFrames) { - if (pRB == NULL) { + if (pRB == nullptr) { return MA_INVALID_ARGS; } @@ -58771,7 +58771,7 @@ MA_API ma_result ma_pcm_rb_seek_write(ma_pcm_rb* pRB, ma_uint32 offsetInFrames) MA_API ma_int32 ma_pcm_rb_pointer_distance(ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58780,7 +58780,7 @@ MA_API ma_int32 ma_pcm_rb_pointer_distance(ma_pcm_rb* pRB) MA_API ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58789,7 +58789,7 @@ MA_API ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb* pRB) MA_API ma_uint32 ma_pcm_rb_available_write(ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58798,7 +58798,7 @@ MA_API ma_uint32 ma_pcm_rb_available_write(ma_pcm_rb* pRB) MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58807,7 +58807,7 @@ MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB) MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58816,7 +58816,7 @@ MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB) MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbufferIndex) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58825,8 +58825,8 @@ MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbuf MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferIndex, void* pBuffer) { - if (pRB == NULL) { - return NULL; + if (pRB == nullptr) { + return nullptr; } return ma_rb_get_subbuffer_ptr(&pRB->rb, subbufferIndex, pBuffer); @@ -58834,7 +58834,7 @@ MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferInde MA_API ma_format ma_pcm_rb_get_format(const ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return ma_format_unknown; } @@ -58843,7 +58843,7 @@ MA_API ma_format ma_pcm_rb_get_format(const ma_pcm_rb* pRB) MA_API ma_uint32 ma_pcm_rb_get_channels(const ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58852,7 +58852,7 @@ MA_API ma_uint32 ma_pcm_rb_get_channels(const ma_pcm_rb* pRB) MA_API ma_uint32 ma_pcm_rb_get_sample_rate(const ma_pcm_rb* pRB) { - if (pRB == NULL) { + if (pRB == nullptr) { return 0; } @@ -58861,7 +58861,7 @@ MA_API ma_uint32 ma_pcm_rb_get_sample_rate(const ma_pcm_rb* pRB) MA_API void ma_pcm_rb_set_sample_rate(ma_pcm_rb* pRB, ma_uint32 sampleRate) { - if (pRB == NULL) { + if (pRB == nullptr) { return; } @@ -58880,7 +58880,7 @@ MA_API ma_result ma_duplex_rb_init(ma_format captureFormat, ma_uint32 captureCha return MA_INVALID_ARGS; } - result = ma_pcm_rb_init(captureFormat, captureChannels, sizeInFrames, NULL, pAllocationCallbacks, &pRB->rb); + result = ma_pcm_rb_init(captureFormat, captureChannels, sizeInFrames, nullptr, pAllocationCallbacks, &pRB->rb); if (result != MA_SUCCESS) { return result; } @@ -58984,21 +58984,21 @@ MA_API const char* ma_result_description(ma_result result) MA_API void* ma_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks != NULL) { - if (pAllocationCallbacks->onMalloc != NULL) { + if (pAllocationCallbacks != nullptr) { + if (pAllocationCallbacks->onMalloc != nullptr) { return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData); } else { - return NULL; /* Do not fall back to the default implementation. */ + return nullptr; /* Do not fall back to the default implementation. */ } } else { - return ma__malloc_default(sz, NULL); + return ma__malloc_default(sz, nullptr); } } MA_API void* ma_calloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { void* p = ma_malloc(sz, pAllocationCallbacks); - if (p != NULL) { + if (p != nullptr) { MA_ZERO_MEMORY(p, sz); } @@ -59007,31 +59007,31 @@ MA_API void* ma_calloc(size_t sz, const ma_allocation_callbacks* pAllocationCall MA_API void* ma_realloc(void* p, size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks != NULL) { - if (pAllocationCallbacks->onRealloc != NULL) { + if (pAllocationCallbacks != nullptr) { + if (pAllocationCallbacks->onRealloc != nullptr) { return pAllocationCallbacks->onRealloc(p, sz, pAllocationCallbacks->pUserData); } else { - return NULL; /* Do not fall back to the default implementation. */ + return nullptr; /* Do not fall back to the default implementation. */ } } else { - return ma__realloc_default(p, sz, NULL); + return ma__realloc_default(p, sz, nullptr); } } MA_API void ma_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { - if (p == NULL) { + if (p == nullptr) { return; } - if (pAllocationCallbacks != NULL) { - if (pAllocationCallbacks->onFree != NULL) { + if (pAllocationCallbacks != nullptr) { + if (pAllocationCallbacks->onFree != nullptr) { pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } else { return; /* Do no fall back to the default implementation. */ } } else { - ma__free_default(p, NULL); + ma__free_default(p, nullptr); } } @@ -59048,8 +59048,8 @@ MA_API void* ma_aligned_malloc(size_t sz, size_t alignment, const ma_allocation_ extraBytes = alignment-1 + sizeof(void*); pUnaligned = ma_malloc(sz + extraBytes, pAllocationCallbacks); - if (pUnaligned == NULL) { - return NULL; + if (pUnaligned == nullptr) { + return nullptr; } pAligned = (void*)(((ma_uintptr)pUnaligned + extraBytes) & ~((ma_uintptr)(alignment-1))); @@ -59120,17 +59120,17 @@ MA_API ma_result ma_data_source_init(const ma_data_source_config* pConfig, ma_da { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDataSourceBase); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - if (pConfig->vtable == NULL) { + if (pConfig->vtable == nullptr) { return MA_INVALID_ARGS; } @@ -59140,15 +59140,15 @@ MA_API ma_result ma_data_source_init(const ma_data_source_config* pConfig, ma_da pDataSourceBase->loopBegInFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG; pDataSourceBase->loopEndInFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END; pDataSourceBase->pCurrent = pDataSource; /* Always read from ourself by default. */ - pDataSourceBase->pNext = NULL; - pDataSourceBase->onGetNext = NULL; + pDataSourceBase->pNext = nullptr; + pDataSourceBase->onGetNext = nullptr; return MA_SUCCESS; } MA_API void ma_data_source_uninit(ma_data_source* pDataSource) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return; } @@ -59162,16 +59162,16 @@ static ma_result ma_data_source_resolve_current(ma_data_source* pDataSource, ma_ { ma_data_source_base* pCurrentDataSource = (ma_data_source_base*)pDataSource; - MA_ASSERT(pDataSource != NULL); - MA_ASSERT(ppCurrentDataSource != NULL); + MA_ASSERT(pDataSource != nullptr); + MA_ASSERT(ppCurrentDataSource != nullptr); - if (pCurrentDataSource->pCurrent == NULL) { + if (pCurrentDataSource->pCurrent == nullptr) { /* - The current data source is NULL. If we're using this in the context of a chain we need to return NULL + The current data source is nullptr. If we're using this in the context of a chain we need to return nullptr here so that we don't end up looping. Otherwise we just return the data source itself. */ - if (pCurrentDataSource->pNext != NULL || pCurrentDataSource->onGetNext != NULL) { - pCurrentDataSource = NULL; + if (pCurrentDataSource->pNext != nullptr || pCurrentDataSource->onGetNext != nullptr) { + pCurrentDataSource = nullptr; } else { pCurrentDataSource = (ma_data_source_base*)pDataSource; /* Not being used in a chain. Make sure we just always read from the data source itself at all times. */ } @@ -59188,12 +59188,12 @@ static ma_result ma_data_source_read_pcm_frames_from_backend(ma_data_source* pDa { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - MA_ASSERT(pDataSourceBase != NULL); - MA_ASSERT(pDataSourceBase->vtable != NULL); - MA_ASSERT(pDataSourceBase->vtable->onRead != NULL); - MA_ASSERT(pFramesRead != NULL); + MA_ASSERT(pDataSourceBase != nullptr); + MA_ASSERT(pDataSourceBase->vtable != nullptr); + MA_ASSERT(pDataSourceBase->vtable->onRead != nullptr); + MA_ASSERT(pFramesRead != nullptr); - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { return pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, pFramesRead); } else { /* @@ -59207,7 +59207,7 @@ static ma_result ma_data_source_read_pcm_frames_from_backend(ma_data_source* pDa ma_uint64 discardBufferCapInFrames; ma_uint8 pDiscardBuffer[4096]; - result = ma_data_source_get_data_format(pDataSource, &format, &channels, NULL, NULL, 0); + result = ma_data_source_get_data_format(pDataSource, &format, &channels, nullptr, nullptr, 0); if (result != MA_SUCCESS) { return result; } @@ -59243,7 +59243,7 @@ static ma_result ma_data_source_read_pcm_frames_within_range(ma_data_source* pDa ma_uint64 framesRead = 0; ma_bool32 loop = ma_data_source_is_looping(pDataSource); - if (pDataSourceBase == NULL) { + if (pDataSourceBase == nullptr) { return MA_AT_END; } @@ -59251,7 +59251,7 @@ static ma_result ma_data_source_read_pcm_frames_within_range(ma_data_source* pDa return MA_INVALID_ARGS; } - MA_ASSERT(pDataSourceBase->vtable != NULL); + MA_ASSERT(pDataSourceBase->vtable != nullptr); if ((pDataSourceBase->vtable->flags & MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT) != 0 || (pDataSourceBase->rangeEndInFrames == ~((ma_uint64)0) && (pDataSourceBase->loopEndInFrames == ~((ma_uint64)0) || loop == MA_FALSE))) { /* Either the data source is self-managing the range, or no range is set - just read like normal. The data source itself will tell us when the end is reached. */ @@ -59299,7 +59299,7 @@ static ma_result ma_data_source_read_pcm_frames_within_range(ma_data_source* pDa } } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = framesRead; } @@ -59323,7 +59323,7 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi ma_uint32 emptyLoopCounter = 0; /* Keeps track of how many times 0 frames have been read. For infinite loop detection of sounds with no audio data. */ ma_bool32 loop; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -59331,7 +59331,7 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi return MA_INVALID_ARGS; } - if (pDataSourceBase == NULL) { + if (pDataSourceBase == nullptr) { return MA_INVALID_ARGS; } @@ -59341,7 +59341,7 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi We need to know the data format so we can advance the output buffer as we read frames. If this fails, chaining will not work and we'll just read as much as we can from the current source. */ - if (ma_data_source_get_data_format(pDataSource, &format, &channels, NULL, NULL, 0) != MA_SUCCESS) { + if (ma_data_source_get_data_format(pDataSource, &format, &channels, nullptr, nullptr, 0) != MA_SUCCESS) { result = ma_data_source_resolve_current(pDataSource, (ma_data_source**)&pCurrentDataSource); if (result != MA_SUCCESS) { return result; @@ -59366,7 +59366,7 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi break; } - if (pCurrentDataSource == NULL) { + if (pCurrentDataSource == nullptr) { break; } @@ -59417,11 +59417,11 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi /* Don't return MA_AT_END for looping sounds. */ result = MA_SUCCESS; } else { - if (pCurrentDataSource->pNext != NULL) { + if (pCurrentDataSource->pNext != nullptr) { pDataSourceBase->pCurrent = pCurrentDataSource->pNext; - } else if (pCurrentDataSource->onGetNext != NULL) { + } else if (pCurrentDataSource->onGetNext != nullptr) { pDataSourceBase->pCurrent = pCurrentDataSource->onGetNext(pCurrentDataSource); - if (pDataSourceBase->pCurrent == NULL) { + if (pDataSourceBase->pCurrent == nullptr) { break; /* Our callback did not return a next data source. We're done. */ } } else { @@ -59437,12 +59437,12 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi } } - if (pRunningFramesOut != NULL) { + if (pRunningFramesOut != nullptr) { pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesProcessed * ma_get_bytes_per_frame(format, channels)); } } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesProcessed; } @@ -59457,18 +59457,18 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked) { - return ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount, pFramesSeeked); + return ma_data_source_read_pcm_frames(pDataSource, nullptr, frameCount, pFramesSeeked); } MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - if (pDataSourceBase == NULL) { + if (pDataSourceBase == nullptr) { return MA_INVALID_ARGS; } - if (pDataSourceBase->vtable->onSeek == NULL) { + if (pDataSourceBase->vtable->onSeek == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -59476,7 +59476,7 @@ MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, m return MA_INVALID_OPERATION; /* Trying to seek too far forward. */ } - MA_ASSERT(pDataSourceBase->vtable != NULL); + MA_ASSERT(pDataSourceBase->vtable != nullptr); return pDataSourceBase->vtable->onSeek(pDataSource, pDataSourceBase->rangeBegInFrames + frameIndex); } @@ -59488,11 +59488,11 @@ MA_API ma_result ma_data_source_seek_seconds(ma_data_source* pDataSource, float ma_uint32 sampleRate; ma_result result; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } - result = ma_data_source_get_data_format(pDataSource, NULL, NULL, &sampleRate, NULL, 0); + result = ma_data_source_get_data_format(pDataSource, nullptr, nullptr, &sampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; } @@ -59513,11 +59513,11 @@ MA_API ma_result ma_data_source_seek_to_second(ma_data_source* pDataSource, floa ma_uint32 sampleRate; ma_result result; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } - result = ma_data_source_get_data_format(pDataSource, NULL, NULL, &sampleRate, NULL, 0); + result = ma_data_source_get_data_format(pDataSource, nullptr, nullptr, &sampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; } @@ -59537,26 +59537,26 @@ MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_ ma_uint32 sampleRate; /* Initialize to defaults for safety just in case the data source does not implement this callback. */ - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = ma_format_unknown; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = 0; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = 0; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } - if (pDataSourceBase == NULL) { + if (pDataSourceBase == nullptr) { return MA_INVALID_ARGS; } - MA_ASSERT(pDataSourceBase->vtable != NULL); + MA_ASSERT(pDataSourceBase->vtable != nullptr); - if (pDataSourceBase->vtable->onGetDataFormat == NULL) { + if (pDataSourceBase->vtable->onGetDataFormat == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -59565,13 +59565,13 @@ MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_ return result; } - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = format; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = channels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = sampleRate; } @@ -59586,19 +59586,19 @@ MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSo ma_result result; ma_uint64 cursor; - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; - if (pDataSourceBase == NULL) { + if (pDataSourceBase == nullptr) { return MA_SUCCESS; } - MA_ASSERT(pDataSourceBase->vtable != NULL); + MA_ASSERT(pDataSourceBase->vtable != nullptr); - if (pDataSourceBase->vtable->onGetCursor == NULL) { + if (pDataSourceBase->vtable->onGetCursor == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -59621,17 +59621,17 @@ MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSo { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; - if (pDataSourceBase == NULL) { + if (pDataSourceBase == nullptr) { return MA_INVALID_ARGS; } - MA_ASSERT(pDataSourceBase->vtable != NULL); + MA_ASSERT(pDataSourceBase->vtable != nullptr); /* If we have a range defined we'll use that to determine the length. This is one of rare times @@ -59647,7 +59647,7 @@ MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSo Getting here means a range is not defined so we'll need to get the data source itself to tell us the length. */ - if (pDataSourceBase->vtable->onGetLength == NULL) { + if (pDataSourceBase->vtable->onGetLength == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -59660,7 +59660,7 @@ MA_API ma_result ma_data_source_get_cursor_in_seconds(ma_data_source* pDataSourc ma_uint64 cursorInPCMFrames; ma_uint32 sampleRate; - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } @@ -59671,7 +59671,7 @@ MA_API ma_result ma_data_source_get_cursor_in_seconds(ma_data_source* pDataSourc return result; } - result = ma_data_source_get_data_format(pDataSource, NULL, NULL, &sampleRate, NULL, 0); + result = ma_data_source_get_data_format(pDataSource, nullptr, nullptr, &sampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; } @@ -59688,7 +59688,7 @@ MA_API ma_result ma_data_source_get_length_in_seconds(ma_data_source* pDataSourc ma_uint64 lengthInPCMFrames; ma_uint32 sampleRate; - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } @@ -59699,7 +59699,7 @@ MA_API ma_result ma_data_source_get_length_in_seconds(ma_data_source* pDataSourc return result; } - result = ma_data_source_get_data_format(pDataSource, NULL, NULL, &sampleRate, NULL, 0); + result = ma_data_source_get_data_format(pDataSource, nullptr, nullptr, &sampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; } @@ -59714,16 +59714,16 @@ MA_API ma_result ma_data_source_set_looping(ma_data_source* pDataSource, ma_bool { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } ma_atomic_exchange_32(&pDataSourceBase->isLooping, isLooping); - MA_ASSERT(pDataSourceBase->vtable != NULL); + MA_ASSERT(pDataSourceBase->vtable != nullptr); /* If there's no callback for this just treat it as a successful no-op. */ - if (pDataSourceBase->vtable->onSetLooping == NULL) { + if (pDataSourceBase->vtable->onSetLooping == nullptr) { return MA_SUCCESS; } @@ -59734,7 +59734,7 @@ MA_API ma_bool32 ma_data_source_is_looping(const ma_data_source* pDataSource) { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_FALSE; } @@ -59749,7 +59749,7 @@ MA_API ma_result ma_data_source_set_range_in_pcm_frames(ma_data_source* pDataSou ma_uint64 absoluteCursor; ma_bool32 doSeekAdjustment = MA_FALSE; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -59812,22 +59812,22 @@ MA_API void ma_data_source_get_range_in_pcm_frames(const ma_data_source* pDataSo { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; - if (pRangeBegInFrames != NULL) { + if (pRangeBegInFrames != nullptr) { *pRangeBegInFrames = 0; } - if (pRangeEndInFrames != NULL) { + if (pRangeEndInFrames != nullptr) { *pRangeEndInFrames = 0; } - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return; } - if (pRangeBegInFrames != NULL) { + if (pRangeBegInFrames != nullptr) { *pRangeBegInFrames = pDataSourceBase->rangeBegInFrames; } - if (pRangeEndInFrames != NULL) { + if (pRangeEndInFrames != nullptr) { *pRangeEndInFrames = pDataSourceBase->rangeEndInFrames; } } @@ -59836,7 +59836,7 @@ MA_API ma_result ma_data_source_set_loop_point_in_pcm_frames(ma_data_source* pDa { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -59863,22 +59863,22 @@ MA_API void ma_data_source_get_loop_point_in_pcm_frames(const ma_data_source* pD { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; - if (pLoopBegInFrames != NULL) { + if (pLoopBegInFrames != nullptr) { *pLoopBegInFrames = 0; } - if (pLoopEndInFrames != NULL) { + if (pLoopEndInFrames != nullptr) { *pLoopEndInFrames = 0; } - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return; } - if (pLoopBegInFrames != NULL) { + if (pLoopBegInFrames != nullptr) { *pLoopBegInFrames = pDataSourceBase->loopBegInFrames; } - if (pLoopEndInFrames != NULL) { + if (pLoopEndInFrames != nullptr) { *pLoopEndInFrames = pDataSourceBase->loopEndInFrames; } } @@ -59887,7 +59887,7 @@ MA_API ma_result ma_data_source_set_current(ma_data_source* pDataSource, ma_data { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -59900,8 +59900,8 @@ MA_API ma_data_source* ma_data_source_get_current(const ma_data_source* pDataSou { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { - return NULL; + if (pDataSource == nullptr) { + return nullptr; } return pDataSourceBase->pCurrent; @@ -59911,7 +59911,7 @@ MA_API ma_result ma_data_source_set_next(ma_data_source* pDataSource, ma_data_so { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -59924,8 +59924,8 @@ MA_API ma_data_source* ma_data_source_get_next(const ma_data_source* pDataSource { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { - return NULL; + if (pDataSource == nullptr) { + return nullptr; } return pDataSourceBase->pNext; @@ -59935,7 +59935,7 @@ MA_API ma_result ma_data_source_set_next_callback(ma_data_source* pDataSource, m { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -59948,8 +59948,8 @@ MA_API ma_data_source_get_next_proc ma_data_source_get_next_callback(const ma_da { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; - if (pDataSource == NULL) { - return NULL; + if (pDataSource == nullptr) { + return nullptr; } return pDataSourceBase->onGetNext; @@ -59961,7 +59961,7 @@ static ma_result ma_audio_buffer_ref__data_source_on_read(ma_data_source* pDataS ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource; ma_uint64 framesRead = ma_audio_buffer_ref_read_pcm_frames(pAudioBufferRef, pFramesOut, frameCount, MA_FALSE); - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = framesRead; } @@ -60014,7 +60014,7 @@ static ma_data_source_vtable g_ma_audio_buffer_ref_data_source_vtable = ma_audio_buffer_ref__data_source_on_get_data_format, ma_audio_buffer_ref__data_source_on_get_cursor, ma_audio_buffer_ref__data_source_on_get_length, - NULL, /* onSetLooping */ + nullptr, /* onSetLooping */ 0 }; @@ -60023,7 +60023,7 @@ MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, ma_result result; ma_data_source_config dataSourceConfig; - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return MA_INVALID_ARGS; } @@ -60049,7 +60049,7 @@ MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, MA_API void ma_audio_buffer_ref_uninit(ma_audio_buffer_ref* pAudioBufferRef) { - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return; } @@ -60058,7 +60058,7 @@ MA_API void ma_audio_buffer_ref_uninit(ma_audio_buffer_ref* pAudioBufferRef) MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames) { - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return MA_INVALID_ARGS; } @@ -60073,7 +60073,7 @@ MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudio { ma_uint64 totalFramesRead = 0; - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return 0; } @@ -60091,7 +60091,7 @@ MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudio framesToRead = framesAvailable; } - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { ma_copy_pcm_frames(ma_offset_ptr(pFramesOut, totalFramesRead * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels)), ma_offset_ptr(pAudioBufferRef->pData, pAudioBufferRef->cursor * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels)), framesToRead, pAudioBufferRef->format, pAudioBufferRef->channels); } @@ -60114,7 +60114,7 @@ MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudio MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex) { - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return MA_INVALID_ARGS; } @@ -60132,16 +60132,16 @@ MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, v ma_uint64 framesAvailable; ma_uint64 frameCount = 0; - if (ppFramesOut != NULL) { - *ppFramesOut = NULL; /* Safety. */ + if (ppFramesOut != nullptr) { + *ppFramesOut = nullptr; /* Safety. */ } - if (pFrameCount != NULL) { + if (pFrameCount != nullptr) { frameCount = *pFrameCount; *pFrameCount = 0; /* Safety. */ } - if (pAudioBufferRef == NULL || ppFramesOut == NULL || pFrameCount == NULL) { + if (pAudioBufferRef == nullptr || ppFramesOut == nullptr || pFrameCount == nullptr) { return MA_INVALID_ARGS; } @@ -60160,7 +60160,7 @@ MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, { ma_uint64 framesAvailable; - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return MA_INVALID_ARGS; } @@ -60180,7 +60180,7 @@ MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, MA_API ma_bool32 ma_audio_buffer_ref_at_end(const ma_audio_buffer_ref* pAudioBufferRef) { - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return MA_FALSE; } @@ -60189,13 +60189,13 @@ MA_API ma_bool32 ma_audio_buffer_ref_at_end(const ma_audio_buffer_ref* pAudioBuf MA_API ma_result ma_audio_buffer_ref_get_cursor_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return MA_INVALID_ARGS; } @@ -60206,13 +60206,13 @@ MA_API ma_result ma_audio_buffer_ref_get_cursor_in_pcm_frames(const ma_audio_buf MA_API ma_result ma_audio_buffer_ref_get_length_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pLength) { - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return MA_INVALID_ARGS; } @@ -60223,13 +60223,13 @@ MA_API ma_result ma_audio_buffer_ref_get_length_in_pcm_frames(const ma_audio_buf MA_API ma_result ma_audio_buffer_ref_get_available_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames) { - if (pAvailableFrames == NULL) { + if (pAvailableFrames == nullptr) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; - if (pAudioBufferRef == NULL) { + if (pAudioBufferRef == nullptr) { return MA_INVALID_ARGS; } @@ -60264,13 +60264,13 @@ static ma_result ma_audio_buffer_init_ex(const ma_audio_buffer_config* pConfig, { ma_result result; - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_MEMORY(pAudioBuffer, sizeof(*pAudioBuffer) - sizeof(pAudioBuffer->_pExtraData)); /* Safety. Don't overwrite the extra data. */ - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -60278,7 +60278,7 @@ static ma_result ma_audio_buffer_init_ex(const ma_audio_buffer_config* pConfig, return MA_INVALID_ARGS; /* Not allowing buffer sizes of 0 frames. */ } - result = ma_audio_buffer_ref_init(pConfig->format, pConfig->channels, NULL, 0, &pAudioBuffer->ref); + result = ma_audio_buffer_ref_init(pConfig->format, pConfig->channels, nullptr, 0, &pAudioBuffer->ref); if (result != MA_SUCCESS) { return result; } @@ -60298,11 +60298,11 @@ static ma_result ma_audio_buffer_init_ex(const ma_audio_buffer_config* pConfig, } pData = ma_malloc((size_t)allocationSizeInBytes, &pAudioBuffer->allocationCallbacks); /* Safe cast to size_t. */ - if (pData == NULL) { + if (pData == nullptr) { return MA_OUT_OF_MEMORY; } - if (pConfig->pData != NULL) { + if (pConfig->pData != nullptr) { ma_copy_pcm_frames(pData, pConfig->pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels); } else { ma_silence_pcm_frames(pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels); @@ -60320,7 +60320,7 @@ static ma_result ma_audio_buffer_init_ex(const ma_audio_buffer_config* pConfig, static void ma_audio_buffer_uninit_ex(ma_audio_buffer* pAudioBuffer, ma_bool32 doFree) { - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return; } @@ -60352,13 +60352,13 @@ MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pC ma_audio_buffer_config innerConfig; /* We'll be making some changes to the config, so need to make a copy. */ ma_uint64 allocationSizeInBytes; - if (ppAudioBuffer == NULL) { + if (ppAudioBuffer == nullptr) { return MA_INVALID_ARGS; } - *ppAudioBuffer = NULL; /* Safety. */ + *ppAudioBuffer = nullptr; /* Safety. */ - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -60371,11 +60371,11 @@ MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pC } pAudioBuffer = (ma_audio_buffer*)ma_malloc((size_t)allocationSizeInBytes, &innerConfig.allocationCallbacks); /* Safe cast to size_t. */ - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return MA_OUT_OF_MEMORY; } - if (pConfig->pData != NULL) { + if (pConfig->pData != nullptr) { ma_copy_pcm_frames(&pAudioBuffer->_pExtraData[0], pConfig->pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels); } else { ma_silence_pcm_frames(&pAudioBuffer->_pExtraData[0], pConfig->sizeInFrames, pConfig->format, pConfig->channels); @@ -60406,7 +60406,7 @@ MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer) MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop) { - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return 0; } @@ -60415,7 +60415,7 @@ MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex) { - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -60424,12 +60424,12 @@ MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount) { - if (ppFramesOut != NULL) { - *ppFramesOut = NULL; /* Safety. */ + if (ppFramesOut != nullptr) { + *ppFramesOut = nullptr; /* Safety. */ } - if (pAudioBuffer == NULL) { - if (pFrameCount != NULL) { + if (pAudioBuffer == nullptr) { + if (pFrameCount != nullptr) { *pFrameCount = 0; } @@ -60441,7 +60441,7 @@ MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFra MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount) { - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -60450,7 +60450,7 @@ MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 MA_API ma_bool32 ma_audio_buffer_at_end(const ma_audio_buffer* pAudioBuffer) { - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return MA_FALSE; } @@ -60459,7 +60459,7 @@ MA_API ma_bool32 ma_audio_buffer_at_end(const ma_audio_buffer* pAudioBuffer) MA_API ma_result ma_audio_buffer_get_cursor_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pCursor) { - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -60468,7 +60468,7 @@ MA_API ma_result ma_audio_buffer_get_cursor_in_pcm_frames(const ma_audio_buffer* MA_API ma_result ma_audio_buffer_get_length_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pLength) { - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -60477,13 +60477,13 @@ MA_API ma_result ma_audio_buffer_get_length_in_pcm_frames(const ma_audio_buffer* MA_API ma_result ma_audio_buffer_get_available_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames) { - if (pAvailableFrames == NULL) { + if (pAvailableFrames == nullptr) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; - if (pAudioBuffer == NULL) { + if (pAudioBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -60496,7 +60496,7 @@ MA_API ma_result ma_audio_buffer_get_available_frames(const ma_audio_buffer* pAu MA_API ma_result ma_paged_audio_buffer_data_init(ma_format format, ma_uint32 channels, ma_paged_audio_buffer_data* pData) { - if (pData == NULL) { + if (pData == nullptr) { return MA_INVALID_ARGS; } @@ -60513,13 +60513,13 @@ MA_API void ma_paged_audio_buffer_data_uninit(ma_paged_audio_buffer_data* pData, { ma_paged_audio_buffer_page* pPage; - if (pData == NULL) { + if (pData == nullptr) { return; } /* All pages need to be freed. */ pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pData->head.pNext); - while (pPage != NULL) { + while (pPage != nullptr) { ma_paged_audio_buffer_page* pNext = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPage->pNext); ma_free(pPage, pAllocationCallbacks); @@ -60529,8 +60529,8 @@ MA_API void ma_paged_audio_buffer_data_uninit(ma_paged_audio_buffer_data* pData, MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_head(ma_paged_audio_buffer_data* pData) { - if (pData == NULL) { - return NULL; + if (pData == nullptr) { + return nullptr; } return &pData->head; @@ -60538,8 +60538,8 @@ MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_head(ma_paged_ MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_tail(ma_paged_audio_buffer_data* pData) { - if (pData == NULL) { - return NULL; + if (pData == nullptr) { + return nullptr; } return pData->pTail; @@ -60549,18 +60549,18 @@ MA_API ma_result ma_paged_audio_buffer_data_get_length_in_pcm_frames(ma_paged_au { ma_paged_audio_buffer_page* pPage; - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; - if (pData == NULL) { + if (pData == nullptr) { return MA_INVALID_ARGS; } /* Calculate the length from the linked list. */ - for (pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pData->head.pNext); pPage != NULL; pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPage->pNext)) { + for (pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pData->head.pNext); pPage != nullptr; pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPage->pNext)) { *pLength += pPage->sizeInFrames; } @@ -60572,13 +60572,13 @@ MA_API ma_result ma_paged_audio_buffer_data_allocate_page(ma_paged_audio_buffer_ ma_paged_audio_buffer_page* pPage; ma_uint64 allocationSize; - if (ppPage == NULL) { + if (ppPage == nullptr) { return MA_INVALID_ARGS; } - *ppPage = NULL; + *ppPage = nullptr; - if (pData == NULL) { + if (pData == nullptr) { return MA_INVALID_ARGS; } @@ -60588,14 +60588,14 @@ MA_API ma_result ma_paged_audio_buffer_data_allocate_page(ma_paged_audio_buffer_ } pPage = (ma_paged_audio_buffer_page*)ma_malloc((size_t)allocationSize, pAllocationCallbacks); /* Safe cast to size_t. */ - if (pPage == NULL) { + if (pPage == nullptr) { return MA_OUT_OF_MEMORY; } - pPage->pNext = NULL; + pPage->pNext = nullptr; pPage->sizeInFrames = pageSizeInFrames; - if (pInitialData != NULL) { + if (pInitialData != nullptr) { ma_copy_pcm_frames(pPage->pAudioData, pInitialData, pageSizeInFrames, pData->format, pData->channels); } @@ -60606,7 +60606,7 @@ MA_API ma_result ma_paged_audio_buffer_data_allocate_page(ma_paged_audio_buffer_ MA_API ma_result ma_paged_audio_buffer_data_free_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pData == NULL || pPage == NULL) { + if (pData == nullptr || pPage == nullptr) { return MA_INVALID_ARGS; } @@ -60618,7 +60618,7 @@ MA_API ma_result ma_paged_audio_buffer_data_free_page(ma_paged_audio_buffer_data MA_API ma_result ma_paged_audio_buffer_data_append_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage) { - if (pData == NULL || pPage == NULL) { + if (pData == nullptr || pPage == nullptr) { return MA_INVALID_ARGS; } @@ -60703,7 +60703,7 @@ static ma_data_source_vtable g_ma_paged_audio_buffer_data_source_vtable = ma_paged_audio_buffer__data_source_on_get_data_format, ma_paged_audio_buffer__data_source_on_get_cursor, ma_paged_audio_buffer__data_source_on_get_length, - NULL, /* onSetLooping */ + nullptr, /* onSetLooping */ 0 }; @@ -60712,18 +60712,18 @@ MA_API ma_result ma_paged_audio_buffer_init(const ma_paged_audio_buffer_config* ma_result result; ma_data_source_config dataSourceConfig; - if (pPagedAudioBuffer == NULL) { + if (pPagedAudioBuffer == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pPagedAudioBuffer); /* A config is required for the format and channel count. */ - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - if (pConfig->pData == NULL) { + if (pConfig->pData == nullptr) { return MA_INVALID_ARGS; /* No underlying data specified. */ } @@ -60745,7 +60745,7 @@ MA_API ma_result ma_paged_audio_buffer_init(const ma_paged_audio_buffer_config* MA_API void ma_paged_audio_buffer_uninit(ma_paged_audio_buffer* pPagedAudioBuffer) { - if (pPagedAudioBuffer == NULL) { + if (pPagedAudioBuffer == nullptr) { return; } @@ -60759,7 +60759,7 @@ MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pP ma_format format; ma_uint32 channels; - if (pPagedAudioBuffer == NULL) { + if (pPagedAudioBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -60767,12 +60767,12 @@ MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pP channels = pPagedAudioBuffer->pData->channels; while (totalFramesRead < frameCount) { - /* Read from the current page. The buffer should never be in a state where this is NULL. */ + /* Read from the current page. The buffer should never be in a state where this is nullptr. */ ma_uint64 framesRemainingInCurrentPage; ma_uint64 framesRemainingToRead = frameCount - totalFramesRead; ma_uint64 framesToReadThisIteration; - MA_ASSERT(pPagedAudioBuffer->pCurrent != NULL); + MA_ASSERT(pPagedAudioBuffer->pCurrent != nullptr); framesRemainingInCurrentPage = pPagedAudioBuffer->pCurrent->sizeInFrames - pPagedAudioBuffer->relativeCursor; @@ -60789,7 +60789,7 @@ MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pP if (pPagedAudioBuffer->relativeCursor == pPagedAudioBuffer->pCurrent->sizeInFrames) { /* We reached the end of the page. Need to move to the next. If there's no more pages, we're done. */ ma_paged_audio_buffer_page* pNext = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPagedAudioBuffer->pCurrent->pNext); - if (pNext == NULL) { + if (pNext == nullptr) { result = MA_AT_END; break; /* We've reached the end. */ } else { @@ -60799,7 +60799,7 @@ MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pP } } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesRead; } @@ -60808,7 +60808,7 @@ MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pP MA_API ma_result ma_paged_audio_buffer_seek_to_pcm_frame(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64 frameIndex) { - if (pPagedAudioBuffer == NULL) { + if (pPagedAudioBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -60830,7 +60830,7 @@ MA_API ma_result ma_paged_audio_buffer_seek_to_pcm_frame(ma_paged_audio_buffer* ma_paged_audio_buffer_page* pPage; ma_uint64 runningCursor = 0; - for (pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&ma_paged_audio_buffer_data_get_head(pPagedAudioBuffer->pData)->pNext); pPage != NULL; pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPage->pNext)) { + for (pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&ma_paged_audio_buffer_data_get_head(pPagedAudioBuffer->pData)->pNext); pPage != nullptr; pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPage->pNext)) { ma_uint64 pageRangeBeg = runningCursor; ma_uint64 pageRangeEnd = pageRangeBeg + pPage->sizeInFrames; @@ -60856,13 +60856,13 @@ MA_API ma_result ma_paged_audio_buffer_seek_to_pcm_frame(ma_paged_audio_buffer* MA_API ma_result ma_paged_audio_buffer_get_cursor_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ - if (pPagedAudioBuffer == NULL) { + if (pPagedAudioBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -60887,17 +60887,17 @@ MA_API ma_result ma_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 open { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; - if (pFile == NULL) { + if (pFile == nullptr) { return MA_INVALID_ARGS; } - *pFile = NULL; + *pFile = nullptr; - if (pVFS == NULL || pFilePath == NULL || openMode == 0) { + if (pVFS == nullptr || pFilePath == nullptr || openMode == 0) { return MA_INVALID_ARGS; } - if (pCallbacks->onOpen == NULL) { + if (pCallbacks->onOpen == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -60908,17 +60908,17 @@ MA_API ma_result ma_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; - if (pFile == NULL) { + if (pFile == nullptr) { return MA_INVALID_ARGS; } - *pFile = NULL; + *pFile = nullptr; - if (pVFS == NULL || pFilePath == NULL || openMode == 0) { + if (pVFS == nullptr || pFilePath == nullptr || openMode == 0) { return MA_INVALID_ARGS; } - if (pCallbacks->onOpenW == NULL) { + if (pCallbacks->onOpenW == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -60929,11 +60929,11 @@ MA_API ma_result ma_vfs_close(ma_vfs* pVFS, ma_vfs_file file) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; - if (pVFS == NULL || file == NULL) { + if (pVFS == nullptr || file == nullptr) { return MA_INVALID_ARGS; } - if (pCallbacks->onClose == NULL) { + if (pCallbacks->onClose == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -60946,21 +60946,21 @@ MA_API ma_result ma_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t ma_result result; size_t bytesRead = 0; - if (pBytesRead != NULL) { + if (pBytesRead != nullptr) { *pBytesRead = 0; } - if (pVFS == NULL || file == NULL || pDst == NULL) { + if (pVFS == nullptr || file == nullptr || pDst == nullptr) { return MA_INVALID_ARGS; } - if (pCallbacks->onRead == NULL) { + if (pCallbacks->onRead == nullptr) { return MA_NOT_IMPLEMENTED; } result = pCallbacks->onRead(pVFS, file, pDst, sizeInBytes, &bytesRead); - if (pBytesRead != NULL) { + if (pBytesRead != nullptr) { *pBytesRead = bytesRead; } @@ -60975,15 +60975,15 @@ MA_API ma_result ma_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; - if (pBytesWritten != NULL) { + if (pBytesWritten != nullptr) { *pBytesWritten = 0; } - if (pVFS == NULL || file == NULL || pSrc == NULL) { + if (pVFS == nullptr || file == nullptr || pSrc == nullptr) { return MA_INVALID_ARGS; } - if (pCallbacks->onWrite == NULL) { + if (pCallbacks->onWrite == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -60994,11 +60994,11 @@ MA_API ma_result ma_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; - if (pVFS == NULL || file == NULL) { + if (pVFS == nullptr || file == nullptr) { return MA_INVALID_ARGS; } - if (pCallbacks->onSeek == NULL) { + if (pCallbacks->onSeek == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -61009,17 +61009,17 @@ MA_API ma_result ma_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; - if (pVFS == NULL || file == NULL) { + if (pVFS == nullptr || file == nullptr) { return MA_INVALID_ARGS; } - if (pCallbacks->onTell == NULL) { + if (pCallbacks->onTell == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -61030,17 +61030,17 @@ MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; - if (pInfo == NULL) { + if (pInfo == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pInfo); - if (pVFS == NULL || file == NULL) { + if (pVFS == nullptr || file == nullptr) { return MA_INVALID_ARGS; } - if (pCallbacks->onInfo == NULL) { + if (pCallbacks->onInfo == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -61063,17 +61063,17 @@ program and is left to the OS to uninitialize when the program terminates. typedef DWORD (__stdcall * ma_SetFilePointer_proc)(HANDLE hFile, LONG lDistanceToMove, LONG* lpDistanceToMoveHigh, DWORD dwMoveMethod); typedef BOOL (__stdcall * ma_SetFilePointerEx_proc)(HANDLE hFile, LARGE_INTEGER liDistanceToMove, LARGE_INTEGER* lpNewFilePointer, DWORD dwMoveMethod); -static ma_handle hKernel32DLL = NULL; -static ma_SetFilePointer_proc ma_SetFilePointer = NULL; -static ma_SetFilePointerEx_proc ma_SetFilePointerEx = NULL; +static ma_handle hKernel32DLL = nullptr; +static ma_SetFilePointer_proc ma_SetFilePointer = nullptr; +static ma_SetFilePointerEx_proc ma_SetFilePointerEx = nullptr; static void ma_win32_fileio_init(void) { - if (hKernel32DLL == NULL) { - hKernel32DLL = ma_dlopen(NULL, "kernel32.dll"); - if (hKernel32DLL != NULL) { - ma_SetFilePointer = (ma_SetFilePointer_proc) ma_dlsym(NULL, hKernel32DLL, "SetFilePointer"); - ma_SetFilePointerEx = (ma_SetFilePointerEx_proc)ma_dlsym(NULL, hKernel32DLL, "SetFilePointerEx"); + if (hKernel32DLL == nullptr) { + hKernel32DLL = ma_dlopen(nullptr, "kernel32.dll"); + if (hKernel32DLL != nullptr) { + ma_SetFilePointer = (ma_SetFilePointer_proc) ma_dlsym(nullptr, hKernel32DLL, "SetFilePointer"); + ma_SetFilePointerEx = (ma_SetFilePointerEx_proc)ma_dlsym(nullptr, hKernel32DLL, "SetFilePointerEx"); } } } @@ -61114,7 +61114,7 @@ static ma_result ma_default_vfs_open__win32(ma_vfs* pVFS, const char* pFilePath, ma_default_vfs__get_open_settings_win32(openMode, &dwDesiredAccess, &dwShareMode, &dwCreationDisposition); - hFile = CreateFileA(pFilePath, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileA(pFilePath, dwDesiredAccess, dwShareMode, nullptr, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { return ma_result_from_GetLastError(GetLastError()); } @@ -61139,7 +61139,7 @@ static ma_result ma_default_vfs_open_w__win32(ma_vfs* pVFS, const wchar_t* pFile ma_default_vfs__get_open_settings_win32(openMode, &dwDesiredAccess, &dwShareMode, &dwCreationDisposition); - hFile = CreateFileW(pFilePath, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileW(pFilePath, dwDesiredAccess, dwShareMode, nullptr, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { return ma_result_from_GetLastError(GetLastError()); } @@ -61188,7 +61188,7 @@ static ma_result ma_default_vfs_read__win32(ma_vfs* pVFS, ma_vfs_file file, void bytesToRead = (DWORD)bytesRemaining; } - readResult = ReadFile((HANDLE)file, ma_offset_ptr(pDst, totalBytesRead), bytesToRead, &bytesRead, NULL); + readResult = ReadFile((HANDLE)file, ma_offset_ptr(pDst, totalBytesRead), bytesToRead, &bytesRead, nullptr); if (readResult == 1 && bytesRead == 0) { result = MA_AT_END; break; /* EOF */ @@ -61206,7 +61206,7 @@ static ma_result ma_default_vfs_read__win32(ma_vfs* pVFS, ma_vfs_file file, void } } - if (pBytesRead != NULL) { + if (pBytesRead != nullptr) { *pBytesRead = totalBytesRead; } @@ -61234,7 +61234,7 @@ static ma_result ma_default_vfs_write__win32(ma_vfs* pVFS, ma_vfs_file file, con bytesToWrite = (DWORD)bytesRemaining; } - writeResult = WriteFile((HANDLE)file, ma_offset_ptr(pSrc, totalBytesWritten), bytesToWrite, &bytesWritten, NULL); + writeResult = WriteFile((HANDLE)file, ma_offset_ptr(pSrc, totalBytesWritten), bytesToWrite, &bytesWritten, nullptr); totalBytesWritten += bytesWritten; if (writeResult == 0) { @@ -61243,7 +61243,7 @@ static ma_result ma_default_vfs_write__win32(ma_vfs* pVFS, ma_vfs_file file, con } } - if (pBytesWritten != NULL) { + if (pBytesWritten != nullptr) { *pBytesWritten = totalBytesWritten; } @@ -61269,15 +61269,15 @@ static ma_result ma_default_vfs_seek__win32(ma_vfs* pVFS, ma_vfs_file file, ma_i dwMoveMethod = FILE_BEGIN; } - if (ma_SetFilePointerEx != NULL) { - result = ma_SetFilePointerEx((HANDLE)file, liDistanceToMove, NULL, dwMoveMethod); - } else if (ma_SetFilePointer != NULL) { + if (ma_SetFilePointerEx != nullptr) { + result = ma_SetFilePointerEx((HANDLE)file, liDistanceToMove, nullptr, dwMoveMethod); + } else if (ma_SetFilePointer != nullptr) { /* No SetFilePointerEx() so restrict to 31 bits. */ if (offset > 0x7FFFFFFF) { return MA_OUT_OF_RANGE; } - result = ma_SetFilePointer((HANDLE)file, (LONG)liDistanceToMove.QuadPart, NULL, dwMoveMethod); + result = ma_SetFilePointer((HANDLE)file, (LONG)liDistanceToMove.QuadPart, nullptr, dwMoveMethod); } else { return MA_NOT_IMPLEMENTED; } @@ -61299,9 +61299,9 @@ static ma_result ma_default_vfs_tell__win32(ma_vfs* pVFS, ma_vfs_file file, ma_i liZero.QuadPart = 0; - if (ma_SetFilePointerEx != NULL) { + if (ma_SetFilePointerEx != nullptr) { result = ma_SetFilePointerEx((HANDLE)file, liZero, &liTell, FILE_CURRENT); - } else if (ma_SetFilePointer != NULL) { + } else if (ma_SetFilePointer != nullptr) { LONG tell; result = ma_SetFilePointer((HANDLE)file, (LONG)liZero.QuadPart, &tell, FILE_CURRENT); @@ -61314,7 +61314,7 @@ static ma_result ma_default_vfs_tell__win32(ma_vfs* pVFS, ma_vfs_file file, ma_i return ma_result_from_GetLastError(GetLastError()); } - if (pCursor != NULL) { + if (pCursor != nullptr) { *pCursor = liTell.QuadPart; } @@ -61353,9 +61353,9 @@ static ma_result ma_default_vfs_open__stdio(ma_vfs* pVFS, const char* pFilePath, FILE* pFileStd; const char* pOpenModeStr; - MA_ASSERT(pFilePath != NULL); + MA_ASSERT(pFilePath != nullptr); MA_ASSERT(openMode != 0); - MA_ASSERT(pFile != NULL); + MA_ASSERT(pFile != nullptr); (void)pVFS; @@ -61385,9 +61385,9 @@ static ma_result ma_default_vfs_open_w__stdio(ma_vfs* pVFS, const wchar_t* pFile FILE* pFileStd; const wchar_t* pOpenModeStr; - MA_ASSERT(pFilePath != NULL); + MA_ASSERT(pFilePath != nullptr); MA_ASSERT(openMode != 0); - MA_ASSERT(pFile != NULL); + MA_ASSERT(pFile != nullptr); (void)pVFS; @@ -61401,7 +61401,7 @@ static ma_result ma_default_vfs_open_w__stdio(ma_vfs* pVFS, const wchar_t* pFile pOpenModeStr = L"wb"; } - result = ma_wfopen(&pFileStd, pFilePath, pOpenModeStr, (pVFS != NULL) ? &((ma_default_vfs*)pVFS)->allocationCallbacks : NULL); + result = ma_wfopen(&pFileStd, pFilePath, pOpenModeStr, (pVFS != nullptr) ? &((ma_default_vfs*)pVFS)->allocationCallbacks : nullptr); if (result != MA_SUCCESS) { return result; } @@ -61413,7 +61413,7 @@ static ma_result ma_default_vfs_open_w__stdio(ma_vfs* pVFS, const wchar_t* pFile static ma_result ma_default_vfs_close__stdio(ma_vfs* pVFS, ma_vfs_file file) { - MA_ASSERT(file != NULL); + MA_ASSERT(file != nullptr); (void)pVFS; @@ -61426,14 +61426,14 @@ static ma_result ma_default_vfs_read__stdio(ma_vfs* pVFS, ma_vfs_file file, void { size_t result; - MA_ASSERT(file != NULL); - MA_ASSERT(pDst != NULL); + MA_ASSERT(file != nullptr); + MA_ASSERT(pDst != nullptr); (void)pVFS; result = fread(pDst, 1, sizeInBytes, (FILE*)file); - if (pBytesRead != NULL) { + if (pBytesRead != nullptr) { *pBytesRead = result; } @@ -61452,14 +61452,14 @@ static ma_result ma_default_vfs_write__stdio(ma_vfs* pVFS, ma_vfs_file file, con { size_t result; - MA_ASSERT(file != NULL); - MA_ASSERT(pSrc != NULL); + MA_ASSERT(file != nullptr); + MA_ASSERT(pSrc != nullptr); (void)pVFS; result = fwrite(pSrc, 1, sizeInBytes, (FILE*)file); - if (pBytesWritten != NULL) { + if (pBytesWritten != nullptr) { *pBytesWritten = result; } @@ -61475,7 +61475,7 @@ static ma_result ma_default_vfs_seek__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_i int result; int whence; - MA_ASSERT(file != NULL); + MA_ASSERT(file != nullptr); (void)pVFS; @@ -61512,8 +61512,8 @@ static ma_result ma_default_vfs_tell__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_i { ma_int64 result; - MA_ASSERT(file != NULL); - MA_ASSERT(pCursor != NULL); + MA_ASSERT(file != nullptr); + MA_ASSERT(pCursor != nullptr); (void)pVFS; @@ -61541,8 +61541,8 @@ static ma_result ma_default_vfs_info__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_f int fd; struct stat info; - MA_ASSERT(file != NULL); - MA_ASSERT(pInfo != NULL); + MA_ASSERT(file != nullptr); + MA_ASSERT(pInfo != nullptr); (void)pVFS; @@ -61565,13 +61565,13 @@ static ma_result ma_default_vfs_info__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_f static ma_result ma_default_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { - if (pFile == NULL) { + if (pFile == nullptr) { return MA_INVALID_ARGS; } - *pFile = NULL; + *pFile = nullptr; - if (pFilePath == NULL || openMode == 0) { + if (pFilePath == nullptr || openMode == 0) { return MA_INVALID_ARGS; } @@ -61584,13 +61584,13 @@ static ma_result ma_default_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uin static ma_result ma_default_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { - if (pFile == NULL) { + if (pFile == nullptr) { return MA_INVALID_ARGS; } - *pFile = NULL; + *pFile = nullptr; - if (pFilePath == NULL || openMode == 0) { + if (pFilePath == nullptr || openMode == 0) { return MA_INVALID_ARGS; } @@ -61603,7 +61603,7 @@ static ma_result ma_default_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, m static ma_result ma_default_vfs_close(ma_vfs* pVFS, ma_vfs_file file) { - if (file == NULL) { + if (file == nullptr) { return MA_INVALID_ARGS; } @@ -61616,11 +61616,11 @@ static ma_result ma_default_vfs_close(ma_vfs* pVFS, ma_vfs_file file) static ma_result ma_default_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead) { - if (pBytesRead != NULL) { + if (pBytesRead != nullptr) { *pBytesRead = 0; } - if (file == NULL || pDst == NULL) { + if (file == nullptr || pDst == nullptr) { return MA_INVALID_ARGS; } @@ -61633,11 +61633,11 @@ static ma_result ma_default_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, static ma_result ma_default_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten) { - if (pBytesWritten != NULL) { + if (pBytesWritten != nullptr) { *pBytesWritten = 0; } - if (file == NULL || pSrc == NULL) { + if (file == nullptr || pSrc == nullptr) { return MA_INVALID_ARGS; } @@ -61650,7 +61650,7 @@ static ma_result ma_default_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void static ma_result ma_default_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin) { - if (file == NULL) { + if (file == nullptr) { return MA_INVALID_ARGS; } @@ -61663,13 +61663,13 @@ static ma_result ma_default_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 of static ma_result ma_default_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; - if (file == NULL) { + if (file == nullptr) { return MA_INVALID_ARGS; } @@ -61684,13 +61684,13 @@ static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_inf { ma_result result; - if (pInfo == NULL) { + if (pInfo == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pInfo); - if (file == NULL) { + if (file == nullptr) { return MA_INVALID_ARGS; } @@ -61736,7 +61736,7 @@ static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_inf MA_API ma_result ma_default_vfs_init(ma_default_vfs* pVFS, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pVFS == NULL) { + if (pVFS == nullptr) { return MA_INVALID_ARGS; } @@ -61756,7 +61756,7 @@ MA_API ma_result ma_default_vfs_init(ma_default_vfs* pVFS, const ma_allocation_c MA_API ma_result ma_vfs_or_default_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { - if (pVFS != NULL) { + if (pVFS != nullptr) { return ma_vfs_open(pVFS, pFilePath, openMode, pFile); } else { return ma_default_vfs_open(pVFS, pFilePath, openMode, pFile); @@ -61765,7 +61765,7 @@ MA_API ma_result ma_vfs_or_default_open(ma_vfs* pVFS, const char* pFilePath, ma_ MA_API ma_result ma_vfs_or_default_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { - if (pVFS != NULL) { + if (pVFS != nullptr) { return ma_vfs_open_w(pVFS, pFilePath, openMode, pFile); } else { return ma_default_vfs_open_w(pVFS, pFilePath, openMode, pFile); @@ -61774,7 +61774,7 @@ MA_API ma_result ma_vfs_or_default_open_w(ma_vfs* pVFS, const wchar_t* pFilePath MA_API ma_result ma_vfs_or_default_close(ma_vfs* pVFS, ma_vfs_file file) { - if (pVFS != NULL) { + if (pVFS != nullptr) { return ma_vfs_close(pVFS, file); } else { return ma_default_vfs_close(pVFS, file); @@ -61783,7 +61783,7 @@ MA_API ma_result ma_vfs_or_default_close(ma_vfs* pVFS, ma_vfs_file file) MA_API ma_result ma_vfs_or_default_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead) { - if (pVFS != NULL) { + if (pVFS != nullptr) { return ma_vfs_read(pVFS, file, pDst, sizeInBytes, pBytesRead); } else { return ma_default_vfs_read(pVFS, file, pDst, sizeInBytes, pBytesRead); @@ -61792,7 +61792,7 @@ MA_API ma_result ma_vfs_or_default_read(ma_vfs* pVFS, ma_vfs_file file, void* pD MA_API ma_result ma_vfs_or_default_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten) { - if (pVFS != NULL) { + if (pVFS != nullptr) { return ma_vfs_write(pVFS, file, pSrc, sizeInBytes, pBytesWritten); } else { return ma_default_vfs_write(pVFS, file, pSrc, sizeInBytes, pBytesWritten); @@ -61801,7 +61801,7 @@ MA_API ma_result ma_vfs_or_default_write(ma_vfs* pVFS, ma_vfs_file file, const v MA_API ma_result ma_vfs_or_default_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin) { - if (pVFS != NULL) { + if (pVFS != nullptr) { return ma_vfs_seek(pVFS, file, offset, origin); } else { return ma_default_vfs_seek(pVFS, file, offset, origin); @@ -61810,7 +61810,7 @@ MA_API ma_result ma_vfs_or_default_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 MA_API ma_result ma_vfs_or_default_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor) { - if (pVFS != NULL) { + if (pVFS != nullptr) { return ma_vfs_tell(pVFS, file, pCursor); } else { return ma_default_vfs_tell(pVFS, file, pCursor); @@ -61819,7 +61819,7 @@ MA_API ma_result ma_vfs_or_default_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64 MA_API ma_result ma_vfs_or_default_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo) { - if (pVFS != NULL) { + if (pVFS != nullptr) { return ma_vfs_info(pVFS, file, pInfo); } else { return ma_default_vfs_info(pVFS, file, pInfo); @@ -61836,18 +61836,18 @@ static ma_result ma_vfs_open_and_read_file_ex(ma_vfs* pVFS, const char* pFilePat void* pData; size_t bytesRead; - if (ppData != NULL) { - *ppData = NULL; + if (ppData != nullptr) { + *ppData = nullptr; } - if (pSize != NULL) { + if (pSize != nullptr) { *pSize = 0; } - if (ppData == NULL) { + if (ppData == nullptr) { return MA_INVALID_ARGS; } - if (pFilePath != NULL) { + if (pFilePath != nullptr) { result = ma_vfs_or_default_open(pVFS, pFilePath, MA_OPEN_MODE_READ, &file); } else { result = ma_vfs_or_default_open_w(pVFS, pFilePathW, MA_OPEN_MODE_READ, &file); @@ -61868,7 +61868,7 @@ static ma_result ma_vfs_open_and_read_file_ex(ma_vfs* pVFS, const char* pFilePat } pData = ma_malloc((size_t)info.sizeInBytes, pAllocationCallbacks); /* Safe cast. */ - if (pData == NULL) { + if (pData == nullptr) { ma_vfs_or_default_close(pVFS, file); return result; } @@ -61881,11 +61881,11 @@ static ma_result ma_vfs_open_and_read_file_ex(ma_vfs* pVFS, const char* pFilePat return result; } - if (pSize != NULL) { + if (pSize != nullptr) { *pSize = bytesRead; } - MA_ASSERT(ppData != NULL); + MA_ASSERT(ppData != nullptr); *ppData = pData; return MA_SUCCESS; @@ -61893,12 +61893,12 @@ static ma_result ma_vfs_open_and_read_file_ex(ma_vfs* pVFS, const char* pFilePat MA_API ma_result ma_vfs_open_and_read_file(ma_vfs* pVFS, const char* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_vfs_open_and_read_file_ex(pVFS, pFilePath, NULL, ppData, pSize, pAllocationCallbacks); + return ma_vfs_open_and_read_file_ex(pVFS, pFilePath, nullptr, ppData, pSize, pAllocationCallbacks); } MA_API ma_result ma_vfs_open_and_read_file_w(ma_vfs* pVFS, const wchar_t* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_vfs_open_and_read_file_ex(pVFS, NULL, pFilePath, ppData, pSize, pAllocationCallbacks); + return ma_vfs_open_and_read_file_ex(pVFS, nullptr, pFilePath, ppData, pSize, pAllocationCallbacks); } @@ -62821,23 +62821,23 @@ Decoding static ma_result ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead) { - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); return pDecoder->onRead(pDecoder, pBufferOut, bytesToRead, pBytesRead); } static ma_result ma_decoder_seek_bytes(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin) { - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); return pDecoder->onSeek(pDecoder, byteOffset, origin); } static ma_result ma_decoder_tell_bytes(ma_decoder* pDecoder, ma_int64* pCursor) { - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); - if (pDecoder->onTell == NULL) { + if (pDecoder->onTell == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -62880,7 +62880,7 @@ MA_API ma_decoder_config ma_decoder_config_init_default(void) MA_API ma_decoder_config ma_decoder_config_init_copy(const ma_decoder_config* pConfig) { ma_decoder_config config; - if (pConfig != NULL) { + if (pConfig != nullptr) { config = *pConfig; } else { MA_ZERO_OBJECT(&config); @@ -62898,8 +62898,8 @@ static ma_result ma_decoder__init_data_converter(ma_decoder* pDecoder, const ma_ ma_uint32 internalSampleRate; ma_channel internalChannelMap[MA_MAX_CHANNELS]; - MA_ASSERT(pDecoder != NULL); - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pDecoder != nullptr); + MA_ASSERT(pConfig != nullptr); result = ma_data_source_get_data_format(pDecoder->pBackend, &internalFormat, &internalChannels, &internalSampleRate, internalChannelMap, ma_countof(internalChannelMap)); if (result != MA_SUCCESS) { @@ -62980,7 +62980,7 @@ static ma_result ma_decoder__init_data_converter(ma_decoder* pDecoder, const ma_ } pDecoder->pInputCache = ma_malloc((size_t)inputCacheCapSizeInBytes, &pDecoder->allocationCallbacks); /* Safe cast to size_t. */ - if (pDecoder->pInputCache == NULL) { + if (pDecoder->pInputCache == nullptr) { ma_data_converter_uninit(&pDecoder->converter, &pDecoder->allocationCallbacks); return MA_OUT_OF_MEMORY; } @@ -62995,7 +62995,7 @@ static ma_result ma_decoder__init_data_converter(ma_decoder* pDecoder, const ma_ static ma_result ma_decoder_internal_on_read__custom(void* pUserData, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead) { ma_decoder* pDecoder = (ma_decoder*)pUserData; - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); return ma_decoder_read_bytes(pDecoder, pBufferOut, bytesToRead, pBytesRead); } @@ -63003,7 +63003,7 @@ static ma_result ma_decoder_internal_on_read__custom(void* pUserData, void* pBuf static ma_result ma_decoder_internal_on_seek__custom(void* pUserData, ma_int64 offset, ma_seek_origin origin) { ma_decoder* pDecoder = (ma_decoder*)pUserData; - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); return ma_decoder_seek_bytes(pDecoder, offset, origin); } @@ -63011,7 +63011,7 @@ static ma_result ma_decoder_internal_on_seek__custom(void* pUserData, ma_int64 o static ma_result ma_decoder_internal_on_tell__custom(void* pUserData, ma_int64* pCursor) { ma_decoder* pDecoder = (ma_decoder*)pUserData; - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); return ma_decoder_tell_bytes(pDecoder, pCursor); } @@ -63023,11 +63023,11 @@ static ma_result ma_decoder_init_from_vtable__internal(const ma_decoding_backend ma_decoding_backend_config backendConfig; ma_data_source* pBackend; - MA_ASSERT(pVTable != NULL); - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pVTable != nullptr); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); - if (pVTable->onInit == NULL) { + if (pVTable->onInit == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -63052,11 +63052,11 @@ static ma_result ma_decoder_init_from_file__internal(const ma_decoding_backend_v ma_decoding_backend_config backendConfig; ma_data_source* pBackend; - MA_ASSERT(pVTable != NULL); - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pVTable != nullptr); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); - if (pVTable->onInitFile == NULL) { + if (pVTable->onInitFile == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -63081,11 +63081,11 @@ static ma_result ma_decoder_init_from_file_w__internal(const ma_decoding_backend ma_decoding_backend_config backendConfig; ma_data_source* pBackend; - MA_ASSERT(pVTable != NULL); - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pVTable != nullptr); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); - if (pVTable->onInitFileW == NULL) { + if (pVTable->onInitFileW == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -63110,11 +63110,11 @@ static ma_result ma_decoder_init_from_memory__internal(const ma_decoding_backend ma_decoding_backend_config backendConfig; ma_data_source* pBackend; - MA_ASSERT(pVTable != NULL); - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pVTable != nullptr); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); - if (pVTable->onInitMemory == NULL) { + if (pVTable->onInitMemory == nullptr) { return MA_NOT_IMPLEMENTED; } @@ -63140,17 +63140,17 @@ static ma_result ma_decoder_init_custom__internal(const ma_decoder_config* pConf ma_result result = MA_NO_BACKEND; size_t ivtable; - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); - if (pConfig->ppCustomBackendVTables == NULL) { + if (pConfig->ppCustomBackendVTables == nullptr) { return MA_NO_BACKEND; } /* The order each backend is listed is what defines the priority. */ for (ivtable = 0; ivtable < pConfig->customBackendCount; ivtable += 1) { const ma_decoding_backend_vtable* pVTable = pConfig->ppCustomBackendVTables[ivtable]; - if (pVTable != NULL) { + if (pVTable != nullptr) { result = ma_decoder_init_from_vtable__internal(pVTable, pConfig->pCustomBackendUserData, pConfig, pDecoder); if (result == MA_SUCCESS) { return MA_SUCCESS; @@ -63175,17 +63175,17 @@ static ma_result ma_decoder_init_custom_from_file__internal(const char* pFilePat ma_result result = MA_NO_BACKEND; size_t ivtable; - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); - if (pConfig->ppCustomBackendVTables == NULL) { + if (pConfig->ppCustomBackendVTables == nullptr) { return MA_NO_BACKEND; } /* The order each backend is listed is what defines the priority. */ for (ivtable = 0; ivtable < pConfig->customBackendCount; ivtable += 1) { const ma_decoding_backend_vtable* pVTable = pConfig->ppCustomBackendVTables[ivtable]; - if (pVTable != NULL) { + if (pVTable != nullptr) { result = ma_decoder_init_from_file__internal(pVTable, pConfig->pCustomBackendUserData, pFilePath, pConfig, pDecoder); if (result == MA_SUCCESS) { return MA_SUCCESS; @@ -63204,17 +63204,17 @@ static ma_result ma_decoder_init_custom_from_file_w__internal(const wchar_t* pFi ma_result result = MA_NO_BACKEND; size_t ivtable; - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); - if (pConfig->ppCustomBackendVTables == NULL) { + if (pConfig->ppCustomBackendVTables == nullptr) { return MA_NO_BACKEND; } /* The order each backend is listed is what defines the priority. */ for (ivtable = 0; ivtable < pConfig->customBackendCount; ivtable += 1) { const ma_decoding_backend_vtable* pVTable = pConfig->ppCustomBackendVTables[ivtable]; - if (pVTable != NULL) { + if (pVTable != nullptr) { result = ma_decoder_init_from_file_w__internal(pVTable, pConfig->pCustomBackendUserData, pFilePath, pConfig, pDecoder); if (result == MA_SUCCESS) { return MA_SUCCESS; @@ -63233,17 +63233,17 @@ static ma_result ma_decoder_init_custom_from_memory__internal(const void* pData, ma_result result = MA_NO_BACKEND; size_t ivtable; - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); - if (pConfig->ppCustomBackendVTables == NULL) { + if (pConfig->ppCustomBackendVTables == nullptr) { return MA_NO_BACKEND; } /* The order each backend is listed is what defines the priority. */ for (ivtable = 0; ivtable < pConfig->customBackendCount; ivtable += 1) { const ma_decoding_backend_vtable* pVTable = pConfig->ppCustomBackendVTables[ivtable]; - if (pVTable != NULL) { + if (pVTable != nullptr) { result = ma_decoder_init_from_memory__internal(pVTable, pConfig->pCustomBackendUserData, pData, dataSize, pConfig, pDecoder); if (result == MA_SUCCESS) { return MA_SUCCESS; @@ -63318,7 +63318,7 @@ static ma_data_source_vtable g_ma_wav_ds_vtable = ma_wav_ds_get_data_format, ma_wav_ds_get_cursor, ma_wav_ds_get_length, - NULL, /* onSetLooping */ + nullptr, /* onSetLooping */ 0 }; @@ -63330,7 +63330,7 @@ static size_t ma_wav_dr_callback__read(void* pUserData, void* pBufferOut, size_t ma_result result; size_t bytesRead; - MA_ASSERT(pWav != NULL); + MA_ASSERT(pWav != nullptr); result = pWav->onRead(pWav->pReadSeekTellUserData, pBufferOut, bytesToRead, &bytesRead); (void)result; @@ -63344,7 +63344,7 @@ static ma_bool32 ma_wav_dr_callback__seek(void* pUserData, int offset, ma_dr_wav ma_result result; ma_seek_origin maSeekOrigin; - MA_ASSERT(pWav != NULL); + MA_ASSERT(pWav != nullptr); maSeekOrigin = ma_seek_origin_start; if (origin == MA_DR_WAV_SEEK_CUR) { @@ -63366,10 +63366,10 @@ static ma_bool32 ma_wav_dr_callback__tell(void* pUserData, ma_int64* pCursor) ma_wav* pWav = (ma_wav*)pUserData; ma_result result; - MA_ASSERT(pWav != NULL); - MA_ASSERT(pCursor != NULL); + MA_ASSERT(pWav != nullptr); + MA_ASSERT(pCursor != nullptr); - if (pWav->onTell == NULL) { + if (pWav->onTell == nullptr) { return MA_FALSE; /* Not implemented. */ } @@ -63387,14 +63387,14 @@ static ma_result ma_wav_init_internal(const ma_decoding_backend_config* pConfig, ma_result result; ma_data_source_config dataSourceConfig; - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pWav); pWav->format = ma_format_unknown; /* Use closest match to source file by default. */ - if (pConfig != NULL && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16 || pConfig->preferredFormat == ma_format_s32)) { + if (pConfig != nullptr && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16 || pConfig->preferredFormat == ma_format_s32)) { pWav->format = pConfig->preferredFormat; } else { /* Getting here means something other than f32 and s16 was specified. Just leave this unset to use the default format. */ @@ -63461,7 +63461,7 @@ MA_API ma_result ma_wav_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_p return result; } - if (onRead == NULL || onSeek == NULL) { + if (onRead == nullptr || onSeek == nullptr) { return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */ } @@ -63591,7 +63591,7 @@ MA_API ma_result ma_wav_init_memory(const void* pData, size_t dataSize, const ma MA_API void ma_wav_uninit(ma_wav* pWav, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pWav == NULL) { + if (pWav == nullptr) { return; } @@ -63613,7 +63613,7 @@ MA_API void ma_wav_uninit(ma_wav* pWav, const ma_allocation_callbacks* pAllocati MA_API ma_result ma_wav_read_pcm_frames(ma_wav* pWav, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -63621,7 +63621,7 @@ MA_API ma_result ma_wav_read_pcm_frames(ma_wav* pWav, void* pFramesOut, ma_uint6 return MA_INVALID_ARGS; } - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_ARGS; } @@ -63632,7 +63632,7 @@ MA_API ma_result ma_wav_read_pcm_frames(ma_wav* pWav, void* pFramesOut, ma_uint6 ma_uint64 totalFramesRead = 0; ma_format format; - ma_wav_get_data_format(pWav, &format, NULL, NULL, NULL, 0); + ma_wav_get_data_format(pWav, &format, nullptr, nullptr, nullptr, 0); switch (format) { @@ -63664,7 +63664,7 @@ MA_API ma_result ma_wav_read_pcm_frames(ma_wav* pWav, void* pFramesOut, ma_uint6 result = MA_AT_END; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesRead; } @@ -63690,7 +63690,7 @@ MA_API ma_result ma_wav_read_pcm_frames(ma_wav* pWav, void* pFramesOut, ma_uint6 MA_API ma_result ma_wav_seek_to_pcm_frame(ma_wav* pWav, ma_uint64 frameIndex) { - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_ARGS; } @@ -63720,38 +63720,38 @@ MA_API ma_result ma_wav_seek_to_pcm_frame(ma_wav* pWav, ma_uint64 frameIndex) MA_API ma_result ma_wav_get_data_format(ma_wav* pWav, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = ma_format_unknown; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = 0; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = 0; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_OPERATION; } - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = pWav->format; } #if !defined(MA_NO_WAV) { - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = pWav->dr.channels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = pWav->dr.sampleRate; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pChannelMap, channelMapCap, pWav->dr.channels); } @@ -63768,13 +63768,13 @@ MA_API ma_result ma_wav_get_data_format(ma_wav* pWav, ma_format* pFormat, ma_uin MA_API ma_result ma_wav_get_cursor_in_pcm_frames(ma_wav* pWav, ma_uint64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_ARGS; } @@ -63798,13 +63798,13 @@ MA_API ma_result ma_wav_get_cursor_in_pcm_frames(ma_wav* pWav, ma_uint64* pCurso MA_API ma_result ma_wav_get_length_in_pcm_frames(ma_wav* pWav, ma_uint64* pLength) { - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; /* Safety. */ - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_ARGS; } @@ -63836,7 +63836,7 @@ static ma_result ma_decoding_backend_init__wav(void* pUserData, ma_read_proc onR /* For now we're just allocating the decoder backend on the heap. */ pWav = (ma_wav*)ma_malloc(sizeof(*pWav), pAllocationCallbacks); - if (pWav == NULL) { + if (pWav == nullptr) { return MA_OUT_OF_MEMORY; } @@ -63860,7 +63860,7 @@ static ma_result ma_decoding_backend_init_file__wav(void* pUserData, const char* /* For now we're just allocating the decoder backend on the heap. */ pWav = (ma_wav*)ma_malloc(sizeof(*pWav), pAllocationCallbacks); - if (pWav == NULL) { + if (pWav == nullptr) { return MA_OUT_OF_MEMORY; } @@ -63884,7 +63884,7 @@ static ma_result ma_decoding_backend_init_file_w__wav(void* pUserData, const wch /* For now we're just allocating the decoder backend on the heap. */ pWav = (ma_wav*)ma_malloc(sizeof(*pWav), pAllocationCallbacks); - if (pWav == NULL) { + if (pWav == nullptr) { return MA_OUT_OF_MEMORY; } @@ -63908,7 +63908,7 @@ static ma_result ma_decoding_backend_init_memory__wav(void* pUserData, const voi /* For now we're just allocating the decoder backend on the heap. */ pWav = (ma_wav*)ma_malloc(sizeof(*pWav), pAllocationCallbacks); - if (pWav == NULL) { + if (pWav == nullptr) { return MA_OUT_OF_MEMORY; } @@ -63944,22 +63944,22 @@ static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_wav = static ma_result ma_decoder_init_wav__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_wav, NULL, pConfig, pDecoder); + return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_wav, nullptr, pConfig, pDecoder); } static ma_result ma_decoder_init_wav_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_wav, NULL, pFilePath, pConfig, pDecoder); + return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_wav, nullptr, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_wav_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_wav, NULL, pFilePath, pConfig, pDecoder); + return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_wav, nullptr, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_wav_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_wav, NULL, pData, dataSize, pConfig, pDecoder); + return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_wav, nullptr, pData, dataSize, pConfig, pDecoder); } #endif /* ma_dr_wav_h */ @@ -64023,7 +64023,7 @@ static ma_data_source_vtable g_ma_flac_ds_vtable = ma_flac_ds_get_data_format, ma_flac_ds_get_cursor, ma_flac_ds_get_length, - NULL, /* onSetLooping */ + nullptr, /* onSetLooping */ 0 }; @@ -64035,7 +64035,7 @@ static size_t ma_flac_dr_callback__read(void* pUserData, void* pBufferOut, size_ ma_result result; size_t bytesRead; - MA_ASSERT(pFlac != NULL); + MA_ASSERT(pFlac != nullptr); result = pFlac->onRead(pFlac->pReadSeekTellUserData, pBufferOut, bytesToRead, &bytesRead); (void)result; @@ -64049,7 +64049,7 @@ static ma_bool32 ma_flac_dr_callback__seek(void* pUserData, int offset, ma_dr_fl ma_result result; ma_seek_origin maSeekOrigin; - MA_ASSERT(pFlac != NULL); + MA_ASSERT(pFlac != nullptr); maSeekOrigin = ma_seek_origin_start; if (origin == MA_DR_FLAC_SEEK_CUR) { @@ -64071,10 +64071,10 @@ static ma_bool32 ma_flac_dr_callback__tell(void* pUserData, ma_int64* pCursor) ma_flac* pFlac = (ma_flac*)pUserData; ma_result result; - MA_ASSERT(pFlac != NULL); - MA_ASSERT(pCursor != NULL); + MA_ASSERT(pFlac != nullptr); + MA_ASSERT(pCursor != nullptr); - if (pFlac->onTell == NULL) { + if (pFlac->onTell == nullptr) { return MA_FALSE; /* Not implemented. */ } @@ -64092,14 +64092,14 @@ static ma_result ma_flac_init_internal(const ma_decoding_backend_config* pConfig ma_result result; ma_data_source_config dataSourceConfig; - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFlac); pFlac->format = ma_format_f32; /* f32 by default. */ - if (pConfig != NULL && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16 || pConfig->preferredFormat == ma_format_s32)) { + if (pConfig != nullptr && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16 || pConfig->preferredFormat == ma_format_s32)) { pFlac->format = pConfig->preferredFormat; } else { /* Getting here means something other than f32 and s16 was specified. Just leave this unset to use the default format. */ @@ -64125,7 +64125,7 @@ MA_API ma_result ma_flac_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_ return result; } - if (onRead == NULL || onSeek == NULL) { + if (onRead == nullptr || onSeek == nullptr) { return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */ } @@ -64137,7 +64137,7 @@ MA_API ma_result ma_flac_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_ #if !defined(MA_NO_FLAC) { pFlac->dr = ma_dr_flac_open(ma_flac_dr_callback__read, ma_flac_dr_callback__seek, ma_flac_dr_callback__tell, pFlac, pAllocationCallbacks); - if (pFlac->dr == NULL) { + if (pFlac->dr == nullptr) { return MA_INVALID_FILE; } @@ -64164,7 +64164,7 @@ MA_API ma_result ma_flac_init_file(const char* pFilePath, const ma_decoding_back #if !defined(MA_NO_FLAC) { pFlac->dr = ma_dr_flac_open_file(pFilePath, pAllocationCallbacks); - if (pFlac->dr == NULL) { + if (pFlac->dr == nullptr) { return MA_INVALID_FILE; } @@ -64192,7 +64192,7 @@ MA_API ma_result ma_flac_init_file_w(const wchar_t* pFilePath, const ma_decoding #if !defined(MA_NO_FLAC) { pFlac->dr = ma_dr_flac_open_file_w(pFilePath, pAllocationCallbacks); - if (pFlac->dr == NULL) { + if (pFlac->dr == nullptr) { return MA_INVALID_FILE; } @@ -64220,7 +64220,7 @@ MA_API ma_result ma_flac_init_memory(const void* pData, size_t dataSize, const m #if !defined(MA_NO_FLAC) { pFlac->dr = ma_dr_flac_open_memory(pData, dataSize, pAllocationCallbacks); - if (pFlac->dr == NULL) { + if (pFlac->dr == nullptr) { return MA_INVALID_FILE; } @@ -64239,7 +64239,7 @@ MA_API ma_result ma_flac_init_memory(const void* pData, size_t dataSize, const m MA_API void ma_flac_uninit(ma_flac* pFlac, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFlac == NULL) { + if (pFlac == nullptr) { return; } @@ -64261,7 +64261,7 @@ MA_API void ma_flac_uninit(ma_flac* pFlac, const ma_allocation_callbacks* pAlloc MA_API ma_result ma_flac_read_pcm_frames(ma_flac* pFlac, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -64269,7 +64269,7 @@ MA_API ma_result ma_flac_read_pcm_frames(ma_flac* pFlac, void* pFramesOut, ma_ui return MA_INVALID_ARGS; } - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_INVALID_ARGS; } @@ -64280,7 +64280,7 @@ MA_API ma_result ma_flac_read_pcm_frames(ma_flac* pFlac, void* pFramesOut, ma_ui ma_uint64 totalFramesRead = 0; ma_format format; - ma_flac_get_data_format(pFlac, &format, NULL, NULL, NULL, 0); + ma_flac_get_data_format(pFlac, &format, nullptr, nullptr, nullptr, 0); switch (format) { @@ -64313,7 +64313,7 @@ MA_API ma_result ma_flac_read_pcm_frames(ma_flac* pFlac, void* pFramesOut, ma_ui result = MA_AT_END; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesRead; } @@ -64339,7 +64339,7 @@ MA_API ma_result ma_flac_read_pcm_frames(ma_flac* pFlac, void* pFramesOut, ma_ui MA_API ma_result ma_flac_seek_to_pcm_frame(ma_flac* pFlac, ma_uint64 frameIndex) { - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_INVALID_ARGS; } @@ -64369,38 +64369,38 @@ MA_API ma_result ma_flac_seek_to_pcm_frame(ma_flac* pFlac, ma_uint64 frameIndex) MA_API ma_result ma_flac_get_data_format(ma_flac* pFlac, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = ma_format_unknown; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = 0; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = 0; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_INVALID_OPERATION; } - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = pFlac->format; } #if !defined(MA_NO_FLAC) { - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = pFlac->dr->channels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = pFlac->dr->sampleRate; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pChannelMap, channelMapCap, pFlac->dr->channels); } @@ -64417,13 +64417,13 @@ MA_API ma_result ma_flac_get_data_format(ma_flac* pFlac, ma_format* pFormat, ma_ MA_API ma_result ma_flac_get_cursor_in_pcm_frames(ma_flac* pFlac, ma_uint64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_INVALID_ARGS; } @@ -64444,13 +64444,13 @@ MA_API ma_result ma_flac_get_cursor_in_pcm_frames(ma_flac* pFlac, ma_uint64* pCu MA_API ma_result ma_flac_get_length_in_pcm_frames(ma_flac* pFlac, ma_uint64* pLength) { - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; /* Safety. */ - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_INVALID_ARGS; } @@ -64479,7 +64479,7 @@ static ma_result ma_decoding_backend_init__flac(void* pUserData, ma_read_proc on /* For now we're just allocating the decoder backend on the heap. */ pFlac = (ma_flac*)ma_malloc(sizeof(*pFlac), pAllocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_OUT_OF_MEMORY; } @@ -64503,7 +64503,7 @@ static ma_result ma_decoding_backend_init_file__flac(void* pUserData, const char /* For now we're just allocating the decoder backend on the heap. */ pFlac = (ma_flac*)ma_malloc(sizeof(*pFlac), pAllocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_OUT_OF_MEMORY; } @@ -64527,7 +64527,7 @@ static ma_result ma_decoding_backend_init_file_w__flac(void* pUserData, const wc /* For now we're just allocating the decoder backend on the heap. */ pFlac = (ma_flac*)ma_malloc(sizeof(*pFlac), pAllocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_OUT_OF_MEMORY; } @@ -64551,7 +64551,7 @@ static ma_result ma_decoding_backend_init_memory__flac(void* pUserData, const vo /* For now we're just allocating the decoder backend on the heap. */ pFlac = (ma_flac*)ma_malloc(sizeof(*pFlac), pAllocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_OUT_OF_MEMORY; } @@ -64587,22 +64587,22 @@ static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_flac = static ma_result ma_decoder_init_flac__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_flac, NULL, pConfig, pDecoder); + return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_flac, nullptr, pConfig, pDecoder); } static ma_result ma_decoder_init_flac_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_flac, NULL, pFilePath, pConfig, pDecoder); + return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_flac, nullptr, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_flac_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_flac, NULL, pFilePath, pConfig, pDecoder); + return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_flac, nullptr, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_flac_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_flac, NULL, pData, dataSize, pConfig, pDecoder); + return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_flac, nullptr, pData, dataSize, pConfig, pDecoder); } #endif /* ma_dr_flac_h */ @@ -64668,7 +64668,7 @@ static ma_data_source_vtable g_ma_mp3_ds_vtable = ma_mp3_ds_get_data_format, ma_mp3_ds_get_cursor, ma_mp3_ds_get_length, - NULL, /* onSetLooping */ + nullptr, /* onSetLooping */ 0 }; @@ -64680,7 +64680,7 @@ static size_t ma_mp3_dr_callback__read(void* pUserData, void* pBufferOut, size_t ma_result result; size_t bytesRead; - MA_ASSERT(pMP3 != NULL); + MA_ASSERT(pMP3 != nullptr); result = pMP3->onRead(pMP3->pReadSeekTellUserData, pBufferOut, bytesToRead, &bytesRead); (void)result; @@ -64694,7 +64694,7 @@ static ma_bool32 ma_mp3_dr_callback__seek(void* pUserData, int offset, ma_dr_mp3 ma_result result; ma_seek_origin maSeekOrigin; - MA_ASSERT(pMP3 != NULL); + MA_ASSERT(pMP3 != nullptr); if (origin == MA_DR_MP3_SEEK_SET) { maSeekOrigin = ma_seek_origin_start; @@ -64717,7 +64717,7 @@ static ma_bool32 ma_mp3_dr_callback__tell(void* pUserData, ma_int64* pCursor) ma_mp3* pMP3 = (ma_mp3*)pUserData; ma_result result; - MA_ASSERT(pMP3 != NULL); + MA_ASSERT(pMP3 != nullptr); result = pMP3->onTell(pMP3->pReadSeekTellUserData, pCursor); if (result != MA_SUCCESS) { @@ -64733,14 +64733,14 @@ static ma_result ma_mp3_init_internal(const ma_decoding_backend_config* pConfig, ma_result result; ma_data_source_config dataSourceConfig; - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pMP3); pMP3->format = ma_format_f32; /* f32 by default. */ - if (pConfig != NULL && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16)) { + if (pConfig != nullptr && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16)) { pMP3->format = pConfig->preferredFormat; } else { /* Getting here means something other than f32 and s16 was specified. Just leave this unset to use the default format. */ @@ -64761,15 +64761,15 @@ static ma_result ma_mp3_generate_seek_table(ma_mp3* pMP3, const ma_decoding_back { ma_bool32 mp3Result; ma_uint32 seekPointCount = 0; - ma_dr_mp3_seek_point* pSeekPoints = NULL; + ma_dr_mp3_seek_point* pSeekPoints = nullptr; - MA_ASSERT(pMP3 != NULL); - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pMP3 != nullptr); + MA_ASSERT(pConfig != nullptr); seekPointCount = pConfig->seekPointCount; if (seekPointCount > 0) { pSeekPoints = (ma_dr_mp3_seek_point*)ma_malloc(sizeof(*pMP3->pSeekPoints) * seekPointCount, pAllocationCallbacks); - if (pSeekPoints == NULL) { + if (pSeekPoints == nullptr) { return MA_OUT_OF_MEMORY; } } @@ -64813,7 +64813,7 @@ MA_API ma_result ma_mp3_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_p return result; } - if (onRead == NULL || onSeek == NULL) { + if (onRead == nullptr || onSeek == nullptr) { return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */ } @@ -64826,7 +64826,7 @@ MA_API ma_result ma_mp3_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_p { ma_bool32 mp3Result; - mp3Result = ma_dr_mp3_init(&pMP3->dr, ma_mp3_dr_callback__read, ma_mp3_dr_callback__seek, ma_mp3_dr_callback__tell, NULL, pMP3, pAllocationCallbacks); + mp3Result = ma_dr_mp3_init(&pMP3->dr, ma_mp3_dr_callback__read, ma_mp3_dr_callback__seek, ma_mp3_dr_callback__tell, nullptr, pMP3, pAllocationCallbacks); if (mp3Result != MA_TRUE) { return MA_INVALID_FILE; } @@ -64943,7 +64943,7 @@ MA_API ma_result ma_mp3_init_memory(const void* pData, size_t dataSize, const ma MA_API void ma_mp3_uninit(ma_mp3* pMP3, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return; } @@ -64966,7 +64966,7 @@ MA_API void ma_mp3_uninit(ma_mp3* pMP3, const ma_allocation_callbacks* pAllocati MA_API ma_result ma_mp3_read_pcm_frames(ma_mp3* pMP3, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -64974,7 +64974,7 @@ MA_API ma_result ma_mp3_read_pcm_frames(ma_mp3* pMP3, void* pFramesOut, ma_uint6 return MA_INVALID_ARGS; } - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_INVALID_ARGS; } @@ -64985,7 +64985,7 @@ MA_API ma_result ma_mp3_read_pcm_frames(ma_mp3* pMP3, void* pFramesOut, ma_uint6 ma_uint64 totalFramesRead = 0; ma_format format; - ma_mp3_get_data_format(pMP3, &format, NULL, NULL, NULL, 0); + ma_mp3_get_data_format(pMP3, &format, nullptr, nullptr, nullptr, 0); switch (format) { @@ -65014,7 +65014,7 @@ MA_API ma_result ma_mp3_read_pcm_frames(ma_mp3* pMP3, void* pFramesOut, ma_uint6 result = MA_AT_END; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesRead; } @@ -65036,7 +65036,7 @@ MA_API ma_result ma_mp3_read_pcm_frames(ma_mp3* pMP3, void* pFramesOut, ma_uint6 MA_API ma_result ma_mp3_seek_to_pcm_frame(ma_mp3* pMP3, ma_uint64 frameIndex) { - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_INVALID_ARGS; } @@ -65066,38 +65066,38 @@ MA_API ma_result ma_mp3_seek_to_pcm_frame(ma_mp3* pMP3, ma_uint64 frameIndex) MA_API ma_result ma_mp3_get_data_format(ma_mp3* pMP3, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = ma_format_unknown; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = 0; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = 0; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_INVALID_OPERATION; } - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = pMP3->format; } #if !defined(MA_NO_MP3) { - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = pMP3->dr.channels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = pMP3->dr.sampleRate; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pMP3->dr.channels); } @@ -65114,13 +65114,13 @@ MA_API ma_result ma_mp3_get_data_format(ma_mp3* pMP3, ma_format* pFormat, ma_uin MA_API ma_result ma_mp3_get_cursor_in_pcm_frames(ma_mp3* pMP3, ma_uint64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_INVALID_ARGS; } @@ -65141,13 +65141,13 @@ MA_API ma_result ma_mp3_get_cursor_in_pcm_frames(ma_mp3* pMP3, ma_uint64* pCurso MA_API ma_result ma_mp3_get_length_in_pcm_frames(ma_mp3* pMP3, ma_uint64* pLength) { - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; /* Safety. */ - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_INVALID_ARGS; } @@ -65176,7 +65176,7 @@ static ma_result ma_decoding_backend_init__mp3(void* pUserData, ma_read_proc onR /* For now we're just allocating the decoder backend on the heap. */ pMP3 = (ma_mp3*)ma_malloc(sizeof(*pMP3), pAllocationCallbacks); - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_OUT_OF_MEMORY; } @@ -65200,7 +65200,7 @@ static ma_result ma_decoding_backend_init_file__mp3(void* pUserData, const char* /* For now we're just allocating the decoder backend on the heap. */ pMP3 = (ma_mp3*)ma_malloc(sizeof(*pMP3), pAllocationCallbacks); - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_OUT_OF_MEMORY; } @@ -65224,7 +65224,7 @@ static ma_result ma_decoding_backend_init_file_w__mp3(void* pUserData, const wch /* For now we're just allocating the decoder backend on the heap. */ pMP3 = (ma_mp3*)ma_malloc(sizeof(*pMP3), pAllocationCallbacks); - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_OUT_OF_MEMORY; } @@ -65248,7 +65248,7 @@ static ma_result ma_decoding_backend_init_memory__mp3(void* pUserData, const voi /* For now we're just allocating the decoder backend on the heap. */ pMP3 = (ma_mp3*)ma_malloc(sizeof(*pMP3), pAllocationCallbacks); - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_OUT_OF_MEMORY; } @@ -65284,22 +65284,22 @@ static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_mp3 = static ma_result ma_decoder_init_mp3__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_mp3, NULL, pConfig, pDecoder); + return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_mp3, nullptr, pConfig, pDecoder); } static ma_result ma_decoder_init_mp3_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_mp3, NULL, pFilePath, pConfig, pDecoder); + return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_mp3, nullptr, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_mp3_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_mp3, NULL, pFilePath, pConfig, pDecoder); + return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_mp3, nullptr, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_mp3_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_mp3, NULL, pData, dataSize, pConfig, pDecoder); + return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_mp3, nullptr, pData, dataSize, pConfig, pDecoder); } #endif /* ma_dr_mp3_h */ @@ -65381,7 +65381,7 @@ static ma_data_source_vtable g_ma_stbvorbis_ds_vtable = ma_stbvorbis_ds_get_data_format, ma_stbvorbis_ds_get_cursor, ma_stbvorbis_ds_get_length, - NULL, /* onSetLooping */ + nullptr, /* onSetLooping */ 0 }; @@ -65393,7 +65393,7 @@ static ma_result ma_stbvorbis_init_internal(const ma_decoding_backend_config* pC (void)pConfig; - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_INVALID_ARGS; } @@ -65416,7 +65416,7 @@ static ma_result ma_stbvorbis_post_init(ma_stbvorbis* pVorbis) { stb_vorbis_info info; - MA_ASSERT(pVorbis != NULL); + MA_ASSERT(pVorbis != nullptr); info = stb_vorbis_get_info(pVorbis->stb); @@ -65432,7 +65432,7 @@ static ma_result ma_stbvorbis_init_internal_decoder_push(ma_stbvorbis* pVorbis) stb_vorbis* stb; size_t dataSize = 0; size_t dataCapacity = 0; - ma_uint8* pData = NULL; /* <-- Must be initialized to NULL. */ + ma_uint8* pData = nullptr; /* <-- Must be initialized to nullptr. */ for (;;) { int vorbisError; @@ -65443,7 +65443,7 @@ static ma_result ma_stbvorbis_init_internal_decoder_push(ma_stbvorbis* pVorbis) /* Allocate memory for the new chunk. */ dataCapacity += MA_VORBIS_DATA_CHUNK_SIZE; pNewData = (ma_uint8*)ma_realloc(pData, dataCapacity, &pVorbis->allocationCallbacks); - if (pNewData == NULL) { + if (pNewData == nullptr) { ma_free(pData, &pVorbis->allocationCallbacks); return MA_OUT_OF_MEMORY; } @@ -65465,8 +65465,8 @@ static ma_result ma_stbvorbis_init_internal_decoder_push(ma_stbvorbis* pVorbis) return MA_TOO_BIG; } - stb = stb_vorbis_open_pushdata(pData, (int)dataSize, &consumedDataSize, &vorbisError, NULL); - if (stb != NULL) { + stb = stb_vorbis_open_pushdata(pData, (int)dataSize, &consumedDataSize, &vorbisError, nullptr); + if (stb != nullptr) { /* Successfully opened the Vorbis decoder. We might have some leftover unprocessed data so we'll need to move that down to the front. @@ -65492,7 +65492,7 @@ static ma_result ma_stbvorbis_init_internal_decoder_push(ma_stbvorbis* pVorbis) } } - MA_ASSERT(stb != NULL); + MA_ASSERT(stb != nullptr); pVorbis->stb = stb; pVorbis->push.pData = pData; pVorbis->push.dataSize = dataSize; @@ -65511,7 +65511,7 @@ MA_API ma_result ma_stbvorbis_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_ return result; } - if (onRead == NULL || onSeek == NULL) { + if (onRead == nullptr || onSeek == nullptr) { return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */ } @@ -65567,8 +65567,8 @@ MA_API ma_result ma_stbvorbis_init_file(const char* pFilePath, const ma_decoding (void)pAllocationCallbacks; /* Don't know how to make use of this with stb_vorbis. */ /* We can use stb_vorbis' pull mode for file based streams. */ - pVorbis->stb = stb_vorbis_open_filename(pFilePath, NULL, NULL); - if (pVorbis->stb == NULL) { + pVorbis->stb = stb_vorbis_open_filename(pFilePath, nullptr, nullptr); + if (pVorbis->stb == nullptr) { return MA_INVALID_FILE; } @@ -65610,8 +65610,8 @@ MA_API ma_result ma_stbvorbis_init_memory(const void* pData, size_t dataSize, co return MA_TOO_BIG; } - pVorbis->stb = stb_vorbis_open_memory((const unsigned char*)pData, (int)dataSize, NULL, NULL); - if (pVorbis->stb == NULL) { + pVorbis->stb = stb_vorbis_open_memory((const unsigned char*)pData, (int)dataSize, nullptr, nullptr); + if (pVorbis->stb == nullptr) { return MA_INVALID_FILE; } @@ -65638,7 +65638,7 @@ MA_API ma_result ma_stbvorbis_init_memory(const void* pData, size_t dataSize, co MA_API void ma_stbvorbis_uninit(ma_stbvorbis* pVorbis, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return; } @@ -65663,7 +65663,7 @@ MA_API void ma_stbvorbis_uninit(ma_stbvorbis* pVorbis, const ma_allocation_callb MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -65671,7 +65671,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram return MA_INVALID_ARGS; } - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_INVALID_ARGS; } @@ -65683,7 +65683,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram ma_format format; ma_uint32 channels; - ma_stbvorbis_get_data_format(pVorbis, &format, &channels, NULL, NULL, 0); + ma_stbvorbis_get_data_format(pVorbis, &format, &channels, nullptr, nullptr, 0); if (format == ma_format_f32) { /* We read differently depending on whether or not we're using push mode. */ @@ -65696,7 +65696,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram ma_uint32 framesToReadFromCache = (ma_uint32)ma_min(pVorbis->push.framesRemaining, (frameCount - totalFramesRead)); /* Safe cast because pVorbis->framesRemaining is 32-bit. */ /* The output pointer can be null in which case we just treat it as a seek. */ - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { ma_uint64 iFrame; for (iFrame = 0; iFrame < framesToReadFromCache; iFrame += 1) { ma_uint32 iChannel; @@ -65730,7 +65730,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram break; /* Too big. */ } - consumedDataSize = stb_vorbis_decode_frame_pushdata(pVorbis->stb, pVorbis->push.pData, (int)pVorbis->push.dataSize, NULL, &pVorbis->push.ppPacketData, &samplesRead); + consumedDataSize = stb_vorbis_decode_frame_pushdata(pVorbis->stb, pVorbis->push.pData, (int)pVorbis->push.dataSize, nullptr, &pVorbis->push.ppPacketData, &samplesRead); if (consumedDataSize != 0) { /* Successfully decoded a Vorbis frame. Consume the data. */ pVorbis->push.dataSize -= (size_t)consumedDataSize; @@ -65750,7 +65750,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram ma_uint8* pNewData; pNewData = (ma_uint8*)ma_realloc(pVorbis->push.pData, newCap, &pVorbis->allocationCallbacks); - if (pNewData == NULL) { + if (pNewData == nullptr) { result = MA_OUT_OF_MEMORY; break; } @@ -65802,7 +65802,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram result = MA_AT_END; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesRead; } @@ -65828,7 +65828,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram MA_API ma_result ma_stbvorbis_seek_to_pcm_frame(ma_stbvorbis* pVorbis, ma_uint64 frameIndex) { - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_INVALID_ARGS; } @@ -65918,38 +65918,38 @@ MA_API ma_result ma_stbvorbis_seek_to_pcm_frame(ma_stbvorbis* pVorbis, ma_uint64 MA_API ma_result ma_stbvorbis_get_data_format(ma_stbvorbis* pVorbis, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = ma_format_unknown; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = 0; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = 0; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_INVALID_OPERATION; } - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = pVorbis->format; } #if !defined(MA_NO_VORBIS) { - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = pVorbis->channels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = pVorbis->sampleRate; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { ma_channel_map_init_standard(ma_standard_channel_map_vorbis, pChannelMap, channelMapCap, pVorbis->channels); } @@ -65966,13 +65966,13 @@ MA_API ma_result ma_stbvorbis_get_data_format(ma_stbvorbis* pVorbis, ma_format* MA_API ma_result ma_stbvorbis_get_cursor_in_pcm_frames(ma_stbvorbis* pVorbis, ma_uint64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_INVALID_ARGS; } @@ -65993,13 +65993,13 @@ MA_API ma_result ma_stbvorbis_get_cursor_in_pcm_frames(ma_stbvorbis* pVorbis, ma MA_API ma_result ma_stbvorbis_get_length_in_pcm_frames(ma_stbvorbis* pVorbis, ma_uint64* pLength) { - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; /* Safety. */ - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_INVALID_ARGS; } @@ -66032,7 +66032,7 @@ static ma_result ma_decoding_backend_init__stbvorbis(void* pUserData, ma_read_pr /* For now we're just allocating the decoder backend on the heap. */ pVorbis = (ma_stbvorbis*)ma_malloc(sizeof(*pVorbis), pAllocationCallbacks); - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_OUT_OF_MEMORY; } @@ -66056,7 +66056,7 @@ static ma_result ma_decoding_backend_init_file__stbvorbis(void* pUserData, const /* For now we're just allocating the decoder backend on the heap. */ pVorbis = (ma_stbvorbis*)ma_malloc(sizeof(*pVorbis), pAllocationCallbacks); - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_OUT_OF_MEMORY; } @@ -66080,7 +66080,7 @@ static ma_result ma_decoding_backend_init_memory__stbvorbis(void* pUserData, con /* For now we're just allocating the decoder backend on the heap. */ pVorbis = (ma_stbvorbis*)ma_malloc(sizeof(*pVorbis), pAllocationCallbacks); - if (pVorbis == NULL) { + if (pVorbis == nullptr) { return MA_OUT_OF_MEMORY; } @@ -66109,29 +66109,29 @@ static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_stbvorbis = { ma_decoding_backend_init__stbvorbis, ma_decoding_backend_init_file__stbvorbis, - NULL, /* onInitFileW() */ + nullptr, /* onInitFileW() */ ma_decoding_backend_init_memory__stbvorbis, ma_decoding_backend_uninit__stbvorbis }; static ma_result ma_decoder_init_vorbis__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_stbvorbis, NULL, pConfig, pDecoder); + return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_stbvorbis, nullptr, pConfig, pDecoder); } static ma_result ma_decoder_init_vorbis_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_stbvorbis, NULL, pFilePath, pConfig, pDecoder); + return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_stbvorbis, nullptr, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_vorbis_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_stbvorbis, NULL, pFilePath, pConfig, pDecoder); + return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_stbvorbis, nullptr, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_vorbis_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_stbvorbis, NULL, pData, dataSize, pConfig, pDecoder); + return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_stbvorbis, nullptr, pData, dataSize, pConfig, pDecoder); } #endif /* STB_VORBIS_INCLUDE_STB_VORBIS_H */ @@ -66139,9 +66139,9 @@ static ma_result ma_decoder_init_vorbis_from_memory__internal(const void* pData, static ma_result ma_decoder__init_allocation_callbacks(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); - if (pConfig != NULL) { + if (pConfig != nullptr) { return ma_allocation_callbacks_init_copy(&pDecoder->allocationCallbacks, &pConfig->allocationCallbacks); } else { pDecoder->allocationCallbacks = ma_allocation_callbacks_init_default(); @@ -66181,7 +66181,7 @@ static ma_data_source_vtable g_ma_decoder_data_source_vtable = ma_decoder__data_source_on_get_data_format, ma_decoder__data_source_on_get_cursor, ma_decoder__data_source_on_get_length, - NULL, /* onSetLooping */ + nullptr, /* onSetLooping */ 0 }; @@ -66190,9 +66190,9 @@ static ma_result ma_decoder__preinit(ma_decoder_read_proc onRead, ma_decoder_see ma_result result; ma_data_source_config dataSourceConfig; - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pConfig != nullptr); - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_INVALID_ARGS; } @@ -66240,8 +66240,8 @@ static ma_result ma_decoder_init__internal(ma_decoder_read_proc onRead, ma_decod { ma_result result = MA_NO_BACKEND; - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pDecoder != nullptr); /* Silence some warnings in the case that we don't have any decoder backends enabled. */ (void)onRead; @@ -66346,7 +66346,7 @@ MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_pr config = ma_decoder_config_init_copy(pConfig); - result = ma_decoder__preinit(onRead, onSeek, NULL, pUserData, &config, pDecoder); + result = ma_decoder__preinit(onRead, onSeek, nullptr, pUserData, &config, pDecoder); if (result != MA_SUCCESS) { return result; } @@ -66361,7 +66361,7 @@ static ma_result ma_decoder__on_read_memory(ma_decoder* pDecoder, void* pBufferO MA_ASSERT(pDecoder->data.memory.dataSize >= pDecoder->data.memory.currentReadPos); - if (pBytesRead != NULL) { + if (pBytesRead != nullptr) { *pBytesRead = 0; } @@ -66379,7 +66379,7 @@ static ma_result ma_decoder__on_read_memory(ma_decoder* pDecoder, void* pBufferO pDecoder->data.memory.currentReadPos += bytesToRead; } - if (pBytesRead != NULL) { + if (pBytesRead != nullptr) { *pBytesRead = bytesToRead; } @@ -66431,8 +66431,8 @@ static ma_result ma_decoder__on_seek_memory(ma_decoder* pDecoder, ma_int64 byteO static ma_result ma_decoder__on_tell_memory(ma_decoder* pDecoder, ma_int64* pCursor) { - MA_ASSERT(pDecoder != NULL); - MA_ASSERT(pCursor != NULL); + MA_ASSERT(pDecoder != nullptr); + MA_ASSERT(pCursor != nullptr); *pCursor = (ma_int64)pDecoder->data.memory.currentReadPos; @@ -66441,12 +66441,12 @@ static ma_result ma_decoder__on_tell_memory(ma_decoder* pDecoder, ma_int64* pCur static ma_result ma_decoder__preinit_memory_wrapper(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { - ma_result result = ma_decoder__preinit(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, ma_decoder__on_tell_memory, NULL, pConfig, pDecoder); + ma_result result = ma_decoder__preinit(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, ma_decoder__on_tell_memory, nullptr, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } - if (pData == NULL || dataSize == 0) { + if (pData == nullptr || dataSize == 0) { return MA_INVALID_ARGS; } @@ -66465,12 +66465,12 @@ MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, cons config = ma_decoder_config_init_copy(pConfig); - result = ma_decoder__preinit(NULL, NULL, NULL, NULL, &config, pDecoder); + result = ma_decoder__preinit(nullptr, nullptr, nullptr, nullptr, &config, pDecoder); if (result != MA_SUCCESS) { return result; } - if (pData == NULL || dataSize == 0) { + if (pData == nullptr || dataSize == 0) { return MA_INVALID_ARGS; } @@ -66560,7 +66560,7 @@ MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, cons return result; } - result = ma_decoder_init__internal(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, NULL, &config, pDecoder); + result = ma_decoder_init__internal(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, nullptr, &config, pDecoder); if (result != MA_SUCCESS) { return result; } @@ -66582,8 +66582,8 @@ static const char* ma_path_file_name(const char* path) { const char* fileName; - if (path == NULL) { - return NULL; + if (path == nullptr) { + return nullptr; } fileName = path; @@ -66609,8 +66609,8 @@ static const wchar_t* ma_path_file_name_w(const wchar_t* path) { const wchar_t* fileName; - if (path == NULL) { - return NULL; + if (path == nullptr) { + return nullptr; } fileName = path; @@ -66638,12 +66638,12 @@ static const char* ma_path_extension(const char* path) const char* extension; const char* lastOccurance; - if (path == NULL) { + if (path == nullptr) { path = ""; } extension = ma_path_file_name(path); - lastOccurance = NULL; + lastOccurance = nullptr; /* Just find the last '.' and return. */ while (extension[0] != '\0') { @@ -66655,7 +66655,7 @@ static const char* ma_path_extension(const char* path) extension += 1; } - return (lastOccurance != NULL) ? lastOccurance : extension; + return (lastOccurance != nullptr) ? lastOccurance : extension; } static const wchar_t* ma_path_extension_w(const wchar_t* path) @@ -66663,12 +66663,12 @@ static const wchar_t* ma_path_extension_w(const wchar_t* path) const wchar_t* extension; const wchar_t* lastOccurance; - if (path == NULL) { + if (path == nullptr) { path = L""; } extension = ma_path_file_name_w(path); - lastOccurance = NULL; + lastOccurance = nullptr; /* Just find the last '.' and return. */ while (extension[0] != '\0') { @@ -66680,7 +66680,7 @@ static const wchar_t* ma_path_extension_w(const wchar_t* path) extension += 1; } - return (lastOccurance != NULL) ? lastOccurance : extension; + return (lastOccurance != nullptr) ? lastOccurance : extension; } @@ -66689,7 +66689,7 @@ static ma_bool32 ma_path_extension_equal(const char* path, const char* extension const char* ext1; const char* ext2; - if (path == NULL || extension == NULL) { + if (path == nullptr || extension == nullptr) { return MA_FALSE; } @@ -66708,7 +66708,7 @@ static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* e const wchar_t* ext1; const wchar_t* ext2; - if (path == NULL || extension == NULL) { + if (path == nullptr || extension == nullptr) { return MA_FALSE; } @@ -66758,22 +66758,22 @@ static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* e static ma_result ma_decoder__on_read_vfs(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead) { - MA_ASSERT(pDecoder != NULL); - MA_ASSERT(pBufferOut != NULL); + MA_ASSERT(pDecoder != nullptr); + MA_ASSERT(pBufferOut != nullptr); return ma_vfs_or_default_read(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, pBufferOut, bytesToRead, pBytesRead); } static ma_result ma_decoder__on_seek_vfs(ma_decoder* pDecoder, ma_int64 offset, ma_seek_origin origin) { - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); return ma_vfs_or_default_seek(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, offset, origin); } static ma_result ma_decoder__on_tell_vfs(ma_decoder* pDecoder, ma_int64* pCursor) { - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); return ma_vfs_or_default_tell(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, pCursor); } @@ -66783,12 +66783,12 @@ static ma_result ma_decoder__preinit_vfs(ma_vfs* pVFS, const char* pFilePath, co ma_result result; ma_vfs_file file; - result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, ma_decoder__on_tell_vfs, NULL, pConfig, pDecoder); + result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, ma_decoder__on_tell_vfs, nullptr, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } - if (pFilePath == NULL || pFilePath[0] == '\0') { + if (pFilePath == nullptr || pFilePath[0] == '\0') { return MA_INVALID_ARGS; } @@ -66892,13 +66892,13 @@ MA_API ma_result ma_decoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const /* If we still haven't got a result just use trial and error. Otherwise we can finish up. */ if (result != MA_SUCCESS) { - result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, &config, pDecoder); + result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, nullptr, &config, pDecoder); } else { result = ma_decoder__postinit(&config, pDecoder); } if (result != MA_SUCCESS) { - if (pDecoder->data.vfs.file != NULL) { /* <-- Will be reset to NULL if ma_decoder_uninit() is called in one of the steps above which allows us to avoid a double close of the file. */ + if (pDecoder->data.vfs.file != nullptr) { /* <-- Will be reset to nullptr if ma_decoder_uninit() is called in one of the steps above which allows us to avoid a double close of the file. */ ma_vfs_or_default_close(pVFS, pDecoder->data.vfs.file); } @@ -66914,12 +66914,12 @@ static ma_result ma_decoder__preinit_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePat ma_result result; ma_vfs_file file; - result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, ma_decoder__on_tell_vfs, NULL, pConfig, pDecoder); + result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, ma_decoder__on_tell_vfs, nullptr, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } - if (pFilePath == NULL || pFilePath[0] == '\0') { + if (pFilePath == nullptr || pFilePath[0] == '\0') { return MA_INVALID_ARGS; } @@ -67023,7 +67023,7 @@ MA_API ma_result ma_decoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, c /* If we still haven't got a result just use trial and error. Otherwise we can finish up. */ if (result != MA_SUCCESS) { - result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, &config, pDecoder); + result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, nullptr, &config, pDecoder); } else { result = ma_decoder__postinit(&config, pDecoder); } @@ -67041,12 +67041,12 @@ static ma_result ma_decoder__preinit_file(const char* pFilePath, const ma_decode { ma_result result; - result = ma_decoder__preinit(NULL, NULL, NULL, NULL, pConfig, pDecoder); + result = ma_decoder__preinit(nullptr, nullptr, nullptr, nullptr, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } - if (pFilePath == NULL || pFilePath[0] == '\0') { + if (pFilePath == nullptr || pFilePath[0] == '\0') { return MA_INVALID_ARGS; } @@ -67170,7 +67170,7 @@ MA_API ma_result ma_decoder_init_file(const char* pFilePath, const ma_decoder_co } } else { /* Probably no implementation for loading from a file path. Use miniaudio's file IO instead. */ - result = ma_decoder_init_vfs(NULL, pFilePath, pConfig, pDecoder); + result = ma_decoder_init_vfs(nullptr, pFilePath, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } @@ -67183,12 +67183,12 @@ static ma_result ma_decoder__preinit_file_w(const wchar_t* pFilePath, const ma_d { ma_result result; - result = ma_decoder__preinit(NULL, NULL, NULL, NULL, pConfig, pDecoder); + result = ma_decoder__preinit(nullptr, nullptr, nullptr, nullptr, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } - if (pFilePath == NULL || pFilePath[0] == '\0') { + if (pFilePath == nullptr || pFilePath[0] == '\0') { return MA_INVALID_ARGS; } @@ -67312,7 +67312,7 @@ MA_API ma_result ma_decoder_init_file_w(const wchar_t* pFilePath, const ma_decod } } else { /* Probably no implementation for loading from a file path. Use miniaudio's file IO instead. */ - result = ma_decoder_init_vfs_w(NULL, pFilePath, pConfig, pDecoder); + result = ma_decoder_init_vfs_w(nullptr, pFilePath, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } @@ -67323,25 +67323,25 @@ MA_API ma_result ma_decoder_init_file_w(const wchar_t* pFilePath, const ma_decod MA_API ma_result ma_decoder_uninit(ma_decoder* pDecoder) { - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_INVALID_ARGS; } - if (pDecoder->pBackend != NULL) { - if (pDecoder->pBackendVTable != NULL && pDecoder->pBackendVTable->onUninit != NULL) { + if (pDecoder->pBackend != nullptr) { + if (pDecoder->pBackendVTable != nullptr && pDecoder->pBackendVTable->onUninit != nullptr) { pDecoder->pBackendVTable->onUninit(pDecoder->pBackendUserData, pDecoder->pBackend, &pDecoder->allocationCallbacks); } } if (pDecoder->onRead == ma_decoder__on_read_vfs) { ma_vfs_or_default_close(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file); - pDecoder->data.vfs.file = NULL; + pDecoder->data.vfs.file = nullptr; } ma_data_converter_uninit(&pDecoder->converter, &pDecoder->allocationCallbacks); ma_data_source_uninit(&pDecoder->ds); - if (pDecoder->pInputCache != NULL) { + if (pDecoder->pInputCache != nullptr) { ma_free(pDecoder->pInputCache, &pDecoder->allocationCallbacks); } @@ -67354,7 +67354,7 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO ma_uint64 totalFramesReadOut; void* pRunningFramesOut; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; /* Safety. */ } @@ -67362,11 +67362,11 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO return MA_INVALID_ARGS; } - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_INVALID_ARGS; } - if (pDecoder->pBackend == NULL) { + if (pDecoder->pBackend == nullptr) { return MA_INVALID_OPERATION; } @@ -67378,8 +67378,8 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO Getting here means we need to do data conversion. If we're seeking forward and are _not_ doing resampling we can run this in a fast path. If we're doing resampling we need to run through each sample because we need to ensure its internal cache is updated. */ - if (pFramesOut == NULL && pDecoder->converter.hasResampler == MA_FALSE) { - result = ma_data_source_read_pcm_frames(pDecoder->pBackend, NULL, frameCount, &totalFramesReadOut); + if (pFramesOut == nullptr && pDecoder->converter.hasResampler == MA_FALSE) { + result = ma_data_source_read_pcm_frames(pDecoder->pBackend, nullptr, frameCount, &totalFramesReadOut); } else { /* Slow path. Need to run everything through the data converter. */ ma_format internalFormat; @@ -67388,7 +67388,7 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO totalFramesReadOut = 0; pRunningFramesOut = pFramesOut; - result = ma_data_source_get_data_format(pDecoder->pBackend, &internalFormat, &internalChannels, NULL, NULL, 0); + result = ma_data_source_get_data_format(pDecoder->pBackend, &internalFormat, &internalChannels, nullptr, nullptr, 0); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the internal format and channel count. */ } @@ -67399,7 +67399,7 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO the required number of input frames, we'll use the heap-allocated path. Otherwise we'll use the stack-allocated path. */ - if (pDecoder->pInputCache != NULL) { + if (pDecoder->pInputCache != nullptr) { /* We don't have a way of determining the required number of input frames, so need to persistently store input data in a cache. */ while (totalFramesReadOut < frameCount) { ma_uint64 framesToReadThisIterationIn; @@ -67423,7 +67423,7 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO totalFramesReadOut += framesToReadThisIterationOut; - if (pRunningFramesOut != NULL) { + if (pRunningFramesOut != nullptr) { pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesToReadThisIterationOut * ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels)); } @@ -67491,7 +67491,7 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO totalFramesReadOut += framesReadThisIterationOut; - if (pRunningFramesOut != NULL) { + if (pRunningFramesOut != nullptr) { pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesReadThisIterationOut * ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels)); } @@ -67505,7 +67505,7 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO pDecoder->readPointerInPCMFrames += totalFramesReadOut; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesReadOut; } @@ -67518,17 +67518,17 @@ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesO MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex) { - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_INVALID_ARGS; } - if (pDecoder->pBackend != NULL) { + if (pDecoder->pBackend != nullptr) { ma_result result; ma_uint64 internalFrameIndex; ma_uint32 internalSampleRate; ma_uint64 currentFrameIndex; - result = ma_data_source_get_data_format(pDecoder->pBackend, NULL, NULL, &internalSampleRate, NULL, 0); + result = ma_data_source_get_data_format(pDecoder->pBackend, nullptr, nullptr, &internalSampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the internal sample rate. */ } @@ -67560,23 +67560,23 @@ MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 fr MA_API ma_result ma_decoder_get_data_format(ma_decoder* pDecoder, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_INVALID_ARGS; } - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = pDecoder->outputFormat; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = pDecoder->outputChannels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = pDecoder->outputSampleRate; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { ma_data_converter_get_output_channel_map(&pDecoder->converter, pChannelMap, channelMapCap); } @@ -67585,13 +67585,13 @@ MA_API ma_result ma_decoder_get_data_format(ma_decoder* pDecoder, ma_format* pFo MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_INVALID_ARGS; } @@ -67602,17 +67602,17 @@ MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_ui MA_API ma_result ma_decoder_get_length_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pLength) { - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_INVALID_ARGS; } - if (pDecoder->pBackend != NULL) { + if (pDecoder->pBackend != nullptr) { ma_result result; ma_uint64 internalLengthInPCMFrames; ma_uint32 internalSampleRate; @@ -67622,7 +67622,7 @@ MA_API ma_result ma_decoder_get_length_in_pcm_frames(ma_decoder* pDecoder, ma_ui return result; /* Failed to retrieve the internal length. */ } - result = ma_data_source_get_data_format(pDecoder->pBackend, NULL, NULL, &internalSampleRate, NULL, 0); + result = ma_data_source_get_data_format(pDecoder->pBackend, nullptr, nullptr, &internalSampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the internal sample rate. */ } @@ -67644,13 +67644,13 @@ MA_API ma_result ma_decoder_get_available_frames(ma_decoder* pDecoder, ma_uint64 ma_result result; ma_uint64 totalFrameCount; - if (pAvailableFrames == NULL) { + if (pAvailableFrames == nullptr) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_INVALID_ARGS; } @@ -67677,14 +67677,14 @@ static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_dec ma_uint64 dataCapInFrames; void* pPCMFramesOut; - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pDecoder != nullptr); totalFrameCount = 0; bpf = ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels); /* The frame count is unknown until we try reading. Thus, we just run in a loop. */ dataCapInFrames = 0; - pPCMFramesOut = NULL; + pPCMFramesOut = nullptr; for (;;) { ma_uint64 frameCountToTryReading; ma_uint64 framesJustRead; @@ -67703,7 +67703,7 @@ static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_dec } pNewPCMFramesOut = (void*)ma_realloc(pPCMFramesOut, (size_t)(newDataCapInFrames * bpf), &pDecoder->allocationCallbacks); - if (pNewPCMFramesOut == NULL) { + if (pNewPCMFramesOut == nullptr) { ma_free(pPCMFramesOut, &pDecoder->allocationCallbacks); return MA_OUT_OF_MEMORY; } @@ -67728,19 +67728,19 @@ static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_dec } - if (pConfigOut != NULL) { + if (pConfigOut != nullptr) { pConfigOut->format = pDecoder->outputFormat; pConfigOut->channels = pDecoder->outputChannels; pConfigOut->sampleRate = pDecoder->outputSampleRate; } - if (ppPCMFramesOut != NULL) { + if (ppPCMFramesOut != nullptr) { *ppPCMFramesOut = pPCMFramesOut; } else { ma_free(pPCMFramesOut, &pDecoder->allocationCallbacks); } - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = totalFrameCount; } @@ -67754,11 +67754,11 @@ MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_deco ma_decoder_config config; ma_decoder decoder; - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = 0; } - if (ppPCMFramesOut != NULL) { - *ppPCMFramesOut = NULL; + if (ppPCMFramesOut != nullptr) { + *ppPCMFramesOut = nullptr; } config = ma_decoder_config_init_copy(pConfig); @@ -67775,7 +67775,7 @@ MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_deco MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut) { - return ma_decode_from_vfs(NULL, pFilePath, pConfig, pFrameCountOut, ppPCMFramesOut); + return ma_decode_from_vfs(nullptr, pFilePath, pConfig, pFrameCountOut, ppPCMFramesOut); } MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut) @@ -67784,14 +67784,14 @@ MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder ma_decoder decoder; ma_result result; - if (pFrameCountOut != NULL) { + if (pFrameCountOut != nullptr) { *pFrameCountOut = 0; } - if (ppPCMFramesOut != NULL) { - *ppPCMFramesOut = NULL; + if (ppPCMFramesOut != nullptr) { + *ppPCMFramesOut = nullptr; } - if (pData == NULL || dataSize == 0) { + if (pData == nullptr || dataSize == 0) { return MA_INVALID_ARGS; } @@ -67815,7 +67815,7 @@ static size_t ma_encoder__internal_on_write_wav(void* pUserData, const void* pDa ma_encoder* pEncoder = (ma_encoder*)pUserData; size_t bytesWritten = 0; - MA_ASSERT(pEncoder != NULL); + MA_ASSERT(pEncoder != nullptr); pEncoder->onWrite(pEncoder, pData, bytesToWrite, &bytesWritten); return bytesWritten; @@ -67827,7 +67827,7 @@ static ma_bool32 ma_encoder__internal_on_seek_wav(void* pUserData, int offset, m ma_result result; ma_seek_origin maSeekOrigin; - MA_ASSERT(pEncoder != NULL); + MA_ASSERT(pEncoder != nullptr); maSeekOrigin = ma_seek_origin_start; if (origin == MA_DR_WAV_SEEK_CUR) { @@ -67850,10 +67850,10 @@ static ma_result ma_encoder__on_init_wav(ma_encoder* pEncoder) ma_allocation_callbacks allocationCallbacks; ma_dr_wav* pWav; - MA_ASSERT(pEncoder != NULL); + MA_ASSERT(pEncoder != nullptr); pWav = (ma_dr_wav*)ma_malloc(sizeof(*pWav), &pEncoder->config.allocationCallbacks); - if (pWav == NULL) { + if (pWav == nullptr) { return MA_OUT_OF_MEMORY; } @@ -67885,10 +67885,10 @@ static void ma_encoder__on_uninit_wav(ma_encoder* pEncoder) { ma_dr_wav* pWav; - MA_ASSERT(pEncoder != NULL); + MA_ASSERT(pEncoder != nullptr); pWav = (ma_dr_wav*)pEncoder->pInternalEncoder; - MA_ASSERT(pWav != NULL); + MA_ASSERT(pWav != nullptr); ma_dr_wav_uninit(pWav); ma_free(pWav, &pEncoder->config.allocationCallbacks); @@ -67899,14 +67899,14 @@ static ma_result ma_encoder__on_write_pcm_frames_wav(ma_encoder* pEncoder, const ma_dr_wav* pWav; ma_uint64 framesWritten; - MA_ASSERT(pEncoder != NULL); + MA_ASSERT(pEncoder != nullptr); pWav = (ma_dr_wav*)pEncoder->pInternalEncoder; - MA_ASSERT(pWav != NULL); + MA_ASSERT(pWav != nullptr); framesWritten = ma_dr_wav_write_pcm_frames(pWav, frameCount, pFramesIn); - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = framesWritten; } @@ -67931,13 +67931,13 @@ MA_API ma_result ma_encoder_preinit(const ma_encoder_config* pConfig, ma_encoder { ma_result result; - if (pEncoder == NULL) { + if (pEncoder == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pEncoder); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -67960,9 +67960,9 @@ MA_API ma_result ma_encoder_init__internal(ma_encoder_write_proc onWrite, ma_enc ma_result result = MA_SUCCESS; /* This assumes ma_encoder_preinit() has been called prior. */ - MA_ASSERT(pEncoder != NULL); + MA_ASSERT(pEncoder != nullptr); - if (onWrite == NULL || onSeek == NULL) { + if (onWrite == nullptr || onSeek == nullptr) { return MA_INVALID_ARGS; } @@ -68026,7 +68026,7 @@ MA_API ma_result ma_encoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const pEncoder->data.vfs.pVFS = pVFS; pEncoder->data.vfs.file = file; - result = ma_encoder_init__internal(ma_encoder__on_write_vfs, ma_encoder__on_seek_vfs, NULL, pEncoder); + result = ma_encoder_init__internal(ma_encoder__on_write_vfs, ma_encoder__on_seek_vfs, nullptr, pEncoder); if (result != MA_SUCCESS) { ma_vfs_or_default_close(pVFS, file); return result; @@ -68054,7 +68054,7 @@ MA_API ma_result ma_encoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, c pEncoder->data.vfs.pVFS = pVFS; pEncoder->data.vfs.file = file; - result = ma_encoder_init__internal(ma_encoder__on_write_vfs, ma_encoder__on_seek_vfs, NULL, pEncoder); + result = ma_encoder_init__internal(ma_encoder__on_write_vfs, ma_encoder__on_seek_vfs, nullptr, pEncoder); if (result != MA_SUCCESS) { ma_vfs_or_default_close(pVFS, file); return result; @@ -68065,12 +68065,12 @@ MA_API ma_result ma_encoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, c MA_API ma_result ma_encoder_init_file(const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder) { - return ma_encoder_init_vfs(NULL, pFilePath, pConfig, pEncoder); + return ma_encoder_init_vfs(nullptr, pFilePath, pConfig, pEncoder); } MA_API ma_result ma_encoder_init_file_w(const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder) { - return ma_encoder_init_vfs_w(NULL, pFilePath, pConfig, pEncoder); + return ma_encoder_init_vfs_w(nullptr, pFilePath, pConfig, pEncoder); } MA_API ma_result ma_encoder_init(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, const ma_encoder_config* pConfig, ma_encoder* pEncoder) @@ -68088,7 +68088,7 @@ MA_API ma_result ma_encoder_init(ma_encoder_write_proc onWrite, ma_encoder_seek_ MA_API void ma_encoder_uninit(ma_encoder* pEncoder) { - if (pEncoder == NULL) { + if (pEncoder == nullptr) { return; } @@ -68099,18 +68099,18 @@ MA_API void ma_encoder_uninit(ma_encoder* pEncoder) /* If we have a file handle, close it. */ if (pEncoder->onWrite == ma_encoder__on_write_vfs) { ma_vfs_or_default_close(pEncoder->data.vfs.pVFS, pEncoder->data.vfs.file); - pEncoder->data.vfs.file = NULL; + pEncoder->data.vfs.file = nullptr; } } MA_API ma_result ma_encoder_write_pcm_frames(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount, ma_uint64* pFramesWritten) { - if (pFramesWritten != NULL) { + if (pFramesWritten != nullptr) { *pFramesWritten = 0; } - if (pEncoder == NULL || pFramesIn == NULL) { + if (pEncoder == nullptr || pFramesIn == nullptr) { return MA_INVALID_ARGS; } @@ -68188,8 +68188,8 @@ static ma_data_source_vtable g_ma_waveform_data_source_vtable = ma_waveform__data_source_on_seek, ma_waveform__data_source_on_get_data_format, ma_waveform__data_source_on_get_cursor, - NULL, /* onGetLength. There's no notion of a length in waveforms. */ - NULL, /* onSetLooping */ + nullptr, /* onGetLength. There's no notion of a length in waveforms. */ + nullptr, /* onSetLooping */ 0 }; @@ -68198,7 +68198,7 @@ MA_API ma_result ma_waveform_init(const ma_waveform_config* pConfig, ma_waveform ma_result result; ma_data_source_config dataSourceConfig; - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68221,7 +68221,7 @@ MA_API ma_result ma_waveform_init(const ma_waveform_config* pConfig, ma_waveform MA_API void ma_waveform_uninit(ma_waveform* pWaveform) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return; } @@ -68230,7 +68230,7 @@ MA_API void ma_waveform_uninit(ma_waveform* pWaveform) MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68240,7 +68240,7 @@ MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplit MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68252,7 +68252,7 @@ MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double freque MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68262,7 +68262,7 @@ MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type t MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68338,8 +68338,8 @@ static void ma_waveform_read_pcm_frames__sine(ma_waveform* pWaveform, void* pFra ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format); ma_uint32 bpf = bps * pWaveform->config.channels; - MA_ASSERT(pWaveform != NULL); - MA_ASSERT(pFramesOut != NULL); + MA_ASSERT(pWaveform != nullptr); + MA_ASSERT(pFramesOut != nullptr); if (pWaveform->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; @@ -68380,8 +68380,8 @@ static void ma_waveform_read_pcm_frames__square(ma_waveform* pWaveform, double d ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format); ma_uint32 bpf = bps * pWaveform->config.channels; - MA_ASSERT(pWaveform != NULL); - MA_ASSERT(pFramesOut != NULL); + MA_ASSERT(pWaveform != nullptr); + MA_ASSERT(pFramesOut != nullptr); if (pWaveform->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; @@ -68422,8 +68422,8 @@ static void ma_waveform_read_pcm_frames__triangle(ma_waveform* pWaveform, void* ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format); ma_uint32 bpf = bps * pWaveform->config.channels; - MA_ASSERT(pWaveform != NULL); - MA_ASSERT(pFramesOut != NULL); + MA_ASSERT(pWaveform != nullptr); + MA_ASSERT(pFramesOut != nullptr); if (pWaveform->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; @@ -68464,8 +68464,8 @@ static void ma_waveform_read_pcm_frames__sawtooth(ma_waveform* pWaveform, void* ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format); ma_uint32 bpf = bps * pWaveform->config.channels; - MA_ASSERT(pWaveform != NULL); - MA_ASSERT(pFramesOut != NULL); + MA_ASSERT(pWaveform != nullptr); + MA_ASSERT(pFramesOut != nullptr); if (pWaveform->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; @@ -68501,7 +68501,7 @@ static void ma_waveform_read_pcm_frames__sawtooth(ma_waveform* pWaveform, void* MA_API ma_result ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -68509,11 +68509,11 @@ MA_API ma_result ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFram return MA_INVALID_ARGS; } - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { switch (pWaveform->config.type) { case ma_waveform_type_sine: @@ -68542,7 +68542,7 @@ MA_API ma_result ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFram pWaveform->time += pWaveform->advance * (ma_int64)frameCount; /* Cast to int64 required for VC6. Won't affect anything in practice. */ } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = frameCount; } @@ -68551,7 +68551,7 @@ MA_API ma_result ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFram MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68580,7 +68580,7 @@ MA_API ma_result ma_pulsewave_init(const ma_pulsewave_config* pConfig, ma_pulsew ma_result result; ma_waveform_config config; - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68603,7 +68603,7 @@ MA_API ma_result ma_pulsewave_init(const ma_pulsewave_config* pConfig, ma_pulsew MA_API void ma_pulsewave_uninit(ma_pulsewave* pWaveform) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return; } @@ -68612,7 +68612,7 @@ MA_API void ma_pulsewave_uninit(ma_pulsewave* pWaveform) MA_API ma_result ma_pulsewave_read_pcm_frames(ma_pulsewave* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -68620,17 +68620,17 @@ MA_API ma_result ma_pulsewave_read_pcm_frames(ma_pulsewave* pWaveform, void* pFr return MA_INVALID_ARGS; } - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { ma_waveform_read_pcm_frames__square(&pWaveform->waveform, pWaveform->config.dutyCycle, pFramesOut, frameCount); } else { pWaveform->waveform.time += pWaveform->waveform.advance * (ma_int64)frameCount; /* Cast to int64 required for VC6. Won't affect anything in practice. */ } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = frameCount; } @@ -68639,7 +68639,7 @@ MA_API ma_result ma_pulsewave_read_pcm_frames(ma_pulsewave* pWaveform, void* pFr MA_API ma_result ma_pulsewave_seek_to_pcm_frame(ma_pulsewave* pWaveform, ma_uint64 frameIndex) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68650,7 +68650,7 @@ MA_API ma_result ma_pulsewave_seek_to_pcm_frame(ma_pulsewave* pWaveform, ma_uint MA_API ma_result ma_pulsewave_set_amplitude(ma_pulsewave* pWaveform, double amplitude) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68662,7 +68662,7 @@ MA_API ma_result ma_pulsewave_set_amplitude(ma_pulsewave* pWaveform, double ampl MA_API ma_result ma_pulsewave_set_frequency(ma_pulsewave* pWaveform, double frequency) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68674,7 +68674,7 @@ MA_API ma_result ma_pulsewave_set_frequency(ma_pulsewave* pWaveform, double freq MA_API ma_result ma_pulsewave_set_sample_rate(ma_pulsewave* pWaveform, ma_uint32 sampleRate) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68686,7 +68686,7 @@ MA_API ma_result ma_pulsewave_set_sample_rate(ma_pulsewave* pWaveform, ma_uint32 MA_API ma_result ma_pulsewave_set_duty_cycle(ma_pulsewave* pWaveform, double dutyCycle) { - if (pWaveform == NULL) { + if (pWaveform == nullptr) { return MA_INVALID_ARGS; } @@ -68746,9 +68746,9 @@ static ma_data_source_vtable g_ma_noise_data_source_vtable = ma_noise__data_source_on_read, ma_noise__data_source_on_seek, /* No-op for noise. */ ma_noise__data_source_on_get_data_format, - NULL, /* onGetCursor. No notion of a cursor for noise. */ - NULL, /* onGetLength. No notion of a length for noise. */ - NULL, /* onSetLooping */ + nullptr, /* onGetCursor. No notion of a cursor for noise. */ + nullptr, /* onGetLength. No notion of a length for noise. */ + nullptr, /* onSetLooping */ 0 }; @@ -68774,11 +68774,11 @@ typedef struct static ma_result ma_noise_get_heap_layout(const ma_noise_config* pConfig, ma_noise_heap_layout* pHeapLayout) { - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -68822,7 +68822,7 @@ MA_API ma_result ma_noise_get_heap_size(const ma_noise_config* pConfig, size_t* ma_result result; ma_noise_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -68845,7 +68845,7 @@ MA_API ma_result ma_noise_init_preallocated(const ma_noise_config* pConfig, void ma_data_source_config dataSourceConfig; ma_uint32 iChannel; - if (pNoise == NULL) { + if (pNoise == nullptr) { return MA_INVALID_ARGS; } @@ -68906,11 +68906,11 @@ MA_API ma_result ma_noise_init(const ma_noise_config* pConfig, const ma_allocati if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_noise_init_preallocated(pConfig, pHeap, pNoise); @@ -68925,7 +68925,7 @@ MA_API ma_result ma_noise_init(const ma_noise_config* pConfig, const ma_allocati MA_API void ma_noise_uninit(ma_noise* pNoise, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pNoise == NULL) { + if (pNoise == nullptr) { return; } @@ -68938,7 +68938,7 @@ MA_API void ma_noise_uninit(ma_noise* pNoise, const ma_allocation_callbacks* pAl MA_API ma_result ma_noise_set_amplitude(ma_noise* pNoise, double amplitude) { - if (pNoise == NULL) { + if (pNoise == nullptr) { return MA_INVALID_ARGS; } @@ -68948,7 +68948,7 @@ MA_API ma_result ma_noise_set_amplitude(ma_noise* pNoise, double amplitude) MA_API ma_result ma_noise_set_seed(ma_noise* pNoise, ma_int32 seed) { - if (pNoise == NULL) { + if (pNoise == nullptr) { return MA_INVALID_ARGS; } @@ -68959,7 +68959,7 @@ MA_API ma_result ma_noise_set_seed(ma_noise* pNoise, ma_int32 seed) MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type) { - if (pNoise == NULL) { + if (pNoise == nullptr) { return MA_INVALID_ARGS; } @@ -69252,7 +69252,7 @@ MA_API ma_result ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma { ma_uint64 framesRead = 0; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -69260,12 +69260,12 @@ MA_API ma_result ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma return MA_INVALID_ARGS; } - if (pNoise == NULL) { + if (pNoise == nullptr) { return MA_INVALID_ARGS; } - /* The output buffer is allowed to be NULL. Since we aren't tracking cursors or anything we can just do nothing and pretend to be successful. */ - if (pFramesOut == NULL) { + /* The output buffer is allowed to be nullptr. Since we aren't tracking cursors or anything we can just do nothing and pretend to be successful. */ + if (pFramesOut == nullptr) { framesRead = frameCount; } else { switch (pNoise->config.type) { @@ -69276,7 +69276,7 @@ MA_API ma_result ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma } } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = framesRead; } @@ -69306,7 +69306,7 @@ MA_API ma_resource_manager_pipeline_notifications ma_resource_manager_pipeline_n static void ma_resource_manager_pipeline_notifications_signal_all_notifications(const ma_resource_manager_pipeline_notifications* pPipelineNotifications) { - if (pPipelineNotifications == NULL) { + if (pPipelineNotifications == nullptr) { return; } @@ -69316,22 +69316,22 @@ static void ma_resource_manager_pipeline_notifications_signal_all_notifications( static void ma_resource_manager_pipeline_notifications_acquire_all_fences(const ma_resource_manager_pipeline_notifications* pPipelineNotifications) { - if (pPipelineNotifications == NULL) { + if (pPipelineNotifications == nullptr) { return; } - if (pPipelineNotifications->init.pFence != NULL) { ma_fence_acquire(pPipelineNotifications->init.pFence); } - if (pPipelineNotifications->done.pFence != NULL) { ma_fence_acquire(pPipelineNotifications->done.pFence); } + if (pPipelineNotifications->init.pFence != nullptr) { ma_fence_acquire(pPipelineNotifications->init.pFence); } + if (pPipelineNotifications->done.pFence != nullptr) { ma_fence_acquire(pPipelineNotifications->done.pFence); } } static void ma_resource_manager_pipeline_notifications_release_all_fences(const ma_resource_manager_pipeline_notifications* pPipelineNotifications) { - if (pPipelineNotifications == NULL) { + if (pPipelineNotifications == nullptr) { return; } - if (pPipelineNotifications->init.pFence != NULL) { ma_fence_release(pPipelineNotifications->init.pFence); } - if (pPipelineNotifications->done.pFence != NULL) { ma_fence_release(pPipelineNotifications->done.pFence); } + if (pPipelineNotifications->init.pFence != nullptr) { ma_fence_release(pPipelineNotifications->init.pFence); } + if (pPipelineNotifications->done.pFence != nullptr) { ma_fence_release(pPipelineNotifications->done.pFence); } } @@ -69447,11 +69447,11 @@ static ma_result ma_resource_manager_data_buffer_node_search(ma_resource_manager { ma_resource_manager_data_buffer_node* pCurrentNode; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(ppDataBufferNode != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(ppDataBufferNode != nullptr); pCurrentNode = pResourceManager->pRootDataBufferNode; - while (pCurrentNode != NULL) { + while (pCurrentNode != nullptr) { if (hashedName32 == pCurrentNode->hashedName32) { break; /* Found. */ } else if (hashedName32 < pCurrentNode->hashedName32) { @@ -69463,7 +69463,7 @@ static ma_result ma_resource_manager_data_buffer_node_search(ma_resource_manager *ppDataBufferNode = pCurrentNode; - if (pCurrentNode == NULL) { + if (pCurrentNode == nullptr) { return MA_DOES_NOT_EXIST; } else { return MA_SUCCESS; @@ -69475,31 +69475,31 @@ static ma_result ma_resource_manager_data_buffer_node_insert_point(ma_resource_m ma_result result = MA_SUCCESS; ma_resource_manager_data_buffer_node* pCurrentNode; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(ppInsertPoint != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(ppInsertPoint != nullptr); - *ppInsertPoint = NULL; + *ppInsertPoint = nullptr; - if (pResourceManager->pRootDataBufferNode == NULL) { + if (pResourceManager->pRootDataBufferNode == nullptr) { return MA_SUCCESS; /* No items. */ } /* We need to find the node that will become the parent of the new node. If a node is found that already has the same hashed name we need to return MA_ALREADY_EXISTS. */ pCurrentNode = pResourceManager->pRootDataBufferNode; - while (pCurrentNode != NULL) { + while (pCurrentNode != nullptr) { if (hashedName32 == pCurrentNode->hashedName32) { result = MA_ALREADY_EXISTS; break; } else { if (hashedName32 < pCurrentNode->hashedName32) { - if (pCurrentNode->pChildLo == NULL) { + if (pCurrentNode->pChildLo == nullptr) { result = MA_SUCCESS; break; } else { pCurrentNode = pCurrentNode->pChildLo; } } else { - if (pCurrentNode->pChildHi == NULL) { + if (pCurrentNode->pChildHi == nullptr) { result = MA_SUCCESS; break; } else { @@ -69515,22 +69515,22 @@ static ma_result ma_resource_manager_data_buffer_node_insert_point(ma_resource_m static ma_result ma_resource_manager_data_buffer_node_insert_at(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, ma_resource_manager_data_buffer_node* pInsertPoint) { - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); /* The key must have been set before calling this function. */ MA_ASSERT(pDataBufferNode->hashedName32 != 0); - if (pInsertPoint == NULL) { + if (pInsertPoint == nullptr) { /* It's the first node. */ pResourceManager->pRootDataBufferNode = pDataBufferNode; } else { /* It's not the first node. It needs to be inserted. */ if (pDataBufferNode->hashedName32 < pInsertPoint->hashedName32) { - MA_ASSERT(pInsertPoint->pChildLo == NULL); + MA_ASSERT(pInsertPoint->pChildLo == nullptr); pInsertPoint->pChildLo = pDataBufferNode; } else { - MA_ASSERT(pInsertPoint->pChildHi == NULL); + MA_ASSERT(pInsertPoint->pChildHi == nullptr); pInsertPoint->pChildHi = pDataBufferNode; } } @@ -69546,8 +69546,8 @@ static ma_result ma_resource_manager_data_buffer_node_insert(ma_resource_manager ma_result result; ma_resource_manager_data_buffer_node* pInsertPoint; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); result = ma_resource_manager_data_buffer_node_insert_point(pResourceManager, pDataBufferNode->hashedName32, &pInsertPoint); if (result != MA_SUCCESS) { @@ -69562,10 +69562,10 @@ static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_ { ma_resource_manager_data_buffer_node* pCurrentNode; - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pDataBufferNode != nullptr); pCurrentNode = pDataBufferNode; - while (pCurrentNode->pChildLo != NULL) { + while (pCurrentNode->pChildLo != nullptr) { pCurrentNode = pCurrentNode->pChildLo; } @@ -69576,10 +69576,10 @@ static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_ { ma_resource_manager_data_buffer_node* pCurrentNode; - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pDataBufferNode != nullptr); pCurrentNode = pDataBufferNode; - while (pCurrentNode->pChildHi != NULL) { + while (pCurrentNode->pChildHi != nullptr) { pCurrentNode = pCurrentNode->pChildHi; } @@ -69588,8 +69588,8 @@ static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_ static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_buffer_node_find_inorder_successor(ma_resource_manager_data_buffer_node* pDataBufferNode) { - MA_ASSERT(pDataBufferNode != NULL); - MA_ASSERT(pDataBufferNode->pChildHi != NULL); + MA_ASSERT(pDataBufferNode != nullptr); + MA_ASSERT(pDataBufferNode->pChildHi != nullptr); return ma_resource_manager_data_buffer_node_find_min(pDataBufferNode->pChildHi); } @@ -69597,8 +69597,8 @@ static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_ #if 0 /* Currently unused, but might make use of this later. */ static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_buffer_node_find_inorder_predecessor(ma_resource_manager_data_buffer_node* pDataBufferNode) { - MA_ASSERT(pDataBufferNode != NULL); - MA_ASSERT(pDataBufferNode->pChildLo != NULL); + MA_ASSERT(pDataBufferNode != nullptr); + MA_ASSERT(pDataBufferNode->pChildLo != nullptr); return ma_resource_manager_data_buffer_node_find_max(pDataBufferNode->pChildLo); } @@ -69606,27 +69606,27 @@ static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_ static ma_result ma_resource_manager_data_buffer_node_remove(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode) { - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); - if (pDataBufferNode->pChildLo == NULL) { - if (pDataBufferNode->pChildHi == NULL) { + if (pDataBufferNode->pChildLo == nullptr) { + if (pDataBufferNode->pChildHi == nullptr) { /* Simple case - deleting a buffer with no children. */ - if (pDataBufferNode->pParent == NULL) { + if (pDataBufferNode->pParent == nullptr) { MA_ASSERT(pResourceManager->pRootDataBufferNode == pDataBufferNode); /* There is only a single buffer in the tree which should be equal to the root node. */ - pResourceManager->pRootDataBufferNode = NULL; + pResourceManager->pRootDataBufferNode = nullptr; } else { if (pDataBufferNode->pParent->pChildLo == pDataBufferNode) { - pDataBufferNode->pParent->pChildLo = NULL; + pDataBufferNode->pParent->pChildLo = nullptr; } else { - pDataBufferNode->pParent->pChildHi = NULL; + pDataBufferNode->pParent->pChildHi = nullptr; } } } else { - /* Node has one child - pChildHi != NULL. */ + /* Node has one child - pChildHi != nullptr. */ pDataBufferNode->pChildHi->pParent = pDataBufferNode->pParent; - if (pDataBufferNode->pParent == NULL) { + if (pDataBufferNode->pParent == nullptr) { MA_ASSERT(pResourceManager->pRootDataBufferNode == pDataBufferNode); pResourceManager->pRootDataBufferNode = pDataBufferNode->pChildHi; } else { @@ -69638,11 +69638,11 @@ static ma_result ma_resource_manager_data_buffer_node_remove(ma_resource_manager } } } else { - if (pDataBufferNode->pChildHi == NULL) { - /* Node has one child - pChildLo != NULL. */ + if (pDataBufferNode->pChildHi == nullptr) { + /* Node has one child - pChildLo != nullptr. */ pDataBufferNode->pChildLo->pParent = pDataBufferNode->pParent; - if (pDataBufferNode->pParent == NULL) { + if (pDataBufferNode->pParent == nullptr) { MA_ASSERT(pResourceManager->pRootDataBufferNode == pDataBufferNode); pResourceManager->pRootDataBufferNode = pDataBufferNode->pChildLo; } else { @@ -69658,7 +69658,7 @@ static ma_result ma_resource_manager_data_buffer_node_remove(ma_resource_manager /* For now we are just going to use the in-order successor as the replacement, but we may want to try to keep this balanced by switching between the two. */ pReplacementDataBufferNode = ma_resource_manager_data_buffer_node_find_inorder_successor(pDataBufferNode); - MA_ASSERT(pReplacementDataBufferNode != NULL); + MA_ASSERT(pReplacementDataBufferNode != nullptr); /* Now that we have our replacement node we can make the change. The simple way to do this would be to just exchange the values, and then remove the replacement @@ -69666,14 +69666,14 @@ static ma_result ma_resource_manager_data_buffer_node_remove(ma_resource_manager replacement node should have at most 1 child. Therefore, we can detach it in terms of our simpler cases above. What we're essentially doing is detaching the replacement node and reinserting it into the same position as the deleted node. */ - MA_ASSERT(pReplacementDataBufferNode->pParent != NULL); /* The replacement node should never be the root which means it should always have a parent. */ - MA_ASSERT(pReplacementDataBufferNode->pChildLo == NULL); /* Because we used in-order successor. This would be pChildHi == NULL if we used in-order predecessor. */ + MA_ASSERT(pReplacementDataBufferNode->pParent != nullptr); /* The replacement node should never be the root which means it should always have a parent. */ + MA_ASSERT(pReplacementDataBufferNode->pChildLo == nullptr); /* Because we used in-order successor. This would be pChildHi == nullptr if we used in-order predecessor. */ - if (pReplacementDataBufferNode->pChildHi == NULL) { + if (pReplacementDataBufferNode->pChildHi == nullptr) { if (pReplacementDataBufferNode->pParent->pChildLo == pReplacementDataBufferNode) { - pReplacementDataBufferNode->pParent->pChildLo = NULL; + pReplacementDataBufferNode->pParent->pChildLo = nullptr; } else { - pReplacementDataBufferNode->pParent->pChildHi = NULL; + pReplacementDataBufferNode->pParent->pChildHi = nullptr; } } else { pReplacementDataBufferNode->pChildHi->pParent = pReplacementDataBufferNode->pParent; @@ -69686,7 +69686,7 @@ static ma_result ma_resource_manager_data_buffer_node_remove(ma_resource_manager /* The replacement node has essentially been detached from the binary tree, so now we need to replace the old data buffer with it. The first thing to update is the parent */ - if (pDataBufferNode->pParent != NULL) { + if (pDataBufferNode->pParent != nullptr) { if (pDataBufferNode->pParent->pChildLo == pDataBufferNode) { pDataBufferNode->pParent->pChildLo = pReplacementDataBufferNode; } else { @@ -69700,10 +69700,10 @@ static ma_result ma_resource_manager_data_buffer_node_remove(ma_resource_manager pReplacementDataBufferNode->pChildHi = pDataBufferNode->pChildHi; /* Now the children of the replacement node need to have their parent pointers updated. */ - if (pReplacementDataBufferNode->pChildLo != NULL) { + if (pReplacementDataBufferNode->pChildLo != nullptr) { pReplacementDataBufferNode->pChildLo->pParent = pReplacementDataBufferNode; } - if (pReplacementDataBufferNode->pChildHi != NULL) { + if (pReplacementDataBufferNode->pChildHi != nullptr) { pReplacementDataBufferNode->pChildHi->pParent = pReplacementDataBufferNode; } @@ -69746,14 +69746,14 @@ static ma_result ma_resource_manager_data_buffer_node_increment_ref(ma_resource_ { ma_uint32 refCount; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); (void)pResourceManager; refCount = ma_atomic_fetch_add_32(&pDataBufferNode->refCount, 1) + 1; - if (pNewRefCount != NULL) { + if (pNewRefCount != nullptr) { *pNewRefCount = refCount; } @@ -69764,14 +69764,14 @@ static ma_result ma_resource_manager_data_buffer_node_decrement_ref(ma_resource_ { ma_uint32 refCount; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); (void)pResourceManager; refCount = ma_atomic_fetch_sub_32(&pDataBufferNode->refCount, 1) - 1; - if (pNewRefCount != NULL) { + if (pNewRefCount != nullptr) { *pNewRefCount = refCount; } @@ -69780,17 +69780,17 @@ static ma_result ma_resource_manager_data_buffer_node_decrement_ref(ma_resource_ static void ma_resource_manager_data_buffer_node_free(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode) { - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); if (pDataBufferNode->isDataOwnedByResourceManager) { if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode) == ma_resource_manager_data_supply_type_encoded) { ma_free((void*)pDataBufferNode->data.backend.encoded.pData, &pResourceManager->config.allocationCallbacks); - pDataBufferNode->data.backend.encoded.pData = NULL; + pDataBufferNode->data.backend.encoded.pData = nullptr; pDataBufferNode->data.backend.encoded.sizeInBytes = 0; } else if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode) == ma_resource_manager_data_supply_type_decoded) { ma_free((void*)pDataBufferNode->data.backend.decoded.pData, &pResourceManager->config.allocationCallbacks); - pDataBufferNode->data.backend.decoded.pData = NULL; + pDataBufferNode->data.backend.decoded.pData = nullptr; pDataBufferNode->data.backend.decoded.totalFrameCount = 0; } else if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode) == ma_resource_manager_data_supply_type_decoded_paged) { ma_paged_audio_buffer_data_uninit(&pDataBufferNode->data.backend.decodedPaged.data, &pResourceManager->config.allocationCallbacks); @@ -69806,7 +69806,7 @@ static void ma_resource_manager_data_buffer_node_free(ma_resource_manager* pReso static ma_result ma_resource_manager_data_buffer_node_result(const ma_resource_manager_data_buffer_node* pDataBufferNode) { - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pDataBufferNode != nullptr); return (ma_result)ma_atomic_load_i32((ma_result*)&pDataBufferNode->result); /* Need a naughty const-cast here. */ } @@ -69814,7 +69814,7 @@ static ma_result ma_resource_manager_data_buffer_node_result(const ma_resource_m static ma_bool32 ma_resource_manager_is_threading_enabled(const ma_resource_manager* pResourceManager) { - MA_ASSERT(pResourceManager != NULL); + MA_ASSERT(pResourceManager != nullptr); return (pResourceManager->config.flags & MA_RESOURCE_MANAGER_FLAG_NO_THREADING) == 0; } @@ -69832,8 +69832,8 @@ typedef struct static ma_result ma_resource_manager_inline_notification_init(ma_resource_manager* pResourceManager, ma_resource_manager_inline_notification* pNotification) { - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pNotification != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pNotification != nullptr); pNotification->pResourceManager = pResourceManager; @@ -69846,7 +69846,7 @@ static ma_result ma_resource_manager_inline_notification_init(ma_resource_manage static void ma_resource_manager_inline_notification_uninit(ma_resource_manager_inline_notification* pNotification) { - MA_ASSERT(pNotification != NULL); + MA_ASSERT(pNotification != nullptr); if (ma_resource_manager_is_threading_enabled(pNotification->pResourceManager)) { ma_async_notification_event_uninit(&pNotification->backend.e); @@ -69857,7 +69857,7 @@ static void ma_resource_manager_inline_notification_uninit(ma_resource_manager_i static void ma_resource_manager_inline_notification_wait(ma_resource_manager_inline_notification* pNotification) { - MA_ASSERT(pNotification != NULL); + MA_ASSERT(pNotification != nullptr); if (ma_resource_manager_is_threading_enabled(pNotification->pResourceManager)) { ma_async_notification_event_wait(&pNotification->backend.e); @@ -69880,7 +69880,7 @@ static void ma_resource_manager_inline_notification_wait_and_uninit(ma_resource_ static void ma_resource_manager_data_buffer_bst_lock(ma_resource_manager* pResourceManager) { - MA_ASSERT(pResourceManager != NULL); + MA_ASSERT(pResourceManager != nullptr); if (ma_resource_manager_is_threading_enabled(pResourceManager)) { #ifndef MA_NO_THREADING @@ -69899,7 +69899,7 @@ static void ma_resource_manager_data_buffer_bst_lock(ma_resource_manager* pResou static void ma_resource_manager_data_buffer_bst_unlock(ma_resource_manager* pResourceManager) { - MA_ASSERT(pResourceManager != NULL); + MA_ASSERT(pResourceManager != nullptr); if (ma_resource_manager_is_threading_enabled(pResourceManager)) { #ifndef MA_NO_THREADING @@ -69920,7 +69920,7 @@ static void ma_resource_manager_data_buffer_bst_unlock(ma_resource_manager* pRes static ma_thread_result MA_THREADCALL ma_resource_manager_job_thread(void* pUserData) { ma_resource_manager* pResourceManager = (ma_resource_manager*)pUserData; - MA_ASSERT(pResourceManager != NULL); + MA_ASSERT(pResourceManager != nullptr); for (;;) { ma_result result; @@ -69974,13 +69974,13 @@ MA_API ma_result ma_resource_manager_init(const ma_resource_manager_config* pCon ma_result result; ma_job_queue_config jobQueueConfig; - if (pResourceManager == NULL) { + if (pResourceManager == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pResourceManager); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -69996,16 +69996,16 @@ MA_API ma_result ma_resource_manager_init(const ma_resource_manager_config* pCon ma_allocation_callbacks_init_copy(&pResourceManager->config.allocationCallbacks, &pConfig->allocationCallbacks); /* Get the log set up early so we can start using it as soon as possible. */ - if (pResourceManager->config.pLog == NULL) { + if (pResourceManager->config.pLog == nullptr) { result = ma_log_init(&pResourceManager->config.allocationCallbacks, &pResourceManager->log); if (result == MA_SUCCESS) { pResourceManager->config.pLog = &pResourceManager->log; } else { - pResourceManager->config.pLog = NULL; /* Logging is unavailable. */ + pResourceManager->config.pLog = nullptr; /* Logging is unavailable. */ } } - if (pResourceManager->config.pVFS == NULL) { + if (pResourceManager->config.pVFS == nullptr) { result = ma_default_vfs_init(&pResourceManager->defaultVFS, &pResourceManager->config.allocationCallbacks); if (result != MA_SUCCESS) { return result; /* Failed to initialize the default file system. */ @@ -70049,12 +70049,12 @@ MA_API ma_result ma_resource_manager_init(const ma_resource_manager_config* pCon /* Custom decoding backends. */ - if (pConfig->ppCustomDecodingBackendVTables != NULL && pConfig->customDecodingBackendCount > 0) { + if (pConfig->ppCustomDecodingBackendVTables != nullptr && pConfig->customDecodingBackendCount > 0) { size_t sizeInBytes = sizeof(*pResourceManager->config.ppCustomDecodingBackendVTables) * pConfig->customDecodingBackendCount; ma_decoding_backend_vtable** ppCustomDecodingBackendVTables; ppCustomDecodingBackendVTables = (ma_decoding_backend_vtable**)ma_malloc(sizeInBytes, &pResourceManager->config.allocationCallbacks); - if (pResourceManager->config.ppCustomDecodingBackendVTables == NULL) { + if (pResourceManager->config.ppCustomDecodingBackendVTables == nullptr) { ma_job_queue_uninit(&pResourceManager->jobQueue, &pResourceManager->config.allocationCallbacks); return MA_OUT_OF_MEMORY; } @@ -70108,7 +70108,7 @@ static void ma_resource_manager_delete_all_data_buffer_nodes(ma_resource_manager MA_ASSERT(pResourceManager); /* If everything was done properly, there shouldn't be any active data buffers. */ - while (pResourceManager->pRootDataBufferNode != NULL) { + while (pResourceManager->pRootDataBufferNode != nullptr) { ma_resource_manager_data_buffer_node* pDataBufferNode = pResourceManager->pRootDataBufferNode; ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode); @@ -70119,7 +70119,7 @@ static void ma_resource_manager_delete_all_data_buffer_nodes(ma_resource_manager MA_API void ma_resource_manager_uninit(ma_resource_manager* pResourceManager) { - if (pResourceManager == NULL) { + if (pResourceManager == nullptr) { return; } @@ -70174,8 +70174,8 @@ MA_API void ma_resource_manager_uninit(ma_resource_manager* pResourceManager) MA_API ma_log* ma_resource_manager_get_log(ma_resource_manager* pResourceManager) { - if (pResourceManager == NULL) { - return NULL; + if (pResourceManager == nullptr) { + return nullptr; } return pResourceManager->config.pLog; @@ -70217,13 +70217,13 @@ static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourc ma_result result; ma_decoder_config config; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pFilePath != NULL || pFilePathW != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pFilePath != nullptr || pFilePathW != nullptr); + MA_ASSERT(pDecoder != nullptr); config = ma_resource_manager__init_decoder_config(pResourceManager); - if (pFilePath != NULL) { + if (pFilePath != nullptr) { result = ma_decoder_init_vfs(pResourceManager->config.pVFS, pFilePath, &config, pDecoder); if (result != MA_SUCCESS) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%s\". %s.\n", pFilePath, ma_result_description(result)); @@ -70250,7 +70250,7 @@ static ma_bool32 ma_resource_manager_data_buffer_has_connector(ma_resource_manag static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource_manager_data_buffer* pDataBuffer) { if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE) { - return NULL; /* Connector not yet initialized. */ + return nullptr; /* Connector not yet initialized. */ } switch (pDataBuffer->pNode->data.type) @@ -70263,7 +70263,7 @@ static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource default: { ma_log_postf(ma_resource_manager_get_log(pDataBuffer->pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to retrieve data buffer connector. Unknown data supply type.\n"); - return NULL; + return nullptr; }; }; } @@ -70272,8 +70272,8 @@ static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_mana { ma_result result; - MA_ASSERT(pDataBuffer != NULL); - MA_ASSERT(pConfig != NULL); + MA_ASSERT(pDataBuffer != nullptr); + MA_ASSERT(pConfig != nullptr); MA_ASSERT(ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE); /* The underlying data buffer must be initialized before we'll be able to know how to initialize the backend. */ @@ -70299,7 +70299,7 @@ static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_mana case ma_resource_manager_data_supply_type_decoded: /* Connector is an audio buffer. */ { ma_audio_buffer_config config; - config = ma_audio_buffer_config_init(pDataBuffer->pNode->data.backend.decoded.format, pDataBuffer->pNode->data.backend.decoded.channels, pDataBuffer->pNode->data.backend.decoded.totalFrameCount, pDataBuffer->pNode->data.backend.decoded.pData, NULL); + config = ma_audio_buffer_config_init(pDataBuffer->pNode->data.backend.decoded.format, pDataBuffer->pNode->data.backend.decoded.channels, pDataBuffer->pNode->data.backend.decoded.totalFrameCount, pDataBuffer->pNode->data.backend.decoded.pData, nullptr); result = ma_audio_buffer_init(&config, &pDataBuffer->connector.buffer); } break; @@ -70349,11 +70349,11 @@ static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_mana ma_atomic_bool32_set(&pDataBuffer->isConnectorInitialized, MA_TRUE); - if (pInitNotification != NULL) { + if (pInitNotification != nullptr) { ma_async_notification_signal(pInitNotification); } - if (pInitFence != NULL) { + if (pInitFence != nullptr) { ma_fence_release(pInitFence); } } @@ -70364,8 +70364,8 @@ static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_mana static ma_result ma_resource_manager_data_buffer_uninit_connector(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer* pDataBuffer) { - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBuffer != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBuffer != nullptr); (void)pResourceManager; @@ -70399,7 +70399,7 @@ static ma_result ma_resource_manager_data_buffer_uninit_connector(ma_resource_ma static ma_uint32 ma_resource_manager_data_buffer_node_next_execution_order(ma_resource_manager_data_buffer_node* pDataBufferNode) { - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pDataBufferNode != nullptr); return ma_atomic_fetch_add_32(&pDataBufferNode->executionCounter, 1); } @@ -70409,13 +70409,13 @@ static ma_result ma_resource_manager_data_buffer_node_init_supply_encoded(ma_res size_t dataSizeInBytes; void* pData; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); - MA_ASSERT(pFilePath != NULL || pFilePathW != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); + MA_ASSERT(pFilePath != nullptr || pFilePathW != nullptr); result = ma_vfs_open_and_read_file_ex(pResourceManager->config.pVFS, pFilePath, pFilePathW, &pData, &dataSizeInBytes, &pResourceManager->config.allocationCallbacks); if (result != MA_SUCCESS) { - if (pFilePath != NULL) { + if (pFilePath != nullptr) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%s\". %s.\n", pFilePath, ma_result_description(result)); } else { #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(_MSC_VER) @@ -70439,15 +70439,15 @@ static ma_result ma_resource_manager_data_buffer_node_init_supply_decoded(ma_res ma_decoder* pDecoder; ma_uint64 totalFrameCount; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); - MA_ASSERT(ppDecoder != NULL); - MA_ASSERT(pFilePath != NULL || pFilePathW != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); + MA_ASSERT(ppDecoder != nullptr); + MA_ASSERT(pFilePath != nullptr || pFilePathW != nullptr); - *ppDecoder = NULL; /* For safety. */ + *ppDecoder = nullptr; /* For safety. */ pDecoder = (ma_decoder*)ma_malloc(sizeof(*pDecoder), &pResourceManager->config.allocationCallbacks); - if (pDecoder == NULL) { + if (pDecoder == nullptr) { return MA_OUT_OF_MEMORY; } @@ -70485,7 +70485,7 @@ static ma_result ma_resource_manager_data_buffer_node_init_supply_decoded(ma_res } pData = ma_malloc((size_t)dataSizeInBytes, &pResourceManager->config.allocationCallbacks); - if (pData == NULL) { + if (pData == nullptr) { ma_decoder_uninit(pDecoder); ma_free(pDecoder, &pResourceManager->config.allocationCallbacks); return MA_OUT_OF_MEMORY; @@ -70532,9 +70532,9 @@ static ma_result ma_resource_manager_data_buffer_node_decode_next_page(ma_resour ma_uint64 framesToTryReading; ma_uint64 framesRead; - MA_ASSERT(pResourceManager != NULL); - MA_ASSERT(pDataBufferNode != NULL); - MA_ASSERT(pDecoder != NULL); + MA_ASSERT(pResourceManager != nullptr); + MA_ASSERT(pDataBufferNode != nullptr); + MA_ASSERT(pDecoder != nullptr); /* We need to know the size of a page in frames to know how many frames to decode. */ pageSizeInFrames = MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS * (pDecoder->outputSampleRate/1000); @@ -70562,7 +70562,7 @@ static ma_result ma_resource_manager_data_buffer_node_decode_next_page(ma_resour pDataBufferNode->data.backend.decoded.pData, pDataBufferNode->data.backend.decoded.decodedFrameCount * ma_get_bytes_per_frame(pDataBufferNode->data.backend.decoded.format, pDataBufferNode->data.backend.decoded.channels) ); - MA_ASSERT(pDst != NULL); + MA_ASSERT(pDst != nullptr); result = ma_decoder_read_pcm_frames(pDecoder, pDst, framesToTryReading, &framesRead); if (framesRead > 0) { @@ -70578,7 +70578,7 @@ static ma_result ma_resource_manager_data_buffer_node_decode_next_page(ma_resour /* The destination buffer is a freshly allocated page. */ ma_paged_audio_buffer_page* pPage; - result = ma_paged_audio_buffer_data_allocate_page(&pDataBufferNode->data.backend.decodedPaged.data, framesToTryReading, NULL, &pResourceManager->config.allocationCallbacks, &pPage); + result = ma_paged_audio_buffer_data_allocate_page(&pDataBufferNode->data.backend.decodedPaged.data, framesToTryReading, nullptr, &pResourceManager->config.allocationCallbacks, &pPage); if (result != MA_SUCCESS) { return result; } @@ -70622,11 +70622,11 @@ static ma_result ma_resource_manager_data_buffer_node_decode_next_page(ma_resour static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(ma_resource_manager* pResourceManager, const char* pFilePath, const wchar_t* pFilePathW, ma_uint32 hashedName32, ma_uint32 flags, const ma_resource_manager_data_supply* pExistingData, ma_fence* pInitFence, ma_fence* pDoneFence, ma_resource_manager_inline_notification* pInitNotification, ma_resource_manager_data_buffer_node** ppDataBufferNode) { ma_result result = MA_SUCCESS; - ma_resource_manager_data_buffer_node* pDataBufferNode = NULL; + ma_resource_manager_data_buffer_node* pDataBufferNode = nullptr; ma_resource_manager_data_buffer_node* pInsertPoint; - if (ppDataBufferNode != NULL) { - *ppDataBufferNode = NULL; + if (ppDataBufferNode != nullptr) { + *ppDataBufferNode = nullptr; } result = ma_resource_manager_data_buffer_node_insert_point(pResourceManager, hashedName32, &pInsertPoint); @@ -70634,7 +70634,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m /* The node already exists. We just need to increment the reference count. */ pDataBufferNode = pInsertPoint; - result = ma_resource_manager_data_buffer_node_increment_ref(pResourceManager, pDataBufferNode, NULL); + result = ma_resource_manager_data_buffer_node_increment_ref(pResourceManager, pDataBufferNode, nullptr); if (result != MA_SUCCESS) { return result; /* Should never happen. Failed to increment the reference count. */ } @@ -70648,7 +70648,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m does not occur before initialization on another thread. */ pDataBufferNode = (ma_resource_manager_data_buffer_node*)ma_malloc(sizeof(*pDataBufferNode), &pResourceManager->config.allocationCallbacks); - if (pDataBufferNode == NULL) { + if (pDataBufferNode == nullptr) { return MA_OUT_OF_MEMORY; } @@ -70656,7 +70656,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m pDataBufferNode->hashedName32 = hashedName32; pDataBufferNode->refCount = 1; /* Always set to 1 by default (this is our first reference). */ - if (pExistingData == NULL) { + if (pExistingData == nullptr) { pDataBufferNode->data.type = ma_resource_manager_data_supply_type_unknown; /* <-- We won't know this until we start decoding. */ pDataBufferNode->result = MA_BUSY; /* Must be set to MA_BUSY before we leave the critical section, so might as well do it now. */ pDataBufferNode->isDataOwnedByResourceManager = MA_TRUE; @@ -70680,17 +70680,17 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m if (pDataBufferNode->isDataOwnedByResourceManager && (flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC) != 0) { /* Loading asynchronously. Post the job. */ ma_job job; - char* pFilePathCopy = NULL; - wchar_t* pFilePathWCopy = NULL; + char* pFilePathCopy = nullptr; + wchar_t* pFilePathWCopy = nullptr; /* We need a copy of the file path. We should probably make this more efficient, but for now we'll do a transient memory allocation. */ - if (pFilePath != NULL) { + if (pFilePath != nullptr) { pFilePathCopy = ma_copy_string(pFilePath, &pResourceManager->config.allocationCallbacks); } else { pFilePathWCopy = ma_copy_string_w(pFilePathW, &pResourceManager->config.allocationCallbacks); } - if (pFilePathCopy == NULL && pFilePathWCopy == NULL) { + if (pFilePathCopy == nullptr && pFilePathWCopy == nullptr) { ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode); ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks); return MA_OUT_OF_MEMORY; @@ -70701,8 +70701,8 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m } /* Acquire init and done fences before posting the job. These will be unacquired by the job thread. */ - if (pInitFence != NULL) { ma_fence_acquire(pInitFence); } - if (pDoneFence != NULL) { ma_fence_acquire(pDoneFence); } + if (pInitFence != nullptr) { ma_fence_acquire(pInitFence); } + if (pDoneFence != nullptr) { ma_fence_acquire(pDoneFence); } /* We now have everything we need to post the job to the job thread. */ job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE); @@ -70712,8 +70712,8 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m job.data.resourceManager.loadDataBufferNode.pFilePath = pFilePathCopy; job.data.resourceManager.loadDataBufferNode.pFilePathW = pFilePathWCopy; job.data.resourceManager.loadDataBufferNode.flags = flags; - job.data.resourceManager.loadDataBufferNode.pInitNotification = ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) ? pInitNotification : NULL; - job.data.resourceManager.loadDataBufferNode.pDoneNotification = NULL; + job.data.resourceManager.loadDataBufferNode.pInitNotification = ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) ? pInitNotification : nullptr; + job.data.resourceManager.loadDataBufferNode.pDoneNotification = nullptr; job.data.resourceManager.loadDataBufferNode.pInitFence = pInitFence; job.data.resourceManager.loadDataBufferNode.pDoneFence = pDoneFence; @@ -70737,8 +70737,8 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m In the WAIT_INIT case, these will have already been released in ma_job_process() so we should only release fences in this branch. */ - if (pInitFence != NULL) { ma_fence_release(pInitFence); } - if (pDoneFence != NULL) { ma_fence_release(pDoneFence); } + if (pInitFence != nullptr) { ma_fence_release(pInitFence); } + if (pDoneFence != nullptr) { ma_fence_release(pDoneFence); } /* These will have been freed by the job thread, but with WAIT_INIT they will already have happened since the job has already been handled. */ ma_free(pFilePathCopy, &pResourceManager->config.allocationCallbacks); @@ -70754,7 +70754,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m } done: - if (ppDataBufferNode != NULL) { + if (ppDataBufferNode != nullptr) { *ppDataBufferNode = pDataBufferNode; } @@ -70765,19 +70765,19 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage { ma_result result = MA_SUCCESS; ma_bool32 nodeAlreadyExists = MA_FALSE; - ma_resource_manager_data_buffer_node* pDataBufferNode = NULL; + ma_resource_manager_data_buffer_node* pDataBufferNode = nullptr; ma_resource_manager_inline_notification initNotification; /* Used when the WAIT_INIT flag is set. */ - if (ppDataBufferNode != NULL) { - *ppDataBufferNode = NULL; /* Safety. */ + if (ppDataBufferNode != nullptr) { + *ppDataBufferNode = nullptr; /* Safety. */ } - if (pResourceManager == NULL || (pFilePath == NULL && pFilePathW == NULL && hashedName32 == 0)) { + if (pResourceManager == nullptr || (pFilePath == nullptr && pFilePathW == nullptr && hashedName32 == 0)) { return MA_INVALID_ARGS; } /* If we're specifying existing data, it must be valid. */ - if (pExistingData != NULL && pExistingData->type == ma_resource_manager_data_supply_type_unknown) { + if (pExistingData != nullptr && pExistingData->type == ma_resource_manager_data_supply_type_unknown) { return MA_INVALID_ARGS; } @@ -70787,7 +70787,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage } if (hashedName32 == 0) { - if (pFilePath != NULL) { + if (pFilePath != nullptr) { hashedName32 = ma_hash_string_32(pFilePath); } else { hashedName32 = ma_hash_string_w_32(pFilePathW); @@ -70823,7 +70823,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage the node is initialized by the decoding thread(s). */ if (nodeAlreadyExists == MA_FALSE) { /* Don't need to try loading anything if the node already exists. */ - if (pFilePath == NULL && pFilePathW == NULL) { + if (pFilePath == nullptr && pFilePathW == nullptr) { /* If this path is hit, it means a buffer is being copied (i.e. initialized from only the hashed name), but that node has been freed in the meantime, probably from some other @@ -70883,7 +70883,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage } } else { /* The data is not managed by the resource manager so there's nothing else to do. */ - MA_ASSERT(pExistingData != NULL); + MA_ASSERT(pExistingData != nullptr); } } @@ -70906,7 +70906,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage } } - if (ppDataBufferNode != NULL) { + if (ppDataBufferNode != nullptr) { *ppDataBufferNode = pDataBufferNode; } @@ -70919,16 +70919,16 @@ static ma_result ma_resource_manager_data_buffer_node_unacquire(ma_resource_mana ma_uint32 refCount = 0xFFFFFFFF; /* The new reference count of the node after decrementing. Initialize to non-0 to be safe we don't fall into the freeing path. */ ma_uint32 hashedName32 = 0; - if (pResourceManager == NULL) { + if (pResourceManager == nullptr) { return MA_INVALID_ARGS; } - if (pDataBufferNode == NULL) { - if (pName == NULL && pNameW == NULL) { + if (pDataBufferNode == nullptr) { + if (pName == nullptr && pNameW == nullptr) { return MA_INVALID_ARGS; } - if (pName != NULL) { + if (pName != nullptr) { hashedName32 = ma_hash_string_32(pName); } else { hashedName32 = ma_hash_string_w_32(pNameW); @@ -70943,7 +70943,7 @@ static ma_result ma_resource_manager_data_buffer_node_unacquire(ma_resource_mana ma_resource_manager_data_buffer_bst_lock(pResourceManager); { /* Might need to find the node. Must be done inside the critical section. */ - if (pDataBufferNode == NULL) { + if (pDataBufferNode == nullptr) { result = ma_resource_manager_data_buffer_node_search(pResourceManager, hashedName32, &pDataBufferNode); if (result != MA_SUCCESS) { goto stage2; /* Couldn't find the node. */ @@ -71017,7 +71017,7 @@ static ma_result ma_resource_manager_data_buffer_node_unacquire(ma_resource_mana static ma_uint32 ma_resource_manager_data_buffer_next_execution_order(ma_resource_manager_data_buffer* pDataBuffer) { - MA_ASSERT(pDataBuffer != NULL); + MA_ASSERT(pDataBuffer != nullptr); return ma_atomic_fetch_add_32(&pDataBuffer->executionCounter, 1); } @@ -71049,7 +71049,7 @@ static ma_result ma_resource_manager_data_buffer_cb__get_length_in_pcm_frames(ma static ma_result ma_resource_manager_data_buffer_cb__set_looping(ma_data_source* pDataSource, ma_bool32 isLooping) { ma_resource_manager_data_buffer* pDataBuffer = (ma_resource_manager_data_buffer*)pDataSource; - MA_ASSERT(pDataBuffer != NULL); + MA_ASSERT(pDataBuffer != nullptr); ma_atomic_exchange_32(&pDataBuffer->isLooping, isLooping); @@ -71079,8 +71079,8 @@ static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_ma ma_uint32 flags; ma_resource_manager_pipeline_notifications notifications; - if (pDataBuffer == NULL) { - if (pConfig != NULL && pConfig->pNotifications != NULL) { + if (pDataBuffer == nullptr) { + if (pConfig != nullptr && pConfig->pNotifications != nullptr) { ma_resource_manager_pipeline_notifications_signal_all_notifications(pConfig->pNotifications); } @@ -71089,12 +71089,12 @@ static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_ma MA_ZERO_OBJECT(pDataBuffer); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - if (pConfig->pNotifications != NULL) { - notifications = *pConfig->pNotifications; /* From here on out we should be referencing `notifications` instead of `pNotifications`. Set this to NULL to catch errors at testing time. */ + if (pConfig->pNotifications != nullptr) { + notifications = *pConfig->pNotifications; /* From here on out we should be referencing `notifications` instead of `pNotifications`. Set this to nullptr to catch errors at testing time. */ } else { MA_ZERO_OBJECT(¬ifications); } @@ -71126,7 +71126,7 @@ static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_ma ma_resource_manager_pipeline_notifications_acquire_all_fences(¬ifications); { /* We first need to acquire a node. If ASYNC is not set, this will not return until the entire sound has been loaded. */ - result = ma_resource_manager_data_buffer_node_acquire(pResourceManager, pConfig->pFilePath, pConfig->pFilePathW, hashedName32, flags, NULL, notifications.init.pFence, notifications.done.pFence, &pDataBufferNode); + result = ma_resource_manager_data_buffer_node_acquire(pResourceManager, pConfig->pFilePath, pConfig->pFilePathW, hashedName32, flags, nullptr, notifications.init.pFence, notifications.done.pFence, &pDataBufferNode); if (result != MA_SUCCESS) { ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); goto done; @@ -71137,7 +71137,7 @@ static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_ma result = ma_data_source_init(&dataSourceConfig, &pDataBuffer->ds); if (result != MA_SUCCESS) { - ma_resource_manager_data_buffer_node_unacquire(pResourceManager, pDataBufferNode, NULL, NULL); + ma_resource_manager_data_buffer_node_unacquire(pResourceManager, pDataBufferNode, nullptr, nullptr); ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); goto done; } @@ -71150,7 +71150,7 @@ static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_ma /* If we're loading asynchronously we need to post a job to the job queue to initialize the connector. */ if (async == MA_FALSE || ma_resource_manager_data_buffer_node_result(pDataBufferNode) == MA_SUCCESS) { /* Loading synchronously or the data has already been fully loaded. We can just initialize the connector from here without a job. */ - result = ma_resource_manager_data_buffer_init_connector(pDataBuffer, pConfig, NULL, NULL); + result = ma_resource_manager_data_buffer_init_connector(pDataBuffer, pConfig, nullptr, nullptr); ma_atomic_exchange_i32(&pDataBuffer->result, result); ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); @@ -71205,7 +71205,7 @@ static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_ma if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { ma_resource_manager_inline_notification_wait(&initNotification); - if (notifications.init.pNotification != NULL) { + if (notifications.init.pNotification != nullptr) { ma_async_notification_signal(notifications.init.pNotification); } @@ -71225,7 +71225,7 @@ static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_ma } if (result != MA_SUCCESS) { - ma_resource_manager_data_buffer_node_unacquire(pResourceManager, pDataBufferNode, NULL, NULL); + ma_resource_manager_data_buffer_node_unacquire(pResourceManager, pDataBufferNode, nullptr, nullptr); goto done; } } @@ -71274,11 +71274,11 @@ MA_API ma_result ma_resource_manager_data_buffer_init_copy(ma_resource_manager* { ma_resource_manager_data_source_config config; - if (pExistingDataBuffer == NULL) { + if (pExistingDataBuffer == nullptr) { return MA_INVALID_ARGS; } - MA_ASSERT(pExistingDataBuffer->pNode != NULL); /* <-- If you've triggered this, you've passed in an invalid existing data buffer. */ + MA_ASSERT(pExistingDataBuffer->pNode != nullptr); /* <-- If you've triggered this, you've passed in an invalid existing data buffer. */ config = ma_resource_manager_data_source_config_init(); config.flags = pExistingDataBuffer->flags; @@ -71288,13 +71288,13 @@ MA_API ma_result ma_resource_manager_data_buffer_init_copy(ma_resource_manager* static ma_result ma_resource_manager_data_buffer_uninit_internal(ma_resource_manager_data_buffer* pDataBuffer) { - MA_ASSERT(pDataBuffer != NULL); + MA_ASSERT(pDataBuffer != nullptr); /* The connector should be uninitialized first. */ ma_resource_manager_data_buffer_uninit_connector(pDataBuffer->pResourceManager, pDataBuffer); /* With the connector uninitialized we can unacquire the node. */ - ma_resource_manager_data_buffer_node_unacquire(pDataBuffer->pResourceManager, pDataBuffer->pNode, NULL, NULL); + ma_resource_manager_data_buffer_node_unacquire(pDataBuffer->pResourceManager, pDataBuffer->pNode, nullptr, nullptr); /* The base data source needs to be uninitialized as well. */ ma_data_source_uninit(&pDataBuffer->ds); @@ -71306,7 +71306,7 @@ MA_API ma_result ma_resource_manager_data_buffer_uninit(ma_resource_manager_data { ma_result result; - if (pDataBuffer == NULL) { + if (pDataBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -71337,7 +71337,7 @@ MA_API ma_result ma_resource_manager_data_buffer_uninit(ma_resource_manager_data job.order = ma_resource_manager_data_buffer_next_execution_order(pDataBuffer); job.data.resourceManager.freeDataBuffer.pDataBuffer = pDataBuffer; job.data.resourceManager.freeDataBuffer.pDoneNotification = ¬ification; - job.data.resourceManager.freeDataBuffer.pDoneFence = NULL; + job.data.resourceManager.freeDataBuffer.pDoneFence = nullptr; result = ma_resource_manager_post_job(pDataBuffer->pResourceManager, &job); if (result != MA_SUCCESS) { @@ -71358,7 +71358,7 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man ma_bool32 isDecodedBufferBusy = MA_FALSE; /* Safety. */ - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -71452,7 +71452,7 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man result = MA_BUSY; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = framesRead; } @@ -71533,7 +71533,7 @@ MA_API ma_result ma_resource_manager_data_buffer_get_data_format(ma_resource_man MA_API ma_result ma_resource_manager_data_buffer_get_cursor_in_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pCursor) { - if (pDataBuffer == NULL || pCursor == NULL) { + if (pDataBuffer == nullptr || pCursor == nullptr) { return MA_INVALID_ARGS; } @@ -71573,7 +71573,7 @@ MA_API ma_result ma_resource_manager_data_buffer_get_cursor_in_pcm_frames(ma_res MA_API ma_result ma_resource_manager_data_buffer_get_length_in_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pLength) { - if (pDataBuffer == NULL || pLength == NULL) { + if (pDataBuffer == nullptr || pLength == nullptr) { return MA_INVALID_ARGS; } @@ -71589,7 +71589,7 @@ MA_API ma_result ma_resource_manager_data_buffer_get_length_in_pcm_frames(ma_res MA_API ma_result ma_resource_manager_data_buffer_result(const ma_resource_manager_data_buffer* pDataBuffer) { - if (pDataBuffer == NULL) { + if (pDataBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -71608,13 +71608,13 @@ MA_API ma_bool32 ma_resource_manager_data_buffer_is_looping(const ma_resource_ma MA_API ma_result ma_resource_manager_data_buffer_get_available_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pAvailableFrames) { - if (pAvailableFrames == NULL) { + if (pAvailableFrames == nullptr) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; - if (pDataBuffer == NULL) { + if (pDataBuffer == nullptr) { return MA_INVALID_ARGS; } @@ -71663,18 +71663,18 @@ MA_API ma_result ma_resource_manager_data_buffer_get_available_frames(ma_resourc MA_API ma_result ma_resource_manager_register_file(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 flags) { - return ma_resource_manager_data_buffer_node_acquire(pResourceManager, pFilePath, NULL, 0, flags, NULL, NULL, NULL, NULL); + return ma_resource_manager_data_buffer_node_acquire(pResourceManager, pFilePath, nullptr, 0, flags, nullptr, nullptr, nullptr, nullptr); } MA_API ma_result ma_resource_manager_register_file_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath, ma_uint32 flags) { - return ma_resource_manager_data_buffer_node_acquire(pResourceManager, NULL, pFilePath, 0, flags, NULL, NULL, NULL, NULL); + return ma_resource_manager_data_buffer_node_acquire(pResourceManager, nullptr, pFilePath, 0, flags, nullptr, nullptr, nullptr, nullptr); } static ma_result ma_resource_manager_register_data(ma_resource_manager* pResourceManager, const char* pName, const wchar_t* pNameW, ma_resource_manager_data_supply* pExistingData) { - return ma_resource_manager_data_buffer_node_acquire(pResourceManager, pName, pNameW, 0, 0, pExistingData, NULL, NULL, NULL); + return ma_resource_manager_data_buffer_node_acquire(pResourceManager, pName, pNameW, 0, 0, pExistingData, nullptr, nullptr, nullptr); } static ma_result ma_resource_manager_register_decoded_data_internal(ma_resource_manager* pResourceManager, const char* pName, const wchar_t* pNameW, const void* pData, ma_uint64 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate) @@ -71692,12 +71692,12 @@ static ma_result ma_resource_manager_register_decoded_data_internal(ma_resource_ MA_API ma_result ma_resource_manager_register_decoded_data(ma_resource_manager* pResourceManager, const char* pName, const void* pData, ma_uint64 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate) { - return ma_resource_manager_register_decoded_data_internal(pResourceManager, pName, NULL, pData, frameCount, format, channels, sampleRate); + return ma_resource_manager_register_decoded_data_internal(pResourceManager, pName, nullptr, pData, frameCount, format, channels, sampleRate); } MA_API ma_result ma_resource_manager_register_decoded_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName, const void* pData, ma_uint64 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate) { - return ma_resource_manager_register_decoded_data_internal(pResourceManager, NULL, pName, pData, frameCount, format, channels, sampleRate); + return ma_resource_manager_register_decoded_data_internal(pResourceManager, nullptr, pName, pData, frameCount, format, channels, sampleRate); } @@ -71713,12 +71713,12 @@ static ma_result ma_resource_manager_register_encoded_data_internal(ma_resource_ MA_API ma_result ma_resource_manager_register_encoded_data(ma_resource_manager* pResourceManager, const char* pName, const void* pData, size_t sizeInBytes) { - return ma_resource_manager_register_encoded_data_internal(pResourceManager, pName, NULL, pData, sizeInBytes); + return ma_resource_manager_register_encoded_data_internal(pResourceManager, pName, nullptr, pData, sizeInBytes); } MA_API ma_result ma_resource_manager_register_encoded_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName, const void* pData, size_t sizeInBytes) { - return ma_resource_manager_register_encoded_data_internal(pResourceManager, NULL, pName, pData, sizeInBytes); + return ma_resource_manager_register_encoded_data_internal(pResourceManager, nullptr, pName, pData, sizeInBytes); } @@ -71734,30 +71734,30 @@ MA_API ma_result ma_resource_manager_unregister_file_w(ma_resource_manager* pRes MA_API ma_result ma_resource_manager_unregister_data(ma_resource_manager* pResourceManager, const char* pName) { - return ma_resource_manager_data_buffer_node_unacquire(pResourceManager, NULL, pName, NULL); + return ma_resource_manager_data_buffer_node_unacquire(pResourceManager, nullptr, pName, nullptr); } MA_API ma_result ma_resource_manager_unregister_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName) { - return ma_resource_manager_data_buffer_node_unacquire(pResourceManager, NULL, NULL, pName); + return ma_resource_manager_data_buffer_node_unacquire(pResourceManager, nullptr, nullptr, pName); } static ma_uint32 ma_resource_manager_data_stream_next_execution_order(ma_resource_manager_data_stream* pDataStream) { - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); return ma_atomic_fetch_add_32(&pDataStream->executionCounter, 1); } static ma_bool32 ma_resource_manager_data_stream_is_decoder_at_end(const ma_resource_manager_data_stream* pDataStream) { - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); return ma_atomic_load_32((ma_bool32*)&pDataStream->isDecoderAtEnd); } static ma_uint32 ma_resource_manager_data_stream_seek_counter(const ma_resource_manager_data_stream* pDataStream) { - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); return ma_atomic_load_32((ma_uint32*)&pDataStream->seekCounter); } @@ -71790,7 +71790,7 @@ static ma_result ma_resource_manager_data_stream_cb__get_length_in_pcm_frames(ma static ma_result ma_resource_manager_data_stream_cb__set_looping(ma_data_source* pDataSource, ma_bool32 isLooping) { ma_resource_manager_data_stream* pDataStream = (ma_resource_manager_data_stream*)pDataSource; - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); ma_atomic_exchange_32(&pDataStream->isLooping, isLooping); @@ -71822,16 +71822,16 @@ MA_API ma_result ma_resource_manager_data_stream_init_ex(ma_resource_manager* pR { ma_result result; ma_data_source_config dataSourceConfig; - char* pFilePathCopy = NULL; - wchar_t* pFilePathWCopy = NULL; + char* pFilePathCopy = nullptr; + wchar_t* pFilePathWCopy = nullptr; ma_job job; ma_bool32 waitBeforeReturning = MA_FALSE; ma_resource_manager_inline_notification waitNotification; ma_resource_manager_pipeline_notifications notifications; ma_uint32 flags; - if (pDataStream == NULL) { - if (pConfig != NULL && pConfig->pNotifications != NULL) { + if (pDataStream == nullptr) { + if (pConfig != nullptr && pConfig->pNotifications != nullptr) { ma_resource_manager_pipeline_notifications_signal_all_notifications(pConfig->pNotifications); } @@ -71840,12 +71840,12 @@ MA_API ma_result ma_resource_manager_data_stream_init_ex(ma_resource_manager* pR MA_ZERO_OBJECT(pDataStream); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - if (pConfig->pNotifications != NULL) { - notifications = *pConfig->pNotifications; /* From here on out, `notifications` should be used instead of `pNotifications`. Setting this to NULL to catch any errors at testing time. */ + if (pConfig->pNotifications != nullptr) { + notifications = *pConfig->pNotifications; /* From here on out, `notifications` should be used instead of `pNotifications`. Setting this to nullptr to catch any errors at testing time. */ } else { MA_ZERO_OBJECT(¬ifications); } @@ -71872,7 +71872,7 @@ MA_API ma_result ma_resource_manager_data_stream_init_ex(ma_resource_manager* pR ma_data_source_set_loop_point_in_pcm_frames(pDataStream, pConfig->loopPointBegInPCMFrames, pConfig->loopPointEndInPCMFrames); ma_data_source_set_looping(pDataStream, (flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_LOOPING) != 0); - if (pResourceManager == NULL || (pConfig->pFilePath == NULL && pConfig->pFilePathW == NULL)) { + if (pResourceManager == nullptr || (pConfig->pFilePath == nullptr && pConfig->pFilePathW == nullptr)) { ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); return MA_INVALID_ARGS; } @@ -71880,13 +71880,13 @@ MA_API ma_result ma_resource_manager_data_stream_init_ex(ma_resource_manager* pR /* We want all access to the VFS and the internal decoder to happen on the job thread just to keep things easier to manage for the VFS. */ /* We need a copy of the file path. We should probably make this more efficient, but for now we'll do a transient memory allocation. */ - if (pConfig->pFilePath != NULL) { + if (pConfig->pFilePath != nullptr) { pFilePathCopy = ma_copy_string(pConfig->pFilePath, &pResourceManager->config.allocationCallbacks); } else { pFilePathWCopy = ma_copy_string_w(pConfig->pFilePathW, &pResourceManager->config.allocationCallbacks); } - if (pFilePathCopy == NULL && pFilePathWCopy == NULL) { + if (pFilePathCopy == nullptr && pFilePathWCopy == nullptr) { ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); return MA_OUT_OF_MEMORY; } @@ -71932,7 +71932,7 @@ MA_API ma_result ma_resource_manager_data_stream_init_ex(ma_resource_manager* pR if (waitBeforeReturning) { ma_resource_manager_inline_notification_wait_and_uninit(&waitNotification); - if (notifications.init.pNotification != NULL) { + if (notifications.init.pNotification != nullptr) { ma_async_notification_signal(notifications.init.pNotification); } @@ -71979,7 +71979,7 @@ MA_API ma_result ma_resource_manager_data_stream_uninit(ma_resource_manager_data ma_resource_manager_inline_notification freeEvent; ma_job job; - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -71996,7 +71996,7 @@ MA_API ma_result ma_resource_manager_data_stream_uninit(ma_resource_manager_data job.order = ma_resource_manager_data_stream_next_execution_order(pDataStream); job.data.resourceManager.freeDataStream.pDataStream = pDataStream; job.data.resourceManager.freeDataStream.pDoneNotification = &freeEvent; - job.data.resourceManager.freeDataStream.pDoneFence = NULL; + job.data.resourceManager.freeDataStream.pDoneFence = nullptr; ma_resource_manager_post_job(pDataStream->pResourceManager, &job); /* We need to wait for the job to finish processing before we return. */ @@ -72008,7 +72008,7 @@ MA_API ma_result ma_resource_manager_data_stream_uninit(ma_resource_manager_data static ma_uint32 ma_resource_manager_data_stream_get_page_size_in_frames(ma_resource_manager_data_stream* pDataStream) { - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); MA_ASSERT(pDataStream->isDecoderInitialized == MA_TRUE); return MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS * (pDataStream->decoder.outputSampleRate/1000); @@ -72016,7 +72016,7 @@ static ma_uint32 ma_resource_manager_data_stream_get_page_size_in_frames(ma_reso static void* ma_resource_manager_data_stream_get_page_data_pointer(ma_resource_manager_data_stream* pDataStream, ma_uint32 pageIndex, ma_uint32 relativeCursor) { - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); MA_ASSERT(pDataStream->isDecoderInitialized == MA_TRUE); MA_ASSERT(pageIndex == 0 || pageIndex == 1); @@ -72062,7 +72062,7 @@ static void ma_resource_manager_data_stream_fill_pages(ma_resource_manager_data_ { ma_uint32 iPage; - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); for (iPage = 0; iPage < 2; iPage += 1) { ma_resource_manager_data_stream_fill_page(pDataStream, iPage); @@ -72078,15 +72078,15 @@ static ma_result ma_resource_manager_data_stream_map(ma_resource_manager_data_st /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); - if (pFrameCount != NULL) { + if (pFrameCount != nullptr) { frameCount = *pFrameCount; *pFrameCount = 0; } - if (ppFramesOut != NULL) { - *ppFramesOut = NULL; + if (ppFramesOut != nullptr) { + *ppFramesOut = nullptr; } - if (pDataStream == NULL || ppFramesOut == NULL || pFrameCount == NULL) { + if (pDataStream == nullptr || ppFramesOut == nullptr || pFrameCount == nullptr) { return MA_INVALID_ARGS; } @@ -72143,7 +72143,7 @@ static ma_result ma_resource_manager_data_stream_unmap(ma_resource_manager_data_ /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -72197,7 +72197,7 @@ MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_man ma_uint32 channels; /* Safety. */ - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -72208,7 +72208,7 @@ MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_man /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -72221,7 +72221,7 @@ MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_man return MA_BUSY; } - ma_resource_manager_data_stream_get_data_format(pDataStream, &format, &channels, NULL, NULL, 0); + ma_resource_manager_data_stream_get_data_format(pDataStream, &format, &channels, nullptr, nullptr, 0); /* Reading is implemented in terms of map/unmap. We need to run this in a loop because mapping is clamped against page boundaries. */ totalFramesProcessed = 0; @@ -72235,8 +72235,8 @@ MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_man break; } - /* Copy the mapped data to the output buffer if we have one. It's allowed for pFramesOut to be NULL in which case a relative forward seek is performed. */ - if (pFramesOut != NULL) { + /* Copy the mapped data to the output buffer if we have one. It's allowed for pFramesOut to be nullptr in which case a relative forward seek is performed. */ + if (pFramesOut != nullptr) { ma_copy_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesProcessed, format, channels), pMappedFrames, mappedFrameCount, format, channels); } @@ -72248,7 +72248,7 @@ MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_man } } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesProcessed; } @@ -72269,7 +72269,7 @@ MA_API ma_result ma_resource_manager_data_stream_seek_to_pcm_frame(ma_resource_m /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(streamResult != MA_UNAVAILABLE); - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -72320,23 +72320,23 @@ MA_API ma_result ma_resource_manager_data_stream_get_data_format(ma_resource_man /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = ma_format_unknown; } - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = 0; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = 0; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -72355,7 +72355,7 @@ MA_API ma_result ma_resource_manager_data_stream_get_cursor_in_pcm_frames(ma_res { ma_result result; - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } @@ -72364,7 +72364,7 @@ MA_API ma_result ma_resource_manager_data_stream_get_cursor_in_pcm_frames(ma_res /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -72387,7 +72387,7 @@ MA_API ma_result ma_resource_manager_data_stream_get_length_in_pcm_frames(ma_res { ma_result streamResult; - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } @@ -72398,7 +72398,7 @@ MA_API ma_result ma_resource_manager_data_stream_get_length_in_pcm_frames(ma_res /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(streamResult != MA_UNAVAILABLE); - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -72420,7 +72420,7 @@ MA_API ma_result ma_resource_manager_data_stream_get_length_in_pcm_frames(ma_res MA_API ma_result ma_resource_manager_data_stream_result(const ma_resource_manager_data_stream* pDataStream) { - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -72434,7 +72434,7 @@ MA_API ma_result ma_resource_manager_data_stream_set_looping(ma_resource_manager MA_API ma_bool32 ma_resource_manager_data_stream_is_looping(const ma_resource_manager_data_stream* pDataStream) { - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_FALSE; } @@ -72448,13 +72448,13 @@ MA_API ma_result ma_resource_manager_data_stream_get_available_frames(ma_resourc ma_uint32 relativeCursor; ma_uint64 availableFrames; - if (pAvailableFrames == NULL) { + if (pAvailableFrames == nullptr) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; - if (pDataStream == NULL) { + if (pDataStream == nullptr) { return MA_INVALID_ARGS; } @@ -72477,17 +72477,17 @@ MA_API ma_result ma_resource_manager_data_stream_get_available_frames(ma_resourc static ma_result ma_resource_manager_data_source_preinit(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_resource_manager_data_source* pDataSource) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDataSource); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - if (pResourceManager == NULL) { + if (pResourceManager == nullptr) { return MA_INVALID_ARGS; } @@ -72545,7 +72545,7 @@ MA_API ma_result ma_resource_manager_data_source_init_copy(ma_resource_manager* ma_result result; ma_resource_manager_data_source_config config; - if (pExistingDataSource == NULL) { + if (pExistingDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72567,7 +72567,7 @@ MA_API ma_result ma_resource_manager_data_source_init_copy(ma_resource_manager* MA_API ma_result ma_resource_manager_data_source_uninit(ma_resource_manager_data_source* pDataSource) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72582,11 +72582,11 @@ MA_API ma_result ma_resource_manager_data_source_uninit(ma_resource_manager_data MA_API ma_result ma_resource_manager_data_source_read_pcm_frames(ma_resource_manager_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { /* Safety. */ - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72599,7 +72599,7 @@ MA_API ma_result ma_resource_manager_data_source_read_pcm_frames(ma_resource_man MA_API ma_result ma_resource_manager_data_source_seek_to_pcm_frame(ma_resource_manager_data_source* pDataSource, ma_uint64 frameIndex) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72612,7 +72612,7 @@ MA_API ma_result ma_resource_manager_data_source_seek_to_pcm_frame(ma_resource_m MA_API ma_result ma_resource_manager_data_source_map(ma_resource_manager_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72625,7 +72625,7 @@ MA_API ma_result ma_resource_manager_data_source_map(ma_resource_manager_data_so MA_API ma_result ma_resource_manager_data_source_unmap(ma_resource_manager_data_source* pDataSource, ma_uint64 frameCount) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72638,7 +72638,7 @@ MA_API ma_result ma_resource_manager_data_source_unmap(ma_resource_manager_data_ MA_API ma_result ma_resource_manager_data_source_get_data_format(ma_resource_manager_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72651,7 +72651,7 @@ MA_API ma_result ma_resource_manager_data_source_get_data_format(ma_resource_man MA_API ma_result ma_resource_manager_data_source_get_cursor_in_pcm_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pCursor) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72664,7 +72664,7 @@ MA_API ma_result ma_resource_manager_data_source_get_cursor_in_pcm_frames(ma_res MA_API ma_result ma_resource_manager_data_source_get_length_in_pcm_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pLength) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72677,7 +72677,7 @@ MA_API ma_result ma_resource_manager_data_source_get_length_in_pcm_frames(ma_res MA_API ma_result ma_resource_manager_data_source_result(const ma_resource_manager_data_source* pDataSource) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72690,7 +72690,7 @@ MA_API ma_result ma_resource_manager_data_source_result(const ma_resource_manage MA_API ma_result ma_resource_manager_data_source_set_looping(ma_resource_manager_data_source* pDataSource, ma_bool32 isLooping) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72703,7 +72703,7 @@ MA_API ma_result ma_resource_manager_data_source_set_looping(ma_resource_manager MA_API ma_bool32 ma_resource_manager_data_source_is_looping(const ma_resource_manager_data_source* pDataSource) { - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_FALSE; } @@ -72716,13 +72716,13 @@ MA_API ma_bool32 ma_resource_manager_data_source_is_looping(const ma_resource_ma MA_API ma_result ma_resource_manager_data_source_get_available_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pAvailableFrames) { - if (pAvailableFrames == NULL) { + if (pAvailableFrames == nullptr) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; - if (pDataSource == NULL) { + if (pDataSource == nullptr) { return MA_INVALID_ARGS; } @@ -72736,7 +72736,7 @@ MA_API ma_result ma_resource_manager_data_source_get_available_frames(ma_resourc MA_API ma_result ma_resource_manager_post_job(ma_resource_manager* pResourceManager, const ma_job* pJob) { - if (pResourceManager == NULL) { + if (pResourceManager == nullptr) { return MA_INVALID_ARGS; } @@ -72751,7 +72751,7 @@ MA_API ma_result ma_resource_manager_post_job_quit(ma_resource_manager* pResourc MA_API ma_result ma_resource_manager_next_job(ma_resource_manager* pResourceManager, ma_job* pJob) { - if (pResourceManager == NULL) { + if (pResourceManager == nullptr) { return MA_INVALID_ARGS; } @@ -72765,13 +72765,13 @@ static ma_result ma_job_process__resource_manager__load_data_buffer_node(ma_job* ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer_node* pDataBufferNode; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pResourceManager = (ma_resource_manager*)pJob->data.resourceManager.loadDataBufferNode.pResourceManager; - MA_ASSERT(pResourceManager != NULL); + MA_ASSERT(pResourceManager != nullptr); pDataBufferNode = (ma_resource_manager_data_buffer_node*)pJob->data.resourceManager.loadDataBufferNode.pDataBufferNode; - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pDataBufferNode != nullptr); MA_ASSERT(pDataBufferNode->isDataOwnedByResourceManager == MA_TRUE); /* The data should always be owned by the resource manager. */ /* The data buffer is not getting deleted, but we may be getting executed out of order. If so, we need to push the job back onto the queue and return. */ @@ -72825,7 +72825,7 @@ static ma_result ma_job_process__resource_manager__load_data_buffer_node(ma_job* } if (result != MA_SUCCESS) { - if (pJob->data.resourceManager.loadDataBufferNode.pFilePath != NULL) { + if (pJob->data.resourceManager.loadDataBufferNode.pFilePath != nullptr) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to initialize data supply for \"%s\". %s.\n", pJob->data.resourceManager.loadDataBufferNode.pFilePath, ma_result_description(result)); } else { #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(_MSC_VER) @@ -72889,19 +72889,19 @@ static ma_result ma_job_process__resource_manager__load_data_buffer_node(ma_job* ma_atomic_compare_and_swap_i32(&pDataBufferNode->result, MA_BUSY, result); /* At this point initialization is complete and we can signal the notification if any. */ - if (pJob->data.resourceManager.loadDataBufferNode.pInitNotification != NULL) { + if (pJob->data.resourceManager.loadDataBufferNode.pInitNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.loadDataBufferNode.pInitNotification); } - if (pJob->data.resourceManager.loadDataBufferNode.pInitFence != NULL) { + if (pJob->data.resourceManager.loadDataBufferNode.pInitFence != nullptr) { ma_fence_release(pJob->data.resourceManager.loadDataBufferNode.pInitFence); } /* If we have a success result it means we've fully loaded the buffer. This will happen in the non-decoding case. */ if (result != MA_BUSY) { - if (pJob->data.resourceManager.loadDataBufferNode.pDoneNotification != NULL) { + if (pJob->data.resourceManager.loadDataBufferNode.pDoneNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.loadDataBufferNode.pDoneNotification); } - if (pJob->data.resourceManager.loadDataBufferNode.pDoneFence != NULL) { + if (pJob->data.resourceManager.loadDataBufferNode.pDoneFence != nullptr) { ma_fence_release(pJob->data.resourceManager.loadDataBufferNode.pDoneFence); } } @@ -72922,24 +72922,24 @@ static ma_result ma_job_process__resource_manager__free_data_buffer_node(ma_job* ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer_node* pDataBufferNode; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pResourceManager = (ma_resource_manager*)pJob->data.resourceManager.freeDataBufferNode.pResourceManager; - MA_ASSERT(pResourceManager != NULL); + MA_ASSERT(pResourceManager != nullptr); pDataBufferNode = (ma_resource_manager_data_buffer_node*)pJob->data.resourceManager.freeDataBufferNode.pDataBufferNode; - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pDataBufferNode != nullptr); if (pJob->order != ma_atomic_load_32(&pDataBufferNode->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ } /* The event needs to be signalled last. */ - if (pJob->data.resourceManager.freeDataBufferNode.pDoneNotification != NULL) { + if (pJob->data.resourceManager.freeDataBufferNode.pDoneNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.freeDataBufferNode.pDoneNotification); } - if (pJob->data.resourceManager.freeDataBufferNode.pDoneFence != NULL) { + if (pJob->data.resourceManager.freeDataBufferNode.pDoneFence != nullptr) { ma_fence_release(pJob->data.resourceManager.freeDataBufferNode.pDoneFence); } @@ -72956,13 +72956,13 @@ static ma_result ma_job_process__resource_manager__page_data_buffer_node(ma_job* ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer_node* pDataBufferNode; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pResourceManager = (ma_resource_manager*)pJob->data.resourceManager.pageDataBufferNode.pResourceManager; - MA_ASSERT(pResourceManager != NULL); + MA_ASSERT(pResourceManager != nullptr); pDataBufferNode = (ma_resource_manager_data_buffer_node*)pJob->data.resourceManager.pageDataBufferNode.pDataBufferNode; - MA_ASSERT(pDataBufferNode != NULL); + MA_ASSERT(pDataBufferNode != nullptr); if (pJob->order != ma_atomic_load_32(&pDataBufferNode->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ @@ -73011,11 +73011,11 @@ static ma_result ma_job_process__resource_manager__page_data_buffer_node(ma_job* /* Signal the notification after setting the result in case the notification callback wants to inspect the result code. */ if (result != MA_BUSY) { - if (pJob->data.resourceManager.pageDataBufferNode.pDoneNotification != NULL) { + if (pJob->data.resourceManager.pageDataBufferNode.pDoneNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.pageDataBufferNode.pDoneNotification); } - if (pJob->data.resourceManager.pageDataBufferNode.pDoneFence != NULL) { + if (pJob->data.resourceManager.pageDataBufferNode.pDoneFence != nullptr) { ma_fence_release(pJob->data.resourceManager.pageDataBufferNode.pDoneFence); } } @@ -73037,10 +73037,10 @@ static ma_result ma_job_process__resource_manager__load_data_buffer(ma_job* pJob All we're doing here is checking if the node has finished loading. If not, we just re-post the job and keep waiting. Otherwise we increment the execution counter and set the buffer's result code. */ - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pDataBuffer = (ma_resource_manager_data_buffer*)pJob->data.resourceManager.loadDataBuffer.pDataBuffer; - MA_ASSERT(pDataBuffer != NULL); + MA_ASSERT(pDataBuffer != nullptr); pResourceManager = pDataBuffer->pResourceManager; @@ -73106,10 +73106,10 @@ static ma_result ma_job_process__resource_manager__load_data_buffer(ma_job* pJob ma_atomic_compare_and_swap_i32(&pDataBuffer->result, MA_BUSY, result); /* Only signal the other threads after the result has been set just for cleanliness sake. */ - if (pJob->data.resourceManager.loadDataBuffer.pDoneNotification != NULL) { + if (pJob->data.resourceManager.loadDataBuffer.pDoneNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.loadDataBuffer.pDoneNotification); } - if (pJob->data.resourceManager.loadDataBuffer.pDoneFence != NULL) { + if (pJob->data.resourceManager.loadDataBuffer.pDoneFence != nullptr) { ma_fence_release(pJob->data.resourceManager.loadDataBuffer.pDoneFence); } @@ -73118,10 +73118,10 @@ static ma_result ma_job_process__resource_manager__load_data_buffer(ma_job* pJob notification event was never signalled which means we need to signal it here. */ if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE && result != MA_SUCCESS) { - if (pJob->data.resourceManager.loadDataBuffer.pInitNotification != NULL) { + if (pJob->data.resourceManager.loadDataBuffer.pInitNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.loadDataBuffer.pInitNotification); } - if (pJob->data.resourceManager.loadDataBuffer.pInitFence != NULL) { + if (pJob->data.resourceManager.loadDataBuffer.pInitFence != nullptr) { ma_fence_release(pJob->data.resourceManager.loadDataBuffer.pInitFence); } } @@ -73135,10 +73135,10 @@ static ma_result ma_job_process__resource_manager__free_data_buffer(ma_job* pJob ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer* pDataBuffer; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pDataBuffer = (ma_resource_manager_data_buffer*)pJob->data.resourceManager.freeDataBuffer.pDataBuffer; - MA_ASSERT(pDataBuffer != NULL); + MA_ASSERT(pDataBuffer != nullptr); pResourceManager = pDataBuffer->pResourceManager; @@ -73149,11 +73149,11 @@ static ma_result ma_job_process__resource_manager__free_data_buffer(ma_job* pJob ma_resource_manager_data_buffer_uninit_internal(pDataBuffer); /* The event needs to be signalled last. */ - if (pJob->data.resourceManager.freeDataBuffer.pDoneNotification != NULL) { + if (pJob->data.resourceManager.freeDataBuffer.pDoneNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.freeDataBuffer.pDoneNotification); } - if (pJob->data.resourceManager.freeDataBuffer.pDoneFence != NULL) { + if (pJob->data.resourceManager.freeDataBuffer.pDoneFence != nullptr) { ma_fence_release(pJob->data.resourceManager.freeDataBuffer.pDoneFence); } @@ -73169,10 +73169,10 @@ static ma_result ma_job_process__resource_manager__load_data_stream(ma_job* pJob ma_resource_manager* pResourceManager; ma_resource_manager_data_stream* pDataStream; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pDataStream = (ma_resource_manager_data_stream*)pJob->data.resourceManager.loadDataStream.pDataStream; - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); pResourceManager = pDataStream->pResourceManager; @@ -73188,7 +73188,7 @@ static ma_result ma_job_process__resource_manager__load_data_stream(ma_job* pJob /* We need to initialize the decoder first so we can determine the size of the pages. */ decoderConfig = ma_resource_manager__init_decoder_config(pResourceManager); - if (pJob->data.resourceManager.loadDataStream.pFilePath != NULL) { + if (pJob->data.resourceManager.loadDataStream.pFilePath != nullptr) { result = ma_decoder_init_vfs(pResourceManager->config.pVFS, pJob->data.resourceManager.loadDataStream.pFilePath, &decoderConfig, &pDataStream->decoder); } else { result = ma_decoder_init_vfs_w(pResourceManager->config.pVFS, pJob->data.resourceManager.loadDataStream.pFilePathW, &decoderConfig, &pDataStream->decoder); @@ -73217,7 +73217,7 @@ static ma_result ma_job_process__resource_manager__load_data_stream(ma_job* pJob pageBufferSizeInBytes = ma_resource_manager_data_stream_get_page_size_in_frames(pDataStream) * 2 * ma_get_bytes_per_frame(pDataStream->decoder.outputFormat, pDataStream->decoder.outputChannels); pDataStream->pPageData = ma_malloc(pageBufferSizeInBytes, &pResourceManager->config.allocationCallbacks); - if (pDataStream->pPageData == NULL) { + if (pDataStream->pPageData == nullptr) { ma_decoder_uninit(&pDataStream->decoder); result = MA_OUT_OF_MEMORY; goto done; @@ -73240,10 +73240,10 @@ static ma_result ma_job_process__resource_manager__load_data_stream(ma_job* pJob ma_atomic_compare_and_swap_i32(&pDataStream->result, MA_BUSY, result); /* Only signal the other threads after the result has been set just for cleanliness sake. */ - if (pJob->data.resourceManager.loadDataStream.pInitNotification != NULL) { + if (pJob->data.resourceManager.loadDataStream.pInitNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.loadDataStream.pInitNotification); } - if (pJob->data.resourceManager.loadDataStream.pInitFence != NULL) { + if (pJob->data.resourceManager.loadDataStream.pInitFence != nullptr) { ma_fence_release(pJob->data.resourceManager.loadDataStream.pInitFence); } @@ -73256,10 +73256,10 @@ static ma_result ma_job_process__resource_manager__free_data_stream(ma_job* pJob ma_resource_manager* pResourceManager; ma_resource_manager_data_stream* pDataStream; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pDataStream = (ma_resource_manager_data_stream*)pJob->data.resourceManager.freeDataStream.pDataStream; - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); pResourceManager = pDataStream->pResourceManager; @@ -73274,18 +73274,18 @@ static ma_result ma_job_process__resource_manager__free_data_stream(ma_job* pJob ma_decoder_uninit(&pDataStream->decoder); } - if (pDataStream->pPageData != NULL) { + if (pDataStream->pPageData != nullptr) { ma_free(pDataStream->pPageData, &pResourceManager->config.allocationCallbacks); - pDataStream->pPageData = NULL; /* Just in case... */ + pDataStream->pPageData = nullptr; /* Just in case... */ } ma_data_source_uninit(&pDataStream->ds); /* The event needs to be signalled last. */ - if (pJob->data.resourceManager.freeDataStream.pDoneNotification != NULL) { + if (pJob->data.resourceManager.freeDataStream.pDoneNotification != nullptr) { ma_async_notification_signal(pJob->data.resourceManager.freeDataStream.pDoneNotification); } - if (pJob->data.resourceManager.freeDataStream.pDoneFence != NULL) { + if (pJob->data.resourceManager.freeDataStream.pDoneFence != nullptr) { ma_fence_release(pJob->data.resourceManager.freeDataStream.pDoneFence); } @@ -73299,10 +73299,10 @@ static ma_result ma_job_process__resource_manager__page_data_stream(ma_job* pJob ma_resource_manager* pResourceManager; ma_resource_manager_data_stream* pDataStream; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pDataStream = (ma_resource_manager_data_stream*)pJob->data.resourceManager.pageDataStream.pDataStream; - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); pResourceManager = pDataStream->pResourceManager; @@ -73329,10 +73329,10 @@ static ma_result ma_job_process__resource_manager__seek_data_stream(ma_job* pJob ma_resource_manager* pResourceManager; ma_resource_manager_data_stream* pDataStream; - MA_ASSERT(pJob != NULL); + MA_ASSERT(pJob != nullptr); pDataStream = (ma_resource_manager_data_stream*)pJob->data.resourceManager.seekDataStream.pDataStream; - MA_ASSERT(pDataStream != NULL); + MA_ASSERT(pDataStream != nullptr); pResourceManager = pDataStream->pResourceManager; @@ -73365,7 +73365,7 @@ static ma_result ma_job_process__resource_manager__seek_data_stream(ma_job* pJob MA_API ma_result ma_resource_manager_process_job(ma_resource_manager* pResourceManager, ma_job* pJob) { - if (pResourceManager == NULL || pJob == NULL) { + if (pResourceManager == nullptr || pJob == nullptr) { return MA_INVALID_ARGS; } @@ -73377,7 +73377,7 @@ MA_API ma_result ma_resource_manager_process_next_job(ma_resource_manager* pReso ma_result result; ma_job job; - if (pResourceManager == NULL) { + if (pResourceManager == nullptr) { return MA_INVALID_ARGS; } @@ -73410,12 +73410,12 @@ static ma_stack* ma_stack_init(size_t sizeInBytes, const ma_allocation_callbacks ma_stack* pStack; if (sizeInBytes == 0) { - return NULL; + return nullptr; } pStack = (ma_stack*)ma_malloc(sizeof(*pStack) - sizeof(pStack->_data) + sizeInBytes, pAllocationCallbacks); - if (pStack == NULL) { - return NULL; + if (pStack == nullptr) { + return nullptr; } pStack->offset = 0; @@ -73426,7 +73426,7 @@ static ma_stack* ma_stack_init(size_t sizeInBytes, const ma_allocation_callbacks static void ma_stack_uninit(ma_stack* pStack, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pStack == NULL) { + if (pStack == nullptr) { return; } @@ -73441,7 +73441,7 @@ static void* ma_stack_alloc(ma_stack* pStack, size_t sz) sz = (sz + (sizeof(ma_uintptr) - 1)) & ~(sizeof(ma_uintptr) - 1); /* Padding. */ if (pStack->offset + sz + sizeof(size_t) > pStack->sizeInBytes) { - return NULL; /* Out of memory. */ + return nullptr; /* Out of memory. */ } pStack->offset += sz + sizeof(size_t); @@ -73454,7 +73454,7 @@ static void ma_stack_free(ma_stack* pStack, void* p) { size_t* pSize; - if (p == NULL) { + if (p == nullptr) { return; } @@ -73484,7 +73484,7 @@ MA_API void ma_debug_fill_pcm_frames_with_sine_wave(float* pFramesOut, ma_uint32 waveformConfig = ma_waveform_config_init(format, channels, sampleRate, ma_waveform_type_sine, 1.0, 400); ma_waveform_init(&waveformConfig, &waveform); - ma_waveform_read_pcm_frames(&waveform, pFramesOut, frameCount, NULL); + ma_waveform_read_pcm_frames(&waveform, pFramesOut, frameCount, nullptr); } #else { @@ -73520,14 +73520,14 @@ MA_API ma_node_graph_config ma_node_graph_config_init(ma_uint32 channels) static void ma_node_graph_set_is_reading(ma_node_graph* pNodeGraph, ma_bool32 isReading) { - MA_ASSERT(pNodeGraph != NULL); + MA_ASSERT(pNodeGraph != nullptr); ma_atomic_exchange_32(&pNodeGraph->isReading, isReading); } #if 0 static ma_bool32 ma_node_graph_is_reading(ma_node_graph* pNodeGraph) { - MA_ASSERT(pNodeGraph != NULL); + MA_ASSERT(pNodeGraph != nullptr); return ma_atomic_load_32(&pNodeGraph->isReading); } #endif @@ -73549,7 +73549,7 @@ static void ma_node_graph_node_process_pcm_frames(ma_node* pNode, const float** static ma_node_vtable g_node_graph_node_vtable = { ma_node_graph_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 0, /* 0 input buses. */ 1, /* 1 output bus. */ 0 /* Flags. */ @@ -73557,7 +73557,7 @@ static ma_node_vtable g_node_graph_node_vtable = static void ma_node_graph_endpoint_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); MA_ASSERT(ma_node_get_input_bus_count(pNode) == 1); MA_ASSERT(ma_node_get_output_bus_count(pNode) == 1); @@ -73573,7 +73573,7 @@ static void ma_node_graph_endpoint_process_pcm_frames(ma_node* pNode, const floa #if 0 /* The data has already been mixed. We just need to move it to the output buffer. */ - if (ppFramesIn != NULL) { + if (ppFramesIn != nullptr) { ma_copy_pcm_frames(ppFramesOut[0], ppFramesIn[0], *pFrameCountOut, ma_format_f32, ma_node_get_output_channels(pNode, 0)); } #endif @@ -73582,7 +73582,7 @@ static void ma_node_graph_endpoint_process_pcm_frames(ma_node* pNode, const floa static ma_node_vtable g_node_graph_endpoint_vtable = { ma_node_graph_endpoint_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* 1 input bus. */ 1, /* 1 output bus. */ MA_NODE_FLAG_PASSTHROUGH /* Flags. The endpoint is a passthrough. */ @@ -73594,7 +73594,7 @@ MA_API ma_result ma_node_graph_init(const ma_node_graph_config* pConfig, const m ma_node_config baseConfig; ma_node_config endpointConfig; - if (pNodeGraph == NULL) { + if (pNodeGraph == nullptr) { return MA_INVALID_ARGS; } @@ -73628,7 +73628,7 @@ MA_API ma_result ma_node_graph_init(const ma_node_graph_config* pConfig, const m /* Processing cache. */ if (pConfig->processingSizeInFrames > 0) { pNodeGraph->pProcessingCache = (float*)ma_malloc(pConfig->processingSizeInFrames * pConfig->channels * sizeof(float), pAllocationCallbacks); - if (pNodeGraph->pProcessingCache == NULL) { + if (pNodeGraph->pProcessingCache == nullptr) { ma_node_uninit(&pNodeGraph->endpoint, pAllocationCallbacks); ma_node_uninit(&pNodeGraph->base, pAllocationCallbacks); return MA_OUT_OF_MEMORY; @@ -73646,10 +73646,10 @@ MA_API ma_result ma_node_graph_init(const ma_node_graph_config* pConfig, const m } pNodeGraph->pPreMixStack = ma_stack_init(preMixStackSizeInBytes, pAllocationCallbacks); - if (pNodeGraph->pPreMixStack == NULL) { + if (pNodeGraph->pPreMixStack == nullptr) { ma_node_uninit(&pNodeGraph->endpoint, pAllocationCallbacks); ma_node_uninit(&pNodeGraph->base, pAllocationCallbacks); - if (pNodeGraph->pProcessingCache != NULL) { + if (pNodeGraph->pProcessingCache != nullptr) { ma_free(pNodeGraph->pProcessingCache, pAllocationCallbacks); } @@ -73663,28 +73663,28 @@ MA_API ma_result ma_node_graph_init(const ma_node_graph_config* pConfig, const m MA_API void ma_node_graph_uninit(ma_node_graph* pNodeGraph, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pNodeGraph == NULL) { + if (pNodeGraph == nullptr) { return; } ma_node_uninit(&pNodeGraph->endpoint, pAllocationCallbacks); ma_node_uninit(&pNodeGraph->base, pAllocationCallbacks); - if (pNodeGraph->pProcessingCache != NULL) { + if (pNodeGraph->pProcessingCache != nullptr) { ma_free(pNodeGraph->pProcessingCache, pAllocationCallbacks); - pNodeGraph->pProcessingCache = NULL; + pNodeGraph->pProcessingCache = nullptr; } - if (pNodeGraph->pPreMixStack != NULL) { + if (pNodeGraph->pPreMixStack != nullptr) { ma_stack_uninit(pNodeGraph->pPreMixStack, pAllocationCallbacks); - pNodeGraph->pPreMixStack = NULL; + pNodeGraph->pPreMixStack = nullptr; } } MA_API ma_node* ma_node_graph_get_endpoint(ma_node_graph* pNodeGraph) { - if (pNodeGraph == NULL) { - return NULL; + if (pNodeGraph == nullptr) { + return nullptr; } return &pNodeGraph->endpoint; @@ -73696,11 +73696,11 @@ MA_API ma_result ma_node_graph_read_pcm_frames(ma_node_graph* pNodeGraph, void* ma_uint64 totalFramesRead; ma_uint32 channels; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; /* Safety. */ } - if (pNodeGraph == NULL) { + if (pNodeGraph == nullptr) { return MA_INVALID_ARGS; } @@ -73785,7 +73785,7 @@ MA_API ma_result ma_node_graph_read_pcm_frames(ma_node_graph* pNodeGraph, void* ma_silence_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, ma_format_f32, channels), (frameCount - totalFramesRead), ma_format_f32, channels); } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = totalFramesRead; } @@ -73794,7 +73794,7 @@ MA_API ma_result ma_node_graph_read_pcm_frames(ma_node_graph* pNodeGraph, void* MA_API ma_uint32 ma_node_graph_get_channels(const ma_node_graph* pNodeGraph) { - if (pNodeGraph == NULL) { + if (pNodeGraph == nullptr) { return 0; } @@ -73803,7 +73803,7 @@ MA_API ma_uint32 ma_node_graph_get_channels(const ma_node_graph* pNodeGraph) MA_API ma_uint64 ma_node_graph_get_time(const ma_node_graph* pNodeGraph) { - if (pNodeGraph == NULL) { + if (pNodeGraph == nullptr) { return 0; } @@ -73812,7 +73812,7 @@ MA_API ma_uint64 ma_node_graph_get_time(const ma_node_graph* pNodeGraph) MA_API ma_result ma_node_graph_set_time(ma_node_graph* pNodeGraph, ma_uint64 globalTime) { - if (pNodeGraph == NULL) { + if (pNodeGraph == nullptr) { return MA_INVALID_ARGS; } @@ -73821,7 +73821,7 @@ MA_API ma_result ma_node_graph_set_time(ma_node_graph* pNodeGraph, ma_uint64 glo MA_API ma_uint32 ma_node_graph_get_processing_size_in_frames(const ma_node_graph* pNodeGraph) { - if (pNodeGraph == NULL) { + if (pNodeGraph == nullptr) { return 0; } @@ -73833,7 +73833,7 @@ MA_API ma_uint32 ma_node_graph_get_processing_size_in_frames(const ma_node_graph static ma_result ma_node_output_bus_init(ma_node* pNode, ma_uint32 outputBusIndex, ma_uint32 channels, ma_node_output_bus* pOutputBus) { - MA_ASSERT(pOutputBus != NULL); + MA_ASSERT(pOutputBus != nullptr); MA_ASSERT(outputBusIndex < MA_MAX_NODE_BUS_COUNT); MA_ASSERT(outputBusIndex < ma_node_get_output_bus_count(pNode)); MA_ASSERT(channels < 256); @@ -73898,7 +73898,7 @@ static ma_bool32 ma_node_output_bus_is_attached(ma_node_output_bus* pOutputBus) static ma_result ma_node_output_bus_set_volume(ma_node_output_bus* pOutputBus, float volume) { - MA_ASSERT(pOutputBus != NULL); + MA_ASSERT(pOutputBus != nullptr); if (volume < 0.0f) { volume = 0.0f; @@ -73917,7 +73917,7 @@ static float ma_node_output_bus_get_volume(const ma_node_output_bus* pOutputBus) static ma_result ma_node_input_bus_init(ma_uint32 channels, ma_node_input_bus* pInputBus) { - MA_ASSERT(pInputBus != NULL); + MA_ASSERT(pInputBus != nullptr); MA_ASSERT(channels < 256); MA_ZERO_OBJECT(pInputBus); @@ -73933,14 +73933,14 @@ static ma_result ma_node_input_bus_init(ma_uint32 channels, ma_node_input_bus* p static void ma_node_input_bus_lock(ma_node_input_bus* pInputBus) { - MA_ASSERT(pInputBus != NULL); + MA_ASSERT(pInputBus != nullptr); ma_spinlock_lock(&pInputBus->lock); } static void ma_node_input_bus_unlock(ma_node_input_bus* pInputBus) { - MA_ASSERT(pInputBus != NULL); + MA_ASSERT(pInputBus != nullptr); ma_spinlock_unlock(&pInputBus->lock); } @@ -73970,8 +73970,8 @@ static ma_uint32 ma_node_input_bus_get_channels(const ma_node_input_bus* pInputB static void ma_node_input_bus_detach__no_output_bus_lock(ma_node_input_bus* pInputBus, ma_node_output_bus* pOutputBus) { - MA_ASSERT(pInputBus != NULL); - MA_ASSERT(pOutputBus != NULL); + MA_ASSERT(pInputBus != nullptr); + MA_ASSERT(pOutputBus != nullptr); /* Mark the output bus as detached first. This will prevent future iterations on the audio thread @@ -73996,19 +73996,19 @@ static void ma_node_input_bus_detach__no_output_bus_lock(ma_node_input_bus* pInp ma_node_output_bus* pOldPrev = (ma_node_output_bus*)ma_atomic_load_ptr(&pOutputBus->pPrev); ma_node_output_bus* pOldNext = (ma_node_output_bus*)ma_atomic_load_ptr(&pOutputBus->pNext); - if (pOldPrev != NULL) { + if (pOldPrev != nullptr) { ma_atomic_exchange_ptr(&pOldPrev->pNext, pOldNext); /* <-- This is where the output bus is detached from the list. */ } - if (pOldNext != NULL) { + if (pOldNext != nullptr) { ma_atomic_exchange_ptr(&pOldNext->pPrev, pOldPrev); /* <-- This is required for detachment. */ } } ma_node_input_bus_unlock(pInputBus); /* At this point the output bus is detached and the linked list is completely unaware of it. Reset some data for safety. */ - ma_atomic_exchange_ptr(&pOutputBus->pNext, NULL); /* Using atomic exchanges here, mainly for the benefit of analysis tools which don't always recognize spinlocks. */ - ma_atomic_exchange_ptr(&pOutputBus->pPrev, NULL); /* As above. */ - pOutputBus->pInputNode = NULL; + ma_atomic_exchange_ptr(&pOutputBus->pNext, nullptr); /* Using atomic exchanges here, mainly for the benefit of analysis tools which don't always recognize spinlocks. */ + ma_atomic_exchange_ptr(&pOutputBus->pPrev, nullptr); /* As above. */ + pOutputBus->pInputNode = nullptr; pOutputBus->inputNodeInputBusIndex = 0; @@ -74044,8 +74044,8 @@ static void ma_node_input_bus_detach__no_output_bus_lock(ma_node_input_bus* pInp #if 0 /* Not used at the moment, but leaving here in case I need it later. */ static void ma_node_input_bus_detach(ma_node_input_bus* pInputBus, ma_node_output_bus* pOutputBus) { - MA_ASSERT(pInputBus != NULL); - MA_ASSERT(pOutputBus != NULL); + MA_ASSERT(pInputBus != nullptr); + MA_ASSERT(pOutputBus != nullptr); ma_node_output_bus_lock(pOutputBus); { @@ -74057,15 +74057,15 @@ static void ma_node_input_bus_detach(ma_node_input_bus* pInputBus, ma_node_outpu static void ma_node_input_bus_attach(ma_node_input_bus* pInputBus, ma_node_output_bus* pOutputBus, ma_node* pNewInputNode, ma_uint32 inputNodeInputBusIndex) { - MA_ASSERT(pInputBus != NULL); - MA_ASSERT(pOutputBus != NULL); + MA_ASSERT(pInputBus != nullptr); + MA_ASSERT(pOutputBus != nullptr); ma_node_output_bus_lock(pOutputBus); { ma_node_output_bus* pOldInputNode = (ma_node_output_bus*)ma_atomic_load_ptr(&pOutputBus->pInputNode); /* Detach from any existing attachment first if necessary. */ - if (pOldInputNode != NULL) { + if (pOldInputNode != nullptr) { ma_node_input_bus_detach__no_output_bus_lock(pInputBus, pOutputBus); } @@ -74102,7 +74102,7 @@ static void ma_node_input_bus_attach(ma_node_input_bus* pInputBus, ma_node_outpu ma_atomic_exchange_ptr(&pInputBus->head.pNext, pOutputBus); /* <-- This is where the output bus is actually attached to the input bus. */ /* Do the previous pointer last. This is only used for detachment. */ - if (pNewNext != NULL) { + if (pNewNext != nullptr) { ma_atomic_exchange_ptr(&pNewNext->pPrev, pOutputBus); } } @@ -74121,10 +74121,10 @@ static ma_node_output_bus* ma_node_input_bus_next(ma_node_input_bus* pInputBus, { ma_node_output_bus* pNext; - MA_ASSERT(pInputBus != NULL); + MA_ASSERT(pInputBus != nullptr); - if (pOutputBus == NULL) { - return NULL; + if (pOutputBus == nullptr) { + return nullptr; } ma_node_input_bus_next_begin(pInputBus); @@ -74132,7 +74132,7 @@ static ma_node_output_bus* ma_node_input_bus_next(ma_node_input_bus* pInputBus, pNext = pOutputBus; for (;;) { pNext = (ma_node_output_bus*)ma_atomic_load_ptr(&pNext->pNext); - if (pNext == NULL) { + if (pNext == nullptr) { break; /* Reached the end. */ } @@ -74145,7 +74145,7 @@ static ma_node_output_bus* ma_node_input_bus_next(ma_node_input_bus* pInputBus, } /* We need to increment the reference count of the selected node. */ - if (pNext != NULL) { + if (pNext != nullptr) { ma_atomic_fetch_add_32(&pNext->refCount, 1); } @@ -74189,8 +74189,8 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_ do this, we need to read from each attachment in a loop and read as many frames as we can, up to `frameCount`. */ - MA_ASSERT(pInputNode != NULL); - MA_ASSERT(pFramesRead != NULL); /* pFramesRead is critical and must always be specified. On input it's undefined and on output it'll be set to the number of frames actually read. */ + MA_ASSERT(pInputNode != nullptr); + MA_ASSERT(pFramesRead != nullptr); /* pFramesRead is critical and must always be specified. On input it's undefined and on output it'll be set to the number of frames actually read. */ *pFramesRead = 0; /* Safety. */ @@ -74205,20 +74205,20 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_ after calling ma_node_input_bus_next(), which we won't be. */ pFirst = ma_node_input_bus_first(pInputBus); - if (pFirst == NULL) { + if (pFirst == nullptr) { return MA_SUCCESS; /* No attachments. Read nothing. */ } - for (pOutputBus = pFirst; pOutputBus != NULL; pOutputBus = ma_node_input_bus_next(pInputBus, pOutputBus)) { + for (pOutputBus = pFirst; pOutputBus != nullptr; pOutputBus = ma_node_input_bus_next(pInputBus, pOutputBus)) { ma_uint32 framesProcessed = 0; ma_bool32 isSilentOutput = MA_FALSE; - MA_ASSERT(pOutputBus->pNode != NULL); - MA_ASSERT(((ma_node_base*)pOutputBus->pNode)->vtable != NULL); + MA_ASSERT(pOutputBus->pNode != nullptr); + MA_ASSERT(((ma_node_base*)pOutputBus->pNode)->vtable != nullptr); isSilentOutput = (((ma_node_base*)pOutputBus->pNode)->vtable->flags & MA_NODE_FLAG_SILENT_OUTPUT) != 0; - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { /* Read. */ while (framesProcessed < frameCount) { float* pRunningFramesOut; @@ -74236,7 +74236,7 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_ ma_uint32 preMixBufferCapInFrames = ((ma_node_base*)pInputNode)->cachedDataCapInFramesPerBus; float* pPreMixBuffer = (float*)ma_stack_alloc(((ma_node_base*)pInputNode)->pNodeGraph->pPreMixStack, preMixBufferCapInFrames * inputChannels * sizeof(float)); - if (pPreMixBuffer == NULL) { + if (pPreMixBuffer == nullptr) { /* If you're hitting this assert it means you've got an unusually deep chain of nodes, you've got an excessively large processing size, or you have a combination of both, and as a result have run out of stack space. You can increase this using the @@ -74258,7 +74258,7 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_ /* The pre-mix buffer is no longer required. */ ma_stack_free(((ma_node_base*)pInputNode)->pNodeGraph->pPreMixStack, pPreMixBuffer); - pPreMixBuffer = NULL; + pPreMixBuffer = nullptr; } } @@ -74285,12 +74285,12 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_ } } else { /* Seek. */ - ma_node_read_pcm_frames(pOutputBus->pNode, pOutputBus->outputBusIndex, NULL, frameCount, &framesProcessed, globalTime); + ma_node_read_pcm_frames(pOutputBus->pNode, pOutputBus->outputBusIndex, nullptr, frameCount, &framesProcessed, globalTime); } } /* If we didn't output anything, output silence. */ - if (doesOutputBufferHaveContent == MA_FALSE && pFramesOut != NULL) { + if (doesOutputBufferHaveContent == MA_FALSE && pFramesOut != nullptr) { ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, inputChannels); } @@ -74342,7 +74342,7 @@ static float* ma_node_get_cached_input_ptr(ma_node* pNode, ma_uint32 inputBusInd ma_uint32 iInputBus; float* pBasePtr; - MA_ASSERT(pNodeBase != NULL); + MA_ASSERT(pNodeBase != nullptr); /* Input data is stored at the front of the buffer. */ pBasePtr = pNodeBase->pCachedData; @@ -74360,7 +74360,7 @@ static float* ma_node_get_cached_output_ptr(ma_node* pNode, ma_uint32 outputBusI ma_uint32 iOutputBus; float* pBasePtr; - MA_ASSERT(pNodeBase != NULL); + MA_ASSERT(pNodeBase != nullptr); /* Cached output data starts after the input data. */ pBasePtr = pNodeBase->pCachedData; @@ -74391,9 +74391,9 @@ static ma_result ma_node_translate_bus_counts(const ma_node_config* pConfig, ma_ ma_uint32 inputBusCount; ma_uint32 outputBusCount; - MA_ASSERT(pConfig != NULL); - MA_ASSERT(pInputBusCount != NULL); - MA_ASSERT(pOutputBusCount != NULL); + MA_ASSERT(pConfig != nullptr); + MA_ASSERT(pInputBusCount != nullptr); + MA_ASSERT(pOutputBusCount != nullptr); /* Bus counts are determined by the vtable, unless they're set to `MA_NODE_BUS_COUNT_UNKNWON`, in which case they're taken from the config. */ if (pConfig->vtable->inputBusCount == MA_NODE_BUS_COUNT_UNKNOWN) { @@ -74423,7 +74423,7 @@ static ma_result ma_node_translate_bus_counts(const ma_node_config* pConfig, ma_ /* We must have channel counts for each bus. */ - if ((inputBusCount > 0 && pConfig->pInputChannels == NULL) || (outputBusCount > 0 && pConfig->pOutputChannels == NULL)) { + if ((inputBusCount > 0 && pConfig->pInputChannels == nullptr) || (outputBusCount > 0 && pConfig->pOutputChannels == nullptr)) { return MA_INVALID_ARGS; /* You must specify channel counts for each input and output bus. */ } @@ -74452,11 +74452,11 @@ static ma_result ma_node_get_heap_layout(ma_node_graph* pNodeGraph, const ma_nod ma_uint32 inputBusCount; ma_uint32 outputBusCount; - MA_ASSERT(pHeapLayout != NULL); + MA_ASSERT(pHeapLayout != nullptr); MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL || pConfig->vtable == NULL || pConfig->vtable->onProcess == NULL) { + if (pConfig == nullptr || pConfig->vtable == nullptr || pConfig->vtable->onProcess == nullptr) { return MA_INVALID_ARGS; } @@ -74542,7 +74542,7 @@ MA_API ma_result ma_node_get_heap_size(ma_node_graph* pNodeGraph, const ma_node_ ma_result result; ma_node_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -74566,7 +74566,7 @@ MA_API ma_result ma_node_init_preallocated(ma_node_graph* pNodeGraph, const ma_n ma_uint32 iInputBus; ma_uint32 iOutputBus; - if (pNodeBase == NULL) { + if (pNodeBase == nullptr) { return MA_INVALID_ARGS; } @@ -74604,7 +74604,7 @@ MA_API ma_result ma_node_init_preallocated(ma_node_graph* pNodeGraph, const ma_n pNodeBase->pCachedData = (float*)ma_offset_ptr(pHeap, heapLayout.cachedDataOffset); pNodeBase->cachedDataCapInFramesPerBus = ma_node_config_get_cache_size_in_frames(pConfig, pNodeGraph); } else { - pNodeBase->pCachedData = NULL; + pNodeBase->pCachedData = nullptr; } @@ -74625,7 +74625,7 @@ MA_API ma_result ma_node_init_preallocated(ma_node_graph* pNodeGraph, const ma_n /* The cached data needs to be initialized to silence (or a sine wave tone if we're debugging). */ - if (pNodeBase->pCachedData != NULL) { + if (pNodeBase->pCachedData != nullptr) { ma_uint32 iBus; #if 1 /* Toggle this between 0 and 1 to turn debugging on or off. 1 = fill with a sine wave for debugging; 0 = fill with silence. */ @@ -74663,11 +74663,11 @@ MA_API ma_result ma_node_init(ma_node_graph* pNodeGraph, const ma_node_config* p if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_node_init_preallocated(pNodeGraph, pConfig, pHeap, pNode); @@ -74684,7 +74684,7 @@ MA_API void ma_node_uninit(ma_node* pNode, const ma_allocation_callbacks* pAlloc { ma_node_base* pNodeBase = (ma_node_base*)pNode; - if (pNodeBase == NULL) { + if (pNodeBase == nullptr) { return; } @@ -74707,8 +74707,8 @@ MA_API void ma_node_uninit(ma_node* pNode, const ma_allocation_callbacks* pAlloc MA_API ma_node_graph* ma_node_get_node_graph(const ma_node* pNode) { - if (pNode == NULL) { - return NULL; + if (pNode == nullptr) { + return nullptr; } return ((const ma_node_base*)pNode)->pNodeGraph; @@ -74716,7 +74716,7 @@ MA_API ma_node_graph* ma_node_get_node_graph(const ma_node* pNode) MA_API ma_uint32 ma_node_get_input_bus_count(const ma_node* pNode) { - if (pNode == NULL) { + if (pNode == nullptr) { return 0; } @@ -74725,7 +74725,7 @@ MA_API ma_uint32 ma_node_get_input_bus_count(const ma_node* pNode) MA_API ma_uint32 ma_node_get_output_bus_count(const ma_node* pNode) { - if (pNode == NULL) { + if (pNode == nullptr) { return 0; } @@ -74737,7 +74737,7 @@ MA_API ma_uint32 ma_node_get_input_channels(const ma_node* pNode, ma_uint32 inpu { const ma_node_base* pNodeBase = (const ma_node_base*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return 0; } @@ -74752,7 +74752,7 @@ MA_API ma_uint32 ma_node_get_output_channels(const ma_node* pNode, ma_uint32 out { const ma_node_base* pNodeBase = (const ma_node_base*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return 0; } @@ -74769,7 +74769,7 @@ static ma_result ma_node_detach_full(ma_node* pNode) ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_uint32 iInputBus; - if (pNodeBase == NULL) { + if (pNodeBase == nullptr) { return MA_INVALID_ARGS; } @@ -74796,7 +74796,7 @@ static ma_result ma_node_detach_full(ma_node* pNode) linked list logic. We don't need to worry about the audio thread referencing these because the step above severed the connection to the graph. */ - for (pOutputBus = (ma_node_output_bus*)ma_atomic_load_ptr(&pInputBus->head.pNext); pOutputBus != NULL; pOutputBus = (ma_node_output_bus*)ma_atomic_load_ptr(&pInputBus->head.pNext)) { + for (pOutputBus = (ma_node_output_bus*)ma_atomic_load_ptr(&pInputBus->head.pNext); pOutputBus != nullptr; pOutputBus = (ma_node_output_bus*)ma_atomic_load_ptr(&pInputBus->head.pNext)) { ma_node_detach_output_bus(pOutputBus->pNode, pOutputBus->outputBusIndex); /* This won't do any waiting in practice and should be efficient. */ } } @@ -74810,7 +74810,7 @@ MA_API ma_result ma_node_detach_output_bus(ma_node* pNode, ma_uint32 outputBusIn ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_node_base* pInputNodeBase; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -74822,7 +74822,7 @@ MA_API ma_result ma_node_detach_output_bus(ma_node* pNode, ma_uint32 outputBusIn ma_node_output_bus_lock(&pNodeBase->pOutputBuses[outputBusIndex]); { pInputNodeBase = (ma_node_base*)pNodeBase->pOutputBuses[outputBusIndex].pInputNode; - if (pInputNodeBase != NULL) { + if (pInputNodeBase != nullptr) { ma_node_input_bus_detach__no_output_bus_lock(&pInputNodeBase->pInputBuses[pNodeBase->pOutputBuses[outputBusIndex].inputNodeInputBusIndex], &pNodeBase->pOutputBuses[outputBusIndex]); } } @@ -74835,7 +74835,7 @@ MA_API ma_result ma_node_detach_all_output_buses(ma_node* pNode) { ma_uint32 iOutputBus; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -74851,7 +74851,7 @@ MA_API ma_result ma_node_attach_output_bus(ma_node* pNode, ma_uint32 outputBusIn ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_node_base* pOtherNodeBase = (ma_node_base*)pOtherNode; - if (pNodeBase == NULL || pOtherNodeBase == NULL) { + if (pNodeBase == nullptr || pOtherNodeBase == nullptr) { return MA_INVALID_ARGS; } @@ -74878,7 +74878,7 @@ MA_API ma_result ma_node_set_output_bus_volume(ma_node* pNode, ma_uint32 outputB { ma_node_base* pNodeBase = (ma_node_base*)pNode; - if (pNodeBase == NULL) { + if (pNodeBase == nullptr) { return MA_INVALID_ARGS; } @@ -74893,7 +74893,7 @@ MA_API float ma_node_get_output_bus_volume(const ma_node* pNode, ma_uint32 outpu { const ma_node_base* pNodeBase = (const ma_node_base*)pNode; - if (pNodeBase == NULL) { + if (pNodeBase == nullptr) { return 0; } @@ -74908,7 +74908,7 @@ MA_API ma_result ma_node_set_state(ma_node* pNode, ma_node_state state) { ma_node_base* pNodeBase = (ma_node_base*)pNode; - if (pNodeBase == NULL) { + if (pNodeBase == nullptr) { return MA_INVALID_ARGS; } @@ -74921,7 +74921,7 @@ MA_API ma_node_state ma_node_get_state(const ma_node* pNode) { const ma_node_base* pNodeBase = (const ma_node_base*)pNode; - if (pNodeBase == NULL) { + if (pNodeBase == nullptr) { return ma_node_state_stopped; } @@ -74930,7 +74930,7 @@ MA_API ma_node_state ma_node_get_state(const ma_node* pNode) MA_API ma_result ma_node_set_state_time(ma_node* pNode, ma_node_state state, ma_uint64 globalTime) { - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -74946,7 +74946,7 @@ MA_API ma_result ma_node_set_state_time(ma_node* pNode, ma_node_state state, ma_ MA_API ma_uint64 ma_node_get_state_time(const ma_node* pNode, ma_node_state state) { - if (pNode == NULL) { + if (pNode == nullptr) { return 0; } @@ -74960,7 +74960,7 @@ MA_API ma_uint64 ma_node_get_state_time(const ma_node* pNode, ma_node_state stat MA_API ma_node_state ma_node_get_state_by_time(const ma_node* pNode, ma_uint64 globalTime) { - if (pNode == NULL) { + if (pNode == nullptr) { return ma_node_state_stopped; } @@ -74971,7 +74971,7 @@ MA_API ma_node_state ma_node_get_state_by_time_range(const ma_node* pNode, ma_ui { ma_node_state state; - if (pNode == NULL) { + if (pNode == nullptr) { return ma_node_state_stopped; } @@ -75001,7 +75001,7 @@ MA_API ma_node_state ma_node_get_state_by_time_range(const ma_node* pNode, ma_ui MA_API ma_uint64 ma_node_get_time(const ma_node* pNode) { - if (pNode == NULL) { + if (pNode == nullptr) { return 0; } @@ -75010,7 +75010,7 @@ MA_API ma_uint64 ma_node_get_time(const ma_node* pNode) MA_API ma_result ma_node_set_time(ma_node* pNode, ma_uint64 localTime) { - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -75025,7 +75025,7 @@ static void ma_node_process_pcm_frames_internal(ma_node* pNode, const float** pp { ma_node_base* pNodeBase = (ma_node_base*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); if (pNodeBase->vtable->onProcess) { pNodeBase->vtable->onProcess(pNode, ppFramesIn, pFrameCountIn, ppFramesOut, pFrameCountOut); @@ -75057,14 +75057,14 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde expected that the number of frames read may be different to that requested. Therefore, the caller must look at this value to correctly determine how many frames were read. */ - MA_ASSERT(pFramesRead != NULL); /* <-- If you've triggered this assert, you're using this function wrong. You *must* use this variable and inspect it after the call returns. */ - if (pFramesRead == NULL) { + MA_ASSERT(pFramesRead != nullptr); /* <-- If you've triggered this assert, you're using this function wrong. You *must* use this variable and inspect it after the call returns. */ + if (pFramesRead == nullptr) { return MA_INVALID_ARGS; } *pFramesRead = 0; /* Safety. */ - if (pNodeBase == NULL) { + if (pNodeBase == nullptr) { return MA_INVALID_ARGS; } @@ -75142,7 +75142,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, ma_node_get_output_channels(pNode, outputBusIndex)); } - ma_node_process_pcm_frames_internal(pNode, NULL, &frameCountIn, ppFramesOut, &frameCountOut); + ma_node_process_pcm_frames_internal(pNode, nullptr, &frameCountIn, ppFramesOut, &frameCountOut); totalFramesRead = frameCountOut; } else { /* Slow path. Need to read input data. */ @@ -75271,7 +75271,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde input frames to the maximum number we read from each attachment (the lesser will be padded with silence). If we didn't read anything, this will be set to 0 and the entire buffer will have been assigned to silence. This being equal to 0 is an important property for us because - it allows us to detect when NULL can be passed into the processing callback for the input + it allows us to detect when nullptr can be passed into the processing callback for the input buffer for the purpose of continuous processing. */ pNodeBase->cachedFrameCountIn = (ma_uint16)maxFramesReadIn; @@ -75287,7 +75287,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde optimization here - we can set the pointer to the output buffer for this output bus so that the final copy into the output buffer is done directly by onProcess(). */ - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { ppFramesOut[outputBusIndex] = ma_offset_pcm_frames_ptr_f32(pFramesOut, pNodeBase->cachedFrameCountOut, ma_node_get_output_channels(pNode, outputBusIndex)); } @@ -75299,7 +75299,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde We need to treat nodes with continuous processing a little differently. For these ones, we always want to fire the callback with the requested number of frames, regardless of pNodeBase->cachedFrameCountIn, which could be 0. Also, we want to check if we can pass - in NULL for the input buffer to the callback. + in nullptr for the input buffer to the callback. */ if ((pNodeBase->vtable->flags & MA_NODE_FLAG_CONTINUOUS_PROCESSING) != 0) { /* We're using continuous processing. Make sure we specify the whole frame count at all times. */ @@ -75332,11 +75332,11 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde } /* - Process data slightly differently depending on whether or not we're consuming NULL + Process data slightly differently depending on whether or not we're consuming nullptr input (checked just above). */ if (consumeNullInput) { - ma_node_process_pcm_frames_internal(pNode, NULL, &frameCountIn, ppFramesOut, &frameCountOut); + ma_node_process_pcm_frames_internal(pNode, nullptr, &frameCountIn, ppFramesOut, &frameCountOut); } else { /* We want to skip processing if there's no input data, but we can only do that safely if @@ -75360,7 +75360,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde Thanks to our sneaky optimization above we don't need to do any data copying directly into the output buffer - the onProcess() callback just did that for us. We do, however, need to apply the number of input and output frames that were processed. Note that due to continuous - processing above, we need to do explicit checks here. If we just consumed a NULL input + processing above, we need to do explicit checks here. If we just consumed a nullptr input buffer it means that no actual input data was processed from the internal buffers and we don't want to be modifying any counters. */ @@ -75382,7 +75382,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde We're not needing to read anything from the input buffer so just read directly from our already-processed data. */ - if (pFramesOut != NULL) { + if (pFramesOut != nullptr) { ma_copy_pcm_frames(pFramesOut, ma_node_get_cached_output_ptr(pNodeBase, outputBusIndex), pNodeBase->cachedFrameCountOut, ma_format_f32, ma_node_get_output_channels(pNodeBase, outputBusIndex)); } } @@ -75429,8 +75429,8 @@ static void ma_data_source_node_process_pcm_frames(ma_node* pNode, const float** ma_uint32 frameCount; ma_uint64 framesRead = 0; - MA_ASSERT(pDataSourceNode != NULL); - MA_ASSERT(pDataSourceNode->pDataSource != NULL); + MA_ASSERT(pDataSourceNode != nullptr); + MA_ASSERT(pDataSourceNode->pDataSource != nullptr); MA_ASSERT(ma_node_get_input_bus_count(pDataSourceNode) == 0); MA_ASSERT(ma_node_get_output_bus_count(pDataSourceNode) == 1); @@ -75443,7 +75443,7 @@ static void ma_data_source_node_process_pcm_frames(ma_node* pNode, const float** /* miniaudio should never be calling this with a frame count of zero. */ MA_ASSERT(frameCount > 0); - if (ma_data_source_get_data_format(pDataSourceNode->pDataSource, &format, &channels, NULL, NULL, 0) == MA_SUCCESS) { /* <-- Don't care about sample rate here. */ + if (ma_data_source_get_data_format(pDataSourceNode->pDataSource, &format, &channels, nullptr, nullptr, 0) == MA_SUCCESS) { /* <-- Don't care about sample rate here. */ /* The node graph system requires samples be in floating point format. This is checked in ma_data_source_node_init(). */ MA_ASSERT(format == ma_format_f32); (void)format; /* Just to silence some static analysis tools. */ @@ -75457,7 +75457,7 @@ static void ma_data_source_node_process_pcm_frames(ma_node* pNode, const float** static ma_node_vtable g_ma_data_source_node_vtable = { ma_data_source_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 0, /* 0 input buses. */ 1, /* 1 output bus. */ 0 @@ -75470,17 +75470,17 @@ MA_API ma_result ma_data_source_node_init(ma_node_graph* pNodeGraph, const ma_da ma_uint32 channels; /* For specifying the channel count of the output bus. */ ma_node_config baseConfig; - if (pDataSourceNode == NULL) { + if (pDataSourceNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDataSourceNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - result = ma_data_source_get_data_format(pConfig->pDataSource, &format, &channels, NULL, NULL, 0); /* Don't care about sample rate. This will check pDataSource for NULL. */ + result = ma_data_source_get_data_format(pConfig->pDataSource, &format, &channels, nullptr, nullptr, 0); /* Don't care about sample rate. This will check pDataSource for nullptr. */ if (result != MA_SUCCESS) { return result; } @@ -75497,11 +75497,11 @@ MA_API ma_result ma_data_source_node_init(ma_node_graph* pNodeGraph, const ma_da /* The channel count is defined by the data source. It is invalid for the caller to manually set the channel counts in the config. `ma_data_source_node_config_init()` will have defaulted the - channel count pointer to NULL which is how it must remain. If you trigger any of these asserts + channel count pointer to nullptr which is how it must remain. If you trigger any of these asserts it means you're explicitly setting the channel count. Instead, configure the output channel count of your data source to be the necessary channel count. */ - if (baseConfig.pOutputChannels != NULL) { + if (baseConfig.pOutputChannels != nullptr) { return MA_INVALID_ARGS; } @@ -75524,7 +75524,7 @@ MA_API void ma_data_source_node_uninit(ma_data_source_node* pDataSourceNode, con MA_API ma_result ma_data_source_node_set_looping(ma_data_source_node* pDataSourceNode, ma_bool32 isLooping) { - if (pDataSourceNode == NULL) { + if (pDataSourceNode == nullptr) { return MA_INVALID_ARGS; } @@ -75533,7 +75533,7 @@ MA_API ma_result ma_data_source_node_set_looping(ma_data_source_node* pDataSourc MA_API ma_bool32 ma_data_source_node_is_looping(ma_data_source_node* pDataSourceNode) { - if (pDataSourceNode == NULL) { + if (pDataSourceNode == nullptr) { return MA_FALSE; } @@ -75562,7 +75562,7 @@ static void ma_splitter_node_process_pcm_frames(ma_node* pNode, const float** pp ma_uint32 iOutputBus; ma_uint32 channels; - MA_ASSERT(pNodeBase != NULL); + MA_ASSERT(pNodeBase != nullptr); MA_ASSERT(ma_node_get_input_bus_count(pNodeBase) == 1); /* We don't need to consider the input frame count - it'll be the same as the output frame count and we process everything. */ @@ -75580,7 +75580,7 @@ static void ma_splitter_node_process_pcm_frames(ma_node* pNode, const float** pp static ma_node_vtable g_ma_splitter_node_vtable = { ma_splitter_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* 1 input bus. */ MA_NODE_BUS_COUNT_UNKNOWN, /* The output bus count is specified on a per-node basis. */ 0 @@ -75594,13 +75594,13 @@ MA_API ma_result ma_splitter_node_init(ma_node_graph* pNodeGraph, const ma_split ma_uint32 pOutputChannels[MA_MAX_NODE_BUS_COUNT]; ma_uint32 iOutputBus; - if (pSplitterNode == NULL) { + if (pSplitterNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pSplitterNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -75651,7 +75651,7 @@ static void ma_biquad_node_process_pcm_frames(ma_node* pNode, const float** ppFr { ma_biquad_node* pLPFNode = (ma_biquad_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); (void)pFrameCountIn; ma_biquad_process_pcm_frames(&pLPFNode->biquad, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); @@ -75660,7 +75660,7 @@ static void ma_biquad_node_process_pcm_frames(ma_node* pNode, const float** ppFr static ma_node_vtable g_ma_biquad_node_vtable = { ma_biquad_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ @@ -75671,13 +75671,13 @@ MA_API ma_result ma_biquad_node_init(ma_node_graph* pNodeGraph, const ma_biquad_ ma_result result; ma_node_config baseNodeConfig; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -75707,7 +75707,7 @@ MA_API ma_result ma_biquad_node_reinit(const ma_biquad_config* pConfig, ma_biqua { ma_biquad_node* pLPFNode = (ma_biquad_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); return ma_biquad_reinit(pConfig, &pLPFNode->biquad); } @@ -75716,7 +75716,7 @@ MA_API void ma_biquad_node_uninit(ma_biquad_node* pNode, const ma_allocation_cal { ma_biquad_node* pLPFNode = (ma_biquad_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return; } @@ -75743,7 +75743,7 @@ static void ma_lpf_node_process_pcm_frames(ma_node* pNode, const float** ppFrame { ma_lpf_node* pLPFNode = (ma_lpf_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); (void)pFrameCountIn; ma_lpf_process_pcm_frames(&pLPFNode->lpf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); @@ -75752,7 +75752,7 @@ static void ma_lpf_node_process_pcm_frames(ma_node* pNode, const float** ppFrame static ma_node_vtable g_ma_lpf_node_vtable = { ma_lpf_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ @@ -75763,13 +75763,13 @@ MA_API ma_result ma_lpf_node_init(ma_node_graph* pNodeGraph, const ma_lpf_node_c ma_result result; ma_node_config baseNodeConfig; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -75799,7 +75799,7 @@ MA_API ma_result ma_lpf_node_reinit(const ma_lpf_config* pConfig, ma_lpf_node* p { ma_lpf_node* pLPFNode = (ma_lpf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -75810,7 +75810,7 @@ MA_API void ma_lpf_node_uninit(ma_lpf_node* pNode, const ma_allocation_callbacks { ma_lpf_node* pLPFNode = (ma_lpf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return; } @@ -75837,7 +75837,7 @@ static void ma_hpf_node_process_pcm_frames(ma_node* pNode, const float** ppFrame { ma_hpf_node* pHPFNode = (ma_hpf_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); (void)pFrameCountIn; ma_hpf_process_pcm_frames(&pHPFNode->hpf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); @@ -75846,7 +75846,7 @@ static void ma_hpf_node_process_pcm_frames(ma_node* pNode, const float** ppFrame static ma_node_vtable g_ma_hpf_node_vtable = { ma_hpf_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ @@ -75857,13 +75857,13 @@ MA_API ma_result ma_hpf_node_init(ma_node_graph* pNodeGraph, const ma_hpf_node_c ma_result result; ma_node_config baseNodeConfig; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -75893,7 +75893,7 @@ MA_API ma_result ma_hpf_node_reinit(const ma_hpf_config* pConfig, ma_hpf_node* p { ma_hpf_node* pHPFNode = (ma_hpf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -75904,7 +75904,7 @@ MA_API void ma_hpf_node_uninit(ma_hpf_node* pNode, const ma_allocation_callbacks { ma_hpf_node* pHPFNode = (ma_hpf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return; } @@ -75932,7 +75932,7 @@ static void ma_bpf_node_process_pcm_frames(ma_node* pNode, const float** ppFrame { ma_bpf_node* pBPFNode = (ma_bpf_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); (void)pFrameCountIn; ma_bpf_process_pcm_frames(&pBPFNode->bpf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); @@ -75941,7 +75941,7 @@ static void ma_bpf_node_process_pcm_frames(ma_node* pNode, const float** ppFrame static ma_node_vtable g_ma_bpf_node_vtable = { ma_bpf_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ @@ -75952,13 +75952,13 @@ MA_API ma_result ma_bpf_node_init(ma_node_graph* pNodeGraph, const ma_bpf_node_c ma_result result; ma_node_config baseNodeConfig; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -75988,7 +75988,7 @@ MA_API ma_result ma_bpf_node_reinit(const ma_bpf_config* pConfig, ma_bpf_node* p { ma_bpf_node* pBPFNode = (ma_bpf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -75999,7 +75999,7 @@ MA_API void ma_bpf_node_uninit(ma_bpf_node* pNode, const ma_allocation_callbacks { ma_bpf_node* pBPFNode = (ma_bpf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return; } @@ -76026,7 +76026,7 @@ static void ma_notch_node_process_pcm_frames(ma_node* pNode, const float** ppFra { ma_notch_node* pBPFNode = (ma_notch_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); (void)pFrameCountIn; ma_notch2_process_pcm_frames(&pBPFNode->notch, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); @@ -76035,7 +76035,7 @@ static void ma_notch_node_process_pcm_frames(ma_node* pNode, const float** ppFra static ma_node_vtable g_ma_notch_node_vtable = { ma_notch_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ @@ -76046,13 +76046,13 @@ MA_API ma_result ma_notch_node_init(ma_node_graph* pNodeGraph, const ma_notch_no ma_result result; ma_node_config baseNodeConfig; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -76082,7 +76082,7 @@ MA_API ma_result ma_notch_node_reinit(const ma_notch_config* pConfig, ma_notch_n { ma_notch_node* pNotchNode = (ma_notch_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -76093,7 +76093,7 @@ MA_API void ma_notch_node_uninit(ma_notch_node* pNode, const ma_allocation_callb { ma_notch_node* pNotchNode = (ma_notch_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return; } @@ -76120,7 +76120,7 @@ static void ma_peak_node_process_pcm_frames(ma_node* pNode, const float** ppFram { ma_peak_node* pBPFNode = (ma_peak_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); (void)pFrameCountIn; ma_peak2_process_pcm_frames(&pBPFNode->peak, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); @@ -76129,7 +76129,7 @@ static void ma_peak_node_process_pcm_frames(ma_node* pNode, const float** ppFram static ma_node_vtable g_ma_peak_node_vtable = { ma_peak_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ @@ -76140,13 +76140,13 @@ MA_API ma_result ma_peak_node_init(ma_node_graph* pNodeGraph, const ma_peak_node ma_result result; ma_node_config baseNodeConfig; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -76177,7 +76177,7 @@ MA_API ma_result ma_peak_node_reinit(const ma_peak_config* pConfig, ma_peak_node { ma_peak_node* pPeakNode = (ma_peak_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -76188,7 +76188,7 @@ MA_API void ma_peak_node_uninit(ma_peak_node* pNode, const ma_allocation_callbac { ma_peak_node* pPeakNode = (ma_peak_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return; } @@ -76215,7 +76215,7 @@ static void ma_loshelf_node_process_pcm_frames(ma_node* pNode, const float** ppF { ma_loshelf_node* pBPFNode = (ma_loshelf_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); (void)pFrameCountIn; ma_loshelf2_process_pcm_frames(&pBPFNode->loshelf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); @@ -76224,7 +76224,7 @@ static void ma_loshelf_node_process_pcm_frames(ma_node* pNode, const float** ppF static ma_node_vtable g_ma_loshelf_node_vtable = { ma_loshelf_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ @@ -76235,13 +76235,13 @@ MA_API ma_result ma_loshelf_node_init(ma_node_graph* pNodeGraph, const ma_loshel ma_result result; ma_node_config baseNodeConfig; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -76271,7 +76271,7 @@ MA_API ma_result ma_loshelf_node_reinit(const ma_loshelf_config* pConfig, ma_los { ma_loshelf_node* pLoshelfNode = (ma_loshelf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -76282,7 +76282,7 @@ MA_API void ma_loshelf_node_uninit(ma_loshelf_node* pNode, const ma_allocation_c { ma_loshelf_node* pLoshelfNode = (ma_loshelf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return; } @@ -76309,7 +76309,7 @@ static void ma_hishelf_node_process_pcm_frames(ma_node* pNode, const float** ppF { ma_hishelf_node* pBPFNode = (ma_hishelf_node*)pNode; - MA_ASSERT(pNode != NULL); + MA_ASSERT(pNode != nullptr); (void)pFrameCountIn; ma_hishelf2_process_pcm_frames(&pBPFNode->hishelf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); @@ -76318,7 +76318,7 @@ static void ma_hishelf_node_process_pcm_frames(ma_node* pNode, const float** ppF static ma_node_vtable g_ma_hishelf_node_vtable = { ma_hishelf_node_process_pcm_frames, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ @@ -76329,13 +76329,13 @@ MA_API ma_result ma_hishelf_node_init(ma_node_graph* pNodeGraph, const ma_hishel ma_result result; ma_node_config baseNodeConfig; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -76365,7 +76365,7 @@ MA_API ma_result ma_hishelf_node_reinit(const ma_hishelf_config* pConfig, ma_his { ma_hishelf_node* pHishelfNode = (ma_hishelf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return MA_INVALID_ARGS; } @@ -76376,7 +76376,7 @@ MA_API void ma_hishelf_node_uninit(ma_hishelf_node* pNode, const ma_allocation_c { ma_hishelf_node* pHishelfNode = (ma_hishelf_node*)pNode; - if (pNode == NULL) { + if (pNode == nullptr) { return; } @@ -76410,7 +76410,7 @@ static void ma_delay_node_process_pcm_frames(ma_node* pNode, const float** ppFra static ma_node_vtable g_ma_delay_node_vtable = { ma_delay_node_process_pcm_frames, - NULL, + nullptr, 1, /* 1 input channels. */ 1, /* 1 output channel. */ MA_NODE_FLAG_CONTINUOUS_PROCESSING /* Delay requires continuous processing to ensure the tail get's processed. */ @@ -76421,7 +76421,7 @@ MA_API ma_result ma_delay_node_init(ma_node_graph* pNodeGraph, const ma_delay_no ma_result result; ma_node_config baseConfig; - if (pDelayNode == NULL) { + if (pDelayNode == nullptr) { return MA_INVALID_ARGS; } @@ -76448,7 +76448,7 @@ MA_API ma_result ma_delay_node_init(ma_node_graph* pNodeGraph, const ma_delay_no MA_API void ma_delay_node_uninit(ma_delay_node* pDelayNode, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pDelayNode == NULL) { + if (pDelayNode == nullptr) { return; } @@ -76459,7 +76459,7 @@ MA_API void ma_delay_node_uninit(ma_delay_node* pDelayNode, const ma_allocation_ MA_API void ma_delay_node_set_wet(ma_delay_node* pDelayNode, float value) { - if (pDelayNode == NULL) { + if (pDelayNode == nullptr) { return; } @@ -76468,7 +76468,7 @@ MA_API void ma_delay_node_set_wet(ma_delay_node* pDelayNode, float value) MA_API float ma_delay_node_get_wet(const ma_delay_node* pDelayNode) { - if (pDelayNode == NULL) { + if (pDelayNode == nullptr) { return 0; } @@ -76477,7 +76477,7 @@ MA_API float ma_delay_node_get_wet(const ma_delay_node* pDelayNode) MA_API void ma_delay_node_set_dry(ma_delay_node* pDelayNode, float value) { - if (pDelayNode == NULL) { + if (pDelayNode == nullptr) { return; } @@ -76486,7 +76486,7 @@ MA_API void ma_delay_node_set_dry(ma_delay_node* pDelayNode, float value) MA_API float ma_delay_node_get_dry(const ma_delay_node* pDelayNode) { - if (pDelayNode == NULL) { + if (pDelayNode == nullptr) { return 0; } @@ -76495,7 +76495,7 @@ MA_API float ma_delay_node_get_dry(const ma_delay_node* pDelayNode) MA_API void ma_delay_node_set_decay(ma_delay_node* pDelayNode, float value) { - if (pDelayNode == NULL) { + if (pDelayNode == nullptr) { return; } @@ -76504,7 +76504,7 @@ MA_API void ma_delay_node_set_decay(ma_delay_node* pDelayNode, float value) MA_API float ma_delay_node_get_decay(const ma_delay_node* pDelayNode) { - if (pDelayNode == NULL) { + if (pDelayNode == nullptr) { return 0; } @@ -76525,7 +76525,7 @@ Engine static void ma_sound_set_at_end(ma_sound* pSound, ma_bool32 atEnd) { - MA_ASSERT(pSound != NULL); + MA_ASSERT(pSound != nullptr); ma_atomic_exchange_32(&pSound->atEnd, atEnd); /* @@ -76537,7 +76537,7 @@ static void ma_sound_set_at_end(ma_sound* pSound, ma_bool32 atEnd) #if 0 /* Fire any callbacks or events. */ if (atEnd) { - if (pSound->endCallback != NULL) { + if (pSound->endCallback != nullptr) { pSound->endCallback(pSound->pEndCallbackUserData, pSound); } } @@ -76546,7 +76546,7 @@ static void ma_sound_set_at_end(ma_sound* pSound, ma_bool32 atEnd) static ma_bool32 ma_sound_get_at_end(const ma_sound* pSound) { - MA_ASSERT(pSound != NULL); + MA_ASSERT(pSound != nullptr); return ma_atomic_load_32(&pSound->atEnd); } @@ -76572,7 +76572,7 @@ static void ma_engine_node_update_pitch_if_required(ma_engine_node* pEngineNode) ma_bool32 isUpdateRequired = MA_FALSE; float newPitch; - MA_ASSERT(pEngineNode != NULL); + MA_ASSERT(pEngineNode != nullptr); newPitch = ma_atomic_load_explicit_f32(&pEngineNode->pitch, ma_atomic_memory_order_acquire); @@ -76594,7 +76594,7 @@ static void ma_engine_node_update_pitch_if_required(ma_engine_node* pEngineNode) static ma_bool32 ma_engine_node_is_pitching_enabled(const ma_engine_node* pEngineNode) { - MA_ASSERT(pEngineNode != NULL); + MA_ASSERT(pEngineNode != nullptr); /* Don't try to be clever by skipping resampling in the pitch=1 case or else you'll glitch when moving away from 1. */ return !ma_atomic_load_explicit_32(&pEngineNode->isPitchDisabled, ma_atomic_memory_order_acquire); @@ -76602,14 +76602,14 @@ static ma_bool32 ma_engine_node_is_pitching_enabled(const ma_engine_node* pEngin static ma_bool32 ma_engine_node_is_spatialization_enabled(const ma_engine_node* pEngineNode) { - MA_ASSERT(pEngineNode != NULL); + MA_ASSERT(pEngineNode != nullptr); return !ma_atomic_load_explicit_32(&pEngineNode->isSpatializationDisabled, ma_atomic_memory_order_acquire); } static ma_result ma_engine_node_set_volume(ma_engine_node* pEngineNode, float volume) { - if (pEngineNode == NULL) { + if (pEngineNode == nullptr) { return MA_INVALID_ARGS; } @@ -76629,13 +76629,13 @@ static ma_result ma_engine_node_set_volume(ma_engine_node* pEngineNode, float vo static ma_result ma_engine_node_get_volume(const ma_engine_node* pEngineNode, float* pVolume) { - if (pVolume == NULL) { + if (pVolume == nullptr) { return MA_INVALID_ARGS; } *pVolume = 0.0f; - if (pEngineNode == NULL) { + if (pEngineNode == nullptr) { return MA_INVALID_ARGS; } @@ -76821,7 +76821,7 @@ static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNo } } else { /* Channel conversion required. TODO: Add support for channel maps here. */ - ma_channel_map_apply_f32(pRunningFramesOut, NULL, channelsOut, pWorkingBuffer, NULL, channelsIn, framesJustProcessedOut, ma_channel_mix_mode_simple, pEngineNode->monoExpansionMode); + ma_channel_map_apply_f32(pRunningFramesOut, nullptr, channelsOut, pWorkingBuffer, nullptr, channelsIn, framesJustProcessedOut, ma_channel_mix_mode_simple, pEngineNode->monoExpansionMode); /* If we're using smoothing, the volume will have already been applied. */ if (!isVolumeSmoothingEnabled) { @@ -76873,7 +76873,7 @@ static void ma_engine_node_process_pcm_frames__sound(ma_node* pNode, const float if (ma_sound_at_end(pSound)) { ma_sound_stop(pSound); - if (pSound->endCallback != NULL) { + if (pSound->endCallback != nullptr) { pSound->endCallback(pSound->pEndCallbackUserData, pSound); } @@ -76907,7 +76907,7 @@ static void ma_engine_node_process_pcm_frames__sound(ma_node* pNode, const float For the convenience of the caller, we're doing to allow data sources to use non-floating-point formats and channel counts that differ from the main engine. */ - result = ma_data_source_get_data_format(pSound->pDataSource, &dataSourceFormat, &dataSourceChannels, NULL, NULL, 0); + result = ma_data_source_get_data_format(pSound->pDataSource, &dataSourceFormat, &dataSourceChannels, nullptr, nullptr, 0); if (result == MA_SUCCESS) { tempCapInFrames = sizeof(temp) / ma_get_bytes_per_frame(dataSourceFormat, dataSourceChannels); @@ -77008,7 +77008,7 @@ static void ma_engine_node_process_pcm_frames__group(ma_node* pNode, const float static ma_node_vtable g_ma_engine_node_vtable__sound = { ma_engine_node_process_pcm_frames__sound, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 0, /* Sounds are data source nodes which means they have zero inputs (their input is drawn from the data source itself). */ 1, /* Sounds have one output bus. */ 0 /* Default flags. */ @@ -77017,7 +77017,7 @@ static ma_node_vtable g_ma_engine_node_vtable__sound = static ma_node_vtable g_ma_engine_node_vtable__group = { ma_engine_node_process_pcm_frames__group, - NULL, /* onGetRequiredInputFrameCount */ + nullptr, /* onGetRequiredInputFrameCount */ 1, /* Groups have one input bus. */ 1, /* Groups have one output bus. */ MA_NODE_FLAG_DIFFERENT_PROCESSING_RATES /* The engine node does resampling so should let miniaudio know about it. */ @@ -77075,11 +77075,11 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo MA_ZERO_OBJECT(pHeapLayout); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } - if (pConfig->pEngine == NULL) { + if (pConfig->pEngine == nullptr) { return MA_INVALID_ARGS; /* An engine must be specified. */ } @@ -77158,7 +77158,7 @@ MA_API ma_result ma_engine_node_get_heap_size(const ma_engine_node_config* pConf ma_result result; ma_engine_node_heap_layout heapLayout; - if (pHeapSizeInBytes == NULL) { + if (pHeapSizeInBytes == nullptr) { return MA_INVALID_ARGS; } @@ -77188,7 +77188,7 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p ma_uint32 channelsOut; ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */ - if (pEngineNode == NULL) { + if (pEngineNode == nullptr) { return MA_INVALID_ARGS; } @@ -77318,9 +77318,9 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p return MA_SUCCESS; /* No need for allocation callbacks here because we use a preallocated heap. */ -error3: ma_spatializer_uninit(&pEngineNode->spatializer, NULL); -error2: ma_resampler_uninit(&pEngineNode->resampler, NULL); -error1: ma_node_uninit(&pEngineNode->baseNode, NULL); +error3: ma_spatializer_uninit(&pEngineNode->spatializer, nullptr); +error2: ma_resampler_uninit(&pEngineNode->resampler, nullptr); +error1: ma_node_uninit(&pEngineNode->baseNode, nullptr); error0: return result; } @@ -77337,11 +77337,11 @@ MA_API ma_result ma_engine_node_init(const ma_engine_node_config* pConfig, const if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); - if (pHeap == NULL) { + if (pHeap == nullptr) { return MA_OUT_OF_MEMORY; } } else { - pHeap = NULL; + pHeap = nullptr; } result = ma_engine_node_init_preallocated(pConfig, pHeap, pEngineNode); @@ -77379,7 +77379,7 @@ MA_API void ma_engine_node_uninit(ma_engine_node* pEngineNode, const ma_allocati MA_API ma_sound_config ma_sound_config_init(void) { - return ma_sound_config_init_2(NULL); + return ma_sound_config_init_2(nullptr); } MA_API ma_sound_config ma_sound_config_init_2(ma_engine* pEngine) @@ -77388,7 +77388,7 @@ MA_API ma_sound_config ma_sound_config_init_2(ma_engine* pEngine) MA_ZERO_OBJECT(&config); - if (pEngine != NULL) { + if (pEngine != nullptr) { config.monoExpansionMode = pEngine->monoExpansionMode; config.pitchResampling = pEngine->pitchResamplingConfig; } else { @@ -77406,7 +77406,7 @@ MA_API ma_sound_config ma_sound_config_init_2(ma_engine* pEngine) MA_API ma_sound_group_config ma_sound_group_config_init(void) { - return ma_sound_group_config_init_2(NULL); + return ma_sound_group_config_init_2(nullptr); } MA_API ma_sound_group_config ma_sound_group_config_init_2(ma_engine* pEngine) @@ -77415,7 +77415,7 @@ MA_API ma_sound_group_config ma_sound_group_config_init_2(ma_engine* pEngine) MA_ZERO_OBJECT(&config); - if (pEngine != NULL) { + if (pEngine != nullptr) { config.monoExpansionMode = pEngine->monoExpansionMode; config.pitchResampling = pEngine->pitchResamplingConfig; } else { @@ -77468,7 +77468,7 @@ static void ma_engine_data_callback_internal(ma_device* pDevice, void* pFramesOu */ #if !defined(MA_NO_RESOURCE_MANAGER) && defined(MA_EMSCRIPTEN) { - if (pEngine->pResourceManager != NULL) { + if (pEngine->pResourceManager != nullptr) { if ((pEngine->pResourceManager->config.flags & MA_RESOURCE_MANAGER_FLAG_NO_THREADING) != 0) { ma_resource_manager_process_next_job(pEngine->pResourceManager); } @@ -77476,7 +77476,7 @@ static void ma_engine_data_callback_internal(ma_device* pDevice, void* pFramesOu } #endif - ma_engine_read_pcm_frames(pEngine, pFramesOut, frameCount, NULL); + ma_engine_read_pcm_frames(pEngine, pFramesOut, frameCount, nullptr); } static ma_uint32 ma_device__get_processing_size_in_frames(ma_device* pDevice) @@ -77503,14 +77503,14 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng ma_spatializer_listener_config listenerConfig; ma_uint32 iListener; - if (pEngine == NULL) { + if (pEngine == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pEngine); - /* The config is allowed to be NULL in which case we use defaults for everything. */ - if (pConfig != NULL) { + /* The config is allowed to be nullptr in which case we use defaults for everything. */ + if (pConfig != nullptr) { engineConfig = *pConfig; } else { engineConfig = ma_engine_config_init(); @@ -77534,11 +77534,11 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng pEngine->pDevice = engineConfig.pDevice; /* If we don't have a device, we need one. */ - if (pEngine->pDevice == NULL && engineConfig.noDevice == MA_FALSE) { + if (pEngine->pDevice == nullptr && engineConfig.noDevice == MA_FALSE) { ma_device_config deviceConfig; pEngine->pDevice = (ma_device*)ma_malloc(sizeof(*pEngine->pDevice), &pEngine->allocationCallbacks); - if (pEngine->pDevice == NULL) { + if (pEngine->pDevice == nullptr) { return MA_OUT_OF_MEMORY; } @@ -77547,7 +77547,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng deviceConfig.playback.format = ma_format_f32; deviceConfig.playback.channels = engineConfig.channels; deviceConfig.sampleRate = engineConfig.sampleRate; - deviceConfig.dataCallback = (engineConfig.dataCallback != NULL) ? engineConfig.dataCallback : ma_engine_data_callback_internal; + deviceConfig.dataCallback = (engineConfig.dataCallback != nullptr) ? engineConfig.dataCallback : ma_engine_data_callback_internal; deviceConfig.pUserData = pEngine; deviceConfig.notificationCallback = engineConfig.notificationCallback; deviceConfig.periodSizeInFrames = engineConfig.periodSizeInFrames; @@ -77555,7 +77555,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng deviceConfig.noPreSilencedOutputBuffer = MA_TRUE; /* We'll always be outputting to every frame in the callback so there's no need for a pre-silenced buffer. */ deviceConfig.noClip = MA_TRUE; /* The engine will do clipping itself. */ - if (engineConfig.pContext == NULL) { + if (engineConfig.pContext == nullptr) { ma_context_config contextConfig = ma_context_config_init(); contextConfig.allocationCallbacks = pEngine->allocationCallbacks; contextConfig.pLog = engineConfig.pLog; @@ -77563,20 +77563,20 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng /* If the engine config does not specify a log, use the resource manager's if we have one. */ #ifndef MA_NO_RESOURCE_MANAGER { - if (contextConfig.pLog == NULL && engineConfig.pResourceManager != NULL) { + if (contextConfig.pLog == nullptr && engineConfig.pResourceManager != nullptr) { contextConfig.pLog = ma_resource_manager_get_log(engineConfig.pResourceManager); } } #endif - result = ma_device_init_ex(NULL, 0, &contextConfig, &deviceConfig, pEngine->pDevice); + result = ma_device_init_ex(nullptr, 0, &contextConfig, &deviceConfig, pEngine->pDevice); } else { result = ma_device_init(engineConfig.pContext, &deviceConfig, pEngine->pDevice); } if (result != MA_SUCCESS) { ma_free(pEngine->pDevice, &pEngine->allocationCallbacks); - pEngine->pDevice = NULL; + pEngine->pDevice = nullptr; return result; } @@ -77584,7 +77584,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng } /* Update the channel count and sample rate of the engine config so we can reference it below. */ - if (pEngine->pDevice != NULL) { + if (pEngine->pDevice != nullptr) { engineConfig.channels = pEngine->pDevice->playback.channels; engineConfig.sampleRate = pEngine->pDevice->sampleRate; @@ -77606,7 +77606,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng pEngine->sampleRate = engineConfig.sampleRate; /* The engine always uses either the log that was passed into the config, or the context's log is available. */ - if (engineConfig.pLog != NULL) { + if (engineConfig.pLog != nullptr) { pEngine->pLog = engineConfig.pLog; } else { #if !defined(MA_NO_DEVICE_IO) @@ -77615,7 +77615,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng } #else { - pEngine->pLog = NULL; + pEngine->pLog = nullptr; } #endif } @@ -77651,7 +77651,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng */ #if !defined(MA_NO_DEVICE_IO) { - if (pEngine->pDevice != NULL) { + if (pEngine->pDevice != nullptr) { /* Temporarily disabled. There is a subtle bug here where front-left and front-right will be used by the device's channel map, but this is not what we want to use for @@ -77687,11 +77687,11 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng /* We need a resource manager. */ #ifndef MA_NO_RESOURCE_MANAGER { - if (pEngine->pResourceManager == NULL) { + if (pEngine->pResourceManager == nullptr) { ma_resource_manager_config resourceManagerConfig; pEngine->pResourceManager = (ma_resource_manager*)ma_malloc(sizeof(*pEngine->pResourceManager), &pEngine->allocationCallbacks); - if (pEngine->pResourceManager == NULL) { + if (pEngine->pResourceManager == nullptr) { result = MA_OUT_OF_MEMORY; goto on_error_2; } @@ -77725,12 +77725,12 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng /* Setup some stuff for inlined sounds. That is sounds played with ma_engine_play_sound(). */ pEngine->inlinedSoundLock = 0; - pEngine->pInlinedSoundHead = NULL; + pEngine->pInlinedSoundHead = nullptr; /* Start the engine if required. This should always be the last step. */ #if !defined(MA_NO_DEVICE_IO) { - if (engineConfig.noAutoStart == MA_FALSE && pEngine->pDevice != NULL) { + if (engineConfig.noAutoStart == MA_FALSE && pEngine->pDevice != nullptr) { result = ma_engine_start(pEngine); if (result != MA_SUCCESS) { goto on_error_4; /* Failed to start the engine. */ @@ -77773,7 +77773,7 @@ MA_API void ma_engine_uninit(ma_engine* pEngine) { ma_uint32 iListener; - if (pEngine == NULL) { + if (pEngine == nullptr) { return; } @@ -77784,7 +77784,7 @@ MA_API void ma_engine_uninit(ma_engine* pEngine) ma_device_uninit(pEngine->pDevice); ma_free(pEngine->pDevice, &pEngine->allocationCallbacks); } else { - if (pEngine->pDevice != NULL) { + if (pEngine->pDevice != nullptr) { ma_device_stop(pEngine->pDevice); } } @@ -77799,7 +77799,7 @@ MA_API void ma_engine_uninit(ma_engine* pEngine) { for (;;) { ma_sound_inlined* pSoundToDelete = pEngine->pInlinedSoundHead; - if (pSoundToDelete == NULL) { + if (pSoundToDelete == nullptr) { break; /* Done. */ } @@ -77832,7 +77832,7 @@ MA_API ma_result ma_engine_read_pcm_frames(ma_engine* pEngine, void* pFramesOut, ma_result result; ma_uint64 framesRead = 0; - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = 0; } @@ -77841,7 +77841,7 @@ MA_API ma_result ma_engine_read_pcm_frames(ma_engine* pEngine, void* pFramesOut, return result; } - if (pFramesRead != NULL) { + if (pFramesRead != nullptr) { *pFramesRead = framesRead; } @@ -77854,8 +77854,8 @@ MA_API ma_result ma_engine_read_pcm_frames(ma_engine* pEngine, void* pFramesOut, MA_API ma_node_graph* ma_engine_get_node_graph(ma_engine* pEngine) { - if (pEngine == NULL) { - return NULL; + if (pEngine == nullptr) { + return nullptr; } return &pEngine->nodeGraph; @@ -77864,8 +77864,8 @@ MA_API ma_node_graph* ma_engine_get_node_graph(ma_engine* pEngine) #if !defined(MA_NO_RESOURCE_MANAGER) MA_API ma_resource_manager* ma_engine_get_resource_manager(ma_engine* pEngine) { - if (pEngine == NULL) { - return NULL; + if (pEngine == nullptr) { + return nullptr; } #if !defined(MA_NO_RESOURCE_MANAGER) @@ -77874,7 +77874,7 @@ MA_API ma_resource_manager* ma_engine_get_resource_manager(ma_engine* pEngine) } #else { - return NULL; + return nullptr; } #endif } @@ -77882,8 +77882,8 @@ MA_API ma_resource_manager* ma_engine_get_resource_manager(ma_engine* pEngine) MA_API ma_device* ma_engine_get_device(ma_engine* pEngine) { - if (pEngine == NULL) { - return NULL; + if (pEngine == nullptr) { + return nullptr; } #if !defined(MA_NO_DEVICE_IO) @@ -77892,18 +77892,18 @@ MA_API ma_device* ma_engine_get_device(ma_engine* pEngine) } #else { - return NULL; + return nullptr; } #endif } MA_API ma_log* ma_engine_get_log(ma_engine* pEngine) { - if (pEngine == NULL) { - return NULL; + if (pEngine == nullptr) { + return nullptr; } - if (pEngine->pLog != NULL) { + if (pEngine->pLog != nullptr) { return pEngine->pLog; } else { #if !defined(MA_NO_DEVICE_IO) @@ -77912,7 +77912,7 @@ MA_API ma_log* ma_engine_get_log(ma_engine* pEngine) } #else { - return NULL; + return nullptr; } #endif } @@ -77960,7 +77960,7 @@ MA_API ma_uint32 ma_engine_get_channels(const ma_engine* pEngine) MA_API ma_uint32 ma_engine_get_sample_rate(const ma_engine* pEngine) { - if (pEngine == NULL) { + if (pEngine == nullptr) { return 0; } @@ -77972,13 +77972,13 @@ MA_API ma_result ma_engine_start(ma_engine* pEngine) { ma_result result; - if (pEngine == NULL) { + if (pEngine == nullptr) { return MA_INVALID_ARGS; } #if !defined(MA_NO_DEVICE_IO) { - if (pEngine->pDevice != NULL) { + if (pEngine->pDevice != nullptr) { result = ma_device_start(pEngine->pDevice); } else { result = MA_INVALID_OPERATION; /* The engine is running without a device which means there's no real notion of "starting" the engine. */ @@ -78001,13 +78001,13 @@ MA_API ma_result ma_engine_stop(ma_engine* pEngine) { ma_result result; - if (pEngine == NULL) { + if (pEngine == nullptr) { return MA_INVALID_ARGS; } #if !defined(MA_NO_DEVICE_IO) { - if (pEngine->pDevice != NULL) { + if (pEngine->pDevice != nullptr) { result = ma_device_stop(pEngine->pDevice); } else { result = MA_INVALID_OPERATION; /* The engine is running without a device which means there's no real notion of "stopping" the engine. */ @@ -78028,7 +78028,7 @@ MA_API ma_result ma_engine_stop(ma_engine* pEngine) MA_API ma_result ma_engine_set_volume(ma_engine* pEngine, float volume) { - if (pEngine == NULL) { + if (pEngine == nullptr) { return MA_INVALID_ARGS; } @@ -78037,7 +78037,7 @@ MA_API ma_result ma_engine_set_volume(ma_engine* pEngine, float volume) MA_API float ma_engine_get_volume(ma_engine* pEngine) { - if (pEngine == NULL) { + if (pEngine == nullptr) { return 0; } @@ -78057,7 +78057,7 @@ MA_API float ma_engine_get_gain_db(ma_engine* pEngine) MA_API ma_uint32 ma_engine_get_listener_count(const ma_engine* pEngine) { - if (pEngine == NULL) { + if (pEngine == nullptr) { return 0; } @@ -78070,7 +78070,7 @@ MA_API ma_uint32 ma_engine_find_closest_listener(const ma_engine* pEngine, float ma_uint32 iListenerClosest; float closestLen2 = MA_FLT_MAX; - if (pEngine == NULL || pEngine->listenerCount == 1) { + if (pEngine == nullptr || pEngine->listenerCount == 1) { return 0; } @@ -78091,7 +78091,7 @@ MA_API ma_uint32 ma_engine_find_closest_listener(const ma_engine* pEngine, float MA_API void ma_engine_listener_set_position(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return; } @@ -78100,7 +78100,7 @@ MA_API void ma_engine_listener_set_position(ma_engine* pEngine, ma_uint32 listen MA_API ma_vec3f ma_engine_listener_get_position(const ma_engine* pEngine, ma_uint32 listenerIndex) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return ma_vec3f_init_3f(0, 0, 0); } @@ -78109,7 +78109,7 @@ MA_API ma_vec3f ma_engine_listener_get_position(const ma_engine* pEngine, ma_uin MA_API void ma_engine_listener_set_direction(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return; } @@ -78118,7 +78118,7 @@ MA_API void ma_engine_listener_set_direction(ma_engine* pEngine, ma_uint32 liste MA_API ma_vec3f ma_engine_listener_get_direction(const ma_engine* pEngine, ma_uint32 listenerIndex) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return ma_vec3f_init_3f(0, 0, -1); } @@ -78127,7 +78127,7 @@ MA_API ma_vec3f ma_engine_listener_get_direction(const ma_engine* pEngine, ma_ui MA_API void ma_engine_listener_set_velocity(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return; } @@ -78136,7 +78136,7 @@ MA_API void ma_engine_listener_set_velocity(ma_engine* pEngine, ma_uint32 listen MA_API ma_vec3f ma_engine_listener_get_velocity(const ma_engine* pEngine, ma_uint32 listenerIndex) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return ma_vec3f_init_3f(0, 0, 0); } @@ -78145,7 +78145,7 @@ MA_API ma_vec3f ma_engine_listener_get_velocity(const ma_engine* pEngine, ma_uin MA_API void ma_engine_listener_set_cone(ma_engine* pEngine, ma_uint32 listenerIndex, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return; } @@ -78154,19 +78154,19 @@ MA_API void ma_engine_listener_set_cone(ma_engine* pEngine, ma_uint32 listenerIn MA_API void ma_engine_listener_get_cone(const ma_engine* pEngine, ma_uint32 listenerIndex, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { - if (pInnerAngleInRadians != NULL) { + if (pInnerAngleInRadians != nullptr) { *pInnerAngleInRadians = 0; } - if (pOuterAngleInRadians != NULL) { + if (pOuterAngleInRadians != nullptr) { *pOuterAngleInRadians = 0; } - if (pOuterGain != NULL) { + if (pOuterGain != nullptr) { *pOuterGain = 0; } - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return; } @@ -78175,7 +78175,7 @@ MA_API void ma_engine_listener_get_cone(const ma_engine* pEngine, ma_uint32 list MA_API void ma_engine_listener_set_world_up(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return; } @@ -78184,7 +78184,7 @@ MA_API void ma_engine_listener_set_world_up(ma_engine* pEngine, ma_uint32 listen MA_API ma_vec3f ma_engine_listener_get_world_up(const ma_engine* pEngine, ma_uint32 listenerIndex) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return ma_vec3f_init_3f(0, 1, 0); } @@ -78193,7 +78193,7 @@ MA_API ma_vec3f ma_engine_listener_get_world_up(const ma_engine* pEngine, ma_uin MA_API void ma_engine_listener_set_enabled(ma_engine* pEngine, ma_uint32 listenerIndex, ma_bool32 isEnabled) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return; } @@ -78202,7 +78202,7 @@ MA_API void ma_engine_listener_set_enabled(ma_engine* pEngine, ma_uint32 listene MA_API ma_bool32 ma_engine_listener_is_enabled(const ma_engine* pEngine, ma_uint32 listenerIndex) { - if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { + if (pEngine == nullptr || listenerIndex >= pEngine->listenerCount) { return MA_FALSE; } @@ -78214,15 +78214,15 @@ MA_API ma_bool32 ma_engine_listener_is_enabled(const ma_engine* pEngine, ma_uint MA_API ma_result ma_engine_play_sound_ex(ma_engine* pEngine, const char* pFilePath, ma_node* pNode, ma_uint32 nodeInputBusIndex) { ma_result result = MA_SUCCESS; - ma_sound_inlined* pSound = NULL; - ma_sound_inlined* pNextSound = NULL; + ma_sound_inlined* pSound = nullptr; + ma_sound_inlined* pNextSound = nullptr; - if (pEngine == NULL || pFilePath == NULL) { + if (pEngine == nullptr || pFilePath == nullptr) { return MA_INVALID_ARGS; } /* Attach to the endpoint node if nothing is specified. */ - if (pNode == NULL) { + if (pNode == nullptr) { pNode = ma_node_graph_get_endpoint(&pEngine->nodeGraph); nodeInputBusIndex = 0; } @@ -78243,7 +78243,7 @@ MA_API ma_result ma_engine_play_sound_ex(ma_engine* pEngine, const char* pFilePa { ma_uint32 soundFlags = 0; - for (pNextSound = pEngine->pInlinedSoundHead; pNextSound != NULL; pNextSound = pNextSound->pNext) { + for (pNextSound = pEngine->pInlinedSoundHead; pNextSound != nullptr; pNextSound = pNextSound->pNext) { if (ma_sound_at_end(&pNextSound->sound)) { /* The sound is at the end which means it's available for recycling. All we need to do @@ -78255,7 +78255,7 @@ MA_API ma_result ma_engine_play_sound_ex(ma_engine* pEngine, const char* pFilePa } } - if (pSound != NULL) { + if (pSound != nullptr) { /* We actually want to detach the sound from the list here. The reason is because we want the sound to be in a consistent state at the non-recycled case to simplify the logic below. @@ -78264,10 +78264,10 @@ MA_API ma_result ma_engine_play_sound_ex(ma_engine* pEngine, const char* pFilePa pEngine->pInlinedSoundHead = pSound->pNext; } - if (pSound->pPrev != NULL) { + if (pSound->pPrev != nullptr) { pSound->pPrev->pNext = pSound->pNext; } - if (pSound->pNext != NULL) { + if (pSound->pNext != nullptr) { pSound->pNext->pPrev = pSound->pPrev; } @@ -78278,7 +78278,7 @@ MA_API ma_result ma_engine_play_sound_ex(ma_engine* pEngine, const char* pFilePa pSound = (ma_sound_inlined*)ma_malloc(sizeof(*pSound), &pEngine->allocationCallbacks); } - if (pSound != NULL) { /* Safety check for the allocation above. */ + if (pSound != nullptr) { /* Safety check for the allocation above. */ /* At this point we should have memory allocated for the inlined sound. We just need to initialize it like a normal sound now. @@ -78288,17 +78288,17 @@ MA_API ma_result ma_engine_play_sound_ex(ma_engine* pEngine, const char* pFilePa soundFlags |= MA_SOUND_FLAG_NO_PITCH; /* Pitching isn't usable with inlined sounds, so disable it to save on speed. */ soundFlags |= MA_SOUND_FLAG_NO_SPATIALIZATION; /* Not currently doing spatialization with inlined sounds, but this might actually change later. For now disable spatialization. Will be removed if we ever add support for spatialization here. */ - result = ma_sound_init_from_file(pEngine, pFilePath, soundFlags, NULL, NULL, &pSound->sound); + result = ma_sound_init_from_file(pEngine, pFilePath, soundFlags, nullptr, nullptr, &pSound->sound); if (result == MA_SUCCESS) { /* Now attach the sound to the graph. */ result = ma_node_attach_output_bus(pSound, 0, pNode, nodeInputBusIndex); if (result == MA_SUCCESS) { /* At this point the sound should be loaded and we can go ahead and add it to the list. The new item becomes the new head. */ pSound->pNext = pEngine->pInlinedSoundHead; - pSound->pPrev = NULL; + pSound->pPrev = nullptr; pEngine->pInlinedSoundHead = pSound; /* <-- This is what attaches the sound to the list. */ - if (pSound->pNext != NULL) { + if (pSound->pNext != nullptr) { pSound->pNext->pPrev = pSound; } } else { @@ -78338,14 +78338,14 @@ MA_API ma_result ma_engine_play_sound(ma_engine* pEngine, const char* pFilePath, static ma_result ma_sound_preinit(ma_engine* pEngine, ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pSound); pSound->seekTarget = MA_SEEK_TARGET_NONE; - if (pEngine == NULL) { + if (pEngine == nullptr) { return MA_INVALID_ARGS; } @@ -78359,16 +78359,16 @@ static ma_result ma_sound_init_from_data_source_internal(ma_engine* pEngine, con ma_engine_node_type type; /* Will be set to ma_engine_node_type_group if no data source is specified. */ /* Do not clear pSound to zero here - that's done at a higher level with ma_sound_preinit(). */ - MA_ASSERT(pEngine != NULL); - MA_ASSERT(pSound != NULL); + MA_ASSERT(pEngine != nullptr); + MA_ASSERT(pSound != nullptr); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } pSound->pDataSource = pConfig->pDataSource; - if (pConfig->pDataSource != NULL) { + if (pConfig->pDataSource != nullptr) { type = ma_engine_node_type_sound; } else { type = ma_engine_node_type_group; @@ -78390,8 +78390,8 @@ static ma_result ma_sound_init_from_data_source_internal(ma_engine* pEngine, con } /* If we're loading from a data source the input channel count needs to be the data source's native channel count. */ - if (pConfig->pDataSource != NULL) { - result = ma_data_source_get_data_format(pConfig->pDataSource, NULL, &engineNodeConfig.channelsIn, &engineNodeConfig.sampleRate, NULL, 0); + if (pConfig->pDataSource != nullptr) { + result = ma_data_source_get_data_format(pConfig->pDataSource, nullptr, &engineNodeConfig.channelsIn, &engineNodeConfig.sampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the channel count. */ } @@ -78413,7 +78413,7 @@ static ma_result ma_sound_init_from_data_source_internal(ma_engine* pEngine, con } /* If no attachment is specified, attach the sound straight to the endpoint. */ - if (pConfig->pInitialAttachment == NULL) { + if (pConfig->pInitialAttachment == nullptr) { /* No group. Attach straight to the endpoint by default, unless the caller has requested that it not. */ if ((pConfig->flags & MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT) == 0) { result = ma_node_attach_output_bus(pSound, 0, ma_node_graph_get_endpoint(&pEngine->nodeGraph), 0); @@ -78433,7 +78433,7 @@ static ma_result ma_sound_init_from_data_source_internal(ma_engine* pEngine, con When pulling data from a data source we need a processing cache to hold onto unprocessed input data from the data source after doing resampling. */ - if (pSound->pDataSource != NULL) { + if (pSound->pDataSource != nullptr) { pSound->processingCacheFramesRemaining = 0; pSound->processingCacheCap = ma_node_graph_get_processing_size_in_frames(&pEngine->nodeGraph); if (pSound->processingCacheCap == 0) { @@ -78441,7 +78441,7 @@ static ma_result ma_sound_init_from_data_source_internal(ma_engine* pEngine, con } pSound->pProcessingCache = (float*)ma_calloc(pSound->processingCacheCap * ma_get_bytes_per_frame(ma_format_f32, engineNodeConfig.channelsIn), &pEngine->allocationCallbacks); - if (pSound->pProcessingCache == NULL) { + if (pSound->pProcessingCache == nullptr) { ma_engine_node_uninit(&pSound->engineNode, &pEngine->allocationCallbacks); return MA_OUT_OF_MEMORY; } @@ -78486,13 +78486,13 @@ MA_API ma_result ma_sound_init_from_file_internal(ma_engine* pEngine, const ma_s } pSound->pResourceManagerDataSource = (ma_resource_manager_data_source*)ma_malloc(sizeof(*pSound->pResourceManagerDataSource), &pEngine->allocationCallbacks); - if (pSound->pResourceManagerDataSource == NULL) { + if (pSound->pResourceManagerDataSource == nullptr) { return MA_OUT_OF_MEMORY; } /* Removed in 0.12. Set pDoneFence on the notifications. */ notifications = pConfig->initNotifications; - if (pConfig->pDoneFence != NULL && notifications.done.pFence == NULL) { + if (pConfig->pDoneFence != nullptr && notifications.done.pFence == nullptr) { notifications.done.pFence = pConfig->pDoneFence; } @@ -78524,8 +78524,8 @@ MA_API ma_result ma_sound_init_from_file_internal(ma_engine* pEngine, const ma_s /* We need to use a slightly customized version of the config so we'll need to make a copy. */ config = *pConfig; - config.pFilePath = NULL; - config.pFilePathW = NULL; + config.pFilePath = nullptr; + config.pFilePathW = nullptr; config.pDataSource = pSound->pResourceManagerDataSource; result = ma_sound_init_from_data_source_internal(pEngine, &config, pSound); @@ -78545,7 +78545,7 @@ MA_API ma_result ma_sound_init_from_file(ma_engine* pEngine, const char* pFilePa { ma_sound_config config; - if (pFilePath == NULL) { + if (pFilePath == nullptr) { return MA_INVALID_ARGS; } @@ -78562,7 +78562,7 @@ MA_API ma_result ma_sound_init_from_file_w(ma_engine* pEngine, const wchar_t* pF { ma_sound_config config; - if (pFilePath == NULL) { + if (pFilePath == nullptr) { return MA_INVALID_ARGS; } @@ -78585,12 +78585,12 @@ MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistin return result; } - if (pExistingSound == NULL) { + if (pExistingSound == nullptr) { return MA_INVALID_ARGS; } /* Cloning only works for data buffers (not streams) that are loaded from the resource manager. */ - if (pExistingSound->pResourceManagerDataSource == NULL) { + if (pExistingSound->pResourceManagerDataSource == nullptr) { return MA_INVALID_OPERATION; } @@ -78599,7 +78599,7 @@ MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistin this will fail. */ pSound->pResourceManagerDataSource = (ma_resource_manager_data_source*)ma_malloc(sizeof(*pSound->pResourceManagerDataSource), &pEngine->allocationCallbacks); - if (pSound->pResourceManagerDataSource == NULL) { + if (pSound->pResourceManagerDataSource == nullptr) { return MA_OUT_OF_MEMORY; } @@ -78649,7 +78649,7 @@ MA_API ma_result ma_sound_init_ex(ma_engine* pEngine, const ma_sound_config* pCo return result; } - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } @@ -78658,7 +78658,7 @@ MA_API ma_result ma_sound_init_ex(ma_engine* pEngine, const ma_sound_config* pCo /* We need to load the sound differently depending on whether or not we're loading from a file. */ #ifndef MA_NO_RESOURCE_MANAGER - if (pConfig->pFilePath != NULL || pConfig->pFilePathW != NULL) { + if (pConfig->pFilePath != nullptr || pConfig->pFilePathW != nullptr) { return ma_sound_init_from_file_internal(pEngine, pConfig, pSound); } else #endif @@ -78675,7 +78675,7 @@ MA_API ma_result ma_sound_init_ex(ma_engine* pEngine, const ma_sound_config* pCo MA_API void ma_sound_uninit(ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -78685,9 +78685,9 @@ MA_API void ma_sound_uninit(ma_sound* pSound) */ ma_engine_node_uninit(&pSound->engineNode, &pSound->engineNode.pEngine->allocationCallbacks); - if (pSound->pProcessingCache != NULL) { + if (pSound->pProcessingCache != nullptr) { ma_free(pSound->pProcessingCache, &pSound->engineNode.pEngine->allocationCallbacks); - pSound->pProcessingCache = NULL; + pSound->pProcessingCache = nullptr; } /* Once the sound is detached from the group we can guarantee that it won't be referenced by the mixer thread which means it's safe for us to destroy the data source. */ @@ -78695,7 +78695,7 @@ MA_API void ma_sound_uninit(ma_sound* pSound) if (pSound->ownsDataSource) { ma_resource_manager_data_source_uninit(pSound->pResourceManagerDataSource); ma_free(pSound->pResourceManagerDataSource, &pSound->engineNode.pEngine->allocationCallbacks); - pSound->pDataSource = NULL; + pSound->pDataSource = nullptr; } #else MA_ASSERT(pSound->ownsDataSource == MA_FALSE); @@ -78704,8 +78704,8 @@ MA_API void ma_sound_uninit(ma_sound* pSound) MA_API ma_engine* ma_sound_get_engine(const ma_sound* pSound) { - if (pSound == NULL) { - return NULL; + if (pSound == nullptr) { + return nullptr; } return pSound->engineNode.pEngine; @@ -78713,8 +78713,8 @@ MA_API ma_engine* ma_sound_get_engine(const ma_sound* pSound) MA_API ma_data_source* ma_sound_get_data_source(const ma_sound* pSound) { - if (pSound == NULL) { - return NULL; + if (pSound == nullptr) { + return nullptr; } return pSound->pDataSource; @@ -78722,7 +78722,7 @@ MA_API ma_data_source* ma_sound_get_data_source(const ma_sound* pSound) MA_API ma_result ma_sound_start(ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } @@ -78750,7 +78750,7 @@ MA_API ma_result ma_sound_start(ma_sound* pSound) MA_API ma_result ma_sound_stop(ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } @@ -78762,7 +78762,7 @@ MA_API ma_result ma_sound_stop(ma_sound* pSound) MA_API ma_result ma_sound_stop_with_fade_in_pcm_frames(ma_sound* pSound, ma_uint64 fadeLengthInFrames) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } @@ -78776,7 +78776,7 @@ MA_API ma_result ma_sound_stop_with_fade_in_milliseconds(ma_sound* pSound, ma_ui { ma_uint64 sampleRate; - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } @@ -78808,7 +78808,7 @@ MA_API void ma_sound_reset_stop_time_and_fade(ma_sound* pSound) MA_API void ma_sound_set_volume(ma_sound* pSound, float volume) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -78819,7 +78819,7 @@ MA_API float ma_sound_get_volume(const ma_sound* pSound) { float volume = 0; - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -78830,7 +78830,7 @@ MA_API float ma_sound_get_volume(const ma_sound* pSound) MA_API void ma_sound_set_pan(ma_sound* pSound, float pan) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -78839,7 +78839,7 @@ MA_API void ma_sound_set_pan(ma_sound* pSound, float pan) MA_API float ma_sound_get_pan(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -78848,7 +78848,7 @@ MA_API float ma_sound_get_pan(const ma_sound* pSound) MA_API void ma_sound_set_pan_mode(ma_sound* pSound, ma_pan_mode panMode) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -78857,7 +78857,7 @@ MA_API void ma_sound_set_pan_mode(ma_sound* pSound, ma_pan_mode panMode) MA_API ma_pan_mode ma_sound_get_pan_mode(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return ma_pan_mode_balance; } @@ -78866,7 +78866,7 @@ MA_API ma_pan_mode ma_sound_get_pan_mode(const ma_sound* pSound) MA_API void ma_sound_set_pitch(ma_sound* pSound, float pitch) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -78879,7 +78879,7 @@ MA_API void ma_sound_set_pitch(ma_sound* pSound, float pitch) MA_API float ma_sound_get_pitch(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -78888,7 +78888,7 @@ MA_API float ma_sound_get_pitch(const ma_sound* pSound) MA_API void ma_sound_set_spatialization_enabled(ma_sound* pSound, ma_bool32 enabled) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -78897,7 +78897,7 @@ MA_API void ma_sound_set_spatialization_enabled(ma_sound* pSound, ma_bool32 enab MA_API ma_bool32 ma_sound_is_spatialization_enabled(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_FALSE; } @@ -78906,7 +78906,7 @@ MA_API ma_bool32 ma_sound_is_spatialization_enabled(const ma_sound* pSound) MA_API void ma_sound_set_pinned_listener_index(ma_sound* pSound, ma_uint32 listenerIndex) { - if (pSound == NULL || listenerIndex >= ma_engine_get_listener_count(ma_sound_get_engine(pSound))) { + if (pSound == nullptr || listenerIndex >= ma_engine_get_listener_count(ma_sound_get_engine(pSound))) { return; } @@ -78915,7 +78915,7 @@ MA_API void ma_sound_set_pinned_listener_index(ma_sound* pSound, ma_uint32 liste MA_API ma_uint32 ma_sound_get_pinned_listener_index(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_LISTENER_INDEX_CLOSEST; } @@ -78926,7 +78926,7 @@ MA_API ma_uint32 ma_sound_get_listener_index(const ma_sound* pSound) { ma_uint32 listenerIndex; - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -78944,23 +78944,23 @@ MA_API ma_vec3f ma_sound_get_direction_to_listener(const ma_sound* pSound) ma_vec3f relativePos; ma_engine* pEngine; - if (pSound == NULL) { + if (pSound == nullptr) { return ma_vec3f_init_3f(0, 0, -1); } pEngine = ma_sound_get_engine(pSound); - if (pEngine == NULL) { + if (pEngine == nullptr) { return ma_vec3f_init_3f(0, 0, -1); } - ma_spatializer_get_relative_position_and_direction(&pSound->engineNode.spatializer, &pEngine->listeners[ma_sound_get_listener_index(pSound)], &relativePos, NULL); + ma_spatializer_get_relative_position_and_direction(&pSound->engineNode.spatializer, &pEngine->listeners[ma_sound_get_listener_index(pSound)], &relativePos, nullptr); return ma_vec3f_normalize(ma_vec3f_neg(relativePos)); } MA_API void ma_sound_set_position(ma_sound* pSound, float x, float y, float z) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -78969,7 +78969,7 @@ MA_API void ma_sound_set_position(ma_sound* pSound, float x, float y, float z) MA_API ma_vec3f ma_sound_get_position(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return ma_vec3f_init_3f(0, 0, 0); } @@ -78978,7 +78978,7 @@ MA_API ma_vec3f ma_sound_get_position(const ma_sound* pSound) MA_API void ma_sound_set_direction(ma_sound* pSound, float x, float y, float z) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -78987,7 +78987,7 @@ MA_API void ma_sound_set_direction(ma_sound* pSound, float x, float y, float z) MA_API ma_vec3f ma_sound_get_direction(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return ma_vec3f_init_3f(0, 0, 0); } @@ -78996,7 +78996,7 @@ MA_API ma_vec3f ma_sound_get_direction(const ma_sound* pSound) MA_API void ma_sound_set_velocity(ma_sound* pSound, float x, float y, float z) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79005,7 +79005,7 @@ MA_API void ma_sound_set_velocity(ma_sound* pSound, float x, float y, float z) MA_API ma_vec3f ma_sound_get_velocity(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return ma_vec3f_init_3f(0, 0, 0); } @@ -79014,7 +79014,7 @@ MA_API ma_vec3f ma_sound_get_velocity(const ma_sound* pSound) MA_API void ma_sound_set_attenuation_model(ma_sound* pSound, ma_attenuation_model attenuationModel) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79023,7 +79023,7 @@ MA_API void ma_sound_set_attenuation_model(ma_sound* pSound, ma_attenuation_mode MA_API ma_attenuation_model ma_sound_get_attenuation_model(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return ma_attenuation_model_none; } @@ -79032,7 +79032,7 @@ MA_API ma_attenuation_model ma_sound_get_attenuation_model(const ma_sound* pSoun MA_API void ma_sound_set_positioning(ma_sound* pSound, ma_positioning positioning) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79041,7 +79041,7 @@ MA_API void ma_sound_set_positioning(ma_sound* pSound, ma_positioning positionin MA_API ma_positioning ma_sound_get_positioning(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return ma_positioning_absolute; } @@ -79050,7 +79050,7 @@ MA_API ma_positioning ma_sound_get_positioning(const ma_sound* pSound) MA_API void ma_sound_set_rolloff(ma_sound* pSound, float rolloff) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79059,7 +79059,7 @@ MA_API void ma_sound_set_rolloff(ma_sound* pSound, float rolloff) MA_API float ma_sound_get_rolloff(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -79068,7 +79068,7 @@ MA_API float ma_sound_get_rolloff(const ma_sound* pSound) MA_API void ma_sound_set_min_gain(ma_sound* pSound, float minGain) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79077,7 +79077,7 @@ MA_API void ma_sound_set_min_gain(ma_sound* pSound, float minGain) MA_API float ma_sound_get_min_gain(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -79086,7 +79086,7 @@ MA_API float ma_sound_get_min_gain(const ma_sound* pSound) MA_API void ma_sound_set_max_gain(ma_sound* pSound, float maxGain) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79095,7 +79095,7 @@ MA_API void ma_sound_set_max_gain(ma_sound* pSound, float maxGain) MA_API float ma_sound_get_max_gain(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -79104,7 +79104,7 @@ MA_API float ma_sound_get_max_gain(const ma_sound* pSound) MA_API void ma_sound_set_min_distance(ma_sound* pSound, float minDistance) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79113,7 +79113,7 @@ MA_API void ma_sound_set_min_distance(ma_sound* pSound, float minDistance) MA_API float ma_sound_get_min_distance(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -79122,7 +79122,7 @@ MA_API float ma_sound_get_min_distance(const ma_sound* pSound) MA_API void ma_sound_set_max_distance(ma_sound* pSound, float maxDistance) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79131,7 +79131,7 @@ MA_API void ma_sound_set_max_distance(ma_sound* pSound, float maxDistance) MA_API float ma_sound_get_max_distance(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -79140,7 +79140,7 @@ MA_API float ma_sound_get_max_distance(const ma_sound* pSound) MA_API void ma_sound_set_cone(ma_sound* pSound, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79149,19 +79149,19 @@ MA_API void ma_sound_set_cone(ma_sound* pSound, float innerAngleInRadians, float MA_API void ma_sound_get_cone(const ma_sound* pSound, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { - if (pInnerAngleInRadians != NULL) { + if (pInnerAngleInRadians != nullptr) { *pInnerAngleInRadians = 0; } - if (pOuterAngleInRadians != NULL) { + if (pOuterAngleInRadians != nullptr) { *pOuterAngleInRadians = 0; } - if (pOuterGain != NULL) { + if (pOuterGain != nullptr) { *pOuterGain = 0; } - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79170,7 +79170,7 @@ MA_API void ma_sound_get_cone(const ma_sound* pSound, float* pInnerAngleInRadian MA_API void ma_sound_set_doppler_factor(ma_sound* pSound, float dopplerFactor) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79179,7 +79179,7 @@ MA_API void ma_sound_set_doppler_factor(ma_sound* pSound, float dopplerFactor) MA_API float ma_sound_get_doppler_factor(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -79188,7 +79188,7 @@ MA_API float ma_sound_get_doppler_factor(const ma_sound* pSound) MA_API void ma_sound_set_directional_attenuation_factor(ma_sound* pSound, float directionalAttenuationFactor) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79197,7 +79197,7 @@ MA_API void ma_sound_set_directional_attenuation_factor(ma_sound* pSound, float MA_API float ma_sound_get_directional_attenuation_factor(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 1; } @@ -79207,7 +79207,7 @@ MA_API float ma_sound_get_directional_attenuation_factor(const ma_sound* pSound) MA_API void ma_sound_set_fade_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79216,7 +79216,7 @@ MA_API void ma_sound_set_fade_in_pcm_frames(ma_sound* pSound, float volumeBeg, f MA_API void ma_sound_set_fade_in_milliseconds(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79225,7 +79225,7 @@ MA_API void ma_sound_set_fade_in_milliseconds(ma_sound* pSound, float volumeBeg, MA_API void ma_sound_set_fade_start_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames, ma_uint64 absoluteGlobalTimeInFrames) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79244,7 +79244,7 @@ MA_API void ma_sound_set_fade_start_in_milliseconds(ma_sound* pSound, float volu { ma_uint32 sampleRate; - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79255,7 +79255,7 @@ MA_API void ma_sound_set_fade_start_in_milliseconds(ma_sound* pSound, float volu MA_API float ma_sound_get_current_fade_volume(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } @@ -79264,7 +79264,7 @@ MA_API float ma_sound_get_current_fade_volume(const ma_sound* pSound) MA_API void ma_sound_set_start_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79273,7 +79273,7 @@ MA_API void ma_sound_set_start_time_in_pcm_frames(ma_sound* pSound, ma_uint64 ab MA_API void ma_sound_set_start_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79282,7 +79282,7 @@ MA_API void ma_sound_set_start_time_in_milliseconds(ma_sound* pSound, ma_uint64 MA_API void ma_sound_set_stop_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79291,7 +79291,7 @@ MA_API void ma_sound_set_stop_time_in_pcm_frames(ma_sound* pSound, ma_uint64 abs MA_API void ma_sound_set_stop_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79300,7 +79300,7 @@ MA_API void ma_sound_set_stop_time_in_milliseconds(ma_sound* pSound, ma_uint64 a MA_API void ma_sound_set_stop_time_with_fade_in_pcm_frames(ma_sound* pSound, ma_uint64 stopAbsoluteGlobalTimeInFrames, ma_uint64 fadeLengthInFrames) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79319,7 +79319,7 @@ MA_API void ma_sound_set_stop_time_with_fade_in_milliseconds(ma_sound* pSound, m { ma_uint32 sampleRate; - if (pSound == NULL) { + if (pSound == nullptr) { return; } @@ -79330,7 +79330,7 @@ MA_API void ma_sound_set_stop_time_with_fade_in_milliseconds(ma_sound* pSound, m MA_API ma_bool32 ma_sound_is_playing(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_FALSE; } @@ -79339,7 +79339,7 @@ MA_API ma_bool32 ma_sound_is_playing(const ma_sound* pSound) MA_API ma_uint64 ma_sound_get_time_in_pcm_frames(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return 0; } @@ -79358,12 +79358,12 @@ MA_API ma_uint64 ma_sound_get_time_in_milliseconds(const ma_sound* pSound) MA_API void ma_sound_set_looping(ma_sound* pSound, ma_bool32 isLooping) { - if (pSound == NULL) { + if (pSound == nullptr) { return; } /* Looping is only a valid concept if the sound is backed by a data source. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { return; } @@ -79373,12 +79373,12 @@ MA_API void ma_sound_set_looping(ma_sound* pSound, ma_bool32 isLooping) MA_API ma_bool32 ma_sound_is_looping(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_FALSE; } /* There is no notion of looping for sounds that are not backed by a data source. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { return MA_FALSE; } @@ -79387,12 +79387,12 @@ MA_API ma_bool32 ma_sound_is_looping(const ma_sound* pSound) MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_FALSE; } /* There is no notion of an end of a sound if it's not backed by a data source. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { return MA_FALSE; } @@ -79401,12 +79401,12 @@ MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound) MA_API ma_result ma_sound_seek_to_pcm_frame(ma_sound* pSound, ma_uint64 frameIndex) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } /* Seeking is only valid for sounds that are backed by a data source. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { return MA_INVALID_OPERATION; } @@ -79422,11 +79422,11 @@ MA_API ma_result ma_sound_seek_to_second(ma_sound* pSound, float seekPointInSeco ma_uint32 sampleRate; ma_result result; - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } - result = ma_sound_get_data_format(pSound, NULL, NULL, &sampleRate, NULL, 0); + result = ma_sound_get_data_format(pSound, nullptr, nullptr, &sampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; } @@ -79439,28 +79439,28 @@ MA_API ma_result ma_sound_seek_to_second(ma_sound* pSound, float seekPointInSeco MA_API ma_result ma_sound_get_data_format(const ma_sound* pSound, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } /* The data format is retrieved directly from the data source if the sound is backed by one. Otherwise we pull it from the node. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { ma_uint32 channels; - if (pFormat != NULL) { + if (pFormat != nullptr) { *pFormat = ma_format_f32; } channels = ma_node_get_input_channels(&pSound->engineNode, 0); - if (pChannels != NULL) { + if (pChannels != nullptr) { *pChannels = channels; } - if (pSampleRate != NULL) { + if (pSampleRate != nullptr) { *pSampleRate = pSound->engineNode.resampler.sampleRateIn; } - if (pChannelMap != NULL) { + if (pChannelMap != nullptr) { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, channels); } @@ -79474,12 +79474,12 @@ MA_API ma_result ma_sound_get_cursor_in_pcm_frames(const ma_sound* pSound, ma_ui { ma_uint64 seekTarget; - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } /* The notion of a cursor is only valid for sounds that are backed by a data source. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { return MA_INVALID_OPERATION; } @@ -79494,12 +79494,12 @@ MA_API ma_result ma_sound_get_cursor_in_pcm_frames(const ma_sound* pSound, ma_ui MA_API ma_result ma_sound_get_length_in_pcm_frames(const ma_sound* pSound, ma_uint64* pLength) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } /* The notion of a sound length is only valid for sounds that are backed by a data source. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { return MA_INVALID_OPERATION; } @@ -79512,7 +79512,7 @@ MA_API ma_result ma_sound_get_cursor_in_seconds(const ma_sound* pSound, float* p ma_uint64 cursorInPCMFrames; ma_uint32 sampleRate; - if (pCursor != NULL) { + if (pCursor != nullptr) { *pCursor = 0; } @@ -79521,7 +79521,7 @@ MA_API ma_result ma_sound_get_cursor_in_seconds(const ma_sound* pSound, float* p return result; } - result = ma_sound_get_data_format(pSound, NULL, NULL, &sampleRate, NULL, 0); + result = ma_sound_get_data_format(pSound, nullptr, nullptr, &sampleRate, nullptr, 0); if (result != MA_SUCCESS) { return result; } @@ -79534,12 +79534,12 @@ MA_API ma_result ma_sound_get_cursor_in_seconds(const ma_sound* pSound, float* p MA_API ma_result ma_sound_get_length_in_seconds(const ma_sound* pSound, float* pLength) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } /* The notion of a sound length is only valid for sounds that are backed by a data source. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { return MA_INVALID_OPERATION; } @@ -79548,12 +79548,12 @@ MA_API ma_result ma_sound_get_length_in_seconds(const ma_sound* pSound, float* p MA_API ma_result ma_sound_set_end_callback(ma_sound* pSound, ma_sound_end_proc callback, void* pUserData) { - if (pSound == NULL) { + if (pSound == nullptr) { return MA_INVALID_ARGS; } /* The notion of an end is only valid for sounds that are backed by a data source. */ - if (pSound->pDataSource == NULL) { + if (pSound->pDataSource == nullptr) { return MA_INVALID_OPERATION; } @@ -79576,21 +79576,21 @@ MA_API ma_result ma_sound_group_init_ex(ma_engine* pEngine, const ma_sound_group { ma_sound_config soundConfig; - if (pGroup == NULL) { + if (pGroup == nullptr) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pGroup); - if (pConfig == NULL) { + if (pConfig == nullptr) { return MA_INVALID_ARGS; } /* A sound group is just a sound without a data source. */ soundConfig = *pConfig; - soundConfig.pFilePath = NULL; - soundConfig.pFilePathW = NULL; - soundConfig.pDataSource = NULL; + soundConfig.pFilePath = nullptr; + soundConfig.pFilePathW = nullptr; + soundConfig.pDataSource = nullptr; /* Groups need to have spatialization disabled by default because I think it'll be pretty rare @@ -80245,55 +80245,55 @@ MA_PRIVATE void ma_dr_wav__free_default(void* p, void* pUserData) } MA_PRIVATE void* ma_dr_wav__malloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks == NULL) { - return NULL; + if (pAllocationCallbacks == nullptr) { + return nullptr; } - if (pAllocationCallbacks->onMalloc != NULL) { + if (pAllocationCallbacks->onMalloc != nullptr) { return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData); } - if (pAllocationCallbacks->onRealloc != NULL) { - return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData); + if (pAllocationCallbacks->onRealloc != nullptr) { + return pAllocationCallbacks->onRealloc(nullptr, sz, pAllocationCallbacks->pUserData); } - return NULL; + return nullptr; } MA_PRIVATE void* ma_dr_wav__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks == NULL) { - return NULL; + if (pAllocationCallbacks == nullptr) { + return nullptr; } - if (pAllocationCallbacks->onRealloc != NULL) { + if (pAllocationCallbacks->onRealloc != nullptr) { return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData); } - if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) { + if (pAllocationCallbacks->onMalloc != nullptr && pAllocationCallbacks->onFree != nullptr) { void* p2; p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData); - if (p2 == NULL) { - return NULL; + if (p2 == nullptr) { + return nullptr; } - if (p != NULL) { + if (p != nullptr) { MA_DR_WAV_COPY_MEMORY(p2, p, szOld); pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } return p2; } - return NULL; + return nullptr; } MA_PRIVATE void ma_dr_wav__free_from_callbacks(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { - if (p == NULL || pAllocationCallbacks == NULL) { + if (p == nullptr || pAllocationCallbacks == nullptr) { return; } - if (pAllocationCallbacks->onFree != NULL) { + if (pAllocationCallbacks->onFree != nullptr) { pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } } MA_PRIVATE ma_allocation_callbacks ma_dr_wav_copy_allocation_callbacks_or_defaults(const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks != NULL) { + if (pAllocationCallbacks != nullptr) { return *pAllocationCallbacks; } else { ma_allocation_callbacks allocationCallbacks; - allocationCallbacks.pUserData = NULL; + allocationCallbacks.pUserData = nullptr; allocationCallbacks.onMalloc = ma_dr_wav__malloc_default; allocationCallbacks.onRealloc = ma_dr_wav__realloc_default; allocationCallbacks.onFree = ma_dr_wav__free_default; @@ -80386,8 +80386,8 @@ MA_PRIVATE ma_bool32 ma_dr_wav__seek_from_start(ma_dr_wav_seek_proc onSeek, ma_u MA_PRIVATE size_t ma_dr_wav__on_read(ma_dr_wav_read_proc onRead, void* pUserData, void* pBufferOut, size_t bytesToRead, ma_uint64* pCursor) { size_t bytesRead; - MA_DR_WAV_ASSERT(onRead != NULL); - MA_DR_WAV_ASSERT(pCursor != NULL); + MA_DR_WAV_ASSERT(onRead != nullptr); + MA_DR_WAV_ASSERT(pCursor != nullptr); bytesRead = onRead(pUserData, pBufferOut, bytesToRead); *pCursor += bytesRead; return bytesRead; @@ -80395,8 +80395,8 @@ MA_PRIVATE size_t ma_dr_wav__on_read(ma_dr_wav_read_proc onRead, void* pUserData #if 0 MA_PRIVATE ma_bool32 ma_dr_wav__on_seek(ma_dr_wav_seek_proc onSeek, void* pUserData, int offset, ma_dr_wav_seek_origin origin, ma_uint64* pCursor) { - MA_DR_WAV_ASSERT(onSeek != NULL); - MA_DR_WAV_ASSERT(pCursor != NULL); + MA_DR_WAV_ASSERT(onSeek != nullptr); + MA_DR_WAV_ASSERT(pCursor != nullptr); if (!onSeek(pUserData, offset, origin)) { return MA_FALSE; } @@ -80474,7 +80474,7 @@ MA_PRIVATE ma_result ma_dr_wav__metadata_alloc(ma_dr_wav__metadata_parser* pPars pAllocationCallbacks->onFree(pParser->pData, pAllocationCallbacks->pUserData); pParser->pData = (ma_uint8*)pAllocationCallbacks->onMalloc(ma_dr_wav__metadata_memory_capacity(pParser), pAllocationCallbacks->pUserData); pParser->pDataCursor = pParser->pData; - if (pParser->pData == NULL) { + if (pParser->pData == nullptr) { return MA_OUT_OF_MEMORY; } pParser->pMetadata = (ma_dr_wav_metadata*)ma_dr_wav__metadata_get_memory(pParser, sizeof(ma_dr_wav_metadata) * pParser->metadataCount, 1); @@ -80484,7 +80484,7 @@ MA_PRIVATE ma_result ma_dr_wav__metadata_alloc(ma_dr_wav__metadata_parser* pPars } MA_PRIVATE size_t ma_dr_wav__metadata_parser_read(ma_dr_wav__metadata_parser* pParser, void* pBufferOut, size_t bytesToRead, ma_uint64* pCursor) { - if (pCursor != NULL) { + if (pCursor != nullptr) { return ma_dr_wav__on_read(pParser->onRead, pParser->pReadSeekUserData, pBufferOut, bytesToRead, pCursor); } else { return pParser->onRead(pParser->pReadSeekUserData, pBufferOut, bytesToRead); @@ -80495,13 +80495,13 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_smpl_to_metadata_obj(ma_dr_wav__metadata_pa ma_uint8 smplHeaderData[MA_DR_WAV_SMPL_BYTES]; ma_uint64 totalBytesRead = 0; size_t bytesJustRead; - if (pMetadata == NULL) { + if (pMetadata == nullptr) { return 0; } bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, smplHeaderData, sizeof(smplHeaderData), &totalBytesRead); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); - MA_DR_WAV_ASSERT(pChunkHeader != NULL); - if (pMetadata != NULL && bytesJustRead == sizeof(smplHeaderData)) { + MA_DR_WAV_ASSERT(pChunkHeader != nullptr); + if (pMetadata != nullptr && bytesJustRead == sizeof(smplHeaderData)) { ma_uint32 iSampleLoop; pMetadata->type = ma_dr_wav_metadata_type_smpl; pMetadata->data.smpl.manufacturerId = ma_dr_wav_bytes_to_u32(smplHeaderData + 0); @@ -80531,7 +80531,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_smpl_to_metadata_obj(ma_dr_wav__metadata_pa } if (pMetadata->data.smpl.samplerSpecificDataSizeInBytes > 0) { pMetadata->data.smpl.pSamplerSpecificData = ma_dr_wav__metadata_get_memory(pParser, pMetadata->data.smpl.samplerSpecificDataSizeInBytes, 1); - MA_DR_WAV_ASSERT(pMetadata->data.smpl.pSamplerSpecificData != NULL); + MA_DR_WAV_ASSERT(pMetadata->data.smpl.pSamplerSpecificData != nullptr); ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.smpl.pSamplerSpecificData, pMetadata->data.smpl.samplerSpecificDataSizeInBytes, &totalBytesRead); } } @@ -80543,7 +80543,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_cue_to_metadata_obj(ma_dr_wav__metadata_par ma_uint8 cueHeaderSectionData[MA_DR_WAV_CUE_BYTES]; ma_uint64 totalBytesRead = 0; size_t bytesJustRead; - if (pMetadata == NULL) { + if (pMetadata == nullptr) { return 0; } bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, cueHeaderSectionData, sizeof(cueHeaderSectionData), &totalBytesRead); @@ -80553,7 +80553,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_cue_to_metadata_obj(ma_dr_wav__metadata_par pMetadata->data.cue.cuePointCount = ma_dr_wav_bytes_to_u32(cueHeaderSectionData); if (pMetadata->data.cue.cuePointCount == (pChunkHeader->sizeInBytes - MA_DR_WAV_CUE_BYTES) / MA_DR_WAV_CUE_POINT_BYTES) { pMetadata->data.cue.pCuePoints = (ma_dr_wav_cue_point*)ma_dr_wav__metadata_get_memory(pParser, sizeof(ma_dr_wav_cue_point) * pMetadata->data.cue.cuePointCount, MA_DR_WAV_METADATA_ALIGNMENT); - MA_DR_WAV_ASSERT(pMetadata->data.cue.pCuePoints != NULL); + MA_DR_WAV_ASSERT(pMetadata->data.cue.pCuePoints != nullptr); if (pMetadata->data.cue.cuePointCount > 0) { ma_uint32 iCuePoint; for (iCuePoint = 0; iCuePoint < pMetadata->data.cue.cuePointCount; ++iCuePoint) { @@ -80582,10 +80582,10 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_inst_to_metadata_obj(ma_dr_wav__metadata_pa { ma_uint8 instData[MA_DR_WAV_INST_BYTES]; ma_uint64 bytesRead; - if (pMetadata == NULL) { + if (pMetadata == nullptr) { return 0; } - bytesRead = ma_dr_wav__metadata_parser_read(pParser, instData, sizeof(instData), NULL); + bytesRead = ma_dr_wav__metadata_parser_read(pParser, instData, sizeof(instData), nullptr); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesRead == sizeof(instData)) { pMetadata->type = ma_dr_wav_metadata_type_inst; @@ -80603,10 +80603,10 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_acid_to_metadata_obj(ma_dr_wav__metadata_pa { ma_uint8 acidData[MA_DR_WAV_ACID_BYTES]; ma_uint64 bytesRead; - if (pMetadata == NULL) { + if (pMetadata == nullptr) { return 0; } - bytesRead = ma_dr_wav__metadata_parser_read(pParser, acidData, sizeof(acidData), NULL); + bytesRead = ma_dr_wav__metadata_parser_read(pParser, acidData, sizeof(acidData), nullptr); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesRead == sizeof(acidData)) { pMetadata->type = ma_dr_wav_metadata_type_acid; @@ -80642,12 +80642,12 @@ MA_PRIVATE char* ma_dr_wav__metadata_copy_string(ma_dr_wav__metadata_parser* pPa size_t len = ma_dr_wav__strlen_clamped(str, maxToRead); if (len) { char* result = (char*)ma_dr_wav__metadata_get_memory(pParser, len + 1, 1); - MA_DR_WAV_ASSERT(result != NULL); + MA_DR_WAV_ASSERT(result != nullptr); MA_DR_WAV_COPY_MEMORY(result, str, len); result[len] = '\0'; return result; } else { - return NULL; + return nullptr; } } typedef struct @@ -80658,8 +80658,8 @@ typedef struct } ma_dr_wav_buffer_reader; MA_PRIVATE ma_result ma_dr_wav_buffer_reader_init(const void* pBuffer, size_t sizeInBytes, ma_dr_wav_buffer_reader* pReader) { - MA_DR_WAV_ASSERT(pBuffer != NULL); - MA_DR_WAV_ASSERT(pReader != NULL); + MA_DR_WAV_ASSERT(pBuffer != nullptr); + MA_DR_WAV_ASSERT(pReader != nullptr); MA_DR_WAV_ZERO_OBJECT(pReader); pReader->pBuffer = pBuffer; pReader->sizeInBytes = sizeInBytes; @@ -80668,12 +80668,12 @@ MA_PRIVATE ma_result ma_dr_wav_buffer_reader_init(const void* pBuffer, size_t si } MA_PRIVATE const void* ma_dr_wav_buffer_reader_ptr(const ma_dr_wav_buffer_reader* pReader) { - MA_DR_WAV_ASSERT(pReader != NULL); + MA_DR_WAV_ASSERT(pReader != nullptr); return ma_dr_wav_offset_ptr(pReader->pBuffer, pReader->cursor); } MA_PRIVATE ma_result ma_dr_wav_buffer_reader_seek(ma_dr_wav_buffer_reader* pReader, size_t bytesToSeek) { - MA_DR_WAV_ASSERT(pReader != NULL); + MA_DR_WAV_ASSERT(pReader != nullptr); if (pReader->cursor + bytesToSeek > pReader->sizeInBytes) { return MA_BAD_SEEK; } @@ -80684,15 +80684,15 @@ MA_PRIVATE ma_result ma_dr_wav_buffer_reader_read(ma_dr_wav_buffer_reader* pRead { ma_result result = MA_SUCCESS; size_t bytesRemaining; - MA_DR_WAV_ASSERT(pReader != NULL); - if (pBytesRead != NULL) { + MA_DR_WAV_ASSERT(pReader != nullptr); + if (pBytesRead != nullptr) { *pBytesRead = 0; } bytesRemaining = (pReader->sizeInBytes - pReader->cursor); if (bytesToRead > bytesRemaining) { bytesToRead = bytesRemaining; } - if (pDst == NULL) { + if (pDst == nullptr) { result = ma_dr_wav_buffer_reader_seek(pReader, bytesToRead); } else { MA_DR_WAV_COPY_MEMORY(pDst, ma_dr_wav_buffer_reader_ptr(pReader), bytesToRead); @@ -80700,7 +80700,7 @@ MA_PRIVATE ma_result ma_dr_wav_buffer_reader_read(ma_dr_wav_buffer_reader* pRead } MA_DR_WAV_ASSERT(pReader->cursor <= pReader->sizeInBytes); if (result == MA_SUCCESS) { - if (pBytesRead != NULL) { + if (pBytesRead != nullptr) { *pBytesRead = bytesToRead; } } @@ -80711,8 +80711,8 @@ MA_PRIVATE ma_result ma_dr_wav_buffer_reader_read_u16(ma_dr_wav_buffer_reader* p ma_result result; size_t bytesRead; ma_uint8 data[2]; - MA_DR_WAV_ASSERT(pReader != NULL); - MA_DR_WAV_ASSERT(pDst != NULL); + MA_DR_WAV_ASSERT(pReader != nullptr); + MA_DR_WAV_ASSERT(pDst != nullptr); *pDst = 0; result = ma_dr_wav_buffer_reader_read(pReader, data, sizeof(*pDst), &bytesRead); if (result != MA_SUCCESS || bytesRead != sizeof(*pDst)) { @@ -80726,8 +80726,8 @@ MA_PRIVATE ma_result ma_dr_wav_buffer_reader_read_u32(ma_dr_wav_buffer_reader* p ma_result result; size_t bytesRead; ma_uint8 data[4]; - MA_DR_WAV_ASSERT(pReader != NULL); - MA_DR_WAV_ASSERT(pDst != NULL); + MA_DR_WAV_ASSERT(pReader != nullptr); + MA_DR_WAV_ASSERT(pDst != nullptr); *pDst = 0; result = ma_dr_wav_buffer_reader_read(pReader, data, sizeof(*pDst), &bytesRead); if (result != MA_SUCCESS || bytesRead != sizeof(*pDst)) { @@ -80739,7 +80739,7 @@ MA_PRIVATE ma_result ma_dr_wav_buffer_reader_read_u32(ma_dr_wav_buffer_reader* p MA_PRIVATE ma_uint64 ma_dr_wav__read_bext_to_metadata_obj(ma_dr_wav__metadata_parser* pParser, ma_dr_wav_metadata* pMetadata, ma_uint64 chunkSize) { ma_uint8 bextData[MA_DR_WAV_BEXT_BYTES]; - size_t bytesRead = ma_dr_wav__metadata_parser_read(pParser, bextData, sizeof(bextData), NULL); + size_t bytesRead = ma_dr_wav__metadata_parser_read(pParser, bextData, sizeof(bextData), nullptr); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesRead == sizeof(bextData)) { ma_dr_wav_buffer_reader reader; @@ -80754,14 +80754,14 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_bext_to_metadata_obj(ma_dr_wav__metadata_pa ma_dr_wav_buffer_reader_seek(&reader, MA_DR_WAV_BEXT_ORIGINATOR_NAME_BYTES); pMetadata->data.bext.pOriginatorReference = ma_dr_wav__metadata_copy_string(pParser, (const char*)ma_dr_wav_buffer_reader_ptr(&reader), MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES); ma_dr_wav_buffer_reader_seek(&reader, MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES); - ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pOriginationDate, sizeof(pMetadata->data.bext.pOriginationDate), NULL); - ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pOriginationTime, sizeof(pMetadata->data.bext.pOriginationTime), NULL); + ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pOriginationDate, sizeof(pMetadata->data.bext.pOriginationDate), nullptr); + ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pOriginationTime, sizeof(pMetadata->data.bext.pOriginationTime), nullptr); ma_dr_wav_buffer_reader_read_u32(&reader, &timeReferenceLow); ma_dr_wav_buffer_reader_read_u32(&reader, &timeReferenceHigh); pMetadata->data.bext.timeReference = ((ma_uint64)timeReferenceHigh << 32) + timeReferenceLow; ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.version); pMetadata->data.bext.pUMID = ma_dr_wav__metadata_get_memory(pParser, MA_DR_WAV_BEXT_UMID_BYTES, 1); - ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pUMID, MA_DR_WAV_BEXT_UMID_BYTES, NULL); + ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pUMID, MA_DR_WAV_BEXT_UMID_BYTES, nullptr); ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.loudnessValue); ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.loudnessRange); ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.maxTruePeakLevel); @@ -80771,11 +80771,11 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_bext_to_metadata_obj(ma_dr_wav__metadata_pa extraBytes = (size_t)(chunkSize - MA_DR_WAV_BEXT_BYTES); if (extraBytes > 0) { pMetadata->data.bext.pCodingHistory = (char*)ma_dr_wav__metadata_get_memory(pParser, extraBytes + 1, 1); - MA_DR_WAV_ASSERT(pMetadata->data.bext.pCodingHistory != NULL); - bytesRead += ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.bext.pCodingHistory, extraBytes, NULL); + MA_DR_WAV_ASSERT(pMetadata->data.bext.pCodingHistory != nullptr); + bytesRead += ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.bext.pCodingHistory, extraBytes, nullptr); pMetadata->data.bext.codingHistorySize = (ma_uint32)ma_dr_wav__strlen(pMetadata->data.bext.pCodingHistory); } else { - pMetadata->data.bext.pCodingHistory = NULL; + pMetadata->data.bext.pCodingHistory = nullptr; pMetadata->data.bext.codingHistorySize = 0; } } @@ -80796,11 +80796,11 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_list_label_or_note_to_metadata_obj(ma_dr_wa if (sizeIncludingNullTerminator > 0) { pMetadata->data.labelOrNote.stringLength = sizeIncludingNullTerminator - 1; pMetadata->data.labelOrNote.pString = (char*)ma_dr_wav__metadata_get_memory(pParser, sizeIncludingNullTerminator, 1); - MA_DR_WAV_ASSERT(pMetadata->data.labelOrNote.pString != NULL); + MA_DR_WAV_ASSERT(pMetadata->data.labelOrNote.pString != nullptr); ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.labelOrNote.pString, sizeIncludingNullTerminator, &totalBytesRead); } else { pMetadata->data.labelOrNote.stringLength = 0; - pMetadata->data.labelOrNote.pString = NULL; + pMetadata->data.labelOrNote.pString = nullptr; } } return totalBytesRead; @@ -80828,11 +80828,11 @@ MA_PRIVATE ma_uint64 ma_dr_wav__read_list_labelled_cue_region_to_metadata_obj(ma if (sizeIncludingNullTerminator > 0) { pMetadata->data.labelledCueRegion.stringLength = sizeIncludingNullTerminator - 1; pMetadata->data.labelledCueRegion.pString = (char*)ma_dr_wav__metadata_get_memory(pParser, sizeIncludingNullTerminator, 1); - MA_DR_WAV_ASSERT(pMetadata->data.labelledCueRegion.pString != NULL); + MA_DR_WAV_ASSERT(pMetadata->data.labelledCueRegion.pString != nullptr); ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.labelledCueRegion.pString, sizeIncludingNullTerminator, &totalBytesRead); } else { pMetadata->data.labelledCueRegion.stringLength = 0; - pMetadata->data.labelledCueRegion.pString = NULL; + pMetadata->data.labelledCueRegion.pString = nullptr; } } return totalBytesRead; @@ -80850,15 +80850,15 @@ MA_PRIVATE ma_uint64 ma_dr_wav__metadata_process_info_text_chunk(ma_dr_wav__meta if (stringSizeWithNullTerminator > 0) { pMetadata->data.infoText.stringLength = stringSizeWithNullTerminator - 1; pMetadata->data.infoText.pString = (char*)ma_dr_wav__metadata_get_memory(pParser, stringSizeWithNullTerminator, 1); - MA_DR_WAV_ASSERT(pMetadata->data.infoText.pString != NULL); - bytesRead = ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.infoText.pString, (size_t)stringSizeWithNullTerminator, NULL); + MA_DR_WAV_ASSERT(pMetadata->data.infoText.pString != nullptr); + bytesRead = ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.infoText.pString, (size_t)stringSizeWithNullTerminator, nullptr); if (bytesRead == chunkSize) { pParser->metadataCursor += 1; } else { } } else { pMetadata->data.infoText.stringLength = 0; - pMetadata->data.infoText.pString = NULL; + pMetadata->data.infoText.pString = nullptr; pParser->metadataCursor += 1; } } @@ -80886,8 +80886,8 @@ MA_PRIVATE ma_uint64 ma_dr_wav__metadata_process_unknown_chunk(ma_dr_wav__metada pMetadata->data.unknown.id[3] = pChunkId[3]; pMetadata->data.unknown.dataSizeInBytes = (ma_uint32)chunkSize; pMetadata->data.unknown.pData = (ma_uint8 *)ma_dr_wav__metadata_get_memory(pParser, (size_t)chunkSize, 1); - MA_DR_WAV_ASSERT(pMetadata->data.unknown.pData != NULL); - bytesRead = ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.unknown.pData, pMetadata->data.unknown.dataSizeInBytes, NULL); + MA_DR_WAV_ASSERT(pMetadata->data.unknown.pData != nullptr); + bytesRead = ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.unknown.pData, pMetadata->data.unknown.dataSizeInBytes, nullptr); if (bytesRead == pMetadata->data.unknown.dataSizeInBytes) { pParser->metadataCursor += 1; } else { @@ -81137,7 +81137,7 @@ MA_PRIVATE ma_uint32 ma_dr_wav_get_bytes_per_pcm_frame(ma_dr_wav* pWav) } MA_API ma_uint16 ma_dr_wav_fmt_get_format(const ma_dr_wav_fmt* pFMT) { - if (pFMT == NULL) { + if (pFMT == nullptr) { return 0; } if (pFMT->formatTag != MA_DR_WAVE_FORMAT_EXTENSIBLE) { @@ -81148,7 +81148,7 @@ MA_API ma_uint16 ma_dr_wav_fmt_get_format(const ma_dr_wav_fmt* pFMT) } MA_PRIVATE ma_bool32 ma_dr_wav_preinit(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, ma_dr_wav_tell_proc onTell, void* pReadSeekTellUserData, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pWav == NULL || onRead == NULL || onSeek == NULL) { + if (pWav == nullptr || onRead == nullptr || onSeek == nullptr) { return MA_FALSE; } MA_DR_WAV_ZERO_MEMORY(pWav, sizeof(*pWav)); @@ -81157,7 +81157,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_preinit(ma_dr_wav* pWav, ma_dr_wav_read_proc onRe pWav->onTell = onTell; pWav->pUserData = pReadSeekTellUserData; pWav->allocationCallbacks = ma_dr_wav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks); - if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) { + if (pWav->allocationCallbacks.onFree == nullptr || (pWav->allocationCallbacks.onMalloc == nullptr && pWav->allocationCallbacks.onRealloc == nullptr)) { return MA_FALSE; } return MA_TRUE; @@ -81319,7 +81319,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p break; } chunkSize = header.sizeInBytes; - if (!sequential && onChunk != NULL) { + if (!sequential && onChunk != nullptr) { ma_uint64 callbackBytesRead = onChunk(pChunkUserData, pWav->onRead, pWav->onSeek, pWav->pUserData, &header, pWav->container, &fmt); if (callbackBytesRead > 0) { if (ma_dr_wav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData) == MA_FALSE) { @@ -81610,7 +81610,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p pWav->pMetadata = metadataParser.pMetadata; pWav->metadataCount = metadataParser.metadataCount; } - if (pWav->onTell != NULL && pWav->onSeek != NULL) { + if (pWav->onTell != nullptr && pWav->onSeek != nullptr) { if (pWav->onSeek(pWav->pUserData, 0, MA_DR_WAV_SEEK_END) == MA_TRUE) { ma_int64 fileSize; if (pWav->onTell(pWav->pUserData, &fileSize)) { @@ -81704,7 +81704,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p } MA_API ma_bool32 ma_dr_wav_init(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, ma_dr_wav_tell_proc onTell, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_wav_init_ex(pWav, onRead, onSeek, onTell, NULL, pUserData, NULL, 0, pAllocationCallbacks); + return ma_dr_wav_init_ex(pWav, onRead, onSeek, onTell, nullptr, pUserData, nullptr, 0, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_ex(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, ma_dr_wav_tell_proc onTell, ma_dr_wav_chunk_proc onChunk, void* pReadSeekTellUserData, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { @@ -81718,31 +81718,31 @@ MA_API ma_bool32 ma_dr_wav_init_with_metadata(ma_dr_wav* pWav, ma_dr_wav_read_pr if (!ma_dr_wav_preinit(pWav, onRead, onSeek, onTell, pUserData, pAllocationCallbacks)) { return MA_FALSE; } - return ma_dr_wav_init__internal(pWav, NULL, NULL, flags | MA_DR_WAV_WITH_METADATA); + return ma_dr_wav_init__internal(pWav, nullptr, nullptr, flags | MA_DR_WAV_WITH_METADATA); } MA_API ma_dr_wav_metadata* ma_dr_wav_take_ownership_of_metadata(ma_dr_wav* pWav) { ma_dr_wav_metadata *result = pWav->pMetadata; - pWav->pMetadata = NULL; + pWav->pMetadata = nullptr; pWav->metadataCount = 0; return result; } MA_PRIVATE size_t ma_dr_wav__write(ma_dr_wav* pWav, const void* pData, size_t dataSize) { - MA_DR_WAV_ASSERT(pWav != NULL); - MA_DR_WAV_ASSERT(pWav->onWrite != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); + MA_DR_WAV_ASSERT(pWav->onWrite != nullptr); return pWav->onWrite(pWav->pUserData, pData, dataSize); } MA_PRIVATE size_t ma_dr_wav__write_byte(ma_dr_wav* pWav, ma_uint8 byte) { - MA_DR_WAV_ASSERT(pWav != NULL); - MA_DR_WAV_ASSERT(pWav->onWrite != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); + MA_DR_WAV_ASSERT(pWav->onWrite != nullptr); return pWav->onWrite(pWav->pUserData, &byte, 1); } MA_PRIVATE size_t ma_dr_wav__write_u16ne_to_le(ma_dr_wav* pWav, ma_uint16 value) { - MA_DR_WAV_ASSERT(pWav != NULL); - MA_DR_WAV_ASSERT(pWav->onWrite != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); + MA_DR_WAV_ASSERT(pWav->onWrite != nullptr); if (!ma_dr_wav__is_little_endian()) { value = ma_dr_wav__bswap16(value); } @@ -81750,8 +81750,8 @@ MA_PRIVATE size_t ma_dr_wav__write_u16ne_to_le(ma_dr_wav* pWav, ma_uint16 value) } MA_PRIVATE size_t ma_dr_wav__write_u32ne_to_le(ma_dr_wav* pWav, ma_uint32 value) { - MA_DR_WAV_ASSERT(pWav != NULL); - MA_DR_WAV_ASSERT(pWav->onWrite != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); + MA_DR_WAV_ASSERT(pWav->onWrite != nullptr); if (!ma_dr_wav__is_little_endian()) { value = ma_dr_wav__bswap32(value); } @@ -81759,8 +81759,8 @@ MA_PRIVATE size_t ma_dr_wav__write_u32ne_to_le(ma_dr_wav* pWav, ma_uint32 value) } MA_PRIVATE size_t ma_dr_wav__write_u64ne_to_le(ma_dr_wav* pWav, ma_uint64 value) { - MA_DR_WAV_ASSERT(pWav != NULL); - MA_DR_WAV_ASSERT(pWav->onWrite != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); + MA_DR_WAV_ASSERT(pWav->onWrite != nullptr); if (!ma_dr_wav__is_little_endian()) { value = ma_dr_wav__bswap64(value); } @@ -81772,8 +81772,8 @@ MA_PRIVATE size_t ma_dr_wav__write_f32ne_to_le(ma_dr_wav* pWav, float value) ma_uint32 u32; float f32; } u; - MA_DR_WAV_ASSERT(pWav != NULL); - MA_DR_WAV_ASSERT(pWav->onWrite != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); + MA_DR_WAV_ASSERT(pWav->onWrite != nullptr); u.f32 = value; if (!ma_dr_wav__is_little_endian()) { u.u32 = ma_dr_wav__bswap32(u.u32); @@ -81782,28 +81782,28 @@ MA_PRIVATE size_t ma_dr_wav__write_f32ne_to_le(ma_dr_wav* pWav, float value) } MA_PRIVATE size_t ma_dr_wav__write_or_count(ma_dr_wav* pWav, const void* pData, size_t dataSize) { - if (pWav == NULL) { + if (pWav == nullptr) { return dataSize; } return ma_dr_wav__write(pWav, pData, dataSize); } MA_PRIVATE size_t ma_dr_wav__write_or_count_byte(ma_dr_wav* pWav, ma_uint8 byte) { - if (pWav == NULL) { + if (pWav == nullptr) { return 1; } return ma_dr_wav__write_byte(pWav, byte); } MA_PRIVATE size_t ma_dr_wav__write_or_count_u16ne_to_le(ma_dr_wav* pWav, ma_uint16 value) { - if (pWav == NULL) { + if (pWav == nullptr) { return 2; } return ma_dr_wav__write_u16ne_to_le(pWav, value); } MA_PRIVATE size_t ma_dr_wav__write_or_count_u32ne_to_le(ma_dr_wav* pWav, ma_uint32 value) { - if (pWav == NULL) { + if (pWav == nullptr) { return 4; } return ma_dr_wav__write_u32ne_to_le(pWav, value); @@ -81811,7 +81811,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_u32ne_to_le(ma_dr_wav* pWav, ma_uint #if 0 MA_PRIVATE size_t ma_dr_wav__write_or_count_u64ne_to_le(ma_dr_wav* pWav, ma_uint64 value) { - if (pWav == NULL) { + if (pWav == nullptr) { return 8; } return ma_dr_wav__write_u64ne_to_le(pWav, value); @@ -81819,7 +81819,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_u64ne_to_le(ma_dr_wav* pWav, ma_uint #endif MA_PRIVATE size_t ma_dr_wav__write_or_count_f32ne_to_le(ma_dr_wav* pWav, float value) { - if (pWav == NULL) { + if (pWav == nullptr) { return 4; } return ma_dr_wav__write_f32ne_to_le(pWav, value); @@ -81827,7 +81827,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_f32ne_to_le(ma_dr_wav* pWav, float v MA_PRIVATE size_t ma_dr_wav__write_or_count_string_to_fixed_size_buf(ma_dr_wav* pWav, char* str, size_t bufFixedSize) { size_t len; - if (pWav == NULL) { + if (pWav == nullptr) { return bufFixedSize; } len = ma_dr_wav__strlen_clamped(str, bufFixedSize); @@ -81846,7 +81846,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_metadata(ma_dr_wav* pWav, ma_dr_wav_ ma_bool32 hasListAdtl = MA_FALSE; ma_bool32 hasListInfo = MA_FALSE; ma_uint32 iMetadata; - if (pMetadatas == NULL || metadataCount == 0) { + if (pMetadatas == nullptr || metadataCount == 0) { return 0; } for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) { @@ -81996,7 +81996,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_metadata(ma_dr_wav* pWav, ma_dr_wav_ ma_dr_wav_metadata* pMetadata = &pMetadatas[iMetadata]; ma_uint32 subchunkSize = 0; if (pMetadata->type & ma_dr_wav_metadata_type_list_all_info_strings) { - const char* pID = NULL; + const char* pID = nullptr; switch (pMetadata->type) { case ma_dr_wav_metadata_type_list_info_software: pID = "ISFT"; break; case ma_dr_wav_metadata_type_list_info_copyright: pID = "ICOP"; break; @@ -82014,7 +82014,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_metadata(ma_dr_wav* pWav, ma_dr_wav_ case ma_dr_wav_metadata_type_list_info_description: pID = "ISBJ"; break; default: break; } - MA_DR_WAV_ASSERT(pID != NULL); + MA_DR_WAV_ASSERT(pID != nullptr); if (pMetadata->data.infoText.stringLength) { subchunkSize = pMetadata->data.infoText.stringLength + 1; bytesWritten += ma_dr_wav__write_or_count(pWav, pID, 4); @@ -82083,15 +82083,15 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_metadata(ma_dr_wav* pWav, ma_dr_wav_ case ma_dr_wav_metadata_type_list_note: { if (pMetadata->data.labelOrNote.stringLength > 0) { - const char *pID = NULL; + const char *pID = nullptr; if (pMetadata->type == ma_dr_wav_metadata_type_list_label) { pID = "labl"; } else if (pMetadata->type == ma_dr_wav_metadata_type_list_note) { pID = "note"; } - MA_DR_WAV_ASSERT(pID != NULL); - MA_DR_WAV_ASSERT(pMetadata->data.labelOrNote.pString != NULL); + MA_DR_WAV_ASSERT(pID != nullptr); + MA_DR_WAV_ASSERT(pMetadata->data.labelOrNote.pString != nullptr); subchunkSize = MA_DR_WAV_LIST_LABEL_OR_NOTE_BYTES; bytesWritten += ma_dr_wav__write_or_count(pWav, pID, 4); subchunkSize += pMetadata->data.labelOrNote.stringLength + 1; @@ -82117,7 +82117,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_metadata(ma_dr_wav* pWav, ma_dr_wav_ bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.dialect); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.codePage); if (pMetadata->data.labelledCueRegion.stringLength > 0) { - MA_DR_WAV_ASSERT(pMetadata->data.labelledCueRegion.pString != NULL); + MA_DR_WAV_ASSERT(pMetadata->data.labelledCueRegion.pString != nullptr); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.labelledCueRegion.pString, pMetadata->data.labelledCueRegion.stringLength); bytesWritten += ma_dr_wav__write_or_count_byte(pWav, '\0'); } @@ -82126,7 +82126,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_metadata(ma_dr_wav* pWav, ma_dr_wav_ { if (pMetadata->data.unknown.chunkLocation == ma_dr_wav_metadata_location_inside_adtl_list) { subchunkSize = pMetadata->data.unknown.dataSizeInBytes; - MA_DR_WAV_ASSERT(pMetadata->data.unknown.pData != NULL); + MA_DR_WAV_ASSERT(pMetadata->data.unknown.pData != nullptr); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.unknown.id, 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, subchunkSize); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.unknown.pData, subchunkSize); @@ -82144,7 +82144,7 @@ MA_PRIVATE size_t ma_dr_wav__write_or_count_metadata(ma_dr_wav* pWav, ma_dr_wav_ } MA_PRIVATE ma_uint32 ma_dr_wav__riff_chunk_size_riff(ma_uint64 dataChunkSize, ma_dr_wav_metadata* pMetadata, ma_uint32 metadataCount) { - ma_uint64 chunkSize = 4 + 24 + (ma_uint64)ma_dr_wav__write_or_count_metadata(NULL, pMetadata, metadataCount) + 8 + dataChunkSize + ma_dr_wav__chunk_padding_size_riff(dataChunkSize); + ma_uint64 chunkSize = 4 + 24 + (ma_uint64)ma_dr_wav__write_or_count_metadata(nullptr, pMetadata, metadataCount) + 8 + dataChunkSize + ma_dr_wav__chunk_padding_size_riff(dataChunkSize); if (chunkSize > 0xFFFFFFFFUL) { chunkSize = 0xFFFFFFFFUL; } @@ -82169,7 +82169,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav__data_chunk_size_w64(ma_uint64 dataChunkSize) } MA_PRIVATE ma_uint64 ma_dr_wav__riff_chunk_size_rf64(ma_uint64 dataChunkSize, ma_dr_wav_metadata *metadata, ma_uint32 numMetadata) { - ma_uint64 chunkSize = 4 + 36 + 24 + (ma_uint64)ma_dr_wav__write_or_count_metadata(NULL, metadata, numMetadata) + 8 + dataChunkSize + ma_dr_wav__chunk_padding_size_riff(dataChunkSize); + ma_uint64 chunkSize = 4 + 36 + 24 + (ma_uint64)ma_dr_wav__write_or_count_metadata(nullptr, metadata, numMetadata) + 8 + dataChunkSize + ma_dr_wav__chunk_padding_size_riff(dataChunkSize); if (chunkSize > 0xFFFFFFFFUL) { chunkSize = 0xFFFFFFFFUL; } @@ -82181,10 +82181,10 @@ MA_PRIVATE ma_uint64 ma_dr_wav__data_chunk_size_rf64(ma_uint64 dataChunkSize) } MA_PRIVATE ma_bool32 ma_dr_wav_preinit_write(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_bool32 isSequential, ma_dr_wav_write_proc onWrite, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pWav == NULL || onWrite == NULL) { + if (pWav == nullptr || onWrite == nullptr) { return MA_FALSE; } - if (!isSequential && onSeek == NULL) { + if (!isSequential && onSeek == nullptr) { return MA_FALSE; } if (pFormat->format == MA_DR_WAVE_FORMAT_EXTENSIBLE) { @@ -82198,7 +82198,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_preinit_write(ma_dr_wav* pWav, const ma_dr_wav_da pWav->onSeek = onSeek; pWav->pUserData = pUserData; pWav->allocationCallbacks = ma_dr_wav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks); - if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) { + if (pWav->allocationCallbacks.onFree == nullptr || (pWav->allocationCallbacks.onMalloc == nullptr && pWav->allocationCallbacks.onRealloc == nullptr)) { return MA_FALSE; } pWav->fmt.formatTag = (ma_uint16)pFormat->format; @@ -82267,7 +82267,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init_write__internal(ma_dr_wav* pWav, const ma_dr runningPos += ma_dr_wav__write_u32ne_to_le(pWav, pWav->fmt.avgBytesPerSec); runningPos += ma_dr_wav__write_u16ne_to_le(pWav, pWav->fmt.blockAlign); runningPos += ma_dr_wav__write_u16ne_to_le(pWav, pWav->fmt.bitsPerSample); - if (!pWav->isSequentialWrite && pWav->pMetadata != NULL && pWav->metadataCount > 0 && (pFormat->container == ma_dr_wav_container_riff || pFormat->container == ma_dr_wav_container_rf64)) { + if (!pWav->isSequentialWrite && pWav->pMetadata != nullptr && pWav->metadataCount > 0 && (pFormat->container == ma_dr_wav_container_riff || pFormat->container == ma_dr_wav_container_rf64)) { runningPos += ma_dr_wav__write_or_count_metadata(pWav, pWav->pMetadata, pWav->metadataCount); } pWav->dataChunkDataPos = runningPos; @@ -82300,14 +82300,14 @@ MA_API ma_bool32 ma_dr_wav_init_write(ma_dr_wav* pWav, const ma_dr_wav_data_form } MA_API ma_bool32 ma_dr_wav_init_write_sequential(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_dr_wav_write_proc onWrite, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { - if (!ma_dr_wav_preinit_write(pWav, pFormat, MA_TRUE, onWrite, NULL, pUserData, pAllocationCallbacks)) { + if (!ma_dr_wav_preinit_write(pWav, pFormat, MA_TRUE, onWrite, nullptr, pUserData, pAllocationCallbacks)) { return MA_FALSE; } return ma_dr_wav_init_write__internal(pWav, pFormat, totalSampleCount); } MA_API ma_bool32 ma_dr_wav_init_write_sequential_pcm_frames(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, ma_dr_wav_write_proc onWrite, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFormat == NULL) { + if (pFormat == nullptr) { return MA_FALSE; } return ma_dr_wav_init_write_sequential(pWav, pFormat, totalPCMFrameCount*pFormat->channels, onWrite, pUserData, pAllocationCallbacks); @@ -82361,8 +82361,8 @@ MA_PRIVATE ma_bool32 ma_dr_wav__on_tell_stdio(void* pUserData, ma_int64* pCursor { FILE* pFileStdio = (FILE*)pUserData; ma_int64 result; - MA_DR_WAV_ASSERT(pFileStdio != NULL); - MA_DR_WAV_ASSERT(pCursor != NULL); + MA_DR_WAV_ASSERT(pFileStdio != nullptr); + MA_DR_WAV_ASSERT(pCursor != nullptr); #if defined(_WIN32) && !defined(NXDK) #if defined(_MSC_VER) && _MSC_VER > 1200 result = _ftelli64(pFileStdio); @@ -82377,7 +82377,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav__on_tell_stdio(void* pUserData, ma_int64* pCursor } MA_API ma_bool32 ma_dr_wav_init_file(ma_dr_wav* pWav, const char* filename, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_wav_init_file_ex(pWav, filename, NULL, NULL, 0, pAllocationCallbacks); + return ma_dr_wav_init_file_ex(pWav, filename, nullptr, nullptr, 0, pAllocationCallbacks); } MA_PRIVATE ma_bool32 ma_dr_wav_init_file__internal_FILE(ma_dr_wav* pWav, FILE* pFile, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { @@ -82405,7 +82405,7 @@ MA_API ma_bool32 ma_dr_wav_init_file_ex(ma_dr_wav* pWav, const char* filename, m #ifndef MA_DR_WAV_NO_WCHAR MA_API ma_bool32 ma_dr_wav_init_file_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_wav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks); + return ma_dr_wav_init_file_ex_w(pWav, filename, nullptr, nullptr, 0, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_file_ex_w(ma_dr_wav* pWav, const wchar_t* filename, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { @@ -82422,7 +82422,7 @@ MA_API ma_bool32 ma_dr_wav_init_file_with_metadata(ma_dr_wav* pWav, const char* if (ma_fopen(&pFile, filename, "rb") != MA_SUCCESS) { return MA_FALSE; } - return ma_dr_wav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags | MA_DR_WAV_WITH_METADATA, pAllocationCallbacks); + return ma_dr_wav_init_file__internal_FILE(pWav, pFile, nullptr, nullptr, flags | MA_DR_WAV_WITH_METADATA, pAllocationCallbacks); } #ifndef MA_DR_WAV_NO_WCHAR MA_API ma_bool32 ma_dr_wav_init_file_with_metadata_w(ma_dr_wav* pWav, const wchar_t* filename, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) @@ -82431,7 +82431,7 @@ MA_API ma_bool32 ma_dr_wav_init_file_with_metadata_w(ma_dr_wav* pWav, const wcha if (ma_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != MA_SUCCESS) { return MA_FALSE; } - return ma_dr_wav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags | MA_DR_WAV_WITH_METADATA, pAllocationCallbacks); + return ma_dr_wav_init_file__internal_FILE(pWav, pFile, nullptr, nullptr, flags | MA_DR_WAV_WITH_METADATA, pAllocationCallbacks); } #endif MA_PRIVATE ma_bool32 ma_dr_wav_init_file_write__internal_FILE(ma_dr_wav* pWav, FILE* pFile, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_bool32 isSequential, const ma_allocation_callbacks* pAllocationCallbacks) @@ -82477,7 +82477,7 @@ MA_API ma_bool32 ma_dr_wav_init_file_write_sequential(ma_dr_wav* pWav, const cha } MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_pcm_frames(ma_dr_wav* pWav, const char* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFormat == NULL) { + if (pFormat == nullptr) { return MA_FALSE; } return ma_dr_wav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks); @@ -82493,7 +82493,7 @@ MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_w(ma_dr_wav* pWav, const w } MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_pcm_frames_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFormat == NULL) { + if (pFormat == nullptr) { return MA_FALSE; } return ma_dr_wav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks); @@ -82504,7 +82504,7 @@ MA_PRIVATE size_t ma_dr_wav__on_read_memory(void* pUserData, void* pBufferOut, s { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; size_t bytesRemaining; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); MA_DR_WAV_ASSERT(pWav->memoryStream.dataSize >= pWav->memoryStream.currentReadPos); bytesRemaining = pWav->memoryStream.dataSize - pWav->memoryStream.currentReadPos; if (bytesToRead > bytesRemaining) { @@ -82520,7 +82520,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav__on_seek_memory(void* pUserData, int offset, ma_d { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; ma_int64 newCursor; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); if (origin == MA_DR_WAV_SEEK_SET) { newCursor = 0; } else if (origin == MA_DR_WAV_SEEK_CUR) { @@ -82545,7 +82545,7 @@ MA_PRIVATE size_t ma_dr_wav__on_write_memory(void* pUserData, const void* pDataI { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; size_t bytesRemaining; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); MA_DR_WAV_ASSERT(pWav->memoryStreamWrite.dataCapacity >= pWav->memoryStreamWrite.currentWritePos); bytesRemaining = pWav->memoryStreamWrite.dataCapacity - pWav->memoryStreamWrite.currentWritePos; if (bytesRemaining < bytesToWrite) { @@ -82555,7 +82555,7 @@ MA_PRIVATE size_t ma_dr_wav__on_write_memory(void* pUserData, const void* pDataI newDataCapacity = pWav->memoryStreamWrite.currentWritePos + bytesToWrite; } pNewData = ma_dr_wav__realloc_from_callbacks(*pWav->memoryStreamWrite.ppData, newDataCapacity, pWav->memoryStreamWrite.dataCapacity, &pWav->allocationCallbacks); - if (pNewData == NULL) { + if (pNewData == nullptr) { return 0; } *pWav->memoryStreamWrite.ppData = pNewData; @@ -82573,7 +82573,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav__on_seek_memory_write(void* pUserData, int offset { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; ma_int64 newCursor; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); if (origin == MA_DR_WAV_SEEK_SET) { newCursor = 0; } else if (origin == MA_DR_WAV_SEEK_CUR) { @@ -82597,18 +82597,18 @@ MA_PRIVATE ma_bool32 ma_dr_wav__on_seek_memory_write(void* pUserData, int offset MA_PRIVATE ma_bool32 ma_dr_wav__on_tell_memory(void* pUserData, ma_int64* pCursor) { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; - MA_DR_WAV_ASSERT(pWav != NULL); - MA_DR_WAV_ASSERT(pCursor != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); + MA_DR_WAV_ASSERT(pCursor != nullptr); *pCursor = (ma_int64)pWav->memoryStream.currentReadPos; return MA_TRUE; } MA_API ma_bool32 ma_dr_wav_init_memory(ma_dr_wav* pWav, const void* data, size_t dataSize, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_wav_init_memory_ex(pWav, data, dataSize, NULL, NULL, 0, pAllocationCallbacks); + return ma_dr_wav_init_memory_ex(pWav, data, dataSize, nullptr, nullptr, 0, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_memory_ex(ma_dr_wav* pWav, const void* data, size_t dataSize, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { - if (data == NULL || dataSize == 0) { + if (data == nullptr || dataSize == 0) { return MA_FALSE; } if (!ma_dr_wav_preinit(pWav, ma_dr_wav__on_read_memory, ma_dr_wav__on_seek_memory, ma_dr_wav__on_tell_memory, pWav, pAllocationCallbacks)) { @@ -82621,7 +82621,7 @@ MA_API ma_bool32 ma_dr_wav_init_memory_ex(ma_dr_wav* pWav, const void* data, siz } MA_API ma_bool32 ma_dr_wav_init_memory_with_metadata(ma_dr_wav* pWav, const void* data, size_t dataSize, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { - if (data == NULL || dataSize == 0) { + if (data == nullptr || dataSize == 0) { return MA_FALSE; } if (!ma_dr_wav_preinit(pWav, ma_dr_wav__on_read_memory, ma_dr_wav__on_seek_memory, ma_dr_wav__on_tell_memory, pWav, pAllocationCallbacks)) { @@ -82630,14 +82630,14 @@ MA_API ma_bool32 ma_dr_wav_init_memory_with_metadata(ma_dr_wav* pWav, const void pWav->memoryStream.data = (const ma_uint8*)data; pWav->memoryStream.dataSize = dataSize; pWav->memoryStream.currentReadPos = 0; - return ma_dr_wav_init__internal(pWav, NULL, NULL, flags | MA_DR_WAV_WITH_METADATA); + return ma_dr_wav_init__internal(pWav, nullptr, nullptr, flags | MA_DR_WAV_WITH_METADATA); } MA_PRIVATE ma_bool32 ma_dr_wav_init_memory_write__internal(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_bool32 isSequential, const ma_allocation_callbacks* pAllocationCallbacks) { - if (ppData == NULL || pDataSize == NULL) { + if (ppData == nullptr || pDataSize == nullptr) { return MA_FALSE; } - *ppData = NULL; + *ppData = nullptr; *pDataSize = 0; if (!ma_dr_wav_preinit_write(pWav, pFormat, isSequential, ma_dr_wav__on_write_memory, ma_dr_wav__on_seek_memory_write, pWav, pAllocationCallbacks)) { return MA_FALSE; @@ -82659,7 +82659,7 @@ MA_API ma_bool32 ma_dr_wav_init_memory_write_sequential(ma_dr_wav* pWav, void** } MA_API ma_bool32 ma_dr_wav_init_memory_write_sequential_pcm_frames(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pFormat == NULL) { + if (pFormat == nullptr) { return MA_FALSE; } return ma_dr_wav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks); @@ -82667,10 +82667,10 @@ MA_API ma_bool32 ma_dr_wav_init_memory_write_sequential_pcm_frames(ma_dr_wav* pW MA_API ma_result ma_dr_wav_uninit(ma_dr_wav* pWav) { ma_result result = MA_SUCCESS; - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_ARGS; } - if (pWav->onWrite != NULL) { + if (pWav->onWrite != nullptr) { ma_uint32 paddingSize = 0; if (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rf64) { paddingSize = ma_dr_wav__chunk_padding_size_riff(pWav->dataChunkDataSize); @@ -82731,7 +82731,7 @@ MA_API size_t ma_dr_wav_read_raw(ma_dr_wav* pWav, size_t bytesToRead, void* pBuf { size_t bytesRead; ma_uint32 bytesPerFrame; - if (pWav == NULL || bytesToRead == 0) { + if (pWav == nullptr || bytesToRead == 0) { return 0; } if (bytesToRead > pWav->bytesRemaining) { @@ -82744,7 +82744,7 @@ MA_API size_t ma_dr_wav_read_raw(ma_dr_wav* pWav, size_t bytesToRead, void* pBuf if (bytesPerFrame == 0) { return 0; } - if (pBufferOut != NULL) { + if (pBufferOut != nullptr) { bytesRead = pWav->onRead(pWav->pUserData, pBufferOut, bytesToRead); } else { bytesRead = 0; @@ -82781,7 +82781,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 framesT ma_uint32 bytesPerFrame; ma_uint64 bytesToRead; ma_uint64 framesRemainingInFile; - if (pWav == NULL || framesToRead == 0) { + if (pWav == nullptr || framesToRead == 0) { return 0; } if (ma_dr_wav__is_compressed_format_tag(pWav->translatedFormatTag)) { @@ -82807,7 +82807,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 framesT MA_API ma_uint64 ma_dr_wav_read_pcm_frames_be(ma_dr_wav* pWav, ma_uint64 framesToRead, void* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_le(pWav, framesToRead, pBufferOut); - if (pBufferOut != NULL) { + if (pBufferOut != nullptr) { ma_uint32 bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; @@ -82837,7 +82837,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames(ma_dr_wav* pWav, ma_uint64 framesToRe post_process: { if (pWav->container == ma_dr_wav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == MA_FALSE) { - if (pBufferOut != NULL) { + if (pBufferOut != nullptr) { ma_uint64 iSample; for (iSample = 0; iSample < framesRead * pWav->channels; iSample += 1) { ((ma_uint8*)pBufferOut)[iSample] += 128; @@ -82849,7 +82849,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames(ma_dr_wav* pWav, ma_uint64 framesToRe } MA_PRIVATE ma_bool32 ma_dr_wav_seek_to_first_pcm_frame(ma_dr_wav* pWav) { - if (pWav->onWrite != NULL) { + if (pWav->onWrite != nullptr) { return MA_FALSE; } if (!pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos, MA_DR_WAV_SEEK_SET)) { @@ -82870,10 +82870,10 @@ MA_PRIVATE ma_bool32 ma_dr_wav_seek_to_first_pcm_frame(ma_dr_wav* pWav) } MA_API ma_bool32 ma_dr_wav_seek_to_pcm_frame(ma_dr_wav* pWav, ma_uint64 targetFrameIndex) { - if (pWav == NULL || pWav->onSeek == NULL) { + if (pWav == nullptr || pWav->onSeek == nullptr) { return MA_FALSE; } - if (pWav->onWrite != NULL) { + if (pWav->onWrite != nullptr) { return MA_FALSE; } if (pWav->totalPCMFrameCount == 0) { @@ -82945,11 +82945,11 @@ MA_API ma_bool32 ma_dr_wav_seek_to_pcm_frame(ma_dr_wav* pWav, ma_uint64 targetFr } MA_API ma_result ma_dr_wav_get_cursor_in_pcm_frames(ma_dr_wav* pWav, ma_uint64* pCursor) { - if (pCursor == NULL) { + if (pCursor == nullptr) { return MA_INVALID_ARGS; } *pCursor = 0; - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_ARGS; } *pCursor = pWav->readCursorInPCMFrames; @@ -82957,11 +82957,11 @@ MA_API ma_result ma_dr_wav_get_cursor_in_pcm_frames(ma_dr_wav* pWav, ma_uint64* } MA_API ma_result ma_dr_wav_get_length_in_pcm_frames(ma_dr_wav* pWav, ma_uint64* pLength) { - if (pLength == NULL) { + if (pLength == nullptr) { return MA_INVALID_ARGS; } *pLength = 0; - if (pWav == NULL) { + if (pWav == nullptr) { return MA_INVALID_ARGS; } *pLength = pWav->totalPCMFrameCount; @@ -82970,7 +82970,7 @@ MA_API ma_result ma_dr_wav_get_length_in_pcm_frames(ma_dr_wav* pWav, ma_uint64* MA_API size_t ma_dr_wav_write_raw(ma_dr_wav* pWav, size_t bytesToWrite, const void* pData) { size_t bytesWritten; - if (pWav == NULL || bytesToWrite == 0 || pData == NULL) { + if (pWav == nullptr || bytesToWrite == 0 || pData == nullptr) { return 0; } bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite); @@ -82982,7 +82982,7 @@ MA_API ma_uint64 ma_dr_wav_write_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 frames ma_uint64 bytesToWrite; ma_uint64 bytesWritten; const ma_uint8* pRunningData; - if (pWav == NULL || framesToWrite == 0 || pData == NULL) { + if (pWav == nullptr || framesToWrite == 0 || pData == nullptr) { return 0; } bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8); @@ -83012,7 +83012,7 @@ MA_API ma_uint64 ma_dr_wav_write_pcm_frames_be(ma_dr_wav* pWav, ma_uint64 frames ma_uint64 bytesWritten; ma_uint32 bytesPerSample; const ma_uint8* pRunningData; - if (pWav == NULL || framesToWrite == 0 || pData == NULL) { + if (pWav == nullptr || framesToWrite == 0 || pData == nullptr) { return 0; } bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8); @@ -83065,7 +83065,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__msadpcm(ma_dr_wav* pWav, ma_ }; static const ma_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460, 392 }; static const ma_int32 coeff2Table[] = { 0, -256, 0, 64, 0, -208, -232 }; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); MA_DR_WAV_ASSERT(framesToRead > 0); while (pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) { MA_DR_WAV_ASSERT(framesToRead > 0); @@ -83112,7 +83112,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__msadpcm(ma_dr_wav* pWav, ma_ } } while (framesToRead > 0 && pWav->msadpcm.cachedFrameCount > 0 && pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) { - if (pBufferOut != NULL) { + if (pBufferOut != nullptr) { ma_uint32 iSample = 0; for (iSample = 0; iSample < pWav->channels; iSample += 1) { pBufferOut[iSample] = (ma_int16)pWav->msadpcm.cachedFrames[(ma_dr_wav_countof(pWav->msadpcm.cachedFrames) - (pWav->msadpcm.cachedFrameCount*pWav->channels)) + iSample]; @@ -83222,7 +83222,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ima(ma_dr_wav* pWav, ma_uint 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); MA_DR_WAV_ASSERT(framesToRead > 0); while (pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) { MA_DR_WAV_ASSERT(framesToRead > 0); @@ -83263,7 +83263,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ima(ma_dr_wav* pWav, ma_uint } } while (framesToRead > 0 && pWav->ima.cachedFrameCount > 0 && pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) { - if (pBufferOut != NULL) { + if (pBufferOut != nullptr) { ma_uint32 iSample; for (iSample = 0; iSample < pWav->channels; iSample += 1) { pBufferOut[iSample] = (ma_int16)pWav->ima.cachedFrames[(ma_dr_wav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + iSample]; @@ -83426,7 +83426,7 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__pcm(ma_dr_wav* pWav, ma_uint ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; - if ((pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 16) || pBufferOut == NULL) { + if ((pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 16) || pBufferOut == nullptr) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, pBufferOut); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); @@ -83464,8 +83464,8 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ieee(ma_dr_wav* pWav, ma_uin ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; - if (pBufferOut == NULL) { - return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); + if (pBufferOut == nullptr) { + return ma_dr_wav_read_pcm_frames(pWav, framesToRead, nullptr); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { @@ -83502,8 +83502,8 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__alaw(ma_dr_wav* pWav, ma_uin ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; - if (pBufferOut == NULL) { - return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); + if (pBufferOut == nullptr) { + return ma_dr_wav_read_pcm_frames(pWav, framesToRead, nullptr); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { @@ -83550,8 +83550,8 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__mulaw(ma_dr_wav* pWav, ma_ui ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; - if (pBufferOut == NULL) { - return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); + if (pBufferOut == nullptr) { + return ma_dr_wav_read_pcm_frames(pWav, framesToRead, nullptr); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { @@ -83593,11 +83593,11 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__mulaw(ma_dr_wav* pWav, ma_ui } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { - if (pWav == NULL || framesToRead == 0) { + if (pWav == nullptr || framesToRead == 0) { return 0; } - if (pBufferOut == NULL) { - return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); + if (pBufferOut == nullptr) { + return ma_dr_wav_read_pcm_frames(pWav, framesToRead, nullptr); } if (framesToRead * pWav->channels * sizeof(ma_int16) > MA_SIZE_MAX) { framesToRead = MA_SIZE_MAX / sizeof(ma_int16) / pWav->channels; @@ -83625,7 +83625,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16(ma_dr_wav* pWav, ma_uint64 frames MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16le(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut); - if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_FALSE) { + if (pBufferOut != nullptr && ma_dr_wav__is_little_endian() == MA_FALSE) { ma_dr_wav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels); } return framesRead; @@ -83633,7 +83633,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16le(ma_dr_wav* pWav, ma_uint64 fram MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16be(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut); - if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_TRUE) { + if (pBufferOut != nullptr && ma_dr_wav__is_little_endian() == MA_TRUE) { ma_dr_wav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels); } return framesRead; @@ -83947,11 +83947,11 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_f32__mulaw(ma_dr_wav* pWav, ma_ui } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { - if (pWav == NULL || framesToRead == 0) { + if (pWav == nullptr || framesToRead == 0) { return 0; } - if (pBufferOut == NULL) { - return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); + if (pBufferOut == nullptr) { + return ma_dr_wav_read_pcm_frames(pWav, framesToRead, nullptr); } if (framesToRead * pWav->channels * sizeof(float) > MA_SIZE_MAX) { framesToRead = MA_SIZE_MAX / sizeof(float) / pWav->channels; @@ -83976,7 +83976,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32(ma_dr_wav* pWav, ma_uint64 frames MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32le(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut); - if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_FALSE) { + if (pBufferOut != nullptr && ma_dr_wav__is_little_endian() == MA_FALSE) { ma_dr_wav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels); } return framesRead; @@ -83984,7 +83984,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32le(ma_dr_wav* pWav, ma_uint64 fram MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32be(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut); - if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_TRUE) { + if (pBufferOut != nullptr && ma_dr_wav__is_little_endian() == MA_TRUE) { ma_dr_wav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels); } return framesRead; @@ -83992,7 +83992,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32be(ma_dr_wav* pWav, ma_uint64 fram MA_API void ma_dr_wav_u8_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT @@ -84011,7 +84011,7 @@ MA_API void ma_dr_wav_u8_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleC MA_API void ma_dr_wav_s16_to_f32(float* pOut, const ma_int16* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84021,7 +84021,7 @@ MA_API void ma_dr_wav_s16_to_f32(float* pOut, const ma_int16* pIn, size_t sample MA_API void ma_dr_wav_s24_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84036,7 +84036,7 @@ MA_API void ma_dr_wav_s24_to_f32(float* pOut, const ma_uint8* pIn, size_t sample MA_API void ma_dr_wav_s32_to_f32(float* pOut, const ma_int32* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84046,7 +84046,7 @@ MA_API void ma_dr_wav_s32_to_f32(float* pOut, const ma_int32* pIn, size_t sample MA_API void ma_dr_wav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84056,7 +84056,7 @@ MA_API void ma_dr_wav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCo MA_API void ma_dr_wav_alaw_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84066,7 +84066,7 @@ MA_API void ma_dr_wav_alaw_to_f32(float* pOut, const ma_uint8* pIn, size_t sampl MA_API void ma_dr_wav_mulaw_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84307,11 +84307,11 @@ MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s32__mulaw(ma_dr_wav* pWav, ma_ui } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { - if (pWav == NULL || framesToRead == 0) { + if (pWav == nullptr || framesToRead == 0) { return 0; } - if (pBufferOut == NULL) { - return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); + if (pBufferOut == nullptr) { + return ma_dr_wav_read_pcm_frames(pWav, framesToRead, nullptr); } if (framesToRead * pWav->channels * sizeof(ma_int32) > MA_SIZE_MAX) { framesToRead = MA_SIZE_MAX / sizeof(ma_int32) / pWav->channels; @@ -84336,7 +84336,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32(ma_dr_wav* pWav, ma_uint64 frames MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32le(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut); - if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_FALSE) { + if (pBufferOut != nullptr && ma_dr_wav__is_little_endian() == MA_FALSE) { ma_dr_wav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels); } return framesRead; @@ -84344,7 +84344,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32le(ma_dr_wav* pWav, ma_uint64 fram MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32be(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut); - if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_TRUE) { + if (pBufferOut != nullptr && ma_dr_wav__is_little_endian() == MA_TRUE) { ma_dr_wav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels); } return framesRead; @@ -84352,7 +84352,7 @@ MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32be(ma_dr_wav* pWav, ma_uint64 fram MA_API void ma_dr_wav_u8_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84362,7 +84362,7 @@ MA_API void ma_dr_wav_u8_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t samp MA_API void ma_dr_wav_s16_to_s32(ma_int32* pOut, const ma_int16* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84372,7 +84372,7 @@ MA_API void ma_dr_wav_s16_to_s32(ma_int32* pOut, const ma_int16* pIn, size_t sam MA_API void ma_dr_wav_s24_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84386,7 +84386,7 @@ MA_API void ma_dr_wav_s24_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sam MA_API void ma_dr_wav_f32_to_s32(ma_int32* pOut, const float* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84396,7 +84396,7 @@ MA_API void ma_dr_wav_f32_to_s32(ma_int32* pOut, const float* pIn, size_t sample MA_API void ma_dr_wav_f64_to_s32(ma_int32* pOut, const double* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84406,7 +84406,7 @@ MA_API void ma_dr_wav_f64_to_s32(ma_int32* pOut, const double* pIn, size_t sampl MA_API void ma_dr_wav_alaw_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i = 0; i < sampleCount; ++i) { @@ -84416,7 +84416,7 @@ MA_API void ma_dr_wav_alaw_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sa MA_API void ma_dr_wav_mulaw_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; - if (pOut == NULL || pIn == NULL) { + if (pOut == nullptr || pIn == nullptr) { return; } for (i= 0; i < sampleCount; ++i) { @@ -84428,26 +84428,26 @@ MA_PRIVATE ma_int16* ma_dr_wav__read_pcm_frames_and_close_s16(ma_dr_wav* pWav, u ma_uint64 sampleDataSize; ma_int16* pSampleData; ma_uint64 framesRead; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); if (pWav->channels == 0 || pWav->totalPCMFrameCount > MA_SIZE_MAX / pWav->channels / sizeof(ma_int16)) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(ma_int16); if (sampleDataSize > MA_SIZE_MAX) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } pSampleData = (ma_int16*)ma_dr_wav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); - if (pSampleData == NULL) { + if (pSampleData == nullptr) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } framesRead = ma_dr_wav_read_pcm_frames_s16(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData); if (framesRead != pWav->totalPCMFrameCount) { ma_dr_wav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks); ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } ma_dr_wav_uninit(pWav); if (sampleRate) { @@ -84466,26 +84466,26 @@ MA_PRIVATE float* ma_dr_wav__read_pcm_frames_and_close_f32(ma_dr_wav* pWav, unsi ma_uint64 sampleDataSize; float* pSampleData; ma_uint64 framesRead; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); if (pWav->channels == 0 || pWav->totalPCMFrameCount > MA_SIZE_MAX / pWav->channels / sizeof(float)) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(float); if (sampleDataSize > MA_SIZE_MAX) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } pSampleData = (float*)ma_dr_wav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); - if (pSampleData == NULL) { + if (pSampleData == nullptr) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } framesRead = ma_dr_wav_read_pcm_frames_f32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData); if (framesRead != pWav->totalPCMFrameCount) { ma_dr_wav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks); ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } ma_dr_wav_uninit(pWav); if (sampleRate) { @@ -84504,26 +84504,26 @@ MA_PRIVATE ma_int32* ma_dr_wav__read_pcm_frames_and_close_s32(ma_dr_wav* pWav, u ma_uint64 sampleDataSize; ma_int32* pSampleData; ma_uint64 framesRead; - MA_DR_WAV_ASSERT(pWav != NULL); + MA_DR_WAV_ASSERT(pWav != nullptr); if (pWav->channels == 0 || pWav->totalPCMFrameCount > MA_SIZE_MAX / pWav->channels / sizeof(ma_int32)) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(ma_int32); if (sampleDataSize > MA_SIZE_MAX) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } pSampleData = (ma_int32*)ma_dr_wav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); - if (pSampleData == NULL) { + if (pSampleData == nullptr) { ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } framesRead = ma_dr_wav_read_pcm_frames_s32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData); if (framesRead != pWav->totalPCMFrameCount) { ma_dr_wav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks); ma_dr_wav_uninit(pWav); - return NULL; + return nullptr; } ma_dr_wav_uninit(pWav); if (sampleRate) { @@ -84550,7 +84550,7 @@ MA_API ma_int16* ma_dr_wav_open_and_read_pcm_frames_s16(ma_dr_wav_read_proc onRe *totalFrameCountOut = 0; } if (!ma_dr_wav_init(&wav, onRead, onSeek, onTell, pUserData, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84567,7 +84567,7 @@ MA_API float* ma_dr_wav_open_and_read_pcm_frames_f32(ma_dr_wav_read_proc onRead, *totalFrameCountOut = 0; } if (!ma_dr_wav_init(&wav, onRead, onSeek, onTell, pUserData, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84584,7 +84584,7 @@ MA_API ma_int32* ma_dr_wav_open_and_read_pcm_frames_s32(ma_dr_wav_read_proc onRe *totalFrameCountOut = 0; } if (!ma_dr_wav_init(&wav, onRead, onSeek, onTell, pUserData, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84602,7 +84602,7 @@ MA_API ma_int16* ma_dr_wav_open_file_and_read_pcm_frames_s16(const char* filenam *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file(&wav, filename, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84619,7 +84619,7 @@ MA_API float* ma_dr_wav_open_file_and_read_pcm_frames_f32(const char* filename, *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file(&wav, filename, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84636,7 +84636,7 @@ MA_API ma_int32* ma_dr_wav_open_file_and_read_pcm_frames_s32(const char* filenam *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file(&wav, filename, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84654,7 +84654,7 @@ MA_API ma_int16* ma_dr_wav_open_file_and_read_pcm_frames_s16_w(const wchar_t* fi *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file_w(&wav, filename, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84671,7 +84671,7 @@ MA_API float* ma_dr_wav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filen *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file_w(&wav, filename, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84688,7 +84688,7 @@ MA_API ma_int32* ma_dr_wav_open_file_and_read_pcm_frames_s32_w(const wchar_t* fi *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file_w(&wav, filename, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84707,7 +84707,7 @@ MA_API ma_int16* ma_dr_wav_open_memory_and_read_pcm_frames_s16(const void* data, *totalFrameCountOut = 0; } if (!ma_dr_wav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84724,7 +84724,7 @@ MA_API float* ma_dr_wav_open_memory_and_read_pcm_frames_f32(const void* data, si *totalFrameCountOut = 0; } if (!ma_dr_wav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } @@ -84741,17 +84741,17 @@ MA_API ma_int32* ma_dr_wav_open_memory_and_read_pcm_frames_s32(const void* data, *totalFrameCountOut = 0; } if (!ma_dr_wav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_wav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } #endif MA_API void ma_dr_wav_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks != NULL) { + if (pAllocationCallbacks != nullptr) { ma_dr_wav__free_from_callbacks(p, pAllocationCallbacks); } else { - ma_dr_wav__free_default(p, NULL); + ma_dr_wav__free_default(p, nullptr); } } MA_API ma_uint16 ma_dr_wav_bytes_to_u16(const ma_uint8* data) @@ -85597,8 +85597,8 @@ static void ma_dr_flac__reset_cache(ma_dr_flac_bs* bs) } static MA_INLINE ma_bool32 ma_dr_flac__read_uint32(ma_dr_flac_bs* bs, unsigned int bitCount, ma_uint32* pResultOut) { - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pResultOut != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pResultOut != nullptr); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 32); if (bs->consumedBits == MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs)) { @@ -85645,8 +85645,8 @@ static MA_INLINE ma_bool32 ma_dr_flac__read_uint32(ma_dr_flac_bs* bs, unsigned i static ma_bool32 ma_dr_flac__read_int32(ma_dr_flac_bs* bs, unsigned int bitCount, ma_int32* pResult) { ma_uint32 result; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pResult != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pResult != nullptr); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 32); if (!ma_dr_flac__read_uint32(bs, bitCount, &result)) { @@ -85695,8 +85695,8 @@ static ma_bool32 ma_dr_flac__read_int64(ma_dr_flac_bs* bs, unsigned int bitCount static ma_bool32 ma_dr_flac__read_uint16(ma_dr_flac_bs* bs, unsigned int bitCount, ma_uint16* pResult) { ma_uint32 result; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pResult != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pResult != nullptr); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 16); if (!ma_dr_flac__read_uint32(bs, bitCount, &result)) { @@ -85709,8 +85709,8 @@ static ma_bool32 ma_dr_flac__read_uint16(ma_dr_flac_bs* bs, unsigned int bitCoun static ma_bool32 ma_dr_flac__read_int16(ma_dr_flac_bs* bs, unsigned int bitCount, ma_int16* pResult) { ma_int32 result; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pResult != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pResult != nullptr); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 16); if (!ma_dr_flac__read_int32(bs, bitCount, &result)) { @@ -85723,8 +85723,8 @@ static ma_bool32 ma_dr_flac__read_int16(ma_dr_flac_bs* bs, unsigned int bitCount static ma_bool32 ma_dr_flac__read_uint8(ma_dr_flac_bs* bs, unsigned int bitCount, ma_uint8* pResult) { ma_uint32 result; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pResult != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pResult != nullptr); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 8); if (!ma_dr_flac__read_uint32(bs, bitCount, &result)) { @@ -85736,8 +85736,8 @@ static ma_bool32 ma_dr_flac__read_uint8(ma_dr_flac_bs* bs, unsigned int bitCount static ma_bool32 ma_dr_flac__read_int8(ma_dr_flac_bs* bs, unsigned int bitCount, ma_int8* pResult) { ma_int32 result; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pResult != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pResult != nullptr); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 8); if (!ma_dr_flac__read_int32(bs, bitCount, &result)) { @@ -85793,7 +85793,7 @@ static ma_bool32 ma_dr_flac__seek_bits(ma_dr_flac_bs* bs, size_t bitsToSeek) } static ma_bool32 ma_dr_flac__find_and_seek_to_next_sync_code(ma_dr_flac_bs* bs) { - MA_DR_FLAC_ASSERT(bs != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); if (!ma_dr_flac__seek_bits(bs, MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) { return MA_FALSE; } @@ -86014,7 +86014,7 @@ static MA_INLINE ma_bool32 ma_dr_flac__seek_past_next_set_bit(ma_dr_flac_bs* bs, } static ma_bool32 ma_dr_flac__seek_to_byte(ma_dr_flac_bs* bs, ma_uint64 offsetFromStart) { - MA_DR_FLAC_ASSERT(bs != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); MA_DR_FLAC_ASSERT(offsetFromStart > 0); if (offsetFromStart > 0x7FFFFFFF) { ma_uint64 bytesRemaining = offsetFromStart; @@ -86048,9 +86048,9 @@ static ma_result ma_dr_flac__read_utf8_coded_number(ma_dr_flac_bs* bs, ma_uint64 ma_uint8 utf8[7] = {0}; int byteCount; int i; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pNumberOut != NULL); - MA_DR_FLAC_ASSERT(pCRCOut != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pNumberOut != nullptr); + MA_DR_FLAC_ASSERT(pCRCOut != nullptr); crc = *pCRCOut; if (!ma_dr_flac__read_uint8(bs, 8, utf8)) { *pNumberOut = 0; @@ -86323,8 +86323,8 @@ static MA_INLINE ma_int32 ma_dr_flac__calculate_prediction_64(ma_uint32 order, m static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__reference(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { ma_uint32 i; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pSamplesOut != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pSamplesOut != nullptr); for (i = 0; i < count; ++i) { ma_uint32 zeroCounter = 0; for (;;) { @@ -86600,8 +86600,8 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__scalar_zeroorde ma_uint32 riceParamPart0; ma_uint32 riceParamMask; ma_uint32 i; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pSamplesOut != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pSamplesOut != nullptr); (void)bitsPerSample; (void)order; (void)shift; @@ -86634,8 +86634,8 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__scalar(ma_dr_fl ma_uint32 riceParamMask; const ma_int32* pSamplesOutEnd; ma_uint32 i; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pSamplesOut != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pSamplesOut != nullptr); if (lpcOrder == 0) { return ma_dr_flac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut); } @@ -87052,8 +87052,8 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__sse41_64(ma_dr_ } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__sse41(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pSamplesOut != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pSamplesOut != nullptr); if (lpcOrder > 0 && lpcOrder <= 12) { if (ma_dr_flac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) { return ma_dr_flac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut); @@ -87402,8 +87402,8 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__neon_64(ma_dr_f } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__neon(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(pSamplesOut != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(pSamplesOut != nullptr); if (lpcOrder > 0 && lpcOrder <= 12) { if (ma_dr_flac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) { return ma_dr_flac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut); @@ -87437,7 +87437,7 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice(ma_dr_flac_bs* b static ma_bool32 ma_dr_flac__read_and_seek_residual__rice(ma_dr_flac_bs* bs, ma_uint32 count, ma_uint8 riceParam) { ma_uint32 i; - MA_DR_FLAC_ASSERT(bs != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); for (i = 0; i < count; ++i) { if (!ma_dr_flac__seek_rice_parts(bs, riceParam)) { return MA_FALSE; @@ -87451,9 +87451,9 @@ __attribute__((no_sanitize("signed-integer-overflow"))) static ma_bool32 ma_dr_flac__decode_samples_with_residual__unencoded(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 unencodedBitsPerSample, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { ma_uint32 i; - MA_DR_FLAC_ASSERT(bs != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); MA_DR_FLAC_ASSERT(unencodedBitsPerSample <= 31); - MA_DR_FLAC_ASSERT(pSamplesOut != NULL); + MA_DR_FLAC_ASSERT(pSamplesOut != nullptr); for (i = 0; i < count; ++i) { if (unencodedBitsPerSample > 0) { if (!ma_dr_flac__read_int32(bs, unencodedBitsPerSample, pSamplesOut + i)) { @@ -87476,9 +87476,9 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual(ma_dr_flac_bs* bs, ma_ ma_uint8 partitionOrder; ma_uint32 samplesInPartition; ma_uint32 partitionsRemaining; - MA_DR_FLAC_ASSERT(bs != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); MA_DR_FLAC_ASSERT(blockSize != 0); - MA_DR_FLAC_ASSERT(pDecodedSamples != NULL); + MA_DR_FLAC_ASSERT(pDecodedSamples != nullptr); if (!ma_dr_flac__read_uint8(bs, 2, &residualMethod)) { return MA_FALSE; } @@ -87544,7 +87544,7 @@ static ma_bool32 ma_dr_flac__read_and_seek_residual(ma_dr_flac_bs* bs, ma_uint32 ma_uint8 partitionOrder; ma_uint32 samplesInPartition; ma_uint32 partitionsRemaining; - MA_DR_FLAC_ASSERT(bs != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); MA_DR_FLAC_ASSERT(blockSize != 0); if (!ma_dr_flac__read_uint8(bs, 2, &residualMethod)) { return MA_FALSE; @@ -87689,8 +87689,8 @@ static ma_bool32 ma_dr_flac__read_next_flac_frame_header(ma_dr_flac_bs* bs, ma_u { const ma_uint32 sampleRateTable[12] = {0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000}; const ma_uint8 bitsPerSampleTable[8] = {0, 8, 12, (ma_uint8)-1, 16, 20, 24, (ma_uint8)-1}; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(header != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(header != nullptr); for (;;) { ma_uint8 crc8 = 0xCE; ma_uint8 reserved = 0; @@ -87886,8 +87886,8 @@ static ma_bool32 ma_dr_flac__decode_subframe(ma_dr_flac_bs* bs, ma_dr_flac_frame { ma_dr_flac_subframe* pSubframe; ma_uint32 subframeBitsPerSample; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(frame != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(frame != nullptr); pSubframe = frame->subframes + subframeIndex; if (!ma_dr_flac__read_subframe_header(bs, pSubframe)) { return MA_FALSE; @@ -87935,8 +87935,8 @@ static ma_bool32 ma_dr_flac__seek_subframe(ma_dr_flac_bs* bs, ma_dr_flac_frame* { ma_dr_flac_subframe* pSubframe; ma_uint32 subframeBitsPerSample; - MA_DR_FLAC_ASSERT(bs != NULL); - MA_DR_FLAC_ASSERT(frame != NULL); + MA_DR_FLAC_ASSERT(bs != nullptr); + MA_DR_FLAC_ASSERT(frame != nullptr); pSubframe = frame->subframes + subframeIndex; if (!ma_dr_flac__read_subframe_header(bs, pSubframe)) { return MA_FALSE; @@ -87951,7 +87951,7 @@ static ma_bool32 ma_dr_flac__seek_subframe(ma_dr_flac_bs* bs, ma_dr_flac_frame* return MA_FALSE; } subframeBitsPerSample -= pSubframe->wastedBitsPerSample; - pSubframe->pSamplesS32 = NULL; + pSubframe->pSamplesS32 = nullptr; switch (pSubframe->subframeType) { case MA_DR_FLAC_SUBFRAME_CONSTANT: @@ -88084,7 +88084,7 @@ static ma_result ma_dr_flac__seek_flac_frame(ma_dr_flac* pFlac) } static ma_bool32 ma_dr_flac__read_and_decode_next_flac_frame(ma_dr_flac* pFlac) { - MA_DR_FLAC_ASSERT(pFlac != NULL); + MA_DR_FLAC_ASSERT(pFlac != nullptr); for (;;) { ma_result result; if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { @@ -88105,7 +88105,7 @@ static void ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(ma_dr_flac* pF { ma_uint64 firstPCMFrame; ma_uint64 lastPCMFrame; - MA_DR_FLAC_ASSERT(pFlac != NULL); + MA_DR_FLAC_ASSERT(pFlac != nullptr); firstPCMFrame = pFlac->currentFLACFrame.header.pcmFrameNumber; if (firstPCMFrame == 0) { firstPCMFrame = ((ma_uint64)pFlac->currentFLACFrame.header.flacFrameNumber) * pFlac->maxBlockSizeInPCMFrames; @@ -88124,7 +88124,7 @@ static void ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(ma_dr_flac* pF static ma_bool32 ma_dr_flac__seek_to_first_frame(ma_dr_flac* pFlac) { ma_bool32 result; - MA_DR_FLAC_ASSERT(pFlac != NULL); + MA_DR_FLAC_ASSERT(pFlac != nullptr); result = ma_dr_flac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes); MA_DR_FLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame)); pFlac->currentPCMFrame = 0; @@ -88132,7 +88132,7 @@ static ma_bool32 ma_dr_flac__seek_to_first_frame(ma_dr_flac* pFlac) } static MA_INLINE ma_result ma_dr_flac__seek_to_next_flac_frame(ma_dr_flac* pFlac) { - MA_DR_FLAC_ASSERT(pFlac != NULL); + MA_DR_FLAC_ASSERT(pFlac != nullptr); return ma_dr_flac__seek_flac_frame(pFlac); } static ma_uint64 ma_dr_flac__seek_forward_by_pcm_frames(ma_dr_flac* pFlac, ma_uint64 pcmFramesToSeek) @@ -88162,7 +88162,7 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__brute_force(ma_dr_flac* pFlac, m { ma_bool32 isMidFrame = MA_FALSE; ma_uint64 runningPCMFrameCount; - MA_DR_FLAC_ASSERT(pFlac != NULL); + MA_DR_FLAC_ASSERT(pFlac != nullptr); if (pcmFrameIndex >= pFlac->currentPCMFrame) { runningPCMFrameCount = pFlac->currentPCMFrame; if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) { @@ -88234,8 +88234,8 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__brute_force(ma_dr_flac* pFlac, m #define MA_DR_FLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO 0.6f static ma_bool32 ma_dr_flac__seek_to_approximate_flac_frame_to_byte(ma_dr_flac* pFlac, ma_uint64 targetByte, ma_uint64 rangeLo, ma_uint64 rangeHi, ma_uint64* pLastSuccessfulSeekOffset) { - MA_DR_FLAC_ASSERT(pFlac != NULL); - MA_DR_FLAC_ASSERT(pLastSuccessfulSeekOffset != NULL); + MA_DR_FLAC_ASSERT(pFlac != nullptr); + MA_DR_FLAC_ASSERT(pLastSuccessfulSeekOffset != nullptr); MA_DR_FLAC_ASSERT(targetByte >= rangeLo); MA_DR_FLAC_ASSERT(targetByte <= rangeHi); *pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes; @@ -88270,7 +88270,7 @@ static ma_bool32 ma_dr_flac__seek_to_approximate_flac_frame_to_byte(ma_dr_flac* return MA_FALSE; } } - ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL); + ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, nullptr); MA_DR_FLAC_ASSERT(targetByte <= rangeHi); *pLastSuccessfulSeekOffset = targetByte; return MA_TRUE; @@ -88383,8 +88383,8 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__seek_table(ma_dr_flac* pFlac, ma ma_bool32 isMidFrame = MA_FALSE; ma_uint64 runningPCMFrameCount; ma_uint32 iSeekpoint; - MA_DR_FLAC_ASSERT(pFlac != NULL); - if (pFlac->pSeekpoints == NULL || pFlac->seekpointCount == 0) { + MA_DR_FLAC_ASSERT(pFlac != nullptr); + if (pFlac->pSeekpoints == nullptr || pFlac->seekpointCount == 0) { return MA_FALSE; } if (pFlac->pSeekpoints[0].firstPCMFrame > pcmFrameIndex) { @@ -88419,7 +88419,7 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__seek_table(ma_dr_flac* pFlac, ma } if (ma_dr_flac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) { if (ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { - ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL); + ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, nullptr); if (ma_dr_flac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi)) { return MA_TRUE; } @@ -88599,45 +88599,45 @@ static void ma_dr_flac__free_default(void* p, void* pUserData) } static void* ma_dr_flac__malloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks == NULL) { - return NULL; + if (pAllocationCallbacks == nullptr) { + return nullptr; } - if (pAllocationCallbacks->onMalloc != NULL) { + if (pAllocationCallbacks->onMalloc != nullptr) { return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData); } - if (pAllocationCallbacks->onRealloc != NULL) { - return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData); + if (pAllocationCallbacks->onRealloc != nullptr) { + return pAllocationCallbacks->onRealloc(nullptr, sz, pAllocationCallbacks->pUserData); } - return NULL; + return nullptr; } static void* ma_dr_flac__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks == NULL) { - return NULL; + if (pAllocationCallbacks == nullptr) { + return nullptr; } - if (pAllocationCallbacks->onRealloc != NULL) { + if (pAllocationCallbacks->onRealloc != nullptr) { return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData); } - if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) { + if (pAllocationCallbacks->onMalloc != nullptr && pAllocationCallbacks->onFree != nullptr) { void* p2; p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData); - if (p2 == NULL) { - return NULL; + if (p2 == nullptr) { + return nullptr; } - if (p != NULL) { + if (p != nullptr) { MA_DR_FLAC_COPY_MEMORY(p2, p, szOld); pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } return p2; } - return NULL; + return nullptr; } static void ma_dr_flac__free_from_callbacks(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { - if (p == NULL || pAllocationCallbacks == NULL) { + if (p == nullptr || pAllocationCallbacks == nullptr) { return; } - if (pAllocationCallbacks->onFree != NULL) { + if (pAllocationCallbacks->onFree != nullptr) { pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } } @@ -88659,7 +88659,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea metadata.type = blockType; metadata.rawDataSize = 0; metadata.rawDataOffset = runningFilePos; - metadata.pRawData = NULL; + metadata.pRawData = nullptr; switch (blockType) { case MA_DR_FLAC_METADATA_BLOCK_TYPE_APPLICATION: @@ -88669,7 +88669,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea } if (onMeta) { void* pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); - if (pRawData == NULL) { + if (pRawData == nullptr) { return MA_FALSE; } if (onRead(pUserData, pRawData, blockSize) != blockSize) { @@ -88695,7 +88695,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea void* pRawData; seekpointCount = blockSize/MA_DR_FLAC_SEEKPOINT_SIZE_IN_BYTES; pRawData = ma_dr_flac__malloc_from_callbacks(seekpointCount * sizeof(ma_dr_flac_seekpoint), pAllocationCallbacks); - if (pRawData == NULL) { + if (pRawData == nullptr) { return MA_FALSE; } for (iSeekpoint = 0; iSeekpoint < seekpointCount; ++iSeekpoint) { @@ -88727,7 +88727,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea const char* pRunningDataEnd; ma_uint32 i; pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); - if (pRawData == NULL) { + if (pRawData == nullptr) { return MA_FALSE; } if (onRead(pUserData, pRawData, blockSize) != blockSize) { @@ -88781,7 +88781,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea ma_uint8 iIndex; void* pTrackData; pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); - if (pRawData == NULL) { + if (pRawData == nullptr) { return MA_FALSE; } if (onRead(pUserData, pRawData, blockSize) != blockSize) { @@ -88796,7 +88796,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea metadata.data.cuesheet.leadInSampleCount = ma_dr_flac__be2host_64(*(const ma_uint64*)pRunningData); pRunningData += 8; metadata.data.cuesheet.isCD = (pRunningData[0] & 0x80) != 0; pRunningData += 259; metadata.data.cuesheet.trackCount = pRunningData[0]; pRunningData += 1; - metadata.data.cuesheet.pTrackData = NULL; + metadata.data.cuesheet.pTrackData = nullptr; { const char* pRunningDataSaved = pRunningData; bufferSize = metadata.data.cuesheet.trackCount * MA_DR_FLAC_CUESHEET_TRACK_SIZE_IN_BYTES; @@ -88823,7 +88823,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea { char* pRunningTrackData; pTrackData = ma_dr_flac__malloc_from_callbacks(bufferSize, pAllocationCallbacks); - if (pTrackData == NULL) { + if (pTrackData == nullptr) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } @@ -88847,10 +88847,10 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea metadata.data.cuesheet.pTrackData = pTrackData; } ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); - pRawData = NULL; + pRawData = nullptr; onMeta(pUserDataMD, &metadata); ma_dr_flac__free_from_callbacks(pTrackData, pAllocationCallbacks); - pTrackData = NULL; + pTrackData = nullptr; } } break; case MA_DR_FLAC_METADATA_BLOCK_TYPE_PICTURE: @@ -88861,9 +88861,9 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea if (onMeta) { ma_bool32 result = MA_TRUE; ma_uint32 blockSizeRemaining = blockSize; - char* pMime = NULL; - char* pDescription = NULL; - void* pPictureData = NULL; + char* pMime = nullptr; + char* pDescription = nullptr; + void* pPictureData = nullptr; if (blockSizeRemaining < 4 || onRead(pUserData, &metadata.data.picture.type, 4) != 4) { result = MA_FALSE; goto done_flac; @@ -88877,7 +88877,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea blockSizeRemaining -= 4; metadata.data.picture.mimeLength = ma_dr_flac__be2host_32(metadata.data.picture.mimeLength); pMime = (char*)ma_dr_flac__malloc_from_callbacks(metadata.data.picture.mimeLength + 1, pAllocationCallbacks); - if (pMime == NULL) { + if (pMime == nullptr) { result = MA_FALSE; goto done_flac; } @@ -88895,7 +88895,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea blockSizeRemaining -= 4; metadata.data.picture.descriptionLength = ma_dr_flac__be2host_32(metadata.data.picture.descriptionLength); pDescription = (char*)ma_dr_flac__malloc_from_callbacks(metadata.data.picture.descriptionLength + 1, pAllocationCallbacks); - if (pDescription == NULL) { + if (pDescription == nullptr) { result = MA_FALSE; goto done_flac; } @@ -88943,7 +88943,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea metadata.data.picture.pictureDataOffset = runningFilePos + (blockSize - blockSizeRemaining); #ifndef MA_DR_FLAC_NO_PICTURE_METADATA_MALLOC pPictureData = ma_dr_flac__malloc_from_callbacks(metadata.data.picture.pictureDataSize, pAllocationCallbacks); - if (pPictureData != NULL) { + if (pPictureData != nullptr) { if (onRead(pUserData, pPictureData, metadata.data.picture.pictureDataSize) != metadata.data.picture.pictureDataSize) { result = MA_FALSE; goto done_flac; @@ -88959,7 +88959,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea blockSizeRemaining -= metadata.data.picture.pictureDataSize; (void)blockSizeRemaining; metadata.data.picture.pPictureData = (const ma_uint8*)pPictureData; - if (metadata.data.picture.pictureDataOffset != 0 || metadata.data.picture.pPictureData != NULL) { + if (metadata.data.picture.pictureDataOffset != 0 || metadata.data.picture.pPictureData != nullptr) { onMeta(pUserDataMD, &metadata); } else { } @@ -88995,7 +88995,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea { if (onMeta) { void* pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); - if (pRawData != NULL) { + if (pRawData != nullptr) { if (onRead(pUserData, pRawData, blockSize) != blockSize) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; @@ -89012,7 +89012,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea } } break; } - if (onMeta == NULL && blockSize > 0) { + if (onMeta == nullptr && blockSize > 0) { if (!onSeek(pUserData, blockSize, MA_DR_FLAC_SEEK_CUR)) { isLastBlock = MA_TRUE; } @@ -89070,7 +89070,7 @@ static ma_bool32 ma_dr_flac__init_private__native(ma_dr_flac_init_info* pInit, m if (onMeta) { ma_dr_flac_metadata metadata; metadata.type = MA_DR_FLAC_METADATA_BLOCK_TYPE_STREAMINFO; - metadata.pRawData = NULL; + metadata.pRawData = nullptr; metadata.rawDataSize = 0; metadata.data.streaminfo = streaminfo; onMeta(pUserDataMD, &metadata); @@ -89430,8 +89430,8 @@ static size_t ma_dr_flac__on_read_ogg(void* pUserData, void* bufferOut, size_t b ma_dr_flac_oggbs* oggbs = (ma_dr_flac_oggbs*)pUserData; ma_uint8* pRunningBufferOut = (ma_uint8*)bufferOut; size_t bytesRead = 0; - MA_DR_FLAC_ASSERT(oggbs != NULL); - MA_DR_FLAC_ASSERT(pRunningBufferOut != NULL); + MA_DR_FLAC_ASSERT(oggbs != nullptr); + MA_DR_FLAC_ASSERT(pRunningBufferOut != nullptr); while (bytesRead < bytesToRead) { size_t bytesRemainingToRead = bytesToRead - bytesRead; if (oggbs->bytesRemainingInPage >= bytesRemainingToRead) { @@ -89457,7 +89457,7 @@ static ma_bool32 ma_dr_flac__on_seek_ogg(void* pUserData, int offset, ma_dr_flac { ma_dr_flac_oggbs* oggbs = (ma_dr_flac_oggbs*)pUserData; int bytesSeeked = 0; - MA_DR_FLAC_ASSERT(oggbs != NULL); + MA_DR_FLAC_ASSERT(oggbs != nullptr); MA_DR_FLAC_ASSERT(offset >= 0); if (origin == MA_DR_FLAC_SEEK_SET) { if (!ma_dr_flac_oggbs__seek_physical(oggbs, (int)oggbs->firstBytePos, MA_DR_FLAC_SEEK_SET)) { @@ -89504,7 +89504,7 @@ static ma_bool32 ma_dr_flac_ogg__seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64 ma_uint64 runningGranulePosition; ma_uint64 runningFrameBytePos; ma_uint64 runningPCMFrameCount; - MA_DR_FLAC_ASSERT(oggbs != NULL); + MA_DR_FLAC_ASSERT(oggbs != nullptr); originalBytePos = oggbs->currentBytePos; if (!ma_dr_flac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes)) { return MA_FALSE; @@ -89655,7 +89655,7 @@ static ma_bool32 ma_dr_flac__init_private__ogg(ma_dr_flac_init_info* pInit, ma_d if (onMeta) { ma_dr_flac_metadata metadata; metadata.type = MA_DR_FLAC_METADATA_BLOCK_TYPE_STREAMINFO; - metadata.pRawData = NULL; + metadata.pRawData = nullptr; metadata.rawDataSize = 0; metadata.data.streaminfo = streaminfo; onMeta(pUserDataMD, &metadata); @@ -89700,7 +89700,7 @@ static ma_bool32 ma_dr_flac__init_private(ma_dr_flac_init_info* pInit, ma_dr_fla { ma_bool32 relaxed; ma_uint8 id[4]; - if (pInit == NULL || onRead == NULL || onSeek == NULL) { + if (pInit == nullptr || onRead == nullptr || onSeek == nullptr) { return MA_FALSE; } MA_DR_FLAC_ZERO_MEMORY(pInit, sizeof(*pInit)); @@ -89766,8 +89766,8 @@ static ma_bool32 ma_dr_flac__init_private(ma_dr_flac_init_info* pInit, ma_dr_fla } static void ma_dr_flac__init_from_info(ma_dr_flac* pFlac, const ma_dr_flac_init_info* pInit) { - MA_DR_FLAC_ASSERT(pFlac != NULL); - MA_DR_FLAC_ASSERT(pInit != NULL); + MA_DR_FLAC_ASSERT(pFlac != nullptr); + MA_DR_FLAC_ASSERT(pInit != nullptr); MA_DR_FLAC_ZERO_MEMORY(pFlac, sizeof(*pFlac)); pFlac->bs = pInit->bs; pFlac->onMeta = pInit->onMeta; @@ -89786,7 +89786,7 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on ma_uint32 wholeSIMDVectorCountPerChannel; ma_uint32 decodedSamplesAllocationSize; #ifndef MA_DR_FLAC_NO_OGG - ma_dr_flac_oggbs* pOggbs = NULL; + ma_dr_flac_oggbs* pOggbs = nullptr; #endif ma_uint64 firstFramePos; ma_uint64 seektablePos; @@ -89795,15 +89795,15 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on ma_dr_flac* pFlac; ma_dr_flac__init_cpu_caps(); if (!ma_dr_flac__init_private(&init, onRead, onSeek, onTell, onMeta, container, pUserData, pUserDataMD)) { - return NULL; + return nullptr; } - if (pAllocationCallbacks != NULL) { + if (pAllocationCallbacks != nullptr) { allocationCallbacks = *pAllocationCallbacks; - if (allocationCallbacks.onFree == NULL || (allocationCallbacks.onMalloc == NULL && allocationCallbacks.onRealloc == NULL)) { - return NULL; + if (allocationCallbacks.onFree == nullptr || (allocationCallbacks.onMalloc == nullptr && allocationCallbacks.onRealloc == nullptr)) { + return nullptr; } } else { - allocationCallbacks.pUserData = NULL; + allocationCallbacks.pUserData = nullptr; allocationCallbacks.onMalloc = ma_dr_flac__malloc_default; allocationCallbacks.onRealloc = ma_dr_flac__realloc_default; allocationCallbacks.onFree = ma_dr_flac__free_default; @@ -89821,8 +89821,8 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on if (init.container == ma_dr_flac_container_ogg) { allocationSize += sizeof(ma_dr_flac_oggbs); pOggbs = (ma_dr_flac_oggbs*)ma_dr_flac__malloc_from_callbacks(sizeof(*pOggbs), &allocationCallbacks); - if (pOggbs == NULL) { - return NULL; + if (pOggbs == nullptr) { + return nullptr; } MA_DR_FLAC_ZERO_MEMORY(pOggbs, sizeof(*pOggbs)); pOggbs->onRead = onRead; @@ -89856,16 +89856,16 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on #ifndef MA_DR_FLAC_NO_OGG ma_dr_flac__free_from_callbacks(pOggbs, &allocationCallbacks); #endif - return NULL; + return nullptr; } allocationSize += seekpointCount * sizeof(ma_dr_flac_seekpoint); } pFlac = (ma_dr_flac*)ma_dr_flac__malloc_from_callbacks(allocationSize, &allocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { #ifndef MA_DR_FLAC_NO_OGG ma_dr_flac__free_from_callbacks(pOggbs, &allocationCallbacks); #endif - return NULL; + return nullptr; } ma_dr_flac__init_from_info(pFlac, &init); pFlac->allocationCallbacks = allocationCallbacks; @@ -89875,7 +89875,7 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on ma_dr_flac_oggbs* pInternalOggbs = (ma_dr_flac_oggbs*)((ma_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + (seekpointCount * sizeof(ma_dr_flac_seekpoint))); MA_DR_FLAC_COPY_MEMORY(pInternalOggbs, pOggbs, sizeof(*pOggbs)); ma_dr_flac__free_from_callbacks(pOggbs, &allocationCallbacks); - pOggbs = NULL; + pOggbs = nullptr; pFlac->bs.onRead = ma_dr_flac__on_read_ogg; pFlac->bs.onSeek = ma_dr_flac__on_seek_ogg; pFlac->bs.onTell = ma_dr_flac__on_tell_ogg; @@ -89887,7 +89887,7 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on #ifndef MA_DR_FLAC_NO_OGG if (init.container == ma_dr_flac_container_ogg) { - pFlac->pSeekpoints = NULL; + pFlac->pSeekpoints = nullptr; pFlac->seekpointCount = 0; } else @@ -89896,8 +89896,8 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on if (seektablePos != 0) { pFlac->seekpointCount = seekpointCount; pFlac->pSeekpoints = (ma_dr_flac_seekpoint*)((ma_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize); - MA_DR_FLAC_ASSERT(pFlac->bs.onSeek != NULL); - MA_DR_FLAC_ASSERT(pFlac->bs.onRead != NULL); + MA_DR_FLAC_ASSERT(pFlac->bs.onSeek != nullptr); + MA_DR_FLAC_ASSERT(pFlac->bs.onRead != nullptr); if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, MA_DR_FLAC_SEEK_SET)) { ma_uint32 iSeekpoint; for (iSeekpoint = 0; iSeekpoint < seekpointCount; iSeekpoint += 1) { @@ -89906,17 +89906,17 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = ma_dr_flac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset); pFlac->pSeekpoints[iSeekpoint].pcmFrameCount = ma_dr_flac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount); } else { - pFlac->pSeekpoints = NULL; + pFlac->pSeekpoints = nullptr; pFlac->seekpointCount = 0; break; } } if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, MA_DR_FLAC_SEEK_SET)) { ma_dr_flac__free_from_callbacks(pFlac, &allocationCallbacks); - return NULL; + return nullptr; } } else { - pFlac->pSeekpoints = NULL; + pFlac->pSeekpoints = nullptr; pFlac->seekpointCount = 0; } } @@ -89931,12 +89931,12 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on if (result == MA_CRC_MISMATCH) { if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { ma_dr_flac__free_from_callbacks(pFlac, &allocationCallbacks); - return NULL; + return nullptr; } continue; } else { ma_dr_flac__free_from_callbacks(pFlac, &allocationCallbacks); - return NULL; + return nullptr; } } } @@ -89966,8 +89966,8 @@ static ma_bool32 ma_dr_flac__on_tell_stdio(void* pUserData, ma_int64* pCursor) { FILE* pFileStdio = (FILE*)pUserData; ma_int64 result; - MA_DR_FLAC_ASSERT(pFileStdio != NULL); - MA_DR_FLAC_ASSERT(pCursor != NULL); + MA_DR_FLAC_ASSERT(pFileStdio != nullptr); + MA_DR_FLAC_ASSERT(pCursor != nullptr); #if defined(_WIN32) && !defined(NXDK) #if defined(_MSC_VER) && _MSC_VER > 1200 result = _ftelli64(pFileStdio); @@ -89985,12 +89985,12 @@ MA_API ma_dr_flac* ma_dr_flac_open_file(const char* pFileName, const ma_allocati ma_dr_flac* pFlac; FILE* pFile; if (ma_fopen(&pFile, pFileName, "rb") != MA_SUCCESS) { - return NULL; + return nullptr; } pFlac = ma_dr_flac_open(ma_dr_flac__on_read_stdio, ma_dr_flac__on_seek_stdio, ma_dr_flac__on_tell_stdio, (void*)pFile, pAllocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { fclose(pFile); - return NULL; + return nullptr; } return pFlac; } @@ -90000,12 +90000,12 @@ MA_API ma_dr_flac* ma_dr_flac_open_file_w(const wchar_t* pFileName, const ma_all ma_dr_flac* pFlac; FILE* pFile; if (ma_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != MA_SUCCESS) { - return NULL; + return nullptr; } pFlac = ma_dr_flac_open(ma_dr_flac__on_read_stdio, ma_dr_flac__on_seek_stdio, ma_dr_flac__on_tell_stdio, (void*)pFile, pAllocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { fclose(pFile); - return NULL; + return nullptr; } return pFlac; } @@ -90015,10 +90015,10 @@ MA_API ma_dr_flac* ma_dr_flac_open_file_with_metadata(const char* pFileName, ma_ ma_dr_flac* pFlac; FILE* pFile; if (ma_fopen(&pFile, pFileName, "rb") != MA_SUCCESS) { - return NULL; + return nullptr; } pFlac = ma_dr_flac_open_with_metadata_private(ma_dr_flac__on_read_stdio, ma_dr_flac__on_seek_stdio, ma_dr_flac__on_tell_stdio, onMeta, ma_dr_flac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { fclose(pFile); return pFlac; } @@ -90030,10 +90030,10 @@ MA_API ma_dr_flac* ma_dr_flac_open_file_with_metadata_w(const wchar_t* pFileName ma_dr_flac* pFlac; FILE* pFile; if (ma_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != MA_SUCCESS) { - return NULL; + return nullptr; } pFlac = ma_dr_flac_open_with_metadata_private(ma_dr_flac__on_read_stdio, ma_dr_flac__on_seek_stdio, ma_dr_flac__on_tell_stdio, onMeta, ma_dr_flac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks); - if (pFlac == NULL) { + if (pFlac == nullptr) { fclose(pFile); return pFlac; } @@ -90045,7 +90045,7 @@ static size_t ma_dr_flac__on_read_memory(void* pUserData, void* bufferOut, size_ { ma_dr_flac__memory_stream* memoryStream = (ma_dr_flac__memory_stream*)pUserData; size_t bytesRemaining; - MA_DR_FLAC_ASSERT(memoryStream != NULL); + MA_DR_FLAC_ASSERT(memoryStream != nullptr); MA_DR_FLAC_ASSERT(memoryStream->dataSize >= memoryStream->currentReadPos); bytesRemaining = memoryStream->dataSize - memoryStream->currentReadPos; if (bytesToRead > bytesRemaining) { @@ -90061,7 +90061,7 @@ static ma_bool32 ma_dr_flac__on_seek_memory(void* pUserData, int offset, ma_dr_f { ma_dr_flac__memory_stream* memoryStream = (ma_dr_flac__memory_stream*)pUserData; ma_int64 newCursor; - MA_DR_FLAC_ASSERT(memoryStream != NULL); + MA_DR_FLAC_ASSERT(memoryStream != nullptr); if (origin == MA_DR_FLAC_SEEK_SET) { newCursor = 0; } else if (origin == MA_DR_FLAC_SEEK_CUR) { @@ -90085,8 +90085,8 @@ static ma_bool32 ma_dr_flac__on_seek_memory(void* pUserData, int offset, ma_dr_f static ma_bool32 ma_dr_flac__on_tell_memory(void* pUserData, ma_int64* pCursor) { ma_dr_flac__memory_stream* memoryStream = (ma_dr_flac__memory_stream*)pUserData; - MA_DR_FLAC_ASSERT(memoryStream != NULL); - MA_DR_FLAC_ASSERT(pCursor != NULL); + MA_DR_FLAC_ASSERT(memoryStream != nullptr); + MA_DR_FLAC_ASSERT(pCursor != nullptr); *pCursor = (ma_int64)memoryStream->currentReadPos; return MA_TRUE; } @@ -90098,8 +90098,8 @@ MA_API ma_dr_flac* ma_dr_flac_open_memory(const void* pData, size_t dataSize, co memoryStream.dataSize = dataSize; memoryStream.currentReadPos = 0; pFlac = ma_dr_flac_open(ma_dr_flac__on_read_memory, ma_dr_flac__on_seek_memory, ma_dr_flac__on_tell_memory, &memoryStream, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } pFlac->memoryStream = memoryStream; #ifndef MA_DR_FLAC_NO_OGG @@ -90123,8 +90123,8 @@ MA_API ma_dr_flac* ma_dr_flac_open_memory_with_metadata(const void* pData, size_ memoryStream.dataSize = dataSize; memoryStream.currentReadPos = 0; pFlac = ma_dr_flac_open_with_metadata_private(ma_dr_flac__on_read_memory, ma_dr_flac__on_seek_memory, ma_dr_flac__on_tell_memory, onMeta, ma_dr_flac_container_unknown, &memoryStream, pUserData, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } pFlac->memoryStream = memoryStream; #ifndef MA_DR_FLAC_NO_OGG @@ -90142,11 +90142,11 @@ MA_API ma_dr_flac* ma_dr_flac_open_memory_with_metadata(const void* pData, size_ } MA_API ma_dr_flac* ma_dr_flac_open(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_tell_proc onTell, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_flac_open_with_metadata_private(onRead, onSeek, onTell, NULL, ma_dr_flac_container_unknown, pUserData, pUserData, pAllocationCallbacks); + return ma_dr_flac_open_with_metadata_private(onRead, onSeek, onTell, nullptr, ma_dr_flac_container_unknown, pUserData, pUserData, pAllocationCallbacks); } MA_API ma_dr_flac* ma_dr_flac_open_relaxed(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_tell_proc onTell, ma_dr_flac_container container, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_flac_open_with_metadata_private(onRead, onSeek, onTell, NULL, container, pUserData, pUserData, pAllocationCallbacks); + return ma_dr_flac_open_with_metadata_private(onRead, onSeek, onTell, nullptr, container, pUserData, pUserData, pAllocationCallbacks); } MA_API ma_dr_flac* ma_dr_flac_open_with_metadata(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_tell_proc onTell, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { @@ -90158,7 +90158,7 @@ MA_API ma_dr_flac* ma_dr_flac_open_with_metadata_relaxed(ma_dr_flac_read_proc on } MA_API void ma_dr_flac_close(ma_dr_flac* pFlac) { - if (pFlac == NULL) { + if (pFlac == nullptr) { return; } #ifndef MA_DR_FLAC_NO_STDIO @@ -90783,10 +90783,10 @@ MA_API ma_uint64 ma_dr_flac_read_pcm_frames_s32(ma_dr_flac* pFlac, ma_uint64 fra { ma_uint64 framesRead; ma_uint32 unusedBitsPerSample; - if (pFlac == NULL || framesToRead == 0) { + if (pFlac == nullptr || framesToRead == 0) { return 0; } - if (pBufferOut == NULL) { + if (pBufferOut == nullptr) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, framesToRead); } MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 32); @@ -91520,10 +91520,10 @@ MA_API ma_uint64 ma_dr_flac_read_pcm_frames_s16(ma_dr_flac* pFlac, ma_uint64 fra { ma_uint64 framesRead; ma_uint32 unusedBitsPerSample; - if (pFlac == NULL || framesToRead == 0) { + if (pFlac == nullptr || framesToRead == 0) { return 0; } - if (pBufferOut == NULL) { + if (pBufferOut == nullptr) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, framesToRead); } MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 32); @@ -92247,10 +92247,10 @@ MA_API ma_uint64 ma_dr_flac_read_pcm_frames_f32(ma_dr_flac* pFlac, ma_uint64 fra { ma_uint64 framesRead; ma_uint32 unusedBitsPerSample; - if (pFlac == NULL || framesToRead == 0) { + if (pFlac == nullptr || framesToRead == 0) { return 0; } - if (pBufferOut == NULL) { + if (pBufferOut == nullptr) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, framesToRead); } MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 32); @@ -92312,7 +92312,7 @@ MA_API ma_uint64 ma_dr_flac_read_pcm_frames_f32(ma_dr_flac* pFlac, ma_uint64 fra } MA_API ma_bool32 ma_dr_flac_seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64 pcmFrameIndex) { - if (pFlac == NULL) { + if (pFlac == nullptr) { return MA_FALSE; } if (pFlac->currentPCMFrame == pcmFrameIndex) { @@ -92380,18 +92380,18 @@ MA_API ma_bool32 ma_dr_flac_seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64 pcmFr #define MA_DR_FLAC_DEFINE_FULL_READ_AND_CLOSE(extension, type) \ static type* ma_dr_flac__full_read_and_close_ ## extension (ma_dr_flac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalPCMFrameCountOut)\ { \ - type* pSampleData = NULL; \ + type* pSampleData = nullptr; \ ma_uint64 totalPCMFrameCount; \ type buffer[4096]; \ ma_uint64 pcmFramesRead; \ size_t sampleDataBufferSize = sizeof(buffer); \ \ - MA_DR_FLAC_ASSERT(pFlac != NULL); \ + MA_DR_FLAC_ASSERT(pFlac != nullptr); \ \ totalPCMFrameCount = 0; \ \ pSampleData = (type*)ma_dr_flac__malloc_from_callbacks(sampleDataBufferSize, &pFlac->allocationCallbacks); \ - if (pSampleData == NULL) { \ + if (pSampleData == nullptr) { \ goto on_error; \ } \ \ @@ -92402,7 +92402,7 @@ static type* ma_dr_flac__full_read_and_close_ ## extension (ma_dr_flac* pFlac, u \ newSampleDataBufferSize = sampleDataBufferSize * 2; \ pNewSampleData = (type*)ma_dr_flac__realloc_from_callbacks(pSampleData, newSampleDataBufferSize, sampleDataBufferSize, &pFlac->allocationCallbacks); \ - if (pNewSampleData == NULL) { \ + if (pNewSampleData == nullptr) { \ ma_dr_flac__free_from_callbacks(pSampleData, &pFlac->allocationCallbacks); \ goto on_error; \ } \ @@ -92427,7 +92427,7 @@ static type* ma_dr_flac__full_read_and_close_ ## extension (ma_dr_flac* pFlac, u \ on_error: \ ma_dr_flac_close(pFlac); \ - return NULL; \ + return nullptr; \ } MA_DR_FLAC_DEFINE_FULL_READ_AND_CLOSE(s32, ma_int32) MA_DR_FLAC_DEFINE_FULL_READ_AND_CLOSE(s16, ma_int16) @@ -92445,8 +92445,8 @@ MA_API ma_int32* ma_dr_flac_open_and_read_pcm_frames_s32(ma_dr_flac_read_proc on *totalPCMFrameCountOut = 0; } pFlac = ma_dr_flac_open(onRead, onSeek, onTell, pUserData, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_s32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut); } @@ -92463,8 +92463,8 @@ MA_API ma_int16* ma_dr_flac_open_and_read_pcm_frames_s16(ma_dr_flac_read_proc on *totalPCMFrameCountOut = 0; } pFlac = ma_dr_flac_open(onRead, onSeek, onTell, pUserData, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_s16(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut); } @@ -92481,8 +92481,8 @@ MA_API float* ma_dr_flac_open_and_read_pcm_frames_f32(ma_dr_flac_read_proc onRea *totalPCMFrameCountOut = 0; } pFlac = ma_dr_flac_open(onRead, onSeek, onTell, pUserData, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_f32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut); } @@ -92500,8 +92500,8 @@ MA_API ma_int32* ma_dr_flac_open_file_and_read_pcm_frames_s32(const char* filena *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_file(filename, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount); } @@ -92518,8 +92518,8 @@ MA_API ma_int16* ma_dr_flac_open_file_and_read_pcm_frames_s16(const char* filena *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_file(filename, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount); } @@ -92536,8 +92536,8 @@ MA_API float* ma_dr_flac_open_file_and_read_pcm_frames_f32(const char* filename, *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_file(filename, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount); } @@ -92555,8 +92555,8 @@ MA_API ma_int32* ma_dr_flac_open_memory_and_read_pcm_frames_s32(const void* data *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_memory(data, dataSize, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount); } @@ -92573,8 +92573,8 @@ MA_API ma_int16* ma_dr_flac_open_memory_and_read_pcm_frames_s16(const void* data *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_memory(data, dataSize, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount); } @@ -92591,22 +92591,22 @@ MA_API float* ma_dr_flac_open_memory_and_read_pcm_frames_f32(const void* data, s *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_memory(data, dataSize, pAllocationCallbacks); - if (pFlac == NULL) { - return NULL; + if (pFlac == nullptr) { + return nullptr; } return ma_dr_flac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount); } MA_API void ma_dr_flac_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks != NULL) { + if (pAllocationCallbacks != nullptr) { ma_dr_flac__free_from_callbacks(p, pAllocationCallbacks); } else { - ma_dr_flac__free_default(p, NULL); + ma_dr_flac__free_default(p, nullptr); } } MA_API void ma_dr_flac_init_vorbis_comment_iterator(ma_dr_flac_vorbis_comment_iterator* pIter, ma_uint32 commentCount, const void* pComments) { - if (pIter == NULL) { + if (pIter == nullptr) { return; } pIter->countRemaining = commentCount; @@ -92619,8 +92619,8 @@ MA_API const char* ma_dr_flac_next_vorbis_comment(ma_dr_flac_vorbis_comment_iter if (pCommentLengthOut) { *pCommentLengthOut = 0; } - if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) { - return NULL; + if (pIter == nullptr || pIter->countRemaining == 0 || pIter->pRunningData == nullptr) { + return nullptr; } length = ma_dr_flac__le2host_32_ptr_unaligned(pIter->pRunningData); pIter->pRunningData += 4; @@ -92634,7 +92634,7 @@ MA_API const char* ma_dr_flac_next_vorbis_comment(ma_dr_flac_vorbis_comment_iter } MA_API void ma_dr_flac_init_cuesheet_track_iterator(ma_dr_flac_cuesheet_track_iterator* pIter, ma_uint32 trackCount, const void* pTrackData) { - if (pIter == NULL) { + if (pIter == nullptr) { return; } pIter->countRemaining = trackCount; @@ -92646,7 +92646,7 @@ MA_API ma_bool32 ma_dr_flac_next_cuesheet_track(ma_dr_flac_cuesheet_track_iterat const char* pRunningData; ma_uint64 offsetHi; ma_uint64 offsetLo; - if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) { + if (pIter == nullptr || pIter->countRemaining == 0 || pIter->pRunningData == nullptr) { return MA_FALSE; } pRunningData = pIter->pRunningData; @@ -94289,7 +94289,7 @@ MA_API int ma_dr_mp3dec_decode_frame(ma_dr_mp3dec *dec, const ma_uint8 *mp3, int return 0; } success = ma_dr_mp3_L3_restore_reservoir(dec, bs_frame, &dec->scratch, main_data_begin); - if (success && pcm != NULL) + if (success && pcm != nullptr) { for (igr = 0; igr < (MA_DR_MP3_HDR_TEST_MPEG1(hdr) ? 2 : 1); igr++, pcm = MA_DR_MP3_OFFSET_PTR(pcm, sizeof(ma_dr_mp3d_sample_t)*576*info->channels)) { @@ -94305,7 +94305,7 @@ MA_API int ma_dr_mp3dec_decode_frame(ma_dr_mp3dec *dec, const ma_uint8 *mp3, int return 0; #else ma_dr_mp3_L12_scale_info sci[1]; - if (pcm == NULL) { + if (pcm == nullptr) { return ma_dr_mp3_hdr_frame_samples(hdr); } ma_dr_mp3_L12_read_scale_info(hdr, bs_frame, sci); @@ -94438,55 +94438,55 @@ static void ma_dr_mp3__free_default(void* p, void* pUserData) } static void* ma_dr_mp3__malloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks == NULL) { - return NULL; + if (pAllocationCallbacks == nullptr) { + return nullptr; } - if (pAllocationCallbacks->onMalloc != NULL) { + if (pAllocationCallbacks->onMalloc != nullptr) { return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData); } - if (pAllocationCallbacks->onRealloc != NULL) { - return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData); + if (pAllocationCallbacks->onRealloc != nullptr) { + return pAllocationCallbacks->onRealloc(nullptr, sz, pAllocationCallbacks->pUserData); } - return NULL; + return nullptr; } static void* ma_dr_mp3__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks == NULL) { - return NULL; + if (pAllocationCallbacks == nullptr) { + return nullptr; } - if (pAllocationCallbacks->onRealloc != NULL) { + if (pAllocationCallbacks->onRealloc != nullptr) { return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData); } - if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) { + if (pAllocationCallbacks->onMalloc != nullptr && pAllocationCallbacks->onFree != nullptr) { void* p2; p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData); - if (p2 == NULL) { - return NULL; + if (p2 == nullptr) { + return nullptr; } - if (p != NULL) { + if (p != nullptr) { MA_DR_MP3_COPY_MEMORY(p2, p, szOld); pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } return p2; } - return NULL; + return nullptr; } static void ma_dr_mp3__free_from_callbacks(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { - if (p == NULL || pAllocationCallbacks == NULL) { + if (p == nullptr || pAllocationCallbacks == nullptr) { return; } - if (pAllocationCallbacks->onFree != NULL) { + if (pAllocationCallbacks->onFree != nullptr) { pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } } static ma_allocation_callbacks ma_dr_mp3_copy_allocation_callbacks_or_defaults(const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks != NULL) { + if (pAllocationCallbacks != nullptr) { return *pAllocationCallbacks; } else { ma_allocation_callbacks allocationCallbacks; - allocationCallbacks.pUserData = NULL; + allocationCallbacks.pUserData = nullptr; allocationCallbacks.onMalloc = ma_dr_mp3__malloc_default; allocationCallbacks.onRealloc = ma_dr_mp3__realloc_default; allocationCallbacks.onFree = ma_dr_mp3__free_default; @@ -94496,8 +94496,8 @@ static ma_allocation_callbacks ma_dr_mp3_copy_allocation_callbacks_or_defaults(c static size_t ma_dr_mp3__on_read(ma_dr_mp3* pMP3, void* pBufferOut, size_t bytesToRead) { size_t bytesRead; - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(pMP3->onRead != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(pMP3->onRead != nullptr); if (bytesToRead == 0) { return 0; } @@ -94507,8 +94507,8 @@ static size_t ma_dr_mp3__on_read(ma_dr_mp3* pMP3, void* pBufferOut, size_t bytes } static size_t ma_dr_mp3__on_read_clamped(ma_dr_mp3* pMP3, void* pBufferOut, size_t bytesToRead) { - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(pMP3->onRead != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(pMP3->onRead != nullptr); if (pMP3->streamLength == MA_UINT64_MAX) { return ma_dr_mp3__on_read(pMP3, pBufferOut, bytesToRead); } else { @@ -94572,8 +94572,8 @@ static void ma_dr_mp3__on_meta(ma_dr_mp3* pMP3, ma_dr_mp3_metadata_type type, co static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_dr_mp3d_sample_t* pPCMFrames, ma_dr_mp3dec_frame_info* pMP3FrameInfo, const ma_uint8** ppMP3FrameData) { ma_uint32 pcmFramesRead = 0; - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(pMP3->onRead != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(pMP3->onRead != nullptr); if (pMP3->atEnd) { return 0; } @@ -94581,7 +94581,7 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_d ma_dr_mp3dec_frame_info info; if (pMP3->dataSize < MA_DR_MP3_MIN_DATA_CHUNK_SIZE) { size_t bytesRead; - if (pMP3->pData != NULL) { + if (pMP3->pData != nullptr) { MA_DR_MP3_MOVE_MEMORY(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize); } pMP3->dataConsumed = 0; @@ -94590,7 +94590,7 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_d size_t newDataCap; newDataCap = MA_DR_MP3_DATA_CHUNK_SIZE; pNewData = (ma_uint8*)ma_dr_mp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks); - if (pNewData == NULL) { + if (pNewData == nullptr) { return 0; } pMP3->pData = pNewData; @@ -94609,9 +94609,9 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_d pMP3->atEnd = MA_TRUE; return 0; } - MA_DR_MP3_ASSERT(pMP3->pData != NULL); + MA_DR_MP3_ASSERT(pMP3->pData != nullptr); MA_DR_MP3_ASSERT(pMP3->dataCapacity > 0); - if (pMP3->pData == NULL) { + if (pMP3->pData == nullptr) { return 0; } pcmFramesRead = ma_dr_mp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info); @@ -94623,10 +94623,10 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_d pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead; pMP3->mp3FrameChannels = info.channels; pMP3->mp3FrameSampleRate = info.sample_rate; - if (pMP3FrameInfo != NULL) { + if (pMP3FrameInfo != nullptr) { *pMP3FrameInfo = info; } - if (ppMP3FrameData != NULL) { + if (ppMP3FrameData != nullptr) { *ppMP3FrameData = pMP3->pData + pMP3->dataConsumed - (size_t)info.frame_bytes; } break; @@ -94639,7 +94639,7 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_d size_t newDataCap; newDataCap = pMP3->dataCapacity + MA_DR_MP3_DATA_CHUNK_SIZE; pNewData = (ma_uint8*)ma_dr_mp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks); - if (pNewData == NULL) { + if (pNewData == nullptr) { return 0; } pMP3->pData = pNewData; @@ -94659,8 +94659,8 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__memory(ma_dr_mp3* pMP3, ma_dr_m { ma_uint32 pcmFramesRead = 0; ma_dr_mp3dec_frame_info info; - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(pMP3->memory.pData != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(pMP3->memory.pData != nullptr); if (pMP3->atEnd) { return 0; } @@ -94672,10 +94672,10 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__memory(ma_dr_mp3* pMP3, ma_dr_m pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead; pMP3->mp3FrameChannels = info.channels; pMP3->mp3FrameSampleRate = info.sample_rate; - if (pMP3FrameInfo != NULL) { + if (pMP3FrameInfo != nullptr) { *pMP3FrameInfo = info; } - if (ppMP3FrameData != NULL) { + if (ppMP3FrameData != nullptr) { *ppMP3FrameData = pMP3->memory.pData + pMP3->memory.currentReadPos; } break; @@ -94692,7 +94692,7 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__memory(ma_dr_mp3* pMP3, ma_dr_m } static ma_uint32 ma_dr_mp3_decode_next_frame_ex(ma_dr_mp3* pMP3, ma_dr_mp3d_sample_t* pPCMFrames, ma_dr_mp3dec_frame_info* pMP3FrameInfo, const ma_uint8** ppMP3FrameData) { - if (pMP3->memory.pData != NULL && pMP3->memory.dataSize > 0) { + if (pMP3->memory.pData != nullptr && pMP3->memory.dataSize > 0) { return ma_dr_mp3_decode_next_frame_ex__memory(pMP3, pPCMFrames, pMP3FrameInfo, ppMP3FrameData); } else { return ma_dr_mp3_decode_next_frame_ex__callbacks(pMP3, pPCMFrames, pMP3FrameInfo, ppMP3FrameData); @@ -94700,15 +94700,15 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex(ma_dr_mp3* pMP3, ma_dr_mp3d_samp } static ma_uint32 ma_dr_mp3_decode_next_frame(ma_dr_mp3* pMP3) { - MA_DR_MP3_ASSERT(pMP3 != NULL); - return ma_dr_mp3_decode_next_frame_ex(pMP3, (ma_dr_mp3d_sample_t*)pMP3->pcmFrames, NULL, NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + return ma_dr_mp3_decode_next_frame_ex(pMP3, (ma_dr_mp3d_sample_t*)pMP3->pcmFrames, nullptr, nullptr); } #if 0 static ma_uint32 ma_dr_mp3_seek_next_frame(ma_dr_mp3* pMP3) { ma_uint32 pcmFrameCount; - MA_DR_MP3_ASSERT(pMP3 != NULL); - pcmFrameCount = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL, NULL, NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + pcmFrameCount = ma_dr_mp3_decode_next_frame_ex(pMP3, nullptr, nullptr, nullptr); if (pcmFrameCount == 0) { return 0; } @@ -94724,8 +94724,8 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on const ma_uint8* pFirstFrameData; ma_uint32 firstFramePCMFrameCount; ma_uint32 detectedMP3FrameCount = 0xFFFFFFFF; - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(onRead != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(onRead != nullptr); ma_dr_mp3dec_init(&pMP3->decoder); pMP3->onRead = onRead; pMP3->onSeek = onSeek; @@ -94733,7 +94733,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on pMP3->pUserData = pUserData; pMP3->pUserDataMeta = pUserDataMeta; pMP3->allocationCallbacks = ma_dr_mp3_copy_allocation_callbacks_or_defaults(pAllocationCallbacks); - if (pMP3->allocationCallbacks.onFree == NULL || (pMP3->allocationCallbacks.onMalloc == NULL && pMP3->allocationCallbacks.onRealloc == NULL)) { + if (pMP3->allocationCallbacks.onFree == nullptr || (pMP3->allocationCallbacks.onMalloc == nullptr && pMP3->allocationCallbacks.onRealloc == nullptr)) { return MA_FALSE; } pMP3->streamCursor = 0; @@ -94743,7 +94743,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on pMP3->paddingInPCMFrames = 0; pMP3->totalPCMFrameCount = MA_UINT64_MAX; #if 1 - if (onSeek != NULL && onTell != NULL) { + if (onSeek != nullptr && onTell != nullptr) { if (onSeek(pUserData, 0, MA_DR_MP3_SEEK_END)) { ma_int64 streamLen; int streamEndOffset = 0; @@ -94754,7 +94754,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on if (onRead(pUserData, id3, 3) == 3 && id3[0] == 'T' && id3[1] == 'A' && id3[2] == 'G') { streamEndOffset -= 128; streamLen -= 128; - if (onMeta != NULL) { + if (onMeta != nullptr) { ma_uint8 tag[128]; tag[0] = 'T'; tag[1] = 'A'; tag[2] = 'G'; if (onRead(pUserData, tag + 3, 125) == 125) { @@ -94779,11 +94779,11 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on if (32 + tagSize < streamLen) { streamEndOffset -= 32 + tagSize; streamLen -= 32 + tagSize; - if (onMeta != NULL) { + if (onMeta != nullptr) { if (onSeek(pUserData, streamEndOffset, MA_DR_MP3_SEEK_END)) { size_t apeTagSize = (size_t)tagSize + 32; ma_uint8* pTagData = (ma_uint8*)ma_dr_mp3_malloc(apeTagSize, pAllocationCallbacks); - if (pTagData != NULL) { + if (pTagData != nullptr) { if (onRead(pUserData, pTagData, apeTagSize) == apeTagSize) { ma_dr_mp3__on_meta(pMP3, MA_DR_MP3_METADATA_TYPE_APE, pTagData, apeTagSize); } @@ -94801,7 +94801,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on return MA_FALSE; } pMP3->streamLength = (ma_uint64)streamLen; - if (pMP3->memory.pData != NULL) { + if (pMP3->memory.pData != nullptr) { pMP3->memory.dataSize = (size_t)pMP3->streamLength; } } else { @@ -94827,10 +94827,10 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on if (header[5] & 0x10) { tagSize += 10; } - if (onMeta != NULL) { + if (onMeta != nullptr) { size_t tagSizeWithHeader = 10 + tagSize; ma_uint8* pTagData = (ma_uint8*)ma_dr_mp3_malloc(tagSizeWithHeader, pAllocationCallbacks); - if (pTagData != NULL) { + if (pTagData != nullptr) { MA_DR_MP3_COPY_MEMORY(pTagData, header, 10); if (onRead(pUserData, pTagData + 10, tagSize) == tagSize) { ma_dr_mp3__on_meta(pMP3, MA_DR_MP3_METADATA_TYPE_ID3V2, pTagData, tagSizeWithHeader); @@ -94838,7 +94838,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on ma_dr_mp3_free(pTagData, pAllocationCallbacks); } } else { - if (onSeek != NULL) { + if (onSeek != nullptr) { if (!onSeek(pUserData, tagSize, MA_DR_MP3_SEEK_CUR)) { return MA_FALSE; } @@ -94859,7 +94859,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on pMP3->streamStartOffset += 10 + tagSize; pMP3->streamCursor = pMP3->streamStartOffset; } else { - if (onSeek != NULL) { + if (onSeek != nullptr) { if (!onSeek(pUserData, 0, MA_DR_MP3_SEEK_SET)) { return MA_FALSE; } @@ -94873,7 +94873,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on #endif firstFramePCMFrameCount = ma_dr_mp3_decode_next_frame_ex(pMP3, (ma_dr_mp3d_sample_t*)pMP3->pcmFrames, &firstFrameInfo, &pFirstFrameData); if (firstFramePCMFrameCount > 0) { - MA_DR_MP3_ASSERT(pFirstFrameData != NULL); + MA_DR_MP3_ASSERT(pFirstFrameData != nullptr); #if 1 MA_DR_MP3_ASSERT(firstFrameInfo.frame_bytes > 0); { @@ -94930,7 +94930,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on } else if (isInfo) { pMP3->isCBR = MA_TRUE; } - if (onMeta != NULL) { + if (onMeta != nullptr) { ma_dr_mp3_metadata_type metadataType = isXing ? MA_DR_MP3_METADATA_TYPE_XING : MA_DR_MP3_METADATA_TYPE_VBRI; size_t tagDataSize; tagDataSize = (size_t)firstFrameInfo.frame_bytes; @@ -94959,7 +94959,7 @@ static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc on } MA_API ma_bool32 ma_dr_mp3_init(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, ma_dr_mp3_tell_proc onTell, ma_dr_mp3_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pMP3 == NULL || onRead == NULL) { + if (pMP3 == nullptr || onRead == nullptr) { return MA_FALSE; } MA_DR_MP3_ZERO_OBJECT(pMP3); @@ -94969,7 +94969,7 @@ static size_t ma_dr_mp3__on_read_memory(void* pUserData, void* pBufferOut, size_ { ma_dr_mp3* pMP3 = (ma_dr_mp3*)pUserData; size_t bytesRemaining; - MA_DR_MP3_ASSERT(pMP3 != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); MA_DR_MP3_ASSERT(pMP3->memory.dataSize >= pMP3->memory.currentReadPos); bytesRemaining = pMP3->memory.dataSize - pMP3->memory.currentReadPos; if (bytesToRead > bytesRemaining) { @@ -94985,7 +94985,7 @@ static ma_bool32 ma_dr_mp3__on_seek_memory(void* pUserData, int byteOffset, ma_d { ma_dr_mp3* pMP3 = (ma_dr_mp3*)pUserData; ma_int64 newCursor; - MA_DR_MP3_ASSERT(pMP3 != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); if (origin == MA_DR_MP3_SEEK_SET) { newCursor = 0; } else if (origin == MA_DR_MP3_SEEK_CUR) { @@ -95009,19 +95009,19 @@ static ma_bool32 ma_dr_mp3__on_seek_memory(void* pUserData, int byteOffset, ma_d static ma_bool32 ma_dr_mp3__on_tell_memory(void* pUserData, ma_int64* pCursor) { ma_dr_mp3* pMP3 = (ma_dr_mp3*)pUserData; - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(pCursor != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(pCursor != nullptr); *pCursor = (ma_int64)pMP3->memory.currentReadPos; return MA_TRUE; } MA_API ma_bool32 ma_dr_mp3_init_memory_with_metadata(ma_dr_mp3* pMP3, const void* pData, size_t dataSize, ma_dr_mp3_meta_proc onMeta, void* pUserDataMeta, const ma_allocation_callbacks* pAllocationCallbacks) { ma_bool32 result; - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_FALSE; } MA_DR_MP3_ZERO_OBJECT(pMP3); - if (pData == NULL || dataSize == 0) { + if (pData == nullptr || dataSize == 0) { return MA_FALSE; } pMP3->memory.pData = (const ma_uint8*)pData; @@ -95041,7 +95041,7 @@ MA_API ma_bool32 ma_dr_mp3_init_memory_with_metadata(ma_dr_mp3* pMP3, const void } MA_API ma_bool32 ma_dr_mp3_init_memory(ma_dr_mp3* pMP3, const void* pData, size_t dataSize, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_mp3_init_memory_with_metadata(pMP3, pData, dataSize, NULL, NULL, pAllocationCallbacks); + return ma_dr_mp3_init_memory_with_metadata(pMP3, pData, dataSize, nullptr, nullptr, pAllocationCallbacks); } #ifndef MA_DR_MP3_NO_STDIO #include @@ -95064,8 +95064,8 @@ static ma_bool32 ma_dr_mp3__on_tell_stdio(void* pUserData, ma_int64* pCursor) { FILE* pFileStdio = (FILE*)pUserData; ma_int64 result; - MA_DR_MP3_ASSERT(pFileStdio != NULL); - MA_DR_MP3_ASSERT(pCursor != NULL); + MA_DR_MP3_ASSERT(pFileStdio != nullptr); + MA_DR_MP3_ASSERT(pCursor != nullptr); #if defined(_WIN32) && !defined(NXDK) #if defined(_MSC_VER) && _MSC_VER > 1200 result = _ftelli64(pFileStdio); @@ -95082,7 +95082,7 @@ MA_API ma_bool32 ma_dr_mp3_init_file_with_metadata(ma_dr_mp3* pMP3, const char* { ma_bool32 result; FILE* pFile; - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_FALSE; } MA_DR_MP3_ZERO_OBJECT(pMP3); @@ -95100,7 +95100,7 @@ MA_API ma_bool32 ma_dr_mp3_init_file_with_metadata_w(ma_dr_mp3* pMP3, const wcha { ma_bool32 result; FILE* pFile; - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_FALSE; } MA_DR_MP3_ZERO_OBJECT(pMP3); @@ -95116,24 +95116,24 @@ MA_API ma_bool32 ma_dr_mp3_init_file_with_metadata_w(ma_dr_mp3* pMP3, const wcha } MA_API ma_bool32 ma_dr_mp3_init_file(ma_dr_mp3* pMP3, const char* pFilePath, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_mp3_init_file_with_metadata(pMP3, pFilePath, NULL, NULL, pAllocationCallbacks); + return ma_dr_mp3_init_file_with_metadata(pMP3, pFilePath, nullptr, nullptr, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_mp3_init_file_w(ma_dr_mp3* pMP3, const wchar_t* pFilePath, const ma_allocation_callbacks* pAllocationCallbacks) { - return ma_dr_mp3_init_file_with_metadata_w(pMP3, pFilePath, NULL, NULL, pAllocationCallbacks); + return ma_dr_mp3_init_file_with_metadata_w(pMP3, pFilePath, nullptr, nullptr, pAllocationCallbacks); } #endif MA_API void ma_dr_mp3_uninit(ma_dr_mp3* pMP3) { - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return; } #ifndef MA_DR_MP3_NO_STDIO if (pMP3->onRead == ma_dr_mp3__on_read_stdio) { FILE* pFile = (FILE*)pMP3->pUserData; - if (pFile != NULL) { + if (pFile != nullptr) { fclose(pFile); - pMP3->pUserData = NULL; + pMP3->pUserData = nullptr; } } #endif @@ -95188,8 +95188,8 @@ static void ma_dr_mp3_s16_to_f32(float* dst, const ma_int16* src, ma_uint64 samp static ma_uint64 ma_dr_mp3_read_pcm_frames_raw(ma_dr_mp3* pMP3, ma_uint64 framesToRead, void* pBufferOut) { ma_uint64 totalFramesRead = 0; - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(pMP3->onRead != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(pMP3->onRead != nullptr); while (framesToRead > 0) { ma_uint32 framesToConsume; if (pMP3->currentPCMFrame < pMP3->delayInPCMFrames) { @@ -95209,7 +95209,7 @@ static ma_uint64 ma_dr_mp3_read_pcm_frames_raw(ma_dr_mp3* pMP3, ma_uint64 frames break; } } - if (pBufferOut != NULL) { + if (pBufferOut != nullptr) { #if defined(MA_DR_MP3_FLOAT_OUTPUT) { float* pFramesOutF32 = (float*)MA_DR_MP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalFramesRead * pMP3->channels); @@ -95244,7 +95244,7 @@ static ma_uint64 ma_dr_mp3_read_pcm_frames_raw(ma_dr_mp3* pMP3, ma_uint64 frames } MA_API ma_uint64 ma_dr_mp3_read_pcm_frames_f32(ma_dr_mp3* pMP3, ma_uint64 framesToRead, float* pBufferOut) { - if (pMP3 == NULL || pMP3->onRead == NULL) { + if (pMP3 == nullptr || pMP3->onRead == nullptr) { return 0; } #if defined(MA_DR_MP3_FLOAT_OUTPUT) @@ -95273,7 +95273,7 @@ MA_API ma_uint64 ma_dr_mp3_read_pcm_frames_f32(ma_dr_mp3* pMP3, ma_uint64 frames } MA_API ma_uint64 ma_dr_mp3_read_pcm_frames_s16(ma_dr_mp3* pMP3, ma_uint64 framesToRead, ma_int16* pBufferOut) { - if (pMP3 == NULL || pMP3->onRead == NULL) { + if (pMP3 == nullptr || pMP3->onRead == nullptr) { return 0; } #if !defined(MA_DR_MP3_FLOAT_OUTPUT) @@ -95302,7 +95302,7 @@ MA_API ma_uint64 ma_dr_mp3_read_pcm_frames_s16(ma_dr_mp3* pMP3, ma_uint64 frames } static void ma_dr_mp3_reset(ma_dr_mp3* pMP3) { - MA_DR_MP3_ASSERT(pMP3 != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); pMP3->pcmFramesConsumedInMP3Frame = 0; pMP3->pcmFramesRemainingInMP3Frame = 0; pMP3->currentPCMFrame = 0; @@ -95312,8 +95312,8 @@ static void ma_dr_mp3_reset(ma_dr_mp3* pMP3) } static ma_bool32 ma_dr_mp3_seek_to_start_of_stream(ma_dr_mp3* pMP3) { - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(pMP3->onSeek != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(pMP3->onSeek != nullptr); if (!ma_dr_mp3__on_seek_64(pMP3, pMP3->streamStartOffset, MA_DR_MP3_SEEK_SET)) { return MA_FALSE; } @@ -95324,9 +95324,9 @@ static ma_bool32 ma_dr_mp3_seek_forward_by_pcm_frames__brute_force(ma_dr_mp3* pM { ma_uint64 framesRead; #if defined(MA_DR_MP3_FLOAT_OUTPUT) - framesRead = ma_dr_mp3_read_pcm_frames_f32(pMP3, frameOffset, NULL); + framesRead = ma_dr_mp3_read_pcm_frames_f32(pMP3, frameOffset, nullptr); #else - framesRead = ma_dr_mp3_read_pcm_frames_s16(pMP3, frameOffset, NULL); + framesRead = ma_dr_mp3_read_pcm_frames_s16(pMP3, frameOffset, nullptr); #endif if (framesRead != frameOffset) { return MA_FALSE; @@ -95335,7 +95335,7 @@ static ma_bool32 ma_dr_mp3_seek_forward_by_pcm_frames__brute_force(ma_dr_mp3* pM } static ma_bool32 ma_dr_mp3_seek_to_pcm_frame__brute_force(ma_dr_mp3* pMP3, ma_uint64 frameIndex) { - MA_DR_MP3_ASSERT(pMP3 != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); if (frameIndex == pMP3->currentPCMFrame) { return MA_TRUE; } @@ -95350,7 +95350,7 @@ static ma_bool32 ma_dr_mp3_seek_to_pcm_frame__brute_force(ma_dr_mp3* pMP3, ma_ui static ma_bool32 ma_dr_mp3_find_closest_seek_point(ma_dr_mp3* pMP3, ma_uint64 frameIndex, ma_uint32* pSeekPointIndex) { ma_uint32 iSeekPoint; - MA_DR_MP3_ASSERT(pSeekPointIndex != NULL); + MA_DR_MP3_ASSERT(pSeekPointIndex != nullptr); *pSeekPointIndex = 0; if (frameIndex < pMP3->pSeekPoints[0].pcmFrameIndex) { return MA_FALSE; @@ -95369,8 +95369,8 @@ static ma_bool32 ma_dr_mp3_seek_to_pcm_frame__seek_table(ma_dr_mp3* pMP3, ma_uin ma_uint32 priorSeekPointIndex; ma_uint16 iMP3Frame; ma_uint64 leftoverFrames; - MA_DR_MP3_ASSERT(pMP3 != NULL); - MA_DR_MP3_ASSERT(pMP3->pSeekPoints != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); + MA_DR_MP3_ASSERT(pMP3->pSeekPoints != nullptr); MA_DR_MP3_ASSERT(pMP3->seekPointCount > 0); if (ma_dr_mp3_find_closest_seek_point(pMP3, frameIndex, &priorSeekPointIndex)) { seekPoint = pMP3->pSeekPoints[priorSeekPointIndex]; @@ -95387,11 +95387,11 @@ static ma_bool32 ma_dr_mp3_seek_to_pcm_frame__seek_table(ma_dr_mp3* pMP3, ma_uin for (iMP3Frame = 0; iMP3Frame < seekPoint.mp3FramesToDiscard; ++iMP3Frame) { ma_uint32 pcmFramesRead; ma_dr_mp3d_sample_t* pPCMFrames; - pPCMFrames = NULL; + pPCMFrames = nullptr; if (iMP3Frame == seekPoint.mp3FramesToDiscard-1) { pPCMFrames = (ma_dr_mp3d_sample_t*)pMP3->pcmFrames; } - pcmFramesRead = ma_dr_mp3_decode_next_frame_ex(pMP3, pPCMFrames, NULL, NULL); + pcmFramesRead = ma_dr_mp3_decode_next_frame_ex(pMP3, pPCMFrames, nullptr, nullptr); if (pcmFramesRead == 0) { return MA_FALSE; } @@ -95402,13 +95402,13 @@ static ma_bool32 ma_dr_mp3_seek_to_pcm_frame__seek_table(ma_dr_mp3* pMP3, ma_uin } MA_API ma_bool32 ma_dr_mp3_seek_to_pcm_frame(ma_dr_mp3* pMP3, ma_uint64 frameIndex) { - if (pMP3 == NULL || pMP3->onSeek == NULL) { + if (pMP3 == nullptr || pMP3->onSeek == nullptr) { return MA_FALSE; } if (frameIndex == 0) { return ma_dr_mp3_seek_to_start_of_stream(pMP3); } - if (pMP3->pSeekPoints != NULL && pMP3->seekPointCount > 0) { + if (pMP3->pSeekPoints != nullptr && pMP3->seekPointCount > 0) { return ma_dr_mp3_seek_to_pcm_frame__seek_table(pMP3, frameIndex); } else { return ma_dr_mp3_seek_to_pcm_frame__brute_force(pMP3, frameIndex); @@ -95419,10 +95419,10 @@ MA_API ma_bool32 ma_dr_mp3_get_mp3_and_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint6 ma_uint64 currentPCMFrame; ma_uint64 totalPCMFrameCount; ma_uint64 totalMP3FrameCount; - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_FALSE; } - if (pMP3->onSeek == NULL) { + if (pMP3->onSeek == nullptr) { return MA_FALSE; } currentPCMFrame = pMP3->currentPCMFrame; @@ -95433,7 +95433,7 @@ MA_API ma_bool32 ma_dr_mp3_get_mp3_and_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint6 totalMP3FrameCount = 0; for (;;) { ma_uint32 pcmFramesInCurrentMP3Frame; - pcmFramesInCurrentMP3Frame = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL, NULL, NULL); + pcmFramesInCurrentMP3Frame = ma_dr_mp3_decode_next_frame_ex(pMP3, nullptr, nullptr, nullptr); if (pcmFramesInCurrentMP3Frame == 0) { break; } @@ -95446,10 +95446,10 @@ MA_API ma_bool32 ma_dr_mp3_get_mp3_and_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint6 if (!ma_dr_mp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) { return MA_FALSE; } - if (pMP3FrameCount != NULL) { + if (pMP3FrameCount != nullptr) { *pMP3FrameCount = totalMP3FrameCount; } - if (pPCMFrameCount != NULL) { + if (pPCMFrameCount != nullptr) { *pPCMFrameCount = totalPCMFrameCount; } return MA_TRUE; @@ -95457,7 +95457,7 @@ MA_API ma_bool32 ma_dr_mp3_get_mp3_and_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint6 MA_API ma_uint64 ma_dr_mp3_get_pcm_frame_count(ma_dr_mp3* pMP3) { ma_uint64 totalPCMFrameCount; - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return 0; } if (pMP3->totalPCMFrameCount != MA_UINT64_MAX) { @@ -95472,7 +95472,7 @@ MA_API ma_uint64 ma_dr_mp3_get_pcm_frame_count(ma_dr_mp3* pMP3) } return totalPCMFrameCount; } else { - if (!ma_dr_mp3_get_mp3_and_pcm_frame_count(pMP3, NULL, &totalPCMFrameCount)) { + if (!ma_dr_mp3_get_mp3_and_pcm_frame_count(pMP3, nullptr, &totalPCMFrameCount)) { return 0; } return totalPCMFrameCount; @@ -95481,7 +95481,7 @@ MA_API ma_uint64 ma_dr_mp3_get_pcm_frame_count(ma_dr_mp3* pMP3) MA_API ma_uint64 ma_dr_mp3_get_mp3_frame_count(ma_dr_mp3* pMP3) { ma_uint64 totalMP3FrameCount; - if (!ma_dr_mp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, NULL)) { + if (!ma_dr_mp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, nullptr)) { return 0; } return totalMP3FrameCount; @@ -95509,7 +95509,7 @@ MA_API ma_bool32 ma_dr_mp3_calculate_seek_points(ma_dr_mp3* pMP3, ma_uint32* pSe ma_uint64 currentPCMFrame; ma_uint64 totalMP3FrameCount; ma_uint64 totalPCMFrameCount; - if (pMP3 == NULL || pSeekPointCount == NULL || pSeekPoints == NULL) { + if (pMP3 == nullptr || pSeekPointCount == nullptr || pSeekPoints == nullptr) { return MA_FALSE; } seekPointCount = *pSeekPointCount; @@ -95546,7 +95546,7 @@ MA_API ma_bool32 ma_dr_mp3_calculate_seek_points(ma_dr_mp3* pMP3, ma_uint32* pSe MA_DR_MP3_ASSERT(pMP3->streamCursor >= pMP3->dataSize); mp3FrameInfo[iMP3Frame].bytePos = pMP3->streamCursor - pMP3->dataSize; mp3FrameInfo[iMP3Frame].pcmFrameIndex = runningPCMFrameCount; - pcmFramesInCurrentMP3FrameIn = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL, NULL, NULL); + pcmFramesInCurrentMP3FrameIn = ma_dr_mp3_decode_next_frame_ex(pMP3, nullptr, nullptr, nullptr); if (pcmFramesInCurrentMP3FrameIn == 0) { return MA_FALSE; } @@ -95570,7 +95570,7 @@ MA_API ma_bool32 ma_dr_mp3_calculate_seek_points(ma_dr_mp3* pMP3, ma_uint32* pSe } mp3FrameInfo[MA_DR_MP3_COUNTOF(mp3FrameInfo)-1].bytePos = pMP3->streamCursor - pMP3->dataSize; mp3FrameInfo[MA_DR_MP3_COUNTOF(mp3FrameInfo)-1].pcmFrameIndex = runningPCMFrameCount; - pcmFramesInCurrentMP3FrameIn = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL, NULL, NULL); + pcmFramesInCurrentMP3FrameIn = ma_dr_mp3_decode_next_frame_ex(pMP3, nullptr, nullptr, nullptr); if (pcmFramesInCurrentMP3FrameIn == 0) { pSeekPoints[iSeekPoint].seekPosInBytes = mp3FrameInfo[0].bytePos; pSeekPoints[iSeekPoint].pcmFrameIndex = nextTargetPCMFrame; @@ -95594,12 +95594,12 @@ MA_API ma_bool32 ma_dr_mp3_calculate_seek_points(ma_dr_mp3* pMP3, ma_uint32* pSe } MA_API ma_bool32 ma_dr_mp3_bind_seek_table(ma_dr_mp3* pMP3, ma_uint32 seekPointCount, ma_dr_mp3_seek_point* pSeekPoints) { - if (pMP3 == NULL) { + if (pMP3 == nullptr) { return MA_FALSE; } - if (seekPointCount == 0 || pSeekPoints == NULL) { + if (seekPointCount == 0 || pSeekPoints == nullptr) { pMP3->seekPointCount = 0; - pMP3->pSeekPoints = NULL; + pMP3->pSeekPoints = nullptr; } else { pMP3->seekPointCount = seekPointCount; pMP3->pSeekPoints = pSeekPoints; @@ -95610,9 +95610,9 @@ static float* ma_dr_mp3__full_read_and_close_f32(ma_dr_mp3* pMP3, ma_dr_mp3_conf { ma_uint64 totalFramesRead = 0; ma_uint64 framesCapacity = 0; - float* pFrames = NULL; + float* pFrames = nullptr; float temp[4096]; - MA_DR_MP3_ASSERT(pMP3 != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); for (;;) { ma_uint64 framesToReadRightNow = MA_DR_MP3_COUNTOF(temp) / pMP3->channels; ma_uint64 framesJustRead = ma_dr_mp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp); @@ -95634,9 +95634,9 @@ static float* ma_dr_mp3__full_read_and_close_f32(ma_dr_mp3* pMP3, ma_dr_mp3_conf break; } pNewFrames = (float*)ma_dr_mp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks); - if (pNewFrames == NULL) { + if (pNewFrames == nullptr) { ma_dr_mp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks); - pFrames = NULL; + pFrames = nullptr; totalFramesRead = 0; break; } @@ -95649,7 +95649,7 @@ static float* ma_dr_mp3__full_read_and_close_f32(ma_dr_mp3* pMP3, ma_dr_mp3_conf break; } } - if (pConfig != NULL) { + if (pConfig != nullptr) { pConfig->channels = pMP3->channels; pConfig->sampleRate = pMP3->sampleRate; } @@ -95663,9 +95663,9 @@ static ma_int16* ma_dr_mp3__full_read_and_close_s16(ma_dr_mp3* pMP3, ma_dr_mp3_c { ma_uint64 totalFramesRead = 0; ma_uint64 framesCapacity = 0; - ma_int16* pFrames = NULL; + ma_int16* pFrames = nullptr; ma_int16 temp[4096]; - MA_DR_MP3_ASSERT(pMP3 != NULL); + MA_DR_MP3_ASSERT(pMP3 != nullptr); for (;;) { ma_uint64 framesToReadRightNow = MA_DR_MP3_COUNTOF(temp) / pMP3->channels; ma_uint64 framesJustRead = ma_dr_mp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp); @@ -95687,9 +95687,9 @@ static ma_int16* ma_dr_mp3__full_read_and_close_s16(ma_dr_mp3* pMP3, ma_dr_mp3_c break; } pNewFrames = (ma_int16*)ma_dr_mp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks); - if (pNewFrames == NULL) { + if (pNewFrames == nullptr) { ma_dr_mp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks); - pFrames = NULL; + pFrames = nullptr; totalFramesRead = 0; break; } @@ -95702,7 +95702,7 @@ static ma_int16* ma_dr_mp3__full_read_and_close_s16(ma_dr_mp3* pMP3, ma_dr_mp3_c break; } } - if (pConfig != NULL) { + if (pConfig != nullptr) { pConfig->channels = pMP3->channels; pConfig->sampleRate = pMP3->sampleRate; } @@ -95715,16 +95715,16 @@ static ma_int16* ma_dr_mp3__full_read_and_close_s16(ma_dr_mp3* pMP3, ma_dr_mp3_c MA_API float* ma_dr_mp3_open_and_read_pcm_frames_f32(ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, ma_dr_mp3_tell_proc onTell, void* pUserData, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_mp3 mp3; - if (!ma_dr_mp3_init(&mp3, onRead, onSeek, onTell, NULL, pUserData, pAllocationCallbacks)) { - return NULL; + if (!ma_dr_mp3_init(&mp3, onRead, onSeek, onTell, nullptr, pUserData, pAllocationCallbacks)) { + return nullptr; } return ma_dr_mp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount); } MA_API ma_int16* ma_dr_mp3_open_and_read_pcm_frames_s16(ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, ma_dr_mp3_tell_proc onTell, void* pUserData, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_mp3 mp3; - if (!ma_dr_mp3_init(&mp3, onRead, onSeek, onTell, NULL, pUserData, pAllocationCallbacks)) { - return NULL; + if (!ma_dr_mp3_init(&mp3, onRead, onSeek, onTell, nullptr, pUserData, pAllocationCallbacks)) { + return nullptr; } return ma_dr_mp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount); } @@ -95732,7 +95732,7 @@ MA_API float* ma_dr_mp3_open_memory_and_read_pcm_frames_f32(const void* pData, s { ma_dr_mp3 mp3; if (!ma_dr_mp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_mp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount); } @@ -95740,7 +95740,7 @@ MA_API ma_int16* ma_dr_mp3_open_memory_and_read_pcm_frames_s16(const void* pData { ma_dr_mp3 mp3; if (!ma_dr_mp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_mp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount); } @@ -95749,7 +95749,7 @@ MA_API float* ma_dr_mp3_open_file_and_read_pcm_frames_f32(const char* filePath, { ma_dr_mp3 mp3; if (!ma_dr_mp3_init_file(&mp3, filePath, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_mp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount); } @@ -95757,25 +95757,25 @@ MA_API ma_int16* ma_dr_mp3_open_file_and_read_pcm_frames_s16(const char* filePat { ma_dr_mp3 mp3; if (!ma_dr_mp3_init_file(&mp3, filePath, pAllocationCallbacks)) { - return NULL; + return nullptr; } return ma_dr_mp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount); } #endif MA_API void* ma_dr_mp3_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks != NULL) { + if (pAllocationCallbacks != nullptr) { return ma_dr_mp3__malloc_from_callbacks(sz, pAllocationCallbacks); } else { - return ma_dr_mp3__malloc_default(sz, NULL); + return ma_dr_mp3__malloc_default(sz, nullptr); } } MA_API void ma_dr_mp3_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { - if (pAllocationCallbacks != NULL) { + if (pAllocationCallbacks != nullptr) { ma_dr_mp3__free_from_callbacks(p, pAllocationCallbacks); } else { - ma_dr_mp3__free_default(p, NULL); + ma_dr_mp3__free_default(p, nullptr); } } #endif diff --git a/Minecraft.Client/Common/Audio/stb_vorbis.h b/Minecraft.Client/Common/Audio/stb_vorbis.h index 9192b162a..0e5294136 100644 --- a/Minecraft.Client/Common/Audio/stb_vorbis.h +++ b/Minecraft.Client/Common/Audio/stb_vorbis.h @@ -112,8 +112,8 @@ extern "C" { // query get_info to find the exact amount required. yes I know // this is lame). // -// If you pass in a non-NULL buffer of the type below, allocation -// will occur from it as described above. Otherwise just pass NULL +// If you pass in a non-nullptr buffer of the type below, allocation +// will occur from it as described above. Otherwise just pass nullptr // to use malloc()/alloca() typedef struct @@ -191,8 +191,8 @@ extern stb_vorbis *stb_vorbis_open_pushdata( // the first N bytes of the file--you're told if it's not enough, see below) // on success, returns an stb_vorbis *, does not set error, returns the amount of // data parsed/consumed on this call in *datablock_memory_consumed_in_bytes; -// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed -// if returns NULL and *error is VORBIS_need_more_data, then the input block was +// on failure, returns nullptr on error and sets *error, does not change *datablock_memory_consumed +// if returns nullptr and *error is VORBIS_need_more_data, then the input block was // incomplete and you need to pass in a larger block from the start of the file extern int stb_vorbis_decode_frame_pushdata( @@ -219,7 +219,7 @@ extern int stb_vorbis_decode_frame_pushdata( // without writing state-machiney code to record a partial detection. // // The number of channels returned are stored in *channels (which can be -// NULL--it is always the same as the number of channels reported by +// nullptr--it is always the same as the number of channels reported by // get_info). *output will contain an array of float* buffers, one per // channel. In other words, (*output)[0][0] contains the first sample from // the first channel, and (*output)[1][0] contains the first sample from @@ -269,18 +269,18 @@ extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *chan extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from an ogg vorbis stream in memory (note -// this must be the entire stream!). on failure, returns NULL and sets *error +// this must be the entire stream!). on failure, returns nullptr and sets *error #ifndef STB_VORBIS_NO_STDIO extern stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from a filename via fopen(). on failure, -// returns NULL and sets *error (possibly to VORBIS_file_open_failure). +// returns nullptr and sets *error (possibly to VORBIS_file_open_failure). extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from an open FILE *, looking for a stream at -// the _current_ seek point (ftell). on failure, returns NULL and sets *error. +// the _current_ seek point (ftell). on failure, returns nullptr and sets *error. // note that stb_vorbis must "own" this stream; if you seek it in between // calls to stb_vorbis, it will become confused. Moreover, if you attempt to // perform stb_vorbis_seek_*() operations on this file, it will assume it @@ -291,7 +291,7 @@ extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_cl int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len); // create an ogg vorbis decoder from an open FILE *, looking for a stream at // the _current_ seek point (ftell); the stream will be of length 'len' bytes. -// on failure, returns NULL and sets *error. note that stb_vorbis must "own" +// on failure, returns nullptr and sets *error. note that stb_vorbis must "own" // this stream; if you seek it in between calls to stb_vorbis, it will become // confused. #endif @@ -314,7 +314,7 @@ extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f); extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output); // decode the next frame and return the number of samples. the number of -// channels returned are stored in *channels (which can be NULL--it is always +// channels returned are stored in *channels (which can be nullptr--it is always // the same as the number of channels reported by get_info). *output will // contain an array of float* buffers, one per channel. These outputs will // be overwritten on the next call to stb_vorbis_get_frame_*. @@ -588,7 +588,7 @@ enum STBVorbisError #include #endif #else // STB_VORBIS_NO_CRT - #define NULL 0 + #define nullptr 0 #define malloc(s) 0 #define free(s) ((void) 0) #define realloc(s) 0 @@ -949,11 +949,11 @@ static void *setup_malloc(vorb *f, int sz) f->setup_memory_required += sz; if (f->alloc.alloc_buffer) { void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; - if (f->setup_offset + sz > f->temp_offset) return NULL; + if (f->setup_offset + sz > f->temp_offset) return nullptr; f->setup_offset += sz; return p; } - return sz ? malloc(sz) : NULL; + return sz ? malloc(sz) : nullptr; } static void setup_free(vorb *f, void *p) @@ -966,7 +966,7 @@ static void *setup_temp_malloc(vorb *f, int sz) { sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs. if (f->alloc.alloc_buffer) { - if (f->temp_offset - sz < f->setup_offset) return NULL; + if (f->temp_offset - sz < f->setup_offset) return nullptr; f->temp_offset -= sz; return (char *) f->alloc.alloc_buffer + f->temp_offset; } @@ -1654,12 +1654,12 @@ static int codebook_decode_scalar_raw(vorb *f, Codebook *c) int i; prep_huffman(f); - if (c->codewords == NULL && c->sorted_codewords == NULL) + if (c->codewords == nullptr && c->sorted_codewords == nullptr) return -1; // cases to use binary search: sorted_codewords && !c->codewords // sorted_codewords && c->entries > 8 - if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) { + if (c->entries > 8 ? c->sorted_codewords!=nullptr : !c->codewords) { // binary search uint32 code = bit_reverse(f->acc); int x=0, n=c->sorted_entries, len; @@ -2629,7 +2629,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) // @OPTIMIZE: reduce register pressure by using fewer variables? int save_point = temp_alloc_save(f); float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); - float *u=NULL,*v=NULL; + float *u=nullptr,*v=nullptr; // twiddle factors float *A = f->A[blocktype]; @@ -3057,7 +3057,7 @@ static float *get_window(vorb *f, int len) len <<= 1; if (len == f->blocksize_0) return f->window[0]; if (len == f->blocksize_1) return f->window[1]; - return NULL; + return nullptr; } #ifndef STB_VORBIS_NO_DEFER_FLOOR @@ -3306,7 +3306,7 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, if (map->chan[j].mux == i) { if (zero_channel[j]) { do_not_decode[ch] = TRUE; - residue_buffers[ch] = NULL; + residue_buffers[ch] = nullptr; } else { do_not_decode[ch] = FALSE; residue_buffers[ch] = f->channel_buffers[j]; @@ -3351,7 +3351,7 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, if (really_zero_channel[i]) { memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); } else { - do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL); + do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], nullptr); } } #else @@ -3464,7 +3464,7 @@ static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) if (f->previous_length) { int i,j, n = f->previous_length; float *w = get_window(f, n); - if (w == NULL) return 0; + if (w == nullptr) return 0; for (i=0; i < f->channels; ++i) { for (j=0; j < n; ++j) f->channel_buffers[i][left+j] = @@ -3647,24 +3647,24 @@ static int start_decoder(vorb *f) //file vendor len = get32_packet(f); f->vendor = (char*)setup_malloc(f, sizeof(char) * (len+1)); - if (f->vendor == NULL) return error(f, VORBIS_outofmem); + if (f->vendor == nullptr) return error(f, VORBIS_outofmem); for(i=0; i < len; ++i) { f->vendor[i] = get8_packet(f); } f->vendor[len] = (char)'\0'; //user comments f->comment_list_length = get32_packet(f); - f->comment_list = NULL; + f->comment_list = nullptr; if (f->comment_list_length > 0) { f->comment_list = (char**) setup_malloc(f, sizeof(char*) * (f->comment_list_length)); - if (f->comment_list == NULL) return error(f, VORBIS_outofmem); + if (f->comment_list == nullptr) return error(f, VORBIS_outofmem); } for(i=0; i < f->comment_list_length; ++i) { len = get32_packet(f); f->comment_list[i] = (char*)setup_malloc(f, sizeof(char) * (len+1)); - if (f->comment_list[i] == NULL) return error(f, VORBIS_outofmem); + if (f->comment_list[i] == nullptr) return error(f, VORBIS_outofmem); for(j=0; j < len; ++j) { f->comment_list[i][j] = get8_packet(f); @@ -3710,7 +3710,7 @@ static int start_decoder(vorb *f) f->codebook_count = get_bits(f,8) + 1; f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); - if (f->codebooks == NULL) return error(f, VORBIS_outofmem); + if (f->codebooks == nullptr) return error(f, VORBIS_outofmem); memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); for (i=0; i < f->codebook_count; ++i) { uint32 *values; @@ -3771,7 +3771,7 @@ static int start_decoder(vorb *f) f->setup_temp_memory_required = c->entries; c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); - if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem); + if (c->codeword_lengths == nullptr) return error(f, VORBIS_outofmem); memcpy(c->codeword_lengths, lengths, c->entries); setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs! lengths = c->codeword_lengths; @@ -3791,7 +3791,7 @@ static int start_decoder(vorb *f) } c->sorted_entries = sorted_count; - values = NULL; + values = nullptr; CHECK(f); if (!c->sparse) { @@ -3820,11 +3820,11 @@ static int start_decoder(vorb *f) if (c->sorted_entries) { // allocate an extra slot for sentinels c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1)); - if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem); + if (c->sorted_codewords == nullptr) return error(f, VORBIS_outofmem); // allocate an extra slot at the front so that c->sorted_values[-1] is defined // so that we can catch that case without an extra if c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1)); - if (c->sorted_values == NULL) return error(f, VORBIS_outofmem); + if (c->sorted_values == nullptr) return error(f, VORBIS_outofmem); ++c->sorted_values; c->sorted_values[-1] = -1; compute_sorted_huffman(c, lengths, values); @@ -3834,7 +3834,7 @@ static int start_decoder(vorb *f) setup_temp_free(f, values, sizeof(*values)*c->sorted_entries); setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries); setup_temp_free(f, lengths, c->entries); - c->codewords = NULL; + c->codewords = nullptr; } compute_accelerated_huffman(c); @@ -3857,7 +3857,7 @@ static int start_decoder(vorb *f) } if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup); mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); - if (mults == NULL) return error(f, VORBIS_outofmem); + if (mults == nullptr) return error(f, VORBIS_outofmem); for (j=0; j < (int) c->lookup_values; ++j) { int q = get_bits(f, c->value_bits); if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } @@ -3874,7 +3874,7 @@ static int start_decoder(vorb *f) c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); } else c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); - if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } + if (c->multiplicands == nullptr) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } len = sparse ? c->sorted_entries : c->entries; for (j=0; j < len; ++j) { unsigned int z = sparse ? c->sorted_values[j] : j; @@ -3902,7 +3902,7 @@ static int start_decoder(vorb *f) float last=0; CHECK(f); c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); - if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } + if (c->multiplicands == nullptr) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } for (j=0; j < (int) c->lookup_values; ++j) { float val = mults[j] * c->delta_value + c->minimum_value + last; c->multiplicands[j] = val; @@ -3931,7 +3931,7 @@ static int start_decoder(vorb *f) // Floors f->floor_count = get_bits(f, 6)+1; f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); - if (f->floor_config == NULL) return error(f, VORBIS_outofmem); + if (f->floor_config == nullptr) return error(f, VORBIS_outofmem); for (i=0; i < f->floor_count; ++i) { f->floor_types[i] = get_bits(f, 16); if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup); @@ -4007,7 +4007,7 @@ static int start_decoder(vorb *f) // Residue f->residue_count = get_bits(f, 6)+1; f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0])); - if (f->residue_config == NULL) return error(f, VORBIS_outofmem); + if (f->residue_config == nullptr) return error(f, VORBIS_outofmem); memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0])); for (i=0; i < f->residue_count; ++i) { uint8 residue_cascade[64]; @@ -4029,7 +4029,7 @@ static int start_decoder(vorb *f) residue_cascade[j] = high_bits*8 + low_bits; } r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); - if (r->residue_books == NULL) return error(f, VORBIS_outofmem); + if (r->residue_books == nullptr) return error(f, VORBIS_outofmem); for (j=0; j < r->classifications; ++j) { for (k=0; k < 8; ++k) { if (residue_cascade[j] & (1 << k)) { @@ -4049,7 +4049,7 @@ static int start_decoder(vorb *f) int classwords = f->codebooks[r->classbook].dimensions; int temp = j; r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); - if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem); + if (r->classdata[j] == nullptr) return error(f, VORBIS_outofmem); for (k=classwords-1; k >= 0; --k) { r->classdata[j][k] = temp % r->classifications; temp /= r->classifications; @@ -4059,14 +4059,14 @@ static int start_decoder(vorb *f) f->mapping_count = get_bits(f,6)+1; f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); - if (f->mapping == NULL) return error(f, VORBIS_outofmem); + if (f->mapping == nullptr) return error(f, VORBIS_outofmem); memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping)); for (i=0; i < f->mapping_count; ++i) { Mapping *m = f->mapping + i; int mapping_type = get_bits(f,16); if (mapping_type != 0) return error(f, VORBIS_invalid_setup); m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); - if (m->chan == NULL) return error(f, VORBIS_outofmem); + if (m->chan == nullptr) return error(f, VORBIS_outofmem); if (get_bits(f,1)) m->submaps = get_bits(f,4)+1; else @@ -4128,11 +4128,11 @@ static int start_decoder(vorb *f) f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); - if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem); + if (f->channel_buffers[i] == nullptr || f->previous_window[i] == nullptr || f->finalY[i] == nullptr) return error(f, VORBIS_outofmem); memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1); #ifdef STB_VORBIS_NO_DEFER_FLOOR f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); - if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem); + if (f->floor_buffers[i] == nullptr) return error(f, VORBIS_outofmem); #endif } @@ -4232,7 +4232,7 @@ static void vorbis_deinit(stb_vorbis *p) setup_free(p, c->codewords); setup_free(p, c->sorted_codewords); // c->sorted_values[-1] is the first entry in the array - setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL); + setup_free(p, c->sorted_values ? c->sorted_values-1 : nullptr); } setup_free(p, p->codebooks); } @@ -4266,14 +4266,14 @@ static void vorbis_deinit(stb_vorbis *p) void stb_vorbis_close(stb_vorbis *p) { - if (p == NULL) return; + if (p == nullptr) return; vorbis_deinit(p); setup_free(p,p); } static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) { - memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start + memset(p, 0, sizeof(*p)); // nullptr out all malloc'd pointers to start if (z) { p->alloc = *z; p->alloc.alloc_buffer_length_in_bytes &= ~7; @@ -4281,12 +4281,12 @@ static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) } p->eof = 0; p->error = VORBIS__no_error; - p->stream = NULL; - p->codebooks = NULL; + p->stream = nullptr; + p->codebooks = nullptr; p->page_crc_tests = -1; #ifndef STB_VORBIS_NO_STDIO p->close_on_free = FALSE; - p->f = NULL; + p->f = nullptr; #endif } @@ -4509,7 +4509,7 @@ int stb_vorbis_decode_frame_pushdata( stb_vorbis *stb_vorbis_open_pushdata( const unsigned char *data, int data_len, // the memory available for decoding - int *data_used, // only defined if result is not NULL + int *data_used, // only defined if result is not nullptr int *error, const stb_vorbis_alloc *alloc) { stb_vorbis *f, p; @@ -4523,7 +4523,7 @@ stb_vorbis *stb_vorbis_open_pushdata( else *error = p.error; vorbis_deinit(&p); - return NULL; + return nullptr; } f = vorbis_alloc(&p); if (f) { @@ -4533,7 +4533,7 @@ stb_vorbis *stb_vorbis_open_pushdata( return f; } else { vorbis_deinit(&p); - return NULL; + return nullptr; } } #endif // STB_VORBIS_NO_PUSHDATA_API @@ -4680,7 +4680,7 @@ static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset) set_file_offset(f, previous_safe); - while (vorbis_find_page(f, &end, NULL)) { + while (vorbis_find_page(f, &end, nullptr)) { if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset) return 1; set_file_offset(f, end); @@ -4770,7 +4770,7 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) set_file_offset(f, left.page_end + (delta / 2) - 32768); } - if (!vorbis_find_page(f, NULL, NULL)) goto error; + if (!vorbis_find_page(f, nullptr, nullptr)) goto error; } for (;;) { @@ -4920,7 +4920,7 @@ int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) if (sample_number != f->current_loc) { int n; uint32 frame_start = f->current_loc; - stb_vorbis_get_frame_float(f, &n, NULL); + stb_vorbis_get_frame_float(f, &n, nullptr); assert(sample_number > frame_start); assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end); f->channel_buffer_start += (sample_number - frame_start); @@ -5063,7 +5063,7 @@ stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *er } if (error) *error = p.error; vorbis_deinit(&p); - return NULL; + return nullptr; } stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc) @@ -5081,14 +5081,14 @@ stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const st FILE *f; #if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__) if (0 != fopen_s(&f, filename, "rb")) - f = NULL; + f = nullptr; #else f = fopen(filename, "rb"); #endif if (f) return stb_vorbis_open_file(f, TRUE, error, alloc); if (error) *error = VORBIS_file_open_failure; - return NULL; + return nullptr; } #endif // STB_VORBIS_NO_STDIO @@ -5097,7 +5097,7 @@ stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *err stb_vorbis *f, p; if (!data) { if (error) *error = VORBIS_unexpected_eof; - return NULL; + return nullptr; } vorbis_init(&p, alloc); p.stream = (uint8 *) data; @@ -5116,7 +5116,7 @@ stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *err } if (error) *error = p.error; vorbis_deinit(&p); - return NULL; + return nullptr; } #ifndef STB_VORBIS_NO_INTEGER_CONVERSION @@ -5255,8 +5255,8 @@ static void convert_samples_short(int buf_c, short **buffer, int b_offset, int d int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) { - float **output = NULL; - int len = stb_vorbis_get_frame_float(f, NULL, &output); + float **output = nullptr; + int len = stb_vorbis_get_frame_float(f, nullptr, &output); if (len > num_samples) len = num_samples; if (len) convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len); @@ -5294,7 +5294,7 @@ int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buff float **output; int len; if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts); - len = stb_vorbis_get_frame_float(f, NULL, &output); + len = stb_vorbis_get_frame_float(f, nullptr, &output); if (len) { if (len*num_c > num_shorts) len = num_shorts / num_c; convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len); @@ -5316,7 +5316,7 @@ int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short n += k; f->channel_buffer_start += k; if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; + if (!stb_vorbis_get_frame_float(f, nullptr, &outputs)) break; } return n; } @@ -5333,7 +5333,7 @@ int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, in n += k; f->channel_buffer_start += k; if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; + if (!stb_vorbis_get_frame_float(f, nullptr, &outputs)) break; } return n; } @@ -5343,8 +5343,8 @@ int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_ { int data_len, offset, total, limit, error; short *data; - stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); - if (v == NULL) return -1; + stb_vorbis *v = stb_vorbis_open_filename(filename, &error, nullptr); + if (v == nullptr) return -1; limit = v->channels * 4096; *channels = v->channels; if (sample_rate) @@ -5352,7 +5352,7 @@ int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_ offset = data_len = 0; total = limit; data = (short *) malloc(total * sizeof(*data)); - if (data == NULL) { + if (data == nullptr) { stb_vorbis_close(v); return -2; } @@ -5365,7 +5365,7 @@ int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_ short *data2; total *= 2; data2 = (short *) realloc(data, total * sizeof(*data)); - if (data2 == NULL) { + if (data2 == nullptr) { free(data); stb_vorbis_close(v); return -2; @@ -5383,8 +5383,8 @@ int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *samp { int data_len, offset, total, limit, error; short *data; - stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL); - if (v == NULL) return -1; + stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, nullptr); + if (v == nullptr) return -1; limit = v->channels * 4096; *channels = v->channels; if (sample_rate) @@ -5392,7 +5392,7 @@ int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *samp offset = data_len = 0; total = limit; data = (short *) malloc(total * sizeof(*data)); - if (data == NULL) { + if (data == nullptr) { stb_vorbis_close(v); return -2; } @@ -5405,7 +5405,7 @@ int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *samp short *data2; total *= 2; data2 = (short *) realloc(data, total * sizeof(*data)); - if (data2 == NULL) { + if (data2 == nullptr) { free(data); stb_vorbis_close(v); return -2; @@ -5440,7 +5440,7 @@ int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float f->channel_buffer_start += k; if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) + if (!stb_vorbis_get_frame_float(f, nullptr, &outputs)) break; } return n; @@ -5466,7 +5466,7 @@ int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, in f->channel_buffer_start += k; if (n == num_samples) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) + if (!stb_vorbis_get_frame_float(f, nullptr, &outputs)) break; } return n; diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 2eb87307b..9d9dce1b8 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -100,7 +100,7 @@ CMinecraftApp::CMinecraftApp() { m_eTMSAction[i]=eTMSAction_Idle; m_eXuiAction[i]=eAppAction_Idle; - m_eXuiActionParam[i] = NULL; + m_eXuiActionParam[i] = nullptr; //m_dwAdditionalModelParts[i] = 0; if(FAILED(XUserGetSigninInfo(i,XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY ,&m_currentSigninInfo[i]))) @@ -157,9 +157,9 @@ CMinecraftApp::CMinecraftApp() // m_bRead_TMS_XUIDS_XML=false; // m_bRead_TMS_DLCINFO_XML=false; - m_pDLCFileBuffer=NULL; + m_pDLCFileBuffer=nullptr; m_dwDLCFileSize=0; - m_pBannedListFileBuffer=NULL; + m_pBannedListFileBuffer=nullptr; m_dwBannedListFileSize=0; m_bDefaultCapeInstallAttempted=false; @@ -763,7 +763,7 @@ bool CMinecraftApp::LoadBeaconMenu(int iPad ,shared_ptr inventory, sh #ifdef _WINDOWS64 static void Win64_GetSettingsPath(char *outPath, DWORD size) { - GetModuleFileNameA(NULL, outPath, size); + GetModuleFileNameA(nullptr, outPath, size); char *lastSlash = strrchr(outPath, '\\'); if (lastSlash) *(lastSlash + 1) = '\0'; strncat_s(outPath, size, "settings.dat", _TRUNCATE); @@ -773,7 +773,7 @@ static void Win64_SaveSettings(GAME_SETTINGS *gs) if (!gs) return; char filePath[MAX_PATH] = {}; Win64_GetSettingsPath(filePath, MAX_PATH); - FILE *f = NULL; + FILE *f = nullptr; if (fopen_s(&f, filePath, "wb") == 0 && f) { fwrite(gs, sizeof(GAME_SETTINGS), 1, f); @@ -785,7 +785,7 @@ static void Win64_LoadSettings(GAME_SETTINGS *gs) if (!gs) return; char filePath[MAX_PATH] = {}; Win64_GetSettingsPath(filePath, MAX_PATH); - FILE *f = NULL; + FILE *f = nullptr; if (fopen_s(&f, filePath, "rb") == 0 && f) { GAME_SETTINGS temp = {}; @@ -838,7 +838,7 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con SetGameSettings(iPad,eGameSetting_Gamma,50); // 4J-PB - Don't reset the difficult level if we're in-game - if(Minecraft::GetInstance()->level==NULL) + if(Minecraft::GetInstance()->level==nullptr) { app.DebugPrintf("SetDefaultOptions - Difficulty = 1\n"); SetGameSettings(iPad,eGameSetting_Difficulty,1); @@ -1400,7 +1400,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) app.SetGameHostOption(eGameHostOption_Difficulty,pMinecraft->options->difficulty); // send this to the other players if we are in-game - bool bInGame=pMinecraft->level!=NULL; + bool bInGame=pMinecraft->level!=nullptr; // Game Host only (and for now we can't change the diff while in game, so this shouldn't happen) if(bInGame && g_NetworkManager.IsHost() && (iPad==ProfileManager.GetPrimaryPad())) @@ -1464,7 +1464,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) break; case eGameSetting_GamertagsVisible: { - bool bInGame=pMinecraft->level!=NULL; + bool bInGame=pMinecraft->level!=nullptr; // Game Host only if(bInGame && g_NetworkManager.IsHost() && (iPad==ProfileManager.GetPrimaryPad())) @@ -1493,7 +1493,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_DisplaySplitscreenGamertags: for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(pMinecraft->localplayers[idx] != NULL) + if(pMinecraft->localplayers[idx] != nullptr) { if(pMinecraft->localplayers[idx]->m_iScreenSection==C4JRender::VIEWPORT_TYPE_FULLSCREEN) { @@ -1539,7 +1539,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) break; case eGameSetting_BedrockFog: { - bool bInGame=pMinecraft->level!=NULL; + bool bInGame=pMinecraft->level!=nullptr; // Game Host only if(bInGame && g_NetworkManager.IsHost() && (iPad==ProfileManager.GetPrimaryPad())) @@ -1596,7 +1596,7 @@ void CMinecraftApp::SetPlayerSkin(int iPad,DWORD dwSkinId) TelemetryManager->RecordSkinChanged(iPad, GameSettingsA[iPad]->dwSelectedSkin); - if(Minecraft::GetInstance()->localplayers[iPad]!=NULL) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin(dwSkinId); + if(Minecraft::GetInstance()->localplayers[iPad]!=nullptr) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin(dwSkinId); } @@ -1608,8 +1608,8 @@ wstring CMinecraftApp::GetPlayerSkinName(int iPad) DWORD CMinecraftApp::GetPlayerSkinId(int iPad) { // 4J-PB -check the user has rights to use this skin - they may have had at some point but the entitlement has been removed. - DLCPack *Pack=NULL; - DLCSkinFile *skinFile=NULL; + DLCPack *Pack=nullptr; + DLCSkinFile *skinFile=nullptr; DWORD dwSkin=GameSettingsA[iPad]->dwSelectedSkin; wchar_t chars[256]; @@ -1664,7 +1664,7 @@ void CMinecraftApp::SetPlayerCape(int iPad,DWORD dwCapeId) //SentientManager.RecordSkinChanged(iPad, GameSettingsA[iPad]->dwSelectedSkin); - if(Minecraft::GetInstance()->localplayers[iPad]!=NULL) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape(dwCapeId); + if(Minecraft::GetInstance()->localplayers[iPad]!=nullptr) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape(dwCapeId); } wstring CMinecraftApp::GetPlayerCapeName(int iPad) @@ -1734,7 +1734,7 @@ void CMinecraftApp::ValidateFavoriteSkins(int iPad) // Also check they haven't reverted to a trial pack DLCPack *pDLCPack=app.m_dlcManager.getPackContainingSkin(chars); - if(pDLCPack!=NULL) + if(pDLCPack!=nullptr) { // 4J-PB - We should let players add the free skins to their favourites as well! //DLCFile *pDLCFile=pDLCPack->getFile(DLCManager::e_DLCType_Skin,chars); @@ -1781,7 +1781,7 @@ void CMinecraftApp::SetMinecraftLanguage(int iPad, unsigned char ucLanguage) unsigned char CMinecraftApp::GetMinecraftLanguage(int iPad) { // if there are no game settings read yet, return the default language - if(GameSettingsA[iPad]==NULL) + if(GameSettingsA[iPad]==nullptr) { return 0; } @@ -1800,7 +1800,7 @@ void CMinecraftApp::SetMinecraftLocale(int iPad, unsigned char ucLocale) unsigned char CMinecraftApp::GetMinecraftLocale(int iPad) { // if there are no game settings read yet, return the default language - if(GameSettingsA[iPad]==NULL) + if(GameSettingsA[iPad]==nullptr) { return 0; } @@ -2470,7 +2470,7 @@ unsigned int CMinecraftApp::GetGameSettingsDebugMask(int iPad,bool bOverridePlay shared_ptr player = Minecraft::GetInstance()->localplayers[iPad]; - if(bOverridePlayer || player==NULL) + if(bOverridePlayer || player==nullptr) { return GameSettingsA[iPad]->uiDebugBitmask; } @@ -2782,7 +2782,7 @@ void CMinecraftApp::HandleXuiActions(void) app.SetAutosaveTimerTime(); SetAction(i,eAppAction_Idle); // Check that there is a name for the save - if we're saving from the tutorial and this is the first save from the tutorial, we'll not have a name - /*if(StorageManager.GetSaveName()==NULL) + /*if(StorageManager.GetSaveName()==nullptr) { app.NavigateToScene(i,eUIScene_SaveWorld); } @@ -2851,7 +2851,7 @@ void CMinecraftApp::HandleXuiActions(void) ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), false); // This just allows it to be shown - if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); + if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); //INT saveOrCheckpointId = 0; //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); @@ -2927,7 +2927,7 @@ void CMinecraftApp::HandleXuiActions(void) // send the message for(int idx=0;idxlocalplayers[idx]!=NULL)) + if((i!=idx) && (pMinecraft->localplayers[idx]!=nullptr)) { XuiBroadcastMessage( CXuiSceneBase::GetPlayerBaseScene(idx), &xuiMsg ); } @@ -3009,7 +3009,7 @@ void CMinecraftApp::HandleXuiActions(void) // send the message for(int idx=0;idxlocalplayers[idx]!=NULL)) + if((i!=idx) && (pMinecraft->localplayers[idx]!=nullptr)) { XuiBroadcastMessage( CXuiSceneBase::GetPlayerBaseScene(idx), &xuiMsg ); } @@ -3235,8 +3235,8 @@ void CMinecraftApp::HandleXuiActions(void) UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); // If param is non-null then this is a forced exit by the server, so make sure the player knows why // 4J Stu - Changed - Don't use the FullScreenProgressScreen for action, use a dialog instead - completionData->bRequiresUserAction = FALSE;//(param != NULL) ? TRUE : FALSE; - completionData->bShowTips = (param != NULL) ? FALSE : TRUE; + completionData->bRequiresUserAction = FALSE;//(param != nullptr) ? TRUE : FALSE; + completionData->bShowTips = (param != nullptr) ? FALSE : TRUE; completionData->bShowBackground=TRUE; completionData->bShowLogo=TRUE; completionData->type = e_ProgressCompletion_NavigateToHomeMenu; @@ -3348,7 +3348,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_WaitForRespawnComplete: player = pMinecraft->localplayers[i]; - if(player != NULL && player->GetPlayerRespawned()) + if(player != nullptr && player->GetPlayerRespawned()) { SetAction(i,eAppAction_Idle); @@ -3373,7 +3373,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_WaitForDimensionChangeComplete: player = pMinecraft->localplayers[i]; - if(player != NULL && player->connection && player->connection->isStarted()) + if(player != nullptr && player->connection && player->connection->isStarted()) { SetAction(i,eAppAction_Idle); ui.CloseUIScenes(i); @@ -3687,7 +3687,7 @@ void CMinecraftApp::HandleXuiActions(void) // unload any texture pack audio // if there is audio in use, clear out the audio, and unmount the pack TexturePack *pTexPack=Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=NULL; + DLCTexturePack *pDLCTexPack=nullptr; if(pTexPack->hasAudio()) { @@ -3711,11 +3711,11 @@ void CMinecraftApp::HandleXuiActions(void) pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1); #ifdef _XBOX - if(pDLCTexPack->m_pStreamedWaveBank!=NULL) + if(pDLCTexPack->m_pStreamedWaveBank!=nullptr) { pDLCTexPack->m_pStreamedWaveBank->Destroy(); } - if(pDLCTexPack->m_pSoundBank!=NULL) + if(pDLCTexPack->m_pSoundBank!=nullptr) { pDLCTexPack->m_pSoundBank->Destroy(); } @@ -3735,7 +3735,7 @@ void CMinecraftApp::HandleXuiActions(void) { if(ProfileManager.IsSignedIn(index) ) { - if(index==i || pMinecraft->localplayers[index]!=NULL ) + if(index==i || pMinecraft->localplayers[index]!=nullptr ) { m_InviteData.dwLocalUsersMask |= g_NetworkManager.GetLocalPlayerMask( index ); } @@ -3843,7 +3843,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::ChangeSessionTypeThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); #ifdef __PS3__ @@ -3924,7 +3924,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CMinecraftApp::RemoteSaveThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bRequiresUserAction=FALSE; @@ -4223,7 +4223,7 @@ void CMinecraftApp::HandleXuiActions(void) SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,"\\",eTMSAction_TMSPP_XUIDSFile); #elif defined _XBOX_ONE - //StorageManager.TMSPP_DeleteFile(i,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",NULL,NULL, 0); + //StorageManager.TMSPP_DeleteFile(i,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",nullptr,nullptr, 0); SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,eTMSAction_TMSPP_DLCFileOnly); #else @@ -4320,7 +4320,7 @@ int CMinecraftApp::BannedLevelDialogReturned(void *pParam,int iPad,const C4JStor #if defined _XBOX || defined _XBOX_ONE INetworkPlayer *pHost = g_NetworkManager.GetHostPlayer(); // unban the level - if (pHost != NULL) + if (pHost != nullptr) { #if defined _XBOX pApp->RemoveLevelFromBannedLevelList(iPad,((NetworkPlayerXbox *)pHost)->GetUID(),pApp->GetUniqueMapName()); @@ -4370,10 +4370,10 @@ void CMinecraftApp::loadMediaArchive() HANDLE hFile = CreateFile( path.c_str(), GENERIC_READ, FILE_SHARE_READ, - NULL, + nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, - NULL ); + nullptr ); if( hFile != INVALID_HANDLE_VALUE ) { @@ -4389,7 +4389,7 @@ void CMinecraftApp::loadMediaArchive() m_fBody, dwFileSize, &m_fSize, - NULL ); + nullptr ); assert( m_fSize == dwFileSize ); @@ -4401,7 +4401,7 @@ void CMinecraftApp::loadMediaArchive() { assert( false ); // AHHHHHHHHHHHH - m_mediaArchive = NULL; + m_mediaArchive = nullptr; } #endif } @@ -4410,7 +4410,7 @@ void CMinecraftApp::loadStringTable() { #ifndef _XBOX - if(m_stringTable!=NULL) + if(m_stringTable!=nullptr) { // we need to unload the current string table, this is a reload delete m_stringTable; @@ -4424,7 +4424,7 @@ void CMinecraftApp::loadStringTable() } else { - m_stringTable = NULL; + m_stringTable = nullptr; assert(false); // AHHHHHHHHH. } @@ -4437,7 +4437,7 @@ int CMinecraftApp::PrimaryPlayerSignedOutReturned(void *pParam,int iPad,const C4 //Minecraft *pMinecraft=Minecraft::GetInstance(); // if the player is null, we're in the menus - //if(Minecraft::GetInstance()->player!=NULL) + //if(Minecraft::GetInstance()->player!=nullptr) // We always create a session before kicking of any of the game code, so even though we may still be joining/creating a game // at this point we want to handle it differently from just being in a menu @@ -4458,7 +4458,7 @@ int CMinecraftApp::EthernetDisconnectReturned(void *pParam,int iPad,const C4JSto Minecraft *pMinecraft=Minecraft::GetInstance(); // if the player is null, we're in the menus - if(Minecraft::GetInstance()->player!=NULL) + if(Minecraft::GetInstance()->player!=nullptr) { app.SetAction(pMinecraft->player->GetXboxPad(),eAppAction_EthernetDisconnectedReturned); } @@ -4490,7 +4490,7 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) bool saveStats = false; if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession() ) { - if(lpParameter != NULL ) + if(lpParameter != nullptr ) { switch( app.GetDisconnectReason() ) { @@ -4522,16 +4522,16 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) } pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId ); // 4J - Force a disconnection, this handles the situation that the server has already disconnected - if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(false); - if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(false); + if( pMinecraft->levels[0] != nullptr ) pMinecraft->levels[0]->disconnect(false); + if( pMinecraft->levels[1] != nullptr ) pMinecraft->levels[1]->disconnect(false); } else { exitReasonStringId = IDS_EXITING_GAME; pMinecraft->progressRenderer->progressStartNoAbort( IDS_EXITING_GAME ); - if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(); - if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(); + if( pMinecraft->levels[0] != nullptr ) pMinecraft->levels[0]->disconnect(); + if( pMinecraft->levels[1] != nullptr ) pMinecraft->levels[1]->disconnect(); } // 4J Stu - This only does something if we actually have a server, so don't need to do any other checks @@ -4546,7 +4546,7 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) } else { - if(lpParameter != NULL ) + if(lpParameter != nullptr ) { switch( app.GetDisconnectReason() ) { @@ -4583,7 +4583,7 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId ); } } - pMinecraft->setLevel(NULL,exitReasonStringId,nullptr,saveStats,true); + pMinecraft->setLevel(nullptr,exitReasonStringId,nullptr,saveStats,true); // 4J-JEV: Fix for #106402 - TCR #014 BAS Debug Output: // TU12: Mass Effect Mash-UP: Save file "Default_DisplayName" is created on all storage devices after signing out from a re-launched pre-generated world @@ -4609,7 +4609,7 @@ int CMinecraftApp::UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EM // bug 11285 - TCR 001: BAS Game Stability: CRASH - When trying to join a full version game with a trial version, the trial crashes // 4J-PB - we may be in the main menus here, and we don't have a pMinecraft->player - if(pMinecraft->player==NULL) + if(pMinecraft->player==nullptr) { bNoPlayer=true; } @@ -4621,7 +4621,7 @@ int CMinecraftApp::UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EM // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -4666,7 +4666,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -4731,7 +4731,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -4804,7 +4804,7 @@ int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageR // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -4948,7 +4948,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange if(i == iPrimaryPlayer) continue; // A guest a signed in or out, out of order which invalidates all the guest players we have in the game - if(hasGuestIdChanged && pApp->m_currentSigninInfo[i].dwGuestNumber != 0 && g_NetworkManager.GetLocalPlayerByUserIndex(i)!=NULL) + if(hasGuestIdChanged && pApp->m_currentSigninInfo[i].dwGuestNumber != 0 && g_NetworkManager.GetLocalPlayerByUserIndex(i)!=nullptr) { pApp->DebugPrintf("Recommending removal of player at index %d because their guest id changed\n",i); pApp->SetAction(i, eAppAction_ExitPlayer); @@ -4972,7 +4972,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange // 4J-HG: If either the player is in the network manager or in the game, need to exit player // TODO: Do we need to check the network manager? - if (g_NetworkManager.GetLocalPlayerByUserIndex(i) != NULL || Minecraft::GetInstance()->localplayers[i] != NULL) + if (g_NetworkManager.GetLocalPlayerByUserIndex(i) != nullptr || Minecraft::GetInstance()->localplayers[i] != nullptr) { pApp->DebugPrintf("Player %d signed out\n", i); pApp->SetAction(i, eAppAction_ExitPlayer); @@ -4983,7 +4983,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange // check if any of the addition players have signed out of PSN (primary player is handled below) if(!switchToOffline && i != ProfileManager.GetLockedProfile() && !g_NetworkManager.IsLocalGame()) { - if(g_NetworkManager.GetLocalPlayerByUserIndex(i)!=NULL) + if(g_NetworkManager.GetLocalPlayerByUserIndex(i)!=nullptr) { if(ProfileManager.IsSignedInLive(i) == false) { @@ -5080,7 +5080,7 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { if(!InputManager.IsPadConnected(i) && - Minecraft::GetInstance()->localplayers[i] != NULL && + Minecraft::GetInstance()->localplayers[i] != nullptr && !ui.IsPauseMenuDisplayed(i) && !ui.IsSceneInStack(i, eUIScene_EndPoem) ) { ui.CloseUIScenes(i); @@ -5109,7 +5109,7 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un { DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexPack; XCONTENTDEVICEID deviceID = pDLCTexPack->GetDLCDeviceID(); - if( XContentGetDeviceState( deviceID, NULL ) != ERROR_SUCCESS ) + if( XContentGetDeviceState( deviceID, nullptr ) != ERROR_SUCCESS ) { // Set texture pack flag so that it is now considered as not having audio - this is critical so that the next playStreaming does what it is meant to do, // and also so that we don't try and unmount this again, or play any sounds from it in the future @@ -5117,11 +5117,11 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un // need to stop the streaming audio - by playing streaming audio from the default texture pack now Minecraft::GetInstance()->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0); - if(pDLCTexPack->m_pStreamedWaveBank!=NULL) + if(pDLCTexPack->m_pStreamedWaveBank!=nullptr) { pDLCTexPack->m_pStreamedWaveBank->Destroy(); } - if(pDLCTexPack->m_pSoundBank!=NULL) + if(pDLCTexPack->m_pSoundBank!=nullptr) { pDLCTexPack->m_pSoundBank->Destroy(); } @@ -5273,7 +5273,7 @@ int CMinecraftApp::GetLocalPlayerCount(void) Minecraft *pMinecraft = Minecraft::GetInstance(); for(int i=0;ilocalplayers[i] != NULL) + if(pMinecraft != nullptr && pMinecraft->localplayers[i] != nullptr) { iPlayerC++; } @@ -5423,15 +5423,15 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d DLCPack *pack = app.m_dlcManager.getPack( CONTENT_DATA_DISPLAY_NAME(ContentData) ); - if( pack != NULL && pack->IsCorrupt() ) + if( pack != nullptr && pack->IsCorrupt() ) { app.DebugPrintf("Pack '%ls' is corrupt, removing it from the DLC Manager.\n", CONTENT_DATA_DISPLAY_NAME(ContentData)); app.m_dlcManager.removePack(pack); - pack = NULL; + pack = nullptr; } - if(pack == NULL) + if(pack == nullptr) { app.DebugPrintf("Pack \"%ls\" is not installed, so adding it\n", CONTENT_DATA_DISPLAY_NAME(ContentData)); @@ -5484,7 +5484,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d // // if the file is not already in the memory textures, then read it from TMS // if(!bRes) // { -// BYTE *pBuffer=NULL; +// BYTE *pBuffer=nullptr; // DWORD dwSize=0; // // 4J-PB - out for now for DaveK so he doesn't get the birthday cape // #ifdef _CONTENT_PACKAGE @@ -5656,7 +5656,7 @@ void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD { EnterCriticalSection(&csMemFilesLock); // check it's not already in - PMEMDATA pData=NULL; + PMEMDATA pData=nullptr; auto it = m_MEM_Files.find(wName); if(it != m_MEM_Files.end()) { @@ -5667,8 +5667,8 @@ void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD if(pData->dwBytes == 0 && dwBytes != 0) { - // This should never be NULL if dwBytes is 0 - if(pData->pbData!=NULL) delete [] pData->pbData; + // This should never be nullptr if dwBytes is 0 + if(pData->pbData!=nullptr) delete [] pData->pbData; pData->pbData=pbData; pData->dwBytes=dwBytes; @@ -5764,7 +5764,7 @@ void CMinecraftApp::AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes) { EnterCriticalSection(&csMemTPDLock); // check it's not already in - PMEMDATA pData=NULL; + PMEMDATA pData=nullptr; auto it = m_MEM_TPD.find(iConfig); if(it == m_MEM_TPD.end()) { @@ -5784,7 +5784,7 @@ void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) { EnterCriticalSection(&csMemTPDLock); // check it's not already in - PMEMDATA pData=NULL; + PMEMDATA pData=nullptr; auto it = m_MEM_TPD.find(iConfig); if(it != m_MEM_TPD.end()) { @@ -5799,7 +5799,7 @@ void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) #ifdef _XBOX int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) { - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // run through the DLC info to find the right texture pack/mash-up pack for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) { @@ -5817,7 +5817,7 @@ int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) #elif defined _XBOX_ONE int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) { - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // run through the DLC info to find the right texture pack/mash-up pack for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) { @@ -6018,7 +6018,7 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor { // 4J-PB - need to check this user can access the store bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -6037,7 +6037,7 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor app.DebugPrintf("Texture Pack - %s\n",pchPackName); SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; @@ -6087,7 +6087,7 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName((WCHAR *)pDLCPack->getName().c_str()); - StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),NULL,NULL); + StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),nullptr,nullptr); // the license change coming in when the offer has been installed will cause this scene to refresh } @@ -6120,7 +6120,7 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor // need to allow downloads here, or the player would need to quit the game to let the download of a texture pack happen. This might affect the network traffic, since the download could take all the bandwidth... XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } else @@ -6166,7 +6166,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 uiIDA[1]=IDS_CONFIRM_CANCEL; // Give the player a warning about the trial version of the texture pack - ui.RequestErrorMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,&CMinecraftApp::WarningTrialTexturePackReturned,NULL); + ui.RequestErrorMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,&CMinecraftApp::WarningTrialTexturePackReturned,nullptr); return S_OK; } @@ -6678,7 +6678,7 @@ wstring CMinecraftApp::GetVKReplacement(unsigned int uiVKey) default: break; } - return NULL; + return nullptr; #else wstring replacement = L""; switch(uiVKey) @@ -6777,7 +6777,7 @@ wstring CMinecraftApp::GetIconReplacement(unsigned int uiIcon) default: break; } - return NULL; + return nullptr; #else wchar_t string[128]; @@ -6832,10 +6832,10 @@ HRESULT CMinecraftApp::RegisterMojangData(WCHAR *pXuidName, PlayerUID xuid, WCHA { HRESULT hr=S_OK; eXUID eTempXuid=eXUID_Undefined; - MOJANG_DATA *pMojangData=NULL; + MOJANG_DATA *pMojangData=nullptr; // ignore the names if we don't recognize them - if(pXuidName!=NULL) + if(pXuidName!=nullptr) { if( wcscmp( pXuidName, L"XUID_NOTCH" ) == 0 ) { @@ -6875,7 +6875,7 @@ HRESULT CMinecraftApp::RegisterConfigValues(WCHAR *pType, int iValue) HRESULT hr=S_OK; // #ifdef _XBOX - // if(pType!=NULL) + // if(pType!=nullptr) // { // if(wcscmp(pType,L"XboxOneTransfer")==0) // { @@ -6926,7 +6926,7 @@ HRESULT CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGe } #endif - if(pType!=NULL) + if(pType!=nullptr) { if(wcscmp(pType,L"Skin")==0) { @@ -7111,7 +7111,7 @@ bool CMinecraftApp::GetDLCNameForPackID(const int iPackID,char **ppchKeyID) auto it = DLCTextures_PackID.find(iPackID); if( it == DLCTextures_PackID.end() ) { - *ppchKeyID=NULL; + *ppchKeyID=nullptr; return false; } else @@ -7131,14 +7131,14 @@ DLC_INFO *CMinecraftApp::GetDLCInfo(char *pchDLCName) if( it == DLCInfo.end() ) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } - else return NULL; + else return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfoFromTPackID(int iTPID) @@ -7153,7 +7153,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoFromTPackID(int iTPID) } ++it; } - return NULL; + return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfo(int iIndex) @@ -7209,12 +7209,12 @@ bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID,wstring &Produc } // DLC_INFO *CMinecraftApp::GetDLCInfoForTrialOfferID(wstring &ProductId) // { -// return NULL; +// return nullptr; // } DLC_INFO *CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) { - return NULL; + return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfoFullOffer(int iIndex) { @@ -7268,7 +7268,7 @@ bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID,ULONGLONG *pull } DLC_INFO *CMinecraftApp::GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial) { - //DLC_INFO *pDLCInfo=NULL; + //DLC_INFO *pDLCInfo=nullptr; if(DLCInfo_Trial.size()>0) { auto it = DLCInfo_Trial.find(ullOfferID_Trial); @@ -7276,14 +7276,14 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial) if( it == DLCInfo_Trial.end() ) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } - else return NULL; + else return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) @@ -7333,14 +7333,14 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(WCHAR *pwchProductID) if( it == DLCInfo_Full.end() ) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } - else return NULL; + else return nullptr; } DLC_INFO *CMinecraftApp::GetDLCInfoForProductName(WCHAR *pwchProductName) { @@ -7357,7 +7357,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForProductName(WCHAR *pwchProductName) ++it; } - return NULL; + return nullptr; } #elif defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) @@ -7373,14 +7373,14 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full) if( it == DLCInfo_Full.end() ) { // nothing for this - return NULL; + return nullptr; } else { return it->second; } } - else return NULL; + else return nullptr; } #endif @@ -7471,7 +7471,7 @@ void CMinecraftApp::ExitGameFromRemoteSave( LPVOID lpParameter ) uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad,&CMinecraftApp::ExitGameFromRemoteSaveDialogReturned,NULL); + ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad,&CMinecraftApp::ExitGameFromRemoteSaveDialogReturned,nullptr); } int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) @@ -7489,7 +7489,7 @@ int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4 // Inform fullscreen progress scene that it's not being cancelled after all UIScene_FullscreenProgress *pScene = static_cast(ui.FindScene(eUIScene_FullscreenProgress)); #ifdef __PS3__ - if(pScene!=NULL) + if(pScene!=nullptr) #else if (pScene != nullptr) #endif @@ -7505,7 +7505,7 @@ int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4 void CMinecraftApp::SetSpecialTutorialCompletionFlag(int iPad, int index) { - if(index >= 0 && index < 32 && GameSettingsA[iPad] != NULL) + if(index >= 0 && index < 32 && GameSettingsA[iPad] != nullptr) { GameSettingsA[iPad]->uiSpecialTutorialBitmask |= (1<wchPlayerUID; @@ -7645,7 +7645,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha #ifdef _XBOX StorageManager.DeleteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList"); #elif defined _XBOX_ONE - StorageManager.TMSPP_DeleteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",NULL,NULL, 0); + StorageManager.TMSPP_DeleteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",nullptr,nullptr, 0); #endif } else @@ -7662,7 +7662,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha #ifdef _XBOX StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dwDataBytes); #elif defined _XBOX_ONE - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dwDataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dwDataBytes,nullptr,nullptr, 0); #endif delete [] pBannedList; } @@ -8126,7 +8126,7 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame bool CMinecraftApp::CanRecordStatsAndAchievements() { - bool isTutorial = Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->isTutorial(); + bool isTutorial = Minecraft::GetInstance() != nullptr && Minecraft::GetInstance()->isTutorial(); // 4J Stu - All of these options give the host player some advantage, so should not allow achievements return !(app.GetGameHostOption(eGameHostOption_HasBeenInCreative) || app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) || @@ -8844,7 +8844,7 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto // set this to retrieved whether it found it or not pCurrent->eState=e_TMS_ContentState_Retrieved; - if(pFileData!=NULL) + if(pFileData!=nullptr) { #ifdef _XBOX_ONE @@ -9197,7 +9197,7 @@ vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vect vector *CMinecraftApp::GetAdditionalModelParts(DWORD dwSkinID) { EnterCriticalSection( &csAdditionalModelParts ); - vector *pvModelParts=NULL; + vector *pvModelParts=nullptr; if(m_AdditionalModelParts.size()>0) { auto it = m_AdditionalModelParts.find(dwSkinID); @@ -9214,7 +9214,7 @@ vector *CMinecraftApp::GetAdditionalModelParts(DWORD dwSkinID) vector *CMinecraftApp::GetAdditionalSkinBoxes(DWORD dwSkinID) { EnterCriticalSection( &csAdditionalSkinBoxes ); - vector *pvSkinBoxes=NULL; + vector *pvSkinBoxes=nullptr; if(m_AdditionalSkinBoxes.size()>0) { auto it = m_AdditionalSkinBoxes.find(dwSkinID); @@ -9335,7 +9335,7 @@ int CMinecraftApp::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::E // we need to enable background downloading for the DLC XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo(app.GetRequiredTexturePackID()); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chKeyName[20]; @@ -9344,7 +9344,7 @@ int CMinecraftApp::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::E memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN); // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. // So we assume the first sku for the product is the one we want - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char + // MGH - keyname in the DLC file is 16 chars long, but there's no space for a nullptr terminating char memset(chKeyName, 0, sizeof(chKeyName)); strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); @@ -9390,13 +9390,13 @@ int CMinecraftApp::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::E if( result==C4JStorage::EMessage_ResultAccept ) // Full version { ullIndexA[0]=ullOfferID_Full; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } else // trial version { DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full); ullIndexA[0]=pDLCInfo->ullOfferID_Trial; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } } @@ -9406,7 +9406,7 @@ int CMinecraftApp::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::E int CMinecraftApp::getArchiveFileSize(const wstring &filename) { - TexturePack *tPack = NULL; + TexturePack *tPack = nullptr; Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) @@ -9418,7 +9418,7 @@ int CMinecraftApp::getArchiveFileSize(const wstring &filename) bool CMinecraftApp::hasArchiveFile(const wstring &filename) { - TexturePack *tPack = NULL; + TexturePack *tPack = nullptr; Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) return true; @@ -9427,7 +9427,7 @@ bool CMinecraftApp::hasArchiveFile(const wstring &filename) byteArray CMinecraftApp::getArchiveFile(const wstring &filename) { - TexturePack *tPack = NULL; + TexturePack *tPack = nullptr; Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) diff --git a/Minecraft.Client/Common/Consoles_App.h b/Minecraft.Client/Common/Consoles_App.h index 0e4d66154..ef8b1a697 100644 --- a/Minecraft.Client/Common/Consoles_App.h +++ b/Minecraft.Client/Common/Consoles_App.h @@ -163,12 +163,12 @@ class CMinecraftApp eXuiAction GetGlobalXuiAction() {return m_eGlobalXuiAction;} void SetGlobalXuiAction(eXuiAction action) {m_eGlobalXuiAction=action;} eXuiAction GetXuiAction(int iPad) {return m_eXuiAction[iPad];} - void SetAction(int iPad, eXuiAction action, LPVOID param = NULL); + void SetAction(int iPad, eXuiAction action, LPVOID param = nullptr); void SetTMSAction(int iPad, eTMSAction action) {m_eTMSAction[iPad]=action; } eTMSAction GetTMSAction(int iPad) {return m_eTMSAction[iPad];} eXuiServerAction GetXuiServerAction(int iPad) {return m_eXuiServerAction[iPad];} LPVOID GetXuiServerActionParam(int iPad) {return m_eXuiServerActionParam[iPad];} - void SetXuiServerAction(int iPad, eXuiServerAction action, LPVOID param = NULL) {m_eXuiServerAction[iPad]=action; m_eXuiServerActionParam[iPad] = param;} + void SetXuiServerAction(int iPad, eXuiServerAction action, LPVOID param = nullptr) {m_eXuiServerAction[iPad]=action; m_eXuiServerActionParam[iPad] = param;} eXuiServerAction GetGlobalXuiServerAction() {return m_eGlobalXuiServerAction;} void SetGlobalXuiServerAction(eXuiServerAction action) {m_eGlobalXuiServerAction=action;} @@ -862,12 +862,12 @@ class CMinecraftApp bool GetBanListRead(int iPad) { return m_bRead_BannedListA[iPad];} void SetBanListRead(int iPad,bool bVal) { m_bRead_BannedListA[iPad]=bVal;} - void ClearBanList(int iPad) { BannedListA[iPad].pBannedList=NULL;BannedListA[iPad].dwBytes=0;} + void ClearBanList(int iPad) { BannedListA[iPad].pBannedList=nullptr;BannedListA[iPad].dwBytes=0;} DWORD GetRequiredTexturePackID() {return m_dwRequiredTexturePackID;} void SetRequiredTexturePackID(DWORD dwID) {m_dwRequiredTexturePackID=dwID;} - virtual void GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD dwBytes,PBYTE *ppbData,DWORD *pdwBytes ) {*ppbData = NULL; *pdwBytes = 0;} + virtual void GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD dwBytes,PBYTE *ppbData,DWORD *pdwBytes ) {*ppbData = nullptr; *pdwBytes = 0;} //XTITLE_DEPLOYMENT_TYPE getDeploymentType() { return m_titleDeploymentType; } diff --git a/Minecraft.Client/Common/DLC/DLCAudioFile.cpp b/Minecraft.Client/Common/DLC/DLCAudioFile.cpp index ff18b540a..3c2a4b198 100644 --- a/Minecraft.Client/Common/DLC/DLCAudioFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCAudioFile.cpp @@ -8,7 +8,7 @@ DLCAudioFile::DLCAudioFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_Audio,path) { - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; } @@ -133,7 +133,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) if(uiVersion < CURRENT_AUDIO_VERSION_NUM) { - if(pbData!=NULL) delete [] pbData; + if(pbData!=nullptr) delete [] pbData; app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion); return false; } diff --git a/Minecraft.Client/Common/DLC/DLCColourTableFile.cpp b/Minecraft.Client/Common/DLC/DLCColourTableFile.cpp index ec800dacf..a0c818a7c 100644 --- a/Minecraft.Client/Common/DLC/DLCColourTableFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCColourTableFile.cpp @@ -7,12 +7,12 @@ DLCColourTableFile::DLCColourTableFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_ColourTable,path) { - m_colourTable = NULL; + m_colourTable = nullptr; } DLCColourTableFile::~DLCColourTableFile() { - if(m_colourTable != NULL) + if(m_colourTable != nullptr) { app.DebugPrintf("Deleting DLCColourTableFile data\n"); delete m_colourTable; diff --git a/Minecraft.Client/Common/DLC/DLCFile.h b/Minecraft.Client/Common/DLC/DLCFile.h index 3a40dbc76..5836c509d 100644 --- a/Minecraft.Client/Common/DLC/DLCFile.h +++ b/Minecraft.Client/Common/DLC/DLCFile.h @@ -17,7 +17,7 @@ class DLCFile DWORD getSkinID() { return m_dwSkinId; } virtual void addData(PBYTE pbData, DWORD dwBytes) {} - virtual PBYTE getData(DWORD &dwBytes) { dwBytes = 0; return NULL; } + virtual PBYTE getData(DWORD &dwBytes) { dwBytes = 0; return nullptr; } virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value) {} virtual wstring getParameterAsString(DLCManager::EDLCParameterType type) { return L""; } diff --git a/Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp b/Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp index 8ca520d68..d84e2a609 100644 --- a/Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCGameRulesFile.cpp @@ -4,7 +4,7 @@ DLCGameRulesFile::DLCGameRulesFile(const wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRules,path) { - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; } diff --git a/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp b/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp index 39b852190..2b7859987 100644 --- a/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp +++ b/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp @@ -11,14 +11,14 @@ DLCGameRulesHeader::DLCGameRulesHeader(const wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRulesHeader,path) { - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; m_hasData = false; m_grfPath = path.substr(0, path.length() - 4) + L".grf"; - lgo = NULL; + lgo = nullptr; } void DLCGameRulesHeader::addData(PBYTE pbData, DWORD dwBytes) diff --git a/Minecraft.Client/Common/DLC/DLCLocalisationFile.cpp b/Minecraft.Client/Common/DLC/DLCLocalisationFile.cpp index 358a93e50..909214345 100644 --- a/Minecraft.Client/Common/DLC/DLCLocalisationFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCLocalisationFile.cpp @@ -5,7 +5,7 @@ DLCLocalisationFile::DLCLocalisationFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_LocalisationData,path) { - m_strings = NULL; + m_strings = nullptr; } void DLCLocalisationFile::addData(PBYTE pbData, DWORD dwBytes) diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index 89da3cebe..5fc5f3704 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -82,7 +82,7 @@ void DLCManager::addPack(DLCPack *pack) void DLCManager::removePack(DLCPack *pack) { - if(pack != NULL) + if(pack != nullptr) { auto it = find(m_packs.begin(), m_packs.end(), pack); if(it != m_packs.end() ) m_packs.erase(it); @@ -112,7 +112,7 @@ void DLCManager::LanguageChanged(void) DLCPack *DLCManager::getPack(const wstring &name) { - DLCPack *pack = NULL; + DLCPack *pack = nullptr; //DWORD currentIndex = 0; for( DLCPack * currentPack : m_packs ) { @@ -130,7 +130,7 @@ DLCPack *DLCManager::getPack(const wstring &name) #ifdef _XBOX_ONE DLCPack *DLCManager::getPackFromProductID(const wstring &productID) { - DLCPack *pack = NULL; + DLCPack *pack = nullptr; for( DLCPack *currentPack : m_packs ) { wstring wsName=currentPack->getPurchaseOfferId(); @@ -147,7 +147,7 @@ DLCPack *DLCManager::getPackFromProductID(const wstring &productID) DLCPack *DLCManager::getPack(DWORD index, EDLCType type /*= e_DLCType_All*/) { - DLCPack *pack = NULL; + DLCPack *pack = nullptr; if( type != e_DLCType_All ) { DWORD currentIndex = 0; @@ -181,9 +181,9 @@ DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_D { DWORD foundIndex = 0; found = false; - if(pack == NULL) + if(pack == nullptr) { - app.DebugPrintf("DLCManager: Attempting to find the index for a NULL pack\n"); + app.DebugPrintf("DLCManager: Attempting to find the index for a nullptr pack\n"); //__debugbreak(); return foundIndex; } @@ -244,7 +244,7 @@ DWORD DLCManager::getPackIndexContainingSkin(const wstring &path, bool &found) DLCPack *DLCManager::getPackContainingSkin(const wstring &path) { - DLCPack *foundPack = NULL; + DLCPack *foundPack = nullptr; for( DLCPack *pack : m_packs ) { if(pack->getDLCItemsCount(e_DLCType_Skin)>0) @@ -261,11 +261,11 @@ DLCPack *DLCManager::getPackContainingSkin(const wstring &path) DLCSkinFile *DLCManager::getSkinFile(const wstring &path) { - DLCSkinFile *foundSkinfile = NULL; + DLCSkinFile *foundSkinfile = nullptr; for( DLCPack *pack : m_packs ) { foundSkinfile=pack->getSkinFile(path); - if(foundSkinfile!=NULL) + if(foundSkinfile!=nullptr) { break; } @@ -276,14 +276,14 @@ DLCSkinFile *DLCManager::getSkinFile(const wstring &path) DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) { DWORD corruptDLCCount = m_dwUnnamedCorruptDLCCount; - DLCPack *firstCorruptPack = NULL; + DLCPack *firstCorruptPack = nullptr; for( DLCPack *pack : m_packs ) { if( pack->IsCorrupt() ) { ++corruptDLCCount; - if(firstCorruptPack == NULL) firstCorruptPack = pack; + if(firstCorruptPack == nullptr) firstCorruptPack = pack; } } @@ -291,13 +291,13 @@ DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) { UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - if(corruptDLCCount == 1 && firstCorruptPack != NULL) + if(corruptDLCCount == 1 && firstCorruptPack != nullptr) { // pass in the pack format string WCHAR wchFormat[132]; swprintf(wchFormat, 132, L"%ls\n\n%%ls", firstCorruptPack->getName().c_str()); - C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL,wchFormat); + C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr,wchFormat); } else @@ -330,13 +330,13 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DL #ifdef _WINDOWS64 string finalPath = StorageManager.GetMountedPath(path.c_str()); if(finalPath.size() == 0) finalPath = path; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #elif defined(_DURANGO) wstring finalPath = StorageManager.GetMountedPath(wPath.c_str()); if(finalPath.size() == 0) finalPath = wPath; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #else - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -347,9 +347,9 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DL return false; } - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr); PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { // need to treat the file as corrupt, and flag it, so can't call fatal error @@ -391,7 +391,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD if(uiVersion < CURRENT_DLC_VERSION_NUM) { - if(pbData!=NULL) delete [] pbData; + if(pbData!=nullptr) delete [] pbData; app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion); return false; } @@ -431,8 +431,8 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD { DLCManager::EDLCType type = static_cast(pFile->dwType); - DLCFile *dlcFile = NULL; - DLCPack *dlcTexturePack = NULL; + DLCFile *dlcFile = nullptr; + DLCPack *dlcTexturePack = nullptr; if(type == e_DLCType_TexturePack) { @@ -461,8 +461,8 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD } else { - if(dlcFile != NULL) dlcFile->addParameter(it->second,(WCHAR *)pParams->wchData); - else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, (WCHAR *)pParams->wchData); + if(dlcFile != nullptr) dlcFile->addParameter(it->second,(WCHAR *)pParams->wchData); + else if(dlcTexturePack != nullptr) dlcTexturePack->addParameter(it->second, (WCHAR *)pParams->wchData); } } pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount); @@ -470,15 +470,15 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD } //pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM); - if(dlcTexturePack != NULL) + if(dlcTexturePack != nullptr) { DWORD texturePackFilesProcessed = 0; bool validPack = processDLCDataFile(texturePackFilesProcessed,pbTemp,pFile->uiFileSize,dlcTexturePack); - pack->SetDataPointer(NULL); // If it's a child pack, it doesn't own the data + pack->SetDataPointer(nullptr); // If it's a child pack, it doesn't own the data if(!validPack || texturePackFilesProcessed == 0) { delete dlcTexturePack; - dlcTexturePack = NULL; + dlcTexturePack = nullptr; } else { @@ -491,7 +491,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD } ++dwFilesProcessed; } - else if(dlcFile != NULL) + else if(dlcFile != nullptr) { // Data dlcFile->addData(pbTemp,pFile->uiFileSize); @@ -537,22 +537,22 @@ DWORD DLCManager::retrievePackIDFromDLCDataFile(const string &path, DLCPack *pac #ifdef _WINDOWS64 string finalPath = StorageManager.GetMountedPath(path.c_str()); if(finalPath.size() == 0) finalPath = path; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #elif defined(_DURANGO) wstring finalPath = StorageManager.GetMountedPath(wPath.c_str()); if(finalPath.size() == 0) finalPath = wPath; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #else - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { return 0; } - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr); PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { // need to treat the file as corrupt, and flag it, so can't call fatal error diff --git a/Minecraft.Client/Common/DLC/DLCPack.cpp b/Minecraft.Client/Common/DLC/DLCPack.cpp index 7986bf6d6..110008c61 100644 --- a/Minecraft.Client/Common/DLC/DLCPack.cpp +++ b/Minecraft.Client/Common/DLC/DLCPack.cpp @@ -24,14 +24,14 @@ DLCPack::DLCPack(const wstring &name,DWORD dwLicenseMask) m_isCorrupt = false; m_packId = 0; m_packVersion = 0; - m_parentPack = NULL; + m_parentPack = nullptr; m_dlcMountIndex = -1; #ifdef _XBOX m_dlcDeviceID = XCONTENTDEVICE_ANY; #endif // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children. - m_data = NULL; + m_data = nullptr; } #ifdef _XBOX_ONE @@ -44,11 +44,11 @@ DLCPack::DLCPack(const wstring &name,const wstring &productID,DWORD dwLicenseMas m_isCorrupt = false; m_packId = 0; m_packVersion = 0; - m_parentPack = NULL; + m_parentPack = nullptr; m_dlcMountIndex = -1; // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children. - m_data = NULL; + m_data = nullptr; } #endif @@ -76,7 +76,7 @@ DLCPack::~DLCPack() wprintf(L"Deleting data for DLC pack %ls\n", m_packName.c_str()); #endif // For the same reason, don't delete data pointer for any child pack as it just points to a region within the parent pack that has already been freed - if( m_parentPack == NULL ) + if( m_parentPack == nullptr ) { delete [] m_data; } @@ -85,7 +85,7 @@ DLCPack::~DLCPack() DWORD DLCPack::GetDLCMountIndex() { - if(m_parentPack != NULL) + if(m_parentPack != nullptr) { return m_parentPack->GetDLCMountIndex(); } @@ -94,7 +94,7 @@ DWORD DLCPack::GetDLCMountIndex() XCONTENTDEVICEID DLCPack::GetDLCDeviceID() { - if(m_parentPack != NULL ) + if(m_parentPack != nullptr ) { return m_parentPack->GetDLCDeviceID(); } @@ -187,7 +187,7 @@ bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type, unsigned in DLCFile *DLCPack::addFile(DLCManager::EDLCType type, const wstring &path) { - DLCFile *newFile = NULL; + DLCFile *newFile = nullptr; switch(type) { @@ -243,7 +243,7 @@ DLCFile *DLCPack::addFile(DLCManager::EDLCType type, const wstring &path) break; }; - if( newFile != NULL ) + if( newFile != nullptr ) { m_files[newFile->getType()].push_back(newFile); } @@ -252,7 +252,7 @@ DLCFile *DLCPack::addFile(DLCManager::EDLCType type, const wstring &path) } // MGH - added this comp func, as the embedded func in find_if was confusing the PS3 compiler -static const wstring *g_pathCmpString = NULL; +static const wstring *g_pathCmpString = nullptr; static bool pathCmp(DLCFile *val) { return (g_pathCmpString->compare(val->getPath()) == 0); @@ -284,13 +284,13 @@ bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, const wstring &path DLCFile *DLCPack::getFile(DLCManager::EDLCType type, DWORD index) { - DLCFile *file = NULL; + DLCFile *file = nullptr; if(type == DLCManager::e_DLCType_All) { for(DLCManager::EDLCType currentType = static_cast(0); currentType < DLCManager::e_DLCType_Max; currentType = static_cast(currentType + 1)) { file = getFile(currentType,index); - if(file != NULL) break; + if(file != nullptr) break; } } else @@ -306,13 +306,13 @@ DLCFile *DLCPack::getFile(DLCManager::EDLCType type, DWORD index) DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const wstring &path) { - DLCFile *file = NULL; + DLCFile *file = nullptr; if(type == DLCManager::e_DLCType_All) { for(DLCManager::EDLCType currentType = static_cast(0); currentType < DLCManager::e_DLCType_Max; currentType = static_cast(currentType + 1)) { file = getFile(currentType,path); - if(file != NULL) break; + if(file != nullptr) break; } } else @@ -323,7 +323,7 @@ DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const wstring &path) if(it == m_files[type].end()) { // Not found - file = NULL; + file = nullptr; } else { @@ -420,7 +420,7 @@ void DLCPack::UpdateLanguage() { // find the language file DLCManager::e_DLCType_LocalisationData; - DLCFile *file = NULL; + DLCFile *file = nullptr; if(m_files[DLCManager::e_DLCType_LocalisationData].size() > 0) { diff --git a/Minecraft.Client/Common/DLC/DLCTextureFile.cpp b/Minecraft.Client/Common/DLC/DLCTextureFile.cpp index edf071c63..fb9c5b036 100644 --- a/Minecraft.Client/Common/DLC/DLCTextureFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCTextureFile.cpp @@ -7,7 +7,7 @@ DLCTextureFile::DLCTextureFile(const wstring &path) : DLCFile(DLCManager::e_DLCT m_bIsAnim = false; m_animString = L""; - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; } diff --git a/Minecraft.Client/Common/DLC/DLCUIDataFile.cpp b/Minecraft.Client/Common/DLC/DLCUIDataFile.cpp index a2a56bca5..597c4b7bc 100644 --- a/Minecraft.Client/Common/DLC/DLCUIDataFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCUIDataFile.cpp @@ -4,14 +4,14 @@ DLCUIDataFile::DLCUIDataFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_UIData,path) { - m_pbData = NULL; + m_pbData = nullptr; m_dwBytes = 0; m_canDeleteData = false; } DLCUIDataFile::~DLCUIDataFile() { - if(m_canDeleteData && m_pbData != NULL) + if(m_canDeleteData && m_pbData != nullptr) { app.DebugPrintf("Deleting DLCUIDataFile data\n"); delete [] m_pbData; diff --git a/Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp index 555ed8b47..f97bfdd1f 100644 --- a/Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp @@ -46,7 +46,7 @@ void AddEnchantmentRuleDefinition::addAttribute(const wstring &attributeName, co bool AddEnchantmentRuleDefinition::enchantItem(shared_ptr item) { bool enchanted = false; - if (item != NULL) + if (item != nullptr) { // 4J-JEV: Ripped code from enchantmenthelpers // Maybe we want to add an addEnchantment method to EnchantmentHelpers @@ -58,7 +58,7 @@ bool AddEnchantmentRuleDefinition::enchantItem(shared_ptr item) { Enchantment *e = Enchantment::enchantments[m_enchantmentId]; - if(e != NULL && e->category->canEnchant(item->getItem())) + if(e != nullptr && e->category->canEnchant(item->getItem())) { int level = min(e->getMaxLevel(), m_enchantmentLevel); item->enchant(e, m_enchantmentLevel); diff --git a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp index 012a9f7b6..270909ecd 100644 --- a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp @@ -41,7 +41,7 @@ void AddItemRuleDefinition::getChildren(vector *children) GameRuleDefinition *AddItemRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition *rule = NULL; + GameRuleDefinition *rule = nullptr; if(ruleType == ConsoleGameRules::eGameRuleType_AddEnchantment) { rule = new AddEnchantmentRuleDefinition(); @@ -97,7 +97,7 @@ void AddItemRuleDefinition::addAttribute(const wstring &attributeName, const wst bool AddItemRuleDefinition::addItemToContainer(shared_ptr container, int slotId) { bool added = false; - if(Item::items[m_itemId] != NULL) + if(Item::items[m_itemId] != nullptr) { int quantity = std::min(m_quantity, Item::items[m_itemId]->getMaxStackSize()); shared_ptr newItem = shared_ptr(new ItemInstance(m_itemId,quantity,m_auxValue) ); @@ -118,7 +118,7 @@ bool AddItemRuleDefinition::addItemToContainer(shared_ptr container, container->setItem( slotId, newItem ); added = true; } - else if(dynamic_pointer_cast(container) != NULL) + else if(dynamic_pointer_cast(container) != nullptr) { added = dynamic_pointer_cast(container)->add(newItem); } diff --git a/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp index 7c2b0d955..3c7e02a39 100644 --- a/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp @@ -13,20 +13,20 @@ ApplySchematicRuleDefinition::ApplySchematicRuleDefinition(LevelGenerationOption { m_levelGenOptions = levelGenOptions; m_location = Vec3::newPermanent(0,0,0); - m_locationBox = NULL; + m_locationBox = nullptr; m_totalBlocksChanged = 0; m_totalBlocksChangedLighting = 0; m_rotation = ConsoleSchematicFile::eSchematicRot_0; m_completed = false; m_dimension = 0; - m_schematic = NULL; + m_schematic = nullptr; } ApplySchematicRuleDefinition::~ApplySchematicRuleDefinition() { app.DebugPrintf("Deleting ApplySchematicRuleDefinition.\n"); if(!m_completed) m_levelGenOptions->releaseSchematicFile(m_schematicName); - m_schematic = NULL; + m_schematic = nullptr; delete m_location; } @@ -130,7 +130,7 @@ void ApplySchematicRuleDefinition::addAttribute(const wstring &attributeName, co void ApplySchematicRuleDefinition::updateLocationBox() { - if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); + if(m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); m_locationBox = AABB::newPermanent(0,0,0,0,0,0); @@ -162,9 +162,9 @@ void ApplySchematicRuleDefinition::processSchematic(AABB *chunkBox, LevelChunk * if(chunk->level->dimension->id != m_dimension) return; PIXBeginNamedEvent(0, "Processing ApplySchematicRuleDefinition"); - if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); + if(m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); - if(m_locationBox == NULL) updateLocationBox(); + if(m_locationBox == nullptr) updateLocationBox(); if(chunkBox->intersects( m_locationBox )) { m_locationBox->y1 = min((double)Level::maxBuildHeight, m_locationBox->y1 ); @@ -189,7 +189,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB *chunkBox, LevelChunk * { m_completed = true; //m_levelGenOptions->releaseSchematicFile(m_schematicName); - //m_schematic = NULL; + //m_schematic = nullptr; } } PIXEndNamedEvent(); @@ -201,9 +201,9 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB *chunkBox, Leve if(chunk->level->dimension->id != m_dimension) return; PIXBeginNamedEvent(0, "Processing ApplySchematicRuleDefinition (lighting)"); - if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); + if(m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); - if(m_locationBox == NULL) updateLocationBox(); + if(m_locationBox == nullptr) updateLocationBox(); if(chunkBox->intersects( m_locationBox )) { m_locationBox->y1 = min((double)Level::maxBuildHeight, m_locationBox->y1 ); @@ -223,7 +223,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB *chunkBox, Leve { m_completed = true; //m_levelGenOptions->releaseSchematicFile(m_schematicName); - //m_schematic = NULL; + //m_schematic = nullptr; } } PIXEndNamedEvent(); @@ -231,13 +231,13 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB *chunkBox, Leve bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1) { - if( m_locationBox == NULL ) updateLocationBox(); + if( m_locationBox == nullptr ) updateLocationBox(); return m_locationBox->intersects(x0,y0,z0,x1,y1,z1); } int ApplySchematicRuleDefinition::getMinY() { - if( m_locationBox == NULL ) updateLocationBox(); + if( m_locationBox == nullptr ) updateLocationBox(); return m_locationBox->y0; } diff --git a/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp index f3b484459..85d382192 100644 --- a/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp @@ -77,7 +77,7 @@ void CollectItemRuleDefinition::populateGameRule(GameRulesInstance::EGameRulesIn bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr item) { bool statusChanged = false; - if(item != NULL && item->id == m_itemId && item->getAuxValue() == m_auxValue && item->get4JData() == m_4JDataValue) + if(item != nullptr && item->id == m_itemId && item->getAuxValue() == m_auxValue && item->get4JData() == m_4JDataValue) { if(!getComplete(rule)) { @@ -92,9 +92,9 @@ bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptrgetConnection() != NULL) + if(rule->getConnection() != nullptr) { - rule->getConnection()->send( shared_ptr( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId, m_itemId, m_auxValue, this->m_4JDataValue,NULL,0))); + rule->getConnection()->send( shared_ptr( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId, m_itemId, m_auxValue, this->m_4JDataValue,nullptr,0))); } } } @@ -106,7 +106,7 @@ wstring CollectItemRuleDefinition::generateXml(shared_ptr item) { // 4J Stu - This should be kept in sync with the GameRulesDefinition.xsd wstring xml = L""; - if(item != NULL) + if(item != nullptr) { xml = L"id) + L"\" quantity=\"SET\" descriptionName=\"OPTIONAL\" promptName=\"OPTIONAL\""; if(item->getAuxValue() != 0) xml += L" auxValue=\"" + std::to_wstring(item->getAuxValue()) + L"\""; diff --git a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp index 65bf79ae3..ef83b32c0 100644 --- a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp @@ -36,7 +36,7 @@ void CompleteAllRuleDefinition::updateStatus(GameRule *rule) progress += it.second.gr->getGameRuleDefinition()->getProgress(it.second.gr); } } - if(rule->getConnection() != NULL) + if(rule->getConnection() != nullptr) { PacketData data; data.goal = goal; @@ -45,11 +45,11 @@ void CompleteAllRuleDefinition::updateStatus(GameRule *rule) int icon = -1; int auxValue = 0; - if(m_lastRuleStatusChanged != NULL) + if(m_lastRuleStatusChanged != nullptr) { icon = m_lastRuleStatusChanged->getIcon(); auxValue = m_lastRuleStatusChanged->getAuxValue(); - m_lastRuleStatusChanged = NULL; + m_lastRuleStatusChanged = nullptr; } rule->getConnection()->send( shared_ptr( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId,icon, auxValue, 0,&data,sizeof(PacketData)))); } diff --git a/Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp index 395b4eebd..f75eddd40 100644 --- a/Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp @@ -6,7 +6,7 @@ CompoundGameRuleDefinition::CompoundGameRuleDefinition() { - m_lastRuleStatusChanged = NULL; + m_lastRuleStatusChanged = nullptr; } CompoundGameRuleDefinition::~CompoundGameRuleDefinition() @@ -26,7 +26,7 @@ void CompoundGameRuleDefinition::getChildren(vector *child GameRuleDefinition *CompoundGameRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition *rule = NULL; + GameRuleDefinition *rule = nullptr; if(ruleType == ConsoleGameRules::eGameRuleType_CompleteAllRule) { rule = new CompleteAllRuleDefinition(); @@ -49,13 +49,13 @@ GameRuleDefinition *CompoundGameRuleDefinition::addChild(ConsoleGameRules::EGame wprintf(L"CompoundGameRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType ); #endif } - if(rule != NULL) m_children.push_back(rule); + if(rule != nullptr) m_children.push_back(rule); return rule; } void CompoundGameRuleDefinition::populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule) { - GameRule *newRule = NULL; + GameRule *newRule = nullptr; int i = 0; for (auto& it : m_children ) { diff --git a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp index 62154cdcd..dd7776824 100644 --- a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp +++ b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp @@ -10,7 +10,7 @@ ConsoleGenerateStructure::ConsoleGenerateStructure() : StructurePiece(0) { m_x = m_y = m_z = 0; - boundingBox = NULL; + boundingBox = nullptr; orientation = Direction::NORTH; m_dimension = 0; } @@ -25,7 +25,7 @@ void ConsoleGenerateStructure::getChildren(vector *childre GameRuleDefinition *ConsoleGenerateStructure::addChild(ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition *rule = NULL; + GameRuleDefinition *rule = nullptr; if(ruleType == ConsoleGameRules::eGameRuleType_GenerateBox) { rule = new XboxStructureActionGenerateBox(); @@ -112,7 +112,7 @@ void ConsoleGenerateStructure::addAttribute(const wstring &attributeName, const BoundingBox* ConsoleGenerateStructure::getBoundingBox() { - if(boundingBox == NULL) + if(boundingBox == nullptr) { // Find the max bounds int maxX, maxY, maxZ; diff --git a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp index 15009e5f4..574e72624 100644 --- a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp +++ b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp @@ -16,18 +16,18 @@ ConsoleSchematicFile::ConsoleSchematicFile() { m_xSize = m_ySize = m_zSize = 0; m_refCount = 1; - m_data.data = NULL; + m_data.data = nullptr; } ConsoleSchematicFile::~ConsoleSchematicFile() { app.DebugPrintf("Deleting schematic file\n"); - if(m_data.data != NULL) delete [] m_data.data; + if(m_data.data != nullptr) delete [] m_data.data; } void ConsoleSchematicFile::save(DataOutputStream *dos) { - if(dos != NULL) + if(dos != nullptr) { dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION); @@ -52,7 +52,7 @@ void ConsoleSchematicFile::save(DataOutputStream *dos) void ConsoleSchematicFile::load(DataInputStream *dis) { - if(dis != NULL) + if(dis != nullptr) { // VERSION CHECK // int version = dis->readInt(); @@ -75,10 +75,10 @@ void ConsoleSchematicFile::load(DataInputStream *dis) byteArray compressedBuffer(compressedSize); dis->readFully(compressedBuffer); - if(m_data.data != NULL) + if(m_data.data != nullptr) { delete [] m_data.data; - m_data.data = NULL; + m_data.data = nullptr; } if(compressionType == Compression::eCompressionType_None) @@ -111,17 +111,17 @@ void ConsoleSchematicFile::load(DataInputStream *dis) // READ TAGS // CompoundTag *tag = NbtIo::read(dis); ListTag *tileEntityTags = (ListTag *) tag->getList(L"TileEntities"); - if (tileEntityTags != NULL) + if (tileEntityTags != nullptr) { for (int i = 0; i < tileEntityTags->size(); i++) { CompoundTag *teTag = tileEntityTags->get(i); shared_ptr te = TileEntity::loadStatic(teTag); - if(te == NULL) + if(te == nullptr) { #ifndef _CONTENT_PACKAGE - app.DebugPrintf("ConsoleSchematicFile has read a NULL tile entity\n"); + app.DebugPrintf("ConsoleSchematicFile has read a nullptr tile entity\n"); __debugbreak(); #endif } @@ -132,7 +132,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis) } } ListTag *entityTags = (ListTag *) tag->getList(L"Entities"); - if (entityTags != NULL) + if (entityTags != nullptr) { for (int i = 0; i < entityTags->size(); i++) { @@ -444,7 +444,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, { shared_ptr teCopy = chunk->getTileEntity( static_cast(targetX) & 15, static_cast(targetY) & 15, static_cast(targetZ) & 15 ); - if ( teCopy != NULL ) + if ( teCopy != nullptr ) { CompoundTag *teData = new CompoundTag(); te->save(teData); @@ -493,7 +493,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, } CompoundTag *eTag = it->second; - shared_ptr e = EntityIO::loadStatic(eTag, NULL); + shared_ptr e = EntityIO::loadStatic(eTag, nullptr); if( e->GetType() == eTYPE_PAINTING ) { @@ -582,18 +582,18 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l app.DebugPrintf("Generating schematic file for area (%d,%d,%d) to (%d,%d,%d), %dx%dx%d\n",xStart,yStart,zStart,xEnd,yEnd,zEnd,xSize,ySize,zSize); - if(dos != NULL) dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION); + if(dos != nullptr) dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION); - if(dos != NULL) dos->writeByte(compressionType); + if(dos != nullptr) dos->writeByte(compressionType); //Write xSize - if(dos != NULL) dos->writeInt(xSize); + if(dos != nullptr) dos->writeInt(xSize); //Write ySize - if(dos != NULL) dos->writeInt(ySize); + if(dos != nullptr) dos->writeInt(ySize); //Write zSize - if(dos != NULL) dos->writeInt(zSize); + if(dos != nullptr) dos->writeInt(zSize); //byteArray rawBuffer = level->getBlocksAndData(xStart, yStart, zStart, xSize, ySize, zSize, false); int xRowSize = ySize * zSize; @@ -660,8 +660,8 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l delete [] result.data; byteArray buffer = byteArray(ucTemp,inputSize); - if(dos != NULL) dos->writeInt(inputSize); - if(dos != NULL) dos->write(buffer); + if(dos != nullptr) dos->writeInt(inputSize); + if(dos != nullptr) dos->write(buffer); delete [] buffer.data; CompoundTag tag; @@ -738,7 +738,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l tag.put(L"Entities", entitiesTag); - if(dos != NULL) NbtIo::write(&tag,dos); + if(dos != nullptr) NbtIo::write(&tag,dos); } void ConsoleSchematicFile::getBlocksAndData(LevelChunk *chunk, byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int &blocksP, int &dataP, int &blockLightP, int &skyLightP) diff --git a/Minecraft.Client/Common/GameRules/GameRule.h b/Minecraft.Client/Common/GameRules/GameRule.h index bdc2ceff5..42e575718 100644 --- a/Minecraft.Client/Common/GameRules/GameRule.h +++ b/Minecraft.Client/Common/GameRules/GameRule.h @@ -40,7 +40,7 @@ class GameRule stringValueMapType m_parameters; // These are the members of this rule that maintain it's state public: - GameRule(GameRuleDefinition *definition, Connection *connection = NULL); + GameRule(GameRuleDefinition *definition, Connection *connection = nullptr); virtual ~GameRule(); Connection *getConnection() { return m_connection; } diff --git a/Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp index 80d029560..770b56d56 100644 --- a/Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp @@ -50,7 +50,7 @@ GameRuleDefinition *GameRuleDefinition::addChild(ConsoleGameRules::EGameRuleType #ifndef _CONTENT_PACKAGE wprintf(L"GameRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType ); #endif - return NULL; + return nullptr; } void GameRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue) diff --git a/Minecraft.Client/Common/GameRules/GameRuleDefinition.h b/Minecraft.Client/Common/GameRules/GameRuleDefinition.h index afec8fbcc..4a2c43a1c 100644 --- a/Minecraft.Client/Common/GameRules/GameRuleDefinition.h +++ b/Minecraft.Client/Common/GameRules/GameRuleDefinition.h @@ -61,6 +61,6 @@ class GameRuleDefinition // Static functions static GameRulesInstance *generateNewGameRulesInstance(GameRulesInstance::EGameRulesInstanceType type, LevelRuleset *rules, Connection *connection); - static wstring generateDescriptionString(ConsoleGameRules::EGameRuleType defType, const wstring &description, void *data = NULL, int dataLength = 0); + static wstring generateDescriptionString(ConsoleGameRules::EGameRuleType defType, const wstring &description, void *data = nullptr, int dataLength = 0); }; \ No newline at end of file diff --git a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp index 9b4d0493c..96d4e8289 100644 --- a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp +++ b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp @@ -85,13 +85,13 @@ WCHAR *GameRuleManager::wchAttrNameA[] = GameRuleManager::GameRuleManager() { - m_currentGameRuleDefinitions = NULL; - m_currentLevelGenerationOptions = NULL; + m_currentGameRuleDefinitions = nullptr; + m_currentLevelGenerationOptions = nullptr; } void GameRuleManager::loadGameRules(DLCPack *pack) { - StringTable *strings = NULL; + StringTable *strings = nullptr; if(pack->doesPackContainFile(DLCManager::e_DLCType_LocalisationData,L"languages.loc")) { @@ -237,11 +237,11 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT // 4J-JEV: Reverse of loadGameRules. void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize) { - if (m_currentGameRuleDefinitions == NULL && - m_currentLevelGenerationOptions == NULL) + if (m_currentGameRuleDefinitions == nullptr && + m_currentLevelGenerationOptions == nullptr) { app.DebugPrintf("GameRuleManager:: Nothing here to save."); - *dOut = NULL; + *dOut = nullptr; *dSize = 0; return; } @@ -268,7 +268,7 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize) ByteArrayOutputStream compr_baos; DataOutputStream compr_dos(&compr_baos); - if (m_currentGameRuleDefinitions == NULL) + if (m_currentGameRuleDefinitions == nullptr) { compr_dos.writeInt( 0 ); // numStrings for StringTable compr_dos.writeInt( version_number ); @@ -282,9 +282,9 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize) { StringTable *st = m_currentGameRuleDefinitions->getStringTable(); - if (st == NULL) + if (st == nullptr) { - app.DebugPrintf("GameRuleManager::saveGameRules: StringTable == NULL!"); + app.DebugPrintf("GameRuleManager::saveGameRules: StringTable == nullptr!"); } else { @@ -322,7 +322,7 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize) *dSize = baos.buf.length; *dOut = baos.buf.data; - baos.buf.data = NULL; + baos.buf.data = nullptr; dos.close(); baos.close(); } @@ -399,8 +399,8 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT for(int i = 0; i < 8; ++i) dis.readBoolean(); } - ByteArrayInputStream *contentBais = NULL; - DataInputStream *contentDis = NULL; + ByteArrayInputStream *contentBais = nullptr; + DataInputStream *contentDis = nullptr; if(compressionType == Compression::eCompressionType_None) { @@ -521,7 +521,7 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT auto it = tagIdMap.find(tagId); if(it != tagIdMap.end()) tagVal = it->second; - GameRuleDefinition *rule = NULL; + GameRuleDefinition *rule = nullptr; if(tagVal == ConsoleGameRules::eGameRuleType_LevelGenerationOptions) { @@ -548,14 +548,14 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT { // Not default contentDis->close(); - if(contentBais != NULL) delete contentBais; + if(contentBais != nullptr) delete contentBais; delete contentDis; } dis.close(); bais.reset(); - //if(!levelGenAdded) { delete levelGenerator; levelGenerator = NULL; } + //if(!levelGenAdded) { delete levelGenerator; levelGenerator = nullptr; } if(!gameRulesAdded) delete gameRules; return true; @@ -583,7 +583,7 @@ void GameRuleManager::readAttributes(DataInputStream *dis, vector *tags int attID = dis->readInt(); wstring value = dis->readUTF(); - if(rule != NULL) rule->addAttribute(tagsAndAtts->at(attID),value); + if(rule != nullptr) rule->addAttribute(tagsAndAtts->at(attID),value); } } @@ -597,8 +597,8 @@ void GameRuleManager::readChildren(DataInputStream *dis, vector *tagsAn auto it = tagIdMap->find(tagId); if(it != tagIdMap->end()) tagVal = it->second; - GameRuleDefinition *childRule = NULL; - if(rule != NULL) childRule = rule->addChild(tagVal); + GameRuleDefinition *childRule = nullptr; + if(rule != nullptr) childRule = rule->addChild(tagVal); readAttributes(dis,tagsAndAtts,childRule); readChildren(dis,tagsAndAtts,tagIdMap,childRule); @@ -607,7 +607,7 @@ void GameRuleManager::readChildren(DataInputStream *dis, vector *tagsAn void GameRuleManager::processSchematics(LevelChunk *levelChunk) { - if(getLevelGenerationOptions() != NULL) + if(getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = getLevelGenerationOptions(); levelGenOptions->processSchematics(levelChunk); @@ -616,7 +616,7 @@ void GameRuleManager::processSchematics(LevelChunk *levelChunk) void GameRuleManager::processSchematicsLighting(LevelChunk *levelChunk) { - if(getLevelGenerationOptions() != NULL) + if(getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = getLevelGenerationOptions(); levelGenOptions->processSchematicsLighting(levelChunk); @@ -701,21 +701,21 @@ void GameRuleManager::setLevelGenerationOptions(LevelGenerationOptions *levelGen { unloadCurrentGameRules(); - m_currentGameRuleDefinitions = NULL; + m_currentGameRuleDefinitions = nullptr; m_currentLevelGenerationOptions = levelGen; - if(m_currentLevelGenerationOptions != NULL && m_currentLevelGenerationOptions->requiresGameRules() ) + if(m_currentLevelGenerationOptions != nullptr && m_currentLevelGenerationOptions->requiresGameRules() ) { m_currentGameRuleDefinitions = m_currentLevelGenerationOptions->getRequiredGameRules(); } - if(m_currentLevelGenerationOptions != NULL) + if(m_currentLevelGenerationOptions != nullptr) m_currentLevelGenerationOptions->reset_start(); } LPCWSTR GameRuleManager::GetGameRulesString(const wstring &key) { - if(m_currentGameRuleDefinitions != NULL && !key.empty() ) + if(m_currentGameRuleDefinitions != nullptr && !key.empty() ) { return m_currentGameRuleDefinitions->getString(key); } @@ -739,9 +739,9 @@ LEVEL_GEN_ID GameRuleManager::addLevelGenerationOptions(LevelGenerationOptions * void GameRuleManager::unloadCurrentGameRules() { - if (m_currentLevelGenerationOptions != NULL) + if (m_currentLevelGenerationOptions != nullptr) { - if (m_currentGameRuleDefinitions != NULL + if (m_currentGameRuleDefinitions != nullptr && m_currentLevelGenerationOptions->isFromSave()) m_levelRules.removeLevelRule( m_currentGameRuleDefinitions ); @@ -757,6 +757,6 @@ void GameRuleManager::unloadCurrentGameRules() } } - m_currentGameRuleDefinitions = NULL; - m_currentLevelGenerationOptions = NULL; + m_currentGameRuleDefinitions = nullptr; + m_currentLevelGenerationOptions = nullptr; } diff --git a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp index 7232e9c65..9f72b0984 100644 --- a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp +++ b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp @@ -44,8 +44,8 @@ bool JustGrSource::ready() { return true; } LevelGenerationOptions::LevelGenerationOptions(DLCPack *parentPack) { - m_spawnPos = NULL; - m_stringTable = NULL; + m_spawnPos = nullptr; + m_stringTable = nullptr; m_hasLoadedData = false; @@ -56,7 +56,7 @@ LevelGenerationOptions::LevelGenerationOptions(DLCPack *parentPack) m_minY = INT_MAX; m_bRequiresGameRules = false; - m_pbBaseSaveData = NULL; + m_pbBaseSaveData = nullptr; m_dwBaseSaveSize = 0; m_parentDLCPack = parentPack; @@ -66,7 +66,7 @@ LevelGenerationOptions::LevelGenerationOptions(DLCPack *parentPack) LevelGenerationOptions::~LevelGenerationOptions() { clearSchematics(); - if(m_spawnPos != NULL) delete m_spawnPos; + if(m_spawnPos != nullptr) delete m_spawnPos; for (auto& it : m_schematicRules ) { delete it; @@ -141,7 +141,7 @@ void LevelGenerationOptions::getChildren(vector *children) GameRuleDefinition *LevelGenerationOptions::addChild(ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition *rule = NULL; + GameRuleDefinition *rule = nullptr; if(ruleType == ConsoleGameRules::eGameRuleType_ApplySchematic) { rule = new ApplySchematicRuleDefinition(this); @@ -180,21 +180,21 @@ void LevelGenerationOptions::addAttribute(const wstring &attributeName, const ws } else if(attributeName.compare(L"spawnX") == 0) { - if(m_spawnPos == NULL) m_spawnPos = new Pos(); + if(m_spawnPos == nullptr) m_spawnPos = new Pos(); int value = _fromString(attributeValue); m_spawnPos->x = value; app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnX=%d\n",value); } else if(attributeName.compare(L"spawnY") == 0) { - if(m_spawnPos == NULL) m_spawnPos = new Pos(); + if(m_spawnPos == nullptr) m_spawnPos = new Pos(); int value = _fromString(attributeValue); m_spawnPos->y = value; app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnY=%d\n",value); } else if(attributeName.compare(L"spawnZ") == 0) { - if(m_spawnPos == NULL) m_spawnPos = new Pos(); + if(m_spawnPos == nullptr) m_spawnPos = new Pos(); int value = _fromString(attributeValue); m_spawnPos->z = value; app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnZ=%d\n",value); @@ -268,7 +268,7 @@ void LevelGenerationOptions::processSchematics(LevelChunk *chunk) if (structureStart->getBoundingBox()->intersects(cx, cz, cx + 15, cz + 15)) { BoundingBox *bb = new BoundingBox(cx, cz, cx + 15, cz + 15); - structureStart->postProcess(chunk->level, NULL, bb); + structureStart->postProcess(chunk->level, nullptr, bb); delete bb; } } @@ -353,7 +353,7 @@ ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const wstring &f return it->second; } - ConsoleSchematicFile *schematic = NULL; + ConsoleSchematicFile *schematic = nullptr; byteArray data(pbData,dwLen); ByteArrayInputStream bais(data); DataInputStream dis(&bais); @@ -366,7 +366,7 @@ ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const wstring &f ConsoleSchematicFile *LevelGenerationOptions::getSchematicFile(const wstring &filename) { - ConsoleSchematicFile *schematic = NULL; + ConsoleSchematicFile *schematic = nullptr; // If we have already loaded this, just return auto it = m_schematics.find(filename); if(it != m_schematics.end()) @@ -399,7 +399,7 @@ void LevelGenerationOptions::loadStringTable(StringTable *table) LPCWSTR LevelGenerationOptions::getString(const wstring &key) { - if(m_stringTable == NULL) + if(m_stringTable == nullptr) { return L""; } @@ -456,7 +456,7 @@ unordered_map *LevelGenerationOptions::getUnfin void LevelGenerationOptions::loadBaseSaveData() { int mountIndex = -1; - if(m_parentDLCPack != NULL) mountIndex = m_parentDLCPack->GetDLCMountIndex(); + if(m_parentDLCPack != nullptr) mountIndex = m_parentDLCPack->GetDLCMountIndex(); if(mountIndex > -1) { @@ -513,10 +513,10 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #else const char *pchFilename=wstringtofilename(grf.getPath()); @@ -524,10 +524,10 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #endif @@ -536,7 +536,7 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD DWORD dwFileSize = grf.length(); DWORD bytesRead; PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { app.FatalLoadError(); @@ -565,10 +565,10 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #else const char *pchFilename=wstringtofilename(save.getPath()); @@ -576,18 +576,18 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #endif if( fileHandle != INVALID_HANDLE_VALUE ) { - DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,nullptr); PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { app.FatalLoadError(); @@ -624,8 +624,8 @@ void LevelGenerationOptions::reset_start() void LevelGenerationOptions::reset_finish() { - //if (m_spawnPos) { delete m_spawnPos; m_spawnPos = NULL; } - //if (m_stringTable) { delete m_stringTable; m_stringTable = NULL; } + //if (m_spawnPos) { delete m_spawnPos; m_spawnPos = nullptr; } + //if (m_stringTable) { delete m_stringTable; m_stringTable = nullptr; } if (isFromDLC()) { @@ -694,8 +694,8 @@ bool LevelGenerationOptions::ready() { return info()->ready(); } void LevelGenerationOptions::setBaseSaveData(PBYTE pbData, DWORD dwSize) { m_pbBaseSaveData = pbData; m_dwBaseSaveSize = dwSize; } PBYTE LevelGenerationOptions::getBaseSaveData(DWORD &size) { size = m_dwBaseSaveSize; return m_pbBaseSaveData; } -bool LevelGenerationOptions::hasBaseSaveData() { return m_dwBaseSaveSize > 0 && m_pbBaseSaveData != NULL; } -void LevelGenerationOptions::deleteBaseSaveData() { if(m_pbBaseSaveData) delete m_pbBaseSaveData; m_pbBaseSaveData = NULL; m_dwBaseSaveSize = 0; } +bool LevelGenerationOptions::hasBaseSaveData() { return m_dwBaseSaveSize > 0 && m_pbBaseSaveData != nullptr; } +void LevelGenerationOptions::deleteBaseSaveData() { if(m_pbBaseSaveData) delete m_pbBaseSaveData; m_pbBaseSaveData = nullptr; m_dwBaseSaveSize = 0; } bool LevelGenerationOptions::hasLoadedData() { return m_hasLoadedData; } void LevelGenerationOptions::setLoadedData() { m_hasLoadedData = true; } diff --git a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.h b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.h index aa128ff84..b94b312a7 100644 --- a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.h +++ b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.h @@ -167,7 +167,7 @@ class LevelGenerationOptions : public GameRuleDefinition bool m_bLoadingData; public: - LevelGenerationOptions(DLCPack *parentPack = NULL); + LevelGenerationOptions(DLCPack *parentPack = nullptr); ~LevelGenerationOptions(); virtual ConsoleGameRules::EGameRuleType getActionType(); @@ -202,7 +202,7 @@ class LevelGenerationOptions : public GameRuleDefinition LevelRuleset *getRequiredGameRules(); void getBiomeOverride(int biomeId, BYTE &tile, BYTE &topTile); - bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature, int *orientation = NULL); + bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature, int *orientation = nullptr); void loadStringTable(StringTable *table); LPCWSTR getString(const wstring &key); diff --git a/Minecraft.Client/Common/GameRules/LevelRuleset.cpp b/Minecraft.Client/Common/GameRules/LevelRuleset.cpp index b6525b73d..de17bacca 100644 --- a/Minecraft.Client/Common/GameRules/LevelRuleset.cpp +++ b/Minecraft.Client/Common/GameRules/LevelRuleset.cpp @@ -6,7 +6,7 @@ LevelRuleset::LevelRuleset() { - m_stringTable = NULL; + m_stringTable = nullptr; } LevelRuleset::~LevelRuleset() @@ -26,7 +26,7 @@ void LevelRuleset::getChildren(vector *children) GameRuleDefinition *LevelRuleset::addChild(ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition *rule = NULL; + GameRuleDefinition *rule = nullptr; if(ruleType == ConsoleGameRules::eGameRuleType_NamedArea) { rule = new NamedAreaRuleDefinition(); @@ -46,7 +46,7 @@ void LevelRuleset::loadStringTable(StringTable *table) LPCWSTR LevelRuleset::getString(const wstring &key) { - if(m_stringTable == NULL) + if(m_stringTable == nullptr) { return L""; } diff --git a/Minecraft.Client/Common/GameRules/StartFeature.cpp b/Minecraft.Client/Common/GameRules/StartFeature.cpp index c2ad23505..14b6d9c93 100644 --- a/Minecraft.Client/Common/GameRules/StartFeature.cpp +++ b/Minecraft.Client/Common/GameRules/StartFeature.cpp @@ -58,6 +58,6 @@ void StartFeature::addAttribute(const wstring &attributeName, const wstring &att bool StartFeature::isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature, int *orientation) { - if(orientation != NULL) *orientation = m_orientation; + if(orientation != nullptr) *orientation = m_orientation; return chunkX == m_chunkX && chunkZ == m_chunkZ && feature == m_feature; } \ No newline at end of file diff --git a/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp index 038ba5c78..99aee99b0 100644 --- a/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp @@ -12,7 +12,7 @@ UpdatePlayerRuleDefinition::UpdatePlayerRuleDefinition() m_bUpdateHealth = m_bUpdateFood = m_bUpdateYRot = false;; m_health = 0; m_food = 0; - m_spawnPos = NULL; + m_spawnPos = nullptr; m_yRot = 0.0f; } @@ -65,7 +65,7 @@ void UpdatePlayerRuleDefinition::getChildren(vector *child GameRuleDefinition *UpdatePlayerRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition *rule = NULL; + GameRuleDefinition *rule = nullptr; if(ruleType == ConsoleGameRules::eGameRuleType_AddItem) { rule = new AddItemRuleDefinition(); @@ -84,21 +84,21 @@ void UpdatePlayerRuleDefinition::addAttribute(const wstring &attributeName, cons { if(attributeName.compare(L"spawnX") == 0) { - if(m_spawnPos == NULL) m_spawnPos = new Pos(); + if(m_spawnPos == nullptr) m_spawnPos = new Pos(); int value = _fromString(attributeValue); m_spawnPos->x = value; app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnX=%d\n",value); } else if(attributeName.compare(L"spawnY") == 0) { - if(m_spawnPos == NULL) m_spawnPos = new Pos(); + if(m_spawnPos == nullptr) m_spawnPos = new Pos(); int value = _fromString(attributeValue); m_spawnPos->y = value; app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnY=%d\n",value); } else if(attributeName.compare(L"spawnZ") == 0) { - if(m_spawnPos == NULL) m_spawnPos = new Pos(); + if(m_spawnPos == nullptr) m_spawnPos = new Pos(); int value = _fromString(attributeValue); m_spawnPos->z = value; app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnZ=%d\n",value); @@ -148,7 +148,7 @@ void UpdatePlayerRuleDefinition::postProcessPlayer(shared_ptr player) double z = player->z; float yRot = player->yRot; float xRot = player->xRot; - if(m_spawnPos != NULL) + if(m_spawnPos != nullptr) { x = m_spawnPos->x; y = m_spawnPos->y; @@ -160,7 +160,7 @@ void UpdatePlayerRuleDefinition::postProcessPlayer(shared_ptr player) yRot = m_yRot; } - if(m_spawnPos != NULL || m_bUpdateYRot) player->absMoveTo(x,y,z,yRot,xRot); + if(m_spawnPos != nullptr || m_bUpdateYRot) player->absMoveTo(x,y,z,yRot,xRot); for(auto& addItem : m_items) { diff --git a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp index cd26ad451..1f4946912 100644 --- a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp +++ b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp @@ -33,7 +33,7 @@ void XboxStructureActionPlaceContainer::getChildren(vector GameRuleDefinition *XboxStructureActionPlaceContainer::addChild(ConsoleGameRules::EGameRuleType ruleType) { - GameRuleDefinition *rule = NULL; + GameRuleDefinition *rule = nullptr; if(ruleType == ConsoleGameRules::eGameRuleType_AddItem) { rule = new AddItemRuleDefinition(); @@ -70,7 +70,7 @@ bool XboxStructureActionPlaceContainer::placeContainerInLevel(StructurePiece *st if ( chunkBB->isInside( worldX, worldY, worldZ ) ) { - if ( level->getTileEntity( worldX, worldY, worldZ ) != NULL ) + if ( level->getTileEntity( worldX, worldY, worldZ ) != nullptr ) { // Remove the current tile entity level->removeTileEntity( worldX, worldY, worldZ ); @@ -81,7 +81,7 @@ bool XboxStructureActionPlaceContainer::placeContainerInLevel(StructurePiece *st shared_ptr container = dynamic_pointer_cast(level->getTileEntity( worldX, worldY, worldZ )); app.DebugPrintf("XboxStructureActionPlaceContainer - placing a container at (%d,%d,%d)\n", worldX, worldY, worldZ); - if ( container != NULL ) + if ( container != nullptr ) { level->setData( worldX, worldY, worldZ, m_data, Tile::UPDATE_CLIENTS); // Add items diff --git a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp index 3f6204af7..3e61154fc 100644 --- a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp +++ b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp @@ -46,7 +46,7 @@ bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel(StructurePiece *struct if ( chunkBB->isInside( worldX, worldY, worldZ ) ) { - if ( level->getTileEntity( worldX, worldY, worldZ ) != NULL ) + if ( level->getTileEntity( worldX, worldY, worldZ ) != nullptr ) { // Remove the current tile entity level->removeTileEntity( worldX, worldY, worldZ ); @@ -59,7 +59,7 @@ bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel(StructurePiece *struct #ifndef _CONTENT_PACKAGE wprintf(L"XboxStructureActionPlaceSpawner - placing a %ls spawner at (%d,%d,%d)\n", m_entityId.c_str(), worldX, worldY, worldZ); #endif - if( entity != NULL ) + if( entity != nullptr ) { entity->setEntityId(m_entityId); } diff --git a/Minecraft.Client/Common/Leaderboards/LeaderboardInterface.cpp b/Minecraft.Client/Common/Leaderboards/LeaderboardInterface.cpp index e93613c18..06f9a69bd 100644 --- a/Minecraft.Client/Common/Leaderboards/LeaderboardInterface.cpp +++ b/Minecraft.Client/Common/Leaderboards/LeaderboardInterface.cpp @@ -7,7 +7,7 @@ LeaderboardInterface::LeaderboardInterface(LeaderboardManager *man) m_pending = false; m_filter = static_cast(-1); - m_callback = NULL; + m_callback = nullptr; m_difficulty = 0; m_type = LeaderboardManager::eStatsType_UNDEFINED; m_startIndex = 0; diff --git a/Minecraft.Client/Common/Leaderboards/LeaderboardManager.cpp b/Minecraft.Client/Common/Leaderboards/LeaderboardManager.cpp index 33707b14c..2ba1efd60 100644 --- a/Minecraft.Client/Common/Leaderboards/LeaderboardManager.cpp +++ b/Minecraft.Client/Common/Leaderboards/LeaderboardManager.cpp @@ -12,7 +12,7 @@ const wstring LeaderboardManager::filterNames[eNumFilterModes] = void LeaderboardManager::DeleteInstance() { delete m_instance; - m_instance = NULL; + m_instance = nullptr; } LeaderboardManager::LeaderboardManager() @@ -26,7 +26,7 @@ void LeaderboardManager::zeroReadParameters() { m_difficulty = -1; m_statsType = eStatsType_UNDEFINED; - m_readListener = NULL; + m_readListener = nullptr; m_startIndex = 0; m_readCount = 0; m_eFilterMode = eFM_UNDEFINED; diff --git a/Minecraft.Client/Common/Leaderboards/SonyLeaderboardManager.cpp b/Minecraft.Client/Common/Leaderboards/SonyLeaderboardManager.cpp index 78d62568c..f2d48947d 100644 --- a/Minecraft.Client/Common/Leaderboards/SonyLeaderboardManager.cpp +++ b/Minecraft.Client/Common/Leaderboards/SonyLeaderboardManager.cpp @@ -35,7 +35,7 @@ SonyLeaderboardManager::SonyLeaderboardManager() m_myXUID = INVALID_XUID; - m_scores = NULL; + m_scores = nullptr; m_statsType = eStatsType_Kills; m_difficulty = 0; @@ -47,7 +47,7 @@ SonyLeaderboardManager::SonyLeaderboardManager() InitializeCriticalSection(&m_csViewsLock); m_running = false; - m_threadScoreboard = NULL; + m_threadScoreboard = nullptr; } SonyLeaderboardManager::~SonyLeaderboardManager() @@ -288,7 +288,7 @@ bool SonyLeaderboardManager::getScoreByIds() SonyRtcTick last_sort_date; SceNpScoreRankNumber mTotalRecord; - SceNpId *npIds = NULL; + SceNpId *npIds = nullptr; int ret; uint32_t num = 0; @@ -322,7 +322,7 @@ bool SonyLeaderboardManager::getScoreByIds() ZeroMemory(comments, sizeof(SceNpScoreComment) * num); /* app.DebugPrintf("sceNpScoreGetRankingByNpId(\n\t transaction=%i,\n\t boardID=0,\n\t npId=%i,\n\t friendCount*sizeof(SceNpId)=%i*%i=%i,\ - rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t NULL, 0, NULL, 0,\n\t friendCount=%i,\n...\n", + rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t nullptr, 0, nullptr, 0,\n\t friendCount=%i,\n...\n", transaction, npId, friendCount, sizeof(SceNpId), friendCount*sizeof(SceNpId), rankData, friendCount*sizeof(SceNpScorePlayerRankData), friendCount ); */ @@ -342,9 +342,9 @@ bool SonyLeaderboardManager::getScoreByIds() destroyTransactionContext(ret); - if (npIds != NULL) delete [] npIds; - if (ptr != NULL) delete [] ptr; - if (comments != NULL) delete [] comments; + if (npIds != nullptr) delete [] npIds; + if (ptr != nullptr) delete [] ptr; + if (comments != nullptr) delete [] comments; return false; } @@ -355,9 +355,9 @@ bool SonyLeaderboardManager::getScoreByIds() m_eStatsState = eStatsState_Failed; - if (npIds != NULL) delete [] npIds; - if (ptr != NULL) delete [] ptr; - if (comments != NULL) delete [] comments; + if (npIds != nullptr) delete [] npIds; + if (ptr != nullptr) delete [] ptr; + if (comments != nullptr) delete [] comments; return false; } @@ -387,14 +387,14 @@ bool SonyLeaderboardManager::getScoreByIds() comments, sizeof(SceNpScoreComment) * tmpNum, //OUT: Comments #endif - NULL, 0, // GameData. (unused) + nullptr, 0, // GameData. (unused) tmpNum, &last_sort_date, &mTotalRecord, - NULL // Reserved, specify null. + nullptr // Reserved, specify null. ); if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) @@ -425,7 +425,7 @@ bool SonyLeaderboardManager::getScoreByIds() m_readCount = num; // Filter scorers and construct output structure. - if (m_scores != NULL) delete [] m_scores; + if (m_scores != nullptr) delete [] m_scores; m_scores = new ReadScore[m_readCount]; convertToOutput(m_readCount, m_scores, ptr, comments); m_maxRank = m_readCount; @@ -458,7 +458,7 @@ bool SonyLeaderboardManager::getScoreByIds() delete [] ptr; delete [] comments; error2: - if (npIds != NULL) delete [] npIds; + if (npIds != nullptr) delete [] npIds; error1: if (m_eStatsState != eStatsState_Canceled) m_eStatsState = eStatsState_Failed; app.DebugPrintf("[SonyLeaderboardManager] getScoreByIds() FAILED, ret=0x%X\n", ret); @@ -511,14 +511,14 @@ bool SonyLeaderboardManager::getScoreByRange() comments, sizeof(SceNpScoreComment) * num, //OUT: Comment Data - NULL, 0, // GameData. + nullptr, 0, // GameData. num, &last_sort_date, &m_maxRank, // 'Total number of players registered in the target scoreboard.' - NULL // Reserved, specify null. + nullptr // Reserved, specify null. ); if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) @@ -539,7 +539,7 @@ bool SonyLeaderboardManager::getScoreByRange() delete [] ptr; delete [] comments; - m_scores = NULL; + m_scores = nullptr; m_readCount = 0; m_eStatsState = eStatsState_Ready; @@ -557,7 +557,7 @@ bool SonyLeaderboardManager::getScoreByRange() //m_stats = ptr; //Maybe: addPadding(num,ptr); - if (m_scores != NULL) delete [] m_scores; + if (m_scores != nullptr) delete [] m_scores; m_readCount = ret; m_scores = new ReadScore[m_readCount]; for (int i=0; i 0) ret = eStatsReturn_Success; - if (m_readListener != NULL) + if (m_readListener != nullptr) { app.DebugPrintf("[SonyLeaderboardManager] OnStatsReadComplete(%i, %i, _), m_readCount=%i.\n", ret, m_maxRank, m_readCount); m_readListener->OnStatsReadComplete(ret, m_maxRank, view); @@ -716,16 +716,16 @@ void SonyLeaderboardManager::Tick() m_eStatsState = eStatsState_Idle; delete [] m_scores; - m_scores = NULL; + m_scores = nullptr; } break; case eStatsState_Failed: { view.m_numQueries = 0; - view.m_queries = NULL; + view.m_queries = nullptr; - if ( m_readListener != NULL ) + if ( m_readListener != nullptr ) m_readListener->OnStatsReadComplete(eStatsReturn_NetworkError, 0, view); m_eStatsState = eStatsState_Idle; @@ -747,7 +747,7 @@ bool SonyLeaderboardManager::OpenSession() { if (m_openSessions == 0) { - if (m_threadScoreboard == NULL) + if (m_threadScoreboard == nullptr) { m_threadScoreboard = new C4JThread(&scoreboardThreadEntry, this, "4JScoreboard"); m_threadScoreboard->SetProcessor(CPU_CORE_LEADERBOARDS); @@ -837,7 +837,7 @@ void SonyLeaderboardManager::FlushStats() {} void SonyLeaderboardManager::CancelOperation() { - m_readListener = NULL; + m_readListener = nullptr; m_eStatsState = eStatsState_Canceled; if (m_requestId != 0) @@ -980,7 +980,7 @@ void SonyLeaderboardManager::fromBase32(void *out, SceNpScoreComment *in) for (int i = 0; i < SCE_NP_SCORE_COMMENT_MAXLEN; i++) { ch[0] = getComment(in)[i]; - unsigned char fivebits = strtol(ch, NULL, 32) << 3; + unsigned char fivebits = strtol(ch, nullptr, 32) << 3; int sByte = (i*5) / 8; int eByte = (5+(i*5)) / 8; @@ -1041,7 +1041,7 @@ bool SonyLeaderboardManager::test_string(string testing) int ctx = createTransactionContext(m_titleContext); if (ctx<0) return false; - int ret = sceNpScoreCensorComment(ctx, (const char *) &comment, NULL); + int ret = sceNpScoreCensorComment(ctx, (const char *) &comment, nullptr); if (ret == SCE_NP_COMMUNITY_SERVER_ERROR_CENSORED) { diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp index f8d1f0dad..7d282db5d 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp @@ -56,8 +56,8 @@ CGameNetworkManager::CGameNetworkManager() m_bFullSessionMessageOnNextSessionChange = false; #ifdef __ORBIS__ - m_pUpsell = NULL; - m_pInviteInfo = NULL; + m_pUpsell = nullptr; + m_pInviteInfo = nullptr; #endif } @@ -120,26 +120,26 @@ void CGameNetworkManager::DoWork() s_pPlatformNetworkManager->DoWork(); #ifdef __ORBIS__ - if (m_pUpsell != NULL && m_pUpsell->hasResponse()) + if (m_pUpsell != nullptr && m_pUpsell->hasResponse()) { int iPad_invited = m_iPlayerInvited, iPad_checking = m_pUpsell->m_userIndex; m_iPlayerInvited = -1; delete m_pUpsell; - m_pUpsell = NULL; + m_pUpsell = nullptr; if (ProfileManager.HasPlayStationPlus(iPad_checking)) { this->GameInviteReceived(iPad_invited, m_pInviteInfo); // m_pInviteInfo deleted by GameInviteReceived. - m_pInviteInfo = NULL; + m_pInviteInfo = nullptr; } else { delete m_pInviteInfo; - m_pInviteInfo = NULL; + m_pInviteInfo = nullptr; } } #endif @@ -195,15 +195,15 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame #endif __int64 seed = 0; - if(lpParameter != NULL) + if(lpParameter != nullptr) { NetworkGameInitData *param = static_cast(lpParameter); seed = param->seed; app.setLevelGenerationOptions(param->levelGen); - if(param->levelGen != NULL) + if(param->levelGen != nullptr) { - if(app.getLevelGenerationOptions() == NULL) + if(app.getLevelGenerationOptions() == nullptr) { app.DebugPrintf("Game rule was not loaded, and seed is required. Exiting.\n"); return false; @@ -248,10 +248,10 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #else const char *pchFilename=wstringtofilename(grf.getPath()); @@ -259,18 +259,18 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #endif if( fileHandle != INVALID_HANDLE_VALUE ) { - DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,nullptr); PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { app.FatalLoadError(); @@ -312,7 +312,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame } else { - Socket::Initialise(NULL); + Socket::Initialise(nullptr); } #ifndef _XBOX @@ -358,27 +358,27 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame if( g_NetworkManager.IsHost() ) { - connection = new ClientConnection(minecraft, NULL); + connection = new ClientConnection(minecraft, nullptr); } else { INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(ProfileManager.GetLockedProfile()); - if(pNetworkPlayer == NULL) + if(pNetworkPlayer == nullptr) { MinecraftServer::HaltServer(); app.DebugPrintf("%d\n",ProfileManager.GetLockedProfile()); - // If the player is NULL here then something went wrong in the session setup, and continuing will end up in a crash + // If the player is nullptr here then something went wrong in the session setup, and continuing will end up in a crash return false; } Socket *socket = pNetworkPlayer->GetSocket(); // Fix for #13259 - CRASH: Gameplay: loading process is halted when player loads saved data - if(socket == NULL) + if(socket == nullptr) { assert(false); MinecraftServer::HaltServer(); - // If the socket is NULL here then something went wrong in the session setup, and continuing will end up in a crash + // If the socket is nullptr here then something went wrong in the session setup, and continuing will end up in a crash return false; } @@ -389,7 +389,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame { assert(false); delete connection; - connection = NULL; + connection = nullptr; MinecraftServer::HaltServer(); return false; } @@ -453,7 +453,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame // Already have setup the primary pad if(idx == ProfileManager.GetPrimaryPad() ) continue; - if( GetLocalPlayerByUserIndex(idx) != NULL && !ProfileManager.IsSignedIn(idx) ) + if( GetLocalPlayerByUserIndex(idx) != nullptr && !ProfileManager.IsSignedIn(idx) ) { INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx); Socket *socket = pNetworkPlayer->GetSocket(); @@ -467,7 +467,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame // when joining any other way, so just because they are signed in doesn't mean they are in the session // 4J Stu - If they are in the session, then we should add them to the game. Otherwise we won't be able to add them later INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx); - if( pNetworkPlayer == NULL ) + if( pNetworkPlayer == nullptr ) continue; ClientConnection *connection; @@ -801,9 +801,9 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; #if defined(__PS3__) || defined(__PSVITA__) - ProfileManager.GetChatAndContentRestrictions(iPad,false,&noUGC,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,false,&noUGC,nullptr,nullptr); #elif defined(__ORBIS__) - ProfileManager.GetChatAndContentRestrictions(iPad,false,NULL,&noUGC,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,false,nullptr,&noUGC,nullptr); #endif if(noUGC) @@ -823,7 +823,7 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin { #if defined(__ORBIS__) || defined(__PSVITA__) bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(iPad,false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,false,&chatRestricted,nullptr,nullptr); if(chatRestricted) { ProfileManager.DisplaySystemMessage( 0, ProfileManager.GetPrimaryPad() ); @@ -912,7 +912,7 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter ) app.SetDisconnectReason( DisconnectPacket::eDisconnect_ConnectionCreationFailed ); } // If we failed before the server started, clear the game rules. Otherwise the server will clear it up. - if(MinecraftServer::getInstance() == NULL) app.m_gameRules.unloadCurrentGameRules(); + if(MinecraftServer::getInstance() == nullptr) app.m_gameRules.unloadCurrentGameRules(); Tile::ReleaseThreadStorage(); return -1; } @@ -930,14 +930,14 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter ) int CGameNetworkManager::ServerThreadProc( void* lpParameter ) { __int64 seed = 0; - if(lpParameter != NULL) + if(lpParameter != nullptr) { NetworkGameInitData *param = static_cast(lpParameter); seed = param->seed; app.SetGameHostOption(eGameHostOption_All,param->settings); // 4J Stu - If we are loading a DLC save that's separate from the texture pack, load - if( param->levelGen != NULL && (param->texturePackId == 0 || param->levelGen->getRequiredTexturePackId() != param->texturePackId) ) + if( param->levelGen != nullptr && (param->texturePackId == 0 || param->levelGen->getRequiredTexturePackId() != param->texturePackId) ) { while((Minecraft::GetInstance()->skins->needsUIUpdate() || ui.IsReloadingSkin())) { @@ -966,7 +966,7 @@ int CGameNetworkManager::ServerThreadProc( void* lpParameter ) IntCache::ReleaseThreadStorage(); Level::destroyLightingCache(); - if(lpParameter != NULL) delete lpParameter; + if(lpParameter != nullptr) delete lpParameter; return S_OK; } @@ -979,7 +979,7 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc( void* lpParam ) Compression::UseDefaultThreadStorage(); //app.SetGameStarted(false); - UIScene_PauseMenu::_ExitWorld(NULL); + UIScene_PauseMenu::_ExitWorld(nullptr); while( g_NetworkManager.IsInSession() ) { @@ -1216,14 +1216,14 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) #endif // Null the network player of all the server players that are local, to stop them being removed from the server when removed from the session - if( pServer != NULL ) + if( pServer != nullptr ) { PlayerList *players = pServer->getPlayers(); for(auto& servPlayer : players->players) { if( servPlayer->connection->isLocal() && !servPlayer->connection->isGuest() ) { - servPlayer->connection->connection->getSocket()->setPlayer(NULL); + servPlayer->connection->connection->getSocket()->setPlayer(nullptr); } } } @@ -1259,7 +1259,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) char numLocalPlayers = 0; for(unsigned int index = 0; index < XUSER_MAX_COUNT; ++index) { - if(ProfileManager.IsSignedIn(index) && pMinecraft->localplayers[index] != NULL ) + if(ProfileManager.IsSignedIn(index) && pMinecraft->localplayers[index] != nullptr ) { numLocalPlayers++; localUsersMask |= GetLocalPlayerMask(index); @@ -1277,11 +1277,11 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) } // Restore the network player of all the server players that are local - if( pServer != NULL ) + if( pServer != nullptr ) { for(unsigned int index = 0; index < XUSER_MAX_COUNT; ++index) { - if(ProfileManager.IsSignedIn(index) && pMinecraft->localplayers[index] != NULL ) + if(ProfileManager.IsSignedIn(index) && pMinecraft->localplayers[index] != nullptr ) { PlayerUID localPlayerXuid = pMinecraft->localplayers[index]->getXuid(); @@ -1295,7 +1295,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) } // Player might have a pending connection - if (pMinecraft->m_pendingLocalConnections[index] != NULL) + if (pMinecraft->m_pendingLocalConnections[index] != nullptr) { // Update the network player pMinecraft->m_pendingLocalConnections[index]->getConnection()->getSocket()->setPlayer(g_NetworkManager.GetLocalPlayerByUserIndex(index)); @@ -1361,8 +1361,8 @@ void CGameNetworkManager::renderQueueMeter() #ifdef _XBOX int height = 720; - CGameNetworkManager::byteQueue[(CGameNetworkManager::messageQueuePos) & (CGameNetworkManager::messageQueue_length - 1)] = GetHostPlayer()->GetSendQueueSizeBytes(NULL, false); - CGameNetworkManager::messageQueue[(CGameNetworkManager::messageQueuePos++) & (CGameNetworkManager::messageQueue_length - 1)] = GetHostPlayer()->GetSendQueueSizeMessages(NULL, false); + CGameNetworkManager::byteQueue[(CGameNetworkManager::messageQueuePos) & (CGameNetworkManager::messageQueue_length - 1)] = GetHostPlayer()->GetSendQueueSizeBytes(nullptr, false); + CGameNetworkManager::messageQueue[(CGameNetworkManager::messageQueuePos++) & (CGameNetworkManager::messageQueue_length - 1)] = GetHostPlayer()->GetSendQueueSizeMessages(nullptr, false); Minecraft *pMinecraft = Minecraft::GetInstance(); pMinecraft->gui->renderGraph(CGameNetworkManager::messageQueue_length, CGameNetworkManager::messageQueuePos, CGameNetworkManager::messageQueue, 10, 1000, CGameNetworkManager::byteQueue, 100, 25000); @@ -1426,7 +1426,7 @@ void CGameNetworkManager::StateChange_AnyToStarting() { LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1447,7 +1447,7 @@ void CGameNetworkManager::StateChange_AnyToEnding(bool bStateWasPlaying) for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(i); - if(pNetworkPlayer != NULL && ProfileManager.IsSignedIn( i ) ) + if(pNetworkPlayer != nullptr && ProfileManager.IsSignedIn( i ) ) { app.DebugPrintf("Stats save for an offline game for the player at index %d\n", i ); Minecraft::GetInstance()->forceStatsSave(pNetworkPlayer->GetUserIndex()); @@ -1482,12 +1482,12 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc { Minecraft *pMinecraft = Minecraft::GetInstance(); - Socket *socket = NULL; + Socket *socket = nullptr; shared_ptr mpPlayer = nullptr; int userIdx = pNetworkPlayer->GetUserIndex(); if (userIdx >= 0 && userIdx < XUSER_MAX_COUNT) mpPlayer = pMinecraft->localplayers[userIdx]; - if( localPlayer && mpPlayer != NULL && mpPlayer->connection != NULL) + if( localPlayer && mpPlayer != nullptr && mpPlayer->connection != nullptr) { // If we already have a MultiplayerLocalPlayer here then we are doing a session type change socket = mpPlayer->connection->getSocket(); @@ -1530,7 +1530,7 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc { pMinecraft->connectionDisconnected( idx , DisconnectPacket::eDisconnect_ConnectionCreationFailed ); delete connection; - connection = NULL; + connection = nullptr; } } } @@ -1540,10 +1540,10 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc void CGameNetworkManager::CloseConnection( INetworkPlayer *pNetworkPlayer ) { MinecraftServer *server = MinecraftServer::getInstance(); - if( server != NULL ) + if( server != nullptr ) { PlayerList *players = server->getPlayers(); - if( players != NULL ) + if( players != nullptr ) { players->closePlayerConnectionBySmallId(pNetworkPlayer->GetSmallId()); } @@ -1559,7 +1559,7 @@ void CGameNetworkManager::PlayerJoining( INetworkPlayer *pNetworkPlayer ) for (int iPad=0; iPadlocalplayers[idx] != NULL) + if(Minecraft::GetInstance()->localplayers[idx] != nullptr) { TelemetryManager->RecordLevelStart(idx, eSen_FriendOrMatch_Playing_With_Invited_Friends, eSen_CompeteOrCoop_Coop_and_Competitive, Minecraft::GetInstance()->level->difficulty, app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount()); } @@ -1609,7 +1609,7 @@ void CGameNetworkManager::PlayerLeaving( INetworkPlayer *pNetworkPlayer ) { for(int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(Minecraft::GetInstance()->localplayers[idx] != NULL) + if(Minecraft::GetInstance()->localplayers[idx] != nullptr) { TelemetryManager->RecordLevelStart(idx, eSen_FriendOrMatch_Playing_With_Invited_Friends, eSen_CompeteOrCoop_Coop_and_Competitive, Minecraft::GetInstance()->level->difficulty, app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount()); } @@ -1632,7 +1632,7 @@ void CGameNetworkManager::WriteStats( INetworkPlayer *pNetworkPlayer ) void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *pInviteInfo) { #ifdef __ORBIS__ - if (m_pUpsell != NULL) + if (m_pUpsell != nullptr) { delete pInviteInfo; return; @@ -1721,7 +1721,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * { // 4J-PB we shouldn't bring any inactive players into the game, except for the invited player (who may be an inactive player) // 4J Stu - If we are not in a game, then bring in all players signed in - if(index==userIndex || pMinecraft->localplayers[index]!=NULL ) + if(index==userIndex || pMinecraft->localplayers[index]!=nullptr ) { ++joiningUsers; if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true; @@ -1736,7 +1736,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * BOOL pccAllowed = TRUE; BOOL pccFriendsAllowed = TRUE; #if defined(__PS3__) || defined(__PSVITA__) - ProfileManager.GetChatAndContentRestrictions(userIndex,false,&noUGC,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(userIndex,false,&noUGC,&bContentRestricted,nullptr); #else ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -1781,14 +1781,14 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * uiIDA[0]=IDS_CONFIRM_OK; // 4J-PB - it's possible there is no primary pad here, when accepting an invite from the dashboard - //StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + //StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); ui.RequestErrorMessage( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,XUSER_INDEX_ANY); } else { #if defined(__ORBIS__) || defined(__PSVITA__) bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,nullptr,nullptr); if(chatRestricted) { ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); @@ -1984,7 +1984,7 @@ const char *CGameNetworkManager::GetOnlineName(int playerIdx) void CGameNetworkManager::ServerReadyCreate(bool create) { - m_hServerReadyEvent = ( create ? ( new C4JThread::Event ) : NULL ); + m_hServerReadyEvent = ( create ? ( new C4JThread::Event ) : nullptr ); } void CGameNetworkManager::ServerReady() @@ -2000,17 +2000,17 @@ void CGameNetworkManager::ServerReadyWait() void CGameNetworkManager::ServerReadyDestroy() { delete m_hServerReadyEvent; - m_hServerReadyEvent = NULL; + m_hServerReadyEvent = nullptr; } bool CGameNetworkManager::ServerReadyValid() { - return ( m_hServerReadyEvent != NULL ); + return ( m_hServerReadyEvent != nullptr ); } void CGameNetworkManager::ServerStoppedCreate(bool create) { - m_hServerStoppedEvent = ( create ? ( new C4JThread::Event ) : NULL ); + m_hServerStoppedEvent = ( create ? ( new C4JThread::Event ) : nullptr ); } void CGameNetworkManager::ServerStopped() @@ -2051,12 +2051,12 @@ void CGameNetworkManager::ServerStoppedWait() void CGameNetworkManager::ServerStoppedDestroy() { delete m_hServerStoppedEvent; - m_hServerStoppedEvent = NULL; + m_hServerStoppedEvent = nullptr; } bool CGameNetworkManager::ServerStoppedValid() { - return ( m_hServerStoppedEvent != NULL ); + return ( m_hServerStoppedEvent != nullptr ); } int CGameNetworkManager::GetJoiningReadyPercentage() diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.h b/Minecraft.Client/Common/Network/GameNetworkManager.h index bb7633c28..c5049320a 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.h +++ b/Minecraft.Client/Common/Network/GameNetworkManager.h @@ -108,7 +108,7 @@ class CGameNetworkManager static void CancelJoinGame(LPVOID lpParam); // Not part of the shared interface bool LeaveGame(bool bMigrateHost); static int JoinFromInvite_SignInReturned(void *pParam,bool bContinue, int iPad); - void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL); + void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr); void SendInviteGUI(int iPad); void ResetLeavingGame(); @@ -137,17 +137,17 @@ class CGameNetworkManager // Events - void ServerReadyCreate(bool create); // Create the signal (or set to NULL) + void ServerReadyCreate(bool create); // Create the signal (or set to nullptr) void ServerReady(); // Signal that we are ready void ServerReadyWait(); // Wait for the signal void ServerReadyDestroy(); // Destroy signal - bool ServerReadyValid(); // Is non-NULL + bool ServerReadyValid(); // Is non-nullptr void ServerStoppedCreate(bool create); // Create the signal void ServerStopped(); // Signal that we are ready void ServerStoppedWait(); // Wait for the signal void ServerStoppedDestroy(); // Destroy signal - bool ServerStoppedValid(); // Is non-NULL + bool ServerStoppedValid(); // Is non-nullptr #ifdef __PSVITA__ static bool usingAdhocMode(); diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerInterface.h b/Minecraft.Client/Common/Network/PlatformNetworkManagerInterface.h index 31c415a75..3ed0f888f 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerInterface.h +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerInterface.h @@ -93,7 +93,7 @@ class CPlatformNetworkManager public: - virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL) = 0; + virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr) = 0; private: virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer ) = 0; diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp index 486fe0671..997d055a4 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp @@ -101,7 +101,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer ) for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, false ); } @@ -110,7 +110,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer ) int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pIQNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pIQNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -125,11 +125,11 @@ void CPlatformNetworkManagerStub::NotifyPlayerLeaving(IQNetPlayer* pQNetPlayer) app.DebugPrintf("Player 0x%p \"%ls\" leaving.\n", pQNetPlayer, pQNetPlayer->GetGamertag()); INetworkPlayer* networkPlayer = getNetworkPlayer(pQNetPlayer); - if (networkPlayer == NULL) + if (networkPlayer == nullptr) return; Socket* socket = networkPlayer->GetSocket(); - if (socket != NULL) + if (socket != nullptr) { if (m_pIQNet->IsHost()) g_NetworkManager.CloseConnection(networkPlayer); @@ -144,7 +144,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerLeaving(IQNetPlayer* pQNetPlayer) for (int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if (playerChangedCallback[idx] != NULL) + if (playerChangedCallback[idx] != nullptr) playerChangedCallback[idx](playerChangedCallbackParam[idx], networkPlayer, true); } @@ -160,7 +160,7 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa g_pPlatformNetworkManager = this; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - playerChangedCallback[ i ] = NULL; + playerChangedCallback[ i ] = nullptr; } m_bLeavingGame = false; @@ -171,8 +171,8 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa m_bSearchPending = false; m_bIsOfflineGame = false; - m_pSearchParam = NULL; - m_SessionsUpdatedCallback = NULL; + m_pSearchParam = nullptr; + m_SessionsUpdatedCallback = nullptr; for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { @@ -180,10 +180,10 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa m_lastSearchStartTime[i] = 0; // The results that will be filled in with the current search - m_pSearchResults[i] = NULL; - m_pQoSResult[i] = NULL; - m_pCurrentSearchResults[i] = NULL; - m_pCurrentQoSResult[i] = NULL; + m_pSearchResults[i] = nullptr; + m_pQoSResult[i] = nullptr; + m_pCurrentSearchResults[i] = nullptr; + m_pCurrentQoSResult[i] = nullptr; m_currentSearchResultsCount[i] = 0; } @@ -229,7 +229,7 @@ void CPlatformNetworkManagerStub::DoWork() while (WinsockNetLayer::PopDisconnectedSmallId(&disconnectedSmallId)) { IQNetPlayer* qnetPlayer = m_pIQNet->GetPlayerBySmallId(disconnectedSmallId); - if (qnetPlayer != NULL && qnetPlayer->m_smallId == disconnectedSmallId) + if (qnetPlayer != nullptr && qnetPlayer->m_smallId == disconnectedSmallId) { NotifyPlayerLeaving(qnetPlayer); qnetPlayer->m_smallId = 0; @@ -366,7 +366,7 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame, #ifdef _WINDOWS64 int port = WIN64_NET_DEFAULT_PORT; - const char* bindIp = NULL; + const char* bindIp = nullptr; if (g_Win64DedicatedServer) { if (g_Win64DedicatedServerPort > 0) @@ -399,7 +399,7 @@ bool CPlatformNetworkManagerStub::_StartGame() int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo* searchResult, int localUsersMask, int primaryUserIndex) { #ifdef _WINDOWS64 - if (searchResult == NULL) + if (searchResult == nullptr) return CGameNetworkManager::JOINGAME_FAIL_GENERAL; const char* hostIP = searchResult->data.hostIP; @@ -473,8 +473,8 @@ void CPlatformNetworkManagerStub::UnRegisterPlayerChangedCallback(int iPad, void { if(playerChangedCallbackParam[iPad] == callbackParam) { - playerChangedCallback[iPad] = NULL; - playerChangedCallbackParam[iPad] = NULL; + playerChangedCallback[iPad] = nullptr; + playerChangedCallbackParam[iPad] = nullptr; } } @@ -494,7 +494,7 @@ bool CPlatformNetworkManagerStub::_RunNetworkGame() if (IQNet::m_player[i].m_isRemote) { INetworkPlayer* pNetworkPlayer = getNetworkPlayer(&IQNet::m_player[i]); - if (pNetworkPlayer != NULL && pNetworkPlayer->GetSocket() != NULL) + if (pNetworkPlayer != nullptr && pNetworkPlayer->GetSocket() != nullptr) { Socket::addIncomingSocket(pNetworkPlayer->GetSocket()); } @@ -504,14 +504,14 @@ bool CPlatformNetworkManagerStub::_RunNetworkGame() return true; } -void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/) +void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= nullptr*/) { // DWORD playerCount = m_pIQNet->GetPlayerCount(); // // if( this->m_bLeavingGame ) // return; // -// if( GetHostPlayer() == NULL ) +// if( GetHostPlayer() == nullptr ) // return; // // for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) @@ -531,13 +531,13 @@ void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pN // } // else // { -// m_hostGameSessionData.players[i] = NULL; +// m_hostGameSessionData.players[i] = nullptr; // memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE); // } // } // else // { -// m_hostGameSessionData.players[i] = NULL; +// m_hostGameSessionData.players[i] = nullptr; // memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE); // } // } @@ -552,14 +552,14 @@ int CPlatformNetworkManagerStub::RemovePlayerOnSocketClosedThreadProc( void* lpP Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { //printf("Waiting for socket closed event\n"); socket->m_socketClosedEvent->WaitForSignal(INFINITE); //printf("Socket closed event has fired\n"); // 4J Stu - Clear our reference to this socket - pNetworkPlayer->SetSocket( NULL ); + pNetworkPlayer->SetSocket( nullptr ); delete socket; } @@ -631,7 +631,7 @@ void CPlatformNetworkManagerStub::SystemFlagReset() void CPlatformNetworkManagerStub::SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return; - if( pNetworkPlayer == NULL ) return; + if( pNetworkPlayer == nullptr ) return; for( unsigned int i = 0; i < m_playerFlags.size(); i++ ) { @@ -647,7 +647,7 @@ void CPlatformNetworkManagerStub::SystemFlagSet(INetworkPlayer *pNetworkPlayer, bool CPlatformNetworkManagerStub::SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return false; - if( pNetworkPlayer == NULL ) + if( pNetworkPlayer == nullptr ) { return false; } @@ -690,7 +690,7 @@ wstring CPlatformNetworkManagerStub::GatherRTTStats() void CPlatformNetworkManagerStub::TickSearch() { #ifdef _WINDOWS64 - if (m_SessionsUpdatedCallback == NULL) + if (m_SessionsUpdatedCallback == nullptr) return; static DWORD lastSearchTime = 0; @@ -790,7 +790,7 @@ void CPlatformNetworkManagerStub::SearchForGames() m_searchResultsCount[0] = static_cast(friendsSessions[0].size()); - if (m_SessionsUpdatedCallback != NULL) + if (m_SessionsUpdatedCallback != nullptr) m_SessionsUpdatedCallback(m_pSearchParam); #endif } @@ -838,7 +838,7 @@ void CPlatformNetworkManagerStub::ForceFriendsSessionRefresh() m_searchResultsCount[i] = 0; m_lastSearchStartTime[i] = 0; delete m_pSearchResults[i]; - m_pSearchResults[i] = NULL; + m_pSearchResults[i] = nullptr; } } @@ -865,7 +865,7 @@ void CPlatformNetworkManagerStub::removeNetworkPlayer(IQNetPlayer *pQNetPlayer) INetworkPlayer *CPlatformNetworkManagerStub::getNetworkPlayer(IQNetPlayer *pQNetPlayer) { - return pQNetPlayer ? (INetworkPlayer *)(pQNetPlayer->GetCustomDataValue()) : NULL; + return pQNetPlayer ? (INetworkPlayer *)(pQNetPlayer->GetCustomDataValue()) : nullptr; } diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.h b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.h index 28953cecb..bb4571bdc 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.h +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.h @@ -81,7 +81,7 @@ class CPlatformNetworkManagerStub : public CPlatformNetworkManager GameSessionData m_hostGameSessionData; CGameNetworkManager *m_pGameNetworkManager; public: - virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL); + virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr); private: // TODO 4J Stu - Do we need to be able to have more than one of these? diff --git a/Minecraft.Client/Common/Network/SessionInfo.h b/Minecraft.Client/Common/Network/SessionInfo.h index ce6365bc4..7ae53c289 100644 --- a/Minecraft.Client/Common/Network/SessionInfo.h +++ b/Minecraft.Client/Common/Network/SessionInfo.h @@ -113,7 +113,7 @@ class FriendSessionInfo FriendSessionInfo() { - displayLabel = NULL; + displayLabel = nullptr; displayLabelLength = 0; displayLabelViewableStartIndex = 0; hasPartyMember = false; @@ -121,7 +121,7 @@ class FriendSessionInfo ~FriendSessionInfo() { - if (displayLabel != NULL) + if (displayLabel != nullptr) delete displayLabel; } }; diff --git a/Minecraft.Client/Common/Network/Sony/NetworkPlayerSony.cpp b/Minecraft.Client/Common/Network/Sony/NetworkPlayerSony.cpp index 9b44418f7..293d680f5 100644 --- a/Minecraft.Client/Common/Network/Sony/NetworkPlayerSony.cpp +++ b/Minecraft.Client/Common/Network/Sony/NetworkPlayerSony.cpp @@ -4,7 +4,7 @@ NetworkPlayerSony::NetworkPlayerSony(SQRNetworkPlayer *qnetPlayer) { m_sqrPlayer = qnetPlayer; - m_pSocket = NULL; + m_pSocket = nullptr; m_lastChunkPacketTime = 0; } diff --git a/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.cpp b/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.cpp index a9799d265..107101f4a 100644 --- a/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.cpp +++ b/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.cpp @@ -123,7 +123,7 @@ void CPlatformNetworkManagerSony::HandleDataReceived(SQRNetworkPlayer *playerFro INetworkPlayer *pPlayerFrom = getNetworkPlayer(playerFrom); Socket *socket = pPlayerFrom->GetSocket(); - if(socket != NULL) + if(socket != nullptr) socket->pushDataToQueue(data, dataSize, false); } else @@ -132,7 +132,7 @@ void CPlatformNetworkManagerSony::HandleDataReceived(SQRNetworkPlayer *playerFro INetworkPlayer *pPlayerTo = getNetworkPlayer(playerTo); Socket *socket = pPlayerTo->GetSocket(); //app.DebugPrintf( "Pushing data into read queue for user \"%ls\"\n", apPlayersTo[dwPlayer]->GetGamertag()); - if(socket != NULL) + if(socket != nullptr) socket->pushDataToQueue(data, dataSize); } } @@ -226,7 +226,7 @@ void CPlatformNetworkManagerSony::HandlePlayerJoined(SQRNetworkPlayer * for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, false ); } @@ -235,7 +235,7 @@ void CPlatformNetworkManagerSony::HandlePlayerJoined(SQRNetworkPlayer * int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pSQRNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pSQRNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -258,7 +258,7 @@ void CPlatformNetworkManagerSony::HandlePlayerLeaving(SQRNetworkPlayer *pSQRPlay { // Get our wrapper object associated with this player. Socket *socket = networkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { // If we are in game then remove this player from the game as well. // We may get here either from the player requesting to exit the game, @@ -274,19 +274,19 @@ void CPlatformNetworkManagerSony::HandlePlayerLeaving(SQRNetworkPlayer *pSQRPlay // We need this as long as the game server still needs to communicate with the player //delete socket; - networkPlayer->SetSocket( NULL ); + networkPlayer->SetSocket( nullptr ); } if( m_pSQRNet->IsHost() && !m_bHostChanged ) { if( isSystemPrimaryPlayer(pSQRPlayer) ) { - SQRNetworkPlayer *pNewSQRPrimaryPlayer = NULL; + SQRNetworkPlayer *pNewSQRPrimaryPlayer = nullptr; for(unsigned int i = 0; i < m_pSQRNet->GetPlayerCount(); ++i ) { SQRNetworkPlayer *pSQRPlayer2 = m_pSQRNet->GetPlayerByIndex( i ); - if ( pSQRPlayer2 != NULL && pSQRPlayer2 != pSQRPlayer && pSQRPlayer2->IsSameSystem( pSQRPlayer ) ) + if ( pSQRPlayer2 != nullptr && pSQRPlayer2 != pSQRPlayer && pSQRPlayer2->IsSameSystem( pSQRPlayer ) ) { pNewSQRPrimaryPlayer = pSQRPlayer2; break; @@ -298,7 +298,7 @@ void CPlatformNetworkManagerSony::HandlePlayerLeaving(SQRNetworkPlayer *pSQRPlay m_machineSQRPrimaryPlayers.erase( it ); } - if( pNewSQRPrimaryPlayer != NULL ) + if( pNewSQRPrimaryPlayer != nullptr ) m_machineSQRPrimaryPlayers.push_back( pNewSQRPrimaryPlayer ); } @@ -311,7 +311,7 @@ void CPlatformNetworkManagerSony::HandlePlayerLeaving(SQRNetworkPlayer *pSQRPlay for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, true ); } @@ -320,7 +320,7 @@ void CPlatformNetworkManagerSony::HandlePlayerLeaving(SQRNetworkPlayer *pSQRPlay int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pSQRNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pSQRNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -391,7 +391,7 @@ bool CPlatformNetworkManagerSony::Initialise(CGameNetworkManager *pGameNetworkMa if(ProfileManager.IsSignedInPSN(ProfileManager.GetPrimaryPad())) { // we're signed into the PSN, but we won't be online yet, force a sign-in online here - m_pSQRNet_Vita->AttemptPSNSignIn(NULL, NULL); + m_pSQRNet_Vita->AttemptPSNSignIn(nullptr, nullptr); } @@ -402,7 +402,7 @@ bool CPlatformNetworkManagerSony::Initialise(CGameNetworkManager *pGameNetworkMa g_pPlatformNetworkManager = this; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - playerChangedCallback[ i ] = NULL; + playerChangedCallback[ i ] = nullptr; } m_bLeavingGame = false; @@ -413,11 +413,11 @@ bool CPlatformNetworkManagerSony::Initialise(CGameNetworkManager *pGameNetworkMa m_bSearchPending = false; m_bIsOfflineGame = false; - m_pSearchParam = NULL; - m_SessionsUpdatedCallback = NULL; + m_pSearchParam = nullptr; + m_SessionsUpdatedCallback = nullptr; m_searchResultsCount = 0; - m_pSearchResults = NULL; + m_pSearchResults = nullptr; m_lastSearchStartTime = 0; @@ -622,11 +622,11 @@ bool CPlatformNetworkManagerSony::RemoveLocalPlayerByUserIndex( int userIndex ) SQRNetworkPlayer *pSQRPlayer = m_pSQRNet->GetLocalPlayerByUserIndex(userIndex); INetworkPlayer *pNetworkPlayer = getNetworkPlayer(pSQRPlayer); - if(pNetworkPlayer != NULL) + if(pNetworkPlayer != nullptr) { Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { // We can't remove the player from qnet until we have stopped using it to communicate C4JThread* thread = new C4JThread(&CPlatformNetworkManagerSony::RemovePlayerOnSocketClosedThreadProc, pNetworkPlayer, "RemovePlayerOnSocketClosed"); @@ -702,11 +702,11 @@ bool CPlatformNetworkManagerSony::LeaveGame(bool bMigrateHost) SQRNetworkPlayer *pSQRPlayer = m_pSQRNet->GetLocalPlayerByUserIndex(g_NetworkManager.GetPrimaryPad()); INetworkPlayer *pNetworkPlayer = getNetworkPlayer(pSQRPlayer); - if(pNetworkPlayer != NULL) + if(pNetworkPlayer != nullptr) { Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { //printf("Waiting for socket closed event\n"); DWORD result = socket->m_socketClosedEvent->WaitForSignal(INFINITE); @@ -718,13 +718,13 @@ bool CPlatformNetworkManagerSony::LeaveGame(bool bMigrateHost) // 4J Stu - Clear our reference to this socket pSQRPlayer = m_pSQRNet->GetLocalPlayerByUserIndex(g_NetworkManager.GetPrimaryPad()); pNetworkPlayer = getNetworkPlayer(pSQRPlayer); - pNetworkPlayer->SetSocket( NULL ); + pNetworkPlayer->SetSocket( nullptr ); } delete socket; } else { - //printf("Socket is already NULL\n"); + //printf("Socket is already nullptr\n"); } } @@ -878,8 +878,8 @@ void CPlatformNetworkManagerSony::UnRegisterPlayerChangedCallback(int iPad, void { if(playerChangedCallbackParam[iPad] == callbackParam) { - playerChangedCallback[iPad] = NULL; - playerChangedCallbackParam[iPad] = NULL; + playerChangedCallback[iPad] = nullptr; + playerChangedCallbackParam[iPad] = nullptr; } } @@ -917,7 +917,7 @@ bool CPlatformNetworkManagerSony::_RunNetworkGame() // Note that this does less than the xbox equivalent as we have HandleResyncPlayerRequest that is called by the underlying SQRNetworkManager when players are added/removed etc., so this // call is only used to update the game host settings & then do the final push out of the data. -void CPlatformNetworkManagerSony::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/) +void CPlatformNetworkManagerSony::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= nullptr*/) { if( this->m_bLeavingGame ) return; @@ -934,7 +934,7 @@ void CPlatformNetworkManagerSony::UpdateAndSetGameSessionData(INetworkPlayer *pN // If this is called With a pNetworkPlayerLeaving, then the call has ultimately started within SQRNetworkManager::RemoveRemotePlayersAndSync, so we don't need to sync each change // as that function does a sync at the end of all changes. - if( pNetworkPlayerLeaving == NULL ) + if( pNetworkPlayerLeaving == nullptr ) { m_pSQRNet->UpdateExternalRoomData(); } @@ -946,14 +946,14 @@ int CPlatformNetworkManagerSony::RemovePlayerOnSocketClosedThreadProc( void* lpP Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { //printf("Waiting for socket closed event\n"); socket->m_socketClosedEvent->WaitForSignal(INFINITE); //printf("Socket closed event has fired\n"); // 4J Stu - Clear our reference to this socket - pNetworkPlayer->SetSocket( NULL ); + pNetworkPlayer->SetSocket( nullptr ); delete socket; } @@ -1030,7 +1030,7 @@ void CPlatformNetworkManagerSony::SystemFlagReset() void CPlatformNetworkManagerSony::SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return; - if( pNetworkPlayer == NULL ) return; + if( pNetworkPlayer == nullptr ) return; for( unsigned int i = 0; i < m_playerFlags.size(); i++ ) { @@ -1046,7 +1046,7 @@ void CPlatformNetworkManagerSony::SystemFlagSet(INetworkPlayer *pNetworkPlayer, bool CPlatformNetworkManagerSony::SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return false; - if( pNetworkPlayer == NULL ) + if( pNetworkPlayer == nullptr ) { return false; } @@ -1064,8 +1064,8 @@ bool CPlatformNetworkManagerSony::SystemFlagGet(INetworkPlayer *pNetworkPlayer, wstring CPlatformNetworkManagerSony::GatherStats() { #if 0 - return L"Queue messages: " + std::to_wstring(((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_MESSAGES ) ) - + L" Queue bytes: " + std::to_wstring( ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES ) ); + return L"Queue messages: " + std::to_wstring(((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( nullptr, QNET_GETSENDQUEUESIZE_MESSAGES ) ) + + L" Queue bytes: " + std::to_wstring( ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( nullptr, QNET_GETSENDQUEUESIZE_BYTES ) ); #else return L""; #endif @@ -1111,7 +1111,7 @@ void CPlatformNetworkManagerSony::TickSearch() } m_bSearchPending = false; - if( m_SessionsUpdatedCallback != NULL ) m_SessionsUpdatedCallback(m_pSearchParam); + if( m_SessionsUpdatedCallback != nullptr ) m_SessionsUpdatedCallback(m_pSearchParam); } } else @@ -1126,7 +1126,7 @@ void CPlatformNetworkManagerSony::TickSearch() if( usingAdhocMode()) searchDelay = 5000; #endif - if( m_SessionsUpdatedCallback != NULL && (m_lastSearchStartTime + searchDelay) < GetTickCount() ) + if( m_SessionsUpdatedCallback != nullptr && (m_lastSearchStartTime + searchDelay) < GetTickCount() ) { if( m_pSQRNet->FriendRoomManagerSearch() ) { @@ -1189,7 +1189,7 @@ bool CPlatformNetworkManagerSony::GetGameSessionInfo(int iPad, SessionID session if(memcmp( &pSearchResult->info.sessionID, &sessionId, sizeof(SessionID) ) != 0) continue; bool foundSession = false; - FriendSessionInfo *sessionInfo = NULL; + FriendSessionInfo *sessionInfo = nullptr; auto itFriendSession = friendsSessions[iPad].begin(); for(itFriendSession = friendsSessions[iPad].begin(); itFriendSession < friendsSessions[iPad].end(); ++itFriendSession) { @@ -1231,7 +1231,7 @@ bool CPlatformNetworkManagerSony::GetGameSessionInfo(int iPad, SessionID session sessionInfo->data.isJoinable) { foundSessionInfo->data = sessionInfo->data; - if(foundSessionInfo->displayLabel != NULL) delete [] foundSessionInfo->displayLabel; + if(foundSessionInfo->displayLabel != nullptr) delete [] foundSessionInfo->displayLabel; foundSessionInfo->displayLabel = new wchar_t[100]; memcpy(foundSessionInfo->displayLabel, sessionInfo->displayLabel, 100 * sizeof(wchar_t) ); foundSessionInfo->displayLabelLength = sessionInfo->displayLabelLength; @@ -1267,7 +1267,7 @@ void CPlatformNetworkManagerSony::ForceFriendsSessionRefresh() m_lastSearchStartTime = 0; m_searchResultsCount = 0; delete m_pSearchResults; - m_pSearchResults = NULL; + m_pSearchResults = nullptr; } INetworkPlayer *CPlatformNetworkManagerSony::addNetworkPlayer(SQRNetworkPlayer *pSQRPlayer) @@ -1293,7 +1293,7 @@ void CPlatformNetworkManagerSony::removeNetworkPlayer(SQRNetworkPlayer *pSQRPlay INetworkPlayer *CPlatformNetworkManagerSony::getNetworkPlayer(SQRNetworkPlayer *pSQRPlayer) { - return pSQRPlayer ? (INetworkPlayer *)(pSQRPlayer->GetCustomDataValue()) : NULL; + return pSQRPlayer ? (INetworkPlayer *)(pSQRPlayer->GetCustomDataValue()) : nullptr; } diff --git a/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.h b/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.h index 258acd833..9131e8979 100644 --- a/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.h +++ b/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.h @@ -102,7 +102,7 @@ class CPlatformNetworkManagerSony : public CPlatformNetworkManager, ISQRNetworkM GameSessionData m_hostGameSessionData; CGameNetworkManager *m_pGameNetworkManager; public: - virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL); + virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr); private: // TODO 4J Stu - Do we need to be able to have more than one of these? diff --git a/Minecraft.Client/Common/Network/Sony/SQRNetworkManager.cpp b/Minecraft.Client/Common/Network/Sony/SQRNetworkManager.cpp index f23a0a630..7561c17d4 100644 --- a/Minecraft.Client/Common/Network/Sony/SQRNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/Sony/SQRNetworkManager.cpp @@ -16,7 +16,7 @@ int SQRNetworkManager::GetSendQueueSizeBytes() for(int i = 0; i < playerCount; ++i) { SQRNetworkPlayer *player = GetPlayerByIndex( i ); - if( player != NULL ) + if( player != nullptr ) { queueSize += player->GetTotalSendQueueBytes(); } @@ -31,7 +31,7 @@ int SQRNetworkManager::GetSendQueueSizeMessages() for(int i = 0; i < playerCount; ++i) { SQRNetworkPlayer *player = GetPlayerByIndex( i ); - if( player != NULL ) + if( player != nullptr ) { queueSize += player->GetTotalSendQueueMessages(); } diff --git a/Minecraft.Client/Common/Network/Sony/SQRNetworkPlayer.cpp b/Minecraft.Client/Common/Network/Sony/SQRNetworkPlayer.cpp index a040b28bd..cd9045249 100644 --- a/Minecraft.Client/Common/Network/Sony/SQRNetworkPlayer.cpp +++ b/Minecraft.Client/Common/Network/Sony/SQRNetworkPlayer.cpp @@ -279,12 +279,12 @@ void SQRNetworkPlayer::SendInternal(const void *data, unsigned int dataSize, Ack { // no data, just the flag assert(dataSize == 0); - assert(data == NULL); + assert(data == nullptr); int dataSize = dataRemaining; if( dataSize > SNP_MAX_PAYLOAD ) dataSize = SNP_MAX_PAYLOAD; - sendBlock.start = NULL; - sendBlock.end = NULL; - sendBlock.current = NULL; + sendBlock.start = nullptr; + sendBlock.end = nullptr; + sendBlock.current = nullptr; sendBlock.ack = ackFlags; m_sendQueue.push(sendBlock); } @@ -387,9 +387,9 @@ int SQRNetworkPlayer::ReadDataPacket(void* data, int dataSize) unsigned char* packetData = new unsigned char[packetSize]; #ifdef __PS3__ - int bytesRead = cellRudpRead( m_rudpCtx, packetData, packetSize, 0, NULL ); + int bytesRead = cellRudpRead( m_rudpCtx, packetData, packetSize, 0, nullptr ); #else // __ORBIS__ && __PSVITA__ - int bytesRead = sceRudpRead( m_rudpCtx, packetData, packetSize, 0, NULL ); + int bytesRead = sceRudpRead( m_rudpCtx, packetData, packetSize, 0, nullptr ); #endif if(bytesRead == sc_wouldBlockFlag) { @@ -426,9 +426,9 @@ void SQRNetworkPlayer::ReadAck() { DataPacketHeader header; #ifdef __PS3__ - int bytesRead = cellRudpRead( m_rudpCtx, &header, sizeof(header), 0, NULL ); + int bytesRead = cellRudpRead( m_rudpCtx, &header, sizeof(header), 0, nullptr ); #else // __ORBIS__ && __PSVITA__ - int bytesRead = sceRudpRead( m_rudpCtx, &header, sizeof(header), 0, NULL ); + int bytesRead = sceRudpRead( m_rudpCtx, &header, sizeof(header), 0, nullptr ); #endif if(bytesRead == sc_wouldBlockFlag) { @@ -459,7 +459,7 @@ void SQRNetworkPlayer::ReadAck() void SQRNetworkPlayer::WriteAck() { - SendInternal(NULL, 0, e_flag_AckReturning); + SendInternal(nullptr, 0, e_flag_AckReturning); } int SQRNetworkPlayer::GetOutstandingAckCount() diff --git a/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.cpp b/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.cpp index 6ea168c3e..7dccb73f6 100644 --- a/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.cpp +++ b/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.cpp @@ -30,7 +30,7 @@ static SceRemoteStorageStatus statParams; // { // app.DebugPrintf("remoteStorageCallback err : 0x%08x\n"); // -// app.getRemoteStorage()->getRemoteFileInfo(&statParams, remoteStorageGetInfoCallback, NULL); +// app.getRemoteStorage()->getRemoteFileInfo(&statParams, remoteStorageGetInfoCallback, nullptr); // } @@ -181,7 +181,7 @@ const char* SonyRemoteStorage::getLocalFilename() const char* SonyRemoteStorage::getSaveNameUTF8() { if(m_getInfoStatus != e_infoFound) - return NULL; + return nullptr; return m_retrievedDescData.m_saveNameUTF8; } @@ -261,12 +261,12 @@ int SonyRemoteStorage::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThum } else { - app.DebugPrintf("Thumbnail data is NULL, or has size 0\n"); - pClass->m_thumbnailData = NULL; + app.DebugPrintf("Thumbnail data is nullptr, or has size 0\n"); + pClass->m_thumbnailData = nullptr; pClass->m_thumbnailDataSize = 0; } - if(pClass->m_SetDataThread != NULL) + if(pClass->m_SetDataThread != nullptr) delete pClass->m_SetDataThread; pClass->m_SetDataThread = new C4JThread(setDataThread, pClass, "setDataThread"); @@ -346,7 +346,7 @@ bool SonyRemoteStorage::shutdown() app.DebugPrintf("Term request done \n"); m_bInitialised = false; free(m_memPoolBuffer); - m_memPoolBuffer = NULL; + m_memPoolBuffer = nullptr; return true; } else @@ -409,7 +409,7 @@ void SonyRemoteStorage::GetDescriptionData( DescriptionData& descData) char seed[22]; app.GetImageTextData(m_thumbnailData, m_thumbnailDataSize,(unsigned char *)seed, uiHostOptions, bHostOptionsRead, uiTexturePack); - __int64 iSeed = strtoll(seed,NULL,10); + __int64 iSeed = strtoll(seed,nullptr,10); SetU64HexBytes(descData.m_seed, iSeed); // Save the host options that this world was last played with SetU32HexBytes(descData.m_hostOptions, uiHostOptions); @@ -448,7 +448,7 @@ void SonyRemoteStorage::GetDescriptionData( DescriptionData_V2& descData) char seed[22]; app.GetImageTextData(m_thumbnailData, m_thumbnailDataSize,(unsigned char *)seed, uiHostOptions, bHostOptionsRead, uiTexturePack); - __int64 iSeed = strtoll(seed,NULL,10); + __int64 iSeed = strtoll(seed,nullptr,10); SetU64HexBytes(descData.m_seed, iSeed); // Save the host options that this world was last played with SetU32HexBytes(descData.m_hostOptions, uiHostOptions); diff --git a/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.h b/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.h index d38a06e2c..a545911e2 100644 --- a/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.h +++ b/Minecraft.Client/Common/Network/Sony/SonyRemoteStorage.h @@ -140,7 +140,7 @@ class SonyRemoteStorage static int LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes); static int setDataThread(void* lpParam); - SonyRemoteStorage() : m_memPoolBuffer(NULL), m_bInitialised(false),m_getInfoStatus(e_noInfoFound) {} + SonyRemoteStorage() : m_memPoolBuffer(nullptr), m_bInitialised(false),m_getInfoStatus(e_noInfoFound) {} protected: const char* getRemoteSaveFilename(); diff --git a/Minecraft.Client/Common/Telemetry/TelemetryManager.cpp b/Minecraft.Client/Common/Telemetry/TelemetryManager.cpp index cc47e9287..5561e2a17 100644 --- a/Minecraft.Client/Common/Telemetry/TelemetryManager.cpp +++ b/Minecraft.Client/Common/Telemetry/TelemetryManager.cpp @@ -165,7 +165,7 @@ INT CTelemetryManager::GetMode(DWORD dwUserId) Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localplayers[dwUserId] != NULL && pMinecraft->localplayers[dwUserId]->level != NULL && pMinecraft->localplayers[dwUserId]->level->getLevelData() != NULL ) + if( pMinecraft->localplayers[dwUserId] != nullptr && pMinecraft->localplayers[dwUserId]->level != nullptr && pMinecraft->localplayers[dwUserId]->level->getLevelData() != nullptr ) { GameType *gameType = pMinecraft->localplayers[dwUserId]->level->getLevelData()->getGameType(); @@ -237,7 +237,7 @@ INT CTelemetryManager::GetSubLevelId(DWORD dwUserId) Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[dwUserId] != NULL) + if(pMinecraft->localplayers[dwUserId] != nullptr) { switch(pMinecraft->localplayers[dwUserId]->dimension) { diff --git a/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp b/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp index f01db84e9..df2f5b2b2 100644 --- a/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp +++ b/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp @@ -61,7 +61,7 @@ void ChangeStateConstraint::tick(int iPad) // Send update settings packet to server Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = minecraft->localplayers[iPad]; - if(player != NULL && player->connection && player->connection->getNetworkPlayer() != NULL) + if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); } @@ -89,7 +89,7 @@ void ChangeStateConstraint::tick(int iPad) if(m_changeGameMode) { - if(minecraft->localgameModes[iPad] != NULL) + if(minecraft->localgameModes[iPad] != nullptr) { m_changedFromGameMode = minecraft->localplayers[iPad]->abilities.instabuild ? GameType::CREATIVE : GameType::SURVIVAL; @@ -102,7 +102,7 @@ void ChangeStateConstraint::tick(int iPad) // Send update settings packet to server Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = minecraft->localplayers[iPad]; - if(player != NULL && player->connection && player->connection->getNetworkPlayer() != NULL) + if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); } @@ -126,7 +126,7 @@ void ChangeStateConstraint::tick(int iPad) // Send update settings packet to server Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = minecraft->localplayers[iPad]; - if(player != NULL && player->connection && player->connection->getNetworkPlayer() != NULL) + if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); } diff --git a/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.h b/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.h index 2156870d4..e5f2d74bf 100644 --- a/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.h +++ b/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.h @@ -30,7 +30,7 @@ class ChangeStateConstraint : public TutorialConstraint public: virtual ConstraintType getType() { return e_ConstraintChangeState; } - ChangeStateConstraint( Tutorial *tutorial, eTutorial_State targetState, eTutorial_State sourceStates[], DWORD sourceStatesCount, double x0, double y0, double z0, double x1, double y1, double z1, bool contains = true, bool changeGameMode = false, GameType *targetGameMode = NULL ); + ChangeStateConstraint( Tutorial *tutorial, eTutorial_State targetState, eTutorial_State sourceStates[], DWORD sourceStatesCount, double x0, double y0, double z0, double x1, double y1, double z1, bool contains = true, bool changeGameMode = false, GameType *targetGameMode = nullptr ); ~ChangeStateConstraint(); virtual void tick(int iPad); diff --git a/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp b/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp index 1ea34ace6..987ad6eb1 100644 --- a/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp +++ b/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp @@ -12,7 +12,7 @@ ChoiceTask::ChoiceTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, int iConfirmMapping /*= 0*/, int iCancelMapping /*= 0*/, eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) - : TutorialTask( tutorial, descriptionId, false, NULL, true, false, false ) + : TutorialTask( tutorial, descriptionId, false, nullptr, true, false, false ) { if(requiresUserInput == true) { diff --git a/Minecraft.Client/Common/Tutorial/CompleteUsingItemTask.cpp b/Minecraft.Client/Common/Tutorial/CompleteUsingItemTask.cpp index 43b2f7f31..f2fb8c127 100644 --- a/Minecraft.Client/Common/Tutorial/CompleteUsingItemTask.cpp +++ b/Minecraft.Client/Common/Tutorial/CompleteUsingItemTask.cpp @@ -3,7 +3,7 @@ #include "CompleteUsingItemTask.h" CompleteUsingItemTask::CompleteUsingItemTask(Tutorial *tutorial, int descriptionId, int itemIds[], unsigned int itemIdsLength, bool enablePreCompletion) - : TutorialTask( tutorial, descriptionId, enablePreCompletion, NULL) + : TutorialTask( tutorial, descriptionId, enablePreCompletion, nullptr) { m_iValidItemsA= new int [itemIdsLength]; for(int i=0;i *inConstraints /*= NULL*/, + Tutorial *tutorial, int descriptionId, bool enablePreCompletion /*= true*/, vector *inConstraints /*= nullptr*/, bool bShowMinimumTime /*=false*/, bool bAllowFade /*=true*/, bool m_bTaskReminders /*=true*/ ) : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, bShowMinimumTime, bAllowFade, m_bTaskReminders ), m_quantity( quantity ), @@ -17,7 +17,7 @@ CraftTask::CraftTask( int itemId, int auxValue, int quantity, } CraftTask::CraftTask( int *items, int *auxValues, int numItems, int quantity, - Tutorial *tutorial, int descriptionId, bool enablePreCompletion /*= true*/, vector *inConstraints /*= NULL*/, + Tutorial *tutorial, int descriptionId, bool enablePreCompletion /*= true*/, vector *inConstraints /*= nullptr*/, bool bShowMinimumTime /*=false*/, bool bAllowFade /*=true*/, bool m_bTaskReminders /*=true*/ ) : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, bShowMinimumTime, bAllowFade, m_bTaskReminders ), m_quantity( quantity ), diff --git a/Minecraft.Client/Common/Tutorial/CraftTask.h b/Minecraft.Client/Common/Tutorial/CraftTask.h index 1496f07a4..4246711e0 100644 --- a/Minecraft.Client/Common/Tutorial/CraftTask.h +++ b/Minecraft.Client/Common/Tutorial/CraftTask.h @@ -5,10 +5,10 @@ class CraftTask : public TutorialTask { public: CraftTask( int itemId, int auxValue, int quantity, - Tutorial *tutorial, int descriptionId, bool enablePreCompletion = true, vector *inConstraints = NULL, + Tutorial *tutorial, int descriptionId, bool enablePreCompletion = true, vector *inConstraints = nullptr, bool bShowMinimumTime=false, bool bAllowFade=true, bool m_bTaskReminders=true ); CraftTask( int *items, int *auxValues, int numItems, int quantity, - Tutorial *tutorial, int descriptionId, bool enablePreCompletion = true, vector *inConstraints = NULL, + Tutorial *tutorial, int descriptionId, bool enablePreCompletion = true, vector *inConstraints = nullptr, bool bShowMinimumTime=false, bool bAllowFade=true, bool m_bTaskReminders=true ); ~CraftTask(); diff --git a/Minecraft.Client/Common/Tutorial/DiggerItemHint.cpp b/Minecraft.Client/Common/Tutorial/DiggerItemHint.cpp index 86dbe5005..428bbe3c0 100644 --- a/Minecraft.Client/Common/Tutorial/DiggerItemHint.cpp +++ b/Minecraft.Client/Common/Tutorial/DiggerItemHint.cpp @@ -22,7 +22,7 @@ DiggerItemHint::DiggerItemHint(eTutorial_Hint id, Tutorial *tutorial, int descri int DiggerItemHint::startDestroyBlock(shared_ptr item, Tile *tile) { - if(item != NULL) + if(item != nullptr) { bool itemFound = false; for(unsigned int i=0;i item, Tile *tile) int DiggerItemHint::attack(shared_ptr item, shared_ptr entity) { - if(item != NULL) + if(item != nullptr) { bool itemFound = false; for(unsigned int i=0;iid, this, IDS_TUTORIAL_TASK_PLACE_DOOR) ); addTask(e_Tutorial_State_Gameplay, new CraftTask( Tile::torch_Id, -1, 1, this, IDS_TUTORIAL_TASK_CREATE_TORCH) ); - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"tutorialArea"); - if(area != NULL) + if(area != nullptr) { vector *areaConstraints = new vector(); areaConstraints->push_back( new AreaConstraint( IDS_TUTORIAL_CONSTRAINT_TUTORIAL_AREA, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -283,10 +283,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * MINECART * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"minecartArea"); - if(area != NULL) + if(area != nullptr) { addHint(e_Tutorial_State_Gameplay, new AreaHint(e_Tutorial_Hint_Always_On, this, e_Tutorial_State_Gameplay, e_Tutorial_State_Riding_Minecart, IDS_TUTORIAL_HINT_MINECART, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1 ) ); } @@ -298,10 +298,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * BOAT * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"boatArea"); - if(area != NULL) + if(area != nullptr) { addHint(e_Tutorial_State_Gameplay, new AreaHint(e_Tutorial_Hint_Always_On, this, e_Tutorial_State_Gameplay, e_Tutorial_State_Riding_Boat, IDS_TUTORIAL_HINT_BOAT, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1 ) ); } @@ -313,10 +313,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * FISHING * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"fishingArea"); - if(area != NULL) + if(area != nullptr) { addHint(e_Tutorial_State_Gameplay, new AreaHint(e_Tutorial_Hint_Always_On, this, e_Tutorial_State_Gameplay, e_Tutorial_State_Fishing, IDS_TUTORIAL_HINT_FISHING, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1 ) ); } @@ -328,10 +328,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * PISTON - SELF-REPAIRING BRIDGE * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"pistonBridgeArea"); - if(area != NULL) + if(area != nullptr) { addHint(e_Tutorial_State_Gameplay, new AreaHint(e_Tutorial_Hint_Always_On, this, e_Tutorial_State_Gameplay, e_Tutorial_State_None, IDS_TUTORIAL_HINT_PISTON_SELF_REPAIRING_BRIDGE, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1, true ) ); } @@ -343,10 +343,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * PISTON - PISTON AND REDSTONE CIRCUITS * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"pistonArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State redstoneAndPistonStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Redstone_And_Piston, redstoneAndPistonStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -368,10 +368,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * PORTAL * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"portalArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State portalStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Portal, portalStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -391,10 +391,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * CREATIVE * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"creativeArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State creativeStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_CreativeMode, creativeStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1,true,true,GameType::CREATIVE) ); @@ -411,7 +411,7 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) ProcedureCompoundTask *creativeFinalTask = new ProcedureCompoundTask( this ); AABB *exitArea = app.getGameRuleDefinitions()->getNamedArea(L"creativeExitArea"); - if(exitArea != NULL) + if(exitArea != nullptr) { vector *creativeExitAreaConstraints = new vector(); creativeExitAreaConstraints->push_back( new AreaConstraint( -1, exitArea->x0,exitArea->y0,exitArea->z0,exitArea->x1,exitArea->y1,exitArea->z1,true,false) ); @@ -434,10 +434,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * BREWING * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"brewingArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State brewingStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Brewing, brewingStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -467,10 +467,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * ENCHANTING * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"enchantingArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State enchantingStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Enchanting, enchantingStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -492,10 +492,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * ANVIL * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"anvilArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State enchantingStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Anvil, enchantingStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -517,10 +517,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * TRADING * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"tradingArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State tradingStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Trading, tradingStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -541,10 +541,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * FIREWORKS * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"fireworksArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State fireworkStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Fireworks, fireworkStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -563,10 +563,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * BEACON * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"beaconArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State beaconStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Beacon, beaconStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -585,10 +585,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * HOPPER * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"hopperArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State hopperStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Hopper, hopperStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -610,10 +610,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * ENDERCHEST * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"enderchestArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State enchantingStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Enderchests, enchantingStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -632,10 +632,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * FARMING * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"farmingArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State farmingStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Farming, farmingStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -661,10 +661,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * BREEDING * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"breedingArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State breedingStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Breeding, breedingStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); @@ -689,10 +689,10 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) * SNOW AND IRON GOLEM * */ - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { AABB *area = app.getGameRuleDefinitions()->getNamedArea(L"golemArea"); - if(area != NULL) + if(area != nullptr) { eTutorial_State golemStates[] = {e_Tutorial_State_Gameplay}; AddGlobalConstraint( new ChangeStateConstraint(this, e_Tutorial_State_Golem, golemStates, 1, area->x0,area->y0,area->z0,area->x1,area->y1,area->z1) ); diff --git a/Minecraft.Client/Common/Tutorial/FullTutorialActiveTask.cpp b/Minecraft.Client/Common/Tutorial/FullTutorialActiveTask.cpp index 54985d218..f1357c6c5 100644 --- a/Minecraft.Client/Common/Tutorial/FullTutorialActiveTask.cpp +++ b/Minecraft.Client/Common/Tutorial/FullTutorialActiveTask.cpp @@ -3,7 +3,7 @@ #include "FullTutorialActiveTask.h" FullTutorialActiveTask::FullTutorialActiveTask(Tutorial *tutorial, eTutorial_CompletionAction completeAction /*= e_Tutorial_Completion_None*/) - : TutorialTask( tutorial, -1, false, NULL, false, false, false ) + : TutorialTask( tutorial, -1, false, nullptr, false, false, false ) { m_completeAction = completeAction; } diff --git a/Minecraft.Client/Common/Tutorial/InfoTask.cpp b/Minecraft.Client/Common/Tutorial/InfoTask.cpp index 6a78ed92a..340ea5187 100644 --- a/Minecraft.Client/Common/Tutorial/InfoTask.cpp +++ b/Minecraft.Client/Common/Tutorial/InfoTask.cpp @@ -11,7 +11,7 @@ InfoTask::InfoTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, int iMapping /*= 0*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) - : TutorialTask( tutorial, descriptionId, false, NULL, true, false, false ) + : TutorialTask( tutorial, descriptionId, false, nullptr, true, false, false ) { if(requiresUserInput == true) { diff --git a/Minecraft.Client/Common/Tutorial/PickupTask.h b/Minecraft.Client/Common/Tutorial/PickupTask.h index 68e1d4793..9f2d2426e 100644 --- a/Minecraft.Client/Common/Tutorial/PickupTask.h +++ b/Minecraft.Client/Common/Tutorial/PickupTask.h @@ -8,7 +8,7 @@ class PickupTask : public TutorialTask { public: PickupTask( int itemId, unsigned int quantity, int auxValue, - Tutorial *tutorial, int descriptionId, bool enablePreCompletion = true, vector *inConstraints = NULL, + Tutorial *tutorial, int descriptionId, bool enablePreCompletion = true, vector *inConstraints = nullptr, bool bShowMinimumTime=false, bool bAllowFade=true, bool m_bTaskReminders=true ) : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, bShowMinimumTime, bAllowFade, m_bTaskReminders ), m_itemId( itemId), diff --git a/Minecraft.Client/Common/Tutorial/ProcedureCompoundTask.cpp b/Minecraft.Client/Common/Tutorial/ProcedureCompoundTask.cpp index 0e3b3e377..ddf15a55c 100644 --- a/Minecraft.Client/Common/Tutorial/ProcedureCompoundTask.cpp +++ b/Minecraft.Client/Common/Tutorial/ProcedureCompoundTask.cpp @@ -11,7 +11,7 @@ ProcedureCompoundTask::~ProcedureCompoundTask() void ProcedureCompoundTask::AddTask(TutorialTask *task) { - if(task != NULL) + if(task != nullptr) { m_taskSequence.push_back(task); } diff --git a/Minecraft.Client/Common/Tutorial/ProcedureCompoundTask.h b/Minecraft.Client/Common/Tutorial/ProcedureCompoundTask.h index 36b327984..0a5b7eee4 100644 --- a/Minecraft.Client/Common/Tutorial/ProcedureCompoundTask.h +++ b/Minecraft.Client/Common/Tutorial/ProcedureCompoundTask.h @@ -8,7 +8,7 @@ class ProcedureCompoundTask : public TutorialTask { public: ProcedureCompoundTask(Tutorial *tutorial ) - : TutorialTask(tutorial, -1, false, NULL, false, true, false ) + : TutorialTask(tutorial, -1, false, nullptr, false, true, false ) {} ~ProcedureCompoundTask(); diff --git a/Minecraft.Client/Common/Tutorial/ProgressFlagTask.h b/Minecraft.Client/Common/Tutorial/ProgressFlagTask.h index b96e1bc01..9baea5a57 100644 --- a/Minecraft.Client/Common/Tutorial/ProgressFlagTask.h +++ b/Minecraft.Client/Common/Tutorial/ProgressFlagTask.h @@ -17,7 +17,7 @@ class ProgressFlagTask : public TutorialTask EProgressFlagType m_type; public: ProgressFlagTask(char *flags, char mask, EProgressFlagType type, Tutorial *tutorial ) : - TutorialTask(tutorial, -1, false, NULL ), + TutorialTask(tutorial, -1, false, nullptr ), flags( flags ), m_mask( mask ), m_type( type ) {} diff --git a/Minecraft.Client/Common/Tutorial/RideEntityTask.h b/Minecraft.Client/Common/Tutorial/RideEntityTask.h index d9b6d41e4..749b187f8 100644 --- a/Minecraft.Client/Common/Tutorial/RideEntityTask.h +++ b/Minecraft.Client/Common/Tutorial/RideEntityTask.h @@ -13,7 +13,7 @@ class RideEntityTask : public TutorialTask public: RideEntityTask(const int eTYPE, Tutorial *tutorial, int descriptionId, - bool enablePreCompletion = false, vector *inConstraints = NULL, + bool enablePreCompletion = false, vector *inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true ); virtual bool isCompleted(); diff --git a/Minecraft.Client/Common/Tutorial/StatTask.cpp b/Minecraft.Client/Common/Tutorial/StatTask.cpp index e06db393c..c2dc82aa4 100644 --- a/Minecraft.Client/Common/Tutorial/StatTask.cpp +++ b/Minecraft.Client/Common/Tutorial/StatTask.cpp @@ -6,7 +6,7 @@ #include "StatTask.h" StatTask::StatTask(Tutorial *tutorial, int descriptionId, bool enablePreCompletion, Stat *stat, int variance /*= 1*/) - : TutorialTask( tutorial, descriptionId, enablePreCompletion, NULL ) + : TutorialTask( tutorial, descriptionId, enablePreCompletion, nullptr ) { this->stat = stat; diff --git a/Minecraft.Client/Common/Tutorial/StateChangeTask.h b/Minecraft.Client/Common/Tutorial/StateChangeTask.h index fb9e63966..ab34d35dc 100644 --- a/Minecraft.Client/Common/Tutorial/StateChangeTask.h +++ b/Minecraft.Client/Common/Tutorial/StateChangeTask.h @@ -9,7 +9,7 @@ class StateChangeTask : public TutorialTask eTutorial_State m_state; public: StateChangeTask(eTutorial_State state, - Tutorial *tutorial, int descriptionId = -1, bool enablePreCompletion = false, vector *inConstraints = NULL, + Tutorial *tutorial, int descriptionId = -1, bool enablePreCompletion = false, vector *inConstraints = nullptr, bool bShowMinimumTime=false, bool bAllowFade=true, bool m_bTaskReminders=true ) : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, bShowMinimumTime, bAllowFade, m_bTaskReminders ), m_state( state ) diff --git a/Minecraft.Client/Common/Tutorial/TakeItemHint.cpp b/Minecraft.Client/Common/Tutorial/TakeItemHint.cpp index a1a5c37a9..3a3184889 100644 --- a/Minecraft.Client/Common/Tutorial/TakeItemHint.cpp +++ b/Minecraft.Client/Common/Tutorial/TakeItemHint.cpp @@ -19,7 +19,7 @@ TakeItemHint::TakeItemHint(eTutorial_Hint id, Tutorial *tutorial, int items[], u bool TakeItemHint::onTake(shared_ptr item) { - if(item != NULL) + if(item != nullptr) { bool itemFound = false; for(unsigned int i=0;im_messageId) && (m_messageString.compare(other->m_messageString) == 0); bool titleTheSame = (m_titleId == other->m_titleId) && (m_titleString.compare(other->m_titleString) == 0); @@ -360,12 +360,12 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad ) m_hintDisplayed = false; m_freezeTime = false; m_timeFrozen = false; - m_UIScene = NULL; + m_UIScene = nullptr; m_allowShow = true; m_bHasTickedOnce = false; m_firstTickTime = 0; - m_lastMessage = NULL; + m_lastMessage = nullptr; lastMessageTime = 0; m_iTaskReminders = 0; @@ -374,13 +374,13 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad ) m_CurrentState = e_Tutorial_State_Gameplay; m_hasStateChanged = false; #ifdef _XBOX - m_hTutorialScene=NULL; + m_hTutorialScene=nullptr; #endif for(unsigned int i = 0; i < e_Tutorial_State_Max; ++i) { - currentTask[i] = NULL; - currentFailedConstraint[i] = NULL; + currentTask[i] = nullptr; + currentFailedConstraint[i] = nullptr; } // DEFAULT TASKS THAT ALL TUTORIALS SHARE @@ -1012,7 +1012,7 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad ) addTask(e_Tutorial_State_Horse, new InfoTask(this, IDS_TUTORIAL_TASK_HORSE_TAMING2, IDS_TUTORIAL_PROMPT_PRESS_A_TO_CONTINUE, true, ACTION_MENU_A) ); // 4J-JEV: Only force the RideEntityTask if we're on the full-tutorial. - if (isFullTutorial) addTask(e_Tutorial_State_Horse, new RideEntityTask(eTYPE_HORSE, this, IDS_TUTORIAL_TASK_HORSE_RIDE, true, NULL, false, false, false) ); + if (isFullTutorial) addTask(e_Tutorial_State_Horse, new RideEntityTask(eTYPE_HORSE, this, IDS_TUTORIAL_TASK_HORSE_RIDE, true, nullptr, false, false, false) ); else addTask(e_Tutorial_State_Horse, new InfoTask(this, IDS_TUTORIAL_TASK_HORSE_RIDE, IDS_TUTORIAL_PROMPT_PRESS_A_TO_CONTINUE, true, ACTION_MENU_A) ); addTask(e_Tutorial_State_Horse, new InfoTask(this, IDS_TUTORIAL_TASK_HORSE_SADDLES, IDS_TUTORIAL_PROMPT_PRESS_A_TO_CONTINUE, true, ACTION_MENU_A) ); @@ -1163,8 +1163,8 @@ Tutorial::~Tutorial() delete it; } - currentTask[i] = NULL; - currentFailedConstraint[i] = NULL; + currentTask[i] = nullptr; + currentFailedConstraint[i] = nullptr; } } @@ -1362,7 +1362,7 @@ void Tutorial::tick() if(!m_allowShow) { - if( currentTask[m_CurrentState] != NULL && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) ) + if( currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) ) { uiTempDisabled = true; } @@ -1412,7 +1412,7 @@ void Tutorial::tick() if(ui.IsPauseMenuDisplayed( m_iPad ) ) { - if( currentTask[m_CurrentState] != NULL && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) ) + if( currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) ) { uiTempDisabled = true; } @@ -1460,12 +1460,12 @@ void Tutorial::tick() // Check constraints // Only need to update these if we aren't already failing something - if( !m_allTutorialsComplete && (currentFailedConstraint[m_CurrentState] == NULL || currentFailedConstraint[m_CurrentState]->isConstraintSatisfied(m_iPad)) ) + if( !m_allTutorialsComplete && (currentFailedConstraint[m_CurrentState] == nullptr || currentFailedConstraint[m_CurrentState]->isConstraintSatisfied(m_iPad)) ) { - if( currentFailedConstraint[m_CurrentState] != NULL && currentFailedConstraint[m_CurrentState]->isConstraintSatisfied(m_iPad) ) + if( currentFailedConstraint[m_CurrentState] != nullptr && currentFailedConstraint[m_CurrentState]->isConstraintSatisfied(m_iPad) ) { constraintChanged = true; - currentFailedConstraint[m_CurrentState] = NULL; + currentFailedConstraint[m_CurrentState] = nullptr; } for (auto& constraint : constraints[m_CurrentState]) { @@ -1477,7 +1477,7 @@ void Tutorial::tick() } } - if( !m_allTutorialsComplete && currentFailedConstraint[m_CurrentState] == NULL ) + if( !m_allTutorialsComplete && currentFailedConstraint[m_CurrentState] == nullptr ) { // Update tasks bool isCurrentTask = true; @@ -1496,7 +1496,7 @@ void Tutorial::tick() eTutorial_CompletionAction compAction = task->getCompletionAction(); it = activeTasks[m_CurrentState].erase( it ); delete task; - task = NULL; + task = nullptr; if( activeTasks[m_CurrentState].size() > 0 ) { @@ -1552,12 +1552,12 @@ void Tutorial::tick() { setStateCompleted( m_CurrentState ); - currentTask[m_CurrentState] = NULL; + currentTask[m_CurrentState] = nullptr; } taskChanged = true; // If we can complete this early, check if we can complete it right now - if( currentTask[m_CurrentState] != NULL && currentTask[m_CurrentState]->isPreCompletionEnabled() ) + if( currentTask[m_CurrentState] != nullptr && currentTask[m_CurrentState]->isPreCompletionEnabled() ) { isCurrentTask = true; } @@ -1566,7 +1566,7 @@ void Tutorial::tick() { ++it; } - if( task != NULL && task->ShowMinimumTime() && task->hasBeenActivated() && (lastMessageTime + m_iTutorialMinimumDisplayMessageTime ) < GetTickCount() ) + if( task != nullptr && task->ShowMinimumTime() && task->hasBeenActivated() && (lastMessageTime + m_iTutorialMinimumDisplayMessageTime ) < GetTickCount() ) { task->setShownForMinimumTime(); @@ -1587,7 +1587,7 @@ void Tutorial::tick() } } - if( currentTask[m_CurrentState] == NULL && activeTasks[m_CurrentState].size() > 0 ) + if( currentTask[m_CurrentState] == nullptr && activeTasks[m_CurrentState].size() > 0 ) { currentTask[m_CurrentState] = activeTasks[m_CurrentState][0]; currentTask[m_CurrentState]->setAsCurrentTask(); @@ -1616,17 +1616,17 @@ void Tutorial::tick() } if( constraintChanged || taskChanged || m_hasStateChanged || - (currentFailedConstraint[m_CurrentState] == NULL && currentTask[m_CurrentState] != NULL && (m_lastMessage == NULL || currentTask[m_CurrentState]->getDescriptionId() != m_lastMessage->m_messageId) && !m_hintDisplayed) + (currentFailedConstraint[m_CurrentState] == nullptr && currentTask[m_CurrentState] != nullptr && (m_lastMessage == nullptr || currentTask[m_CurrentState]->getDescriptionId() != m_lastMessage->m_messageId) && !m_hintDisplayed) ) { - if( currentFailedConstraint[m_CurrentState] != NULL ) + if( currentFailedConstraint[m_CurrentState] != nullptr ) { PopupMessageDetails *message = new PopupMessageDetails(); message->m_messageId = currentFailedConstraint[m_CurrentState]->getDescriptionId(); message->m_allowFade = false; setMessage( message ); } - else if( currentTask[m_CurrentState] != NULL ) + else if( currentTask[m_CurrentState] != nullptr ) { PopupMessageDetails *message = new PopupMessageDetails(); message->m_messageId = currentTask[m_CurrentState]->getDescriptionId(); @@ -1637,7 +1637,7 @@ void Tutorial::tick() } else { - setMessage( NULL ); + setMessage( nullptr ); } } @@ -1646,7 +1646,7 @@ void Tutorial::tick() m_hintDisplayed = false; } - if( currentFailedConstraint[m_CurrentState] == NULL && currentTask[m_CurrentState] != NULL && (m_iTaskReminders!=0) && (lastMessageTime + (m_iTaskReminders * m_iTutorialReminderTime) ) < GetTickCount() ) + if( currentFailedConstraint[m_CurrentState] == nullptr && currentTask[m_CurrentState] != nullptr && (m_iTaskReminders!=0) && (lastMessageTime + (m_iTaskReminders * m_iTutorialReminderTime) ) < GetTickCount() ) { // Reminder PopupMessageDetails *message = new PopupMessageDetails(); @@ -1671,7 +1671,7 @@ void Tutorial::tick() bool Tutorial::setMessage(PopupMessageDetails *message) { - if(message != NULL && !message->m_forceDisplay && + if(message != nullptr && !message->m_forceDisplay && m_lastMessageState == m_CurrentState && message->isSameContent(m_lastMessage) && ( !message->m_isReminder || ( (lastMessageTime + m_iTutorialReminderTime ) > GetTickCount() && message->m_isReminder ) ) @@ -1681,7 +1681,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message) return false; } - if(message != NULL && (message->m_messageId > 0 || !message->m_messageString.empty()) ) + if(message != nullptr && (message->m_messageId > 0 || !message->m_messageString.empty()) ) { m_lastMessageState = m_CurrentState; @@ -1695,7 +1695,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message) else { auto it = messages.find(message->m_messageId); - if( it != messages.end() && it->second != NULL ) + if( it != messages.end() && it->second != nullptr ) { TutorialMessage *messageString = it->second; text = wstring( messageString->getMessageForDisplay() ); @@ -1725,7 +1725,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message) else if(message->m_promptId >= 0) { auto it = messages.find(message->m_promptId); - if(it != messages.end() && it->second != NULL) + if(it != messages.end() && it->second != nullptr) { TutorialMessage *prompt = it->second; text.append( prompt->getMessageForDisplay() ); @@ -1754,7 +1754,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message) ui.SetTutorialDescription( m_iPad, &popupInfo ); } } - else if( (m_lastMessage != NULL && m_lastMessage->m_messageId != -1) ) //&& (lastMessageTime + m_iTutorialReminderTime ) > GetTickCount() ) + else if( (m_lastMessage != nullptr && m_lastMessage->m_messageId != -1) ) //&& (lastMessageTime + m_iTutorialReminderTime ) > GetTickCount() ) { // This should cause the popup to dissappear TutorialPopupInfo popupInfo; @@ -1763,7 +1763,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message) ui.SetTutorialDescription( m_iPad, &popupInfo ); } - if(m_lastMessage != NULL) delete m_lastMessage; + if(m_lastMessage != nullptr) delete m_lastMessage; m_lastMessage = message; return true; @@ -1777,7 +1777,7 @@ bool Tutorial::setMessage(TutorialHint *hint, PopupMessageDetails *message) bool messageShown = false; DWORD time = GetTickCount(); - if(message != NULL && (message->m_forceDisplay || hintsOn) && + if(message != nullptr && (message->m_forceDisplay || hintsOn) && (!message->m_delay || ( (m_hintDisplayed && (time - m_lastHintDisplayedTime) > m_iTutorialHintDelayTime ) || @@ -1792,7 +1792,7 @@ bool Tutorial::setMessage(TutorialHint *hint, PopupMessageDetails *message) { m_lastHintDisplayedTime = time; m_hintDisplayed = true; - if(hint!=NULL) setHintCompleted( hint ); + if(hint!=nullptr) setHintCompleted( hint ); } } return messageShown; @@ -1815,7 +1815,7 @@ void Tutorial::showTutorialPopup(bool show) if(!show) { - if( currentTask[m_CurrentState] != NULL && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) ) + if( currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) ) { uiTempDisabled = true; } @@ -1926,7 +1926,7 @@ void Tutorial::handleUIInput(int iAction) { if( m_hintDisplayed ) return; - if(currentTask[m_CurrentState] != NULL) + if(currentTask[m_CurrentState] != nullptr) currentTask[m_CurrentState]->handleUIInput(iAction); } @@ -1988,7 +1988,7 @@ void Tutorial::onSelectedItemChanged(shared_ptr item) // Menus and states like riding in a minecart will NOT allow this if( isSelectedItemState() ) { - if(item != NULL) + if(item != nullptr) { switch(item->id) { @@ -2151,7 +2151,7 @@ void Tutorial::AddConstraint(TutorialConstraint *c) void Tutorial::RemoveConstraint(TutorialConstraint *c, bool delayedRemove /*= false*/) { if( currentFailedConstraint[m_CurrentState] == c ) - currentFailedConstraint[m_CurrentState] = NULL; + currentFailedConstraint[m_CurrentState] = nullptr; if( c->getQueuedForRemoval() ) { @@ -2211,16 +2211,16 @@ void Tutorial::addMessage(int messageId, bool limitRepeats /*= false*/, unsigned } #ifdef _XBOX -void Tutorial::changeTutorialState(eTutorial_State newState, CXuiScene *scene /*= NULL*/) +void Tutorial::changeTutorialState(eTutorial_State newState, CXuiScene *scene /*= nullptr*/) #else -void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*= NULL*/) +void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*= nullptr*/) #endif { if(newState == m_CurrentState) { // If clearing the scene, make sure that the tutorial popup has its reference to this scene removed #ifndef _XBOX - if( scene == NULL ) + if( scene == nullptr ) { ui.RemoveInteractSceneReference(m_iPad, m_UIScene); } @@ -2241,7 +2241,7 @@ void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*= } // The action that caused the change of state may also have completed the current task - if( currentTask[m_CurrentState] != NULL && currentTask[m_CurrentState]->isCompleted() ) + if( currentTask[m_CurrentState] != nullptr && currentTask[m_CurrentState]->isCompleted() ) { activeTasks[m_CurrentState].erase( find( activeTasks[m_CurrentState].begin(), activeTasks[m_CurrentState].end(), currentTask[m_CurrentState]) ); @@ -2252,21 +2252,21 @@ void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*= } else { - currentTask[m_CurrentState] = NULL; + currentTask[m_CurrentState] = nullptr; } } - if( currentTask[m_CurrentState] != NULL ) + if( currentTask[m_CurrentState] != nullptr ) { currentTask[m_CurrentState]->onStateChange(newState); } // Make sure that the current message is cleared - setMessage( NULL ); + setMessage( nullptr ); // If clearing the scene, make sure that the tutorial popup has its reference to this scene removed #ifndef _XBOX - if( scene == NULL ) + if( scene == nullptr ) { ui.RemoveInteractSceneReference(m_iPad, m_UIScene); } diff --git a/Minecraft.Client/Common/Tutorial/Tutorial.h b/Minecraft.Client/Common/Tutorial/Tutorial.h index 169c33e3e..c36a9086e 100644 --- a/Minecraft.Client/Common/Tutorial/Tutorial.h +++ b/Minecraft.Client/Common/Tutorial/Tutorial.h @@ -139,9 +139,9 @@ class Tutorial bool getCompleted( int completableId ); #ifdef _XBOX - void changeTutorialState(eTutorial_State newState, CXuiScene *scene = NULL); + void changeTutorialState(eTutorial_State newState, CXuiScene *scene = nullptr); #else - void changeTutorialState(eTutorial_State newState, UIScene *scene = NULL); + void changeTutorialState(eTutorial_State newState, UIScene *scene = nullptr); #endif bool isSelectedItemState(); diff --git a/Minecraft.Client/Common/Tutorial/TutorialHint.cpp b/Minecraft.Client/Common/Tutorial/TutorialHint.cpp index 5f0808bf2..d80d7d16e 100644 --- a/Minecraft.Client/Common/Tutorial/TutorialHint.cpp +++ b/Minecraft.Client/Common/Tutorial/TutorialHint.cpp @@ -9,7 +9,7 @@ TutorialHint::TutorialHint(eTutorial_Hint id, Tutorial *tutorial, int descriptionId, eHintType type, bool allowFade /*= true*/) : m_id( id ), m_tutorial(tutorial), m_descriptionId( descriptionId ), m_type( type ), m_counter( 0 ), - m_lastTile( NULL ), m_hintNeeded( true ), m_allowFade(allowFade) + m_lastTile( nullptr ), m_hintNeeded( true ), m_allowFade(allowFade) { tutorial->addMessage(descriptionId, type != e_Hint_NoIngredients); } diff --git a/Minecraft.Client/Common/Tutorial/TutorialMode.cpp b/Minecraft.Client/Common/Tutorial/TutorialMode.cpp index 82c81598f..50a45a42d 100644 --- a/Minecraft.Client/Common/Tutorial/TutorialMode.cpp +++ b/Minecraft.Client/Common/Tutorial/TutorialMode.cpp @@ -15,7 +15,7 @@ TutorialMode::TutorialMode(int iPad, Minecraft *minecraft, ClientConnection *con TutorialMode::~TutorialMode() { - if(tutorial != NULL) + if(tutorial != nullptr) delete tutorial; } @@ -38,7 +38,7 @@ bool TutorialMode::destroyBlock(int x, int y, int z, int face) } shared_ptr item = minecraft->player->getSelectedItem(); int damageBefore; - if(item != NULL) + if(item != nullptr) { damageBefore = item->getDamageValue(); } @@ -46,7 +46,7 @@ bool TutorialMode::destroyBlock(int x, int y, int z, int face) if(!tutorial->m_allTutorialsComplete) { - if ( item != NULL && item->isDamageableItem() ) + if ( item != nullptr && item->isDamageableItem() ) { int max = item->getMaxDamage(); int damageNow = item->getDamageValue(); @@ -88,7 +88,7 @@ bool TutorialMode::useItemOn(shared_ptr player, Level *level, shared_ptr if(!bTestUseOnly) { - if(item != NULL) + if(item != nullptr) { haveItem = true; itemCount = item->count; diff --git a/Minecraft.Client/Common/Tutorial/TutorialMode.h b/Minecraft.Client/Common/Tutorial/TutorialMode.h index 75e24edf0..2263a91c6 100644 --- a/Minecraft.Client/Common/Tutorial/TutorialMode.h +++ b/Minecraft.Client/Common/Tutorial/TutorialMode.h @@ -19,7 +19,7 @@ class TutorialMode : public MultiPlayerGameMode virtual void startDestroyBlock(int x, int y, int z, int face); virtual bool destroyBlock(int x, int y, int z, int face); virtual void tick(); - virtual bool useItemOn(shared_ptr player, Level *level, shared_ptr item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly=false, bool *pbUsedItem=NULL); + virtual bool useItemOn(shared_ptr player, Level *level, shared_ptr item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly=false, bool *pbUsedItem=nullptr); virtual void attack(shared_ptr player, shared_ptr entity); virtual bool isInputAllowed(int mapping); diff --git a/Minecraft.Client/Common/Tutorial/TutorialTask.cpp b/Minecraft.Client/Common/Tutorial/TutorialTask.cpp index 53fdd275a..1b6d84b2a 100644 --- a/Minecraft.Client/Common/Tutorial/TutorialTask.cpp +++ b/Minecraft.Client/Common/Tutorial/TutorialTask.cpp @@ -9,7 +9,7 @@ TutorialTask::TutorialTask(Tutorial *tutorial, int descriptionId, bool enablePre areConstraintsEnabled( false ), bIsCompleted( false ), bHasBeenActivated( false ), m_bAllowFade(bAllowFade), m_bTaskReminders(bTaskReminders), m_bShowMinimumTime( bShowMinimumTime), m_bShownForMinimumTime( false ) { - if(inConstraints != NULL) + if(inConstraints != nullptr) { for(auto& constraint : *inConstraints) { diff --git a/Minecraft.Client/Common/Tutorial/UseItemTask.h b/Minecraft.Client/Common/Tutorial/UseItemTask.h index 6c7295407..9c8f01921 100644 --- a/Minecraft.Client/Common/Tutorial/UseItemTask.h +++ b/Minecraft.Client/Common/Tutorial/UseItemTask.h @@ -13,7 +13,7 @@ class UseItemTask : public TutorialTask public: UseItemTask(const int itemId, Tutorial *tutorial, int descriptionId, - bool enablePreCompletion = false, vector *inConstraints = NULL, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true ); + bool enablePreCompletion = false, vector *inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true ); virtual bool isCompleted(); virtual void useItem(shared_ptr item, bool bTestUseOnly=false); }; \ No newline at end of file diff --git a/Minecraft.Client/Common/Tutorial/UseTileTask.h b/Minecraft.Client/Common/Tutorial/UseTileTask.h index 74b3a40cc..1f72fb2ed 100644 --- a/Minecraft.Client/Common/Tutorial/UseTileTask.h +++ b/Minecraft.Client/Common/Tutorial/UseTileTask.h @@ -16,9 +16,9 @@ class UseTileTask : public TutorialTask public: UseTileTask(const int tileId, int x, int y, int z, Tutorial *tutorial, int descriptionId, - bool enablePreCompletion = false, vector *inConstraints = NULL, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true ); + bool enablePreCompletion = false, vector *inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true ); UseTileTask(const int tileId, Tutorial *tutorial, int descriptionId, - bool enablePreCompletion = false, vector *inConstraints = NULL, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true); + bool enablePreCompletion = false, vector *inConstraints = nullptr, bool bShowMinimumTime = false, bool bAllowFade = true, bool bTaskReminders = true); virtual bool isCompleted(); virtual void useItemOn(Level *level, shared_ptr item, int x, int y, int z, bool bTestUseOnly=false); }; \ No newline at end of file diff --git a/Minecraft.Client/Common/Tutorial/XuiCraftingTask.cpp b/Minecraft.Client/Common/Tutorial/XuiCraftingTask.cpp index 71b884790..d0217d195 100644 --- a/Minecraft.Client/Common/Tutorial/XuiCraftingTask.cpp +++ b/Minecraft.Client/Common/Tutorial/XuiCraftingTask.cpp @@ -22,13 +22,13 @@ bool XuiCraftingTask::isCompleted() switch(m_type) { case e_Crafting_SelectGroup: - if(craftScene != NULL && craftScene->getCurrentGroup() == m_group) + if(craftScene != nullptr && craftScene->getCurrentGroup() == m_group) { completed = true; } break; case e_Crafting_SelectItem: - if(craftScene != NULL && craftScene->isItemSelected(m_item)) + if(craftScene != nullptr && craftScene->isItemSelected(m_item)) { completed = true; } diff --git a/Minecraft.Client/Common/Tutorial/XuiCraftingTask.h b/Minecraft.Client/Common/Tutorial/XuiCraftingTask.h index 2dc48709d..146b1554a 100644 --- a/Minecraft.Client/Common/Tutorial/XuiCraftingTask.h +++ b/Minecraft.Client/Common/Tutorial/XuiCraftingTask.h @@ -12,7 +12,7 @@ class XuiCraftingTask : public TutorialTask }; // Select group - XuiCraftingTask(Tutorial *tutorial, int descriptionId, Recipy::_eGroupType groupToSelect, bool enablePreCompletion = false, vector *inConstraints = NULL, + XuiCraftingTask(Tutorial *tutorial, int descriptionId, Recipy::_eGroupType groupToSelect, bool enablePreCompletion = false, vector *inConstraints = nullptr, bool bShowMinimumTime=false, bool bAllowFade=true, bool m_bTaskReminders=true ) : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, bShowMinimumTime, bAllowFade, m_bTaskReminders ), m_group(groupToSelect), @@ -20,7 +20,7 @@ class XuiCraftingTask : public TutorialTask {} // Select Item - XuiCraftingTask(Tutorial *tutorial, int descriptionId, int itemId, bool enablePreCompletion = false, vector *inConstraints = NULL, + XuiCraftingTask(Tutorial *tutorial, int descriptionId, int itemId, bool enablePreCompletion = false, vector *inConstraints = nullptr, bool bShowMinimumTime=false, bool bAllowFade=true, bool m_bTaskReminders=true ) : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, bShowMinimumTime, bAllowFade, m_bTaskReminders ), m_item(itemId), diff --git a/Minecraft.Client/Common/UI/IUIController.h b/Minecraft.Client/Common/UI/IUIController.h index 3040c2ccd..35a808c5d 100644 --- a/Minecraft.Client/Common/UI/IUIController.h +++ b/Minecraft.Client/Common/UI/IUIController.h @@ -12,7 +12,7 @@ class IUIController virtual void StartReloadSkinThread() = 0; virtual bool IsReloadingSkin() = 0; virtual void CleanUpSkinReload() = 0; - virtual bool NavigateToScene(int iPad, EUIScene scene, void *initData = NULL, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD) = 0; + virtual bool NavigateToScene(int iPad, EUIScene scene, void *initData = nullptr, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD) = 0; virtual bool NavigateBack(int iPad, bool forceUsePad = false, EUIScene eScene = eUIScene_COUNT, EUILayer eLayer = eUILayer_COUNT) = 0; virtual void CloseUIScenes(int iPad, bool forceIPad = false) = 0; virtual void CloseAllPlayersScenes() = 0; diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp index 41dc28c87..6df5571a8 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -21,9 +21,9 @@ SavedInventoryCursorPos g_savedInventoryCursorPos = { 0.0f, 0.0f, false }; IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu() { - m_menu = NULL; + m_menu = nullptr; m_autoDeleteMenu = false; - m_lastPointerLabelSlot = NULL; + m_lastPointerLabelSlot = nullptr; m_pointerPos.x = 0.0f; m_pointerPos.y = 0.0f; @@ -41,7 +41,7 @@ IUIScene_AbstractContainerMenu::~IUIScene_AbstractContainerMenu() void IUIScene_AbstractContainerMenu::Initialize(int iPad, AbstractContainerMenu* menu, bool autoDeleteMenu, int startIndex,ESceneSection firstSection,ESceneSection maxSection, bool bNavigateBack) { - assert( menu != NULL ); + assert( menu != nullptr ); m_menu = menu; m_autoDeleteMenu = autoDeleteMenu; @@ -267,10 +267,10 @@ void IUIScene_AbstractContainerMenu::UpdateTooltips() void IUIScene_AbstractContainerMenu::onMouseTick() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[getPad()] != NULL) + if( pMinecraft->localgameModes[getPad()] != nullptr) { Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial(); - if(tutorial != NULL) + if(tutorial != nullptr) { if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(ACTION_MENU_UP)) { @@ -758,17 +758,17 @@ void IUIScene_AbstractContainerMenu::onMouseTick() // What are we carrying on pointer. shared_ptr player = Minecraft::GetInstance()->localplayers[getPad()]; shared_ptr carriedItem = nullptr; - if(player != NULL) carriedItem = player->inventory->getCarried(); + if(player != nullptr) carriedItem = player->inventory->getCarried(); shared_ptr slotItem = nullptr; - Slot *slot = NULL; + Slot *slot = nullptr; int slotIndex = 0; if(bPointerIsOverSlot) { slotIndex = iNewSlotIndex + getSectionStartOffset( eSectionUnderPointer ); slot = m_menu->getSlot(slotIndex); } - bool bIsItemCarried = carriedItem != NULL; + bool bIsItemCarried = carriedItem != nullptr; int iCarriedCount = 0; bool bCarriedIsSameAsSlot = false; // Indicates if same item is carried on pointer as is in slot under pointer. if ( bIsItemCarried ) @@ -788,7 +788,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() if ( bPointerIsOverSlot ) { slotItem = slot->getItem(); - bSlotHasItem = slotItem != NULL; + bSlotHasItem = slotItem != nullptr; if ( bSlotHasItem ) { iSlotCount = slotItem->GetCount(); @@ -829,13 +829,13 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { vector *desc = GetSectionHoverText(eSectionUnderPointer); SetPointerText(desc, false); - m_lastPointerLabelSlot = NULL; + m_lastPointerLabelSlot = nullptr; delete desc; } else { - SetPointerText(NULL, false); - m_lastPointerLabelSlot = NULL; + SetPointerText(nullptr, false); + m_lastPointerLabelSlot = nullptr; } EToolTipItem buttonA, buttonX, buttonY, buttonRT, buttonBack; @@ -1021,7 +1021,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() // Get the info on this item. shared_ptr item = getSlotItem(eSectionUnderPointer, iNewSlotIndex); bool bValidFuel = FurnaceTileEntity::isFuel(item); - bool bValidIngredient = FurnaceRecipes::getInstance()->getResult(item->getItem()->id) != NULL; + bool bValidIngredient = FurnaceRecipes::getInstance()->getResult(item->getItem()->id) != nullptr; if(bValidIngredient) { @@ -1036,7 +1036,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() } else { - if(FurnaceRecipes::getInstance()->getResult(item->id)==NULL) + if(FurnaceRecipes::getInstance()->getResult(item->id)==nullptr) { buttonY = eToolTipQuickMove; } @@ -1076,7 +1076,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() } else { - if(FurnaceRecipes::getInstance()->getResult(item->id)==NULL) + if(FurnaceRecipes::getInstance()->getResult(item->id)==nullptr) { buttonY = eToolTipQuickMove; } @@ -1322,10 +1322,10 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b bool bHandled = false; Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[getPad()] != NULL ) + if( pMinecraft->localgameModes[getPad()] != nullptr ) { Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial(); - if(tutorial != NULL) + if(tutorial != nullptr) { tutorial->handleUIInput(iAction); if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(iAction)) @@ -1513,12 +1513,12 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b if ( bSlotHasItem ) { shared_ptr item = getSlotItem(m_eCurrSection, currentIndex); - if( Minecraft::GetInstance()->localgameModes[iPad] != NULL ) + if( Minecraft::GetInstance()->localgameModes[iPad] != nullptr ) { Tutorial::PopupMessageDetails *message = new Tutorial::PopupMessageDetails; message->m_messageId = item->getUseDescriptionId(); - if(Item::items[item->id] != NULL) message->m_titleString = Item::items[item->id]->getHoverName(item); + if(Item::items[item->id] != nullptr) message->m_titleString = Item::items[item->id]->getHoverName(item); message->m_titleId = item->getDescriptionId(); message->m_icon = item->id; @@ -1526,7 +1526,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b message->m_forceDisplay = true; TutorialMode *gameMode = static_cast(Minecraft::GetInstance()->localgameModes[iPad]); - gameMode->getTutorial()->setMessage(NULL, message); + gameMode->getTutorial()->setMessage(nullptr, message); ui.PlayUISFX(eSFX_Press); } } @@ -1628,7 +1628,7 @@ void IUIScene_AbstractContainerMenu::handleSlotListClicked(ESceneSection eSectio void IUIScene_AbstractContainerMenu::slotClicked(int slotId, int buttonNum, bool quickKey) { // 4J Stu - Removed this line as unused - //if (slot != NULL) slotId = slot->index; + //if (slot != nullptr) slotId = slot->index; Minecraft *pMinecraft = Minecraft::GetInstance(); pMinecraft->localgameModes[getPad()]->handleInventoryMouseClick(m_menu->containerId, slotId, buttonNum, quickKey, pMinecraft->localplayers[getPad()] ); @@ -1645,7 +1645,7 @@ int IUIScene_AbstractContainerMenu::getCurrentIndex(ESceneSection eSection) bool IUIScene_AbstractContainerMenu::IsSameItemAs(shared_ptr itemA, shared_ptr itemB) { - if(itemA == NULL || itemB == NULL) return false; + if(itemA == nullptr || itemB == nullptr) return false; return (itemA->id == itemB->id && (!itemB->isStackedByData() || itemB->getAuxValue() == itemA->getAuxValue()) && ItemInstance::tagMatches(itemB, itemA) ); } @@ -1654,7 +1654,7 @@ int IUIScene_AbstractContainerMenu::GetEmptyStackSpace(Slot *slot) { int iResult = 0; - if(slot != NULL && slot->hasItem()) + if(slot != nullptr && slot->hasItem()) { shared_ptr item = slot->getItem(); if ( item->isStackable() ) @@ -1673,7 +1673,7 @@ int IUIScene_AbstractContainerMenu::GetEmptyStackSpace(Slot *slot) vector *IUIScene_AbstractContainerMenu::GetItemDescription(Slot *slot) { - if(slot == NULL) return NULL; + if(slot == nullptr) return nullptr; vector *lines = slot->getItem()->getHoverText(nullptr, false); @@ -1693,5 +1693,5 @@ vector *IUIScene_AbstractContainerMenu::GetItemDescription(Slot *slo vector *IUIScene_AbstractContainerMenu::GetSectionHoverText(ESceneSection eSection) { - return NULL; + return nullptr; } diff --git a/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp index 10d1bcc41..2c1469bcd 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp @@ -10,7 +10,7 @@ IUIScene_AnvilMenu::IUIScene_AnvilMenu() { m_inventory = nullptr; - m_repairMenu = NULL; + m_repairMenu = nullptr; m_itemName = L""; } @@ -231,7 +231,7 @@ void IUIScene_AnvilMenu::handleTick() void IUIScene_AnvilMenu::updateItemName() { Slot *slot = m_repairMenu->getSlot(AnvilMenu::INPUT_SLOT); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { if (!slot->getItem()->hasCustomHoverName() && m_itemName.compare(slot->getItem()->getHoverName())==0) { @@ -257,10 +257,10 @@ void IUIScene_AnvilMenu::slotChanged(AbstractContainerMenu *container, int slotI { if (slotIndex == AnvilMenu::INPUT_SLOT) { - m_itemName = item == NULL ? L"" : item->getHoverName(); + m_itemName = item == nullptr ? L"" : item->getHoverName(); setEditNameValue(m_itemName); - setEditNameEditable(item != NULL); - if (item != NULL) + setEditNameEditable(item != nullptr); + if (item != nullptr) { updateItemName(); } diff --git a/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp index bb13deb89..efe4c2e11 100644 --- a/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp @@ -216,7 +216,7 @@ void IUIScene_BeaconMenu::handleOtherClicked(int iPad, ESceneSection eSection, i { case eSectionBeaconConfirm: { - if( (m_beacon->getItem(0) == NULL) || (m_beacon->getPrimaryPower() <= 0) ) return; + if( (m_beacon->getItem(0) == nullptr) || (m_beacon->getPrimaryPower() <= 0) ) return; ByteArrayOutputStream baos; DataOutputStream dos(&baos); dos.writeInt(m_beacon->getPrimaryPower()); @@ -286,7 +286,7 @@ void IUIScene_BeaconMenu::handleTick() for (int c = 0; c < count; c++) { - if(BeaconTileEntity::BEACON_EFFECTS[tier][c] == NULL) continue; + if(BeaconTileEntity::BEACON_EFFECTS[tier][c] == nullptr) continue; int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id; int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon(); @@ -315,7 +315,7 @@ void IUIScene_BeaconMenu::handleTick() for (int c = 0; c < count - 1; c++) { - if(BeaconTileEntity::BEACON_EFFECTS[tier][c] == NULL) continue; + if(BeaconTileEntity::BEACON_EFFECTS[tier][c] == nullptr) continue; int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id; int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon(); @@ -355,7 +355,7 @@ void IUIScene_BeaconMenu::handleTick() } } - SetConfirmButtonEnabled( (m_beacon->getItem(0) != NULL) && (m_beacon->getPrimaryPower() > 0) ); + SetConfirmButtonEnabled( (m_beacon->getItem(0) != nullptr) && (m_beacon->getPrimaryPower() > 0) ); } int IUIScene_BeaconMenu::GetId(int tier, int effectId) @@ -365,7 +365,7 @@ int IUIScene_BeaconMenu::GetId(int tier, int effectId) vector *IUIScene_BeaconMenu::GetSectionHoverText(ESceneSection eSection) { - vector *desc = NULL; + vector *desc = nullptr; switch(eSection) { case eSectionBeaconSecondaryTwo: diff --git a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp index e0d8472a1..e056fd68b 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp @@ -154,10 +154,10 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[getPad()] != NULL ) + if( pMinecraft->localgameModes[getPad()] != nullptr ) { Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial(); - if(tutorial != NULL) + if(tutorial != nullptr) { tutorial->handleUIInput(iAction); if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(iAction)) @@ -211,10 +211,10 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); - if( pMinecraft->localgameModes[iPad] != NULL) + if( pMinecraft->localgameModes[iPad] != nullptr) { Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); - if(tutorial != NULL) + if(tutorial != nullptr) { tutorial->onCrafted(pTempItemInst); } @@ -247,10 +247,10 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); - if( pMinecraft->localgameModes[iPad] != NULL ) + if( pMinecraft->localgameModes[iPad] != nullptr ) { Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); - if(tutorial != NULL) + if(tutorial != nullptr) { tutorial->createItemSelected(pTempItemInst, pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]); } @@ -288,7 +288,7 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) } // 4J Stu - Fix for #13097 - Bug: Milk Buckets are removed when crafting Cake - if (ingItemInst != NULL) + if (ingItemInst != nullptr) { if (ingItemInst->getItem()->hasCraftingRemainingItem()) { @@ -608,7 +608,7 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() // dump out the inventory /* for (unsigned int k = 0; k < m_pPlayer->inventory->items.length; k++) { - if (m_pPlayer->inventory->items[k] != NULL) + if (m_pPlayer->inventory->items[k] != nullptr) { wstring itemstring=m_pPlayer->inventory->items[k]->toString(); @@ -627,8 +627,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() // for (int i = 0; i < iRecipeC; i++) // { - // shared_ptr pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(NULL); - // if (pTempItemInst != NULL) + // shared_ptr pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(nullptr); + // if (pTempItemInst != nullptr) // { // wstring itemstring=pTempItemInst->toString(); // @@ -683,7 +683,7 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() // Does the player have this ingredient? for (unsigned int k = 0; k < m_pPlayer->inventory->items.length; k++) { - if (m_pPlayer->inventory->items[k] != NULL) + if (m_pPlayer->inventory->items[k] != nullptr) { // do they have the ingredient, and the aux value matches, and enough off it? if((m_pPlayer->inventory->items[k]->id == pRecipeIngredientsRequired[i].iIngIDA[j]) && @@ -703,7 +703,7 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() for(unsigned int l=0;linventory->items.length;l++) { - if (m_pPlayer->inventory->items[l] != NULL) + if (m_pPlayer->inventory->items[l] != nullptr) { if( (m_pPlayer->inventory->items[l]->id == pRecipeIngredientsRequired[i].iIngIDA[j]) && diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index efe19ce9d..4719a69f7 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -13,7 +13,7 @@ #include "..\..\..\Minecraft.World\JavaMath.h" // 4J JEV - Images for each tab. -IUIScene_CreativeMenu::TabSpec **IUIScene_CreativeMenu::specs = NULL; +IUIScene_CreativeMenu::TabSpec **IUIScene_CreativeMenu::specs = nullptr; vector< shared_ptr > IUIScene_CreativeMenu::categoryGroups[eCreativeInventoryGroupsCount]; @@ -488,7 +488,7 @@ void IUIScene_CreativeMenu::staticCtor() for(unsigned int i = 0; i < Enchantment::enchantments.length; ++i) { Enchantment *enchantment = Enchantment::enchantments[i]; - if (enchantment == NULL || enchantment->category == NULL) continue; + if (enchantment == nullptr || enchantment->category == nullptr) continue; list->push_back(Item::enchantedBook->createForEnchantment(new EnchantmentInstance(enchantment, enchantment->getMaxLevel()))); } @@ -673,7 +673,7 @@ void IUIScene_CreativeMenu::staticCtor() #ifndef _CONTENT_PACKAGE ECreative_Inventory_Groups decorationsGroup[] = {eCreativeInventory_Decoration}; ECreative_Inventory_Groups debugDecorationsGroup[] = {eCreativeInventory_ArtToolsDecorations}; - specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, NULL, 1, debugDecorationsGroup); + specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, nullptr, 1, debugDecorationsGroup); #else ECreative_Inventory_Groups decorationsGroup[] = {eCreativeInventory_Decoration}; specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup); @@ -707,7 +707,7 @@ void IUIScene_CreativeMenu::staticCtor() #ifndef _CONTENT_PACKAGE ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc}; ECreative_Inventory_Groups debugMiscGroup[] = {eCreativeInventory_ArtToolsMisc}; - specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, NULL, 1, debugMiscGroup); + specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, nullptr, 1, debugMiscGroup); #else ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc}; specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup); @@ -766,12 +766,12 @@ void IUIScene_CreativeMenu::ScrollBar(UIVec2D pointerPos) // 4J JEV - Tab Spec Struct -IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups *dynamicGroups, int debugGroupsCount /*= 0*/, ECreative_Inventory_Groups *debugGroups /*= NULL*/) +IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups *dynamicGroups, int debugGroupsCount /*= 0*/, ECreative_Inventory_Groups *debugGroups /*= nullptr*/) : m_icon(icon), m_descriptionId(descriptionId), m_staticGroupsCount(staticGroupsCount), m_dynamicGroupsCount(dynamicGroupsCount), m_debugGroupsCount(debugGroupsCount) { m_pages = 0; - m_staticGroupsA = NULL; + m_staticGroupsA = nullptr; unsigned int dynamicItems = 0; m_staticItems = 0; @@ -786,7 +786,7 @@ IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int sta } } - m_debugGroupsA = NULL; + m_debugGroupsA = nullptr; m_debugItems = 0; if(debugGroupsCount > 0) { @@ -798,8 +798,8 @@ IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int sta } } - m_dynamicGroupsA = NULL; - if(dynamicGroupsCount > 0 && dynamicGroups != NULL) + m_dynamicGroupsA = nullptr; + if(dynamicGroupsCount > 0 && dynamicGroups != nullptr) { m_dynamicGroupsA = new ECreative_Inventory_Groups[dynamicGroupsCount]; for(int i = 0; i < dynamicGroupsCount; ++i) @@ -816,9 +816,9 @@ IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int sta IUIScene_CreativeMenu::TabSpec::~TabSpec() { - if(m_staticGroupsA != NULL) delete [] m_staticGroupsA; - if(m_dynamicGroupsA != NULL) delete [] m_dynamicGroupsA; - if(m_debugGroupsA != NULL) delete [] m_debugGroupsA; + if(m_staticGroupsA != nullptr) delete [] m_staticGroupsA; + if(m_dynamicGroupsA != nullptr) delete [] m_dynamicGroupsA; + if(m_debugGroupsA != nullptr) delete [] m_debugGroupsA; } void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu *menu, int dynamicIndex, unsigned int page) @@ -826,7 +826,7 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu *menu, i int lastSlotIndex = 0; // Fill the dynamic group - if(m_dynamicGroupsCount > 0 && m_dynamicGroupsA != NULL) + if(m_dynamicGroupsCount > 0 && m_dynamicGroupsA != nullptr) { for (auto it = categoryGroups[m_dynamicGroupsA[dynamicIndex]].rbegin(); it != categoryGroups[m_dynamicGroupsA[dynamicIndex]].rend() && lastSlotIndex < MAX_SIZE; ++it) { @@ -957,7 +957,7 @@ IUIScene_CreativeMenu::ItemPickerMenu::ItemPickerMenu( shared_ptrsize(); - Slot *slot = NULL; + Slot *slot = nullptr; for (int i = 0; i < TabSpec::MAX_SIZE; i++) { // 4J JEV - These values get set by addSlot anyway. @@ -1036,7 +1036,7 @@ bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, BOOL qu { shared_ptr newItem = m_menu->getSlot(i)->getItem(); - if(newItem != NULL) + if(newItem != nullptr) { m_menu->getSlot(i)->set(nullptr); // call this function to synchronize multiplayer item bar @@ -1054,7 +1054,7 @@ void IUIScene_CreativeMenu::handleOutsideClicked(int iPad, int buttonNum, BOOL q Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr playerInventory = pMinecraft->localplayers[iPad]->inventory; - if (playerInventory->getCarried() != NULL) + if (playerInventory->getCarried() != nullptr) { if (buttonNum == 0) { @@ -1155,7 +1155,7 @@ void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, int bu shared_ptr playerInventory = pMinecraft->localplayers[getPad()]->inventory; shared_ptr carried = playerInventory->getCarried(); shared_ptr clicked = m_menu->getSlot(currentIndex)->getItem(); - if (clicked != NULL) + if (clicked != nullptr) { playerInventory->setCarried(ItemInstance::clone(clicked)); carried = playerInventory->getCarried(); @@ -1236,7 +1236,7 @@ bool IUIScene_CreativeMenu::getEmptyInventorySlot(shared_ptr item, for(unsigned int i = TabSpec::MAX_SIZE; i < TabSpec::MAX_SIZE + 9; ++i) { shared_ptr slotItem = m_menu->getSlot(i)->getItem(); - if( slotItem != NULL && slotItem->sameItemWithTags(item) && (slotItem->GetCount() + item->GetCount() <= item->getMaxStackSize() )) + if( slotItem != nullptr && slotItem->sameItemWithTags(item) && (slotItem->GetCount() + item->GetCount() <= item->getMaxStackSize() )) { sameItemFound = true; slotX = i - TabSpec::MAX_SIZE; @@ -1249,7 +1249,7 @@ bool IUIScene_CreativeMenu::getEmptyInventorySlot(shared_ptr item, // Find an empty slot for(unsigned int i = TabSpec::MAX_SIZE; i < TabSpec::MAX_SIZE + 9; ++i) { - if( m_menu->getSlot(i)->getItem() == NULL ) + if( m_menu->getSlot(i)->getItem() == nullptr ) { slotX = i - TabSpec::MAX_SIZE; emptySlotFound = true; @@ -1328,7 +1328,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector > *lis // diamonds give trails if (trail) expTag->putBoolean(FireworksItem::TAG_E_TRAIL, true); - intArray colorArray(colors.size()); + intArray colorArray(static_cast(colors.size())); for (int i = 0; i < colorArray.length; i++) { colorArray[i] = colors.at(i); @@ -1347,7 +1347,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector > *lis vector colors; colors.push_back(DyePowderItem::COLOR_RGB[fadeColor]); - intArray colorArray(colors.size()); + intArray colorArray(static_cast(colors.size())); for (int i = 0; i < colorArray.length; i++) { colorArray[i] = colors.at(i); diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h index 64b78029b..864fb5606 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h @@ -69,7 +69,7 @@ class IUIScene_CreativeMenu : public virtual IUIScene_AbstractContainerMenu unsigned int m_debugItems; public: - TabSpec( LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount = 0, ECreative_Inventory_Groups *dynamicGroups = NULL, int debugGroupsCount = 0, ECreative_Inventory_Groups *debugGroups = NULL ); + TabSpec( LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount = 0, ECreative_Inventory_Groups *dynamicGroups = nullptr, int debugGroupsCount = 0, ECreative_Inventory_Groups *debugGroups = nullptr ); ~TabSpec(); void populateMenu(AbstractContainerMenu *menu, int dynamicIndex, unsigned int page); diff --git a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp index 294816ed6..27c62a13e 100644 --- a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp @@ -79,7 +79,7 @@ void IUIScene_HUD::updateFrameTick() { //SetRidingHorse(false, 0); shared_ptr riding = pMinecraft->localplayers[iPad]->riding; - if(riding == NULL) + if(riding == nullptr) { SetRidingHorse(false, false, 0); } @@ -171,7 +171,7 @@ void IUIScene_HUD::updateFrameTick() SetOpacity(fVal); bool bDisplayGui=app.GetGameStarted() && !ui.GetMenuDisplayed(iPad) && !(app.GetXuiAction(iPad)==eAppAction_AutosaveSaveGameCapturedThumbnail) && app.GetGameSettings(iPad,eGameSetting_DisplayHUD)!=0; - if(bDisplayGui && pMinecraft->localplayers[iPad] != NULL) + if(bDisplayGui && pMinecraft->localplayers[iPad] != nullptr) { SetVisible(true); } @@ -219,7 +219,7 @@ void IUIScene_HUD::renderPlayerHealth() shared_ptr riding = pMinecraft->localplayers[iPad]->riding; - if(riding == NULL || riding && !riding->instanceof(eTYPE_LIVINGENTITY)) + if(riding == nullptr || riding && !riding->instanceof(eTYPE_LIVINGENTITY)) { SetRidingHorse(false, false, 0); diff --git a/Minecraft.Client/Common/UI/IUIScene_PauseMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_PauseMenu.cpp index 852928785..e88ed08cd 100644 --- a/Minecraft.Client/Common/UI/IUIScene_PauseMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_PauseMenu.cpp @@ -229,7 +229,7 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4 { // 4J-PB - need to check this user can access the store bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -248,7 +248,7 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4 app.DebugPrintf("Texture Pack - %s\n",pchPackName); SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; @@ -300,7 +300,7 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4 DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName((WCHAR *)pDLCPack->getName().c_str()); - StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),NULL,NULL); + StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),nullptr,nullptr); // the license change coming in when the offer has been installed will cause this scene to refresh } @@ -336,7 +336,7 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4 // need to allow downloads here, or the player would need to quit the game to let the download of a texture pack happen. This might affect the network traffic, since the download could take all the bandwidth... XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } else @@ -421,7 +421,7 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) bool saveStats = true; if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession()) { - if(lpParameter != NULL ) + if(lpParameter != nullptr ) { // 4J-PB - check if we have lost connection to Live if(ProfileManager.GetLiveConnectionStatus()!=XONLINE_S_LOGON_CONNECTION_ESTABLISHED ) @@ -522,17 +522,17 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) exitReasonStringId = -1; // 4J - Force a disconnection, this handles the situation that the server has already disconnected - if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(false); - if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(false); - if( pMinecraft->levels[2] != NULL ) pMinecraft->levels[2]->disconnect(false); + if( pMinecraft->levels[0] != nullptr ) pMinecraft->levels[0]->disconnect(false); + if( pMinecraft->levels[1] != nullptr ) pMinecraft->levels[1]->disconnect(false); + if( pMinecraft->levels[2] != nullptr ) pMinecraft->levels[2]->disconnect(false); } else { exitReasonStringId = IDS_EXITING_GAME; pMinecraft->progressRenderer->progressStartNoAbort( IDS_EXITING_GAME ); - if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(); - if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(); - if( pMinecraft->levels[2] != NULL ) pMinecraft->levels[2]->disconnect(); + if( pMinecraft->levels[0] != nullptr ) pMinecraft->levels[0]->disconnect(); + if( pMinecraft->levels[1] != nullptr ) pMinecraft->levels[1]->disconnect(); + if( pMinecraft->levels[2] != nullptr ) pMinecraft->levels[2]->disconnect(); } // 4J Stu - This only does something if we actually have a server, so don't need to do any other checks @@ -548,7 +548,7 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) } else { - if(lpParameter != NULL && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()) ) + if(lpParameter != nullptr && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()) ) { switch( app.GetDisconnectReason() ) { @@ -625,7 +625,7 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) { Sleep(1); } - pMinecraft->setLevel(NULL,exitReasonStringId,nullptr,saveStats); + pMinecraft->setLevel(nullptr,exitReasonStringId,nullptr,saveStats); TelemetryManager->Flush(); diff --git a/Minecraft.Client/Common/UI/IUIScene_StartGame.cpp b/Minecraft.Client/Common/UI/IUIScene_StartGame.cpp index 08be958aa..735da438a 100644 --- a/Minecraft.Client/Common/UI/IUIScene_StartGame.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_StartGame.cpp @@ -45,7 +45,7 @@ void IUIScene_StartGame::HandleDLCMountingComplete() // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this // REMOVE UNTIL WORKING - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -86,7 +86,7 @@ void IUIScene_StartGame::HandleDLCMountingComplete() // add a TMS request for them app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n"); app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData); - if(m_iConfigA!=NULL) + if(m_iConfigA!=nullptr) { delete m_iConfigA; } @@ -135,13 +135,13 @@ void IUIScene_StartGame::UpdateTexturePackDescription(int index) { TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackByIndex(index); - if(tp==NULL) + if(tp==nullptr) { #if TO_BE_IMPLEMENTED // this is probably a texture pack icon added from TMS DWORD dwBytes=0,dwFileBytes=0; - PBYTE pbData=NULL,pbFileData=NULL; + PBYTE pbData=nullptr,pbFileData=nullptr; CXuiCtrl4JList::LIST_ITEM_INFO ListItem; // get the current index of the list, and then get the data @@ -171,7 +171,7 @@ void IUIScene_StartGame::UpdateTexturePackDescription(int index) } else { - m_texturePackComparison->UseBrush(NULL); + m_texturePackComparison->UseBrush(nullptr); } #endif } @@ -214,7 +214,7 @@ void IUIScene_StartGame::UpdateCurrentTexturePack(int iSlot) TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackByIndex(m_currentTexturePackIndex); // if the texture pack is null, you don't have it yet - if(tp==NULL) + if(tp==nullptr) { #if TO_BE_IMPLEMENTED // Upsell @@ -279,7 +279,7 @@ int IUIScene_StartGame::UnlockTexturePackReturned(void *pParam,int iPad,C4JStora ULONGLONG ullIndexA[1]; DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(pScene->m_pDLCPack->getPurchaseOfferId()); - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullIndexA[0]=pDLCInfo->ullOfferID_Full; } @@ -289,9 +289,9 @@ int IUIScene_StartGame::UnlockTexturePackReturned(void *pParam,int iPad,C4JStora } - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); #elif defined _XBOX_ONE - //StorageManager.InstallOffer(1,StorageManager.GetOffer(iIndex).wszProductID,NULL,NULL); + //StorageManager.InstallOffer(1,StorageManager.GetOffer(iIndex).wszProductID,nullptr,nullptr); #endif // the license change coming in when the offer has been installed will cause this scene to refresh @@ -332,7 +332,7 @@ int IUIScene_StartGame::TexturePackDialogReturned(void *pParam,int iPad,C4JStora if( result==C4JStorage::EMessage_ResultAccept ) // Full version { ullIndexA[0]=ullOfferID_Full; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } else // trial version @@ -343,7 +343,7 @@ int IUIScene_StartGame::TexturePackDialogReturned(void *pParam,int iPad,C4JStora { ullIndexA[0]=pDLCInfo->ullOfferID_Trial; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } } @@ -360,7 +360,7 @@ int IUIScene_StartGame::TexturePackDialogReturned(void *pParam,int iPad,C4JStora app.GetDLCFullOfferIDForPackID(pClass->m_MoreOptionsParams.dwTexturePack,ProductId); - StorageManager.InstallOffer(1,(WCHAR *)ProductId.c_str(),NULL,NULL); + StorageManager.InstallOffer(1,(WCHAR *)ProductId.c_str(),nullptr,nullptr); // the license change coming in when the offer has been installed will cause this scene to refresh } diff --git a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp index 059f9b755..1f9cf7bd9 100644 --- a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp @@ -13,7 +13,7 @@ IUIScene_TradingMenu::IUIScene_TradingMenu() m_validOffersCount = 0; m_selectedSlot = 0; m_offersStartIndex = 0; - m_menu = NULL; + m_menu = nullptr; m_bHasUpdatedOnce = false; } @@ -31,10 +31,10 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[getPad()] != NULL ) + if( pMinecraft->localgameModes[getPad()] != nullptr ) { Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial(); - if(tutorial != NULL) + if(tutorial != nullptr) { tutorial->handleUIInput(iAction); if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(iAction)) @@ -76,7 +76,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) shared_ptr player = Minecraft::GetInstance()->localplayers[getPad()]; int buyAMatches = player->inventory->countMatches(buyAItem); int buyBMatches = player->inventory->countMatches(buyBItem); - if( (buyAItem != NULL && buyAMatches >= buyAItem->count) && (buyBItem == NULL || buyBMatches >= buyBItem->count) ) + if( (buyAItem != nullptr && buyAMatches >= buyAItem->count) && (buyBItem == nullptr || buyBMatches >= buyBItem->count) ) { // 4J-JEV: Fix for PS4 #7111: [PATCH 1.12] Trading Librarian villagers for multiple �Enchanted Books� will cause the title to crash. int actualShopItem = m_activeOffers.at(selectedShopItem).second; @@ -162,7 +162,7 @@ void IUIScene_TradingMenu::handleTick() { int offerCount = 0; MerchantRecipeList *offers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]); - if (offers != NULL) + if (offers != nullptr) { offerCount = offers->size(); @@ -181,7 +181,7 @@ void IUIScene_TradingMenu::updateDisplay() int iA = -1; MerchantRecipeList *unfilteredOffers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]); - if (unfilteredOffers != NULL) + if (unfilteredOffers != nullptr) { m_activeOffers.clear(); int unfilteredIndex = 0; @@ -255,10 +255,10 @@ void IUIScene_TradingMenu::updateDisplay() setRequest1Item(buyAItem); setRequest2Item(buyBItem); - if(buyAItem != NULL) setRequest1Name(buyAItem->getHoverName()); + if(buyAItem != nullptr) setRequest1Name(buyAItem->getHoverName()); else setRequest1Name(L""); - if(buyBItem != NULL) setRequest2Name(buyBItem->getHoverName()); + if(buyBItem != nullptr) setRequest2Name(buyBItem->getHoverName()); else setRequest2Name(L""); bool canMake = true; @@ -284,15 +284,15 @@ void IUIScene_TradingMenu::updateDisplay() } else { - if(buyBItem!=NULL) + if(buyBItem!=nullptr) { setRequest2RedBox(true); canMake = false; } else { - setRequest2RedBox(buyBItem != NULL); - canMake = canMake && buyBItem == NULL; + setRequest2RedBox(buyBItem != nullptr); + canMake = canMake && buyBItem == nullptr; } } @@ -320,7 +320,7 @@ void IUIScene_TradingMenu::updateDisplay() bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe) { bool canMake = false; - if (recipe != NULL) + if (recipe != nullptr) { if(recipe->isDeprecated()) return false; @@ -335,7 +335,7 @@ bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe) } else { - canMake = buyAItem == NULL; + canMake = buyAItem == nullptr; } int buyBMatches = player->inventory->countMatches(buyBItem); @@ -345,7 +345,7 @@ bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe) } else { - canMake = canMake && buyBItem == NULL; + canMake = canMake && buyBItem == nullptr; } } return canMake; diff --git a/Minecraft.Client/Common/UI/UIBitmapFont.cpp b/Minecraft.Client/Common/UI/UIBitmapFont.cpp index 98c19dc87..e9d110b71 100644 --- a/Minecraft.Client/Common/UI/UIBitmapFont.cpp +++ b/Minecraft.Client/Common/UI/UIBitmapFont.cpp @@ -351,7 +351,7 @@ rrbool UIBitmapFont::GetGlyphBitmap(S32 glyph,F32 pixel_scale,IggyBitmapCharacte bitmap->stride_in_bytes = m_cFontData->getFontData()->m_uiGlyphMapX; // 4J-JEV: Additional information needed to release memory afterwards. - bitmap->user_context_for_free = NULL; + bitmap->user_context_for_free = nullptr; return true; } diff --git a/Minecraft.Client/Common/UI/UIComponent_Chat.cpp b/Minecraft.Client/Common/UI/UIComponent_Chat.cpp index 49999255f..f8bd66ad9 100644 --- a/Minecraft.Client/Common/UI/UIComponent_Chat.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_Chat.cpp @@ -46,7 +46,7 @@ void UIComponent_Chat::handleTimerComplete(int id) Minecraft *pMinecraft = Minecraft::GetInstance(); bool anyVisible = false; - if(pMinecraft->localplayers[m_iPad]!= NULL) + if(pMinecraft->localplayers[m_iPad]!= nullptr) { Gui *pGui = pMinecraft->gui; //DWORD messagesToDisplay = min( CHAT_LINES_COUNT, pGui->getMessagesCount(m_iPad) ); diff --git a/Minecraft.Client/Common/UI/UIComponent_Panorama.cpp b/Minecraft.Client/Common/UI/UIComponent_Panorama.cpp index 6a0065034..7ac13115b 100644 --- a/Minecraft.Client/Common/UI/UIComponent_Panorama.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_Panorama.cpp @@ -45,7 +45,7 @@ void UIComponent_Panorama::tick() Minecraft *pMinecraft = Minecraft::GetInstance(); EnterCriticalSection(&pMinecraft->m_setLevelCS); - if(pMinecraft->level!=NULL) + if(pMinecraft->level!=nullptr) { __int64 i64TimeOfDay =0; // are we in the Nether? - Leave the time as 0 if we are, so we show daylight diff --git a/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp b/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp index 9b672939d..856611256 100644 --- a/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp @@ -351,7 +351,7 @@ void UIComponent_Tooltips::_SetTooltip(unsigned int iToolTipId, UIString label, void UIComponent_Tooltips::_Relayout() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcUpdateLayout, 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcUpdateLayout, 0 , nullptr ); #ifdef __PSVITA__ // rebuild touchboxes diff --git a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp index 01f124bd8..06dcd64ca 100644 --- a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp @@ -12,8 +12,8 @@ UIComponent_TutorialPopup::UIComponent_TutorialPopup(int iPad, void *initData, U // Setup all the Iggy references we need for this scene initialiseMovie(); - m_interactScene = NULL; - m_lastInteractSceneMoved = NULL; + m_interactScene = nullptr; + m_lastInteractSceneMoved = nullptr; m_lastSceneMovedLeft = false; m_bAllowFade = false; m_iconItem = nullptr; @@ -90,7 +90,7 @@ void UIComponent_TutorialPopup::RemoveInteractSceneReference(UIScene *scene) { if( m_interactScene == scene ) { - m_interactScene = NULL; + m_interactScene = nullptr; } } @@ -132,7 +132,7 @@ void UIComponent_TutorialPopup::_SetDescription(UIScene *interactScene, const ws { m_interactScene = interactScene; app.DebugPrintf("Setting m_interactScene to %08x\n", m_interactScene); - if( interactScene != m_lastInteractSceneMoved ) m_lastInteractSceneMoved = NULL; + if( interactScene != m_lastInteractSceneMoved ) m_lastInteractSceneMoved = nullptr; if(desc.empty()) { SetVisible( false ); @@ -327,8 +327,8 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, m_iconItem = nullptr; } } - if(!isFixedIcon && m_iconItem != NULL) setupIconHolder(e_ICON_TYPE_IGGY); - m_controlIconHolder.setVisible( isFixedIcon || m_iconItem != NULL); + if(!isFixedIcon && m_iconItem != nullptr) setupIconHolder(e_ICON_TYPE_IGGY); + m_controlIconHolder.setVisible( isFixedIcon || m_iconItem != nullptr); return temp; } @@ -425,7 +425,7 @@ wstring UIComponent_TutorialPopup::ParseDescription(int iPad, wstring &text) void UIComponent_TutorialPopup::UpdateInteractScenePosition(bool visible) { - if( m_interactScene == NULL ) return; + if( m_interactScene == nullptr ) return; // 4J-PB - check this players screen section to see if we should allow the animation bool bAllowAnim=false; @@ -529,7 +529,7 @@ void UIComponent_TutorialPopup::render(S32 width, S32 height, C4JRender::eViewpo void UIComponent_TutorialPopup::customDraw(IggyCustomDrawCallbackRegion *region) { - if(m_iconItem != NULL) customDrawSlotControl(region,m_iPad,m_iconItem,1.0f,m_iconItem->isFoil() || m_iconIsFoil,false); + if(m_iconItem != nullptr) customDrawSlotControl(region,m_iPad,m_iconItem,1.0f,m_iconItem->isFoil() || m_iconIsFoil,false); } void UIComponent_TutorialPopup::setupIconHolder(EIcons icon) diff --git a/Minecraft.Client/Common/UI/UIControl.cpp b/Minecraft.Client/Common/UI/UIControl.cpp index cbbbf7cac..fddcffcbf 100644 --- a/Minecraft.Client/Common/UI/UIControl.cpp +++ b/Minecraft.Client/Common/UI/UIControl.cpp @@ -6,7 +6,7 @@ UIControl::UIControl() { - m_parentScene = NULL; + m_parentScene = nullptr; m_lastOpacity = 1.0f; m_controlName = ""; m_isVisible = true; @@ -29,10 +29,10 @@ bool UIControl::setupControl(UIScene *scene, IggyValuePath *parent, const string m_nameVisible = registerFastName(L"visible"); F64 fx, fy, fwidth, fheight; - IggyValueGetF64RS( getIggyValuePath() , m_nameXPos , NULL , &fx ); - IggyValueGetF64RS( getIggyValuePath() , m_nameYPos , NULL , &fy ); - IggyValueGetF64RS( getIggyValuePath() , m_nameWidth , NULL , &fwidth ); - IggyValueGetF64RS( getIggyValuePath() , m_nameHeight , NULL , &fheight ); + IggyValueGetF64RS( getIggyValuePath() , m_nameXPos , nullptr , &fx ); + IggyValueGetF64RS( getIggyValuePath() , m_nameYPos , nullptr , &fy ); + IggyValueGetF64RS( getIggyValuePath() , m_nameWidth , nullptr , &fwidth ); + IggyValueGetF64RS( getIggyValuePath() , m_nameHeight , nullptr , &fheight ); m_x = static_cast(fx); m_y = static_cast(fy); @@ -45,10 +45,10 @@ bool UIControl::setupControl(UIScene *scene, IggyValuePath *parent, const string void UIControl::UpdateControl() { F64 fx, fy, fwidth, fheight; - IggyValueGetF64RS( getIggyValuePath() , m_nameXPos , NULL , &fx ); - IggyValueGetF64RS( getIggyValuePath() , m_nameYPos , NULL , &fy ); - IggyValueGetF64RS( getIggyValuePath() , m_nameWidth , NULL , &fwidth ); - IggyValueGetF64RS( getIggyValuePath() , m_nameHeight , NULL , &fheight ); + IggyValueGetF64RS( getIggyValuePath() , m_nameXPos , nullptr , &fx ); + IggyValueGetF64RS( getIggyValuePath() , m_nameYPos , nullptr , &fy ); + IggyValueGetF64RS( getIggyValuePath() , m_nameWidth , nullptr , &fwidth ); + IggyValueGetF64RS( getIggyValuePath() , m_nameHeight , nullptr , &fheight ); m_x = static_cast(fx); m_y = static_cast(fy); m_width = static_cast(Math::round(fwidth)); @@ -74,7 +74,7 @@ void UIControl::ReInit() IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, m_parentScene->m_rootPath , m_funcSetAlpha , 2 , value ); } - IggyValueSetBooleanRS( getIggyValuePath(), m_nameVisible, NULL, m_isVisible ); + IggyValueSetBooleanRS( getIggyValuePath(), m_nameVisible, nullptr, m_isVisible ); } IggyValuePath *UIControl::getIggyValuePath() @@ -128,7 +128,7 @@ void UIControl::setVisible(bool visible) { if(visible != m_isVisible) { - rrbool succ = IggyValueSetBooleanRS( getIggyValuePath(), m_nameVisible, NULL, visible ); + rrbool succ = IggyValueSetBooleanRS( getIggyValuePath(), m_nameVisible, nullptr, visible ); if(succ) m_isVisible = visible; else app.DebugPrintf("Failed to set visibility for control\n"); } @@ -138,7 +138,7 @@ bool UIControl::getVisible() { rrbool bVisible = false; - IggyResult result = IggyValueGetBooleanRS ( getIggyValuePath() , m_nameVisible, NULL, &bVisible ); + IggyResult result = IggyValueGetBooleanRS ( getIggyValuePath() , m_nameVisible, nullptr, &bVisible ); m_isVisible = bVisible; diff --git a/Minecraft.Client/Common/UI/UIControl_Base.cpp b/Minecraft.Client/Common/UI/UIControl_Base.cpp index 743aaa92b..87c2862f4 100644 --- a/Minecraft.Client/Common/UI/UIControl_Base.cpp +++ b/Minecraft.Client/Common/UI/UIControl_Base.cpp @@ -72,7 +72,7 @@ void UIControl_Base::setLabel(UIString label, bool instant, bool force) const wchar_t* UIControl_Base::getLabel() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcGetLabel, 0, NULL); + IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcGetLabel, 0, nullptr); if(result.type == IGGY_DATATYPE_string_UTF16) { diff --git a/Minecraft.Client/Common/UI/UIControl_ButtonList.cpp b/Minecraft.Client/Common/UI/UIControl_ButtonList.cpp index 9591be9cf..27e0b72ad 100644 --- a/Minecraft.Client/Common/UI/UIControl_ButtonList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_ButtonList.cpp @@ -60,7 +60,7 @@ void UIControl_ButtonList::ReInit() void UIControl_ButtonList::clearList() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_removeAllItemsFunc , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_removeAllItemsFunc , 0 , nullptr ); m_itemCount = 0; } diff --git a/Minecraft.Client/Common/UI/UIControl_CheckBox.cpp b/Minecraft.Client/Common/UI/UIControl_CheckBox.cpp index 1c3e8afee..e5f4da7a5 100644 --- a/Minecraft.Client/Common/UI/UIControl_CheckBox.cpp +++ b/Minecraft.Client/Common/UI/UIControl_CheckBox.cpp @@ -60,7 +60,7 @@ void UIControl_CheckBox::init(UIString label, int id, bool checked) bool UIControl_CheckBox::IsChecked() { rrbool checked = false; - IggyResult result = IggyValueGetBooleanRS ( &m_iggyPath , m_checkedProp, NULL, &checked ); + IggyResult result = IggyValueGetBooleanRS ( &m_iggyPath , m_checkedProp, nullptr, &checked ); m_bChecked = checked; return checked; } diff --git a/Minecraft.Client/Common/UI/UIControl_DynamicLabel.cpp b/Minecraft.Client/Common/UI/UIControl_DynamicLabel.cpp index ab2d5a44a..8c2758931 100644 --- a/Minecraft.Client/Common/UI/UIControl_DynamicLabel.cpp +++ b/Minecraft.Client/Common/UI/UIControl_DynamicLabel.cpp @@ -74,7 +74,7 @@ void UIControl_DynamicLabel::TouchScroll(S32 iY, bool bActive) S32 UIControl_DynamicLabel::GetRealWidth() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth, 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth, 0 , nullptr ); S32 iRealWidth = m_width; if(result.type == IGGY_DATATYPE_number) @@ -87,7 +87,7 @@ S32 UIControl_DynamicLabel::GetRealWidth() S32 UIControl_DynamicLabel::GetRealHeight() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealHeight, 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealHeight, 0 , nullptr ); S32 iRealHeight = m_height; if(result.type == IGGY_DATATYPE_number) diff --git a/Minecraft.Client/Common/UI/UIControl_EnchantmentBook.cpp b/Minecraft.Client/Common/UI/UIControl_EnchantmentBook.cpp index b8b41c3d0..f091b0fcc 100644 --- a/Minecraft.Client/Common/UI/UIControl_EnchantmentBook.cpp +++ b/Minecraft.Client/Common/UI/UIControl_EnchantmentBook.cpp @@ -12,7 +12,7 @@ UIControl_EnchantmentBook::UIControl_EnchantmentBook() { UIControl::setControlType(UIControl::eEnchantmentBook); - model = NULL; + model = nullptr; last = nullptr; time = 0; @@ -69,12 +69,12 @@ void UIControl_EnchantmentBook::render(IggyCustomDrawCallbackRegion *region) glEnable(GL_CULL_FACE); - if(model == NULL) + if(model == nullptr) { // Share the model the the EnchantTableRenderer EnchantTableRenderer *etr = static_cast(TileEntityRenderDispatcher::instance->getRenderer(eTYPE_ENCHANTMENTTABLEENTITY)); - if(etr != NULL) + if(etr != nullptr) { model = etr->bookModel; } diff --git a/Minecraft.Client/Common/UI/UIControl_HTMLLabel.cpp b/Minecraft.Client/Common/UI/UIControl_HTMLLabel.cpp index 1e2e85993..b6bd3e472 100644 --- a/Minecraft.Client/Common/UI/UIControl_HTMLLabel.cpp +++ b/Minecraft.Client/Common/UI/UIControl_HTMLLabel.cpp @@ -23,7 +23,7 @@ bool UIControl_HTMLLabel::setupControl(UIScene *scene, IggyValuePath *parent, co void UIControl_HTMLLabel::startAutoScroll() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcStartAutoScroll , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcStartAutoScroll , 0 , nullptr ); } void UIControl_HTMLLabel::ReInit() @@ -79,7 +79,7 @@ void UIControl_HTMLLabel::TouchScroll(S32 iY, bool bActive) S32 UIControl_HTMLLabel::GetRealWidth() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth, 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth, 0 , nullptr ); S32 iRealWidth = m_width; if(result.type == IGGY_DATATYPE_number) @@ -92,7 +92,7 @@ S32 UIControl_HTMLLabel::GetRealWidth() S32 UIControl_HTMLLabel::GetRealHeight() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealHeight, 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealHeight, 0 , nullptr ); S32 iRealHeight = m_height; if(result.type == IGGY_DATATYPE_number) diff --git a/Minecraft.Client/Common/UI/UIControl_LeaderboardList.cpp b/Minecraft.Client/Common/UI/UIControl_LeaderboardList.cpp index c34b5e875..3920e0040 100644 --- a/Minecraft.Client/Common/UI/UIControl_LeaderboardList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_LeaderboardList.cpp @@ -45,7 +45,7 @@ void UIControl_LeaderboardList::ReInit() void UIControl_LeaderboardList::clearList() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcResetLeaderboard , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcResetLeaderboard , 0 , nullptr ); } void UIControl_LeaderboardList::setupTitles(const wstring &rank, const wstring &gamertag) diff --git a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp index b03c858f5..b8c439b1a 100644 --- a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp +++ b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp @@ -55,7 +55,7 @@ UIControl_PlayerSkinPreview::UIControl_PlayerSkinPreview() m_fOriginalRotation = 0.0f; m_framesAnimatingRotation = 0; m_bAnimatingToFacing = false; - m_pvAdditionalModelParts=NULL; + m_pvAdditionalModelParts=nullptr; m_uiAnimOverrideBitmask=0L; } @@ -218,7 +218,7 @@ void UIControl_PlayerSkinPreview::render(IggyCustomDrawCallbackRegion *region) //EntityRenderDispatcher::instance->render(pMinecraft->localplayers[0], 0, 0, 0, 0, 1); EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_LOCALPLAYER); - if (renderer != NULL) + if (renderer != nullptr) { // 4J-PB - any additional parts to turn on for this player (skin dependent) //vector *pAdditionalModelParts=mob->GetAdditionalModelParts(); @@ -260,9 +260,9 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou HumanoidModel *model = static_cast(renderer->getModel()); //getAttackAnim(mob, a); - //if (armor != NULL) armor->attackTime = model->attackTime; + //if (armor != nullptr) armor->attackTime = model->attackTime; //model->riding = mob->isRiding(); - //if (armor != NULL) armor->riding = model->riding; + //if (armor != nullptr) armor->riding = model->riding; // 4J Stu - Remember to reset these values once the rendering is done if you add another one model->attackTime = 0; diff --git a/Minecraft.Client/Common/UI/UIControl_Slider.cpp b/Minecraft.Client/Common/UI/UIControl_Slider.cpp index 7f8a8180f..2d56a29c0 100644 --- a/Minecraft.Client/Common/UI/UIControl_Slider.cpp +++ b/Minecraft.Client/Common/UI/UIControl_Slider.cpp @@ -92,7 +92,7 @@ void UIControl_Slider::SetSliderTouchPos(float fTouchPos) S32 UIControl_Slider::GetRealWidth() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth , 0 , nullptr ); S32 iRealWidth = m_width; if(result.type == IGGY_DATATYPE_number) diff --git a/Minecraft.Client/Common/UI/UIControl_TexturePackList.cpp b/Minecraft.Client/Common/UI/UIControl_TexturePackList.cpp index 8e81ac28b..7f721493a 100644 --- a/Minecraft.Client/Common/UI/UIControl_TexturePackList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_TexturePackList.cpp @@ -83,7 +83,7 @@ void UIControl_TexturePackList::selectSlot(int id) void UIControl_TexturePackList::clearSlots() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_clearSlotsFunc ,0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_clearSlotsFunc ,0 , nullptr ); } void UIControl_TexturePackList::setEnabled(bool enable) @@ -133,7 +133,7 @@ bool UIControl_TexturePackList::CanTouchTrigger(S32 iX, S32 iY) S32 UIControl_TexturePackList::GetRealHeight() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealHeight, 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealHeight, 0 , nullptr ); S32 iRealHeight = m_height; if(result.type == IGGY_DATATYPE_number) diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 2972db99a..93b58d1a7 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -60,14 +60,14 @@ DWORD UIController::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; static UIControl_Slider *FindSliderById(UIScene *pScene, int sliderId) { vector *controls = pScene->GetControls(); - if (!controls) return NULL; + if (!controls) return nullptr; for (size_t i = 0; i < controls->size(); ++i) { UIControl *ctrl = (*controls)[i]; if (ctrl && ctrl->getControlType() == UIControl::eSlider && ctrl->getId() == sliderId) return static_cast(ctrl); } - return NULL; + return nullptr; } #endif @@ -180,15 +180,15 @@ static void RADLINK DeallocateFunction ( void * alloc_callback_user_data , void UIController::UIController() { - m_uiDebugConsole = NULL; - m_reloadSkinThread = NULL; + m_uiDebugConsole = nullptr; + m_reloadSkinThread = nullptr; m_navigateToHomeOnReload = false; m_bCleanupOnReload = false; - m_mcTTFFont = NULL; - m_moj7 = NULL; - m_moj11 = NULL; + m_mcTTFFont = nullptr; + m_moj7 = nullptr; + m_moj11 = nullptr; // 4J-JEV: It's important that these remain the same, unless updateCurrentLanguage is going to be called. m_eCurrentFont = m_eTargetFont = eFont_NotLoaded; @@ -313,7 +313,7 @@ void UIController::postInit() #ifdef ENABLE_IGGY_EXPLORER iggy_explorer = IggyExpCreate("127.0.0.1", 9190, malloc(IGGYEXP_MIN_STORAGE), IGGYEXP_MIN_STORAGE); - if ( iggy_explorer == NULL ) + if ( iggy_explorer == nullptr ) { // not normally an error, just an error for this demo! app.DebugPrintf( "Couldn't connect to Iggy Explorer, did you run it first?" ); @@ -326,7 +326,7 @@ void UIController::postInit() #ifdef ENABLE_IGGY_PERFMON m_iggyPerfmonEnabled = false; - iggy_perfmon = IggyPerfmonCreate(perf_malloc, perf_free, NULL); + iggy_perfmon = IggyPerfmonCreate(perf_malloc, perf_free, nullptr); IggyInstallPerfmon(iggy_perfmon); #endif @@ -367,7 +367,7 @@ UITTFFont *UIController::createFont(EFont fontLanguage) #endif // 4J-JEV, Cyrillic characters have been added to this font now, (4/July/14) // XC_LANGUAGE_RUSSIAN and XC_LANGUAGE_GREEK: - default: return NULL; + default: return nullptr; } } @@ -394,17 +394,17 @@ void UIController::SetupFont() if (m_eCurrentFont != eFont_NotLoaded) app.DebugPrintf("[UIController] Font switch required for language transition to %i.\n", nextLanguage); else app.DebugPrintf("[UIController] Initialising font for language %i.\n", nextLanguage); - if (m_mcTTFFont != NULL) + if (m_mcTTFFont != nullptr) { delete m_mcTTFFont; - m_mcTTFFont = NULL; + m_mcTTFFont = nullptr; } if(m_eTargetFont == eFont_Bitmap) { // these may have been set up by a previous language being chosen - if (m_moj7 == NULL) m_moj7 = new UIBitmapFont(SFontData::Mojangles_7); - if (m_moj11 == NULL) m_moj11 = new UIBitmapFont(SFontData::Mojangles_11); + if (m_moj7 == nullptr) m_moj7 = new UIBitmapFont(SFontData::Mojangles_7); + if (m_moj11 == nullptr) m_moj11 = new UIBitmapFont(SFontData::Mojangles_11); // 4J-JEV: Ensure we redirect to them correctly, even if the objects were previously initialised. m_moj7->registerFont(); @@ -612,7 +612,7 @@ IggyLibrary UIController::loadSkin(const wstring &skinPath, const wstring &skinN if(!skinPath.empty() && app.hasArchiveFile(skinPath)) { byteArray baFile = app.getArchiveFile(skinPath); - lib = IggyLibraryCreateFromMemoryUTF16( (IggyUTF16 *)skinName.c_str() , (void *)baFile.data, baFile.length, NULL ); + lib = IggyLibraryCreateFromMemoryUTF16( (IggyUTF16 *)skinName.c_str() , (void *)baFile.data, baFile.length, nullptr ); delete[] baFile.data; #ifdef _DEBUG @@ -620,7 +620,7 @@ IggyLibrary UIController::loadSkin(const wstring &skinPath, const wstring &skinN rrbool res; int iteration = 0; __int64 totalStatic = 0; - while(res = IggyDebugGetMemoryUseInfo ( NULL , + while(res = IggyDebugGetMemoryUseInfo ( nullptr , lib , "" , 0 , @@ -724,7 +724,7 @@ bool UIController::IsExpectingOrReloadingSkin() void UIController::CleanUpSkinReload() { delete m_reloadSkinThread; - m_reloadSkinThread = NULL; + m_reloadSkinThread = nullptr; if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { @@ -786,7 +786,7 @@ void UIController::tickInput() #ifdef _WINDOWS64 if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive()) { - UIScene *pScene = NULL; + UIScene *pScene = nullptr; for (int grp = 0; grp < eUIGroup_COUNT && !pScene; ++grp) { pScene = m_groups[grp]->GetTopScene(eUILayer_Debug); @@ -1006,7 +1006,7 @@ void UIController::handleInput() if(ProfileManager.GetLockedProfile() >= 0 && !InputManager.IsPadLocked( ProfileManager.GetLockedProfile() ) && firstUnfocussedUnhandledPad >= 0) { - ProfileManager.RequestSignInUI(false, false, false, false, true, NULL, NULL, firstUnfocussedUnhandledPad ); + ProfileManager.RequestSignInUI(false, false, false, false, true, nullptr, nullptr, firstUnfocussedUnhandledPad ); } } #endif @@ -1033,8 +1033,8 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) if((m_bTouchscreenPressed==false) && pTouchData->reportNum==1) { // no active touch? clear active and highlighted touch UI elements - m_ActiveUIElement = NULL; - m_HighlightedUIElement = NULL; + m_ActiveUIElement = nullptr; + m_HighlightedUIElement = nullptr; // fullscreen first UIScene *pScene=m_groups[(int)eUIGroup_Fullscreen]->getCurrentScene(); @@ -1316,7 +1316,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) IggyMemoryUseInfo memoryInfo; rrbool res; int iteration = 0; - while(res = IggyDebugGetMemoryUseInfo ( NULL , + while(res = IggyDebugGetMemoryUseInfo ( nullptr , m_iggyLibraries[i] , "" , 0 , @@ -1360,7 +1360,7 @@ rrbool RADLINK UIController::ExternalFunctionCallback( void * user_callback_data { UIScene *scene = static_cast(IggyPlayerGetUserdata(player)); - if(scene != NULL) + if(scene != nullptr) { scene->externalCallback(call); } @@ -1576,7 +1576,7 @@ void UIController::setupCustomDrawMatrices(UIScene *scene, CustomDrawData *custo if(!m_bScreenWidthSetup) { Minecraft *pMinecraft=Minecraft::GetInstance(); - if(pMinecraft != NULL) + if(pMinecraft != nullptr) { m_fScreenWidth=static_cast(pMinecraft->width_phys); m_fScreenHeight=static_cast(pMinecraft->height_phys); @@ -1625,7 +1625,7 @@ void RADLINK UIController::CustomDrawCallback(void *user_callback_data, Iggy *pl { UIScene *scene = static_cast(IggyPlayerGetUserdata(player)); - if(scene != NULL) + if(scene != nullptr) { scene->customDraw(region); } @@ -1637,7 +1637,7 @@ void RADLINK UIController::CustomDrawCallback(void *user_callback_data, Iggy *pl //width - Input value: optional number of pixels wide specified from AS3, or -1 if not defined. Output value: the number of pixels wide to pretend to Iggy that the bitmap is. SWF and AS3 scales bitmaps based on their pixel dimensions, so you can use this to substitute a texture that is higher or lower resolution that ActionScript thinks it is. //height - Input value: optional number of pixels high specified from AS3, or -1 if not defined. Output value: the number of pixels high to pretend to Iggy that the bitmap is. SWF and AS3 scales bitmaps based on their pixel dimensions, so you can use this to substitute a texture that is higher or lower resolution that ActionScript thinks it is. //destroy_callback_data - Optional additional output value you can set; the value will be passed along to the corresponding Iggy_TextureSubstitutionDestroyCallback (e.g. you can store the pointer to your own internal structure here). -//return - A platform-independent wrapped texture handle provided by GDraw, or NULL (NULL with throw an ActionScript 3 ArgumentError that the Flash developer can catch) Use by calling IggySetTextureSubstitutionCallbacks. +//return - A platform-independent wrapped texture handle provided by GDraw, or nullptr (nullptr with throw an ActionScript 3 ArgumentError that the Flash developer can catch) Use by calling IggySetTextureSubstitutionCallbacks. // //Discussion // @@ -1652,7 +1652,7 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void * app.DebugPrintf("Found substitution texture %ls, with %d bytes\n", texture_name,it->second.length); BufferedImage image(it->second.data, it->second.length); - if( image.getData() != NULL ) + if( image.getData() != nullptr ) { image.preMultiplyAlpha(); Textures *t = Minecraft::GetInstance()->textures; @@ -1675,13 +1675,13 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void * } else { - return NULL; + return nullptr; } } else { app.DebugPrintf("Could not find substitution texture %ls\n", static_cast(texture_name)); - return NULL; + return nullptr; } } @@ -1866,7 +1866,7 @@ void UIController::NavigateToHomeMenu() TexturePack *pTexPack=Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=NULL; + DLCTexturePack *pDLCTexPack=nullptr; if(pTexPack->hasAudio()) { // get the dlc texture pack, and store it @@ -1887,11 +1887,11 @@ void UIController::NavigateToHomeMenu() eStream_CD_1); pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1); - // if(pDLCTexPack->m_pStreamedWaveBank!=NULL) + // if(pDLCTexPack->m_pStreamedWaveBank!=nullptr) // { // pDLCTexPack->m_pStreamedWaveBank->Destroy(); // } - // if(pDLCTexPack->m_pSoundBank!=NULL) + // if(pDLCTexPack->m_pSoundBank!=nullptr) // { // pDLCTexPack->m_pSoundBank->Destroy(); // } @@ -1962,7 +1962,7 @@ void UIController::UnregisterCallbackId(size_t id) UIScene *UIController::GetSceneFromCallbackId(size_t id) { - UIScene *scene = NULL; + UIScene *scene = nullptr; auto it = m_registeredCallbackScenes.find(id); if(it != m_registeredCallbackScenes.end() ) { @@ -2439,7 +2439,7 @@ void UIController::HandleInventoryUpdated(int iPad) group = static_cast(iPad + 1); } - m_groups[group]->HandleMessage(eUIMessage_InventoryUpdated, NULL); + m_groups[group]->HandleMessage(eUIMessage_InventoryUpdated, nullptr); } void UIController::HandleGameTick() @@ -2540,7 +2540,7 @@ void UIController::UpdatePlayerBasePositions() for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(pMinecraft->localplayers[idx] != NULL) + if(pMinecraft->localplayers[idx] != nullptr) { if(pMinecraft->localplayers[idx]->m_iScreenSection==C4JRender::VIEWPORT_TYPE_FULLSCREEN) { @@ -2628,7 +2628,7 @@ void UIController::UpdateTrialTimer(unsigned int iPad) // bring up the pause menu to stop the trial over message box being called again? if(!ui.GetMenuDisplayed( iPad ) ) { - ui.NavigateToScene(iPad, eUIScene_PauseMenu, NULL, eUILayer_Scene); + ui.NavigateToScene(iPad, eUIScene_PauseMenu, nullptr, eUILayer_Scene); app.SetAction(iPad,eAppAction_TrialOver); } @@ -2703,7 +2703,7 @@ void UIController::ShowUIDebugConsole(bool show) else { m_groups[eUIGroup_Fullscreen]->removeComponent(eUIComponent_DebugUIConsole, eUILayer_Debug); - m_uiDebugConsole = NULL; + m_uiDebugConsole = nullptr; } #endif } @@ -2719,7 +2719,7 @@ void UIController::ShowUIDebugMarketingGuide(bool show) else { m_groups[eUIGroup_Fullscreen]->removeComponent(eUIComponent_DebugUIMarketingGuide, eUILayer_Debug); - m_uiDebugMarketingGuide = NULL; + m_uiDebugMarketingGuide = nullptr; } #endif } @@ -2806,7 +2806,7 @@ C4JStorage::EMessageResult UIController::RequestMessageBox(UINT uiTitle, UINT ui } } -C4JStorage::EMessageResult UIController::RequestUGCMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = NULL*/, LPVOID lpParam/* = NULL*/) +C4JStorage::EMessageResult UIController::RequestUGCMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = nullptr*/, LPVOID lpParam/* = nullptr*/) { // Default title / messages if (title == -1) @@ -2838,7 +2838,7 @@ C4JStorage::EMessageResult UIController::RequestUGCMessageBox(UINT title/* = -1 #endif } -C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = NULL*/, LPVOID lpParam/* = NULL*/) +C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = nullptr*/, LPVOID lpParam/* = nullptr*/) { // Default title / messages if (title == -1) @@ -2876,7 +2876,7 @@ C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT void UIController::setFontCachingCalculationBuffer(int length) { /* 4J-JEV: As described in an email from Sean. - If your `optional_temp_buffer` is NULL, Iggy will allocate the temp + If your `optional_temp_buffer` is nullptr, Iggy will allocate the temp buffer on the stack during Iggy draw calls. The size of the buffer it will allocate is 16 bytes times `max_chars` in 32-bit, and 24 bytes times `max_chars` in 64-bit. If the stack of the thread making the @@ -2889,10 +2889,10 @@ void UIController::setFontCachingCalculationBuffer(int length) static const int CHAR_SIZE = 16; #endif - if (m_tempBuffer != NULL) delete [] m_tempBuffer; + if (m_tempBuffer != nullptr) delete [] m_tempBuffer; if (length<0) { - if (m_defaultBuffer == NULL) m_defaultBuffer = new char[CHAR_SIZE*5000]; + if (m_defaultBuffer == nullptr) m_defaultBuffer = new char[CHAR_SIZE*5000]; IggySetFontCachingCalculationBuffer(5000, m_defaultBuffer, CHAR_SIZE*5000); } else @@ -2902,16 +2902,16 @@ void UIController::setFontCachingCalculationBuffer(int length) } } -// Returns the first scene of given type if it exists, NULL otherwise +// Returns the first scene of given type if it exists, nullptr otherwise UIScene *UIController::FindScene(EUIScene sceneType) { - UIScene *pScene = NULL; + UIScene *pScene = nullptr; for (int i = 0; i < eUIGroup_COUNT; i++) { pScene = m_groups[i]->FindScene(sceneType); #ifdef __PS3__ - if (pScene != NULL) return pScene; + if (pScene != nullptr) return pScene; #else if (pScene != nullptr) return pScene; #endif @@ -3077,7 +3077,7 @@ bool UIController::TouchBoxHit(UIScene *pUIScene,S32 x, S32 y) } //app.DebugPrintf("MISS at x = %i y = %i\n", (int)x, (int)y); - m_HighlightedUIElement = NULL; + m_HighlightedUIElement = nullptr; return false; } diff --git a/Minecraft.Client/Common/UI/UIController.h b/Minecraft.Client/Common/UI/UIController.h index f4b365b51..81947eef4 100644 --- a/Minecraft.Client/Common/UI/UIController.h +++ b/Minecraft.Client/Common/UI/UIController.h @@ -291,7 +291,7 @@ class UIController : public IUIController static GDrawTexture * RADLINK TextureSubstitutionCreateCallback( void * user_callback_data , IggyUTF16 * texture_name , S32 * width , S32 * height , void **destroy_callback_data ); static void RADLINK TextureSubstitutionDestroyCallback( void * user_callback_data , void * destroy_callback_data , GDrawTexture * handle ); - virtual GDrawTexture *getSubstitutionTexture(int textureId) { return NULL; } + virtual GDrawTexture *getSubstitutionTexture(int textureId) { return nullptr; } virtual void destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle) {} public: @@ -300,7 +300,7 @@ class UIController : public IUIController public: // NAVIGATION - bool NavigateToScene(int iPad, EUIScene scene, void *initData = NULL, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD); + bool NavigateToScene(int iPad, EUIScene scene, void *initData = nullptr, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD); bool NavigateBack(int iPad, bool forceUsePad = false, EUIScene eScene = eUIScene_COUNT, EUILayer eLayer = eUILayer_COUNT); void NavigateToHomeMenu(); UIScene *GetTopScene(int iPad, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD); @@ -380,14 +380,14 @@ class UIController : public IUIController virtual void HidePressStart(); void ClearPressStart(); - virtual C4JStorage::EMessageResult RequestAlertMessage(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, WCHAR *pwchFormatString=NULL); - virtual C4JStorage::EMessageResult RequestErrorMessage(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, WCHAR *pwchFormatString=NULL); + virtual C4JStorage::EMessageResult RequestAlertMessage(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=nullptr,LPVOID lpParam=nullptr, WCHAR *pwchFormatString=nullptr); + virtual C4JStorage::EMessageResult RequestErrorMessage(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=nullptr,LPVOID lpParam=nullptr, WCHAR *pwchFormatString=nullptr); private: virtual C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad,int( *Func)(LPVOID,int,const C4JStorage::EMessageResult),LPVOID lpParam, WCHAR *pwchFormatString,DWORD dwFocusButton, bool bIsError); public: - C4JStorage::EMessageResult RequestUGCMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = NULL, LPVOID lpParam = NULL); - C4JStorage::EMessageResult RequestContentRestrictedMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = NULL, LPVOID lpParam = NULL); + C4JStorage::EMessageResult RequestUGCMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = nullptr, LPVOID lpParam = nullptr); + C4JStorage::EMessageResult RequestContentRestrictedMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = nullptr, LPVOID lpParam = nullptr); virtual void SetWinUserIndex(unsigned int iPad); unsigned int GetWinUserIndex(); diff --git a/Minecraft.Client/Common/UI/UIFontData.cpp b/Minecraft.Client/Common/UI/UIFontData.cpp index c5ad46ef0..715d08ddc 100644 --- a/Minecraft.Client/Common/UI/UIFontData.cpp +++ b/Minecraft.Client/Common/UI/UIFontData.cpp @@ -145,9 +145,9 @@ CFontData::CFontData() { m_unicodeMap = unordered_map(); - m_sFontData = NULL; - m_kerningTable = NULL; - m_pbRawImage = NULL; + m_sFontData = nullptr; + m_kerningTable = nullptr; + m_pbRawImage = nullptr; } CFontData::CFontData(SFontData &sFontData, int *pbRawImage) diff --git a/Minecraft.Client/Common/UI/UIGroup.cpp b/Minecraft.Client/Common/UI/UIGroup.cpp index 769fd83d6..be9054c99 100644 --- a/Minecraft.Client/Common/UI/UIGroup.cpp +++ b/Minecraft.Client/Common/UI/UIGroup.cpp @@ -25,9 +25,9 @@ UIGroup::UIGroup(EUIGroup group, int iPad) m_tooltips = (UIComponent_Tooltips *)m_layers[static_cast(eUILayer_Tooltips)]->addComponent(0, eUIComponent_Tooltips); - m_tutorialPopup = NULL; - m_hud = NULL; - m_pressStartToPlay = NULL; + m_tutorialPopup = nullptr; + m_hud = nullptr; + m_pressStartToPlay = nullptr; if(m_group != eUIGroup_Fullscreen) { m_tutorialPopup = (UIComponent_TutorialPopup *)m_layers[static_cast(eUILayer_Popup)]->addComponent(m_iPad, eUIComponent_TutorialPopup); @@ -151,7 +151,7 @@ void UIGroup::closeAllScenes() Minecraft *pMinecraft = Minecraft::GetInstance(); if( m_iPad >= 0 ) { - if(pMinecraft != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); @@ -214,10 +214,10 @@ UIScene *UIGroup::getCurrentScene() { pScene=m_layers[i]->getCurrentScene(); - if(pScene!=NULL) return pScene; + if(pScene!=nullptr) return pScene; } - return NULL; + return nullptr; } #endif @@ -412,16 +412,16 @@ int UIGroup::getCommandBufferList() return m_commandBufferList; } -// Returns the first scene of given type if it exists, NULL otherwise +// Returns the first scene of given type if it exists, nullptr otherwise UIScene *UIGroup::FindScene(EUIScene sceneType) { - UIScene *pScene = NULL; + UIScene *pScene = nullptr; for (int i = 0; i < eUILayer_COUNT; i++) { pScene = m_layers[i]->FindScene(sceneType); #ifdef __PS3__ - if (pScene != NULL) return pScene; + if (pScene != nullptr) return pScene; #else if (pScene != nullptr) return pScene; #endif diff --git a/Minecraft.Client/Common/UI/UILayer.cpp b/Minecraft.Client/Common/UI/UILayer.cpp index b3cf72a0c..d4dc445b6 100644 --- a/Minecraft.Client/Common/UI/UILayer.cpp +++ b/Minecraft.Client/Common/UI/UILayer.cpp @@ -197,7 +197,7 @@ bool UILayer::GetMenuDisplayed() bool UILayer::NavigateToScene(int iPad, EUIScene scene, void *initData) { - UIScene *newScene = NULL; + UIScene *newScene = nullptr; switch(scene) { // Debug @@ -424,7 +424,7 @@ bool UILayer::NavigateToScene(int iPad, EUIScene scene, void *initData) break; }; - if(newScene == NULL) + if(newScene == nullptr) { app.DebugPrintf("WARNING: Scene %d was not created. Add it to UILayer::NavigateToScene\n", scene); return false; @@ -451,7 +451,7 @@ bool UILayer::NavigateBack(int iPad, EUIScene eScene) bool navigated = false; if(eScene < eUIScene_COUNT) { - UIScene *scene = NULL; + UIScene *scene = nullptr; do { scene = m_sceneStack.back(); @@ -523,9 +523,9 @@ UIScene *UILayer::addComponent(int iPad, EUIScene scene, void *initData) return itComp; } } - return NULL; + return nullptr; } - UIScene *newScene = NULL; + UIScene *newScene = nullptr; switch(scene) { @@ -573,7 +573,7 @@ UIScene *UILayer::addComponent(int iPad, EUIScene scene, void *initData) break; }; - if(newScene == NULL) return NULL; + if(newScene == nullptr) return nullptr; m_components.push_back(newScene); @@ -661,12 +661,12 @@ void UILayer::closeAllScenes() } } -// Get top scene on stack (or NULL if stack is empty) +// Get top scene on stack (or nullptr if stack is empty) UIScene *UILayer::GetTopScene() { if(m_sceneStack.size() == 0) { - return NULL; + return nullptr; } else { @@ -789,7 +789,7 @@ UIScene *UILayer::getCurrentScene() } } - return NULL; + return nullptr; } #endif @@ -894,7 +894,7 @@ void UILayer::PrintTotalMemoryUsage(__int64 &totalStatic, __int64 &totalDynamic) totalDynamic += layerDynamic; } -// Returns the first scene of given type if it exists, NULL otherwise +// Returns the first scene of given type if it exists, nullptr otherwise UIScene *UILayer::FindScene(EUIScene sceneType) { for (int i = 0; i < m_sceneStack.size(); i++) @@ -905,5 +905,5 @@ UIScene *UILayer::FindScene(EUIScene sceneType) } } - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UILayer.h b/Minecraft.Client/Common/UI/UILayer.h index 47c776ab7..074637ca4 100644 --- a/Minecraft.Client/Common/UI/UILayer.h +++ b/Minecraft.Client/Common/UI/UILayer.h @@ -61,7 +61,7 @@ class UILayer // E.g. you can keep a component active while performing navigation with other scenes on this layer void showComponent(int iPad, EUIScene scene, bool show); bool isComponentVisible(EUIScene scene); - UIScene *addComponent(int iPad, EUIScene scene, void *initData = NULL); + UIScene *addComponent(int iPad, EUIScene scene, void *initData = nullptr); void removeComponent(EUIScene scene); // INPUT diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp index e736d25cb..9029e9ffc 100644 --- a/Minecraft.Client/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Common/UI/UIScene.cpp @@ -11,8 +11,8 @@ UIScene::UIScene(int iPad, UILayer *parentLayer) { m_parentLayer = parentLayer; m_iPad = iPad; - swf = NULL; - m_pItemRenderer = NULL; + swf = nullptr; + m_pItemRenderer = nullptr; bHasFocus = false; m_hasTickedOnce = false; @@ -26,7 +26,7 @@ UIScene::UIScene(int iPad, UILayer *parentLayer) m_lastOpacity = 1.0f; m_bUpdateOpacity = false; - m_backScene = NULL; + m_backScene = nullptr; m_cacheSlotRenders = false; m_needsCacheRendered = true; @@ -49,14 +49,14 @@ UIScene::~UIScene() ui.UnregisterCallbackId(m_callbackUniqueId); } - if(m_pItemRenderer != NULL) delete m_pItemRenderer; + if(m_pItemRenderer != nullptr) delete m_pItemRenderer; } void UIScene::destroyMovie() { /* Destroy the Iggy player. */ IggyPlayerDestroy( swf ); - swf = NULL; + swf = nullptr; // Clear out the controls collection (doesn't delete the controls, and they get re-setup later) m_controls.clear(); @@ -115,7 +115,7 @@ bool UIScene::needsReloaded() bool UIScene::hasMovie() { - return swf != NULL; + return swf != nullptr; } F64 UIScene::getSafeZoneHalfHeight() @@ -330,7 +330,7 @@ void UIScene::loadMovie() byteArray baFile = ui.getMovieData(moviePath.c_str()); __int64 beforeLoad = ui.iggyAllocCount; - swf = IggyPlayerCreateFromMemory ( baFile.data , baFile.length, NULL); + swf = IggyPlayerCreateFromMemory ( baFile.data , baFile.length, nullptr); __int64 afterLoad = ui.iggyAllocCount; IggyPlayerInitializeAndTickRS ( swf ); __int64 afterTick = ui.iggyAllocCount; @@ -365,7 +365,7 @@ void UIScene::loadMovie() __int64 totalStatic = 0; __int64 totalDynamic = 0; while(res = IggyDebugGetMemoryUseInfo ( swf , - NULL , + nullptr , 0 , 0 , iteration , @@ -393,7 +393,7 @@ void UIScene::getDebugMemoryUseRecursive(const wstring &moviePath, IggyMemoryUse IggyMemoryUseInfo internalMemoryInfo; int internalIteration = 0; while(res = IggyDebugGetMemoryUseInfo ( swf , - NULL , + nullptr , memoryInfo.subcategory , memoryInfo.subcategory_stringlen , internalIteration , @@ -416,7 +416,7 @@ void UIScene::PrintTotalMemoryUsage(__int64 &totalStatic, __int64 &totalDynamic) __int64 sceneStatic = 0; __int64 sceneDynamic = 0; while(res = IggyDebugGetMemoryUseInfo ( swf , - NULL , + nullptr , "" , 0 , iteration , @@ -451,7 +451,7 @@ void UIScene::tick() UIControl* UIScene::GetMainPanel() { - return NULL; + return nullptr; } @@ -545,19 +545,19 @@ void UIScene::removeControl( UIControl_Base *control, bool centreScene) void UIScene::slideLeft() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSlideLeft , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSlideLeft , 0 , nullptr ); } void UIScene::slideRight() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSlideRight , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSlideRight , 0 , nullptr ); } void UIScene::doHorizontalResizeCheck() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcHorizontalResizeCheck , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcHorizontalResizeCheck , 0 , nullptr ); } void UIScene::render(S32 width, S32 height, C4JRender::eViewportType viewport) @@ -600,7 +600,7 @@ void UIScene::customDraw(IggyCustomDrawCallbackRegion *region) void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion *region, int iPad, shared_ptr item, float fAlpha, bool isFoil, bool bDecorations) { - if (item!= NULL) + if (item!= nullptr) { if(m_cacheSlotRenders) { @@ -739,7 +739,7 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt } PIXBeginNamedEvent(0,"Render and decorate"); - if(m_pItemRenderer == NULL) m_pItemRenderer = new ItemRenderer(); + if(m_pItemRenderer == nullptr) m_pItemRenderer = new ItemRenderer(); RenderManager.StateSetBlendEnable(true); RenderManager.StateSetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); RenderManager.StateSetBlendFactor(0xffffffff); @@ -776,9 +776,9 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt // 4J Stu - Not threadsafe //void UIScene::navigateForward(int iPad, EUIScene scene, void *initData) //{ -// if(m_parentLayer == NULL) +// if(m_parentLayer == nullptr) // { -// app.DebugPrintf("A scene is trying to navigate forwards, but it's parent layer is NULL!\n"); +// app.DebugPrintf("A scene is trying to navigate forwards, but it's parent layer is nullptr!\n"); //#ifndef _CONTENT_PACKAGE // __debugbreak(); //#endif @@ -796,9 +796,9 @@ void UIScene::navigateBack() ui.NavigateBack(m_iPad); - if(m_parentLayer == NULL) + if(m_parentLayer == nullptr) { -// app.DebugPrintf("A scene is trying to navigate back, but it's parent layer is NULL!\n"); +// app.DebugPrintf("A scene is trying to navigate back, but it's parent layer is nullptr!\n"); #ifndef _CONTENT_PACKAGE // __debugbreak(); #endif diff --git a/Minecraft.Client/Common/UI/UIScene.h b/Minecraft.Client/Common/UI/UIScene.h index b4008fa01..458e3e62c 100644 --- a/Minecraft.Client/Common/UI/UIScene.h +++ b/Minecraft.Client/Common/UI/UIScene.h @@ -245,7 +245,7 @@ class UIScene // NAVIGATION protected: - //void navigateForward(int iPad, EUIScene scene, void *initData = NULL); + //void navigateForward(int iPad, EUIScene scene, void *initData = nullptr); void navigateBack(); public: diff --git a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp index a354ba7ae..b8193bac0 100644 --- a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp @@ -49,15 +49,15 @@ void UIScene_AbstractContainerMenu::handleDestroy() #endif Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(pMinecraft->localplayers[m_iPad] != NULL && pMinecraft->localplayers[m_iPad]->containerMenu->containerId == m_menu->containerId) + if(pMinecraft->localplayers[m_iPad] != nullptr && pMinecraft->localplayers[m_iPad]->containerMenu->containerId == m_menu->containerId) { pMinecraft->localplayers[m_iPad]->closeContainer(); } @@ -149,8 +149,8 @@ void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex) m_fPointerMaxX = m_fPanelMaxX + fPointerWidth; m_fPointerMaxY = m_fPanelMaxY + (fPointerHeight/2); -// m_hPointerText=NULL; -// m_hPointerTextBkg=NULL; +// m_hPointerText=nullptr; +// m_hPointerTextBkg=nullptr; // Put the pointer over first item in use row to start with. UIVec2D itemPos; @@ -254,7 +254,7 @@ void UIScene_AbstractContainerMenu::render(S32 width, S32 height, C4JRender::eVi void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; shared_ptr item = nullptr; int slotId = -1; @@ -278,7 +278,7 @@ void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *reg } } - if(item != NULL) customDrawSlotControl(region,m_iPad,item,m_menu->isValidIngredient(item, slotId)?1.0f:0.5f,item->isFoil(),true); + if(item != nullptr) customDrawSlotControl(region,m_iPad,item,m_menu->isValidIngredient(item, slotId)?1.0f:0.5f,item->isFoil(),true); } void UIScene_AbstractContainerMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) @@ -337,7 +337,7 @@ Slot *UIScene_AbstractContainerMenu::getSlot(ESceneSection eSection, int iSlot) { Slot *slot = m_menu->getSlot( getSectionStartOffset(eSection) + iSlot ); if(slot) return slot; - else return NULL; + else return nullptr; } bool UIScene_AbstractContainerMenu::isSlotEmpty(ESceneSection eSection, int iSlot) diff --git a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.h b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.h index 605f5dbdf..c6ef29bbd 100644 --- a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.h @@ -53,7 +53,7 @@ class UIScene_AbstractContainerMenu : public UIScene, public virtual IUIScene_Ab virtual bool isSlotEmpty(ESceneSection eSection, int iSlot); virtual void adjustPointerForSafeZone(); - virtual UIControl *getSection(ESceneSection eSection) { return NULL; } + virtual UIControl *getSection(ESceneSection eSection) { return nullptr; } virtual int GetBaseSlotCount() { return 0; } public: diff --git a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp index 79117bb43..c9d879a36 100644 --- a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp @@ -20,7 +20,7 @@ UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void *_initData, UILayer *parentL m_inventory = initData->inventory; Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[iPad] != NULL ) + if( pMinecraft->localgameModes[iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -250,7 +250,7 @@ void UIScene_AnvilMenu::setSectionSelectedSlot(ESceneSection eSection, int x, in int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionAnvilItem1: @@ -278,7 +278,7 @@ void UIScene_AnvilMenu::setSectionSelectedSlot(ESceneSection eSection, int x, in UIControl *UIScene_AnvilMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionAnvilItem1: diff --git a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp index 64e0fdd8b..cf1ff7f33 100644 --- a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp @@ -24,7 +24,7 @@ UIScene_BeaconMenu::UIScene_BeaconMenu(int iPad, void *_initData, UILayer *paren BeaconScreenInput *initData = static_cast(_initData); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -254,7 +254,7 @@ void UIScene_BeaconMenu::setSectionSelectedSlot(ESceneSection eSection, int x, i int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionBeaconItem: @@ -276,7 +276,7 @@ void UIScene_BeaconMenu::setSectionSelectedSlot(ESceneSection eSection, int x, i UIControl *UIScene_BeaconMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionBeaconItem: @@ -324,7 +324,7 @@ UIControl *UIScene_BeaconMenu::getSection(ESceneSection eSection) void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; shared_ptr item = nullptr; int slotId = -1; @@ -351,7 +351,7 @@ void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion *region) assert(false); break; }; - if(item != NULL) customDrawSlotControl(region,m_iPad,item,1.0f,item->isFoil(),true); + if(item != nullptr) customDrawSlotControl(region,m_iPad,item,1.0f,item->isFoil(),true); } else { diff --git a/Minecraft.Client/Common/UI/UIScene_BrewingStandMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BrewingStandMenu.cpp index 4df5fa039..129868fd0 100644 --- a/Minecraft.Client/Common/UI/UIScene_BrewingStandMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_BrewingStandMenu.cpp @@ -20,7 +20,7 @@ UIScene_BrewingStandMenu::UIScene_BrewingStandMenu(int iPad, void *_initData, UI m_labelBrewingStand.init( m_brewingStand->getName() ); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -249,7 +249,7 @@ void UIScene_BrewingStandMenu::setSectionSelectedSlot(ESceneSection eSection, in int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionBrewingBottle1: @@ -280,7 +280,7 @@ void UIScene_BrewingStandMenu::setSectionSelectedSlot(ESceneSection eSection, in UIControl *UIScene_BrewingStandMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionBrewingBottle1: diff --git a/Minecraft.Client/Common/UI/UIScene_ConnectingProgress.cpp b/Minecraft.Client/Common/UI/UIScene_ConnectingProgress.cpp index a387fb294..e10a5a62a 100644 --- a/Minecraft.Client/Common/UI/UIScene_ConnectingProgress.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ConnectingProgress.cpp @@ -210,7 +210,7 @@ void UIScene_ConnectingProgress::handleInput(int iPad, int key, bool repeat, boo // 4J-PB - Removed the option to cancel join - it didn't work anyway // case ACTION_MENU_CANCEL: // { -// if(m_cancelFunc != NULL) +// if(m_cancelFunc != nullptr) // { // m_cancelFunc(m_cancelFuncParam); // } diff --git a/Minecraft.Client/Common/UI/UIScene_ContainerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_ContainerMenu.cpp index 7a3051eff..b26ae48e9 100644 --- a/Minecraft.Client/Common/UI/UIScene_ContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ContainerMenu.cpp @@ -24,7 +24,7 @@ UIScene_ContainerMenu::UIScene_ContainerMenu(int iPad, void *_initData, UILayer ContainerMenu* menu = new ContainerMenu( initData->inventory, initData->container ); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[iPad] != NULL ) + if( pMinecraft->localgameModes[iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -181,7 +181,7 @@ void UIScene_ContainerMenu::setSectionSelectedSlot(ESceneSection eSection, int x int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionContainerChest: @@ -203,7 +203,7 @@ void UIScene_ContainerMenu::setSectionSelectedSlot(ESceneSection eSection, int x UIControl *UIScene_ContainerMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionContainerChest: diff --git a/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp index 07db23904..939efde11 100644 --- a/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp @@ -25,7 +25,7 @@ UIScene_ControlsMenu::UIScene_ControlsMenu(int iPad, void *initData, UILayer *pa #endif IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetPlatform , 1 , value ); - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { diff --git a/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp index 676feb989..64441ff65 100644 --- a/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp @@ -109,7 +109,7 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p // Update the tutorial state Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -190,14 +190,14 @@ void UIScene_CraftingMenu::handleDestroy() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL && Minecraft::GetInstance()->localplayers[m_iPad]->containerMenu->containerId == m_menu->containerId) + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr && Minecraft::GetInstance()->localplayers[m_iPad]->containerMenu->containerId == m_menu->containerId) { Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); } @@ -436,7 +436,7 @@ void UIScene_CraftingMenu::handleReload() void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; shared_ptr item = nullptr; int slotId = -1; @@ -511,7 +511,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) } } - if(item != NULL) + if(item != nullptr) { if(!inventoryItem) { @@ -627,7 +627,7 @@ void UIScene_CraftingMenu::setCraftingOutputSlotItem(int iPad, shared_ptrgetId(); - m_pDLCPack = NULL; + m_pDLCPack = nullptr; m_bRebuildTouchBoxes = false; #ifdef _WINDOWS64 m_bDirectEditing = false; @@ -100,7 +100,7 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILay // #ifdef __PS3__ // if(ProfileManager.IsSignedInLive( m_iPad )) // { - // ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&bChatRestricted,&bContentRestricted,NULL); + // ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&bChatRestricted,&bContentRestricted,nullptr); // } // #endif @@ -188,7 +188,7 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILay #if TO_BE_IMPLEMENTED // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -565,7 +565,7 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() // texture pack hasn't been set yet, so check what it will be TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - if(pTexturePack==NULL) + if(pTexturePack==nullptr) { #if TO_BE_IMPLEMENTED // They've selected a texture pack they don't have yet @@ -643,7 +643,7 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_pDLCPack->getPurchaseOfferId()); ULONGLONG ullOfferID_Full; - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullOfferID_Full=pDLCInfo->ullOfferID_Full; } @@ -762,7 +762,7 @@ void UIScene_CreateWorldMenu::handleTimerComplete(int id) if(m_iConfigA[i]!=-1) { DWORD dwBytes=0; - PBYTE pbData=NULL; + PBYTE pbData=nullptr; //app.DebugPrintf("Retrieving iConfig %d from TPD\n",m_iConfigA[i]); app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); @@ -771,7 +771,7 @@ void UIScene_CreateWorldMenu::handleTimerComplete(int id) if(dwBytes > 0 && pbData) { DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + PBYTE pbImageData=nullptr; app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); ListInfo.fEnabled = TRUE; @@ -928,7 +928,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // MGH - added this so we don't try and upsell when we don't know if the player has PS Plus yet (if it can't connect to the PS Plus server). UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); + ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr); return; } @@ -948,7 +948,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // UINT uiIDA[2]; // uiIDA[0]=IDS_PLAY_OFFLINE; // uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; -// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),NULL,0,false); +// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),nullptr,0,false); return; } } @@ -988,7 +988,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() #if defined(__PS3__) || defined(__PSVITA__) if(isOnlineGame && isSignedInLive) { - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,nullptr,&bContentRestricted,nullptr); } #endif @@ -1017,7 +1017,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // MGH - added this so we don't try and upsell when we don't know if the player has PS Plus yet (if it can't connect to the PS Plus server). UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); + ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr); return; } @@ -1035,7 +1035,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // UINT uiIDA[2]; // uiIDA[0]=IDS_PLAY_OFFLINE; // uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; -// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),NULL,0,false); +// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),nullptr,0,false); } #endif @@ -1077,7 +1077,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // MGH - added this so we don't try and upsell when we don't know if the player has PS Plus yet (if it can't connect to the PS Plus server). UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); + ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr); return; } @@ -1099,7 +1099,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // UINT uiIDA[2]; // uiIDA[0]=IDS_PLAY_OFFLINE; // uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; -// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),NULL,0,false); +// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::PSPlusReturned,this, app.GetStringTable(),nullptr,0,false); } #endif @@ -1109,7 +1109,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() if(isOnlineGame) { bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,nullptr,nullptr); if(chatRestricted) { ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); @@ -1211,7 +1211,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack; Minecraft *pMinecraft = Minecraft::GetInstance(); @@ -1469,7 +1469,7 @@ int UIScene_CreateWorldMenu::ConfirmCreateReturned(void *pParam,int iPad,C4JStor if(isOnlineGame) { bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,nullptr,nullptr); if(chatRestricted) { ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); diff --git a/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp index 902b987c4..1ac0c91a0 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp @@ -42,7 +42,7 @@ UIScene_CreativeMenu::UIScene_CreativeMenu(int iPad, void *_initData, UILayer *p } Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -400,7 +400,7 @@ void UIScene_CreativeMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionInventoryCreativeSelector: @@ -419,7 +419,7 @@ void UIScene_CreativeMenu::setSectionSelectedSlot(ESceneSection eSection, int x, UIControl *UIScene_CreativeMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionInventoryCreativeSelector: diff --git a/Minecraft.Client/Common/UI/UIScene_Credits.cpp b/Minecraft.Client/Common/UI/UIScene_Credits.cpp index 187bf689a..9900169ce 100644 --- a/Minecraft.Client/Common/UI/UIScene_Credits.cpp +++ b/Minecraft.Client/Common/UI/UIScene_Credits.cpp @@ -593,7 +593,7 @@ void UIScene_Credits::tick() } // Set up the new text element. - if(pDef->m_Text!=NULL) // 4J-PB - think the RAD logo ones aren't set up yet and are coming is as null + if(pDef->m_Text!=nullptr) // 4J-PB - think the RAD logo ones aren't set up yet and are coming is as null { if ( pDef->m_iStringID[0] == CREDIT_ICON ) { diff --git a/Minecraft.Client/Common/UI/UIScene_DLCOffersMenu.cpp b/Minecraft.Client/Common/UI/UIScene_DLCOffersMenu.cpp index cd9f6d6ca..5e644803b 100644 --- a/Minecraft.Client/Common/UI/UIScene_DLCOffersMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DLCOffersMenu.cpp @@ -21,7 +21,7 @@ UIScene_DLCOffersMenu::UIScene_DLCOffersMenu(int iPad, void *initData, UILayer * m_iCurrentDLC=0; m_iTotalDLC=0; #if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) - m_pvProductInfo=NULL; + m_pvProductInfo=nullptr; #endif m_bAddAllDLCButtons=true; @@ -51,7 +51,7 @@ UIScene_DLCOffersMenu::UIScene_DLCOffersMenu(int iPad, void *initData, UILayer * } #ifdef _DURANGO - m_pNoImageFor_DLC = NULL; + m_pNoImageFor_DLC = nullptr; // If we don't yet have this DLC, we need to display a timer m_bDLCRequiredIsRetrieved=false; m_bIgnorePress=true; @@ -261,13 +261,13 @@ void UIScene_DLCOffersMenu::handlePress(F64 controlId, F64 childId) #endif // __PS3__ #elif defined _XBOX_ONE int iIndex = (int)childId; - StorageManager.InstallOffer(1,StorageManager.GetOffer(iIndex).wszProductID,NULL,NULL); + StorageManager.InstallOffer(1,StorageManager.GetOffer(iIndex).wszProductID,nullptr,nullptr); #else int iIndex = static_cast(childId); ULONGLONG ullIndexA[1]; ullIndexA[0]=StorageManager.GetOffer(iIndex).qwOfferID; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); #endif } break; @@ -343,10 +343,10 @@ void UIScene_DLCOffersMenu::tick() { m_bAddAllDLCButtons=false; // add the categories to the list box - if(m_pvProductInfo==NULL) + if(m_pvProductInfo==nullptr) { m_pvProductInfo=app.GetProductList(m_iProductInfoIndex); - if(m_pvProductInfo==NULL) + if(m_pvProductInfo==nullptr) { m_iTotalDLC=0; // need to display text to say no downloadable content available yet @@ -690,7 +690,7 @@ void UIScene_DLCOffersMenu::GetDLCInfo( int iOfferC, bool bUpdateOnly ) // Check that this is in the list of known DLC DLC_INFO *pDLC=app.GetDLCInfoForFullOfferID(xOffer.wszProductID); - if(pDLC!=NULL) + if(pDLC!=nullptr) { OrderA[uiDLCCount].uiContentIndex=i; OrderA[uiDLCCount++].uiSortIndex=pDLC->uiSortIndex; @@ -710,7 +710,7 @@ void UIScene_DLCOffersMenu::GetDLCInfo( int iOfferC, bool bUpdateOnly ) // Check that this is in the list of known DLC DLC_INFO *pDLC=app.GetDLCInfoForFullOfferID(xOffer.wszProductID); - if(pDLC==NULL) + if(pDLC==nullptr) { // skip this one app.DebugPrintf("Unknown offer - %ls\n",xOffer.wszOfferName); @@ -736,7 +736,7 @@ void UIScene_DLCOffersMenu::GetDLCInfo( int iOfferC, bool bUpdateOnly ) // find the DLC in the installed packages XCONTENT_DATA *pContentData=StorageManager.GetInstalledDLC(xOffer.wszProductID); - if(pContentData!=NULL) + if(pContentData!=nullptr) { m_buttonListOffers.addItem(wstrTemp,!pContentData->bTrialLicense,OrderA[i].uiContentIndex); } @@ -809,7 +809,7 @@ bool UIScene_DLCOffersMenu::UpdateDisplay(MARKETPLACE_CONTENTOFFER_INFO& xOffer) DLC_INFO *dlc = app.GetDLCInfoForFullOfferID(xOffer.wszOfferName); #endif - if (dlc != NULL) + if (dlc != nullptr) { WCHAR *cString = dlc->wchBanner; @@ -844,7 +844,7 @@ bool UIScene_DLCOffersMenu::UpdateDisplay(MARKETPLACE_CONTENTOFFER_INFO& xOffer) { if(hasRegisteredSubstitutionTexture(cString)==false) { - BYTE *pData=NULL; + BYTE *pData=nullptr; DWORD dwSize=0; app.GetMemFileDetails(cString,&pData,&dwSize); // set the image diff --git a/Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp b/Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp index 7d02367ab..a4dbe8a82 100644 --- a/Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp @@ -18,7 +18,7 @@ UIScene_DeathMenu::UIScene_DeathMenu(int iPad, void *initData, UILayer *parentLa m_bIgnoreInput = false; Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); @@ -30,7 +30,7 @@ UIScene_DeathMenu::UIScene_DeathMenu(int iPad, void *initData, UILayer *parentLa UIScene_DeathMenu::~UIScene_DeathMenu() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); @@ -104,7 +104,7 @@ void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) { UINT uiIDA[3]; int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } diff --git a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp index 86b515c35..eed4bbe1b 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp @@ -44,7 +44,7 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa std::vector> sortedItems; for (size_t i = 0; i < Item::items.length; ++i) { - if (Item::items[i] != NULL) + if (Item::items[i] != nullptr) { sortedItems.emplace_back(std::wstring(app.GetString(Item::items[i]->getDescriptionId())), i); } @@ -137,18 +137,18 @@ wstring UIScene_DebugOverlay::getMoviePath() void UIScene_DebugOverlay::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; int itemId = -1; swscanf(static_cast(region->name),L"item_%d",&itemId); - if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || Item::items[itemId] == NULL) + if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || Item::items[itemId] == nullptr) { app.DebugPrintf("This is not the control we are looking for\n"); } else { shared_ptr item = shared_ptr( new ItemInstance(itemId,1,0) ); - if(item != NULL) customDrawSlotControl(region,m_iPad,item,1.0f,false,false); + if(item != nullptr) customDrawSlotControl(region,m_iPad,item,1.0f,false,false); } } @@ -211,14 +211,14 @@ void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId) case eControl_Schematic: { #ifndef _CONTENT_PACKAGE - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic,NULL,eUILayer_Debug); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic,nullptr,eUILayer_Debug); #endif } break; case eControl_SetCamera: { #ifndef _CONTENT_PACKAGE - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugSetCamera,NULL,eUILayer_Debug); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugSetCamera,nullptr,eUILayer_Debug); #endif } break; diff --git a/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp b/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp index de200868e..2ebb6c71c 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp @@ -17,7 +17,7 @@ UIScene_DebugSetCamera::UIScene_DebugSetCamera(int iPad, void *initData, UILayer currentPosition->player = playerNo; Minecraft *pMinecraft = Minecraft::GetInstance(); - if (pMinecraft != NULL) + if (pMinecraft != nullptr) { Vec3 *vec = pMinecraft->localplayers[playerNo]->getPos(1.0); diff --git a/Minecraft.Client/Common/UI/UIScene_DispenserMenu.cpp b/Minecraft.Client/Common/UI/UIScene_DispenserMenu.cpp index f7fe65d69..2e47dda43 100644 --- a/Minecraft.Client/Common/UI/UIScene_DispenserMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DispenserMenu.cpp @@ -15,7 +15,7 @@ UIScene_DispenserMenu::UIScene_DispenserMenu(int iPad, void *_initData, UILayer m_labelDispenser.init(initData->trap->getName()); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -156,7 +156,7 @@ void UIScene_DispenserMenu::setSectionSelectedSlot(ESceneSection eSection, int x int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionTrapTrap: @@ -177,7 +177,7 @@ void UIScene_DispenserMenu::setSectionSelectedSlot(ESceneSection eSection, int x UIControl *UIScene_DispenserMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionTrapTrap: diff --git a/Minecraft.Client/Common/UI/UIScene_EnchantingMenu.cpp b/Minecraft.Client/Common/UI/UIScene_EnchantingMenu.cpp index ced0c45a2..f90c4b12b 100644 --- a/Minecraft.Client/Common/UI/UIScene_EnchantingMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_EnchantingMenu.cpp @@ -19,7 +19,7 @@ UIScene_EnchantingMenu::UIScene_EnchantingMenu(int iPad, void *_initData, UILaye m_labelEnchant.init( initData->name.empty() ? app.GetString(IDS_ENCHANT) : initData->name ); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -194,7 +194,7 @@ void UIScene_EnchantingMenu::setSectionSelectedSlot(ESceneSection eSection, int int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionEnchantSlot: @@ -216,7 +216,7 @@ void UIScene_EnchantingMenu::setSectionSelectedSlot(ESceneSection eSection, int UIControl *UIScene_EnchantingMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionEnchantSlot: @@ -247,7 +247,7 @@ UIControl *UIScene_EnchantingMenu::getSection(ESceneSection eSection) void UIScene_EnchantingMenu::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; if(wcscmp((wchar_t *)region->name,L"EnchantmentBook")==0) diff --git a/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp b/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp index f06343fe5..5b10e8cfe 100644 --- a/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp +++ b/Minecraft.Client/Common/UI/UIScene_EndPoem.cpp @@ -50,7 +50,7 @@ UIScene_EndPoem::UIScene_EndPoem(int iPad, void *initData, UILayer *parentLayer) Minecraft *pMinecraft = Minecraft::GetInstance(); wstring playerName = L""; - if(pMinecraft->localplayers[ui.GetWinUserIndex()] != NULL) + if(pMinecraft->localplayers[ui.GetWinUserIndex()] != nullptr) { playerName = escapeXML( pMinecraft->localplayers[ui.GetWinUserIndex()]->getDisplayName() ); } @@ -159,14 +159,14 @@ void UIScene_EndPoem::handleInput(int iPad, int key, bool repeat, bool pressed, Minecraft *pMinecraft = Minecraft::GetInstance(); for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if(pMinecraft->localplayers[i] != NULL) + if(pMinecraft->localplayers[i] != nullptr) { app.SetAction(i,eAppAction_Respawn); } } // This just allows it to be shown - if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true); + if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true); updateTooltips(); navigateBack(); diff --git a/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp b/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp index 533c280f0..b33e086a7 100644 --- a/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FireworksMenu.cpp @@ -16,7 +16,7 @@ UIScene_FireworksMenu::UIScene_FireworksMenu(int iPad, void *_initData, UILayer m_labelFireworks.init(app.GetString(IDS_HOW_TO_PLAY_MENU_FIREWORKS)); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -174,7 +174,7 @@ void UIScene_FireworksMenu::setSectionSelectedSlot(ESceneSection eSection, int x int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionFireworksIngredients: @@ -198,7 +198,7 @@ void UIScene_FireworksMenu::setSectionSelectedSlot(ESceneSection eSection, int x UIControl *UIScene_FireworksMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionFireworksIngredients: diff --git a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp index 66a2c5ee8..0dfde06d6 100644 --- a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp @@ -102,7 +102,7 @@ void UIScene_FullscreenProgress::handleDestroy() DWORD exitcode = *((DWORD *)&code); // If we're active, have a cancel func, and haven't already cancelled, call cancel func - if( exitcode == STILL_ACTIVE && m_cancelFunc != NULL && !m_bWasCancelled) + if( exitcode == STILL_ACTIVE && m_cancelFunc != nullptr && !m_bWasCancelled) { m_bWasCancelled = true; m_cancelFunc(m_cancelFuncParam); @@ -224,7 +224,7 @@ void UIScene_FullscreenProgress::tick() // This just allows it to be shown Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true); + if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true); ui.UpdatePlayerBasePositions(); navigateBack(); } @@ -286,7 +286,7 @@ void UIScene_FullscreenProgress::handleInput(int iPad, int key, bool repeat, boo break; case ACTION_MENU_B: case ACTION_MENU_CANCEL: - if( pressed && m_cancelFunc != NULL && !m_bWasCancelled ) + if( pressed && m_cancelFunc != nullptr && !m_bWasCancelled ) { m_bWasCancelled = true; m_cancelFunc( m_cancelFuncParam ); diff --git a/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp b/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp index 3be86b109..9dcbe45b4 100644 --- a/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FurnaceMenu.cpp @@ -21,7 +21,7 @@ UIScene_FurnaceMenu::UIScene_FurnaceMenu(int iPad, void *_initData, UILayer *par m_progressFurnaceArrow.init(L"",0,0,24,0); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -202,7 +202,7 @@ void UIScene_FurnaceMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionFurnaceResult: @@ -230,7 +230,7 @@ void UIScene_FurnaceMenu::setSectionSelectedSlot(ESceneSection eSection, int x, UIControl *UIScene_FurnaceMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionFurnaceResult: diff --git a/Minecraft.Client/Common/UI/UIScene_HUD.cpp b/Minecraft.Client/Common/UI/UIScene_HUD.cpp index 0e80c1f99..a6f0f81b8 100644 --- a/Minecraft.Client/Common/UI/UIScene_HUD.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HUD.cpp @@ -114,7 +114,7 @@ void UIScene_HUD::tick() if(getMovie() && app.GetGameStarted()) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) { return; } @@ -155,7 +155,7 @@ void UIScene_HUD::tick() void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; int slot = -1; swscanf(static_cast(region->name),L"slot_%d",&slot); @@ -167,7 +167,7 @@ void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion *region) { Slot *invSlot = pMinecraft->localplayers[m_iPad]->inventoryMenu->getSlot(InventoryMenu::USE_ROW_SLOT_START + slot); shared_ptr item = invSlot->getItem(); - if(item != NULL) + if(item != nullptr) { unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity); float fVal; @@ -254,7 +254,7 @@ void UIScene_HUD::handleReload() int iGuiScale; Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localplayers[m_iPad]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN) + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localplayers[m_iPad]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN) { iGuiScale=app.GetGameSettings(m_iPad,eGameSetting_UISize); } @@ -595,7 +595,7 @@ void UIScene_HUD::SetSelectedLabel(const wstring &label) void UIScene_HUD::HideSelectedLabel() { IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcHideSelectedLabel , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcHideSelectedLabel , 0 , nullptr ); } @@ -744,7 +744,7 @@ void UIScene_HUD::handleTimerComplete(int id) Minecraft *pMinecraft = Minecraft::GetInstance(); bool anyVisible = false; - if(pMinecraft->localplayers[m_iPad]!= NULL) + if(pMinecraft->localplayers[m_iPad]!= nullptr) { Gui *pGui = pMinecraft->gui; //DWORD messagesToDisplay = min( CHAT_LINES_COUNT, pGui->getMessagesCount(m_iPad) ); @@ -859,7 +859,7 @@ void UIScene_HUD::handleGameTick() if(getMovie() && app.GetGameStarted()) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) { m_parentLayer->showComponent(m_iPad, eUIScene_HUD,false); return; diff --git a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp index 089848113..e9231fed8 100644 --- a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp @@ -8,7 +8,7 @@ UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void *initData, // Setup all the Iggy references we need for this scene initialiseMovie(); - m_bNotInGame=(Minecraft::GetInstance()->level==NULL); + m_bNotInGame=(Minecraft::GetInstance()->level==nullptr); m_buttons[BUTTON_HAO_CHANGESKIN].init(IDS_CHANGE_SKIN,BUTTON_HAO_CHANGESKIN); m_buttons[BUTTON_HAO_HOWTOPLAY].init(IDS_HOW_TO_PLAY,BUTTON_HAO_HOWTOPLAY); @@ -41,7 +41,7 @@ UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void *initData, // 4J-PB - do not need a storage device to see this menu - just need one when you choose to re-install them - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); // any content to be re-installed? if(m_iPad==ProfileManager.GetPrimaryPad() && bNotInGame) @@ -103,7 +103,7 @@ void UIScene_HelpAndOptionsMenu::updateTooltips() void UIScene_HelpAndOptionsMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); @@ -128,7 +128,7 @@ void UIScene_HelpAndOptionsMenu::handleReload() #endif // 4J-PB - do not need a storage device to see this menu - just need one when you choose to re-install them - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); // any content to be re-installed? if(m_iPad==ProfileManager.GetPrimaryPad() && bNotInGame) diff --git a/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp index d651ecdb8..8c657c973 100644 --- a/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HopperMenu.cpp @@ -15,7 +15,7 @@ UIScene_HopperMenu::UIScene_HopperMenu(int iPad, void *_initData, UILayer *paren m_labelDispenser.init(initData->hopper->getName()); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -156,7 +156,7 @@ void UIScene_HopperMenu::setSectionSelectedSlot(ESceneSection eSection, int x, i int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionHopperContents: @@ -177,7 +177,7 @@ void UIScene_HopperMenu::setSectionSelectedSlot(ESceneSection eSection, int x, i UIControl *UIScene_HopperMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionHopperContents: diff --git a/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp index 290085f70..c062df4ed 100644 --- a/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HorseInventoryMenu.cpp @@ -18,7 +18,7 @@ UIScene_HorseInventoryMenu::UIScene_HorseInventoryMenu(int iPad, void *_initData m_horse = initData->horse; Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[iPad] != NULL ) + if( pMinecraft->localgameModes[iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -240,7 +240,7 @@ void UIScene_HorseInventoryMenu::setSectionSelectedSlot(ESceneSection eSection, int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionHorseArmor: @@ -268,7 +268,7 @@ void UIScene_HorseInventoryMenu::setSectionSelectedSlot(ESceneSection eSection, UIControl *UIScene_HorseInventoryMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionHorseArmor: @@ -296,7 +296,7 @@ UIControl *UIScene_HorseInventoryMenu::getSection(ESceneSection eSection) void UIScene_HorseInventoryMenu::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; if(wcscmp((wchar_t *)region->name,L"horse")==0) { diff --git a/Minecraft.Client/Common/UI/UIScene_HowToPlayMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HowToPlayMenu.cpp index 80492d914..728bd4c07 100644 --- a/Minecraft.Client/Common/UI/UIScene_HowToPlayMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HowToPlayMenu.cpp @@ -122,7 +122,7 @@ void UIScene_HowToPlayMenu::updateTooltips() void UIScene_HowToPlayMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); diff --git a/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp index 74291b1a7..dc11b524d 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp @@ -23,7 +23,7 @@ UIScene_InGameInfoMenu::UIScene_InGameInfoMenu(int iPad, void *initData, UILayer { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); - if( player != NULL ) + if( player != nullptr ) { PlayerInfo *info = BuildPlayerInfo(player); @@ -36,7 +36,7 @@ UIScene_InGameInfoMenu::UIScene_InGameInfoMenu(int iPad, void *initData, UILayer INetworkPlayer *thisPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); m_isHostPlayer = false; - if(thisPlayer != NULL) m_isHostPlayer = thisPlayer->IsHost() == TRUE; + if(thisPlayer != nullptr) m_isHostPlayer = thisPlayer->IsHost() == TRUE; Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr localPlayer = pMinecraft->localplayers[m_iPad]; @@ -109,7 +109,7 @@ void UIScene_InGameInfoMenu::updateTooltips() { keyA = IDS_TOOLTIPS_SELECT; } - else if( selectedPlayer != NULL) + else if( selectedPlayer != nullptr) { bool editingHost = selectedPlayer->IsHost(); if( (cheats && (m_isHostPlayer || !editingHost ) ) || (!trust && (m_isHostPlayer || !editingHost)) @@ -134,7 +134,7 @@ void UIScene_InGameInfoMenu::updateTooltips() if(!m_buttonGameOptions.hasFocus()) { // if the player is me, then view gamer profile - if(selectedPlayer != NULL && selectedPlayer->IsLocal() && selectedPlayer->GetUserIndex()==m_iPad) + if(selectedPlayer != nullptr && selectedPlayer->IsLocal() && selectedPlayer->GetUserIndex()==m_iPad) { ikeyY = IDS_TOOLTIPS_VIEW_GAMERPROFILE; } @@ -172,7 +172,7 @@ void UIScene_InGameInfoMenu::handleReload() { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); - if( player != NULL ) + if( player != nullptr ) { PlayerInfo *info = BuildPlayerInfo(player); @@ -183,7 +183,7 @@ void UIScene_InGameInfoMenu::handleReload() INetworkPlayer *thisPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); m_isHostPlayer = false; - if(thisPlayer != NULL) m_isHostPlayer = thisPlayer->IsHost() == TRUE; + if(thisPlayer != nullptr) m_isHostPlayer = thisPlayer->IsHost() == TRUE; Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr localPlayer = pMinecraft->localplayers[m_iPad]; @@ -209,7 +209,7 @@ void UIScene_InGameInfoMenu::tick() { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); - if(player != NULL) + if(player != nullptr) { PlayerInfo *info = BuildPlayerInfo(player); @@ -283,7 +283,7 @@ void UIScene_InGameInfoMenu::handleInput(int iPad, int key, bool repeat, bool pr if(pressed && m_playerList.hasFocus() && (m_playerList.getItemCount() > 0) && (m_playerList.getCurrentSelection() < m_players.size()) ) { INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId(m_players[m_playerList.getCurrentSelection()]->m_smallId); - if( player != NULL ) + if( player != nullptr ) { PlayerUID uid = player->GetUID(); if( uid != INVALID_XUID ) @@ -344,7 +344,7 @@ void UIScene_InGameInfoMenu::handlePress(F64 controlId, F64 childId) bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; bool trust = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; - if( isOp && selectedPlayer != NULL) + if( isOp && selectedPlayer != nullptr) { bool editingHost = selectedPlayer->IsHost(); if( (cheats && (m_isHostPlayer || !editingHost ) ) || (!trust && (m_isHostPlayer || !editingHost)) @@ -473,7 +473,7 @@ UIScene_InGameInfoMenu::PlayerInfo *UIScene_InGameInfoMenu::BuildPlayerInfo(INet } int voiceStatus = 0; - if(player != NULL && player->HasVoice() ) + if(player != nullptr && player->HasVoice() ) { if( player->IsMutedByLocalUser(m_iPad) ) { diff --git a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp index 8872b0f3a..fb570fdc4 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp @@ -24,14 +24,14 @@ UIScene_InGamePlayerOptionsMenu::UIScene_InGamePlayerOptionsMenu(int iPad, void INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); - if(editingPlayer != NULL) + if(editingPlayer != nullptr) { m_labelGamertag.init(editingPlayer->GetDisplayName()); } bool trustPlayers = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; - m_editingSelf = (localPlayer != NULL && localPlayer == editingPlayer); + m_editingSelf = (localPlayer != nullptr && localPlayer == editingPlayer); if( m_editingSelf || trustPlayers || editingPlayer->IsHost()) { @@ -241,7 +241,7 @@ void UIScene_InGamePlayerOptionsMenu::handleReload() bool trustPlayers = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; - m_editingSelf = (localPlayer != NULL && localPlayer == editingPlayer); + m_editingSelf = (localPlayer != nullptr && localPlayer == editingPlayer); if( m_editingSelf || trustPlayers || editingPlayer->IsHost()) { @@ -372,7 +372,7 @@ void UIScene_InGamePlayerOptionsMenu::handleInput(int iPad, int key, bool repeat else { INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); - if(!trustPlayers && (editingPlayer != NULL && !editingPlayer->IsHost() ) ) + if(!trustPlayers && (editingPlayer != nullptr && !editingPlayer->IsHost() ) ) { Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CannotMine,!m_checkboxes[eControl_BuildAndMine].IsChecked()); Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CannotBuild,!m_checkboxes[eControl_BuildAndMine].IsChecked()); @@ -473,9 +473,9 @@ void UIScene_InGamePlayerOptionsMenu::OnPlayerChanged(void *callbackParam, INetw UIScene_InGamePlayerOptionsMenu *scene = static_cast(callbackParam); UIScene_InGameInfoMenu *infoScene = static_cast(scene->getBackScene()); - if(infoScene != NULL) UIScene_InGameInfoMenu::OnPlayerChanged(infoScene,pPlayer,leaving); + if(infoScene != nullptr) UIScene_InGameInfoMenu::OnPlayerChanged(infoScene,pPlayer,leaving); - if(leaving && pPlayer != NULL && pPlayer->GetSmallId() == scene->m_networkSmallId) + if(leaving && pPlayer != nullptr && pPlayer->GetSmallId() == scene->m_networkSmallId) { scene->m_bShouldNavBack = true; } diff --git a/Minecraft.Client/Common/UI/UIScene_InGameSaveManagementMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameSaveManagementMenu.cpp index 561899897..fb118b154 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameSaveManagementMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameSaveManagementMenu.cpp @@ -20,9 +20,9 @@ int UIScene_InGameSaveManagementMenu::LoadSaveDataThumbnailReturned(LPVOID lpPar } else { - pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData = NULL; + pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData = nullptr; pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].dwThumbnailSize = 0; - app.DebugPrintf("Save thumbnail data is NULL, or has size 0\n"); + app.DebugPrintf("Save thumbnail data is nullptr, or has size 0\n"); } pClass->m_bSaveThumbnailReady = true; @@ -55,9 +55,9 @@ UIScene_InGameSaveManagementMenu::UIScene_InGameSaveManagementMenu(int iPad, voi m_bRetrievingSaveThumbnails = false; m_bSaveThumbnailReady = false; m_bExitScene=false; - m_pSaveDetails=NULL; + m_pSaveDetails=nullptr; m_bSavesDisplayed=false; - m_saveDetails = NULL; + m_saveDetails = nullptr; m_iSaveDetailsCount = 0; #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) || defined(_DURANGO) @@ -198,17 +198,17 @@ void UIScene_InGameSaveManagementMenu::tick() if(!m_bSavesDisplayed) { m_pSaveDetails=StorageManager.ReturnSavesInfo(); - if(m_pSaveDetails!=NULL) + if(m_pSaveDetails!=nullptr) { m_spaceIndicatorSaves.reset(); m_bSavesDisplayed=true; - if(m_saveDetails!=NULL) + if(m_saveDetails!=nullptr) { for(unsigned int i = 0; i < m_pSaveDetails->iSaveC; ++i) { - if(m_saveDetails[i].pbThumbnailData!=NULL) + if(m_saveDetails[i].pbThumbnailData!=nullptr) { delete m_saveDetails[i].pbThumbnailData; } @@ -371,9 +371,9 @@ void UIScene_InGameSaveManagementMenu::GetSaveInfo( ) m_controlSavesTimer.setVisible(true); m_pSaveDetails=StorageManager.ReturnSavesInfo(); - if(m_pSaveDetails==NULL) + if(m_pSaveDetails==nullptr) { - C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save"); + C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,nullptr,this,"save"); } diff --git a/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp index f2bdbd177..4e217c772 100644 --- a/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp @@ -26,7 +26,7 @@ UIScene_InventoryMenu::UIScene_InventoryMenu(int iPad, void *_initData, UILayer InventoryScreenInput *initData = static_cast(_initData); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[initData->iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -182,7 +182,7 @@ void UIScene_InventoryMenu::setSectionSelectedSlot(ESceneSection eSection, int x int index = (y * cols) + x; - UIControl_SlotList *slotList = NULL; + UIControl_SlotList *slotList = nullptr; switch( eSection ) { case eSectionInventoryArmor: @@ -201,7 +201,7 @@ void UIScene_InventoryMenu::setSectionSelectedSlot(ESceneSection eSection, int x UIControl *UIScene_InventoryMenu::getSection(ESceneSection eSection) { - UIControl *control = NULL; + UIControl *control = nullptr; switch( eSection ) { case eSectionInventoryArmor: @@ -220,7 +220,7 @@ UIControl *UIScene_InventoryMenu::getSection(ESceneSection eSection) void UIScene_InventoryMenu::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; if(wcscmp((wchar_t *)region->name,L"player")==0) { @@ -253,7 +253,7 @@ void UIScene_InventoryMenu::updateEffectsDisplay() Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player == NULL) return; + if(player == nullptr) return; vector *activeEffects = player->getActiveEffects(); diff --git a/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp index c25a10855..8ef80b279 100644 --- a/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp @@ -62,7 +62,7 @@ void UIScene_JoinMenu::tick() #if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ for( int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++ ) { - if( m_selectedSession->data.players[i] != NULL ) + if( m_selectedSession->data.players[i] != nullptr ) { #ifndef _CONTENT_PACKAGE if(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask()&(1L< 0) + if(m_selectedSession != nullptr && getControlFocus() == eControl_GamePlayers && m_buttonListPlayers.getItemCount() > 0) { PlayerUID uid = m_selectedSession->searchResult.m_playerXuids[m_buttonListPlayers.getCurrentSelection()]; if( uid != INVALID_XUID ) ProfileManager.ShowProfileCard(ProfileManager.GetLockedProfile(),uid); @@ -473,7 +473,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) #if defined(__PS3__) || defined(__PSVITA__) if(isSignedInLive) { - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&noUGC,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&noUGC,nullptr,nullptr); } #else ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); @@ -511,7 +511,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { #if defined(__ORBIS__) || defined(__PSVITA__) bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,nullptr,nullptr); if(chatRestricted) { ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); @@ -566,7 +566,7 @@ void UIScene_JoinMenu::handleTimerComplete(int id) int selectedIndex = 0; for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { - if( m_selectedSession->data.players[i] != NULL ) + if( m_selectedSession->data.players[i] != nullptr ) { if(m_selectedSession->data.players[i] == selectedPlayerXUID) selectedIndex = i; playersList.InsertItems(i,1); @@ -583,7 +583,7 @@ void UIScene_JoinMenu::handleTimerComplete(int id) } else { - // Leave the loop when we hit the first NULL player + // Leave the loop when we hit the first nullptr player break; } } diff --git a/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp b/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp index 15de62bfc..5b98f2136 100644 --- a/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp +++ b/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp @@ -17,8 +17,8 @@ UIScene_Keyboard::UIScene_Keyboard(int iPad, void *initData, UILayer *parentLaye initialiseMovie(); #ifdef _WINDOWS64 - m_win64Callback = NULL; - m_win64CallbackParam = NULL; + m_win64Callback = nullptr; + m_win64CallbackParam = nullptr; m_win64TextBuffer = L""; m_win64MaxChars = 25; @@ -109,7 +109,7 @@ UIScene_Keyboard::UIScene_Keyboard(int iPad, void *initData, UILayer *parentLaye { IggyValuePath keyPath; if (IggyValuePathMakeNameRef(&keyPath, root, s_keyNames[i])) - IggyValueSetBooleanRS(&keyPath, nameVisible, NULL, false); + IggyValueSetBooleanRS(&keyPath, nameVisible, nullptr, false); } } #endif @@ -223,33 +223,33 @@ void UIScene_Keyboard::handleInput(int iPad, int key, bool repeat, bool pressed, handled = true; break; case ACTION_MENU_X: // X - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcBackspaceButtonPressed, 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcBackspaceButtonPressed, 0 , nullptr ); handled = true; break; case ACTION_MENU_PAGEUP: // LT - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSymbolButtonPressed, 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSymbolButtonPressed, 0 , nullptr ); handled = true; break; case ACTION_MENU_Y: // Y - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSpaceButtonPressed, 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSpaceButtonPressed, 0 , nullptr ); handled = true; break; case ACTION_MENU_STICK_PRESS: // LS - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcCapsButtonPressed, 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcCapsButtonPressed, 0 , nullptr ); handled = true; break; case ACTION_MENU_LEFT_SCROLL: // LB - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcCursorLeftButtonPressed, 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcCursorLeftButtonPressed, 0 , nullptr ); handled = true; break; case ACTION_MENU_RIGHT_SCROLL: // RB - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcCursorRightButtonPressed, 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcCursorRightButtonPressed, 0 , nullptr ); handled = true; break; case ACTION_MENU_PAUSEMENU: // Start if(!m_bKeyboardDonePressed) { - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcDoneButtonPressed, 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcDoneButtonPressed, 0 , nullptr ); // kick off done timer addTimer(KEYBOARD_DONE_TIMER_ID,KEYBOARD_DONE_TIMER_TIME); diff --git a/Minecraft.Client/Common/UI/UIScene_LanguageSelector.cpp b/Minecraft.Client/Common/UI/UIScene_LanguageSelector.cpp index 4950f3229..d899858a8 100644 --- a/Minecraft.Client/Common/UI/UIScene_LanguageSelector.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LanguageSelector.cpp @@ -58,7 +58,7 @@ void UIScene_LanguageSelector::updateTooltips() void UIScene_LanguageSelector::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); diff --git a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index c48cab3ac..184a6cd0a 100644 --- a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -305,7 +305,7 @@ void UIScene_LaunchMoreOptionsMenu::handleInput(int iPad, int key, bool repeat, m_tabIndex = m_tabIndex == 0 ? 1 : 0; updateTooltips(); IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcChangeTab , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcChangeTab , 0 , nullptr ); } break; } @@ -327,7 +327,7 @@ void UIScene_LaunchMoreOptionsMenu::handleTouchInput(unsigned int iPad, S32 x, S m_tabIndex = iNewTabIndex; updateTooltips(); IggyDataValue result; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcChangeTab , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcChangeTab , 0 , nullptr ); } ui.TouchBoxRebuild(this); break; diff --git a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp index 59268cb86..a5b8947b3 100644 --- a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp @@ -11,9 +11,9 @@ // if the value is greater than 32000, it's an xzp icon that needs displayed, rather than the game icon 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 }, + { UIControl_LeaderboardList::e_ICON_TYPE_WALKED, UIControl_LeaderboardList::e_ICON_TYPE_FALLEN, Item::minecart_Id, Item::boat_Id, nullptr }, { 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::egg_Id, Item::wheat_Id, Tile::mushroom_brown_Id, Tile::reeds_Id, Item::bucket_milk_Id, Tile::pumpkin_Id, nullptr }, { UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDERJOKEY, UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIEPIGMAN, UIControl_LeaderboardList::e_ICON_TYPE_SLIME }, }; const UIScene_LeaderboardsMenu::LeaderboardDescriptor UIScene_LeaderboardsMenu::LEADERBOARD_DESCRIPTORS[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][4] = { @@ -576,7 +576,7 @@ bool UIScene_LeaderboardsMenu::RetrieveStats() return true; } - //assert( LeaderboardManager::Instance()->GetStats() != NULL ); + //assert( LeaderboardManager::Instance()->GetStats() != nullptr ); //PXUSER_STATS_READ_RESULTS stats = LeaderboardManager::Instance()->GetStats(); //if( m_currentFilter == LeaderboardManager::eFM_Friends ) LeaderboardManager::Instance()->SortFriendStats(); diff --git a/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp index 51a3bb610..d61a79022 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp @@ -50,7 +50,7 @@ int UIScene_LoadMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumb } else { - app.DebugPrintf("Thumbnail data is NULL, or has size 0\n"); + app.DebugPrintf("Thumbnail data is nullptr, or has size 0\n"); pClass->m_bThumbnailGetFailed = true; } pClass->m_bRetrievingSaveThumbnail = false; @@ -102,7 +102,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye m_bSaveThumbnailReady = false; m_bRetrievingSaveThumbnail = true; m_bShowTimer = false; - m_pDLCPack = NULL; + m_pDLCPack = nullptr; m_bAvailableTexturePacksChecked=false; m_bRequestQuadrantSignin = false; m_iTexturePacksNotInstalled=0; @@ -249,7 +249,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye #endif #endif #ifdef _WINDOWS64 - if (params->saveDetails != NULL && params->saveDetails->UTF8SaveName[0] != '\0') + if (params->saveDetails != nullptr && params->saveDetails->UTF8SaveName[0] != '\0') { wchar_t wSaveName[128]; ZeroMemory(wSaveName, sizeof(wSaveName)); @@ -305,7 +305,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye if(!m_bAvailableTexturePacksChecked) #endif { - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -451,9 +451,9 @@ void UIScene_LoadMenu::tick() // #ifdef _DEBUG // // dump out the thumbnail - // HANDLE hThumbnail = CreateFile("GAME:\\thumbnail.png", GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); + // HANDLE hThumbnail = CreateFile("GAME:\\thumbnail.png", GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, nullptr); // DWORD dwBytes; - // WriteFile(hThumbnail,pbImageData,dwImageBytes,&dwBytes,NULL); + // WriteFile(hThumbnail,pbImageData,dwImageBytes,&dwBytes,nullptr); // XCloseHandle(hThumbnail); // #endif @@ -771,7 +771,7 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() // texture pack hasn't been set yet, so check what it will be TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - if(pTexturePack==NULL) + if(pTexturePack==nullptr) { #if TO_BE_IMPLEMENTED // They've selected a texture pack they don't have yet @@ -849,7 +849,7 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_pDLCPack->getPurchaseOfferId()); ULONGLONG ullOfferID_Full; - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullOfferID_Full=pDLCInfo->ullOfferID_Full; } @@ -1107,7 +1107,7 @@ void UIScene_LoadMenu::LaunchGame(void) // inform them that leaderboard writes and achievements will be disabled //ui.RequestMessageBox(IDS_TITLE_START_GAME, IDS_CONFIRM_START_SAVEDINCREATIVE_CONTINUE, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::ConfirmLoadReturned,this,app.GetStringTable()); - if(m_levelGen != NULL) + if(m_levelGen != nullptr) { m_bIsCorrupt = false; LoadDataComplete(this); @@ -1150,7 +1150,7 @@ void UIScene_LoadMenu::LaunchGame(void) } else { - if(m_levelGen != NULL) + if(m_levelGen != nullptr) { m_bIsCorrupt = false; LoadDataComplete(this); @@ -1210,7 +1210,7 @@ int UIScene_LoadMenu::ConfirmLoadReturned(void *pParam,int iPad,C4JStorage::EMes if(result==C4JStorage::EMessage_ResultAccept) { - if(pClass->m_levelGen != NULL) + if(pClass->m_levelGen != nullptr) { pClass->m_bIsCorrupt = false; pClass->LoadDataComplete(pClass); @@ -1312,7 +1312,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) #if defined(__PS3__) || defined(__PSVITA__) if(isOnlineGame) { - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,nullptr,&bContentRestricted,nullptr); } #endif @@ -1362,7 +1362,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) // MGH - added this so we don't try and upsell when we don't know if the player has PS Plus yet (if it can't connect to the PS Plus server). UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); + ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr); return 0; } @@ -1381,7 +1381,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) // UINT uiIDA[2]; // uiIDA[0]=IDS_PLAY_OFFLINE; // uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; -// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_LoadMenu::PSPlusReturned,pClass, app.GetStringTable(),NULL,0,false); +// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_LoadMenu::PSPlusReturned,pClass, app.GetStringTable(),nullptr,0,false); } #endif @@ -1392,7 +1392,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) if(isOnlineGame) { bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,nullptr,nullptr); if(chatRestricted) { ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); @@ -1431,7 +1431,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) // MGH - added this so we don't try and upsell when we don't know if the player has PS Plus yet (if it can't connect to the PS Plus server). UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); + ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr); return 0; } @@ -1450,7 +1450,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) // UINT uiIDA[2]; // uiIDA[0]=IDS_PLAY_OFFLINE; // uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; -// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_LoadMenu::PSPlusReturned,pClass, app.GetStringTable(),NULL,0,false); +// ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_LoadMenu::PSPlusReturned,pClass, app.GetStringTable(),nullptr,0,false); } #endif else @@ -1554,7 +1554,7 @@ int UIScene_LoadMenu::DeleteSaveDataReturned(void *pParam,bool bSuccess) // 4J Stu - Shared functionality that is the same whether we needed a quadrant sign-in or not void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocalUsersMask) { - if(pClass->m_levelGen == NULL) + if(pClass->m_levelGen == nullptr) { INT saveOrCheckpointId = 0; bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); @@ -1582,7 +1582,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocal NetworkGameInitData *param = new NetworkGameInitData(); param->seed = pClass->m_seed; - param->saveData = NULL; + param->saveData = nullptr; param->levelGen = pClass->m_levelGen; param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack; param->levelName = pClass->m_levelName; @@ -1779,7 +1779,7 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int if(ProfileManager.IsSignedInLive(i)) { bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(i,false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(i,false,&chatRestricted,nullptr,nullptr); if(chatRestricted) { ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, i ); diff --git a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp index ed49a701b..fc668ff2e 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp @@ -36,7 +36,7 @@ static wstring ReadLevelNameFromSaveFile(const wstring& filePath) if (slashPos != wstring::npos) { wstring sidecarPath = filePath.substr(0, slashPos + 1) + L"worldname.txt"; - FILE *fr = NULL; + FILE *fr = nullptr; if (_wfopen_s(&fr, sidecarPath.c_str(), L"r") == 0 && fr) { char buf[128] = {}; @@ -57,15 +57,15 @@ static wstring ReadLevelNameFromSaveFile(const wstring& filePath) } } - HANDLE hFile = CreateFileW(filePath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); + HANDLE hFile = CreateFileW(filePath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr); if (hFile == INVALID_HANDLE_VALUE) return L""; - DWORD fileSize = GetFileSize(hFile, NULL); + DWORD fileSize = GetFileSize(hFile, nullptr); if (fileSize < 12 || fileSize == INVALID_FILE_SIZE) { CloseHandle(hFile); return L""; } unsigned char *rawData = new unsigned char[fileSize]; DWORD bytesRead = 0; - if (!ReadFile(hFile, rawData, fileSize, &bytesRead, NULL) || bytesRead != fileSize) + if (!ReadFile(hFile, rawData, fileSize, &bytesRead, nullptr) || bytesRead != fileSize) { CloseHandle(hFile); delete[] rawData; @@ -73,7 +73,7 @@ static wstring ReadLevelNameFromSaveFile(const wstring& filePath) } CloseHandle(hFile); - unsigned char *saveData = NULL; + unsigned char *saveData = nullptr; unsigned int saveSize = 0; bool freeSaveData = false; @@ -120,10 +120,10 @@ static wstring ReadLevelNameFromSaveFile(const wstring& filePath) ba.data = (byte*)(saveData + off); ba.length = len; CompoundTag *root = NbtIo::decompress(ba); - if (root != NULL) + if (root != nullptr) { CompoundTag *dataTag = root->getCompound(L"Data"); - if (dataTag != NULL) + if (dataTag != nullptr) result = dataTag->getString(L"LevelName"); delete root; } @@ -184,9 +184,9 @@ int UIScene_LoadOrJoinMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE p } else { - pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData = NULL; + pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData = nullptr; pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].dwThumbnailSize = 0; - app.DebugPrintf("Save thumbnail data is NULL, or has size 0\n"); + app.DebugPrintf("Save thumbnail data is nullptr, or has size 0\n"); } pClass->m_bSaveThumbnailReady = true; @@ -215,7 +215,7 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void *initData, UILayer m_bIgnoreInput = false; m_bShowingPartyGamesOnly = false; m_bInParty = false; - m_currentSessions = NULL; + m_currentSessions = nullptr; m_iState=e_SavesIdle; //m_bRetrievingSaveInfo=false; @@ -239,9 +239,9 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void *initData, UILayer m_bRetrievingSaveThumbnails = false; m_bSaveThumbnailReady = false; m_bExitScene=false; - m_pSaveDetails=NULL; + m_pSaveDetails=nullptr; m_bSavesDisplayed=false; - m_saveDetails = NULL; + m_saveDetails = nullptr; m_iSaveDetailsCount = 0; m_iTexturePacksNotInstalled = 0; m_bCopying = false; @@ -320,7 +320,7 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void *initData, UILayer #ifdef _XBOX // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -399,11 +399,11 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void *initData, UILayer UIScene_LoadOrJoinMenu::~UIScene_LoadOrJoinMenu() { - g_NetworkManager.SetSessionsUpdatedCallback( NULL, NULL ); + g_NetworkManager.SetSessionsUpdatedCallback( nullptr, nullptr ); app.SetLiveLinkRequired( false ); delete m_currentSessions; - m_currentSessions = NULL; + m_currentSessions = nullptr; #if TO_BE_IMPLEMENTED // Reset the background downloading, in case we changed it by attempting to download a texture pack @@ -705,7 +705,7 @@ void UIScene_LoadOrJoinMenu::tick() if(!m_bSavesDisplayed) { m_pSaveDetails=StorageManager.ReturnSavesInfo(); - if(m_pSaveDetails!=NULL) + if(m_pSaveDetails!=nullptr) { //CD - Fix - Adding define for ORBIS/XBOXONE #if defined(_XBOX_ONE) || defined(__ORBIS__) @@ -716,11 +716,11 @@ void UIScene_LoadOrJoinMenu::tick() m_bSavesDisplayed=true; UpdateGamesList(); - if(m_saveDetails!=NULL) + if(m_saveDetails!=nullptr) { for(unsigned int i = 0; i < m_iSaveDetailsCount; ++i) { - if(m_saveDetails[i].pbThumbnailData!=NULL) + if(m_saveDetails[i].pbThumbnailData!=nullptr) { delete m_saveDetails[i].pbThumbnailData; } @@ -1000,9 +1000,9 @@ void UIScene_LoadOrJoinMenu::GetSaveInfo() #ifdef __ORBIS__ // We need to make sure this is non-null so that we have an idea of free space m_pSaveDetails=StorageManager.ReturnSavesInfo(); - if(m_pSaveDetails==NULL) + if(m_pSaveDetails==nullptr) { - C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save"); + C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,nullptr,this,"save"); } #endif @@ -1049,9 +1049,9 @@ void UIScene_LoadOrJoinMenu::GetSaveInfo() m_controlSavesTimer.setVisible(true); m_pSaveDetails=StorageManager.ReturnSavesInfo(); - if(m_pSaveDetails==NULL) + if(m_pSaveDetails==nullptr) { - C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save"); + C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,nullptr,this,"save"); } #if TO_BE_IMPLEMENTED @@ -1389,7 +1389,7 @@ int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,boo mbstowcs(wFilename, pClass->m_saveDetails[listPos].UTF8SaveFilename, MAX_SAVEFILENAME_LENGTH - 1); wstring sidecarPath = wstring(L"Windows64\\GameHDD\\") + wstring(wFilename) + wstring(L"\\worldname.txt"); - FILE *fw = NULL; + FILE *fw = nullptr; if (_wfopen_s(&fw, sidecarPath.c_str(), L"w") == 0 && fw) { fputs(narrowName, fw); @@ -1497,7 +1497,7 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) params->iSaveGameInfoIndex=-1; //params->pbSaveRenamed=&m_bSaveRenamed; params->levelGen = levelGen; - params->saveDetails = NULL; + params->saveDetails = nullptr; // navigate to the settings scene ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_LoadMenu, params); @@ -1508,7 +1508,7 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) #ifdef __ORBIS__ // check if this is a damaged save PSAVE_INFO pSaveInfo = &m_pSaveDetails->SaveInfoA[((int)childId)-m_iDefaultButtonsC]; - if(pSaveInfo->thumbnailData == NULL && pSaveInfo->modifiedTime == 0) // no thumbnail data and time of zero and zero blocks useset for corrupt files + if(pSaveInfo->thumbnailData == nullptr && pSaveInfo->modifiedTime == 0) // no thumbnail data and time of zero and zero blocks useset for corrupt files { // give the option to delete the save UINT uiIDA[2]; @@ -1533,7 +1533,7 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) // need to get the iIndex from the list item, since the position in the list doesn't correspond to the GetSaveGameInfo list because of sorting params->iSaveGameInfoIndex=m_saveDetails[static_cast(childId)-m_iDefaultButtonsC].saveId; //params->pbSaveRenamed=&m_bSaveRenamed; - params->levelGen = NULL; + params->levelGen = nullptr; params->saveDetails = &m_saveDetails[ static_cast(childId)-m_iDefaultButtonsC ]; #ifdef _XBOX_ONE @@ -1588,7 +1588,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex) bool bContentRestricted=false; // we're online, since we are joining a game - ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&noUGC,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&noUGC,&bContentRestricted,nullptr); #ifdef __ORBIS__ // 4J Stu - On PS4 we don't restrict playing multiplayer based on chat restriction, so remove this check @@ -1632,7 +1632,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex) UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; // Not allowed to play online - ui.RequestAlertMessage(IDS_ONLINE_GAME, IDS_CHAT_RESTRICTION_UGC, uiIDA, 1, m_iPad,NULL,this); + ui.RequestAlertMessage(IDS_ONLINE_GAME, IDS_CHAT_RESTRICTION_UGC, uiIDA, 1, m_iPad,nullptr,this); #else // Not allowed to play online ProfileManager.ShowSystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, 0 ); @@ -1677,7 +1677,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex) // MGH - added this so we don't try and upsell when we don't know if the player has PS Plus yet (if it can't connect to the PS Plus server). UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL); + ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr); return; } @@ -1697,7 +1697,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex) // UINT uiIDA[2]; // uiIDA[0]=IDS_CONFIRM_OK; // uiIDA[1]=IDS_PLAYSTATIONPLUS_SIGNUP; - // ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_LoadOrJoinMenu::PSPlusReturned,this, app.GetStringTable(),NULL,0,false); + // ui.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA,2,ProfileManager.GetPrimaryPad(),&UIScene_LoadOrJoinMenu::PSPlusReturned,this, app.GetStringTable(),nullptr,0,false); m_bIgnoreInput=false; return; @@ -1799,7 +1799,7 @@ void UIScene_LoadOrJoinMenu::LoadLevelGen(LevelGenerationOptions *levelGen) NetworkGameInitData *param = new NetworkGameInitData(); param->seed = 0; - param->saveData = NULL; + param->saveData = nullptr; param->settings = app.GetGameHostOption( eGameHostOption_Tutorial ); param->levelGen = levelGen; @@ -1832,7 +1832,7 @@ void UIScene_LoadOrJoinMenu::LoadLevelGen(LevelGenerationOptions *levelGen) void UIScene_LoadOrJoinMenu::UpdateGamesListCallback(LPVOID pParam) { - if(pParam != NULL) + if(pParam != nullptr) { UIScene_LoadOrJoinMenu *pScene = static_cast(pParam); pScene->UpdateGamesList(); @@ -1854,7 +1854,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() } - FriendSessionInfo *pSelectedSession = NULL; + FriendSessionInfo *pSelectedSession = nullptr; if(DoesGamesListHaveFocus() && m_buttonListGames.getItemCount() > 0) { unsigned int nIndex = m_buttonListGames.getCurrentSelection(); @@ -1863,8 +1863,8 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() SessionID selectedSessionId; ZeroMemory(&selectedSessionId,sizeof(SessionID)); - if( pSelectedSession != NULL )selectedSessionId = pSelectedSession->sessionId; - pSelectedSession = NULL; + if( pSelectedSession != nullptr )selectedSessionId = pSelectedSession->sessionId; + pSelectedSession = nullptr; m_controlJoinTimer.setVisible( false ); @@ -1930,12 +1930,12 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() HRESULT hr; DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + PBYTE pbImageData=nullptr; - if(tp==NULL) + if(tp==nullptr) { DWORD dwBytes=0; - PBYTE pbData=NULL; + PBYTE pbData=nullptr; app.GetTPD(sessionInfo->data.texturePackParentId,&pbData,&dwBytes); // is it in the tpd data ? @@ -2136,7 +2136,7 @@ void UIScene_LoadOrJoinMenu::LoadSaveFromDisk(File *saveFile, ESavePlatform save __int64 fileSize = saveFile->length(); FileInputStream fis(*saveFile); - byteArray ba(fileSize); + byteArray ba(static_cast(fileSize)); fis.read(ba); fis.close(); @@ -2298,7 +2298,7 @@ int UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JSt if (pClass->m_saveDetails && displayIdx >= 0 && pClass->m_saveDetails[displayIdx].UTF8SaveFilename[0]) { wchar_t wFilename[MAX_SAVEFILENAME_LENGTH] = {}; - mbstowcs_s(NULL, wFilename, MAX_SAVEFILENAME_LENGTH, pClass->m_saveDetails[displayIdx].UTF8SaveFilename, MAX_SAVEFILENAME_LENGTH - 1); + mbstowcs_s(nullptr, wFilename, MAX_SAVEFILENAME_LENGTH, pClass->m_saveDetails[displayIdx].UTF8SaveFilename, MAX_SAVEFILENAME_LENGTH - 1); wchar_t wFolderPath[MAX_PATH] = {}; swprintf_s(wFolderPath, MAX_PATH, L"Windows64\\GameHDD\\%s", wFilename); bSuccess = Win64_DeleteSaveDirectory(wFolderPath); @@ -2387,7 +2387,7 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned(void *pParam,int iPad,C4JS { wchar_t wSaveName[128]; ZeroMemory(wSaveName, 128 * sizeof(wchar_t)); - mbstowcs_s(NULL, wSaveName, 128, pClass->m_saveDetails[pClass->m_iSaveListIndex - pClass->m_iDefaultButtonsC].UTF8SaveName, _TRUNCATE); + mbstowcs_s(nullptr, wSaveName, 128, pClass->m_saveDetails[pClass->m_iSaveListIndex - pClass->m_iDefaultButtonsC].UTF8SaveName, _TRUNCATE); UIKeyboardInitData kbData; kbData.title = app.GetString(IDS_RENAME_WORLD_TITLE); kbData.defaultText = wSaveName; @@ -2504,7 +2504,7 @@ int UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack(void *pParam,bool bCon if(bContinue==true) { SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo(pClass->m_initData->selectedSession->data.texturePackParentId); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chKeyName[20]; @@ -2513,7 +2513,7 @@ int UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack(void *pParam,bool bCon memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN); // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. // So we assume the first sku for the product is the one we want - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char + // MGH - keyname in the DLC file is 16 chars long, but there's no space for a nullptr terminating char memset(chKeyName, 0, sizeof(chKeyName)); strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); @@ -2567,7 +2567,7 @@ int UIScene_LoadOrJoinMenu::TexturePackDialogReturned(void *pParam,int iPad,C4JS #endif SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo(pClass->m_initData->selectedSession->data.texturePackParentId); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chKeyName[20]; @@ -2576,7 +2576,7 @@ int UIScene_LoadOrJoinMenu::TexturePackDialogReturned(void *pParam,int iPad,C4JS memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN); // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. // So we assume the first sku for the product is the one we want - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char + // MGH - keyname in the DLC file is 16 chars long, but there's no space for a nullptr terminating char memset(chKeyName, 0, sizeof(chKeyName)); strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); @@ -2610,7 +2610,7 @@ int UIScene_LoadOrJoinMenu::TexturePackDialogReturned(void *pParam,int iPad,C4JS wstring ProductId; app.GetDLCFullOfferIDForPackID(pClass->m_initData->selectedSession->data.texturePackParentId,ProductId); - StorageManager.InstallOffer(1,(WCHAR *)ProductId.c_str(),NULL,NULL); + StorageManager.InstallOffer(1,(WCHAR *)ProductId.c_str(),nullptr,nullptr); } else { @@ -2802,7 +2802,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter pMinecraft->progressRenderer->progressStart(IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD); pMinecraft->progressRenderer->progressStage( IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD ); - ConsoleSaveFile* pSave = NULL; + ConsoleSaveFile* pSave = nullptr; pClass->m_eSaveTransferState = eSaveTransfer_GetRemoteSaveInfo; @@ -2857,10 +2857,10 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter const char* pNameUTF8 = app.getRemoteStorage()->getSaveNameUTF8(); mbstowcs(wSaveName, pNameUTF8, strlen(pNameUTF8)+1); // plus null StorageManager.SetSaveTitle(wSaveName); - PBYTE pbThumbnailData=NULL; + PBYTE pbThumbnailData=nullptr; DWORD dwThumbnailDataSize=0; - PBYTE pbDataSaveImage=NULL; + PBYTE pbDataSaveImage=nullptr; DWORD dwDataSizeSaveImage=0; StorageManager.GetDefaultSaveImage(&pbDataSaveImage, &dwDataSizeSaveImage); // Get the default save thumbnail (as set by SetDefaultImages) for use on saving games t @@ -3021,10 +3021,10 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter StorageManager.ResetSaveData(); { - PBYTE pbThumbnailData=NULL; + PBYTE pbThumbnailData=nullptr; DWORD dwThumbnailDataSize=0; - PBYTE pbDataSaveImage=NULL; + PBYTE pbDataSaveImage=nullptr; DWORD dwDataSizeSaveImage=0; StorageManager.GetDefaultSaveImage(&pbDataSaveImage, &dwDataSizeSaveImage); // Get the default save thumbnail (as set by SetDefaultImages) for use on saving games t @@ -3232,7 +3232,7 @@ void UIScene_LoadOrJoinMenu::SaveTransferReturned(LPVOID lpParam, SonyRemoteStor } ConsoleSaveFile* UIScene_LoadOrJoinMenu::SonyCrossSaveConvert() { - return NULL; + return nullptr; } void UIScene_LoadOrJoinMenu::CancelSaveTransferCallback(LPVOID lpParam) @@ -3455,7 +3455,7 @@ int UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc( LPVOID lpParameter ) SaveTransferStateContainer *pStateContainer = (SaveTransferStateContainer *) lpParameter; Minecraft *pMinecraft=Minecraft::GetInstance(); - ConsoleSaveFile* pSave = NULL; + ConsoleSaveFile* pSave = nullptr; while(StorageManager.SaveTransferClearState()!=C4JStorage::eSaveTransfer_Idle) { @@ -3557,7 +3557,7 @@ int UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc( LPVOID lpParameter ) int iTextMetadataBytes = app.CreateImageTextData(bTextMetadata, seedVal, true, uiHostOptions, dwTexturePack); // set the icon and save image - StorageManager.SetSaveImages(ba.data, ba.length, NULL, 0, bTextMetadata, iTextMetadataBytes); + StorageManager.SetSaveImages(ba.data, ba.length, nullptr, 0, bTextMetadata, iTextMetadataBytes); delete ba.data; } @@ -3720,12 +3720,12 @@ void UIScene_LoadOrJoinMenu::RequestFileData( SaveTransferStateContainer *pClass File targetFile( wstring(L"FakeTMSPP\\").append(filename) ); if(targetFile.exists()) { - HANDLE hSaveFile = CreateFile( targetFile.getPath().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL); + HANDLE hSaveFile = CreateFile( targetFile.getPath().c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, nullptr); m_debugTransferDetails.pbData = new BYTE[m_debugTransferDetails.ulFileLen]; DWORD numberOfBytesRead = 0; - ReadFile( hSaveFile,m_debugTransferDetails.pbData,m_debugTransferDetails.ulFileLen,&numberOfBytesRead,NULL); + ReadFile( hSaveFile,m_debugTransferDetails.pbData,m_debugTransferDetails.ulFileLen,&numberOfBytesRead,nullptr); assert(numberOfBytesRead == m_debugTransferDetails.ulFileLen); CloseHandle(hSaveFile); @@ -3753,7 +3753,7 @@ int UIScene_LoadOrJoinMenu::SaveTransferReturned(LPVOID lpParam,C4JStorage::SAVE app.DebugPrintf("Save Transfer - size is %d\n",pSaveTransferDetails->ulFileLen); // if the file data is null, then assume this is the file size retrieval - if(pSaveTransferDetails->pbData==NULL) + if(pSaveTransferDetails->pbData==nullptr) { pClass->m_eSaveTransferState=C4JStorage::eSaveTransfer_FileSizeRetrieved; UIScene_LoadOrJoinMenu::s_ulFileSize=pSaveTransferDetails->ulFileLen; diff --git a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp index d8d6d66ae..a1cbc1449 100644 --- a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp @@ -104,7 +104,7 @@ UIScene_MainMenu::UIScene_MainMenu(int iPad, void *initData, UILayer *parentLaye m_bLoadTrialOnNetworkManagerReady = false; // 4J Stu - Clear out any loaded game rules - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // 4J Stu - Reset the leaving game flag so that we correctly handle signouts while in the menus g_NetworkManager.ResetLeavingGame(); @@ -303,9 +303,9 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) int primaryPad = ProfileManager.GetPrimaryPad(); #ifdef _XBOX_ONE - int (*signInReturnedFunc) (LPVOID,const bool, const int iPad, const int iController) = NULL; + int (*signInReturnedFunc) (LPVOID,const bool, const int iPad, const int iController) = nullptr; #else - int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = NULL; + int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = nullptr; #endif switch(static_cast(controlId)) @@ -396,7 +396,7 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) bool confirmUser = false; // Note: if no sign in returned func, assume this isn't required - if (signInReturnedFunc != NULL) + if (signInReturnedFunc != nullptr) { if(ProfileManager.IsSignedIn(primaryPad)) { @@ -940,7 +940,7 @@ int UIScene_MainMenu::Leaderboards_SignInReturned(void *pParam,bool bContinue,in { bool bContentRestricted=false; #if defined(__PS3__) || defined(__PSVITA__) - ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr); #endif if(bContentRestricted) { @@ -1098,7 +1098,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_PlayGame(void * UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; - int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = NULL; + int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = nullptr; // 4J-PB - Check if there is a patch for the game pClass->m_errorCode = ProfileManager.getNPAvailability(ProfileManager.GetPrimaryPad()); @@ -1141,7 +1141,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_PlayGame(void * // UINT uiIDA[1]; // uiIDA[0]=IDS_OK; -// ui.RequestMessageBox(IDS_PATCH_AVAILABLE_TITLE, IDS_PATCH_AVAILABLE_TEXT, uiIDA, 1, XUSER_INDEX_ANY,NULL,pClass); +// ui.RequestMessageBox(IDS_PATCH_AVAILABLE_TITLE, IDS_PATCH_AVAILABLE_TEXT, uiIDA, 1, XUSER_INDEX_ANY,nullptr,pClass); } // Check if PSN is unavailable because of age restriction @@ -1157,7 +1157,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_PlayGame(void * bool confirmUser = false; // Note: if no sign in returned func, assume this isn't required - if (signInReturnedFunc != NULL) + if (signInReturnedFunc != nullptr) { if(ProfileManager.IsSignedIn(primaryPad)) { @@ -1187,7 +1187,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_Leaderboards(vo UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; - int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = NULL; + int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = nullptr; // 4J-PB - Check if there is a patch for the game pClass->m_errorCode = ProfileManager.getNPAvailability(ProfileManager.GetPrimaryPad()); @@ -1228,7 +1228,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_Leaderboards(vo // UINT uiIDA[1]; // uiIDA[0]=IDS_OK; -// ui.RequestMessageBox(IDS_PATCH_AVAILABLE_TITLE, IDS_PATCH_AVAILABLE_TEXT, uiIDA, 1, XUSER_INDEX_ANY,NULL,pClass); +// ui.RequestMessageBox(IDS_PATCH_AVAILABLE_TITLE, IDS_PATCH_AVAILABLE_TEXT, uiIDA, 1, XUSER_INDEX_ANY,nullptr,pClass); } bool confirmUser = false; @@ -1247,7 +1247,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_Leaderboards(vo } // Note: if no sign in returned func, assume this isn't required - if (signInReturnedFunc != NULL) + if (signInReturnedFunc != nullptr) { if(ProfileManager.IsSignedIn(primaryPad)) { @@ -1600,7 +1600,7 @@ void UIScene_MainMenu::RunLeaderboards(int iPad) bool bContentRestricted=false; #if defined(__PS3__) || defined(__PSVITA__) - ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr); #endif if(bContentRestricted) { @@ -1608,7 +1608,7 @@ void UIScene_MainMenu::RunLeaderboards(int iPad) // you can't see leaderboards UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,this); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),nullptr,this); #endif } else @@ -1669,7 +1669,7 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) // UINT uiIDA[1]; // uiIDA[0]=IDS_OK; -// ui.RequestMessageBox(IDS_PATCH_AVAILABLE_TITLE, IDS_PATCH_AVAILABLE_TEXT, uiIDA, 1, XUSER_INDEX_ANY,NULL,this); +// ui.RequestMessageBox(IDS_PATCH_AVAILABLE_TITLE, IDS_PATCH_AVAILABLE_TEXT, uiIDA, 1, XUSER_INDEX_ANY,nullptr,this); return; } @@ -1704,7 +1704,7 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { bool bContentRestricted=false; #if defined(__PS3__) || defined(__PSVITA__) - ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr); #endif if(bContentRestricted) { @@ -1713,7 +1713,7 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) // you can't see the store UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,this); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),nullptr,this); #endif } else @@ -1925,7 +1925,7 @@ void UIScene_MainMenu::tick() // 4J-PB - need to check this user can access the store bool bContentRestricted=false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -2102,7 +2102,7 @@ void UIScene_MainMenu::LoadTrial(void) NetworkGameInitData *param = new NetworkGameInitData(); param->seed = 0; - param->saveData = NULL; + param->saveData = nullptr; param->settings = app.GetGameHostOption( eGameHostOption_Tutorial ) | app.GetGameHostOption(eGameHostOption_DisableSaving); vector *generators = app.getLevelGenerators(); diff --git a/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp b/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp index 52a878e8b..7a0749d4a 100644 --- a/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp +++ b/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp @@ -41,7 +41,7 @@ UIScene_MessageBox::UIScene_MessageBox(int iPad, void *initData, UILayer *parent m_labelTitle.init(app.GetString(param->uiTitle)); m_labelContent.init(app.GetString(param->uiText)); - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , nullptr ); m_Func = param->Func; m_lpParam = param->lpParam; @@ -87,7 +87,7 @@ void UIScene_MessageBox::handleReload() value[1].number = static_cast(getControlFocus()); IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcInit , 2 , value ); - out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , NULL ); + out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , nullptr ); } void UIScene_MessageBox::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) diff --git a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp index 772971370..7cec38b3c 100644 --- a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp @@ -101,7 +101,7 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa TelemetryManager->RecordPauseOrInactive(m_iPad); Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); @@ -114,7 +114,7 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa UIScene_PauseMenu::~UIScene_PauseMenu() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); @@ -593,7 +593,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { bool bContentRestricted=false; #if defined(__PS3__) || defined(__PSVITA__) - ProfileManager.GetChatAndContentRestrictions(m_iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(m_iPad,true,nullptr,&bContentRestricted,nullptr); #endif if(bContentRestricted) { @@ -654,7 +654,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) if(m_iPad==ProfileManager.GetPrimaryPad()) { int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } @@ -723,7 +723,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) else { int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } @@ -741,7 +741,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) if(m_iPad==ProfileManager.GetPrimaryPad()) { int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } @@ -759,7 +759,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) else { int playTime = -1; - if( pMinecraft->localplayers[m_iPad] != NULL ) + if( pMinecraft->localplayers[m_iPad] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[m_iPad]->getSessionTimer()); } @@ -979,7 +979,7 @@ int UIScene_PauseMenu::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage:: // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -1112,7 +1112,7 @@ int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void *pParam,bool bContin { #ifndef __ORBIS__ bool bContentRestricted=false; - ProfileManager.GetChatAndContentRestrictions(pClass->m_iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(pClass->m_iPad,true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { // you can't see leaderboards @@ -1183,7 +1183,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J #ifndef __ORBIS__ // 4J-PB - need to check this user can access the store bool bContentRestricted=false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -1203,7 +1203,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J app.DebugPrintf("Texture Pack - %s\n",pchPackName); SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chKeyName[20]; @@ -1214,7 +1214,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. // So we assume the first sku for the product is the one we want - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char + // MGH - keyname in the DLC file is 16 chars long, but there's no space for a nullptr terminating char memset(chKeyName, 0, sizeof(chKeyName)); strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); @@ -1260,7 +1260,7 @@ int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void *pParam,bool bContinue #ifndef __ORBIS__ // 4J-PB - need to check this user can access the store bool bContentRestricted=false; - ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; @@ -1280,7 +1280,7 @@ int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void *pParam,bool bContinue app.DebugPrintf("Texture Pack - %s\n",pchPackName); SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); - if(pSONYDLCInfo!=NULL) + if(pSONYDLCInfo!=nullptr) { char chName[42]; char chKeyName[20]; @@ -1291,7 +1291,7 @@ int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void *pParam,bool bContinue // we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it. // So we assume the first sku for the product is the one we want - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char + // MGH - keyname in the DLC file is 16 chars long, but there's no space for a nullptr terminating char memset(chKeyName, 0, sizeof(chKeyName)); strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); diff --git a/Minecraft.Client/Common/UI/UIScene_QuadrantSignin.cpp b/Minecraft.Client/Common/UI/UIScene_QuadrantSignin.cpp index 445c6ffcd..766765614 100644 --- a/Minecraft.Client/Common/UI/UIScene_QuadrantSignin.cpp +++ b/Minecraft.Client/Common/UI/UIScene_QuadrantSignin.cpp @@ -274,7 +274,7 @@ int UIScene_QuadrantSignin::AvatarReturned(LPVOID lpParam,PBYTE pbThumbnail,DWOR { UIScene_QuadrantSignin *pClass = static_cast(lpParam); app.DebugPrintf(app.USER_SR,"AvatarReturned callback\n"); - if(pbThumbnail != NULL) + if(pbThumbnail != nullptr) { // 4J-JEV - Added to ensure each new texture gets a unique name. static unsigned int quadrantImageCount = 0; diff --git a/Minecraft.Client/Common/UI/UIScene_ReinstallMenu.cpp b/Minecraft.Client/Common/UI/UIScene_ReinstallMenu.cpp index 3b67f79e7..c713a3900 100644 --- a/Minecraft.Client/Common/UI/UIScene_ReinstallMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ReinstallMenu.cpp @@ -36,7 +36,7 @@ void UIScene_ReinstallMenu::updateTooltips() void UIScene_ReinstallMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); diff --git a/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp b/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp index 98bcab7e0..0b8e0ca4a 100644 --- a/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp @@ -19,7 +19,7 @@ UIScene_SaveMessage::UIScene_SaveMessage(int iPad, void *initData, UILayer *pare IggyDataValue result; // Russian needs to resize the box - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , NULL ); + IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , nullptr ); // 4J-PB - If we have a signed in user connected, let's get the DLC now for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp index c1b38fa04..083fbd358 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp @@ -47,7 +47,7 @@ void UIScene_SettingsAudioMenu::updateTooltips() void UIScene_SettingsAudioMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsControlMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsControlMenu.cpp index 3a81775dc..7dbd243b7 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsControlMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsControlMenu.cpp @@ -47,7 +47,7 @@ void UIScene_SettingsControlMenu::updateTooltips() void UIScene_SettingsControlMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp index be92bd62d..cf4f5bb50 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp @@ -37,7 +37,7 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD initialiseMovie(); Minecraft* pMinecraft = Minecraft::GetInstance(); - m_bNotInGame=(Minecraft::GetInstance()->level==NULL); + m_bNotInGame=(Minecraft::GetInstance()->level==nullptr); m_checkboxClouds.init(app.GetString(IDS_CHECKBOX_RENDER_CLOUDS),eControl_Clouds,(app.GetGameSettings(m_iPad,eGameSetting_Clouds)!=0)); m_checkboxBedrockFog.init(app.GetString(IDS_CHECKBOX_RENDER_BEDROCKFOG),eControl_BedrockFog,(app.GetGameSettings(m_iPad,eGameSetting_BedrockFog)!=0)); @@ -58,7 +58,7 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD doHorizontalResizeCheck(); - bool bInGame=(Minecraft::GetInstance()->level!=NULL); + bool bInGame=(Minecraft::GetInstance()->level!=nullptr); bool bIsPrimaryPad=(ProfileManager.GetPrimaryPad()==m_iPad); // if we're not in the game, we need to use basescene 0 if(bInGame) @@ -113,7 +113,7 @@ void UIScene_SettingsGraphicsMenu::updateTooltips() void UIScene_SettingsGraphicsMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp index 4f15d1081..2ae9c897d 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp @@ -8,7 +8,7 @@ UIScene_SettingsMenu::UIScene_SettingsMenu(int iPad, void *initData, UILayer *pa // Setup all the Iggy references we need for this scene initialiseMovie(); - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); m_buttons[BUTTON_ALL_OPTIONS].init(IDS_OPTIONS,BUTTON_ALL_OPTIONS); m_buttons[BUTTON_ALL_AUDIO].init(IDS_AUDIO,BUTTON_ALL_AUDIO); @@ -51,7 +51,7 @@ wstring UIScene_SettingsMenu::getMoviePath() void UIScene_SettingsMenu::handleReload() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(ProfileManager.GetPrimaryPad()!=m_iPad) { removeControl( &m_buttons[BUTTON_ALL_AUDIO], bNotInGame); @@ -68,7 +68,7 @@ void UIScene_SettingsMenu::updateTooltips() void UIScene_SettingsMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp index 6780e05bc..7b4d3d9dd 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp @@ -29,7 +29,7 @@ UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, void *initDat // Setup all the Iggy references we need for this scene initialiseMovie(); - m_bNotInGame=(Minecraft::GetInstance()->level==NULL); + m_bNotInGame=(Minecraft::GetInstance()->level==nullptr); m_checkboxViewBob.init(IDS_VIEW_BOBBING,eControl_ViewBob,(app.GetGameSettings(m_iPad,eGameSetting_ViewBob)!=0)); m_checkboxShowHints.init(IDS_HINTS,eControl_ShowHints,(app.GetGameSettings(m_iPad,eGameSetting_Hints)!=0)); @@ -99,7 +99,7 @@ UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, void *initDat bool bRemoveAutosave=false; bool bRemoveInGameGamertags=false; - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; if(!bPrimaryPlayer) { @@ -196,7 +196,7 @@ void UIScene_SettingsOptionsMenu::updateTooltips() void UIScene_SettingsOptionsMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); @@ -324,7 +324,7 @@ void UIScene_SettingsOptionsMenu::handleReload() bool bRemoveAutosave=false; bool bRemoveInGameGamertags=false; - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; if(!bPrimaryPlayer) { diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsUIMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsUIMenu.cpp index 5a515c4b3..873564f62 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsUIMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsUIMenu.cpp @@ -7,7 +7,7 @@ UIScene_SettingsUIMenu::UIScene_SettingsUIMenu(int iPad, void *initData, UILayer // Setup all the Iggy references we need for this scene initialiseMovie(); - m_bNotInGame=(Minecraft::GetInstance()->level==NULL); + m_bNotInGame=(Minecraft::GetInstance()->level==nullptr); m_checkboxDisplayHUD.init(app.GetString(IDS_CHECKBOX_DISPLAY_HUD),eControl_DisplayHUD,(app.GetGameSettings(m_iPad,eGameSetting_DisplayHUD)!=0)); m_checkboxDisplayHand.init(app.GetString(IDS_CHECKBOX_DISPLAY_HAND),eControl_DisplayHand,(app.GetGameSettings(m_iPad,eGameSetting_DisplayHand)!=0)); @@ -26,7 +26,7 @@ UIScene_SettingsUIMenu::UIScene_SettingsUIMenu(int iPad, void *initData, UILayer doHorizontalResizeCheck(); - bool bInGame=(Minecraft::GetInstance()->level!=NULL); + bool bInGame=(Minecraft::GetInstance()->level!=nullptr); bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; // if we're not in the game, we need to use basescene 0 @@ -57,7 +57,7 @@ void UIScene_SettingsUIMenu::updateTooltips() void UIScene_SettingsUIMenu::updateComponents() { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); diff --git a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp index 74e7e2dcb..679daff1e 100644 --- a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp @@ -95,7 +95,7 @@ void UIScene_SignEntryMenu::tick() if (pMinecraft->level->isClientSide) { shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player != NULL && player->connection && player->connection->isStarted()) + if(player != nullptr && player->connection && player->connection->isStarted()) { player->connection->send( shared_ptr( new SignUpdatePacket(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages()) ) ); } diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp index 168c96b64..20a741236 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp @@ -40,7 +40,7 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void *initData, UILayer m_bIgnoreInput=false; m_bNoSkinsToShow = false; - m_currentPack = NULL; + m_currentPack = nullptr; m_packIndex = SKIN_SELECT_PACK_DEFAULT; m_skinIndex = 0; @@ -48,7 +48,7 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void *initData, UILayer m_currentSkinPath = app.GetPlayerSkinName(iPad); m_selectedSkinPath = L""; m_selectedCapePath = L""; - m_vAdditionalSkinBoxes = NULL; + m_vAdditionalSkinBoxes = nullptr; m_bSlidingSkins = false; m_bAnimatingMove = false; @@ -107,7 +107,7 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void *initData, UILayer // Change to display the favorites if there are any. The current skin will be in there (probably) - need to check for it m_currentPack = app.m_dlcManager.getPackContainingSkin(m_currentSkinPath); bool bFound; - if(m_currentPack != NULL) + if(m_currentPack != nullptr) { m_packIndex = app.m_dlcManager.getPackIndex(m_currentPack,bFound,DLCManager::e_DLCType_Skin) + SKIN_SELECT_MAX_DEFAULTS; } @@ -436,7 +436,7 @@ void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) } break; default: - if( m_currentPack != NULL ) + if( m_currentPack != nullptr ) { bool renableInputAfterOperation = true; m_bIgnoreInput = true; @@ -520,7 +520,7 @@ void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_currentPack->getPurchaseOfferId()); ULONGLONG ullOfferID_Full; - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullOfferID_Full=pDLCInfo->ullOfferID_Full; } @@ -534,7 +534,7 @@ void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) #endif bool bContentRestricted=false; #if defined(__PS3__) || defined(__PSVITA__) - ProfileManager.GetChatAndContentRestrictions(m_iPad,true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(m_iPad,true,nullptr,&bContentRestricted,nullptr); #endif if(bContentRestricted) { @@ -635,8 +635,8 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() wstring skinOrigin = L""; bool bSkinIsFree=false; bool bLicensed=false; - DLCSkinFile *skinFile=NULL; - DLCPack *Pack=NULL; + DLCSkinFile *skinFile=nullptr; + DLCPack *Pack=nullptr; BYTE sidePreviewControlsL,sidePreviewControlsR; m_bNoSkinsToShow=false; @@ -646,7 +646,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() m_controlSkinNamePlate.setVisible( false ); - if( m_currentPack != NULL ) + if( m_currentPack != nullptr ) { skinFile = m_currentPack->getSkinFile(m_skinIndex); m_selectedSkinPath = skinFile->getPath(); @@ -673,7 +673,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { m_selectedSkinPath = L""; m_selectedCapePath = L""; - m_vAdditionalSkinBoxes = NULL; + m_vAdditionalSkinBoxes = nullptr; switch(m_packIndex) { @@ -758,13 +758,13 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() // add the boxes to the humanoid model, but only if we've not done this already vector *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); - if(pAdditionalModelParts==NULL) + if(pAdditionalModelParts==nullptr) { pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),m_vAdditionalSkinBoxes); } } - if(skinFile!=NULL) + if(skinFile!=nullptr) { app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); } @@ -779,7 +779,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() wstring otherSkinPath = L""; wstring otherCapePath = L""; - vector *othervAdditionalSkinBoxes=NULL; + vector *othervAdditionalSkinBoxes=nullptr; wchar_t chars[256]; // turn off all displays @@ -824,11 +824,11 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { if(showNext) { - skinFile=NULL; + skinFile=nullptr; m_characters[eCharacter_Next1 + i].setVisible(true); - if( m_currentPack != NULL ) + if( m_currentPack != nullptr ) { skinFile = m_currentPack->getSkinFile(nextIndex); otherSkinPath = skinFile->getPath(); @@ -840,7 +840,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { otherSkinPath = L""; otherCapePath = L""; - othervAdditionalSkinBoxes=NULL; + othervAdditionalSkinBoxes=nullptr; switch(m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -872,13 +872,13 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() if(othervAdditionalSkinBoxes && othervAdditionalSkinBoxes->size()!=0) { vector *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); - if(pAdditionalModelParts==NULL) + if(pAdditionalModelParts==nullptr) { pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); } } // 4J-PB - anim override needs set before SetTexture - if(skinFile!=NULL) + if(skinFile!=nullptr) { app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); } @@ -895,11 +895,11 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { if(showPrevious) { - skinFile=NULL; + skinFile=nullptr; m_characters[eCharacter_Previous1 + i].setVisible(true); - if( m_currentPack != NULL ) + if( m_currentPack != nullptr ) { skinFile = m_currentPack->getSkinFile(previousIndex); otherSkinPath = skinFile->getPath(); @@ -911,7 +911,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { otherSkinPath = L""; otherCapePath = L""; - othervAdditionalSkinBoxes=NULL; + othervAdditionalSkinBoxes=nullptr; switch(m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -943,7 +943,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() if(othervAdditionalSkinBoxes && othervAdditionalSkinBoxes->size()!=0) { vector *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); - if(pAdditionalModelParts==NULL) + if(pAdditionalModelParts==nullptr) { pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); } @@ -1021,7 +1021,7 @@ int UIScene_SkinSelectMenu::getNextSkinIndex(DWORD sourceIndex) { nextSkin = eDefaultSkins_ServerSelected; } - else if(m_currentPack != NULL && nextSkin>=m_currentPack->getSkinCount()) + else if(m_currentPack != nullptr && nextSkin>=m_currentPack->getSkinCount()) { nextSkin = 0; } @@ -1055,7 +1055,7 @@ int UIScene_SkinSelectMenu::getPreviousSkinIndex(DWORD sourceIndex) { previousSkin = eDefaultSkins_Count - 1; } - else if(m_currentPack != NULL) + else if(m_currentPack != nullptr) { previousSkin = m_currentPack->getSkinCount()-1; } @@ -1079,10 +1079,10 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() } else { - m_currentPack = NULL; + m_currentPack = nullptr; } m_skinIndex = 0; - if(m_currentPack != NULL) + if(m_currentPack != nullptr) { bool found; DWORD currentSkinIndex = m_currentPack->getSkinIndexAt(m_currentSkinPath, found); @@ -1130,7 +1130,7 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() std::wstring fakeWideToRealWide(const wchar_t* original) { const char* name = reinterpret_cast(original); - int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0); + int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, nullptr, 0); std::wstring wName(len, 0); MultiByteToWideChar(CP_UTF8, 0, name, -1, &wName[0], len); return wName.c_str(); @@ -1500,7 +1500,7 @@ void UIScene_SkinSelectMenu::HandleDLCMountingComplete() if(app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin)>0) { m_currentPack = app.m_dlcManager.getPackContainingSkin(m_currentSkinPath); - if(m_currentPack != NULL) + if(m_currentPack != nullptr) { bool bFound = false; m_packIndex = app.m_dlcManager.getPackIndex(m_currentPack,bFound,DLCManager::e_DLCType_Skin) + SKIN_SELECT_MAX_DEFAULTS; @@ -1520,7 +1520,7 @@ void UIScene_SkinSelectMenu::HandleDLCMountingComplete() m_bIgnoreInput=false; app.m_dlcManager.checkForCorruptDLCAndAlert(); - bool bInGame=(Minecraft::GetInstance()->level!=NULL); + bool bInGame=(Minecraft::GetInstance()->level!=nullptr); #if TO_BE_IMPLEMENTED if(bInGame) XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO); @@ -1534,7 +1534,7 @@ void UIScene_SkinSelectMenu::showNotOnlineDialog(int iPad) { // need to be signed in to live. get them to sign in to online #if defined(__PS3__) - SQRNetworkManager_PS3::AttemptPSNSignIn(NULL, this); + SQRNetworkManager_PS3::AttemptPSNSignIn(nullptr, this); #elif defined(__PSVITA__) if(CGameNetworkManager::usingAdhocMode() && SQRNetworkManager_AdHoc_Vita::GetAdhocStatus()) @@ -1543,15 +1543,15 @@ void UIScene_SkinSelectMenu::showNotOnlineDialog(int iPad) UINT uiIDA[2]; uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1]=IDS_CANCEL; - ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&UIScene_SkinSelectMenu::MustSignInReturned,NULL); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&UIScene_SkinSelectMenu::MustSignInReturned,nullptr); } else { - SQRNetworkManager_Vita::AttemptPSNSignIn(NULL, this); + SQRNetworkManager_Vita::AttemptPSNSignIn(nullptr, this); } #elif defined(__ORBIS__) - SQRNetworkManager_Orbis::AttemptPSNSignIn(NULL, this, false, iPad); + SQRNetworkManager_Orbis::AttemptPSNSignIn(nullptr, this, false, iPad); #elif defined(_DURANGO) @@ -1579,7 +1579,7 @@ int UIScene_SkinSelectMenu::UnlockSkinReturned(void *pParam,int iPad,C4JStorage: const char *pchPackName=wstringtofilename(wStrPackName); SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName); - if (pSONYDLCInfo != NULL) + if (pSONYDLCInfo != nullptr) { char chName[42]; char chKeyName[20]; @@ -1593,7 +1593,7 @@ int UIScene_SkinSelectMenu::UnlockSkinReturned(void *pParam,int iPad,C4JStorage: // while the store is screwed, hardcode the sku //sprintf(chName,"%s-%s-%s",app.GetCommerceCategory(),pSONYDLCInfo->chDLCKeyname,"EURO"); - // MGH - keyname in the DLC file is 16 chars long, but there's no space for a NULL terminating char + // MGH - keyname in the DLC file is 16 chars long, but there's no space for a nullptr terminating char memset(chKeyName, 0, sizeof(chKeyName)); strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); @@ -1623,7 +1623,7 @@ int UIScene_SkinSelectMenu::UnlockSkinReturned(void *pParam,int iPad,C4JStorage: // need to re-enable input because the user can back out of the store purchase, and we'll be stuck pScene->m_bIgnoreInput = false; // MGH - moved this to outside the pSONYDLCInfo, so we don't get stuck #elif defined _XBOX_ONE - StorageManager.InstallOffer(1,(WCHAR *)(pScene->m_currentPack->getPurchaseOfferId().c_str()), &RenableInput, pScene, NULL); + StorageManager.InstallOffer(1,(WCHAR *)(pScene->m_currentPack->getPurchaseOfferId().c_str()), &RenableInput, pScene, nullptr); #endif } else // Is signed in, but not live. diff --git a/Minecraft.Client/Common/UI/UIScene_TeleportMenu.cpp b/Minecraft.Client/Common/UI/UIScene_TeleportMenu.cpp index 5d49196c9..017af93ef 100644 --- a/Minecraft.Client/Common/UI/UIScene_TeleportMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_TeleportMenu.cpp @@ -41,7 +41,7 @@ UIScene_TeleportMenu::UIScene_TeleportMenu(int iPad, void *initData, UILayer *pa { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); - if( player != NULL && !(player->IsLocal() && player->GetUserIndex() == m_iPad) ) + if( player != nullptr && !(player->IsLocal() && player->GetUserIndex() == m_iPad) ) { m_players[m_playersCount] = player->GetSmallId(); ++m_playersCount; @@ -59,7 +59,7 @@ UIScene_TeleportMenu::UIScene_TeleportMenu(int iPad, void *initData, UILayer *pa } int voiceStatus = 0; - if(player != NULL && player->HasVoice() ) + if(player != nullptr && player->HasVoice() ) { if( player->IsMutedByLocalUser(m_iPad) ) { @@ -131,7 +131,7 @@ void UIScene_TeleportMenu::handleReload() { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); - if( player != NULL && !(player->IsLocal() && player->GetUserIndex() == m_iPad) ) + if( player != nullptr && !(player->IsLocal() && player->GetUserIndex() == m_iPad) ) { m_players[m_playersCount] = player->GetSmallId(); ++m_playersCount; @@ -149,7 +149,7 @@ void UIScene_TeleportMenu::handleReload() } int voiceStatus = 0; - if(player != NULL && player->HasVoice() ) + if(player != nullptr && player->HasVoice() ) { if( player->IsMutedByLocalUser(m_iPad) ) { @@ -189,7 +189,7 @@ void UIScene_TeleportMenu::tick() { INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId( m_players[i] ); - if( player != NULL ) + if( player != nullptr ) { m_players[i] = player->GetSmallId(); @@ -320,7 +320,7 @@ void UIScene_TeleportMenu::OnPlayerChanged(void *callbackParam, INetworkPlayer * } int voiceStatus = 0; - if(pPlayer != NULL && pPlayer->HasVoice() ) + if(pPlayer != nullptr && pPlayer->HasVoice() ) { if( pPlayer->IsMutedByLocalUser(scene->m_iPad) ) { diff --git a/Minecraft.Client/Common/UI/UIScene_TradingMenu.cpp b/Minecraft.Client/Common/UI/UIScene_TradingMenu.cpp index d806c49ff..bb9e30af4 100644 --- a/Minecraft.Client/Common/UI/UIScene_TradingMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_TradingMenu.cpp @@ -29,7 +29,7 @@ UIScene_TradingMenu::UIScene_TradingMenu(int iPad, void *_initData, UILayer *par m_merchant = initData->trader; Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[iPad] != NULL ) + if( pMinecraft->localgameModes[iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -87,15 +87,15 @@ void UIScene_TradingMenu::handleDestroy() { app.DebugPrintf("UIScene_TradingMenu::handleDestroy\n"); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(pMinecraft->localplayers[m_iPad] != NULL) pMinecraft->localplayers[m_iPad]->closeContainer(); + if(pMinecraft->localplayers[m_iPad] != nullptr) pMinecraft->localplayers[m_iPad]->closeContainer(); ui.OverrideSFX(m_iPad,ACTION_MENU_A,false); ui.OverrideSFX(m_iPad,ACTION_MENU_OK,false); @@ -155,7 +155,7 @@ void UIScene_TradingMenu::handleInput(int iPad, int key, bool repeat, bool press void UIScene_TradingMenu::customDraw(IggyCustomDrawCallbackRegion *region) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; shared_ptr item = nullptr; int slotId = -1; @@ -190,7 +190,7 @@ void UIScene_TradingMenu::customDraw(IggyCustomDrawCallbackRegion *region) }; } } - if(item != NULL) customDrawSlotControl(region,m_iPad,item,1.0f,item->isFoil(),true); + if(item != nullptr) customDrawSlotControl(region,m_iPad,item,1.0f,item->isFoil(),true); } void UIScene_TradingMenu::showScrollRightArrow(bool show) diff --git a/Minecraft.Client/Common/UI/UIScene_TrialExitUpsell.cpp b/Minecraft.Client/Common/UI/UIScene_TrialExitUpsell.cpp index 9ef8f189a..9338daba7 100644 --- a/Minecraft.Client/Common/UI/UIScene_TrialExitUpsell.cpp +++ b/Minecraft.Client/Common/UI/UIScene_TrialExitUpsell.cpp @@ -50,7 +50,7 @@ void UIScene_TrialExitUpsell::handleInput(int iPad, int key, bool repeat, bool p // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,nullptr,&bContentRestricted,nullptr); if(bContentRestricted) { UINT uiIDA[1]; diff --git a/Minecraft.Client/Common/UI/UIString.cpp b/Minecraft.Client/Common/UI/UIString.cpp index 288fa87a9..04d8b8e37 100644 --- a/Minecraft.Client/Common/UI/UIString.cpp +++ b/Minecraft.Client/Common/UI/UIString.cpp @@ -139,7 +139,7 @@ UIString::~UIString() bool UIString::empty() { - return m_core.get() == NULL; + return m_core.get() == nullptr; } bool UIString::compare(const UIString &uiString) @@ -149,19 +149,19 @@ bool UIString::compare(const UIString &uiString) bool UIString::needsUpdating() { - if (m_core != NULL) return m_core->needsUpdating(); + if (m_core != nullptr) return m_core->needsUpdating(); else return false; } void UIString::setUpdated() { - if (m_core != NULL) m_core->setUpdated(); + if (m_core != nullptr) m_core->setUpdated(); } wstring &UIString::getString() { static wstring blank(L""); - if (m_core != NULL) return m_core->getString(); + if (m_core != nullptr) return m_core->getString(); else return blank; } diff --git a/Minecraft.Client/Common/UI/UIStructs.h b/Minecraft.Client/Common/UI/UIStructs.h index ac83458fc..e5f5a8333 100644 --- a/Minecraft.Client/Common/UI/UIStructs.h +++ b/Minecraft.Client/Common/UI/UIStructs.h @@ -196,8 +196,8 @@ typedef struct _ConnectionProgressParams showTooltips = false; setFailTimer = false; timerTime = 0; - cancelFunc = NULL; - cancelFuncParam = NULL; + cancelFunc = nullptr; + cancelFuncParam = nullptr; } } ConnectionProgressParams; @@ -250,7 +250,7 @@ typedef struct _SaveListDetails _SaveListDetails() { saveId = 0; - pbThumbnailData = NULL; + pbThumbnailData = nullptr; dwThumbnailSize = 0; #ifdef _DURANGO ZeroMemory(UTF16SaveName,sizeof(wchar_t)*128); @@ -403,15 +403,15 @@ typedef struct _LoadingInputParams _LoadingInputParams() { - func = NULL; - lpParam = NULL; - completionData = NULL; + func = nullptr; + lpParam = nullptr; + completionData = nullptr; cancelText = -1; - cancelFunc = NULL; - completeFunc = NULL; - m_cancelFuncParam = NULL; - m_completeFuncParam = NULL; + cancelFunc = nullptr; + completeFunc = nullptr; + m_cancelFuncParam = nullptr; + m_completeFuncParam = nullptr; waitForThreadToDelete = false; } } LoadingInputParams; @@ -439,7 +439,7 @@ typedef struct _TutorialPopupInfo _TutorialPopupInfo() { - interactScene = NULL; + interactScene = nullptr; desc = L""; title = L""; icon = -1; @@ -447,7 +447,7 @@ typedef struct _TutorialPopupInfo isFoil = false; allowFade = true; isReminder = false; - tutorial = NULL; + tutorial = nullptr; } } TutorialPopupInfo; diff --git a/Minecraft.Client/Common/UI/UITTFFont.cpp b/Minecraft.Client/Common/UI/UITTFFont.cpp index 5d72ed97c..359ac76b8 100644 --- a/Minecraft.Client/Common/UI/UITTFFont.cpp +++ b/Minecraft.Client/Common/UI/UITTFFont.cpp @@ -11,9 +11,9 @@ UITTFFont::UITTFFont(const string &name, const string &path, S32 fallbackCharact #ifdef _UNICODE wstring wPath = convStringToWstring(path); - HANDLE file = CreateFile(wPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(wPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #else - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -30,7 +30,7 @@ UITTFFont::UITTFFont(const string &name, const string &path, S32 fallbackCharact DWORD bytesRead; pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { app.FatalLoadError(); diff --git a/Minecraft.Client/Common/XUI/XUI_Chat.cpp b/Minecraft.Client/Common/XUI/XUI_Chat.cpp index a1c43c63f..640056217 100644 --- a/Minecraft.Client/Common/XUI/XUI_Chat.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Chat.cpp @@ -37,7 +37,7 @@ HRESULT CScene_Chat::OnTimer( XUIMessageTimer *pXUIMessageTimer, BOOL &bHandled) m_Labels[i].SetOpacity(0); } } - if(pMinecraft->localplayers[m_iPad]!= NULL) + if(pMinecraft->localplayers[m_iPad]!= nullptr) { m_Jukebox.SetText( pGui->getJukeboxMessage(m_iPad).c_str() ); m_Jukebox.SetOpacity( pGui->getJukeboxOpacity(m_iPad) ); diff --git a/Minecraft.Client/Common/XUI/XUI_ConnectingProgress.cpp b/Minecraft.Client/Common/XUI/XUI_ConnectingProgress.cpp index ab99c00dc..5ae736a3d 100644 --- a/Minecraft.Client/Common/XUI/XUI_ConnectingProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_ConnectingProgress.cpp @@ -203,7 +203,7 @@ HRESULT CScene_ConnectingProgress::OnTimer( XUIMessageTimer *pTimer, BOOL& bHand UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; #ifdef _XBOX - StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); #endif exitReasonStringId = -1; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JEdit.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JEdit.cpp index 65118fa5d..576b75577 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JEdit.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JEdit.cpp @@ -10,7 +10,7 @@ HRESULT CXuiCtrl4JEdit::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled) // set a limit for the text box m_uTextLimit=XUI_4JEDIT_MAX_CHARS-1; XuiEditSetTextLimit(m_hObj,m_uTextLimit); - // Find the text limit. (Add one for NULL terminator) + // Find the text limit. (Add one for nullptr terminator) //m_uTextLimit = min( XuiEditGetTextLimit(m_hObj) + 1, XUI_4JEDIT_MAX_CHARS); ZeroMemory( wchText , sizeof(WCHAR)*(m_uTextLimit+1) ); @@ -145,7 +145,7 @@ HRESULT CXuiCtrl4JEdit::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) if( pThis->m_bReadOnly ) return hr; - // Find the text limit. (Add one for NULL terminator) + // Find the text limit. (Add one for nullptr terminator) //m_uTextLimit = min( XuiEditGetTextLimit(m_hObj) + 1, XUI_4JEDIT_MAX_CHARS); if((((pInputData->dwKeyCode == VK_PAD_A) && (pInputData->wch == 0)) || (pInputData->dwKeyCode == VK_PAD_START)) && !(pInputData->dwFlags & XUI_INPUT_FLAG_REPEAT)) diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JIcon.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JIcon.cpp index 8895b60e3..a4ff8d376 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JIcon.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JIcon.cpp @@ -3,7 +3,7 @@ HRESULT CXuiCtrl4JIcon::OnInit(XUIMessageInit *pInitData, BOOL& bHandled) { - m_hBrush=NULL; + m_hBrush=nullptr; return S_OK; } diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JList.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JList.cpp index 15695fd6d..7523c523f 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_4JList.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_4JList.cpp @@ -7,7 +7,7 @@ HRESULT CXuiCtrl4JList::OnInit(XUIMessageInit *pInitData, BOOL& bHandled) { InitializeCriticalSection(&m_AccessListData); - m_hSelectionChangedHandlerObj = NULL; + m_hSelectionChangedHandlerObj = nullptr; return S_OK; } @@ -315,7 +315,7 @@ HRESULT CXuiCtrl4JList::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourc { // Check for a brush EnterCriticalSection(&m_AccessListData); - if(GetData(pGetSourceImageData->iItem).hXuiBrush!=NULL) + if(GetData(pGetSourceImageData->iItem).hXuiBrush!=nullptr) { pGetSourceImageData->hBrush=GetData(pGetSourceImageData->iItem).hXuiBrush; } diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_BrewProgress.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_BrewProgress.cpp index 69f775d49..e74b92b4b 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_BrewProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_BrewProgress.cpp @@ -10,7 +10,7 @@ int CXuiCtrlBrewProgress::GetValue() void* pvUserData; this->GetUserData( &pvUserData ); - if( pvUserData != NULL ) + if( pvUserData != nullptr ) { BrewingStandTileEntity *pBrewingStandTileEntity = static_cast(pvUserData); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_BubblesProgress.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_BubblesProgress.cpp index 981f49960..48a130c42 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_BubblesProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_BubblesProgress.cpp @@ -8,7 +8,7 @@ int CXuiCtrlBubblesProgress::GetValue() void* pvUserData; this->GetUserData( &pvUserData ); - if( pvUserData != NULL ) + if( pvUserData != nullptr ) { BrewingStandTileEntity *pBrewingStandTileEntity = static_cast(pvUserData); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_BurnProgress.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_BurnProgress.cpp index b618f8c6d..5a1a36743 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_BurnProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_BurnProgress.cpp @@ -10,7 +10,7 @@ int CXuiCtrlBurnProgress::GetValue() void* pvUserData; this->GetUserData( &pvUserData ); - if( pvUserData != NULL ) + if( pvUserData != nullptr ) { FurnaceTileEntity *pFurnaceTileEntity = static_cast(pvUserData); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp index 82b6c3eda..46bcc9831 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp @@ -11,7 +11,7 @@ CXuiCtrlCraftIngredientSlot::CXuiCtrlCraftIngredientSlot() { m_iID=0; - m_Desc=NULL; + m_Desc=nullptr; m_isFoil = false; m_isDirty = false; m_item = nullptr; @@ -29,7 +29,7 @@ HRESULT CXuiCtrlCraftIngredientSlot::OnInit(XUIMessageInit* pInitData, BOOL& rfH //----------------------------------------------------------------------------- HRESULT CXuiCtrlCraftIngredientSlot::OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled) { - if( m_iID != 0 || m_item != NULL ) + if( m_iID != 0 || m_item != nullptr ) { pData->item = m_item; pData->iItemBitField = MAKE_SLOTDISPLAY_ITEM_BITMASK(m_iID,m_iAuxVal,m_isFoil); @@ -94,7 +94,7 @@ void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCo void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, BOOL bShow) { - if(item == NULL) SetIcon(iPad, 0,0,0,0,0,false,false,bShow); + if(item == nullptr) SetIcon(iPad, 0,0,0,0,0,false,false,bShow); else { m_item = item; @@ -118,6 +118,6 @@ void CXuiCtrlCraftIngredientSlot::SetDescription(LPCWSTR Desc) hr=GetVisual(&hObj); XuiElementGetChildById(hObj,L"text_name",&hObjChild); XuiControlSetText(hObjChild,Desc); - XuiElementSetShow(hObjChild,Desc==NULL?FALSE:TRUE); + XuiElementSetShow(hObjChild,Desc==nullptr?FALSE:TRUE); m_Desc=Desc; } \ No newline at end of file diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp index 050fcdc41..9a312287e 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp @@ -28,9 +28,9 @@ HRESULT CXuiCtrlEnchantmentButton::OnInit(XUIMessageInit* pInitData, BOOL& rfHan { XuiElementGetParent(parent,&parent); currentClass = XuiGetObjectClass( parent ); - } while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); + } while (parent != nullptr && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); - assert( parent != NULL ); + assert( parent != nullptr ); VOID *pObj; XuiObjectFromHandle( parent, &pObj ); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp index 584cbe661..a83b7811e 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp @@ -35,7 +35,7 @@ CXuiCtrlEnchantmentBook::CXuiCtrlEnchantmentBook() : m_fScreenHeight=static_cast(pMinecraft->height_phys); m_fRawHeight=static_cast(ssc.rawHeight); - model = NULL; + model = nullptr; time = 0; flip = oFlip = flipT = flipA = 0.0f; @@ -44,7 +44,7 @@ CXuiCtrlEnchantmentBook::CXuiCtrlEnchantmentBook() : CXuiCtrlEnchantmentBook::~CXuiCtrlEnchantmentBook() { - //if(model != NULL) delete model; + //if(model != nullptr) delete model; } //----------------------------------------------------------------------------- @@ -60,9 +60,9 @@ HRESULT CXuiCtrlEnchantmentBook::OnInit(XUIMessageInit* pInitData, BOOL& rfHandl { XuiElementGetParent(parent,&parent); currentClass = XuiGetObjectClass( parent ); - } while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); + } while (parent != nullptr && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); - assert( parent != NULL ); + assert( parent != nullptr ); VOID *pObj; XuiObjectFromHandle( parent, &pObj ); @@ -166,12 +166,12 @@ HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL &b glEnable(GL_CULL_FACE); - if(model == NULL) + if(model == nullptr) { // Share the model the the EnchantTableRenderer EnchantTableRenderer *etr = (EnchantTableRenderer*)TileEntityRenderDispatcher::instance->getRenderer(eTYPE_ENCHANTMENTTABLEENTITY); - if(etr != NULL) + if(etr != nullptr) { model = etr->bookModel; } @@ -181,7 +181,7 @@ HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL &b } } - model->render(NULL, 0, ff1, ff2, o, 0, 1 / 16.0f,true); + model->render(nullptr, 0, ff1, ff2, o, 0, 1 / 16.0f,true); glDisable(GL_CULL_FACE); glPopMatrix(); @@ -281,7 +281,7 @@ HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL &b // // glEnable(GL_RESCALE_NORMAL); // -// model.render(NULL, 0, ff1, ff2, o, 0, 1 / 16.0f,true); +// model.render(nullptr, 0, ff1, ff2, o, 0, 1 / 16.0f,true); // // glDisable(GL_RESCALE_NORMAL); // Lighting::turnOff(); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp index a7700e79c..ecb6132d7 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp @@ -38,9 +38,9 @@ HRESULT CXuiCtrlEnchantmentButtonText::OnInit(XUIMessageInit* pInitData, BOOL& r { XuiElementGetParent(parent,&parent); currentClass = XuiGetObjectClass( parent ); - } while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); + } while (parent != nullptr && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); - assert( parent != NULL ); + assert( parent != nullptr ); VOID *pObj; XuiObjectFromHandle( parent, &pObj ); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_FireProgress.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_FireProgress.cpp index 35b9d534e..3d55db197 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_FireProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_FireProgress.cpp @@ -10,7 +10,7 @@ int CXuiCtrlFireProgress::GetValue() void* pvUserData; this->GetUserData( &pvUserData ); - if( pvUserData != NULL ) + if( pvUserData != nullptr ) { FurnaceTileEntity *pFurnaceTileEntity = static_cast(pvUserData); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp index 7af2ea389..98ff1c267 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp @@ -41,9 +41,9 @@ HRESULT CXuiCtrlMinecraftPlayer::OnInit(XUIMessageInit* pInitData, BOOL& rfHandl { XuiElementGetParent(parent,&parent); currentClass = XuiGetObjectClass( parent ); - } while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); + } while (parent != nullptr && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); - assert( parent != NULL ); + assert( parent != nullptr ); VOID *pObj; XuiObjectFromHandle( parent, &pObj ); @@ -116,7 +116,7 @@ HRESULT CXuiCtrlMinecraftPlayer::OnRender(XUIMessageRender *pRenderData, BOOL &b // // for(int i=0;ilocalplayers[i] != NULL) +// if(pMinecraft->localplayers[i] != nullptr) // { // iPlayerC++; // } diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp index ffa386a06..1fa44d3f7 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.cpp @@ -62,7 +62,7 @@ CXuiCtrlMinecraftSkinPreview::CXuiCtrlMinecraftSkinPreview() : m_fOriginalRotation = 0.0f; m_framesAnimatingRotation = 0; m_bAnimatingToFacing = false; - m_pvAdditionalModelParts=NULL; + m_pvAdditionalModelParts=nullptr; m_uiAnimOverrideBitmask=0L; } @@ -249,7 +249,7 @@ HRESULT CXuiCtrlMinecraftSkinPreview::OnRender(XUIMessageRender *pRenderData, BO //EntityRenderDispatcher::instance->render(pMinecraft->localplayers[0], 0, 0, 0, 0, 1); EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); - if (renderer != NULL) + if (renderer != nullptr) { // 4J-PB - any additional parts to turn on for this player (skin dependent) //vector *pAdditionalModelParts=mob->GetAdditionalModelParts(); @@ -297,9 +297,9 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do HumanoidModel *model = static_cast(renderer->getModel()); //getAttackAnim(mob, a); - //if (armor != NULL) armor->attackTime = model->attackTime; + //if (armor != nullptr) armor->attackTime = model->attackTime; //model->riding = mob->isRiding(); - //if (armor != NULL) armor->riding = model->riding; + //if (armor != nullptr) armor->riding = model->riding; // 4J Stu - Remember to reset these values once the rendering is done if you add another one model->attackTime = 0; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp index a61ca6459..49217c5cd 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp @@ -40,7 +40,7 @@ LPCWSTR CXuiCtrlMinecraftSlot::xzpIcons[15]= //----------------------------------------------------------------------------- CXuiCtrlMinecraftSlot::CXuiCtrlMinecraftSlot() : - //m_hBrush(NULL), + //m_hBrush(nullptr), m_bDirty(FALSE), m_iPassThroughDataAssociation(0), m_iPassThroughIdAssociation(0), @@ -60,7 +60,7 @@ CXuiCtrlMinecraftSlot::CXuiCtrlMinecraftSlot() : Minecraft *pMinecraft=Minecraft::GetInstance(); - if(pMinecraft != NULL) + if(pMinecraft != nullptr) { m_fScreenWidth=static_cast(pMinecraft->width_phys); m_fScreenHeight=static_cast(pMinecraft->height_phys); @@ -109,7 +109,7 @@ HRESULT CXuiCtrlMinecraftSlot::OnGetSourceImage(XUIMessageGetSourceImage* pData, pData->szPath = MsgGetSlotItem.szPath; pData->bDirty = MsgGetSlotItem.bDirty; - if(MsgGetSlotItem.item != NULL) + if(MsgGetSlotItem.item != nullptr) { m_item = MsgGetSlotItem.item; m_iID = m_item->id; @@ -145,7 +145,7 @@ HRESULT CXuiCtrlMinecraftSlot::OnGetSourceImage(XUIMessageGetSourceImage* pData, pData->szPath = xzpIcons[m_iID-32000]; } - if(m_item != NULL && (m_item->id != m_iID || m_item->getAuxValue() != m_iAuxVal || m_item->GetCount() != m_iCount) ) m_item = nullptr; + if(m_item != nullptr && (m_item->id != m_iID || m_item->getAuxValue() != m_iAuxVal || m_item->GetCount() != m_iCount) ) m_item = nullptr; } @@ -184,11 +184,11 @@ HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHa hr = XuiSendMessage(m_hObj, &Message); // We cannot have an Item with id 0 - if(m_item != NULL || (m_iID > 0 && m_iID<32000) ) + if(m_item != nullptr || (m_iID > 0 && m_iID<32000) ) { HXUIDC hDC = pRenderData->hDC; CXuiControl xuiControl(m_hObj); - if(m_item == NULL) m_item = shared_ptr( new ItemInstance(m_iID, m_iCount, m_iAuxVal) ); + if(m_item == nullptr) m_item = shared_ptr( new ItemInstance(m_iID, m_iCount, m_iAuxVal) ); // build and render with the game call @@ -225,7 +225,7 @@ HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHa if(!m_bScreenWidthSetup) { Minecraft *pMinecraft=Minecraft::GetInstance(); - if(pMinecraft != NULL) + if(pMinecraft != nullptr) { m_fScreenWidth=static_cast(pMinecraft->width_phys); m_fScreenHeight=static_cast(pMinecraft->height_phys); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MobEffect.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MobEffect.cpp index 23b225738..6a76980dd 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MobEffect.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MobEffect.cpp @@ -38,9 +38,9 @@ HRESULT CXuiCtrlMobEffect::OnGetSourceDataText(XUIMessageGetSourceText *pGetSour pGetSourceTextData->szText = m_name.c_str(); pGetSourceTextData->bDisplay = TRUE; - if(FAILED(PlayVisualRange(iconFrameNames[m_icon],NULL,iconFrameNames[m_icon]))) + if(FAILED(PlayVisualRange(iconFrameNames[m_icon],nullptr,iconFrameNames[m_icon]))) { - PlayVisualRange(L"Normal",NULL,L"Normal"); + PlayVisualRange(L"Normal",nullptr,L"Normal"); } bHandled = TRUE; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_SliderWrapper.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_SliderWrapper.cpp index d52d560e7..18995854c 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_SliderWrapper.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_SliderWrapper.cpp @@ -119,7 +119,7 @@ HRESULT CXuiCtrlSliderWrapper::SetValueDisplay( BOOL bShow ) hr=XuiControlGetVisual(pThis->m_pSlider->m_hObj,&hVisual); hr=XuiElementGetChildById(hVisual,L"Text_Value",&hText); - if(hText!=NULL) + if(hText!=nullptr) { XuiElementSetShow(hText,bShow); } @@ -132,7 +132,7 @@ LPCWSTR CXuiCtrlSliderWrapper::GetText( ) CXuiCtrlSliderWrapper *pThis; HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis); if (FAILED(hr)) - return NULL; + return nullptr; return pThis->m_pSlider->GetText(); //return S_OK; } @@ -159,7 +159,7 @@ HXUIOBJ CXuiCtrlSliderWrapper::GetSlider() CXuiCtrlSliderWrapper *pThis; HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis); if (FAILED(hr)) - return NULL; + return nullptr; return pThis->m_pSlider->m_hObj; } diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp index 5c820fb5f..8a45d6fcb 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.cpp @@ -26,7 +26,7 @@ HRESULT CXuiCtrlSlotItemCtrlBase::OnDestroy( HXUIOBJ hObj ) void* pvUserData; hr = XuiElementGetUserData( hObj, &pvUserData ); - if( pvUserData != NULL ) + if( pvUserData != nullptr ) { delete pvUserData; } @@ -43,17 +43,17 @@ HRESULT CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem(HXUIOBJ hObj, Cust SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); - if( pUserDataContainer->slot != NULL ) + if( pUserDataContainer->slot != nullptr ) { item = pUserDataContainer->slot->getItem(); } else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT) { shared_ptr player = dynamic_pointer_cast( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] ); - if(player != NULL) item = player->inventory->getCarried(); + if(player != nullptr) item = player->inventory->getCarried(); } - if( item != NULL ) + if( item != nullptr ) { pData->item = item; pData->iItemBitField = MAKE_SLOTDISPLAY_ITEM_BITMASK(item->id,item->getAuxValue(),item->isFoil()); @@ -113,14 +113,14 @@ bool CXuiCtrlSlotItemCtrlBase::isEmpty( HXUIOBJ hObj ) XuiElementGetUserData( hObj, &pvUserData ); SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); - if(pUserDataContainer->slot != NULL) + if(pUserDataContainer->slot != nullptr) { return !pUserDataContainer->slot->hasItem(); } else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT) { shared_ptr player = dynamic_pointer_cast( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] ); - if(player != NULL) return player->inventory->getCarried() == NULL; + if(player != nullptr) return player->inventory->getCarried() == nullptr; } return true; @@ -132,7 +132,7 @@ wstring CXuiCtrlSlotItemCtrlBase::GetItemDescription( HXUIOBJ hObj, vector(pvUserData); - if(pUserDataContainer->slot != NULL) + if(pUserDataContainer->slot != nullptr) { wstring desc = L""; vector *strings = pUserDataContainer->slot->getItem()->getHoverText(Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad], false, unformattedStrings); @@ -167,10 +167,10 @@ wstring CXuiCtrlSlotItemCtrlBase::GetItemDescription( HXUIOBJ hObj, vectorm_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT) { shared_ptr player = dynamic_pointer_cast( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] ); - if(player != NULL) + if(player != nullptr) { shared_ptr item = player->inventory->getCarried(); - if(item != NULL) return app.GetString( item->getDescriptionId() ); + if(item != nullptr) return app.GetString( item->getDescriptionId() ); } } @@ -183,14 +183,14 @@ shared_ptr CXuiCtrlSlotItemCtrlBase::getItemInstance( HXUIOBJ hObj XuiElementGetUserData( hObj, &pvUserData ); SlotControlUserDataContainer* pUserDataContainer = static_cast(pvUserData); - if(pUserDataContainer->slot != NULL) + if(pUserDataContainer->slot != nullptr) { return pUserDataContainer->slot->getItem(); } else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT) { shared_ptr player = dynamic_pointer_cast( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] ); - if(player != NULL) return player->inventory->getCarried(); + if(player != nullptr) return player->inventory->getCarried(); } return nullptr; @@ -258,7 +258,7 @@ int CXuiCtrlSlotItemCtrlBase::GetObjectCount( HXUIOBJ hObj ) int iCount = 0; - if(pUserDataContainer->slot != NULL) + if(pUserDataContainer->slot != nullptr) { if ( pUserDataContainer->slot->hasItem() ) { @@ -268,7 +268,7 @@ int CXuiCtrlSlotItemCtrlBase::GetObjectCount( HXUIOBJ hObj ) else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT) { shared_ptr player = dynamic_pointer_cast( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] ); - if(player != NULL && player->inventory->getCarried() != NULL) + if(player != nullptr && player->inventory->getCarried() != nullptr) { iCount = player->inventory->getCarried()->count; } @@ -296,7 +296,7 @@ bool CXuiCtrlSlotItemCtrlBase::IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj XuiElementGetUserData( hThisObj, &pvThisUserData ); SlotControlUserDataContainer* pThisUserDataContainer = static_cast(pvThisUserData); - if(pThisUserDataContainer->slot != NULL) + if(pThisUserDataContainer->slot != nullptr) { if ( pThisUserDataContainer->slot->hasItem() ) { @@ -309,7 +309,7 @@ bool CXuiCtrlSlotItemCtrlBase::IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj else if(pThisUserDataContainer->m_iPad >= 0 && pThisUserDataContainer->m_iPad < XUSER_MAX_COUNT) { shared_ptr player = dynamic_pointer_cast( Minecraft::GetInstance()->localplayers[pThisUserDataContainer->m_iPad] ); - if(player != NULL && player->inventory->getCarried() != NULL) + if(player != nullptr && player->inventory->getCarried() != nullptr) { iThisID = player->inventory->getCarried()->id; iThisAux = player->inventory->getCarried()->getAuxValue(); @@ -324,7 +324,7 @@ bool CXuiCtrlSlotItemCtrlBase::IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj XuiElementGetUserData( hOtherObj, &pvOtherUserData ); SlotControlUserDataContainer* pOtherUserDataContainer = static_cast(pvOtherUserData); - if(pOtherUserDataContainer->slot != NULL) + if(pOtherUserDataContainer->slot != nullptr) { if ( pOtherUserDataContainer->slot->hasItem() ) { @@ -336,7 +336,7 @@ bool CXuiCtrlSlotItemCtrlBase::IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj else if(pOtherUserDataContainer->m_iPad >= 0 && pOtherUserDataContainer->m_iPad < XUSER_MAX_COUNT) { shared_ptr player = dynamic_pointer_cast( Minecraft::GetInstance()->localplayers[pOtherUserDataContainer->m_iPad] ); - if(player != NULL && player->inventory->getCarried() != NULL) + if(player != nullptr && player->inventory->getCarried() != nullptr) { iOtherID = player->inventory->getCarried()->id; iOtherAux = player->inventory->getCarried()->getAuxValue(); @@ -369,7 +369,7 @@ int CXuiCtrlSlotItemCtrlBase::GetEmptyStackSpace( HXUIOBJ hObj ) int iMaxStackSize = 0; bool bStackable = false; - if(pUserDataContainer->slot != NULL) + if(pUserDataContainer->slot != nullptr) { if ( pUserDataContainer->slot->hasItem() ) { diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.h b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.h index 2fd217494..ac237ac92 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.h +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.h @@ -9,7 +9,7 @@ class ItemInstance; class SlotControlUserDataContainer { public: - SlotControlUserDataContainer() : slot( NULL ), hProgressBar( NULL ), m_iPad( -1 ), m_fAlpha(1.0f) {}; + SlotControlUserDataContainer() : slot( nullptr ), hProgressBar( nullptr ), m_iPad( -1 ), m_fAlpha(1.0f) {}; Slot* slot; HXUIOBJ hProgressBar; float m_fAlpha; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotList.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotList.cpp index 67accbe25..a34f2a7e4 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotList.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotList.cpp @@ -103,7 +103,7 @@ void CXuiCtrlSlotList::SetData(int m_iPad, AbstractContainerMenu* menu, int rows slotControl->SetUserIndex( slotControl->m_hObj, m_iPad ); - slotControl = NULL; + slotControl = nullptr; } } diff --git a/Minecraft.Client/Common/XUI/XUI_CustomMessages.h b/Minecraft.Client/Common/XUI/XUI_CustomMessages.h index cd5e28652..e16f891c3 100644 --- a/Minecraft.Client/Common/XUI/XUI_CustomMessages.h +++ b/Minecraft.Client/Common/XUI/XUI_CustomMessages.h @@ -43,7 +43,7 @@ static __declspec(noinline) void CustomMessage_GetSlotItem(XUIMessage *pMsg, Cus pData->item = nullptr; pData->iDataBitField = iDataBitField; pData->iItemBitField = iItemBitField; - pData->szPath = NULL; + pData->szPath = nullptr; pData->bDirty = false; } diff --git a/Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp b/Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp index e65f5a923..c5150249a 100644 --- a/Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DLCOffers.cpp @@ -187,9 +187,9 @@ HRESULT CScene_DLCOffers::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) m_iType = param->iType; m_iOfferC = app.GetDLCOffersCount(); m_bIsFemale = false; - m_pNoImageFor_DLC=NULL; + m_pNoImageFor_DLC=nullptr; bNoDLCToDisplay=true; - //hCostText=NULL; + //hCostText=nullptr; // 4J JEV: Deleting this here seems simpler. @@ -203,10 +203,10 @@ HRESULT CScene_DLCOffers::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) HRESULT hRes; - hRes=XAvatarInitialize(XAVATAR_COORDINATE_SYSTEM_LEFT_HANDED,0,0,0,NULL); + hRes=XAvatarInitialize(XAVATAR_COORDINATE_SYSTEM_LEFT_HANDED,0,0,0,nullptr); // get the avatar gender - hRes=XAvatarGetMetadataLocalUser(m_iPad,&AvatarMetadata,NULL); + hRes=XAvatarGetMetadataLocalUser(m_iPad,&AvatarMetadata,nullptr); m_bIsFemale= (XAVATAR_BODY_TYPE_FEMALE == XAvatarMetadataGetBodyType(&AvatarMetadata)); // shutdown the avatar system @@ -223,7 +223,7 @@ HRESULT CScene_DLCOffers::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) m_bIgnorePress=true; VOID *pObj; - m_hXuiBrush=NULL; + m_hXuiBrush=nullptr; XuiObjectFromHandle( m_List, &pObj ); m_pOffersList = static_cast(pObj); @@ -259,13 +259,13 @@ HRESULT CScene_DLCOffers::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) { - CXuiCtrl4JList::LIST_ITEM_INFO *pListInfo=NULL; + CXuiCtrl4JList::LIST_ITEM_INFO *pListInfo=nullptr; //XMARKETPLACE_CONTENTOFFER_INFO xOffer; XMARKETPLACE_CURRENCY_CONTENTOFFER_INFO xOffer; const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; ZeroMemory(szResourceLocator,sizeof(WCHAR)*LOCATOR_SIZE); - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); int iCount=0; if(bUpdateOnly) // Just update the info on the current list @@ -275,13 +275,13 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) xOffer = StorageManager.GetOffer(i); // Check that this is in the list of known DLC DLC_INFO *pDLC=app.GetDLCInfoForFullOfferID(xOffer.qwOfferID); - if(pDLC==NULL) + if(pDLC==nullptr) { // try the trial version pDLC=app.GetDLCInfoForTrialOfferID(xOffer.qwOfferID); } - if(pDLC==NULL) + if(pDLC==nullptr) { // skip this one #ifdef _DEBUG @@ -343,13 +343,13 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) // Check that this is in the list of known DLC DLC_INFO *pDLC=app.GetDLCInfoForFullOfferID(xOffer.qwOfferID); - if(pDLC==NULL) + if(pDLC==nullptr) { // try the trial version pDLC=app.GetDLCInfoForTrialOfferID(xOffer.qwOfferID); } - if(pDLC==NULL) + if(pDLC==nullptr) { // skip this one #ifdef _DEBUG @@ -447,9 +447,9 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) m_pOffersList->SetCurSelVisible(0); DLC_INFO *dlc = app.GetDLCInfoForFullOfferID(xOffer.qwOfferID); - if (dlc != NULL) + if (dlc != nullptr) { - BYTE *pData=NULL; + BYTE *pData=nullptr; UINT uiSize=0; DWORD dwSize=0; @@ -460,7 +460,7 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) if(iIndex!=-1) { // it's in the xzp - if(m_hXuiBrush!=NULL) + if(m_hXuiBrush!=nullptr) { XuiDestroyBrush(m_hXuiBrush); // clear the TMS XZP vector memory @@ -480,7 +480,7 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) } else { - if(m_hXuiBrush!=NULL) + if(m_hXuiBrush!=nullptr) { XuiDestroyBrush(m_hXuiBrush); // clear the TMS XZP vector memory @@ -568,7 +568,7 @@ HRESULT CScene_DLCOffers::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* p // if it's already been purchased, we need to let the user download it anyway { ullIndexA[0]=StorageManager.GetOffer(ItemInfo.iData).qwOfferID; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } @@ -662,7 +662,7 @@ HRESULT CScene_DLCOffers::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelCha // reset the image monitor, but not for the first selection if(pNotifySelChangedData->iOldItem!=-1) { - m_pNoImageFor_DLC=NULL; + m_pNoImageFor_DLC=nullptr; } if (m_List.TreeHasFocus())// && offerIndexes.size() > index) @@ -695,14 +695,14 @@ HRESULT CScene_DLCOffers::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelCha m_PriceTag.SetText(xOffer.wszCurrencyPrice); DLC_INFO *dlc = app.GetDLCInfoForTrialOfferID(xOffer.qwOfferID); - if(dlc==NULL) + if(dlc==nullptr) { dlc = app.GetDLCInfoForFullOfferID(xOffer.qwOfferID); } - if (dlc != NULL) + if (dlc != nullptr) { - BYTE *pImage=NULL; + BYTE *pImage=nullptr; UINT uiSize=0; DWORD dwSize=0; @@ -713,7 +713,7 @@ HRESULT CScene_DLCOffers::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelCha if(iIndex!=-1) { // it's in the xzp - if(m_hXuiBrush!=NULL) + if(m_hXuiBrush!=nullptr) { XuiDestroyBrush(m_hXuiBrush); // clear the TMS XZP vector memory @@ -737,7 +737,7 @@ HRESULT CScene_DLCOffers::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelCha } else { - if(m_hXuiBrush!=NULL) + if(m_hXuiBrush!=nullptr) { XuiDestroyBrush(m_hXuiBrush); // clear the TMS XZP vector memory @@ -750,13 +750,13 @@ HRESULT CScene_DLCOffers::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelCha } else { - if(m_hXuiBrush!=NULL) + if(m_hXuiBrush!=nullptr) { XuiDestroyBrush(m_hXuiBrush); // clear the TMS XZP vector memory //app.FreeLocalTMSFiles(); - m_hXuiBrush=NULL; + m_hXuiBrush=nullptr; } } @@ -802,7 +802,7 @@ HRESULT CScene_DLCOffers::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled) } // Check for any TMS image we're waiting for - if(m_pNoImageFor_DLC!=NULL) + if(m_pNoImageFor_DLC!=nullptr) { // Is it present now? WCHAR *cString = m_pNoImageFor_DLC->wchBanner; @@ -811,10 +811,10 @@ HRESULT CScene_DLCOffers::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled) if(bPresent) { - BYTE *pImage=NULL; + BYTE *pImage=nullptr; DWORD dwSize=0; - if(m_hXuiBrush!=NULL) + if(m_hXuiBrush!=nullptr) { XuiDestroyBrush(m_hXuiBrush); // clear the TMS XZP vector memory @@ -822,7 +822,7 @@ HRESULT CScene_DLCOffers::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled) } app.GetMemFileDetails(cString,&pImage,&dwSize); XuiCreateTextureBrushFromMemory(pImage,dwSize,&m_hXuiBrush); - m_pNoImageFor_DLC=NULL; + m_pNoImageFor_DLC=nullptr; } } diff --git a/Minecraft.Client/Common/XUI/XUI_Death.cpp b/Minecraft.Client/Common/XUI/XUI_Death.cpp index e4c786f26..1788ceffd 100644 --- a/Minecraft.Client/Common/XUI/XUI_Death.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Death.cpp @@ -59,7 +59,7 @@ HRESULT CScene_Death::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChange XuiSetLocale( Languages[curSel].pszLanguagePath ); // Apply the locale to the main scene. - XuiApplyLocale( m_hObj, NULL ); + XuiApplyLocale( m_hObj, nullptr ); // Update the text for the current value. m_Value.SetText( m_List.GetText( curSel ) );*/ @@ -105,7 +105,7 @@ HRESULT CScene_Death::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNoti if(pNotifyPressData->UserIndex==ProfileManager.GetPrimaryPad()) { int playTime = -1; - if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) + if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } diff --git a/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp b/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp index e4565acbf..01a4b573b 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp @@ -18,9 +18,9 @@ HRESULT CScene_DebugItemEditor::OnInit( XUIMessageInit *pInitData, BOOL &bHandle m_iPad = initData->iPad; m_slot = initData->slot; m_menu = initData->menu; - if(m_slot != NULL) m_item = m_slot->getItem(); + if(m_slot != nullptr) m_item = m_slot->getItem(); - if(m_item!=NULL) + if(m_item!=nullptr) { m_icon->SetIcon(m_iPad, m_item->id,m_item->getAuxValue(),m_item->count,10,31,false,m_item->isFoil()); m_itemName.SetText( app.GetString( Item::items[m_item->id]->getDescriptionId(m_item) ) ); @@ -54,13 +54,13 @@ HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfH case VK_PAD_START: case VK_PAD_BACK: // We need to send a packet to the server to update it's representation of this item - if(m_slot != NULL && m_menu != NULL) + if(m_slot != nullptr && m_menu != nullptr) { m_slot->set(m_item); Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player != NULL && player->connection) player->connection->send( shared_ptr( new ContainerSetSlotPacket(m_menu->containerId, m_slot->index, m_item) ) ); + if(player != nullptr && player->connection) player->connection->send( shared_ptr( new ContainerSetSlotPacket(m_menu->containerId, m_slot->index, m_item) ) ); } // kill the crafting xui app.NavigateBack(m_iPad); @@ -76,7 +76,7 @@ HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfH HRESULT CScene_DebugItemEditor::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled) { - if(m_item == NULL) m_item = shared_ptr( new ItemInstance(0,1,0) ); + if(m_item == nullptr) m_item = shared_ptr( new ItemInstance(0,1,0) ); if(hObjSource == m_itemId) { int id = 0; @@ -84,7 +84,7 @@ HRESULT CScene_DebugItemEditor::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINot if(!value.empty()) id = _fromString( value ); // TODO Proper validation of the valid item ids - if(id > 0 && Item::items[id] != NULL) m_item->id = id; + if(id > 0 && Item::items[id] != nullptr) m_item->id = id; } else if(hObjSource == m_itemAuxValue) { diff --git a/Minecraft.Client/Common/XUI/XUI_DebugOverlay.cpp b/Minecraft.Client/Common/XUI/XUI_DebugOverlay.cpp index 7c3d491ca..338eb853c 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugOverlay.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugOverlay.cpp @@ -37,7 +37,7 @@ HRESULT CScene_DebugOverlay::OnInit( XUIMessageInit *pInitData, BOOL &bHandled ) for(unsigned int i = 0; i < Item::items.length; ++i) { - if(Item::items[i] != NULL) + if(Item::items[i] != nullptr) { //m_items.InsertItems(m_items.GetItemCount(),1); m_itemIds.push_back(i); @@ -148,7 +148,7 @@ HRESULT CScene_DebugOverlay::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress /*else if( hObjPressed == m_saveToDisc ) // 4J-JEV: Doesn't look like we use this debug option anymore. { #ifndef _CONTENT_PACKAGE - pMinecraft->level->save(true, NULL); + pMinecraft->level->save(true, nullptr); int radius; m_chunkRadius.GetValue(&radius); @@ -166,7 +166,7 @@ HRESULT CScene_DebugOverlay::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress { #ifndef _CONTENT_PACKAGE // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); HXUIOBJ hScene; HRESULT hr; @@ -175,7 +175,7 @@ HRESULT CScene_DebugOverlay::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress WCHAR szResourceLocator[ LOCATOR_SIZE ]; swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/"); - hr = XuiSceneCreate(szResourceLocator,app.GetSceneName(eUIScene_DebugCreateSchematic,false, false), NULL, &hScene); + hr = XuiSceneCreate(szResourceLocator,app.GetSceneName(eUIScene_DebugCreateSchematic,false, false), nullptr, &hScene); this->NavigateForward(hScene); //app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic); #endif @@ -184,7 +184,7 @@ HRESULT CScene_DebugOverlay::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress { #ifndef _CONTENT_PACKAGE // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); HXUIOBJ hScene; HRESULT hr; @@ -193,7 +193,7 @@ HRESULT CScene_DebugOverlay::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress WCHAR szResourceLocator[ LOCATOR_SIZE ]; swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/"); - hr = XuiSceneCreate(szResourceLocator,app.GetSceneName(eUIScene_DebugSetCamera, false, false), NULL, &hScene); + hr = XuiSceneCreate(szResourceLocator,app.GetSceneName(eUIScene_DebugSetCamera, false, false), nullptr, &hScene); this->NavigateForward(hScene); //app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic); #endif @@ -274,7 +274,7 @@ HRESULT CScene_DebugOverlay::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotify HRESULT CScene_DebugOverlay::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled ) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->level != NULL) + if(pMinecraft->level != nullptr) { m_setTime.SetValue( pMinecraft->level->getLevelData()->getTime() % 24000 ); m_setFov.SetValue( static_cast(pMinecraft->gameRenderer->GetFovVal())); @@ -301,14 +301,14 @@ void CScene_DebugOverlay::SaveLimitedFile(int chunkRadius) ConsoleSaveFile *currentSave = pMinecraft->level->getLevelStorage()->getSaveFile(); // With a size of 0 but a value in the data pointer we should create a new save - ConsoleSaveFileOriginal newSave( currentSave->getFilename(), NULL, 0, true ); + ConsoleSaveFileOriginal newSave( currentSave->getFilename(), nullptr, 0, true ); // TODO Make this only happen for the new save //SetSpawnToPlayerPos(); FileEntry *origFileEntry = currentSave->createFile( wstring( L"level.dat" ) ); byteArray levelData( origFileEntry->getFileSize() ); DWORD bytesRead; - currentSave->setFilePointer(origFileEntry,0,NULL,FILE_BEGIN); + currentSave->setFilePointer(origFileEntry,0,nullptr,FILE_BEGIN); currentSave->readFile( origFileEntry, levelData.data, // data buffer @@ -331,10 +331,10 @@ void CScene_DebugOverlay::SaveLimitedFile(int chunkRadius) { for(int zPos = playerChunkZ - chunkRadius; zPos < playerChunkZ + chunkRadius; ++zPos) { - CompoundTag *chunkData=NULL; + CompoundTag *chunkData=nullptr; DataInputStream *is = RegionFileCache::getChunkDataInputStream(currentSave, L"", xPos, zPos); - if (is != NULL) + if (is != nullptr) { chunkData = NbtIo::read((DataInput *)is); is->deleteChildStream(); @@ -342,7 +342,7 @@ void CScene_DebugOverlay::SaveLimitedFile(int chunkRadius) } app.DebugPrintf("Processing chunk (%d, %d)\n", xPos, zPos); DataOutputStream *os = getChunkDataOutputStream(newFileCache, &newSave, L"", xPos, zPos); - if(os != NULL) + if(os != nullptr) { NbtIo::write(chunkData, os); os->close(); @@ -352,7 +352,7 @@ void CScene_DebugOverlay::SaveLimitedFile(int chunkRadius) os->deleteChildStream(); delete os; } - if(chunkData != NULL) + if(chunkData != nullptr) { delete chunkData; } @@ -367,13 +367,13 @@ RegionFile *CScene_DebugOverlay::getRegionFile(unordered_map>5) + L"." + std::to_wstring(chunkZ>>5) + L".mcr" ); - RegionFile *ref = NULL; + RegionFile *ref = nullptr; auto it = newFileCache.find(file); if( it != newFileCache.end() ) ref = it->second; // 4J Jev, put back in. - if (ref != NULL) + if (ref != nullptr) { return ref; } diff --git a/Minecraft.Client/Common/XUI/XUI_DebugSetCamera.cpp b/Minecraft.Client/Common/XUI/XUI_DebugSetCamera.cpp index 90046c4e9..fb6339ce2 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugSetCamera.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugSetCamera.cpp @@ -25,7 +25,7 @@ HRESULT CScene_DebugSetCamera::OnInit( XUIMessageInit *pInitData, BOOL &bHandled currentPosition->player = playerNo; Minecraft *pMinecraft = Minecraft::GetInstance(); - if (pMinecraft != NULL) + if (pMinecraft != nullptr) { Vec3 *vec = pMinecraft->localplayers[playerNo]->getPos(1.0); @@ -94,7 +94,7 @@ HRESULT CScene_DebugSetCamera::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHa NavigateBack(); //delete currentPosition; - //currentPosition = NULL; + //currentPosition = nullptr; rfHandled = TRUE; break; diff --git a/Minecraft.Client/Common/XUI/XUI_FullscreenProgress.cpp b/Minecraft.Client/Common/XUI/XUI_FullscreenProgress.cpp index bfa953e89..cc2359156 100644 --- a/Minecraft.Client/Common/XUI/XUI_FullscreenProgress.cpp +++ b/Minecraft.Client/Common/XUI/XUI_FullscreenProgress.cpp @@ -67,10 +67,10 @@ HRESULT CScene_FullscreenProgress::OnInit( XUIMessageInit* pInitData, BOOL& bHan // The framework calls this handler when the object is to be destroyed. HRESULT CScene_FullscreenProgress::OnDestroy() { - if( thread != NULL && thread != INVALID_HANDLE_VALUE ) + if( thread != nullptr && thread != INVALID_HANDLE_VALUE ) delete thread; - if( m_CompletionData != NULL ) + if( m_CompletionData != nullptr ) delete m_CompletionData; return S_OK; @@ -86,7 +86,7 @@ HRESULT CScene_FullscreenProgress::OnKeyDown(XUIMessageInput* pInputData, BOOL& case VK_PAD_B: case VK_ESCAPE: // 4J-JEV: Fix for Xbox360 #162749 - TU17: Save Upload: Content: UI: Player is presented with non-functional Tooltips after the Upload Save For Xbox One is completed. - if( m_cancelFunc != NULL && !m_threadCompleted ) + if( m_cancelFunc != nullptr && !m_threadCompleted ) { m_cancelFunc( m_cancelFuncParam ); m_bWasCancelled=true; @@ -244,7 +244,7 @@ HRESULT CScene_FullscreenProgress::OnTimer( XUIMessageTimer *pTimer, BOOL& bHand UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, IDS_CONNECTION_LOST_SERVER, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, IDS_CONNECTION_LOST_SERVER, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); app.NavigateToHomeMenu(); ui.UpdatePlayerBasePositions(); @@ -292,7 +292,7 @@ HRESULT CScene_FullscreenProgress::OnTimer( XUIMessageTimer *pTimer, BOOL& bHand CXuiSceneBase::ShowOtherPlayersBaseScene(iPad, true); // This just allows it to be shown Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true); + if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true); ui.UpdatePlayerBasePositions(); } break; diff --git a/Minecraft.Client/Common/XUI/XUI_HUD.cpp b/Minecraft.Client/Common/XUI/XUI_HUD.cpp index 90b929686..e188cbf68 100644 --- a/Minecraft.Client/Common/XUI/XUI_HUD.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HUD.cpp @@ -33,7 +33,7 @@ HRESULT CXuiSceneHud::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHa HRESULT CXuiSceneHud::OnCustomMessage_TickScene() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return S_OK; + if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return S_OK; ++m_tickCount; @@ -196,11 +196,11 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Full if(bHasPoison) { - m_healthIcon[icon].PlayVisualRange(L"FullPoisonFlash",NULL,L"FullPoisonFlash"); + m_healthIcon[icon].PlayVisualRange(L"FullPoisonFlash",nullptr,L"FullPoisonFlash"); } else { - m_healthIcon[icon].PlayVisualRange(L"FullFlash",NULL,L"FullFlash"); + m_healthIcon[icon].PlayVisualRange(L"FullFlash",nullptr,L"FullFlash"); } } else if (icon * 2 + 1 == iLastHealth || icon * 2 + 1 == iHealth) @@ -208,17 +208,17 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Half if(bHasPoison) { - m_healthIcon[icon].PlayVisualRange(L"HalfPoisonFlash",NULL,L"HalfPoisonFlash"); + m_healthIcon[icon].PlayVisualRange(L"HalfPoisonFlash",nullptr,L"HalfPoisonFlash"); } else { - m_healthIcon[icon].PlayVisualRange(L"HalfFlash",NULL,L"HalfFlash"); + m_healthIcon[icon].PlayVisualRange(L"HalfFlash",nullptr,L"HalfFlash"); } } else { // Empty - m_healthIcon[icon].PlayVisualRange(L"NormalFlash",NULL,L"NormalFlash"); + m_healthIcon[icon].PlayVisualRange(L"NormalFlash",nullptr,L"NormalFlash"); } } else @@ -228,11 +228,11 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Full if(bHasPoison) { - m_healthIcon[icon].PlayVisualRange(L"FullPoison",NULL,L"FullPoison"); + m_healthIcon[icon].PlayVisualRange(L"FullPoison",nullptr,L"FullPoison"); } else { - m_healthIcon[icon].PlayVisualRange(L"Full",NULL,L"Full"); + m_healthIcon[icon].PlayVisualRange(L"Full",nullptr,L"Full"); } } else if (icon * 2 + 1 == iHealth) @@ -240,17 +240,17 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Half if(bHasPoison) { - m_healthIcon[icon].PlayVisualRange(L"HalfPoison",NULL,L"HalfPoison"); + m_healthIcon[icon].PlayVisualRange(L"HalfPoison",nullptr,L"HalfPoison"); } else { - m_healthIcon[icon].PlayVisualRange(L"Half",NULL,L"Half"); + m_healthIcon[icon].PlayVisualRange(L"Half",nullptr,L"Half"); } } else { // Empty - m_healthIcon[icon].PlayVisualRange(L"Normal",NULL,L"Normal"); + m_healthIcon[icon].PlayVisualRange(L"Normal",nullptr,L"Normal"); } } @@ -288,11 +288,11 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Full if(hasHungerEffect) { - m_foodIcon[icon].PlayVisualRange(L"FullPoisonFlash",NULL,L"FullPoisonFlash"); + m_foodIcon[icon].PlayVisualRange(L"FullPoisonFlash",nullptr,L"FullPoisonFlash"); } else { - m_foodIcon[icon].PlayVisualRange(L"FullFlash",NULL,L"FullFlash"); + m_foodIcon[icon].PlayVisualRange(L"FullFlash",nullptr,L"FullFlash"); } } else if (icon * 2 + 1 == oldFood || icon * 2 + 1 == food) @@ -300,17 +300,17 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Half if(hasHungerEffect) { - m_foodIcon[icon].PlayVisualRange(L"HalfPoisonFlash",NULL,L"HalfPoisonFlash"); + m_foodIcon[icon].PlayVisualRange(L"HalfPoisonFlash",nullptr,L"HalfPoisonFlash"); } else { - m_foodIcon[icon].PlayVisualRange(L"HalfFlash",NULL,L"HalfFlash"); + m_foodIcon[icon].PlayVisualRange(L"HalfFlash",nullptr,L"HalfFlash"); } } else { // Empty - m_foodIcon[icon].PlayVisualRange(L"NormalFlash",NULL,L"NormalFlash"); + m_foodIcon[icon].PlayVisualRange(L"NormalFlash",nullptr,L"NormalFlash"); } } else @@ -320,11 +320,11 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Full if(hasHungerEffect) { - m_foodIcon[icon].PlayVisualRange(L"FullPoison",NULL,L"FullPoison"); + m_foodIcon[icon].PlayVisualRange(L"FullPoison",nullptr,L"FullPoison"); } else { - m_foodIcon[icon].PlayVisualRange(L"Full",NULL,L"Full"); + m_foodIcon[icon].PlayVisualRange(L"Full",nullptr,L"Full"); } } else if (icon * 2 + 1 == food) @@ -332,11 +332,11 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Half if(hasHungerEffect) { - m_foodIcon[icon].PlayVisualRange(L"HalfPoison",NULL,L"HalfPoison"); + m_foodIcon[icon].PlayVisualRange(L"HalfPoison",nullptr,L"HalfPoison"); } else { - m_foodIcon[icon].PlayVisualRange(L"Half",NULL,L"Half"); + m_foodIcon[icon].PlayVisualRange(L"Half",nullptr,L"Half"); } } else @@ -344,11 +344,11 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() // Empty if(hasHungerEffect) { - m_foodIcon[icon].PlayVisualRange(L"NormalPoison",NULL,L"NormalPoison"); + m_foodIcon[icon].PlayVisualRange(L"NormalPoison",nullptr,L"NormalPoison"); } else { - m_foodIcon[icon].PlayVisualRange(L"Normal",NULL,L"Normal"); + m_foodIcon[icon].PlayVisualRange(L"Normal",nullptr,L"Normal"); } } } @@ -377,9 +377,9 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() m_armourGroup.SetShow(TRUE); for (int icon = 0; icon < 10; icon++) { - if (icon * 2 + 1 < armor) m_armourIcon[icon].PlayVisualRange(L"Full",NULL,L"Full"); - else if (icon * 2 + 1 == armor) m_armourIcon[icon].PlayVisualRange(L"Half",NULL,L"Half"); - else if (icon * 2 + 1 > armor) m_armourIcon[icon].PlayVisualRange(L"Normal",NULL,L"Normal"); + if (icon * 2 + 1 < armor) m_armourIcon[icon].PlayVisualRange(L"Full",nullptr,L"Full"); + else if (icon * 2 + 1 == armor) m_armourIcon[icon].PlayVisualRange(L"Half",nullptr,L"Half"); + else if (icon * 2 + 1 > armor) m_armourIcon[icon].PlayVisualRange(L"Normal",nullptr,L"Normal"); } } else @@ -399,12 +399,12 @@ HRESULT CXuiSceneHud::OnCustomMessage_TickScene() if (icon < count) { m_airIcon[icon].SetShow(TRUE); - m_airIcon[icon].PlayVisualRange(L"Bubble",NULL,L"Bubble"); + m_airIcon[icon].PlayVisualRange(L"Bubble",nullptr,L"Bubble"); } else if(icon < count + extra) { m_airIcon[icon].SetShow(TRUE); - m_airIcon[icon].PlayVisualRange(L"Pop",NULL,L"Pop"); + m_airIcon[icon].PlayVisualRange(L"Pop",nullptr,L"Pop"); } else m_airIcon[icon].SetShow(FALSE); } @@ -428,7 +428,7 @@ HRESULT CXuiSceneHud::OnCustomMessage_DLCInstalled() { // mounted DLC may have changed bool bPauseMenuDisplayed=false; - bool bInGame=(Minecraft::GetInstance()->level!=NULL); + bool bInGame=(Minecraft::GetInstance()->level!=nullptr); // ignore this if we have menus up - they'll deal with it for(int i=0;i(pInitData->pvInitData); - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); MapChildControls(); XuiControlSetText(m_Buttons[BUTTON_HAO_CHANGESKIN],app.GetString(IDS_CHANGE_SKIN)); @@ -140,7 +140,7 @@ HRESULT CScene_HelpAndOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled /*HRESULT CScene_HelpAndOptions::OnTMSDLCFileRetrieved( ) { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); m_Timer.SetShow(FALSE); m_bIgnoreInput=false; @@ -253,7 +253,7 @@ HRESULT CScene_HelpAndOptions::OnControlNavigate(XUIMessageControlNavigate *pCon { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -344,7 +344,7 @@ HRESULT CScene_HelpAndOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHa HRESULT CScene_HelpAndOptions::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { @@ -414,7 +414,7 @@ HRESULT CScene_HelpAndOptions::OnTransitionStart( XUIMessageTransition *pTransit // 4J-PB - Going to resize buttons if the text is too big to fit on any of them (Br-pt problem with the length of Unlock Full Game) XUIRect xuiRect; - HXUIOBJ visual=NULL; + HXUIOBJ visual=nullptr; HXUIOBJ text; float fMaxTextLen=0.0f; float fTextVisualLen; diff --git a/Minecraft.Client/Common/XUI/XUI_HelpControls.cpp b/Minecraft.Client/Common/XUI/XUI_HelpControls.cpp index 5e72a8d1e..3c4e80a22 100644 --- a/Minecraft.Client/Common/XUI/XUI_HelpControls.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HelpControls.cpp @@ -93,7 +93,7 @@ HRESULT CScene_Controls::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); bool bSplitscreen=(app.GetLocalPlayerCount()>1); m_iCurrentTextIndex=0; m_bCreativeMode = !bNotInGame && Minecraft::GetInstance()->localplayers[m_iPad] && Minecraft::GetInstance()->localplayers[m_iPad]->abilities.mayfly; @@ -159,7 +159,7 @@ HRESULT CScene_Controls::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) controlDetailsA[i].vPos.y/=2.0f; } m_FigA[i].SetShow(FALSE); - m_TextPresenterA[i] = NULL; + m_TextPresenterA[i] = nullptr; } // fill out the layouts list @@ -172,7 +172,7 @@ HRESULT CScene_Controls::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) for(int i=0;i<3;i++) { ListInfo[i].pwszText=m_LayoutNameA[i]; - ListInfo[i].hXuiBrush=NULL; + ListInfo[i].hXuiBrush=nullptr; ListInfo[i].fEnabled=TRUE; m_pLayoutList->AddData(ListInfo[i]); } @@ -325,9 +325,9 @@ void CScene_Controls::PositionText(int iPad,int iTextID, unsigned char ucAction) XuiElementGetScale(hFigGroup,&vScale); // check the width of the control with the text set in it - if(m_TextPresenterA[m_iCurrentTextIndex]==NULL) + if(m_TextPresenterA[m_iCurrentTextIndex]==nullptr) { - HXUIOBJ hObj=NULL; + HXUIOBJ hObj=nullptr; HRESULT hr=XuiControlGetVisual(m_TextA[m_iCurrentTextIndex].m_hObj,&hObj); hr=XuiElementGetChildById(hObj,L"Text",&m_TextPresenterA[m_iCurrentTextIndex]); } @@ -452,9 +452,9 @@ void CScene_Controls::PositionTextDirect(int iPad,int iTextID, int iControlDetai XuiElementGetScale(hFigGroup,&vScale); // check the width of the control with the text set in it - if(m_TextPresenterA[m_iCurrentTextIndex]==NULL) + if(m_TextPresenterA[m_iCurrentTextIndex]==nullptr) { - HXUIOBJ hObj=NULL; + HXUIOBJ hObj=nullptr; HRESULT hr=XuiControlGetVisual(m_TextA[m_iCurrentTextIndex].m_hObj,&hObj); hr=XuiElementGetChildById(hObj,L"Text",&m_TextPresenterA[m_iCurrentTextIndex]); } diff --git a/Minecraft.Client/Common/XUI/XUI_HelpCredits.cpp b/Minecraft.Client/Common/XUI/XUI_HelpCredits.cpp index 18435716c..c0584e946 100644 --- a/Minecraft.Client/Common/XUI/XUI_HelpCredits.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HelpCredits.cpp @@ -391,7 +391,7 @@ HRESULT CScene_Credits::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) MapChildControls(); // if we're not in the game, we need to use basescene 0 - if(Minecraft::GetInstance()->level==NULL) + if(Minecraft::GetInstance()->level==nullptr) { iPad=0; } diff --git a/Minecraft.Client/Common/XUI/XUI_HelpHowToPlay.cpp b/Minecraft.Client/Common/XUI/XUI_HelpHowToPlay.cpp index b2d57f883..cd9e962d0 100644 --- a/Minecraft.Client/Common/XUI/XUI_HelpHowToPlay.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HelpHowToPlay.cpp @@ -146,7 +146,7 @@ void CScene_HowToPlay::StartPage( EHowToPlayPage ePage ) { int iBaseSceneUser; // if we're not in the game, we need to use basescene 0 - if(Minecraft::GetInstance()->level==NULL) + if(Minecraft::GetInstance()->level==nullptr) { iBaseSceneUser=DEFAULT_XUI_MENU_USER; } diff --git a/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp b/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp index 8e5d21c44..a99921e06 100644 --- a/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp +++ b/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp @@ -67,9 +67,9 @@ HRESULT CScene_HowToPlayMenu::OnInit( XUIMessageInit* pInitData, BOOL& bHandled { m_iPad = *static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); bool bSplitscreen= app.GetLocalPlayerCount()>1; - m_ButtonList=NULL; + m_ButtonList=nullptr; //MapChildControls(); diff --git a/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp b/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp index 71125b685..64f1f22c6 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp @@ -76,7 +76,7 @@ HRESULT CScene_InGameHostOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& r { Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player != NULL && player->connection) + if(player != nullptr && player->connection) { player->connection->send( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions) ) ); } diff --git a/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp b/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp index 7bd71336f..d22230a91 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp @@ -44,7 +44,7 @@ HRESULT CScene_InGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); - if( player != NULL ) + if( player != nullptr ) { m_players[i] = player->GetSmallId(); ++m_playersCount; @@ -55,7 +55,7 @@ HRESULT CScene_InGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) INetworkPlayer *thisPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); m_isHostPlayer = false; - if(thisPlayer != NULL) m_isHostPlayer = thisPlayer->IsHost() == TRUE; + if(thisPlayer != nullptr) m_isHostPlayer = thisPlayer->IsHost() == TRUE; Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr localPlayer = pMinecraft->localplayers[m_iPad]; @@ -140,7 +140,7 @@ HRESULT CScene_InGameInfo::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandle if(playersList.TreeHasFocus() && (playersList.GetItemCount() > 0) && (playersList.GetCurSel() < m_playersCount) ) { INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId(m_players[playersList.GetCurSel()]); - if( player != NULL ) + if( player != nullptr ) { PlayerUID xuid = static_cast(player)->GetUID(); if( xuid != INVALID_XUID ) @@ -189,7 +189,7 @@ HRESULT CScene_InGameInfo::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; bool trust = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; - if( isOp && selectedPlayer != NULL && playersList.TreeHasFocus() && (playersList.GetItemCount() > 0) && (playersList.GetCurSel() < m_playersCount) ) + if( isOp && selectedPlayer != nullptr && playersList.TreeHasFocus() && (playersList.GetItemCount() > 0) && (playersList.GetCurSel() < m_playersCount) ) { bool editingHost = selectedPlayer->IsHost(); if( (cheats && (m_isHostPlayer || !editingHost ) ) @@ -311,7 +311,7 @@ HRESULT CScene_InGameInfo::OnGetSourceDataText(XUIMessageGetSourceText *pGetSour if( pGetSourceTextData->iItem < m_playersCount ) { INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId( m_players[pGetSourceTextData->iItem] ); - if( player != NULL ) + if( player != nullptr ) { #ifndef _CONTENT_PACKAGE if(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask()&(1L<HasVoice() ) + if(player != nullptr && player->HasVoice() ) { if( player->IsMutedByLocalUser(m_iPad) ) { @@ -477,7 +477,7 @@ void CScene_InGameInfo::updateTooltips() { keyA = IDS_TOOLTIPS_SELECT; } - else if( selectedPlayer != NULL) + else if( selectedPlayer != nullptr) { bool editingHost = selectedPlayer->IsHost(); if( (cheats && (m_isHostPlayer || !editingHost ) ) || (!trust && (m_isHostPlayer || !editingHost)) @@ -499,7 +499,7 @@ void CScene_InGameInfo::updateTooltips() if(!m_gameOptionsButton.HasFocus()) { // if the player is me, then view gamer profile - if(selectedPlayer != NULL && selectedPlayer->IsLocal() && selectedPlayer->GetUserIndex()==m_iPad) + if(selectedPlayer != nullptr && selectedPlayer->IsLocal() && selectedPlayer->GetUserIndex()==m_iPad) { ikeyY = IDS_TOOLTIPS_VIEW_GAMERPROFILE; } @@ -527,7 +527,7 @@ int CScene_InGameInfo::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMes { Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr localPlayer = pMinecraft->localplayers[iPad]; - if(localPlayer != NULL && localPlayer->connection) + if(localPlayer != nullptr && localPlayer->connection) { localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); } diff --git a/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp b/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp index bb3419678..7903ff8eb 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp @@ -32,14 +32,14 @@ HRESULT CScene_InGamePlayerOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHa INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); - if(editingPlayer != NULL) + if(editingPlayer != nullptr) { m_Gamertag.SetText(editingPlayer->GetOnlineName()); } bool trustPlayers = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; - m_editingSelf = (localPlayer != NULL && localPlayer == editingPlayer); + m_editingSelf = (localPlayer != nullptr && localPlayer == editingPlayer); if( m_editingSelf || trustPlayers || editingPlayer->IsHost()) { @@ -247,7 +247,7 @@ HRESULT CScene_InGamePlayerOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& else { INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); - if(!trustPlayers && (editingPlayer != NULL && !editingPlayer->IsHost() ) ) + if(!trustPlayers && (editingPlayer != nullptr && !editingPlayer->IsHost() ) ) { Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CannotMine,!m_checkboxes[eControl_BuildAndMine].IsChecked()); Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CannotBuild,!m_checkboxes[eControl_BuildAndMine].IsChecked()); @@ -278,7 +278,7 @@ HRESULT CScene_InGamePlayerOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& // Send update settings packet to server Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player != NULL && player->connection) + if(player != nullptr && player->connection) { player->connection->send( shared_ptr( new PlayerInfoPacket( m_networkSmallId, -1, m_playerPrivileges) ) ); } @@ -320,7 +320,7 @@ HRESULT CScene_InGamePlayerOptions::OnControlNavigate(XUIMessageControlNavigate { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -337,7 +337,7 @@ int CScene_InGamePlayerOptions::KickPlayerReturned(void *pParam,int iPad,C4JStor { Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr localPlayer = pMinecraft->localplayers[iPad]; - if(localPlayer != NULL && localPlayer->connection) + if(localPlayer != nullptr && localPlayer->connection) { localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); } @@ -360,9 +360,9 @@ void CScene_InGamePlayerOptions::OnPlayerChanged(void *callbackParam, INetworkPl VOID *pObj; XuiObjectFromHandle( hBackScene, &pObj ); infoScene = static_cast(pObj); - if(infoScene != NULL) CScene_InGameInfo::OnPlayerChanged(infoScene,pPlayer,leaving); + if(infoScene != nullptr) CScene_InGameInfo::OnPlayerChanged(infoScene,pPlayer,leaving); - if(leaving && pPlayer != NULL && pPlayer->GetSmallId() == scene->m_networkSmallId) + if(leaving && pPlayer != nullptr && pPlayer->GetSmallId() == scene->m_networkSmallId) { app.NavigateBack(scene->m_iPad); } @@ -373,59 +373,59 @@ HRESULT CScene_InGamePlayerOptions::OnTransitionStart( XUIMessageTransition *pTr if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO) { INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); - if(editingPlayer != NULL) + if(editingPlayer != nullptr) { short colourIndex = app.GetPlayerColour( m_networkSmallId ); switch(colourIndex) { case 1: - m_Icon.PlayVisualRange(L"P1",NULL,L"P1"); + m_Icon.PlayVisualRange(L"P1",nullptr,L"P1"); break; case 2: - m_Icon.PlayVisualRange(L"P2",NULL,L"P2"); + m_Icon.PlayVisualRange(L"P2",nullptr,L"P2"); break; case 3: - m_Icon.PlayVisualRange(L"P3",NULL,L"P3"); + m_Icon.PlayVisualRange(L"P3",nullptr,L"P3"); break; case 4: - m_Icon.PlayVisualRange(L"P4",NULL,L"P4"); + m_Icon.PlayVisualRange(L"P4",nullptr,L"P4"); break; case 5: - m_Icon.PlayVisualRange(L"P5",NULL,L"P5"); + m_Icon.PlayVisualRange(L"P5",nullptr,L"P5"); break; case 6: - m_Icon.PlayVisualRange(L"P6",NULL,L"P6"); + m_Icon.PlayVisualRange(L"P6",nullptr,L"P6"); break; case 7: - m_Icon.PlayVisualRange(L"P7",NULL,L"P7"); + m_Icon.PlayVisualRange(L"P7",nullptr,L"P7"); break; case 8: - m_Icon.PlayVisualRange(L"P8",NULL,L"P8"); + m_Icon.PlayVisualRange(L"P8",nullptr,L"P8"); break; case 9: - m_Icon.PlayVisualRange(L"P9",NULL,L"P9"); + m_Icon.PlayVisualRange(L"P9",nullptr,L"P9"); break; case 10: - m_Icon.PlayVisualRange(L"P10",NULL,L"P10"); + m_Icon.PlayVisualRange(L"P10",nullptr,L"P10"); break; case 11: - m_Icon.PlayVisualRange(L"P11",NULL,L"P11"); + m_Icon.PlayVisualRange(L"P11",nullptr,L"P11"); break; case 12: - m_Icon.PlayVisualRange(L"P12",NULL,L"P12"); + m_Icon.PlayVisualRange(L"P12",nullptr,L"P12"); break; case 13: - m_Icon.PlayVisualRange(L"P13",NULL,L"P13"); + m_Icon.PlayVisualRange(L"P13",nullptr,L"P13"); break; case 14: - m_Icon.PlayVisualRange(L"P14",NULL,L"P14"); + m_Icon.PlayVisualRange(L"P14",nullptr,L"P14"); break; case 15: - m_Icon.PlayVisualRange(L"P15",NULL,L"P15"); + m_Icon.PlayVisualRange(L"P15",nullptr,L"P15"); break; case 0: default: - m_Icon.PlayVisualRange(L"P0",NULL,L"P0"); + m_Icon.PlayVisualRange(L"P0",nullptr,L"P0"); break; }; } diff --git a/Minecraft.Client/Common/XUI/XUI_Leaderboards.cpp b/Minecraft.Client/Common/XUI/XUI_Leaderboards.cpp index 35fa6250c..7fde530bf 100644 --- a/Minecraft.Client/Common/XUI/XUI_Leaderboards.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Leaderboards.cpp @@ -33,9 +33,9 @@ LPCWSTR CScene_Leaderboards::m_TextColumnNameA[7]= // if the value is greater than 511, it's an xzp icon that needs displayed, rather than the game icon const int CScene_Leaderboards::TitleIcons[CScene_Leaderboards::NUM_LEADERBOARDS][7] = { - { XZP_ICON_WALKED, XZP_ICON_FALLEN, Item::minecart_Id, Item::boat_Id, NULL }, + { XZP_ICON_WALKED, XZP_ICON_FALLEN, Item::minecart_Id, Item::boat_Id, nullptr }, { Tile::dirt_Id, Tile::stoneBrick_Id, Tile::sand_Id, Tile::rock_Id, Tile::gravel_Id, Tile::clay_Id, Tile::obsidian_Id }, - { Item::egg_Id, Item::wheat_Id, Tile::mushroom1_Id, Tile::reeds_Id, Item::milk_Id, Tile::pumpkin_Id, NULL }, + { Item::egg_Id, Item::wheat_Id, Tile::mushroom1_Id, Tile::reeds_Id, Item::milk_Id, Tile::pumpkin_Id, nullptr }, { XZP_ICON_ZOMBIE, XZP_ICON_SKELETON, XZP_ICON_CREEPER, XZP_ICON_SPIDER, XZP_ICON_SPIDERJOCKEY, XZP_ICON_ZOMBIEPIGMAN, XZP_ICON_SLIME }, }; @@ -43,33 +43,33 @@ const int CScene_Leaderboards::LEADERBOARD_HEADERS[CScene_Leaderboards::NUM_LEAD { SPASTRING_LB_TRAVELLING_PEACEFUL_NAME, SPASTRING_LB_TRAVELLING_EASY_NAME, SPASTRING_LB_TRAVELLING_NORMAL_NAME, SPASTRING_LB_TRAVELLING_HARD_NAME }, { SPASTRING_LB_MINING_BLOCKS_PEACEFUL_NAME, SPASTRING_LB_MINING_BLOCKS_EASY_NAME, SPASTRING_LB_MINING_BLOCKS_NORMAL_NAME, SPASTRING_LB_MINING_BLOCKS_HARD_NAME }, { SPASTRING_LB_FARMING_PEACEFUL_NAME, SPASTRING_LB_FARMING_EASY_NAME, SPASTRING_LB_FARMING_NORMAL_NAME, SPASTRING_LB_FARMING_HARD_NAME }, - { NULL, SPASTRING_LB_KILLS_EASY_NAME, SPASTRING_LB_KILLS_NORMAL_NAME, SPASTRING_LB_KILLS_HARD_NAME }, + { nullptr, SPASTRING_LB_KILLS_EASY_NAME, SPASTRING_LB_KILLS_NORMAL_NAME, SPASTRING_LB_KILLS_HARD_NAME }, }; const CScene_Leaderboards::LeaderboardDescriptor CScene_Leaderboards::LEADERBOARD_DESCRIPTORS[CScene_Leaderboards::NUM_LEADERBOARDS][4] = { { - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_PEACEFUL, 4, STATS_COLUMN_TRAVELLING_PEACEFUL_WALKED, STATS_COLUMN_TRAVELLING_PEACEFUL_FALLEN, STATS_COLUMN_TRAVELLING_PEACEFUL_MINECART, STATS_COLUMN_TRAVELLING_PEACEFUL_BOAT, NULL, NULL, NULL,NULL), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_EASY, 4, STATS_COLUMN_TRAVELLING_EASY_WALKED, STATS_COLUMN_TRAVELLING_EASY_FALLEN, STATS_COLUMN_TRAVELLING_EASY_MINECART, STATS_COLUMN_TRAVELLING_EASY_BOAT, NULL, NULL, NULL,NULL), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_NORMAL, 4, STATS_COLUMN_TRAVELLING_NORMAL_WALKED, STATS_COLUMN_TRAVELLING_NORMAL_FALLEN, STATS_COLUMN_TRAVELLING_NORMAL_MINECART, STATS_COLUMN_TRAVELLING_NORMAL_BOAT, NULL, NULL, NULL,NULL), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_HARD, 4, STATS_COLUMN_TRAVELLING_HARD_WALKED, STATS_COLUMN_TRAVELLING_HARD_FALLEN, STATS_COLUMN_TRAVELLING_HARD_MINECART, STATS_COLUMN_TRAVELLING_HARD_BOAT, NULL, NULL, NULL,NULL), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_PEACEFUL, 4, STATS_COLUMN_TRAVELLING_PEACEFUL_WALKED, STATS_COLUMN_TRAVELLING_PEACEFUL_FALLEN, STATS_COLUMN_TRAVELLING_PEACEFUL_MINECART, STATS_COLUMN_TRAVELLING_PEACEFUL_BOAT, nullptr, nullptr, nullptr,nullptr), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_EASY, 4, STATS_COLUMN_TRAVELLING_EASY_WALKED, STATS_COLUMN_TRAVELLING_EASY_FALLEN, STATS_COLUMN_TRAVELLING_EASY_MINECART, STATS_COLUMN_TRAVELLING_EASY_BOAT, nullptr, nullptr, nullptr,nullptr), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_NORMAL, 4, STATS_COLUMN_TRAVELLING_NORMAL_WALKED, STATS_COLUMN_TRAVELLING_NORMAL_FALLEN, STATS_COLUMN_TRAVELLING_NORMAL_MINECART, STATS_COLUMN_TRAVELLING_NORMAL_BOAT, nullptr, nullptr, nullptr,nullptr), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_HARD, 4, STATS_COLUMN_TRAVELLING_HARD_WALKED, STATS_COLUMN_TRAVELLING_HARD_FALLEN, STATS_COLUMN_TRAVELLING_HARD_MINECART, STATS_COLUMN_TRAVELLING_HARD_BOAT, nullptr, nullptr, nullptr,nullptr), }, { - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_PEACEFUL, 7, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_DIRT, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_STONE, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_SAND, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_GRAVEL, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_CLAY, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_OBSIDIAN,NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_EASY, 7, STATS_COLUMN_MINING_BLOCKS_EASY_DIRT, STATS_COLUMN_MINING_BLOCKS_EASY_STONE, STATS_COLUMN_MINING_BLOCKS_EASY_SAND, STATS_COLUMN_MINING_BLOCKS_EASY_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_EASY_GRAVEL, STATS_COLUMN_MINING_BLOCKS_EASY_CLAY, STATS_COLUMN_MINING_BLOCKS_EASY_OBSIDIAN,NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_NORMAL, 7, STATS_COLUMN_MINING_BLOCKS_NORMAL_DIRT, STATS_COLUMN_MINING_BLOCKS_NORMAL_STONE, STATS_COLUMN_MINING_BLOCKS_NORMAL_SAND, STATS_COLUMN_MINING_BLOCKS_NORMAL_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_NORMAL_GRAVEL, STATS_COLUMN_MINING_BLOCKS_NORMAL_CLAY, STATS_COLUMN_MINING_BLOCKS_NORMAL_OBSIDIAN,NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_HARD, 7, STATS_COLUMN_MINING_BLOCKS_HARD_DIRT, STATS_COLUMN_MINING_BLOCKS_HARD_STONE, STATS_COLUMN_MINING_BLOCKS_HARD_SAND, STATS_COLUMN_MINING_BLOCKS_HARD_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_HARD_GRAVEL, STATS_COLUMN_MINING_BLOCKS_HARD_CLAY, STATS_COLUMN_MINING_BLOCKS_HARD_OBSIDIAN,NULL ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_PEACEFUL, 7, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_DIRT, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_STONE, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_SAND, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_GRAVEL, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_CLAY, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_OBSIDIAN,nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_EASY, 7, STATS_COLUMN_MINING_BLOCKS_EASY_DIRT, STATS_COLUMN_MINING_BLOCKS_EASY_STONE, STATS_COLUMN_MINING_BLOCKS_EASY_SAND, STATS_COLUMN_MINING_BLOCKS_EASY_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_EASY_GRAVEL, STATS_COLUMN_MINING_BLOCKS_EASY_CLAY, STATS_COLUMN_MINING_BLOCKS_EASY_OBSIDIAN,nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_NORMAL, 7, STATS_COLUMN_MINING_BLOCKS_NORMAL_DIRT, STATS_COLUMN_MINING_BLOCKS_NORMAL_STONE, STATS_COLUMN_MINING_BLOCKS_NORMAL_SAND, STATS_COLUMN_MINING_BLOCKS_NORMAL_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_NORMAL_GRAVEL, STATS_COLUMN_MINING_BLOCKS_NORMAL_CLAY, STATS_COLUMN_MINING_BLOCKS_NORMAL_OBSIDIAN,nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_HARD, 7, STATS_COLUMN_MINING_BLOCKS_HARD_DIRT, STATS_COLUMN_MINING_BLOCKS_HARD_STONE, STATS_COLUMN_MINING_BLOCKS_HARD_SAND, STATS_COLUMN_MINING_BLOCKS_HARD_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_HARD_GRAVEL, STATS_COLUMN_MINING_BLOCKS_HARD_CLAY, STATS_COLUMN_MINING_BLOCKS_HARD_OBSIDIAN,nullptr ), }, { - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_FARMING_PEACEFUL, 6, STATS_COLUMN_FARMING_PEACEFUL_EGGS, STATS_COLUMN_FARMING_PEACEFUL_WHEAT, STATS_COLUMN_FARMING_PEACEFUL_MUSHROOMS, STATS_COLUMN_FARMING_PEACEFUL_SUGARCANE, STATS_COLUMN_FARMING_PEACEFUL_MILK, STATS_COLUMN_FARMING_PEACEFUL_PUMPKINS, NULL,NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_FARMING_EASY, 6, STATS_COLUMN_FARMING_EASY_EGGS, STATS_COLUMN_FARMING_PEACEFUL_WHEAT, STATS_COLUMN_FARMING_EASY_MUSHROOMS, STATS_COLUMN_FARMING_EASY_SUGARCANE, STATS_COLUMN_FARMING_EASY_MILK, STATS_COLUMN_FARMING_EASY_PUMPKINS, NULL,NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_FARMING_NORMAL, 6, STATS_COLUMN_FARMING_NORMAL_EGGS, STATS_COLUMN_FARMING_NORMAL_WHEAT, STATS_COLUMN_FARMING_NORMAL_MUSHROOMS, STATS_COLUMN_FARMING_NORMAL_SUGARCANE, STATS_COLUMN_FARMING_NORMAL_MILK, STATS_COLUMN_FARMING_NORMAL_PUMPKINS, NULL,NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_FARMING_HARD, 6, STATS_COLUMN_FARMING_HARD_EGGS, STATS_COLUMN_FARMING_HARD_WHEAT, STATS_COLUMN_FARMING_HARD_MUSHROOMS, STATS_COLUMN_FARMING_HARD_SUGARCANE, STATS_COLUMN_FARMING_HARD_MILK, STATS_COLUMN_FARMING_HARD_PUMPKINS, NULL,NULL ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_FARMING_PEACEFUL, 6, STATS_COLUMN_FARMING_PEACEFUL_EGGS, STATS_COLUMN_FARMING_PEACEFUL_WHEAT, STATS_COLUMN_FARMING_PEACEFUL_MUSHROOMS, STATS_COLUMN_FARMING_PEACEFUL_SUGARCANE, STATS_COLUMN_FARMING_PEACEFUL_MILK, STATS_COLUMN_FARMING_PEACEFUL_PUMPKINS, nullptr,nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_FARMING_EASY, 6, STATS_COLUMN_FARMING_EASY_EGGS, STATS_COLUMN_FARMING_PEACEFUL_WHEAT, STATS_COLUMN_FARMING_EASY_MUSHROOMS, STATS_COLUMN_FARMING_EASY_SUGARCANE, STATS_COLUMN_FARMING_EASY_MILK, STATS_COLUMN_FARMING_EASY_PUMPKINS, nullptr,nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_FARMING_NORMAL, 6, STATS_COLUMN_FARMING_NORMAL_EGGS, STATS_COLUMN_FARMING_NORMAL_WHEAT, STATS_COLUMN_FARMING_NORMAL_MUSHROOMS, STATS_COLUMN_FARMING_NORMAL_SUGARCANE, STATS_COLUMN_FARMING_NORMAL_MILK, STATS_COLUMN_FARMING_NORMAL_PUMPKINS, nullptr,nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_FARMING_HARD, 6, STATS_COLUMN_FARMING_HARD_EGGS, STATS_COLUMN_FARMING_HARD_WHEAT, STATS_COLUMN_FARMING_HARD_MUSHROOMS, STATS_COLUMN_FARMING_HARD_SUGARCANE, STATS_COLUMN_FARMING_HARD_MILK, STATS_COLUMN_FARMING_HARD_PUMPKINS, nullptr,nullptr ), }, { - CScene_Leaderboards::LeaderboardDescriptor( NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_KILLS_EASY, 7, STATS_COLUMN_KILLS_EASY_ZOMBIES, STATS_COLUMN_KILLS_EASY_SKELETONS, STATS_COLUMN_KILLS_EASY_CREEPERS, STATS_COLUMN_KILLS_EASY_SPIDERS, STATS_COLUMN_KILLS_EASY_SPIDERJOCKEYS, STATS_COLUMN_KILLS_EASY_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_EASY_SLIME,NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_KILLS_NORMAL, 7, STATS_COLUMN_KILLS_NORMAL_ZOMBIES, STATS_COLUMN_KILLS_NORMAL_SKELETONS, STATS_COLUMN_KILLS_NORMAL_CREEPERS, STATS_COLUMN_KILLS_NORMAL_SPIDERS, STATS_COLUMN_KILLS_NORMAL_SPIDERJOCKEYS, STATS_COLUMN_KILLS_NORMAL_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_NORMAL_SLIME,NULL ), - CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_KILLS_HARD, 7, STATS_COLUMN_KILLS_HARD_ZOMBIES, STATS_COLUMN_KILLS_HARD_SKELETONS, STATS_COLUMN_KILLS_HARD_CREEPERS, STATS_COLUMN_KILLS_HARD_SPIDERS, STATS_COLUMN_KILLS_HARD_SPIDERJOCKEYS, STATS_COLUMN_KILLS_HARD_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_HARD_SLIME,NULL ), + CScene_Leaderboards::LeaderboardDescriptor( nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_KILLS_EASY, 7, STATS_COLUMN_KILLS_EASY_ZOMBIES, STATS_COLUMN_KILLS_EASY_SKELETONS, STATS_COLUMN_KILLS_EASY_CREEPERS, STATS_COLUMN_KILLS_EASY_SPIDERS, STATS_COLUMN_KILLS_EASY_SPIDERJOCKEYS, STATS_COLUMN_KILLS_EASY_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_EASY_SLIME,nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_KILLS_NORMAL, 7, STATS_COLUMN_KILLS_NORMAL_ZOMBIES, STATS_COLUMN_KILLS_NORMAL_SKELETONS, STATS_COLUMN_KILLS_NORMAL_CREEPERS, STATS_COLUMN_KILLS_NORMAL_SPIDERS, STATS_COLUMN_KILLS_NORMAL_SPIDERJOCKEYS, STATS_COLUMN_KILLS_NORMAL_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_NORMAL_SLIME,nullptr ), + CScene_Leaderboards::LeaderboardDescriptor( STATS_VIEW_KILLS_HARD, 7, STATS_COLUMN_KILLS_HARD_ZOMBIES, STATS_COLUMN_KILLS_HARD_SKELETONS, STATS_COLUMN_KILLS_HARD_CREEPERS, STATS_COLUMN_KILLS_HARD_SPIDERS, STATS_COLUMN_KILLS_HARD_SPIDERJOCKEYS, STATS_COLUMN_KILLS_HARD_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_HARD_SLIME,nullptr ), }, }; @@ -80,7 +80,7 @@ HRESULT CScene_Leaderboards::OnInit(XUIMessageInit *pInitData, BOOL &bHandled) m_bReady=false; // if we're not in the game, we need to use basescene 0 - if(Minecraft::GetInstance()->level==NULL) + if(Minecraft::GetInstance()->level==nullptr) { m_iPad=DEFAULT_XUI_MENU_USER; } @@ -90,9 +90,9 @@ HRESULT CScene_Leaderboards::OnInit(XUIMessageInit *pInitData, BOOL &bHandled) ui.SetTooltips(m_iPad,-1, IDS_TOOLTIPS_BACK, IDS_TOOLTIPS_CHANGE_FILTER, -1); CXuiSceneBase::ShowLogo( m_iPad, FALSE ); - m_friends = NULL; + m_friends = nullptr; m_numFriends = 0; - m_filteredFriends = NULL; + m_filteredFriends = nullptr; m_numFilteredFriends = 0; m_newTop = m_newSel = -1; @@ -124,10 +124,10 @@ HRESULT CScene_Leaderboards::OnInit(XUIMessageInit *pInitData, BOOL &bHandled) // title icons for(int i=0;i<7;i++) { - m_pHTitleIconSlots[i]=NULL; + m_pHTitleIconSlots[i]=nullptr; m_fTitleIconXPositions[i]=0.0f; m_fTextXPositions[i]=0.0f; - m_hTextEntryA[i]=NULL; + m_hTextEntryA[i]=nullptr; } @@ -190,10 +190,10 @@ HRESULT CScene_Leaderboards::OnDestroy() Sleep( 10 ); } - if( m_friends != NULL ) + if( m_friends != nullptr ) delete [] m_friends; - if( m_filteredFriends != NULL ) + if( m_filteredFriends != nullptr ) delete [] m_filteredFriends; return S_OK; @@ -511,7 +511,7 @@ void CScene_Leaderboards::GetFriends() m_friends, resultsSize, &numFriends, - NULL ); + nullptr ); if( ret != ERROR_SUCCESS ) numFriends = 0; @@ -675,7 +675,7 @@ bool CScene_Leaderboards::RetrieveStats() return true; } - //assert( LeaderboardManager::Instance()->GetStats() != NULL ); + //assert( LeaderboardManager::Instance()->GetStats() != nullptr ); //PXUSER_STATS_READ_RESULTS stats = LeaderboardManager::Instance()->GetStats(); //if( m_currentFilter == LeaderboardManager::eFM_Friends ) LeaderboardManager::Instance()->SortFriendStats(); @@ -898,11 +898,11 @@ HRESULT CScene_Leaderboards::OnGetSourceDataImage(XUIMessageGetSourceImage* pGet void CScene_Leaderboards::PopulateLeaderboard(bool noResults) { HRESULT hr; - HXUIOBJ visual=NULL; - HXUIOBJ hTemp=NULL; + HXUIOBJ visual=nullptr; + HXUIOBJ hTemp=nullptr; hr=XuiControlGetVisual(m_listGamers.m_hObj,&visual); - if(m_pHTitleIconSlots[0]==NULL) + if(m_pHTitleIconSlots[0]==nullptr) { VOID *pObj; HXUIOBJ button; @@ -964,7 +964,7 @@ void CScene_Leaderboards::PopulateLeaderboard(bool noResults) // Really only the newly updated rows need changed, but this shouldn't cause any performance issues for(DWORD i = m_leaderboard.m_entryStartIndex - 1; i < (m_leaderboard.m_entryStartIndex - 1) + m_leaderboard.m_currentEntryCount; ++i) { - HXUIOBJ visual=NULL; + HXUIOBJ visual=nullptr; HXUIOBJ button; D3DXVECTOR3 vPos; // 4J-PB - fix for #13768 - Leaderboards: Player scores appear misaligned when viewed under the "My Score" leaderboard filter @@ -1150,7 +1150,7 @@ void CScene_Leaderboards::SetLeaderboardHeader() WCHAR buffer[40]; DWORD bufferLength = 40; - DWORD ret = XResourceGetString(LEADERBOARD_HEADERS[m_currentLeaderboard][m_currentDifficulty], buffer, &bufferLength, NULL); + DWORD ret = XResourceGetString(LEADERBOARD_HEADERS[m_currentLeaderboard][m_currentDifficulty], buffer, &bufferLength, nullptr); if( ret == ERROR_SUCCESS ) m_textLeaderboard.SetText(buffer); @@ -1184,8 +1184,8 @@ void CScene_Leaderboards::ClearLeaderboardTitlebar() m_pHTitleIconSlots[i]->SetShow(FALSE); } - HXUIOBJ visual=NULL; - HXUIOBJ hTemp=NULL; + HXUIOBJ visual=nullptr; + HXUIOBJ hTemp=nullptr; HRESULT hr; hr=XuiControlGetVisual(m_listGamers.m_hObj,&visual); diff --git a/Minecraft.Client/Common/XUI/XUI_LoadSettings.cpp b/Minecraft.Client/Common/XUI/XUI_LoadSettings.cpp index 55e967887..e12957959 100644 --- a/Minecraft.Client/Common/XUI/XUI_LoadSettings.cpp +++ b/Minecraft.Client/Common/XUI/XUI_LoadSettings.cpp @@ -42,10 +42,10 @@ int CScene_LoadGameSettings::m_iDifficultyTitleSettingA[4]= HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - m_hXuiBrush = NULL; + m_hXuiBrush = nullptr; m_bSetup = false; m_texturePackDescDisplayed = false; - m_iConfigA=NULL; + m_iConfigA=nullptr; WCHAR TempString[256]; @@ -146,7 +146,7 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl else { // set the save icon - PBYTE pbImageData=NULL; + PBYTE pbImageData=nullptr; DWORD dwImageBytes=0; StorageManager.GetSaveCacheFileInfo(m_params->iSaveGameInfoIndex,m_XContentData); @@ -156,13 +156,13 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl // Don't delete the image data after creating the xuibrush, since we'll use it in the rename of the save bool bHostOptionsRead = false; unsigned int uiHostOptions = 0; - if(pbImageData==NULL) + if(pbImageData==nullptr) { - DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&m_XContentData,NULL,&dwImageBytes,NULL); + DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&m_XContentData,nullptr,&dwImageBytes,nullptr); if(dwResult==ERROR_SUCCESS) { pbImageData = new BYTE[dwImageBytes]; - XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&m_XContentData,pbImageData,&dwImageBytes,NULL); + XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&m_XContentData,pbImageData,&dwImageBytes,nullptr); XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hXuiBrush); } } @@ -175,9 +175,9 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl // #ifdef _DEBUG // // dump out the thumbnail -// HANDLE hThumbnail = CreateFile("GAME:\\thumbnail.png", GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); +// HANDLE hThumbnail = CreateFile("GAME:\\thumbnail.png", GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, nullptr); // DWORD dwBytes; -// WriteFile(hThumbnail,pbImageData,dwImageBytes,&dwBytes,NULL); +// WriteFile(hThumbnail,pbImageData,dwImageBytes,&dwBytes,nullptr); // XCloseHandle(hThumbnail); // #endif @@ -310,7 +310,7 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -376,7 +376,7 @@ HRESULT CScene_LoadGameSettings::OnControlNavigate(XUIMessageControlNavigate *pC { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -411,7 +411,7 @@ HRESULT CScene_LoadGameSettings::LaunchGame(void) // inform them that leaderboard writes and achievements will be disabled //StorageManager.RequestMessageBox(IDS_TITLE_START_GAME, IDS_CONFIRM_START_SAVEDINCREATIVE_CONTINUE, uiIDA, 1, m_iPad,&CScene_LoadGameSettings::ConfirmLoadReturned,this,app.GetStringTable()); - if(m_levelGen != NULL) + if(m_levelGen != nullptr) { LoadLevelGen(m_levelGen); } @@ -445,7 +445,7 @@ HRESULT CScene_LoadGameSettings::LaunchGame(void) } else { - if(m_levelGen != NULL) + if(m_levelGen != nullptr) { LoadLevelGen(m_levelGen); } @@ -503,7 +503,7 @@ HRESULT CScene_LoadGameSettings::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyP // texture pack hasn't been set yet, so check what it will be TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - if(pTexturePack==NULL) + if(pTexturePack==nullptr) { // They've selected a texture pack they don't have yet // upsell @@ -572,7 +572,7 @@ HRESULT CScene_LoadGameSettings::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyP // texture pack hasn't been set yet, so check what it will be TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - if(pTexturePack==NULL) + if(pTexturePack==nullptr) { // DLC corrupt, so use the default textures m_MoreOptionsParams.dwTexturePack=0; @@ -600,7 +600,7 @@ HRESULT CScene_LoadGameSettings::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyP DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_pDLCPack->getPurchaseOfferId()); ULONGLONG ullOfferID_Full; - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullOfferID_Full=pDLCInfo->ullOfferID_Full; } @@ -707,7 +707,7 @@ int CScene_LoadGameSettings::ConfirmLoadReturned(void *pParam,int iPad,C4JStorag if(result==C4JStorage::EMessage_ResultAccept) { - if(pClass->m_levelGen != NULL) + if(pClass->m_levelGen != nullptr) { pClass->LoadLevelGen(pClass->m_levelGen); } @@ -784,14 +784,14 @@ HRESULT CScene_LoadGameSettings::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandle if(m_iConfigA[i]!=-1) { DWORD dwBytes=0; - PBYTE pbData=NULL; + PBYTE pbData=nullptr; app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); if(dwBytes > 0 && pbData) { DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + PBYTE pbImageData=nullptr; app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); ListInfo.fEnabled = TRUE; @@ -868,7 +868,7 @@ int CScene_LoadGameSettings::LoadSaveDataReturned(void *pParam,bool bContinue) pClass->m_bIgnoreInput=false; UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } else { @@ -951,7 +951,7 @@ void CScene_LoadGameSettings::StartGameFromSave(CScene_LoadGameSettings* pClass, NetworkGameInitData *param = new NetworkGameInitData(); param->seed = 0; - param->saveData = NULL; + param->saveData = nullptr; param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack; Minecraft *pMinecraft = Minecraft::GetInstance(); @@ -1036,7 +1036,7 @@ int CScene_LoadGameSettings::StartGame_SignInReturned(void *pParam,bool bContinu //pClass->m_bAbortSearch=false; UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } else { @@ -1045,7 +1045,7 @@ int CScene_LoadGameSettings::StartGame_SignInReturned(void *pParam,bool bContinu //pClass->m_bAbortSearch=false; UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } } else @@ -1159,7 +1159,7 @@ int CScene_LoadGameSettings::UnlockTexturePackReturned(void *pParam,int iPad,C4J ULONGLONG ullIndexA[1]; DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(pScene->m_pDLCPack->getPurchaseOfferId()); - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullIndexA[0]=pDLCInfo->ullOfferID_Full; } @@ -1168,7 +1168,7 @@ int CScene_LoadGameSettings::UnlockTexturePackReturned(void *pParam,int iPad,C4J ullIndexA[0]=pScene->m_pDLCPack->getPurchaseOfferId(); } - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); // the license change coming in when the offer has been installed will cause this scene to refresh } @@ -1238,11 +1238,11 @@ void CScene_LoadGameSettings::UpdateTexturePackDescription(int index) int iTexPackId=m_pTexturePacksList->GetData(index).iData; TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(iTexPackId); - if(tp==NULL) + if(tp==nullptr) { // this is probably a texture pack icon added from TMS DWORD dwBytes=0,dwFileBytes=0; - PBYTE pbData=NULL,pbFileData=NULL; + PBYTE pbData=nullptr,pbFileData=nullptr; CXuiCtrl4JList::LIST_ITEM_INFO ListItem; // get the current index of the list, and then get the data @@ -1272,7 +1272,7 @@ void CScene_LoadGameSettings::UpdateTexturePackDescription(int index) } else { - m_texturePackComparison->UseBrush(NULL); + m_texturePackComparison->UseBrush(nullptr); } } else @@ -1290,7 +1290,7 @@ void CScene_LoadGameSettings::UpdateTexturePackDescription(int index) } else { - m_texturePackIcon->UseBrush(NULL); + m_texturePackIcon->UseBrush(nullptr); } pbImageData = tp->getPackComparison(dwImageBytes); @@ -1302,7 +1302,7 @@ void CScene_LoadGameSettings::UpdateTexturePackDescription(int index) } else { - m_texturePackComparison->UseBrush(NULL); + m_texturePackComparison->UseBrush(nullptr); } } } @@ -1311,8 +1311,8 @@ void CScene_LoadGameSettings::ClearTexturePackDescription() { m_texturePackTitle.SetText(L" "); m_texturePackDescription.SetText(L" "); - m_texturePackComparison->UseBrush(NULL); - m_texturePackIcon->UseBrush(NULL); + m_texturePackComparison->UseBrush(nullptr); + m_texturePackIcon->UseBrush(nullptr); } void CScene_LoadGameSettings::UpdateCurrentTexturePack() @@ -1322,7 +1322,7 @@ void CScene_LoadGameSettings::UpdateCurrentTexturePack() TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(iTexPackId); // if the texture pack is null, you don't have it yet - if(tp==NULL) + if(tp==nullptr) { // Upsell @@ -1416,7 +1416,7 @@ void CScene_LoadGameSettings::LoadLevelGen(LevelGenerationOptions *levelGen) m_bIgnoreInput=false; UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); return; } } @@ -1438,7 +1438,7 @@ void CScene_LoadGameSettings::LoadLevelGen(LevelGenerationOptions *levelGen) NetworkGameInitData *param = new NetworkGameInitData(); param->seed = 0; - param->saveData = NULL; + param->saveData = nullptr; param->levelGen = levelGen; if(levelGen->requiresTexturePack()) @@ -1566,7 +1566,7 @@ HRESULT CScene_LoadGameSettings::OnCustomMessage_DLCMountingComplete() m_iTexturePacksNotInstalled=0; // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -1599,7 +1599,7 @@ HRESULT CScene_LoadGameSettings::OnCustomMessage_DLCMountingComplete() // add a TMS request for them app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n"); app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData); - if(m_iConfigA!=NULL) + if(m_iConfigA!=nullptr) { delete m_iConfigA; } @@ -1655,7 +1655,7 @@ int CScene_LoadGameSettings::TexturePackDialogReturned(void *pParam,int iPad,C4J if( result==C4JStorage::EMessage_ResultAccept ) // Full version { ullIndexA[0]=ullOfferID_Full; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } else // trial version @@ -1665,7 +1665,7 @@ int CScene_LoadGameSettings::TexturePackDialogReturned(void *pParam,int iPad,C4J if(pDLCInfo->ullOfferID_Trial!=0LL) { ullIndexA[0]=pDLCInfo->ullOfferID_Trial; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } } diff --git a/Minecraft.Client/Common/XUI/XUI_MainMenu.cpp b/Minecraft.Client/Common/XUI/XUI_MainMenu.cpp index b5f722eb1..4126c5591 100644 --- a/Minecraft.Client/Common/XUI/XUI_MainMenu.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MainMenu.cpp @@ -72,7 +72,7 @@ HRESULT CScene_Main::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) WCHAR szResourceLocator[ LOCATOR_SIZE ]; // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/splashes.txt"); BYTE *splashesData; @@ -119,7 +119,7 @@ HRESULT CScene_Main::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) m_bIgnorePress=false; // 4J Stu - Clear out any loaded game rules - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // Fix for #45154 - Frontend: DLC: Content can only be downloaded from the frontend if you have not joined/exited multiplayer XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); @@ -359,7 +359,7 @@ HRESULT CScene_Main::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& HRESULT hr=S_OK; float fWidth,fHeight; - HXUIOBJ visual=NULL; + HXUIOBJ visual=nullptr; HXUIOBJ pulser, subtitle, text; hr=XuiControlGetVisual(m_Subtitle.m_hObj,&visual); hr=XuiElementGetChildById(visual,L"Pulser",&pulser); @@ -436,7 +436,7 @@ HRESULT CScene_Main::OnControlNavigate(XUIMessageControlNavigate *pControlNaviga // added so we can skip greyed out items for Minecon pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -907,7 +907,7 @@ void CScene_Main::LoadTrial(void) NetworkGameInitData *param = new NetworkGameInitData(); param->seed = 0; - param->saveData = NULL; + param->saveData = nullptr; param->settings = app.GetGameHostOption( eGameHostOption_Tutorial ); vector *generators = app.getLevelGenerators(); diff --git a/Minecraft.Client/Common/XUI/XUI_MultiGameCreate.cpp b/Minecraft.Client/Common/XUI/XUI_MultiGameCreate.cpp index 4034f3c20..6e9fe6da2 100644 --- a/Minecraft.Client/Common/XUI/XUI_MultiGameCreate.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MultiGameCreate.cpp @@ -38,7 +38,7 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle { m_bSetup = false; m_texturePackDescDisplayed = false; - m_iConfigA=NULL; + m_iConfigA=nullptr; WCHAR TempString[256]; MapChildControls(); @@ -222,7 +222,7 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -322,7 +322,7 @@ HRESULT CScene_MultiGameCreate::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPr // texture pack hasn't been set yet, so check what it will be TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - if(pTexturePack==NULL) + if(pTexturePack==nullptr) { // They've selected a texture pack they don't have yet // upsell @@ -391,7 +391,7 @@ HRESULT CScene_MultiGameCreate::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPr // texture pack hasn't been set yet, so check what it will be TexturePack *pTexturePack = pMinecraft->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - if(pTexturePack==NULL) + if(pTexturePack==nullptr) { // corrupt DLC so set it to the default textures m_MoreOptionsParams.dwTexturePack=0; @@ -419,7 +419,7 @@ HRESULT CScene_MultiGameCreate::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPr DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_pDLCPack->getPurchaseOfferId()); ULONGLONG ullOfferID_Full; - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullOfferID_Full=pDLCInfo->ullOfferID_Full; } @@ -485,7 +485,7 @@ HRESULT CScene_MultiGameCreate::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPr SetShow( TRUE ); UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } else { @@ -531,7 +531,7 @@ int CScene_MultiGameCreate::UnlockTexturePackReturned(void *pParam,int iPad,C4JS ULONGLONG ullIndexA[1]; DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(pScene->m_pDLCPack->getPurchaseOfferId()); - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullIndexA[0]=pDLCInfo->ullOfferID_Full; } @@ -540,7 +540,7 @@ int CScene_MultiGameCreate::UnlockTexturePackReturned(void *pParam,int iPad,C4JS ullIndexA[0]=pScene->m_pDLCPack->getPurchaseOfferId(); } - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); // the license change coming in when the offer has been installed will cause this scene to refresh } @@ -588,7 +588,7 @@ int CScene_MultiGameCreate::WarningTrialTexturePackReturned(void *pParam,int iPa { UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } else { @@ -645,7 +645,7 @@ HRESULT CScene_MultiGameCreate::OnControlNavigate(XUIMessageControlNavigate *pCo { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest==NULL) + if(pControlNavigateData->hObjDest==nullptr) { pControlNavigateData->hObjDest=pControlNavigateData->hObjSource; } @@ -706,7 +706,7 @@ HRESULT CScene_MultiGameCreate::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled if(m_iConfigA[i]!=-1) { DWORD dwBytes=0; - PBYTE pbData=NULL; + PBYTE pbData=nullptr; //app.DebugPrintf("Retrieving iConfig %d from TPD\n",m_iConfigA[i]); app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); @@ -715,7 +715,7 @@ HRESULT CScene_MultiGameCreate::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled if(dwBytes > 0 && pbData) { DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + PBYTE pbImageData=nullptr; app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); ListInfo.fEnabled = TRUE; @@ -787,7 +787,7 @@ int CScene_MultiGameCreate::ConfirmCreateReturned(void *pParam,int iPad,C4JStora pClass->SetShow( TRUE ); UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } else { @@ -844,7 +844,7 @@ int CScene_MultiGameCreate::StartGame_SignInReturned(void *pParam,bool bContinue pClass->SetShow( TRUE ); UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } else { @@ -852,7 +852,7 @@ int CScene_MultiGameCreate::StartGame_SignInReturned(void *pParam,bool bContinue pClass->SetShow( TRUE ); UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } } else @@ -889,7 +889,7 @@ void CScene_MultiGameCreate::CreateGame(CScene_MultiGameCreate* pClass, DWORD dw // Make our next save default to the name of the level StorageManager.SetSaveTitle((wchar_t *)wWorldName.c_str()); - BOOL bHasSeed = (pClass->m_EditSeed.GetText() != NULL); + BOOL bHasSeed = (pClass->m_EditSeed.GetText() != nullptr); wstring wSeed; if(bHasSeed) @@ -946,7 +946,7 @@ void CScene_MultiGameCreate::CreateGame(CScene_MultiGameCreate* pClass, DWORD dw NetworkGameInitData *param = new NetworkGameInitData(); param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack; Minecraft *pMinecraft = Minecraft::GetInstance(); @@ -1095,12 +1095,12 @@ void CScene_MultiGameCreate::UpdateTexturePackDescription(int index) int iTexPackId=m_pTexturePacksList->GetData(index).iData; TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(iTexPackId); - if(tp==NULL) + if(tp==nullptr) { // this is probably a texture pack icon added from TMS DWORD dwBytes=0,dwFileBytes=0; - PBYTE pbData=NULL,pbFileData=NULL; + PBYTE pbData=nullptr,pbFileData=nullptr; CXuiCtrl4JList::LIST_ITEM_INFO ListItem; // get the current index of the list, and then get the data @@ -1130,7 +1130,7 @@ void CScene_MultiGameCreate::UpdateTexturePackDescription(int index) } else { - m_texturePackComparison->UseBrush(NULL); + m_texturePackComparison->UseBrush(nullptr); } } else @@ -1156,7 +1156,7 @@ void CScene_MultiGameCreate::UpdateTexturePackDescription(int index) } else { - m_texturePackComparison->UseBrush(NULL); + m_texturePackComparison->UseBrush(nullptr); } } } @@ -1168,7 +1168,7 @@ void CScene_MultiGameCreate::UpdateCurrentTexturePack() TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(iTexPackId); // if the texture pack is null, you don't have it yet - if(tp==NULL) + if(tp==nullptr) { // Upsell @@ -1236,7 +1236,7 @@ int CScene_MultiGameCreate::TexturePackDialogReturned(void *pParam,int iPad,C4JS if( result==C4JStorage::EMessage_ResultAccept ) // Full version { ullIndexA[0]=ullOfferID_Full; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } else // trial version @@ -1246,7 +1246,7 @@ int CScene_MultiGameCreate::TexturePackDialogReturned(void *pParam,int iPad,C4JS if(pDLCInfo->ullOfferID_Trial!=0LL) { ullIndexA[0]=pDLCInfo->ullOfferID_Trial; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } } @@ -1319,7 +1319,7 @@ HRESULT CScene_MultiGameCreate::OnCustomMessage_DLCMountingComplete() // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this // REMOVE UNTIL WORKING - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -1352,7 +1352,7 @@ HRESULT CScene_MultiGameCreate::OnCustomMessage_DLCMountingComplete() // add a TMS request for them app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n"); app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData); - if(m_iConfigA!=NULL) + if(m_iConfigA!=nullptr) { delete m_iConfigA; } @@ -1392,6 +1392,6 @@ void CScene_MultiGameCreate::ClearTexturePackDescription() { m_texturePackTitle.SetText(L" "); m_texturePackDescription.SetText(L" "); - m_texturePackComparison->UseBrush(NULL); - m_texturePackIcon->UseBrush(NULL); + m_texturePackComparison->UseBrush(nullptr); + m_texturePackIcon->UseBrush(nullptr); } \ No newline at end of file diff --git a/Minecraft.Client/Common/XUI/XUI_MultiGameInfo.cpp b/Minecraft.Client/Common/XUI/XUI_MultiGameInfo.cpp index 671b9e8ee..c1dba2829 100644 --- a/Minecraft.Client/Common/XUI/XUI_MultiGameInfo.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MultiGameInfo.cpp @@ -39,7 +39,7 @@ HRESULT CScene_MultiGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { - if( m_selectedSession->data.players[i] != NULL ) + if( m_selectedSession->data.players[i] != nullptr ) { playersList.InsertItems(i,1); #ifndef _CONTENT_PACKAGE @@ -55,7 +55,7 @@ HRESULT CScene_MultiGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled } else { - // Leave the loop when we hit the first NULL player + // Leave the loop when we hit the first nullptr player break; } } @@ -185,7 +185,7 @@ HRESULT CScene_MultiGameInfo::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHan rfHandled = TRUE; break; case VK_PAD_Y: - if(m_selectedSession != NULL && playersList.TreeHasFocus() && playersList.GetItemCount() > 0) + if(m_selectedSession != nullptr && playersList.TreeHasFocus() && playersList.GetItemCount() > 0) { PlayerUID xuid = m_selectedSession->data.players[playersList.GetCurSel()]; if( xuid != INVALID_XUID ) @@ -302,7 +302,7 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass) int messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; if(dwSignedInUsers > 1) messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; - StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, messageText, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, messageText, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } else if(noPrivileges) @@ -311,7 +311,7 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass) pClass->m_bIgnoreInput=false; UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); } else { @@ -338,7 +338,7 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass) { UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); exitReasonStringId = -1; app.NavigateToHomeMenu(); @@ -361,7 +361,7 @@ HRESULT CScene_MultiGameInfo::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled ) int selectedIndex = 0; for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { - if( m_selectedSession->data.players[i] != NULL ) + if( m_selectedSession->data.players[i] != nullptr ) { if(m_selectedSession->data.players[i] == selectedPlayerXUID) selectedIndex = i; playersList.InsertItems(i,1); @@ -378,7 +378,7 @@ HRESULT CScene_MultiGameInfo::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled ) } else { - // Leave the loop when we hit the first NULL player + // Leave the loop when we hit the first nullptr player break; } } diff --git a/Minecraft.Client/Common/XUI/XUI_MultiGameJoinLoad.cpp b/Minecraft.Client/Common/XUI/XUI_MultiGameJoinLoad.cpp index 83cb240f6..c3f73a8ab 100644 --- a/Minecraft.Client/Common/XUI/XUI_MultiGameJoinLoad.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MultiGameJoinLoad.cpp @@ -41,7 +41,7 @@ HRESULT CScene_MultiGameJoinLoad::OnInit( XUIMessageInit* pInitData, BOOL& bHand MapChildControls(); m_iTexturePacksNotInstalled=0; - m_iConfigA=NULL; + m_iConfigA=nullptr; XuiControlSetText(m_LabelNoGames,app.GetString(IDS_NO_GAMES_FOUND)); XuiControlSetText(m_GamesList,app.GetString(IDS_JOIN_GAME)); @@ -51,7 +51,7 @@ HRESULT CScene_MultiGameJoinLoad::OnInit( XUIMessageInit* pInitData, BOOL& bHand const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/TexturePackIcon.png"); m_DefaultMinecraftIconSize = 0; @@ -185,7 +185,7 @@ HRESULT CScene_MultiGameJoinLoad::OnInit( XUIMessageInit* pInitData, BOOL& bHand // 4J-PB - there may be texture packs we don't have, so use the info from TMS for this - DLC_INFO *pDLCInfo=NULL; + DLC_INFO *pDLCInfo=nullptr; // first pass - look to see if there are any that are not in the list bool bTexturePackAlreadyListed; @@ -384,7 +384,7 @@ HRESULT CScene_MultiGameJoinLoad::GetSaveInfo( ) HRESULT CScene_MultiGameJoinLoad::OnDestroy() { - g_NetworkManager.SetSessionsUpdatedCallback( NULL, NULL ); + g_NetworkManager.SetSessionsUpdatedCallback( nullptr, nullptr ); for (auto& it : currentSessions ) { @@ -594,7 +594,7 @@ HRESULT CScene_MultiGameJoinLoad::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotify // need to get the iIndex from the list item, since the position in the list doesn't correspond to the GetSaveGameInfo list because of sorting params->iSaveGameInfoIndex=m_pSavesList->GetData(iIndex).iIndex-m_iDefaultButtonsC; //params->pbSaveRenamed=&m_bSaveRenamed; - params->levelGen = NULL; + params->levelGen = nullptr; // kill the texture pack timer XuiKillTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID); @@ -1050,7 +1050,7 @@ bool CScene_MultiGameJoinLoad::DoesSavesListHaveFocus() { HXUIOBJ hParentObj,hObj=TreeGetFocus(); - if(hObj!=NULL) + if(hObj!=nullptr) { // get the parent and see if it's the saves list XuiElementGetParent(hObj,&hParentObj); @@ -1070,7 +1070,7 @@ bool CScene_MultiGameJoinLoad::DoesMashUpWorldHaveFocus() { HXUIOBJ hParentObj,hObj=TreeGetFocus(); - if(hObj!=NULL) + if(hObj!=nullptr) { // get the parent and see if it's the saves list XuiElementGetParent(hObj,&hParentObj); @@ -1097,7 +1097,7 @@ bool CScene_MultiGameJoinLoad::DoesGamesListHaveFocus() { HXUIOBJ hParentObj,hObj=TreeGetFocus(); - if(hObj!=NULL) + if(hObj!=nullptr) { // get the parent and see if it's the saves list XuiElementGetParent(hObj,&hParentObj); @@ -1111,7 +1111,7 @@ bool CScene_MultiGameJoinLoad::DoesGamesListHaveFocus() void CScene_MultiGameJoinLoad::UpdateGamesListCallback(LPVOID lpParam) { - if(lpParam != NULL) + if(lpParam != nullptr) { CScene_MultiGameJoinLoad* pClass = static_cast(lpParam); // check this there's no save transfer in progress @@ -1133,7 +1133,7 @@ void CScene_MultiGameJoinLoad::UpdateGamesList() } DWORD nIndex = -1; - FriendSessionInfo *pSelectedSession = NULL; + FriendSessionInfo *pSelectedSession = nullptr; if(m_pGamesList->TreeHasFocus() && m_pGamesList->GetItemCount() > 0) { nIndex = m_pGamesList->GetCurSel(); @@ -1141,8 +1141,8 @@ void CScene_MultiGameJoinLoad::UpdateGamesList() } SessionID selectedSessionId; - if( pSelectedSession != NULL )selectedSessionId = pSelectedSession->sessionId; - pSelectedSession = NULL; + if( pSelectedSession != nullptr )selectedSessionId = pSelectedSession->sessionId; + pSelectedSession = nullptr; for (auto& it : currentSessions ) { @@ -1269,12 +1269,12 @@ void CScene_MultiGameJoinLoad::UpdateGamesList() HRESULT hr; DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + PBYTE pbImageData=nullptr; - if(tp==NULL) + if(tp==nullptr) { DWORD dwBytes=0; - PBYTE pbData=NULL; + PBYTE pbData=nullptr; app.GetTPD(sessionInfo->data.texturePackParentId,&pbData,&dwBytes); // is it in the tpd data ? @@ -1386,7 +1386,7 @@ void CScene_MultiGameJoinLoad::UpdateGamesList(DWORD dwNumResults, IQNetGameSear if(pSearchResult->dwOpenPublicSlots < m_localPlayers) continue; - FriendSessionInfo *sessionInfo = NULL; + FriendSessionInfo *sessionInfo = nullptr; bool foundSession = false; for( auto it = friendsSessions.begin(); it != friendsSessions.end(); ++it) { @@ -1481,8 +1481,8 @@ void CScene_MultiGameJoinLoad::UpdateGamesList(DWORD dwNumResults, IQNetGameSear XUIRect xuiRect; HXUIOBJ item = XuiListGetItemControl(m_GamesList,0); - HXUIOBJ hObj=NULL; - HXUIOBJ hTextPres=NULL; + HXUIOBJ hObj=nullptr; + HXUIOBJ hTextPres=nullptr; HRESULT hr=XuiControlGetVisual(item,&hObj); hr=XuiElementGetChildById(hObj,L"text_Label",&hTextPres); @@ -1491,7 +1491,7 @@ void CScene_MultiGameJoinLoad::UpdateGamesList(DWORD dwNumResults, IQNetGameSear { FriendSessionInfo *sessionInfo = currentSessions.at(i); - if(hTextPres != NULL ) + if(hTextPres != nullptr ) { hr=XuiTextPresenterMeasureText(hTextPres, sessionInfo->displayLabel, &xuiRect); @@ -1741,7 +1741,7 @@ HRESULT CScene_MultiGameJoinLoad::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandl if(m_iConfigA[i]!=-1) { DWORD dwBytes=0; - PBYTE pbData=NULL; + PBYTE pbData=nullptr; //app.DebugPrintf("Retrieving iConfig %d from TPD\n",m_iConfigA[i]); app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); @@ -1852,7 +1852,7 @@ void CScene_MultiGameJoinLoad::StartGameFromSave(CScene_MultiGameJoinLoad* pClas LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = nullptr; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1909,7 +1909,7 @@ void CScene_MultiGameJoinLoad::LoadLevelGen(LevelGenerationOptions *levelGen) NetworkGameInitData *param = new NetworkGameInitData(); param->seed = 0; - param->saveData = NULL; + param->saveData = nullptr; param->settings = app.GetGameHostOption( eGameHostOption_Tutorial ); param->levelGen = levelGen; @@ -2083,7 +2083,7 @@ int CScene_MultiGameJoinLoad::UploadSaveForXboxOneThreadProc( LPVOID lpParameter { // set the save icon - PBYTE pbImageData=NULL; + PBYTE pbImageData=nullptr; DWORD dwImageBytes=0; XCONTENT_DATA XContentData; int iIndex=pClass->m_pSavesList->GetData(pClass->m_pSavesList->GetCurSel()).iIndex-pClass->m_iDefaultButtonsC; @@ -2092,14 +2092,14 @@ int CScene_MultiGameJoinLoad::UploadSaveForXboxOneThreadProc( LPVOID lpParameter // if there is no thumbnail, retrieve the default one from the file. // Don't delete the image data after creating the xuibrush, since we'll use it in the rename of the save - if(pbImageData==NULL) + if(pbImageData==nullptr) { - DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,NULL,&dwImageBytes,NULL); + DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,nullptr,&dwImageBytes,nullptr); if(dwResult==ERROR_SUCCESS) { pClass->m_pbSaveTransferData = new BYTE[dwImageBytes]; pbImageData = pClass->m_pbSaveTransferData; // Copy pointer so that we can use the same name as the library owned one, but m_pbSaveTransferData will get deleted when done - XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,pbImageData,&dwImageBytes,NULL); + XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,pbImageData,&dwImageBytes,nullptr); } } @@ -2159,7 +2159,7 @@ void CScene_MultiGameJoinLoad::DeleteFile(CScene_MultiGameJoinLoad *pClass, char C4JStorage::TMS_FILETYPE_BINARY, &CScene_MultiGameJoinLoad::DeleteComplete, pClass, - NULL); + nullptr); if(result != C4JStorage::ETMSStatus_DeleteInProgress) { @@ -2189,10 +2189,10 @@ void CScene_MultiGameJoinLoad::UploadFile(CScene_MultiGameJoinLoad *pClass, char File targetFileDir(L"GAME:\\FakeTMSPP"); if(!targetFileDir.exists()) targetFileDir.mkdir(); string path = string( wstringtofilename( targetFileDir.getPath() ) ).append("\\").append(filename); - HANDLE hSaveFile = CreateFile( path.c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); + HANDLE hSaveFile = CreateFile( path.c_str(), GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, nullptr); DWORD numberOfBytesWritten = 0; - WriteFile( hSaveFile,data,size,&numberOfBytesWritten,NULL); + WriteFile( hSaveFile,data,size,&numberOfBytesWritten,nullptr); assert(numberOfBytesWritten == size); CloseHandle(hSaveFile); @@ -2322,14 +2322,14 @@ int CScene_MultiGameJoinLoad::TransferComplete(void *pParam,int iPad, int iResul CScene_MultiGameJoinLoad* pClass = static_cast(pParam); delete [] pClass->m_pbSaveTransferData; - pClass->m_pbSaveTransferData = NULL; + pClass->m_pbSaveTransferData = nullptr; if(iResult!=0) { // There was a transfer fail // Display a dialog UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - StorageManager.RequestMessageBox(IDS_SAVE_TRANSFER_TITLE, IDS_SAVE_TRANSFER_UPLOADFAILED, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,NULL,app.GetStringTable()); + StorageManager.RequestMessageBox(IDS_SAVE_TRANSFER_TITLE, IDS_SAVE_TRANSFER_UPLOADFAILED, uiIDA, 1, ProfileManager.GetPrimaryPad(),nullptr,nullptr,app.GetStringTable()); pClass->m_bTransferFail=true; } else @@ -2391,7 +2391,7 @@ int CScene_MultiGameJoinLoad::LoadSaveDataForRenameReturned(void *pParam,bool bC if(bContinue==true) { // set the save icon - PBYTE pbImageData=NULL; + PBYTE pbImageData=nullptr; DWORD dwImageBytes=0; HXUIBRUSH hXuiBrush; XCONTENT_DATA XContentData; @@ -2400,13 +2400,13 @@ int CScene_MultiGameJoinLoad::LoadSaveDataForRenameReturned(void *pParam,bool bC // if there is no thumbnail, retrieve the default one from the file. // Don't delete the image data after creating the xuibrush, since we'll use it in the rename of the save - if(pbImageData==NULL) + if(pbImageData==nullptr) { - DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,NULL,&dwImageBytes,NULL); + DWORD dwResult=XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,nullptr,&dwImageBytes,nullptr); if(dwResult==ERROR_SUCCESS) { pbImageData = new BYTE[dwImageBytes]; - XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,pbImageData,&dwImageBytes,NULL); + XContentGetThumbnail(ProfileManager.GetPrimaryPad(),&XContentData,pbImageData,&dwImageBytes,nullptr); XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush); } } @@ -2466,7 +2466,7 @@ int CScene_MultiGameJoinLoad::TexturePackDialogReturned(void *pParam,int iPad,C4 if( result==C4JStorage::EMessage_ResultAccept ) // Full version { ullIndexA[0]=ullOfferID_Full; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } else // trial version @@ -2476,7 +2476,7 @@ int CScene_MultiGameJoinLoad::TexturePackDialogReturned(void *pParam,int iPad,C4 if(pDLCInfo->ullOfferID_Trial!=0LL) { ullIndexA[0]=pDLCInfo->ullOfferID_Trial; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } } @@ -2698,7 +2698,7 @@ bool CScene_MultiGameJoinLoad::GetSavesInfoCallback(LPVOID pParam,int iTotalSave // we could put in a damaged save icon here const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/MinecraftBrokenIcon.png"); @@ -2750,7 +2750,7 @@ void CScene_MultiGameJoinLoad::CancelSaveUploadCallback(LPVOID lpParam) // pClass->m_eSaveUploadState = eSaveUpload_Idle; UINT uiIDA[1] = { IDS_CONFIRM_OK }; - ui.RequestMessageBox(IDS_XBONE_CANCEL_UPLOAD_TITLE, IDS_XBONE_CANCEL_UPLOAD_TEXT, uiIDA, 1, pClass->m_iPad, NULL, NULL, app.GetStringTable()); + ui.RequestMessageBox(IDS_XBONE_CANCEL_UPLOAD_TITLE, IDS_XBONE_CANCEL_UPLOAD_TEXT, uiIDA, 1, pClass->m_iPad, nullptr, nullptr, app.GetStringTable()); } void CScene_MultiGameJoinLoad::SaveUploadCompleteCallback(LPVOID lpParam) diff --git a/Minecraft.Client/Common/XUI/XUI_MultiGameLaunchMoreOptions.cpp b/Minecraft.Client/Common/XUI/XUI_MultiGameLaunchMoreOptions.cpp index 69f474d58..63d28498f 100644 --- a/Minecraft.Client/Common/XUI/XUI_MultiGameLaunchMoreOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_MultiGameLaunchMoreOptions.cpp @@ -231,7 +231,7 @@ HRESULT CScene_MultiGameLaunchMoreOptions::OnControlNavigate(XUIMessageControlNa { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } diff --git a/Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp b/Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp index f6d71b07b..0879ba278 100644 --- a/Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp +++ b/Minecraft.Client/Common/XUI/XUI_PauseMenu.cpp @@ -317,7 +317,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* if(pNotifyPressData->UserIndex==ProfileManager.GetPrimaryPad()) { int playTime = -1; - if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) + if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } @@ -357,7 +357,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* else { int playTime = -1; - if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) + if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } @@ -375,7 +375,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* if(pNotifyPressData->UserIndex==ProfileManager.GetPrimaryPad()) { int playTime = -1; - if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) + if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } @@ -392,7 +392,7 @@ HRESULT UIScene_PauseMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* else { int playTime = -1; - if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL ) + if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != nullptr ) { playTime = static_cast(pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer()); } @@ -596,7 +596,7 @@ HRESULT UIScene_PauseMenu::OnControlNavigate(XUIMessageControlNavigate *pControl { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -790,7 +790,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J // need to allow downloads here, or the player would need to quit the game to let the download of a texture pack happen. This might affect the network traffic, since the download could take all the bandwidth... XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); } } else @@ -1036,7 +1036,7 @@ void UIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) bool saveStats = true; if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession()) { - if(lpParameter != NULL ) + if(lpParameter != nullptr ) { // 4J-PB - check if we have lost connection to Live if(ProfileManager.GetLiveConnectionStatus()!=XONLINE_S_LOGON_CONNECTION_ESTABLISHED ) @@ -1104,21 +1104,21 @@ void UIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) uiIDA[0]=IDS_CONFIRM_OK; // 4J Stu - Fix for #48669 - TU5: Code: Compliance: TCR #15: Incorrect/misleading messages after signing out a profile during online game session. // If the primary player is signed out, then that is most likely the cause of the disconnection so don't display a message box. This will allow the message box requested by the libraries to be brought up - if( ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) ui.RequestMessageBox( exitReasonTitleId, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + if( ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) ui.RequestMessageBox( exitReasonTitleId, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); exitReasonStringId = -1; // 4J - Force a disconnection, this handles the situation that the server has already disconnected - if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(false); - if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(false); - if( pMinecraft->levels[2] != NULL ) pMinecraft->levels[2]->disconnect(false); + if( pMinecraft->levels[0] != nullptr ) pMinecraft->levels[0]->disconnect(false); + if( pMinecraft->levels[1] != nullptr ) pMinecraft->levels[1]->disconnect(false); + if( pMinecraft->levels[2] != nullptr ) pMinecraft->levels[2]->disconnect(false); } else { exitReasonStringId = IDS_EXITING_GAME; pMinecraft->progressRenderer->progressStartNoAbort( IDS_EXITING_GAME ); - if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(); - if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(); - if( pMinecraft->levels[2] != NULL ) pMinecraft->levels[2]->disconnect(); + if( pMinecraft->levels[0] != nullptr ) pMinecraft->levels[0]->disconnect(); + if( pMinecraft->levels[1] != nullptr ) pMinecraft->levels[1]->disconnect(); + if( pMinecraft->levels[2] != nullptr ) pMinecraft->levels[2]->disconnect(); } // 4J Stu - This only does something if we actually have a server, so don't need to do any other checks @@ -1134,7 +1134,7 @@ void UIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) } else { - if(lpParameter != NULL && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()) ) + if(lpParameter != nullptr && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()) ) { switch( app.GetDisconnectReason() ) { @@ -1180,7 +1180,7 @@ void UIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox( exitReasonTitleId, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); + ui.RequestMessageBox( exitReasonTitleId, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),nullptr,nullptr, app.GetStringTable()); exitReasonStringId = -1; } } @@ -1189,7 +1189,7 @@ void UIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) { Sleep(1); } - pMinecraft->setLevel(NULL,exitReasonStringId,nullptr,saveStats); + pMinecraft->setLevel(nullptr,exitReasonStringId,nullptr,saveStats); TelemetryManager->Flush(); diff --git a/Minecraft.Client/Common/XUI/XUI_Reinstall.cpp b/Minecraft.Client/Common/XUI/XUI_Reinstall.cpp index 5f8b585cd..c0650335c 100644 --- a/Minecraft.Client/Common/XUI/XUI_Reinstall.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Reinstall.cpp @@ -224,7 +224,7 @@ HRESULT CScene_Reinstall::OnControlNavigate(XUIMessageControlNavigate *pControlN { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -241,7 +241,7 @@ HRESULT CScene_Reinstall::OnTransitionStart( XUIMessageTransition *pTransition, // 4J-PB - Going to resize buttons if the text is too big to fit on any of them (Br-pt problem with the length of Unlock Full Game) XUIRect xuiRect; - HXUIOBJ visual=NULL; + HXUIOBJ visual=nullptr; HXUIOBJ text; float fMaxTextLen=0.0f; float fTextVisualLen; diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_AbstractContainer.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_AbstractContainer.cpp index 1ccc031cd..2692c8f1c 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_AbstractContainer.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_AbstractContainer.cpp @@ -71,8 +71,8 @@ void CXuiSceneAbstractContainer::PlatformInitialize(int iPad, int startIndex) m_fPointerMaxX = fPanelWidth + fPointerWidth; m_fPointerMaxY = fPanelHeight + (fPointerHeight/2); -// m_hPointerText=NULL; -// m_hPointerTextBkg=NULL; +// m_hPointerText=nullptr; +// m_hPointerTextBkg=nullptr; UIVec2D itemPos; UIVec2D itemSize; @@ -170,7 +170,7 @@ HRESULT CXuiSceneAbstractContainer::OnTransitionStart( XUIMessageTransition *pTr InitDataAssociations(m_iPad, m_menu); } - HXUIOBJ hObj=NULL; + HXUIOBJ hObj=nullptr; HRESULT hr=XuiControlGetVisual(m_pointerControl->m_hObj,&hObj); hr=XuiElementGetChildById(hObj,L"text_measurer",&m_hPointerTextMeasurer); hr=XuiElementGetChildById(hObj,L"text_name",&m_hPointerText); diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp index a10c101b0..bd63d1963 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp @@ -40,7 +40,7 @@ HRESULT CXuiSceneAnvil::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad); } - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -67,15 +67,15 @@ HRESULT CXuiSceneAnvil::OnDestroy() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -158,7 +158,7 @@ CXuiControl* CXuiSceneAnvil::GetSectionControl( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } CXuiCtrlSlotList* CXuiSceneAnvil::GetSectionSlotList( ESceneSection eSection ) @@ -184,7 +184,7 @@ CXuiCtrlSlotList* CXuiSceneAnvil::GetSectionSlotList( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } // 4J Stu - Added to support auto-save. Need to re-associate on a navigate back diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp index 217e68f90..39b43bc6a 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp @@ -22,14 +22,14 @@ #define PRESS_START_TIMER 0 -CXuiSceneBase *CXuiSceneBase::Instance = NULL; +CXuiSceneBase *CXuiSceneBase::Instance = nullptr; DWORD CXuiSceneBase::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; //---------------------------------------------------------------------------------- // Performs initialization tasks - retrieves controls. //---------------------------------------------------------------------------------- HRESULT CXuiSceneBase::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - ASSERT( CXuiSceneBase::Instance == NULL ); + ASSERT( CXuiSceneBase::Instance == nullptr ); CXuiSceneBase::Instance = this; m_iWrongTexturePackTickC=20*5; // default 5 seconds before bringing up the upsell for not having the texture pack @@ -41,7 +41,7 @@ HRESULT CXuiSceneBase::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) HXUIOBJ hTemp; - m_hEmptyQuadrantLogo=NULL; + m_hEmptyQuadrantLogo=nullptr; XuiElementGetChildById(m_hObj,L"EmptyQuadrantLogo",&m_hEmptyQuadrantLogo); D3DXVECTOR3 lastPos; @@ -51,8 +51,8 @@ HRESULT CXuiSceneBase::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { m_visible[idx][ i ] = FALSE; m_iCurrentTooltipTextID[idx][i]=-1; - hTooltipText[idx][i]=NULL; - hTooltipTextSmall[idx][i]=NULL; + hTooltipText[idx][i]=nullptr; + hTooltipTextSmall[idx][i]=nullptr; // set all tooltips to shown FALSE by default m_Buttons[idx][i].SetShow( FALSE ); m_ButtonsSmall[idx][i].SetShow( FALSE ); @@ -106,7 +106,7 @@ HRESULT CXuiSceneBase::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled) // clear the quadrants m_iQuadrantsMask=0; - HXUIOBJ hObj=NULL,hQuadrant; + HXUIOBJ hObj=nullptr,hQuadrant; HRESULT hr=XuiControlGetVisual(m_PressStart.m_hObj,&hObj); @@ -144,8 +144,8 @@ HRESULT CXuiSceneBase::OnSkinChanged(BOOL& bHandled) { for( unsigned int i = 0; i < BUTTONS_TOOLTIP_MAX; ++i ) { - hTooltipText[idx][i]=NULL; - hTooltipTextSmall[idx][i]=NULL; + hTooltipText[idx][i]=nullptr; + hTooltipTextSmall[idx][i]=nullptr; } } @@ -178,7 +178,7 @@ void CXuiSceneBase::_TickAllBaseScenes() //Is it available? TexturePack * pRequiredTPack=pMinecraft->skins->getTexturePackById(app.GetRequiredTexturePackID()); - if(pRequiredTPack!=NULL) + if(pRequiredTPack!=nullptr) { // we can switch to the required pack // reset the timer @@ -206,7 +206,7 @@ void CXuiSceneBase::_TickAllBaseScenes() } } - if (EnderDragonRenderer::bossInstance == NULL) + if (EnderDragonRenderer::bossInstance == nullptr) { if(m_ticksWithNoBoss<=20) { @@ -221,7 +221,7 @@ void CXuiSceneBase::_TickAllBaseScenes() for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if(pMinecraft->localplayers[i] != NULL && pMinecraft->localplayers[i]->dimension == 1 && !ui.GetMenuDisplayed(i) && app.GetGameSettings(i,eGameSetting_DisplayHUD)) + if(pMinecraft->localplayers[i] != nullptr && pMinecraft->localplayers[i]->dimension == 1 && !ui.GetMenuDisplayed(i) && app.GetGameSettings(i,eGameSetting_DisplayHUD)) { int iGuiScale; @@ -245,7 +245,7 @@ void CXuiSceneBase::_TickAllBaseScenes() m_BossHealthProgress1[i].SetShow(TRUE); m_BossHealthProgress2[i].SetShow(FALSE); m_BossHealthProgress3[i].SetShow(FALSE); - if(m_BossHealthProgress1_small[i]!=NULL) + if(m_BossHealthProgress1_small[i]!=nullptr) { m_BossHealthProgress1_small[i].SetShow(FALSE); m_BossHealthProgress2_small[i].SetShow(FALSE); @@ -259,7 +259,7 @@ void CXuiSceneBase::_TickAllBaseScenes() m_BossHealthProgress1[i].SetShow(FALSE); m_BossHealthProgress2[i].SetShow(TRUE); m_BossHealthProgress3[i].SetShow(FALSE); - if(m_BossHealthProgress1_small[i]!=NULL) + if(m_BossHealthProgress1_small[i]!=nullptr) { m_BossHealthProgress1_small[i].SetShow(FALSE); m_BossHealthProgress2_small[i].SetShow(FALSE); @@ -272,7 +272,7 @@ void CXuiSceneBase::_TickAllBaseScenes() m_BossHealthProgress1[i].SetShow(FALSE); m_BossHealthProgress2[i].SetShow(FALSE); m_BossHealthProgress3[i].SetShow(TRUE); - if(m_BossHealthProgress1_small[i]!=NULL) + if(m_BossHealthProgress1_small[i]!=nullptr) { m_BossHealthProgress1_small[i].SetShow(FALSE); m_BossHealthProgress2_small[i].SetShow(FALSE); @@ -295,7 +295,7 @@ void CXuiSceneBase::_TickAllBaseScenes() m_BossHealthProgress1[i].SetShow(TRUE); m_BossHealthProgress2[i].SetShow(FALSE); m_BossHealthProgress3[i].SetShow(FALSE); - if(m_BossHealthProgress1_small[i]!=NULL) + if(m_BossHealthProgress1_small[i]!=nullptr) { m_BossHealthProgress1_small[i].SetShow(FALSE); m_BossHealthProgress2_small[i].SetShow(FALSE); @@ -308,7 +308,7 @@ void CXuiSceneBase::_TickAllBaseScenes() m_BossHealthProgress1[i].SetShow(FALSE); m_BossHealthProgress2[i].SetShow(TRUE); m_BossHealthProgress3[i].SetShow(FALSE); - if(m_BossHealthProgress1_small[i]!=NULL) + if(m_BossHealthProgress1_small[i]!=nullptr) { m_BossHealthProgress1_small[i].SetShow(FALSE); m_BossHealthProgress2_small[i].SetShow(FALSE); @@ -320,7 +320,7 @@ void CXuiSceneBase::_TickAllBaseScenes() m_BossHealthProgress1[i].SetShow(FALSE); m_BossHealthProgress2[i].SetShow(FALSE); m_BossHealthProgress3[i].SetShow(TRUE); - if(m_BossHealthProgress1_small[i]!=NULL) + if(m_BossHealthProgress1_small[i]!=nullptr) { m_BossHealthProgress1_small[i].SetShow(FALSE); m_BossHealthProgress2_small[i].SetShow(FALSE); @@ -470,7 +470,7 @@ void CXuiSceneBase::_TickAllBaseScenes() XuiSendMessage( app.GetCurrentHUDScene(i), &xuiMsg ); bool bDisplayGui=app.GetGameStarted() && !ui.GetMenuDisplayed(i) && !(app.GetXuiAction(i)==eAppAction_AutosaveSaveGameCapturedThumbnail) && app.GetGameSettings(i,eGameSetting_DisplayHUD)!=0; - if(bDisplayGui && pMinecraft->localplayers[i] != NULL) + if(bDisplayGui && pMinecraft->localplayers[i] != nullptr) { XuiElementSetShow(app.GetCurrentHUDScene(i),TRUE); } @@ -498,7 +498,7 @@ HRESULT CXuiSceneBase::_SetTooltipText( unsigned int iPad, unsigned int uiToolti XUIRect xuiRect, xuiRectSmall; HRESULT hr=S_OK; - LPCWSTR pString=NULL; + LPCWSTR pString=nullptr; float fWidth,fHeight; // Want to be able to show just a button (for RB LB) @@ -507,17 +507,17 @@ HRESULT CXuiSceneBase::_SetTooltipText( unsigned int iPad, unsigned int uiToolti pString=app.GetString(iTextID); } - if(hTooltipText[iPad][uiTooltip]==NULL) + if(hTooltipText[iPad][uiTooltip]==nullptr) { - HXUIOBJ hObj=NULL; + HXUIOBJ hObj=nullptr; hr=XuiControlGetVisual(m_Buttons[iPad][uiTooltip].m_hObj,&hObj); hr=XuiElementGetChildById(hObj,L"text_ButtonText",&hTooltipText[iPad][uiTooltip]); hr=XuiElementGetPosition(hTooltipText[iPad][uiTooltip],&m_vPosTextInTooltip[uiTooltip]); } - if(hTooltipTextSmall[iPad][uiTooltip]==NULL) + if(hTooltipTextSmall[iPad][uiTooltip]==nullptr) { - HXUIOBJ hObj=NULL; + HXUIOBJ hObj=nullptr; hr=XuiControlGetVisual(m_ButtonsSmall[iPad][uiTooltip].m_hObj,&hObj); hr=XuiElementGetChildById(hObj,L"text_ButtonText",&hTooltipTextSmall[iPad][uiTooltip]); hr=XuiElementGetPosition(hTooltipTextSmall[iPad][uiTooltip],&m_vPosTextInTooltipSmall[uiTooltip]); @@ -858,7 +858,7 @@ HRESULT CXuiSceneBase::_ShowBackground( unsigned int iPad, BOOL bShow ) hr=XuiElementGetChildById(hVisual,L"NightGroup",&hNight); hr=XuiElementGetChildById(hVisual,L"DayGroup",&hDay); - if(bShow && pMinecraft->level!=NULL) + if(bShow && pMinecraft->level!=nullptr) { __int64 i64TimeOfDay =0; // are we in the Nether? - Leave the time as 0 if we are, so we show daylight @@ -911,7 +911,7 @@ HRESULT CXuiSceneBase::_ShowPressStart(unsigned int iPad) m_PressStart.SetShow(TRUE); // retrieve the visual for this quadrant - HXUIOBJ hObj=NULL,hQuadrant; + HXUIOBJ hObj=nullptr,hQuadrant; HRESULT hr=XuiControlGetVisual(m_PressStart.m_hObj,&hObj); hr=XuiElementGetChildById(hObj,L"text_ButtonText",&hQuadrant); memset(&xuiRect, 0, sizeof(xuiRect)); @@ -1038,7 +1038,7 @@ bool CXuiSceneBase::_PressStartPlaying(unsigned int iPad) HRESULT CXuiSceneBase::_SetPlayerBaseScenePosition( unsigned int iPad, EBaseScenePosition position ) { // turn off the empty quadrant logo - if(m_hEmptyQuadrantLogo!=NULL) + if(m_hEmptyQuadrantLogo!=nullptr) { XuiElementSetShow(m_hEmptyQuadrantLogo,FALSE); } @@ -1268,7 +1268,7 @@ HRESULT CXuiSceneBase::_SetPlayerBaseScenePosition( unsigned int iPad, EBaseScen // 4J Stu - If we already have some scenes open, then call this to update their positions // Fix for #10960 - All Lang: UI: Split-screen: Changing split screen mode (vertical/horizontal) make window layout strange - if(Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->localplayers[iPad]!=NULL) + if(Minecraft::GetInstance() != nullptr && Minecraft::GetInstance()->localplayers[iPad]!=nullptr) { // 4J-PB - Can only do this once we know what the player's UI settings are, so we need to have the player game settings read _UpdateSelectedItemPos(iPad); @@ -1339,7 +1339,7 @@ void CXuiSceneBase::_UpdateSelectedItemPos(unsigned int iPad) unsigned char ucGuiScale=app.GetGameSettings(iPad,eGameSetting_UISize) + 2; - if(Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->localgameModes[iPad] != NULL && Minecraft::GetInstance()->localgameModes[iPad]->canHurtPlayer()) + if(Minecraft::GetInstance() != nullptr && Minecraft::GetInstance()->localgameModes[iPad] != nullptr && Minecraft::GetInstance()->localgameModes[iPad]->canHurtPlayer()) { // SURVIVAL MODE - Move up further because of hearts, shield and xp switch(ucGuiScale) @@ -1428,7 +1428,7 @@ void CXuiSceneBase::_UpdateSelectedItemPos(unsigned int iPad) { float scale=0.5f; selectedItemPos.y -= (scale * 88.0f); - if(Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->localgameModes[iPad] != NULL && Minecraft::GetInstance()->localgameModes[iPad]->canHurtPlayer()) + if(Minecraft::GetInstance() != nullptr && Minecraft::GetInstance()->localgameModes[iPad] != nullptr && Minecraft::GetInstance()->localgameModes[iPad]->canHurtPlayer()) { selectedItemPos.y -= (scale * 80.0f); } @@ -1471,7 +1471,7 @@ CXuiSceneBase::EBaseScenePosition CXuiSceneBase::_GetPlayerBasePosition(int iPad void CXuiSceneBase::_SetEmptyQuadrantLogo(int iPad,EBaseScenePosition ePos) { - if(m_hEmptyQuadrantLogo!=NULL) + if(m_hEmptyQuadrantLogo!=nullptr) { for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { @@ -1607,7 +1607,7 @@ HRESULT CXuiSceneBase::_DisplayGamertag( unsigned int iPad, BOOL bDisplay ) // The host decides whether these are on or off if(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags)!=0) { - if(Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->localplayers[iPad]!=NULL) + if(Minecraft::GetInstance() != nullptr && Minecraft::GetInstance()->localplayers[iPad]!=nullptr) { wstring wsGamertag = convStringToWstring( ProfileManager.GetGamertag(iPad)); XuiControlSetText(m_hGamerTagA[iPad],wsGamertag.c_str()); @@ -1864,7 +1864,7 @@ void CXuiSceneBase::ReLayout( unsigned int iPad ) void CXuiSceneBase::TickAllBaseScenes() { - if( CXuiSceneBase::Instance != NULL ) + if( CXuiSceneBase::Instance != nullptr ) { CXuiSceneBase::Instance->_TickAllBaseScenes(); } @@ -1872,7 +1872,7 @@ void CXuiSceneBase::TickAllBaseScenes() HRESULT CXuiSceneBase::SetEnableTooltips( unsigned int iPad, BOOL bVal ) { - if( CXuiSceneBase::Instance != NULL ) + if( CXuiSceneBase::Instance != nullptr ) { return CXuiSceneBase::Instance->_SetEnableTooltips(iPad, bVal ); } @@ -1881,7 +1881,7 @@ HRESULT CXuiSceneBase::SetEnableTooltips( unsigned int iPad, BOOL bVal ) HRESULT CXuiSceneBase::SetTooltipText( unsigned int iPad, unsigned int tooltip, int iTextID ) { - if( CXuiSceneBase::Instance != NULL ) + if( CXuiSceneBase::Instance != nullptr ) { return CXuiSceneBase::Instance->_SetTooltipText(iPad, tooltip, iTextID ); } @@ -1890,7 +1890,7 @@ HRESULT CXuiSceneBase::SetTooltipText( unsigned int iPad, unsigned int tooltip, HRESULT CXuiSceneBase::RefreshTooltips( unsigned int iPad) { - if( CXuiSceneBase::Instance != NULL ) + if( CXuiSceneBase::Instance != nullptr ) { return CXuiSceneBase::Instance->_RefreshTooltips(iPad); } @@ -1899,7 +1899,7 @@ HRESULT CXuiSceneBase::RefreshTooltips( unsigned int iPad) HRESULT CXuiSceneBase::ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ) { - if( CXuiSceneBase::Instance != NULL ) + if( CXuiSceneBase::Instance != nullptr ) { return CXuiSceneBase::Instance->_ShowTooltip(iPad, tooltip, show ); } @@ -1908,7 +1908,7 @@ HRESULT CXuiSceneBase::ShowTooltip( unsigned int iPad, unsigned int tooltip, boo HRESULT CXuiSceneBase::ShowSafeArea( BOOL bShow ) { - if( CXuiSceneBase::Instance != NULL ) + if( CXuiSceneBase::Instance != nullptr ) { return CXuiSceneBase::Instance->_ShowSafeArea(bShow ); } @@ -1917,7 +1917,7 @@ HRESULT CXuiSceneBase::ShowSafeArea( BOOL bShow ) HRESULT CXuiSceneBase::SetTooltips( unsigned int iPad, int iA, int iB, int iX, int iY , int iLT, int iRT, int iRB, int iLB, int iLS, bool forceUpdate /*= false*/ ) { - if( CXuiSceneBase::Instance != NULL ) + if( CXuiSceneBase::Instance != nullptr ) { // Enable all the tooltips. We should disable them in the scenes as required CXuiSceneBase::Instance->_SetTooltipsEnabled( iPad ); @@ -1978,7 +1978,7 @@ HRESULT CXuiSceneBase::AnimateKeyPress(DWORD userIndex, DWORD dwKeyCode) HRESULT CXuiSceneBase::ShowSavingMessage( unsigned int iPad, C4JStorage::ESavingMessage eVal ) { - if( CXuiSceneBase::Instance != NULL ) + if( CXuiSceneBase::Instance != nullptr ) { return CXuiSceneBase::Instance->_ShowSavingMessage(iPad, eVal); } @@ -2078,7 +2078,7 @@ HRESULT CXuiSceneBase::UpdatePlayerBasePositions() Minecraft *pMinecraft = Minecraft::GetInstance(); // If the game is not started (or is being held paused for a bit) then display all scenes fullscreen - if( pMinecraft == NULL ) + if( pMinecraft == nullptr ) { for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) { @@ -2105,7 +2105,7 @@ HRESULT CXuiSceneBase::UpdatePlayerBasePositions() for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(pMinecraft->localplayers[idx] != NULL) + if(pMinecraft->localplayers[idx] != nullptr) { if(pMinecraft->localplayers[idx]->m_iScreenSection==C4JRender::VIEWPORT_TYPE_FULLSCREEN) { @@ -2186,7 +2186,7 @@ void CXuiSceneBase::SetEmptyQuadrantLogo(int iScreenSection) // find the empty player for( iPad = 0; iPad < XUSER_MAX_COUNT; ++iPad) { - if(pMinecraft->localplayers[iPad] == NULL) + if(pMinecraft->localplayers[iPad] == nullptr) { switch( iScreenSection) { @@ -2238,6 +2238,6 @@ void CXuiSceneBase::CreateBaseSceneInstance() { CXuiSceneBase *sceneBase = new CXuiSceneBase(); BOOL handled; - sceneBase->OnInit(NULL,handled); + sceneBase->OnInit(nullptr,handled); } #endif \ No newline at end of file diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_BrewingStand.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_BrewingStand.cpp index 51a019cfd..a55e8f777 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_BrewingStand.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_BrewingStand.cpp @@ -36,7 +36,7 @@ HRESULT CXuiSceneBrewingStand::OnInit( XUIMessageInit* pInitData, BOOL& bHandled } #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -67,16 +67,16 @@ HRESULT CXuiSceneBrewingStand::OnDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } #endif // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -106,7 +106,7 @@ CXuiControl* CXuiSceneBrewingStand::GetSectionControl( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } CXuiCtrlSlotList* CXuiSceneBrewingStand::GetSectionSlotList( ESceneSection eSection ) @@ -135,7 +135,7 @@ CXuiCtrlSlotList* CXuiSceneBrewingStand::GetSectionSlotList( ESceneSection eSect assert( false ); break; } - return NULL; + return nullptr; } // 4J Stu - Added to support auto-save. Need to re-associate on a navigate back diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Container.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Container.cpp index 70eb7c3cf..25f5cffcb 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Container.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Container.cpp @@ -40,7 +40,7 @@ HRESULT CXuiSceneContainer::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) m_bSplitscreen=initData->bSplitscreen; #ifdef _XBOX - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -95,16 +95,16 @@ HRESULT CXuiSceneContainer::OnDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } #endif // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -125,7 +125,7 @@ CXuiControl* CXuiSceneContainer::GetSectionControl( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } CXuiCtrlSlotList* CXuiSceneContainer::GetSectionSlotList( ESceneSection eSection ) @@ -145,7 +145,7 @@ CXuiCtrlSlotList* CXuiSceneContainer::GetSectionSlotList( ESceneSection eSection assert( false ); break; } - return NULL; + return nullptr; } // 4J Stu - Added to support auto-save. Need to re-associate on a navigate back diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_CraftingPanel.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_CraftingPanel.cpp index cea213939..f1c51ff0d 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_CraftingPanel.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_CraftingPanel.cpp @@ -165,7 +165,7 @@ HRESULT CXuiSceneCraftingPanel::OnInit( XUIMessageInit* pInitData, BOOL& bHandle Minecraft *pMinecraft = Minecraft::GetInstance(); #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -206,7 +206,7 @@ HRESULT CXuiSceneCraftingPanel::OnTransitionEnd( XUIMessageTransition *pTransDat { for(int i=0;iiItem; int iId=(pData->iData>>22)&0x1FF; - pData->szPath = NULL; + pData->szPath = nullptr; pData->bDirty=true; rfHandled = TRUE; return hr; @@ -352,15 +352,15 @@ HRESULT CXuiSceneCraftingPanel::OnDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } #endif // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -433,7 +433,7 @@ void CXuiSceneCraftingPanel::setCraftVSlotItem(int iPad, int iIndex, shared_ptr< void CXuiSceneCraftingPanel::setCraftingOutputSlotItem(int iPad, shared_ptr item) { - if(item == NULL) + if(item == nullptr) { m_pCraftingOutput->SetIcon(iPad, 0,0,0,0,0,false); } @@ -450,7 +450,7 @@ void CXuiSceneCraftingPanel::setCraftingOutputSlotRedBox(bool show) void CXuiSceneCraftingPanel::setIngredientSlotItem(int iPad, int index, shared_ptr item) { - if(item == NULL) + if(item == nullptr) { m_pCraftingIngredientA[index]->SetIcon(iPad, 0,0,0,0,0,false); } diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Enchant.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Enchant.cpp index 6e5159b20..dabe6d6d1 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Enchant.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Enchant.cpp @@ -42,7 +42,7 @@ HRESULT CXuiSceneEnchant::OnInit( XUIMessageInit *pInitData, BOOL &bHandled ) } #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -73,16 +73,16 @@ HRESULT CXuiSceneEnchant::OnDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } #endif // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -112,7 +112,7 @@ CXuiControl* CXuiSceneEnchant::GetSectionControl( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } CXuiCtrlSlotList* CXuiSceneEnchant::GetSectionSlotList( ESceneSection eSection ) @@ -132,7 +132,7 @@ CXuiCtrlSlotList* CXuiSceneEnchant::GetSectionSlotList( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } // 4J Stu - Added to support auto-save. Need to re-associate on a navigate back diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Furnace.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Furnace.cpp index 54f3591b9..c5e2d22c3 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Furnace.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Furnace.cpp @@ -38,7 +38,7 @@ HRESULT CXuiSceneFurnace::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) } #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -69,16 +69,16 @@ HRESULT CXuiSceneFurnace::OnDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } #endif // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -105,7 +105,7 @@ CXuiControl* CXuiSceneFurnace::GetSectionControl( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } CXuiCtrlSlotList* CXuiSceneFurnace::GetSectionSlotList( ESceneSection eSection ) @@ -131,7 +131,7 @@ CXuiCtrlSlotList* CXuiSceneFurnace::GetSectionSlotList( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } // 4J Stu - Added to support auto-save. Need to re-associate on a navigate back diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory.cpp index a5532fefc..e86ff67e0 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory.cpp @@ -38,7 +38,7 @@ HRESULT CXuiSceneInventory::OnInit( XUIMessageInit *pInitData, BOOL &bHandled ) } #ifdef _XBOX - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -79,15 +79,15 @@ HRESULT CXuiSceneInventory::OnDestroy() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -118,7 +118,7 @@ CXuiControl* CXuiSceneInventory::GetSectionControl( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } CXuiCtrlSlotList* CXuiSceneInventory::GetSectionSlotList( ESceneSection eSection ) @@ -138,7 +138,7 @@ CXuiCtrlSlotList* CXuiSceneInventory::GetSectionSlotList( ESceneSection eSection assert( false ); break; } - return NULL; + return nullptr; } // 4J Stu - Added to support auto-save. Need to re-associate on a navigate back @@ -156,7 +156,7 @@ void CXuiSceneInventory::updateEffectsDisplay() Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player == NULL) return; + if(player == nullptr) return; vector *activeEffects = player->getActiveEffects(); diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp index 415d7b51e..345d426dd 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp @@ -48,7 +48,7 @@ HRESULT CXuiSceneInventoryCreative::OnInit( XUIMessageInit *pInitData, BOOL &bHa } #ifdef _XBOX - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -95,16 +95,16 @@ HRESULT CXuiSceneInventoryCreative::OnDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } #endif // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -126,7 +126,7 @@ HRESULT CXuiSceneInventoryCreative::OnTransitionEnd( XUIMessageTransition *pTran { for(int i=0;im_icon,NULL,specs[i]->m_icon); + m_hGroupIconA[i].PlayVisualRange(specs[i]->m_icon,nullptr,specs[i]->m_icon); XuiElementSetShow(m_hGroupIconA[i].m_hObj,TRUE); } } @@ -148,7 +148,7 @@ CXuiControl* CXuiSceneInventoryCreative::GetSectionControl( ESceneSection eSecti assert( false ); break; } - return NULL; + return nullptr; } CXuiCtrlSlotList* CXuiSceneInventoryCreative::GetSectionSlotList( ESceneSection eSection ) @@ -165,7 +165,7 @@ CXuiCtrlSlotList* CXuiSceneInventoryCreative::GetSectionSlotList( ESceneSection assert( false ); break; } - return NULL; + return nullptr; } void CXuiSceneInventoryCreative::updateTabHighlightAndText(ECreativeInventoryTabs tab) diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Trading.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Trading.cpp index b6f3df50e..3fbca979e 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Trading.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Trading.cpp @@ -39,7 +39,7 @@ HRESULT CXuiSceneTrading::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad); } - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -79,15 +79,15 @@ HRESULT CXuiSceneTrading::OnDestroy() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -97,7 +97,7 @@ HRESULT CXuiSceneTrading::OnTransitionStart( XUIMessageTransition *pTransition, if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO) { - HXUIOBJ hObj=NULL; + HXUIOBJ hObj=nullptr; HRESULT hr=XuiControlGetVisual(m_offerInfoControl.m_hObj,&hObj); hr=XuiElementGetChildById(hObj,L"text_measurer",&m_hOfferInfoTextMeasurer); hr=XuiElementGetChildById(hObj,L"text_name",&m_hOfferInfoText); diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Trap.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Trap.cpp index 4453185ea..326e62639 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Trap.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Trap.cpp @@ -27,7 +27,7 @@ HRESULT CXuiSceneTrap::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) m_bSplitscreen=initData->bSplitscreen; #ifdef _XBOX - if( pMinecraft->localgameModes[initData->iPad] != NULL ) + if( pMinecraft->localgameModes[initData->iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); @@ -57,16 +57,16 @@ HRESULT CXuiSceneTrap::OnDestroy() Minecraft *pMinecraft = Minecraft::GetInstance(); #ifdef _XBOX - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad]; - if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); + if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState); } #endif // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss. // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying) - if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + if(Minecraft::GetInstance()->localplayers[m_iPad] != nullptr) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); return S_OK; } @@ -87,7 +87,7 @@ CXuiControl* CXuiSceneTrap::GetSectionControl( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } CXuiCtrlSlotList* CXuiSceneTrap::GetSectionSlotList( ESceneSection eSection ) @@ -107,7 +107,7 @@ CXuiCtrlSlotList* CXuiSceneTrap::GetSectionSlotList( ESceneSection eSection ) assert( false ); break; } - return NULL; + return nullptr; } // 4J Stu - Added to support auto-save. Need to re-associate on a navigate back diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp index 9c491be67..e61815d9b 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp @@ -68,7 +68,7 @@ HRESULT CScene_Win::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[s_winUserIndex] != NULL) + if(pMinecraft->localplayers[s_winUserIndex] != nullptr) { noNoiseString = replaceAll(noNoiseString,L"{*PLAYER*}",pMinecraft->localplayers[s_winUserIndex]->name); } @@ -134,7 +134,7 @@ HRESULT CScene_Win::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) app.CloseAllPlayersXuiScenes(); for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if(pMinecraft->localplayers[i] != NULL) + if(pMinecraft->localplayers[i] != nullptr) { app.SetAction(i,eAppAction_Respawn); } @@ -143,7 +143,7 @@ HRESULT CScene_Win::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) // Show the other players scenes CXuiSceneBase::ShowOtherPlayersBaseScene(pInputData->UserIndex, true); // This just allows it to be shown - if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true); + if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true); ui.UpdatePlayerBasePositions(); rfHandled = TRUE; @@ -277,7 +277,7 @@ HRESULT CScene_Win::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) CXuiSceneBase::ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), false); // This just allows it to be shown - if(Minecraft::GetInstance()->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) Minecraft::GetInstance()->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); + if(Minecraft::GetInstance()->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) Minecraft::GetInstance()->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); // Temporarily make this scene fullscreen CXuiSceneBase::SetPlayerBaseScenePosition( ProfileManager.GetPrimaryPad(), CXuiSceneBase::e_BaseScene_Fullscreen ); diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsAll.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsAll.cpp index 26219376e..3c37b8d85 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsAll.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsAll.cpp @@ -12,7 +12,7 @@ HRESULT CScene_SettingsAll::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) //WCHAR TempString[256]; m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); MapChildControls(); @@ -112,7 +112,7 @@ HRESULT CScene_SettingsAll::OnControlNavigate(XUIMessageControlNavigate *pContro // added so we can skip greyed out items pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -181,7 +181,7 @@ HRESULT CScene_SettingsAll::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* HRESULT CScene_SettingsAll::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); // if we're not in the game, we need to use basescene 0 if(bNotInGame) diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsAudio.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsAudio.cpp index f654a3764..6f399d55e 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsAudio.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsAudio.cpp @@ -9,7 +9,7 @@ HRESULT CScene_SettingsAudio::OnInit( XUIMessageInit* pInitData, BOOL& bHandled WCHAR TempString[256]; m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); MapChildControls(); @@ -141,7 +141,7 @@ HRESULT CScene_SettingsAudio::OnControlNavigate(XUIMessageControlNavigate *pCont // added so we can skip greyed out items pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -240,7 +240,7 @@ HRESULT CScene_SettingsAudio::OnTransitionStart( XUIMessageTransition *pTransiti HRESULT CScene_SettingsAudio::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); // if we're not in the game, we need to use basescene 0 if(bNotInGame) diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsControl.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsControl.cpp index 7bedc2fa2..4fa335fb5 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsControl.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsControl.cpp @@ -12,7 +12,7 @@ HRESULT CScene_SettingsControl::OnInit( XUIMessageInit* pInitData, BOOL& bHandle WCHAR TempString[256]; m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); MapChildControls(); @@ -120,7 +120,7 @@ HRESULT CScene_SettingsControl::OnControlNavigate(XUIMessageControlNavigate *pCo // added so we can skip greyed out items pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -218,7 +218,7 @@ HRESULT CScene_SettingsControl::OnTransitionStart( XUIMessageTransition *pTransi HRESULT CScene_SettingsControl::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); // if we're not in the game, we need to use basescene 0 if(bNotInGame) diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsGraphics.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsGraphics.cpp index 3ce414c57..d73baa0b3 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsGraphics.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsGraphics.cpp @@ -12,7 +12,7 @@ HRESULT CScene_SettingsGraphics::OnInit( XUIMessageInit* pInitData, BOOL& bHandl WCHAR TempString[256]; m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); bool bIsPrimaryPad=(ProfileManager.GetPrimaryPad()==m_iPad); MapChildControls(); @@ -198,7 +198,7 @@ HRESULT CScene_SettingsGraphics::OnControlNavigate(XUIMessageControlNavigate *pC // added so we can skip greyed out items pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -310,7 +310,7 @@ HRESULT CScene_SettingsGraphics::OnTransitionStart( XUIMessageTransition *pTrans HRESULT CScene_SettingsGraphics::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); // if we're not in the game, we need to use basescene 0 if(bNotInGame) diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsOptions.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsOptions.cpp index f8fb5ae98..683ee175e 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsOptions.cpp @@ -28,7 +28,7 @@ HRESULT CScene_SettingsOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandle WCHAR TempString[256]; m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; MapChildControls(); @@ -353,7 +353,7 @@ HRESULT CScene_SettingsOptions::OnControlNavigate(XUIMessageControlNavigate *pCo // added so we can skip greyed out items pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -467,7 +467,7 @@ HRESULT CScene_SettingsOptions::OnTransitionStart( XUIMessageTransition *pTransi // Need to refresh the scenes visual since the object size has now changed XuiControlAttachVisual(m_hObj); - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { diff --git a/Minecraft.Client/Common/XUI/XUI_SettingsUI.cpp b/Minecraft.Client/Common/XUI/XUI_SettingsUI.cpp index 1dc837757..ab9cc53b4 100644 --- a/Minecraft.Client/Common/XUI/XUI_SettingsUI.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SettingsUI.cpp @@ -12,7 +12,7 @@ HRESULT CScene_SettingsUI::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) WCHAR TempString[256]; m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; MapChildControls(); @@ -210,7 +210,7 @@ HRESULT CScene_SettingsUI::OnControlNavigate(XUIMessageControlNavigate *pControl // added so we can skip greyed out items pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest!=NULL) + if(pControlNavigateData->hObjDest!=nullptr) { bHandled=TRUE; } @@ -353,7 +353,7 @@ HRESULT CScene_SettingsUI::OnTransitionStart( XUIMessageTransition *pTransition, HRESULT CScene_SettingsUI::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) { - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); // if we're not in the game, we need to use basescene 0 if(bNotInGame) diff --git a/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp b/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp index 32336cb72..6c54c3e31 100644 --- a/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp @@ -75,7 +75,7 @@ HRESULT CScene_SignEntry::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* p if (pMinecraft->level->isClientSide) { shared_ptr player = pMinecraft->localplayers[pNotifyPressData->UserIndex]; - if(player != NULL && player->connection && player->connection->isStarted()) + if(player != nullptr && player->connection && player->connection->isStarted()) { player->connection->send( shared_ptr( new SignUpdatePacket(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages()) ) ); } diff --git a/Minecraft.Client/Common/XUI/XUI_SkinSelect.cpp b/Minecraft.Client/Common/XUI/XUI_SkinSelect.cpp index b2f2f0a39..b92159c05 100644 --- a/Minecraft.Client/Common/XUI/XUI_SkinSelect.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SkinSelect.cpp @@ -28,7 +28,7 @@ HRESULT CScene_SkinSelect::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { m_iPad=*static_cast(pInitData->pvInitData); // if we're not in the game, we need to use basescene 0 - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); m_bIgnoreInput=false; // 4J Stu - Added this so that we have skins loaded @@ -46,7 +46,7 @@ HRESULT CScene_SkinSelect::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) m_skinIndex = 0; m_currentSkinPath = app.GetPlayerSkinName(m_iPad); m_originalSkinId = app.GetPlayerSkinId(m_iPad); - m_currentPack = NULL; + m_currentPack = nullptr; m_bSlidingSkins = false; m_bAnimatingMove = false; currentPackCount = 0; @@ -86,7 +86,7 @@ HRESULT CScene_SkinSelect::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) // Change to display the favorites if there are any. The current skin will be in there (probably) - need to check for it m_currentPack = app.m_dlcManager.getPackContainingSkin(m_currentSkinPath); bool bFound; - if(m_currentPack != NULL) + if(m_currentPack != nullptr) { m_packIndex = app.m_dlcManager.getPackIndex(m_currentPack,bFound,DLCManager::e_DLCType_Skin) + SKIN_SELECT_MAX_DEFAULTS; } @@ -232,7 +232,7 @@ HRESULT CScene_SkinSelect::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandle } break; default: - if( m_currentPack != NULL ) + if( m_currentPack != nullptr ) { DLCSkinFile *skinFile = m_currentPack->getSkinFile(m_skinIndex); @@ -266,7 +266,7 @@ HRESULT CScene_SkinSelect::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandle DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(m_currentPack->getPurchaseOfferId()); ULONGLONG ullOfferID_Full; - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullOfferID_Full=pDLCInfo->ullOfferID_Full; } @@ -626,8 +626,8 @@ void CScene_SkinSelect::handleSkinIndexChanged() wstring skinOrigin = L""; bool bSkinIsFree=false; bool bLicensed=false; - DLCSkinFile *skinFile=NULL; - DLCPack *Pack=NULL; + DLCSkinFile *skinFile=nullptr; + DLCPack *Pack=nullptr; BYTE sidePreviewControlsL,sidePreviewControlsR; bool bNoSkinsToShow=false; @@ -635,7 +635,7 @@ void CScene_SkinSelect::handleSkinIndexChanged() m_selectedGroup.SetShow( FALSE ); m_skinDetails.SetShow( FALSE ); - if( m_currentPack != NULL ) + if( m_currentPack != nullptr ) { skinFile = m_currentPack->getSkinFile(m_skinIndex); m_selectedSkinPath = skinFile->getPath(); @@ -665,7 +665,7 @@ void CScene_SkinSelect::handleSkinIndexChanged() { m_selectedSkinPath = L""; m_selectedCapePath = L""; - m_vAdditionalSkinBoxes = NULL; + m_vAdditionalSkinBoxes = nullptr; switch(m_packIndex) { @@ -753,13 +753,13 @@ void CScene_SkinSelect::handleSkinIndexChanged() { // add the boxes to the humanoid model, but only if we've not done this already vector *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); - if(pAdditionalModelParts==NULL) + if(pAdditionalModelParts==nullptr) { pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),m_vAdditionalSkinBoxes); } } - if(skinFile!=NULL) + if(skinFile!=nullptr) { app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); } @@ -774,7 +774,7 @@ void CScene_SkinSelect::handleSkinIndexChanged() wstring otherSkinPath = L""; wstring otherCapePath = L""; - vector *othervAdditionalSkinBoxes=NULL; + vector *othervAdditionalSkinBoxes=nullptr; wchar_t chars[256]; // turn off all displays @@ -820,10 +820,10 @@ void CScene_SkinSelect::handleSkinIndexChanged() { if(showNext) { - skinFile=NULL; + skinFile=nullptr; m_previewNextControls[i]->SetShow(TRUE); - if( m_currentPack != NULL ) + if( m_currentPack != nullptr ) { skinFile = m_currentPack->getSkinFile(nextIndex); otherSkinPath = skinFile->getPath(); @@ -835,7 +835,7 @@ void CScene_SkinSelect::handleSkinIndexChanged() { otherSkinPath = L""; otherCapePath = L""; - othervAdditionalSkinBoxes=NULL; + othervAdditionalSkinBoxes=nullptr; switch(m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -867,13 +867,13 @@ void CScene_SkinSelect::handleSkinIndexChanged() if(othervAdditionalSkinBoxes && othervAdditionalSkinBoxes->size()!=0) { vector *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); - if(pAdditionalModelParts==NULL) + if(pAdditionalModelParts==nullptr) { pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); } } // 4J-PB - anim override needs set before SetTexture - if(skinFile!=NULL) + if(skinFile!=nullptr) { app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); } @@ -892,10 +892,10 @@ void CScene_SkinSelect::handleSkinIndexChanged() { if(showPrevious) { - skinFile=NULL; + skinFile=nullptr; m_previewPreviousControls[i]->SetShow(TRUE); - if( m_currentPack != NULL ) + if( m_currentPack != nullptr ) { skinFile = m_currentPack->getSkinFile(previousIndex); otherSkinPath = skinFile->getPath(); @@ -907,7 +907,7 @@ void CScene_SkinSelect::handleSkinIndexChanged() { otherSkinPath = L""; otherCapePath = L""; - othervAdditionalSkinBoxes=NULL; + othervAdditionalSkinBoxes=nullptr; switch(m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -939,7 +939,7 @@ void CScene_SkinSelect::handleSkinIndexChanged() if(othervAdditionalSkinBoxes && othervAdditionalSkinBoxes->size()!=0) { vector *pAdditionalModelParts = app.GetAdditionalModelParts(skinFile->getSkinID()); - if(pAdditionalModelParts==NULL) + if(pAdditionalModelParts==nullptr) { pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); } @@ -957,7 +957,7 @@ void CScene_SkinSelect::handleSkinIndexChanged() } // update the tooltips - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNoSkinsToShow) { @@ -1001,10 +1001,10 @@ void CScene_SkinSelect::handlePackIndexChanged() } else { - m_currentPack = NULL; + m_currentPack = nullptr; } m_skinIndex = 0; - if(m_currentPack != NULL) + if(m_currentPack != nullptr) { bool found; DWORD currentSkinIndex = m_currentPack->getSkinIndexAt(m_currentSkinPath, found); @@ -1199,7 +1199,7 @@ int CScene_SkinSelect::getNextSkinIndex(DWORD sourceIndex) { nextSkin = eDefaultSkins_ServerSelected; } - else if(m_currentPack != NULL && nextSkin>=m_currentPack->getSkinCount()) + else if(m_currentPack != nullptr && nextSkin>=m_currentPack->getSkinCount()) { nextSkin = 0; } @@ -1233,7 +1233,7 @@ int CScene_SkinSelect::getPreviousSkinIndex(DWORD sourceIndex) { previousSkin = eDefaultSkins_Count - 1; } - else if(m_currentPack != NULL) + else if(m_currentPack != nullptr) { previousSkin = m_currentPack->getSkinCount()-1; } @@ -1320,7 +1320,7 @@ int CScene_SkinSelect::UnlockSkinReturned(void *pParam,int iPad,C4JStorage::EMes ULONGLONG ullIndexA[1]; DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(pScene->m_currentPack->getPurchaseOfferId()); - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { ullIndexA[0]=pDLCInfo->ullOfferID_Full; } @@ -1330,13 +1330,13 @@ int CScene_SkinSelect::UnlockSkinReturned(void *pParam,int iPad,C4JStorage::EMes } // If we're in-game, then we need to enable DLC downloads. They'll be set back to Auto on leaving the pause menu - if(Minecraft::GetInstance()->level!=NULL) + if(Minecraft::GetInstance()->level!=nullptr) { // need to allow downloads here, or the player would need to quit the game to let the download of a skin pack happen. This might affect the network traffic, since the download could take all the bandwidth... XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); } - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); + StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr); // the license change coming in when the offer has been installed will cause this scene to refresh } @@ -1380,7 +1380,7 @@ HRESULT CScene_SkinSelect::OnCustomMessage_DLCMountingComplete() if(app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin)>0) { m_currentPack = app.m_dlcManager.getPackContainingSkin(m_currentSkinPath); - if(m_currentPack != NULL) + if(m_currentPack != nullptr) { bool bFound = false; m_packIndex = app.m_dlcManager.getPackIndex(m_currentPack,bFound,DLCManager::e_DLCType_Skin) + SKIN_SELECT_MAX_DEFAULTS; @@ -1400,7 +1400,7 @@ HRESULT CScene_SkinSelect::OnCustomMessage_DLCMountingComplete() updateCurrentFocus(); m_bIgnoreInput=false; app.m_dlcManager.checkForCorruptDLCAndAlert(); - bool bInGame=(Minecraft::GetInstance()->level!=NULL); + bool bInGame=(Minecraft::GetInstance()->level!=nullptr); if(bInGame) XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO); diff --git a/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp b/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp index 26dd220b7..2bd842638 100644 --- a/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp @@ -89,7 +89,7 @@ HRESULT CScene_SocialPost::OnControlNavigate(XUIMessageControlNavigate *pControl { pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE); - if(pControlNavigateData->hObjDest==NULL) + if(pControlNavigateData->hObjDest==nullptr) { pControlNavigateData->hObjDest=pControlNavigateData->hObjSource; } diff --git a/Minecraft.Client/Common/XUI/XUI_Teleport.cpp b/Minecraft.Client/Common/XUI/XUI_Teleport.cpp index 5b13a376e..bbf0005e9 100644 --- a/Minecraft.Client/Common/XUI/XUI_Teleport.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Teleport.cpp @@ -51,7 +51,7 @@ HRESULT CScene_Teleport::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); - if( player != NULL && !(player->IsLocal() && player->GetUserIndex() == m_iPad) ) + if( player != nullptr && !(player->IsLocal() && player->GetUserIndex() == m_iPad) ) { m_players[m_playersCount] = player->GetSmallId(); ++m_playersCount; @@ -167,7 +167,7 @@ HRESULT CScene_Teleport::OnGetSourceDataText(XUIMessageGetSourceText *pGetSource if( pGetSourceTextData->iItem < m_playersCount ) { INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId( m_players[pGetSourceTextData->iItem] ); - if( player != NULL ) + if( player != nullptr ) { #ifndef _CONTENT_PACKAGE if(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask()&(1L<HasVoice() ) + if(player != nullptr && player->HasVoice() ) { if( player->IsMutedByLocalUser(m_iPad) ) { diff --git a/Minecraft.Client/Common/XUI/XUI_TransferToXboxOne.cpp b/Minecraft.Client/Common/XUI/XUI_TransferToXboxOne.cpp index 07304e604..da224f7a3 100644 --- a/Minecraft.Client/Common/XUI/XUI_TransferToXboxOne.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TransferToXboxOne.cpp @@ -28,7 +28,7 @@ HRESULT CScene_TransferToXboxOne::OnInit( XUIMessageInit* pInitData, BOOL& bHand XuiObjectFromHandle( m_SavesSlotList, &pObj ); m_pSavesSlotList = static_cast(pObj); - m_pbImageData=NULL; + m_pbImageData=nullptr; m_dwImageBytes=0; StorageManager.GetSaveCacheFileInfo(m_params->iSaveGameInfoIndex,m_XContentData); @@ -48,7 +48,7 @@ HRESULT CScene_TransferToXboxOne::OnInit( XUIMessageInit* pInitData, BOOL& bHand // saves will be called slot1 to slotx // there will be a details file with the names and png of each slot - m_pbSlotListFile=NULL; + m_pbSlotListFile=nullptr; m_uiSlotListFileBytes=0; if(StorageManager.TMSPP_InFileList(C4JStorage::eGlobalStorage_TitleUser,m_iPad,L"XboxOne/SlotList")) @@ -103,7 +103,7 @@ int CScene_TransferToXboxOne::TMSPPDeleteReturned(LPVOID pParam,int iPad,int iUs // update the slots delete pClass->m_pbSlotListFile; - pClass->m_pbSlotListFile=NULL; + pClass->m_pbSlotListFile=nullptr; pClass->m_uiSlotListFileBytes=0; pClass->m_pSavesSlotList->RemoveAllData(); CXuiCtrl4JList::LIST_ITEM_INFO ListInfo; @@ -220,7 +220,7 @@ HRESULT CScene_TransferToXboxOne::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotify // check if there is a save there CXuiCtrl4JList::LIST_ITEM_INFO info = m_pSavesSlotList->GetData(iIndex); - if(info.pwszImage!=NULL) + if(info.pwszImage!=nullptr) { // we have a save here // Are you sure, etc. @@ -252,10 +252,10 @@ HRESULT CScene_TransferToXboxOne::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotify HRESULT CScene_TransferToXboxOne::BuildSlotFile(int iIndexBeingUpdated,PBYTE pbImageData,DWORD dwImageBytes ) { - SLOTDATA *pCurrentSlotData=NULL; - PBYTE pbCurrentSlotDataPtr=NULL; + SLOTDATA *pCurrentSlotData=nullptr; + PBYTE pbCurrentSlotDataPtr=nullptr; // there may be no slot file yet - if(m_pbSlotListFile!=NULL) + if(m_pbSlotListFile!=nullptr) { pCurrentSlotData=(SLOTDATA *)(m_pbSlotListFile+sizeof(unsigned int)); pbCurrentSlotDataPtr=m_pbSlotListFile + sizeof(unsigned int) + sizeof(SLOTDATA)*m_MaxSlotC; @@ -298,7 +298,7 @@ HRESULT CScene_TransferToXboxOne::BuildSlotFile(int iIndexBeingUpdated,PBYTE pbI } else { - if(pbCurrentSlotDataPtr!=NULL) + if(pbCurrentSlotDataPtr!=nullptr) { memcpy(pbNewSlotImageDataPtr,pbCurrentSlotDataPtr,pCurrentSlotData[i].uiImageLength); pbNewSlotImageDataPtr+=pCurrentSlotData[i].uiImageLength; @@ -307,7 +307,7 @@ HRESULT CScene_TransferToXboxOne::BuildSlotFile(int iIndexBeingUpdated,PBYTE pbI } // move to the next image data in the current slot file - if(pbCurrentSlotDataPtr!=NULL) + if(pbCurrentSlotDataPtr!=nullptr) { pbCurrentSlotDataPtr+=pCurrentSlotData[i].uiImageLength; } @@ -502,7 +502,7 @@ HRESULT CScene_TransferToXboxOne::OnKeyDown(XUIMessageInput* pInputData, BOOL& r break; case VK_PAD_X: // wipe the save slots - if(m_pbSlotListFile!=NULL) + if(m_pbSlotListFile!=nullptr) { m_SavesSlotListTimer.SetShow(TRUE); m_bIgnoreInput=true; diff --git a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp index 9fe644e06..02b7d9db2 100644 --- a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp @@ -29,7 +29,7 @@ HRESULT CScene_TutorialPopup::OnInit( XUIMessageInit* pInitData, BOOL& bHandled m_textFontSize = _fromString( m_fontSizeControl.GetText() ); m_fontSizeControl.SetShow(false); - m_interactScene = NULL; + m_interactScene = nullptr; m_lastSceneMovedLeft = false; m_bAllowFade = false; @@ -63,7 +63,7 @@ HRESULT CScene_TutorialPopup::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled) void CScene_TutorialPopup::UpdateInteractScenePosition(bool visible) { - if( m_interactScene == NULL ) return; + if( m_interactScene == nullptr ) return; // 4J-PB - check this players screen section to see if we should allow the animation bool bAllowAnim=false; @@ -146,8 +146,8 @@ HRESULT CScene_TutorialPopup::_SetDescription(CXuiScene *interactScene, LPCWSTR { HRESULT hr = S_OK; m_interactScene = interactScene; - if( interactScene != m_lastInteractSceneMoved ) m_lastInteractSceneMoved = NULL; - if(desc == NULL) + if( interactScene != m_lastInteractSceneMoved ) m_lastInteractSceneMoved = nullptr; + if(desc == nullptr) { SetShow( false ); XuiSetTimer(m_hObj,TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID,TUTORIAL_POPUP_MOVE_SCENE_TIME); @@ -195,7 +195,7 @@ HRESULT CScene_TutorialPopup::_SetDescription(CXuiScene *interactScene, LPCWSTR hr = XuiElementGetPosition( m_title, &titlePos ); BOOL titleShowAtStart = m_title.IsShown(); - if( title != NULL && title[0] != 0 ) + if( title != nullptr && title[0] != 0 ) { m_title.SetText( title ); m_title.SetShow(TRUE); @@ -269,7 +269,7 @@ HRESULT CScene_TutorialPopup::SetDescription(int iPad, TutorialPopupInfo *info) parsed = CScene_TutorialPopup::ParseDescription(iPad, parsed); if(parsed.empty()) { - hr = pThis->_SetDescription( info->interactScene, NULL, NULL, info->allowFade, info->isReminder ); + hr = pThis->_SetDescription( info->interactScene, nullptr, nullptr, info->allowFade, info->isReminder ); } else { diff --git a/Minecraft.Client/Common/zlib/crc32.c b/Minecraft.Client/Common/zlib/crc32.c index 979a7190a..9837724b0 100644 --- a/Minecraft.Client/Common/zlib/crc32.c +++ b/Minecraft.Client/Common/zlib/crc32.c @@ -143,7 +143,7 @@ local void make_crc_table() FILE *out; out = fopen("crc32.h", "w"); - if (out == NULL) return; + if (out == nullptr) return; fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); fprintf(out, "local const z_crc_t FAR "); diff --git a/Minecraft.Client/Common/zlib/trees.c b/Minecraft.Client/Common/zlib/trees.c index 1fd7759ef..2f8891748 100644 --- a/Minecraft.Client/Common/zlib/trees.c +++ b/Minecraft.Client/Common/zlib/trees.c @@ -115,8 +115,8 @@ local int base_dist[D_CODES]; #endif /* GEN_TREES_H */ struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ + const ct_data *static_tree; /* static tree or nullptr */ + const intf *extra_bits; /* extra bits for each code or nullptr */ int extra_base; /* base index for extra_bits */ int elems; /* max number of elements in the tree */ int max_length; /* max bit length for the codes */ @@ -330,7 +330,7 @@ void gen_trees_header() FILE *header = fopen("trees.h", "w"); int i; - Assert (header != NULL, "Can't open trees.h"); + Assert (header != nullptr, "Can't open trees.h"); fprintf(header, "/* header created automatically with -DGEN_TREES_H */\n\n"); @@ -906,7 +906,7 @@ void ZLIB_INTERNAL _tr_align(s) */ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) deflate_state *s; - charf *buf; /* input block, or NULL if too old */ + charf *buf; /* input block, or nullptr if too old */ ulg stored_len; /* length of input block */ int last; /* one if this is the last block for a file */ { @@ -958,7 +958,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) if (stored_len+4 <= opt_lenb && buf != (char*)0) { /* 4: two words for the lengths */ #endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + /* The test buf != nullptr is only necessary if LIT_BUFSIZE > WSIZE. * Otherwise we can't have processed more than WSIZE input bytes since * the last block flush, because compression would have been * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to diff --git a/Minecraft.Client/Common/zlib/zlib.h b/Minecraft.Client/Common/zlib/zlib.h index 3e0c7672a..b0e74c454 100644 --- a/Minecraft.Client/Common/zlib/zlib.h +++ b/Minecraft.Client/Common/zlib/zlib.h @@ -91,7 +91,7 @@ typedef struct z_stream_s { uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total number of bytes output so far */ - z_const char *msg; /* last error message, NULL if no error */ + z_const char *msg; /* last error message, nullptr if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ @@ -1254,7 +1254,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); reading, this will be detected automatically by looking for the magic two- byte gzip header. - gzopen returns NULL if the file could not be opened, if there was + gzopen returns nullptr if the file could not be opened, if there was insufficient memory to allocate the gzFile state, or if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). errno can be checked to determine if the reason gzopen failed was that the @@ -1277,7 +1277,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); close the associated file descriptor, so they need to have different file descriptors. - gzdopen returns NULL if there was insufficient memory to allocate the + gzdopen returns nullptr if there was insufficient memory to allocate the gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided), or if fd is -1. The file descriptor is not used until the next gz* read, write, seek, or close operation, so gzdopen @@ -1377,7 +1377,7 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); string is terminated with a null character. If no characters are read due to an end-of-file or len < 1, then the buffer is left untouched. - gzgets returns buf which is a null-terminated string, or it returns NULL + gzgets returns buf which is a null-terminated string, or it returns nullptr for end-of-file or in case of error. If there was an error, the contents at buf are indeterminate. */ @@ -1393,7 +1393,7 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file + it does not check to see if file is nullptr, nor whether the structure file points to has been clobbered or not. */ diff --git a/Minecraft.Client/Common/zlib/zutil.c b/Minecraft.Client/Common/zlib/zutil.c index 23d2ebef0..209af2ce3 100644 --- a/Minecraft.Client/Common/zlib/zutil.c +++ b/Minecraft.Client/Common/zlib/zutil.c @@ -231,7 +231,7 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) } else { buf = farmalloc(bsize + 16L); } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + if (buf == nullptr || next_ptr >= MAX_PTR) return nullptr; table[next_ptr].org_ptr = buf; /* Normalize the pointer to seg:0 */ diff --git a/Minecraft.Client/Common/zlib/zutil.h b/Minecraft.Client/Common/zlib/zutil.h index 24ab06b1c..61becfe0a 100644 --- a/Minecraft.Client/Common/zlib/zutil.h +++ b/Minecraft.Client/Common/zlib/zutil.h @@ -125,7 +125,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # include /* for fdopen */ # else # ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ +# define fdopen(fd,mode) nullptr /* No fdopen() */ # endif # endif # endif @@ -146,12 +146,12 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif #if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ +# define fdopen(fd,mode) nullptr /* No fdopen() */ #endif #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX # if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ +# define fdopen(fd,mode) nullptr /* No fdopen() */ # ifndef _PTRDIFF_T_DEFINED typedef int ptrdiff_t; # define _PTRDIFF_T_DEFINED diff --git a/Minecraft.Client/CompassTexture.cpp b/Minecraft.Client/CompassTexture.cpp index 1a73783f8..148069916 100644 --- a/Minecraft.Client/CompassTexture.cpp +++ b/Minecraft.Client/CompassTexture.cpp @@ -7,13 +7,13 @@ #include "Texture.h" #include "CompassTexture.h" -CompassTexture *CompassTexture::instance = NULL; +CompassTexture *CompassTexture::instance = nullptr; CompassTexture::CompassTexture() : StitchedTexture(L"compass",L"compass") { instance = this; - m_dataTexture = NULL; + m_dataTexture = nullptr; m_iPad = XUSER_INDEX_ANY; rot = rota = 0.0; @@ -31,21 +31,21 @@ void CompassTexture::cycleFrames() { Minecraft *mc = Minecraft::GetInstance(); - if (m_iPad >= 0 && m_iPad < XUSER_MAX_COUNT && mc->level != NULL && mc->localplayers[m_iPad] != NULL) + if (m_iPad >= 0 && m_iPad < XUSER_MAX_COUNT && mc->level != nullptr && mc->localplayers[m_iPad] != nullptr) { updateFromPosition(mc->localplayers[m_iPad]->level, mc->localplayers[m_iPad]->x, mc->localplayers[m_iPad]->z, mc->localplayers[m_iPad]->yRot, false, false); } else { frame = 1; - updateFromPosition(NULL, 0, 0, 0, false, true); + updateFromPosition(nullptr, 0, 0, 0, false, true); } } void CompassTexture::updateFromPosition(Level *level, double x, double z, double yRot, bool noNeedle, bool instant) { double rott = 0; - if (level != NULL && !noNeedle) + if (level != nullptr && !noNeedle) { Pos *spawnPos = level->getSharedSpawnPos(); double xa = spawnPos->x - x; @@ -78,7 +78,7 @@ void CompassTexture::updateFromPosition(Level *level, double x, double z, double } // 4J Stu - We share data with another texture - if(m_dataTexture != NULL) + if(m_dataTexture != nullptr) { int newFrame = static_cast(((rot / (PI * 2)) + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); while (newFrame < 0) @@ -118,7 +118,7 @@ int CompassTexture::getSourceHeight() const int CompassTexture::getFrames() { - if(m_dataTexture == NULL) + if(m_dataTexture == nullptr) { return StitchedTexture::getFrames(); } @@ -130,7 +130,7 @@ int CompassTexture::getFrames() void CompassTexture::freeFrameTextures() { - if(m_dataTexture == NULL) + if(m_dataTexture == nullptr) { StitchedTexture::freeFrameTextures(); } @@ -138,5 +138,5 @@ void CompassTexture::freeFrameTextures() bool CompassTexture::hasOwnData() { - return m_dataTexture == NULL; + return m_dataTexture == nullptr; } \ No newline at end of file diff --git a/Minecraft.Client/ConnectScreen.cpp b/Minecraft.Client/ConnectScreen.cpp index 2cf005b6d..c34a219e0 100644 --- a/Minecraft.Client/ConnectScreen.cpp +++ b/Minecraft.Client/ConnectScreen.cpp @@ -12,7 +12,7 @@ ConnectScreen::ConnectScreen(Minecraft *minecraft, const wstring& ip, int port) { aborted = false; // System.out.println("Connecting to " + ip + ", " + port); - minecraft->setLevel(NULL); + minecraft->setLevel(nullptr); #if 1 // 4J - removed from separate thread, but need to investigate what we actually need here connection = new ClientConnection(minecraft, ip, port); @@ -45,7 +45,7 @@ ConnectScreen::ConnectScreen(Minecraft *minecraft, const wstring& ip, int port) void ConnectScreen::tick() { - if (connection != NULL) + if (connection != nullptr) { connection->tick(); } @@ -69,7 +69,7 @@ void ConnectScreen::buttonClicked(Button *button) if (button->id == 0) { aborted = true; - if (connection != NULL) connection->close(); + if (connection != nullptr) connection->close(); minecraft->setScreen(new TitleScreen()); } } @@ -80,7 +80,7 @@ void ConnectScreen::render(int xm, int ym, float a) Language *language = Language::getInstance(); - if (connection == NULL) + if (connection == nullptr) { drawCenteredString(font, language->getElement(L"connect.connecting"), width / 2, height / 2 - 50, 0xffffff); drawCenteredString(font, L"", width / 2, height / 2 - 10, 0xffffff); diff --git a/Minecraft.Client/CreateWorldScreen.cpp b/Minecraft.Client/CreateWorldScreen.cpp index b9856c7e3..4fc0a3531 100644 --- a/Minecraft.Client/CreateWorldScreen.cpp +++ b/Minecraft.Client/CreateWorldScreen.cpp @@ -70,7 +70,7 @@ wstring CreateWorldScreen::findAvailableFolderName(LevelStorageSource *levelSour wstring folder2 = folder; // 4J - copy input as it is const #if 0 - while (levelSource->getDataTagFor(folder2) != NULL) + while (levelSource->getDataTagFor(folder2) != nullptr) { folder2 = folder2 + L"-"; } @@ -93,7 +93,7 @@ void CreateWorldScreen::buttonClicked(Button *button) else if (button->id == 0) { // note: code copied from SelectWorldScreen - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); if (done) return; done = true; @@ -119,7 +119,7 @@ void CreateWorldScreen::buttonClicked(Button *button) #if 0 minecraft->gameMode = new SurvivalMode(minecraft); minecraft->selectLevel(resultFolder, nameEdit->getValue(), seedValue); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); #endif } diff --git a/Minecraft.Client/DLCTexturePack.cpp b/Minecraft.Client/DLCTexturePack.cpp index 752b1cc27..1e72bb260 100644 --- a/Minecraft.Client/DLCTexturePack.cpp +++ b/Minecraft.Client/DLCTexturePack.cpp @@ -16,22 +16,22 @@ #include "Xbox\XML\xmlFilesCallback.h" #endif -DLCTexturePack::DLCTexturePack(DWORD id, DLCPack *pack, TexturePack *fallback) : AbstractTexturePack(id, NULL, pack->getName(), fallback) +DLCTexturePack::DLCTexturePack(DWORD id, DLCPack *pack, TexturePack *fallback) : AbstractTexturePack(id, nullptr, pack->getName(), fallback) { m_dlcInfoPack = pack; - m_dlcDataPack = NULL; + m_dlcDataPack = nullptr; bUILoaded = false; m_bLoadingData = false; m_bHasLoadedData = false; - m_archiveFile = NULL; + m_archiveFile = nullptr; if (app.getLevelGenerationOptions()) app.getLevelGenerationOptions()->setLoadedData(); m_bUsingDefaultColourTable = true; - m_stringTable = NULL; + m_stringTable = nullptr; #ifdef _XBOX - m_pStreamedWaveBank=NULL; - m_pSoundBank=NULL; + m_pStreamedWaveBank=nullptr; + m_pSoundBank=nullptr; #endif if(m_dlcInfoPack->doesPackContainFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc")) @@ -75,7 +75,7 @@ void DLCTexturePack::loadName() if(m_dlcInfoPack->GetPackID()&1024) { - if(m_stringTable != NULL) + if(m_stringTable != nullptr) { texname = m_stringTable->getString(L"IDS_DISPLAY_NAME"); m_wsWorldName=m_stringTable->getString(L"IDS_WORLD_NAME"); @@ -83,7 +83,7 @@ void DLCTexturePack::loadName() } else { - if(m_stringTable != NULL) + if(m_stringTable != nullptr) { texname = m_stringTable->getString(L"IDS_DISPLAY_NAME"); } @@ -95,7 +95,7 @@ void DLCTexturePack::loadDescription() { desc1 = L""; - if(m_stringTable != NULL) + if(m_stringTable != nullptr) { desc1 = m_stringTable->getString(L"IDS_TP_DESCRIPTION"); } @@ -115,15 +115,15 @@ InputStream *DLCTexturePack::getResourceImplementation(const wstring &name) //th // 4J Stu - We should never call this function #ifndef _CONTENT_PACKAGE __debugbreak(); - if(hasFile(name)) return NULL; + if(hasFile(name)) return nullptr; #endif - return NULL; //resource; + return nullptr; //resource; } bool DLCTexturePack::hasFile(const wstring &name) { bool hasFile = false; - if(m_dlcDataPack != NULL) hasFile = m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_Texture, name); + if(m_dlcDataPack != nullptr) hasFile = m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_Texture, name); return hasFile; } @@ -164,7 +164,7 @@ DLCPack * DLCTexturePack::getDLCPack() void DLCTexturePack::loadColourTable() { // Load the game colours - if(m_dlcDataPack != NULL && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_ColourTable, L"colours.col")) + if(m_dlcDataPack != nullptr && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_ColourTable, L"colours.col")) { DLCColourTableFile *colourFile = static_cast(m_dlcDataPack->getFile(DLCManager::e_DLCType_ColourTable, L"colours.col")); m_colourTable = colourFile->getColourTable(); @@ -173,14 +173,14 @@ void DLCTexturePack::loadColourTable() else { // 4J Stu - We can delete the default colour table, but not the one from the DLCColourTableFile - if(!m_bUsingDefaultColourTable) m_colourTable = NULL; + if(!m_bUsingDefaultColourTable) m_colourTable = nullptr; loadDefaultColourTable(); m_bUsingDefaultColourTable = true; } // Load the text colours #ifdef _XBOX - if(m_dlcDataPack != NULL && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")) + if(m_dlcDataPack != nullptr && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")) { DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp"); @@ -205,7 +205,7 @@ void DLCTexturePack::loadColourTable() swprintf(szResourceLocator, LOCATOR_SIZE,L"memory://%08X,%04X#xuiscene_colourtable.xur",pbData, dwSize); HXUIOBJ hScene; - HRESULT hr = XuiSceneCreate(szResourceLocator,szResourceLocator, NULL, &hScene); + HRESULT hr = XuiSceneCreate(szResourceLocator,szResourceLocator, nullptr, &hScene); if(HRESULT_SUCCEEDED(hr)) { @@ -294,11 +294,11 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen if(!app.m_dlcManager.readDLCDataFile(dwFilesProcessed, getFilePath(texturePack->m_dlcInfoPack->GetPackID(), dataFilePath),texturePack->m_dlcDataPack)) { delete texturePack->m_dlcDataPack; - texturePack->m_dlcDataPack = NULL; + texturePack->m_dlcDataPack = nullptr; } // Load the UI data - if(texturePack->m_dlcDataPack != NULL) + if(texturePack->m_dlcDataPack != nullptr) { #ifdef _XBOX File xzpPath(getFilePath(texturePack->m_dlcInfoPack->GetPackID(), wstring(L"TexturePack.xzp") ) ); @@ -310,10 +310,10 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); if( fileHandle != INVALID_HANDLE_VALUE ) @@ -321,7 +321,7 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen DWORD dwFileSize = xzpPath.length(); DWORD bytesRead; PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL success = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); + BOOL success = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,nullptr); CloseHandle(fileHandle); if(success) { @@ -342,7 +342,7 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen */ DLCPack *pack = texturePack->m_dlcInfoPack->GetParentPack(); LevelGenerationOptions *levelGen = app.getLevelGenerationOptions(); - if (levelGen != NULL && !levelGen->hasLoadedData()) + if (levelGen != nullptr && !levelGen->hasLoadedData()) { int gameRulesCount = pack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader); for(int i = 0; i < gameRulesCount; ++i) @@ -361,10 +361,10 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #else const char *pchFilename=wstringtofilename(grf.getPath()); @@ -372,10 +372,10 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #endif @@ -384,7 +384,7 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen DWORD dwFileSize = grf.length(); DWORD bytesRead; PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { app.FatalLoadError(); @@ -413,10 +413,10 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #else const char *pchFilename=wstringtofilename(grf.getPath()); @@ -424,18 +424,18 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #endif if( fileHandle != INVALID_HANDLE_VALUE ) { - DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,nullptr); PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { app.FatalLoadError(); @@ -513,7 +513,7 @@ void DLCTexturePack::loadUI() //L"memory://0123ABCD,21A3#skin_default.xur" // Load new skin - if(m_dlcDataPack != NULL && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")) + if(m_dlcDataPack != nullptr && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")) { DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp"); @@ -527,7 +527,7 @@ void DLCTexturePack::loadUI() XuiFreeVisuals(L""); - HRESULT hr = app.LoadSkin(szResourceLocator,NULL);//L"TexturePack"); + HRESULT hr = app.LoadSkin(szResourceLocator,nullptr);//L"TexturePack"); if(HRESULT_SUCCEEDED(hr)) { bUILoaded = true; @@ -577,7 +577,7 @@ void DLCTexturePack::unloadUI() AbstractTexturePack::unloadUI(); app.m_dlcManager.removePack(m_dlcDataPack); - m_dlcDataPack = NULL; + m_dlcDataPack = nullptr; delete m_archiveFile; m_bHasLoadedData = false; @@ -587,7 +587,7 @@ void DLCTexturePack::unloadUI() wstring DLCTexturePack::getXuiRootPath() { wstring path = L""; - if(m_dlcDataPack != NULL && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")) + if(m_dlcDataPack != nullptr && m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")) { DLCUIDataFile *dataFile = static_cast(m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp")); diff --git a/Minecraft.Client/DLCTexturePack.h b/Minecraft.Client/DLCTexturePack.h index 153f3d438..595c47dac 100644 --- a/Minecraft.Client/DLCTexturePack.h +++ b/Minecraft.Client/DLCTexturePack.h @@ -50,7 +50,7 @@ class DLCTexturePack : public AbstractTexturePack bool isTerrainUpdateCompatible(); // 4J Added - virtual wstring getPath(bool bTitleUpdateTexture = false, const char *pchBDPatchFilename=NULL); + virtual wstring getPath(bool bTitleUpdateTexture = false, const char *pchBDPatchFilename=nullptr); virtual wstring getAnimationString(const wstring &textureName, const wstring &path); virtual BufferedImage *getImageResource(const wstring& File, bool filenameHasExtension = false, bool bTitleUpdateTexture=false, const wstring &drive =L""); virtual void loadColourTable(); diff --git a/Minecraft.Client/DeathScreen.cpp b/Minecraft.Client/DeathScreen.cpp index e7ab13285..0e9cfb191 100644 --- a/Minecraft.Client/DeathScreen.cpp +++ b/Minecraft.Client/DeathScreen.cpp @@ -11,7 +11,7 @@ void DeathScreen::init() buttons.push_back(new Button(1, width / 2 - 100, height / 4 + 24 * 3, L"Respawn")); buttons.push_back(new Button(2, width / 2 - 100, height / 4 + 24 * 4, L"Title menu")); - if (minecraft->user == NULL) + if (minecraft->user == nullptr) { buttons[1]->active = false; } @@ -30,12 +30,12 @@ void DeathScreen::buttonClicked(Button *button) if (button->id == 1) { minecraft->player->respawn(); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft.setScreen(new NewLevelScreen(this)); } if (button->id == 2) { - minecraft->setLevel(NULL); + minecraft->setLevel(nullptr); minecraft->setScreen(new TitleScreen()); } } diff --git a/Minecraft.Client/DefaultRenderer.h b/Minecraft.Client/DefaultRenderer.h index 04b953907..28630de29 100644 --- a/Minecraft.Client/DefaultRenderer.h +++ b/Minecraft.Client/DefaultRenderer.h @@ -5,5 +5,5 @@ class DefaultRenderer : public EntityRenderer { public: virtual void render(shared_ptr entity, double x, double y, double z, float rot, float a); - virtual ResourceLocation *getTextureLocation(shared_ptr mob) { return NULL; }; + virtual ResourceLocation *getTextureLocation(shared_ptr mob) { return nullptr; }; }; \ No newline at end of file diff --git a/Minecraft.Client/DefaultTexturePack.cpp b/Minecraft.Client/DefaultTexturePack.cpp index d2974b6d0..d2712404b 100644 --- a/Minecraft.Client/DefaultTexturePack.cpp +++ b/Minecraft.Client/DefaultTexturePack.cpp @@ -4,7 +4,7 @@ #include "..\Minecraft.World\StringHelpers.h" -DefaultTexturePack::DefaultTexturePack() : AbstractTexturePack(0, NULL, L"Minecraft", NULL) +DefaultTexturePack::DefaultTexturePack() : AbstractTexturePack(0, nullptr, L"Minecraft", nullptr) { // 4J Stu - These calls need to be in the most derived version of the class loadIcon(); @@ -20,7 +20,7 @@ void DefaultTexturePack::loadIcon() const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/TexturePackIcon.png"); UINT size = 0; @@ -102,7 +102,7 @@ InputStream *DefaultTexturePack::getResourceImplementation(const wstring &name)/ #endif InputStream *resource = InputStream::getResourceAsStream(wDrive + name); //InputStream *stream = DefaultTexturePack::class->getResourceAsStream(name); - //if (stream == NULL) + //if (stream == nullptr) //{ // throw new FileNotFoundException(name); //} diff --git a/Minecraft.Client/DefaultTexturePack.h b/Minecraft.Client/DefaultTexturePack.h index 9aa87a07a..5fd0b40c4 100644 --- a/Minecraft.Client/DefaultTexturePack.h +++ b/Minecraft.Client/DefaultTexturePack.h @@ -5,7 +5,7 @@ class DefaultTexturePack : public AbstractTexturePack { public: DefaultTexturePack(); - DLCPack * getDLCPack() {return NULL;} + DLCPack * getDLCPack() {return nullptr;} protected: //@Override diff --git a/Minecraft.Client/DerivedServerLevel.cpp b/Minecraft.Client/DerivedServerLevel.cpp index a67408d70..78de818de 100644 --- a/Minecraft.Client/DerivedServerLevel.cpp +++ b/Minecraft.Client/DerivedServerLevel.cpp @@ -10,7 +10,7 @@ DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, shared_ptrsavedDataStorage) { delete this->savedDataStorage; - this->savedDataStorage=NULL; + this->savedDataStorage=nullptr; } this->savedDataStorage = wrapped->savedDataStorage; levelData = new DerivedLevelData(wrapped->getLevelData()); @@ -19,7 +19,7 @@ DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, shared_ptrsavedDataStorage=NULL; + this->savedDataStorage=nullptr; } void DerivedServerLevel::saveLevelData() diff --git a/Minecraft.Client/DisconnectedScreen.cpp b/Minecraft.Client/DisconnectedScreen.cpp index b445e4d07..800df73f4 100644 --- a/Minecraft.Client/DisconnectedScreen.cpp +++ b/Minecraft.Client/DisconnectedScreen.cpp @@ -9,7 +9,7 @@ DisconnectedScreen::DisconnectedScreen(const wstring& title, const wstring reaso Language *language = Language::getInstance(); this->title = language->getElement(title); - if (reasonObjects != NULL) + if (reasonObjects != nullptr) { this->reason = language->getElement(reason, reasonObjects); } diff --git a/Minecraft.Client/Durango/4JLibs/inc/4J_Input.h b/Minecraft.Client/Durango/4JLibs/inc/4J_Input.h index 884f281e1..a24d61169 100644 --- a/Minecraft.Client/Durango/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Durango/4JLibs/inc/4J_Input.h @@ -61,8 +61,8 @@ STRING_VERIFY_RESPONSE; class C4JStringTable { public: - LPCWSTR Lookup(LPCWSTR szId) {return NULL;} - LPCWSTR Lookup(UINT nIndex) {return NULL;} + LPCWSTR Lookup(LPCWSTR szId) {return nullptr;} + LPCWSTR Lookup(UINT nIndex) {return nullptr;} void Clear(); HRESULT Load(LPCWSTR szId) {return S_OK;} }; @@ -126,8 +126,8 @@ class C_4JInput void SetMenuDisplayed(int iPad, bool bVal); -// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); -// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); +// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); +// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, int iMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); void DestroyKeyboard(); diff --git a/Minecraft.Client/Durango/4JLibs/inc/4J_Profile.h b/Minecraft.Client/Durango/4JLibs/inc/4J_Profile.h index dab464171..961b5d2a7 100644 --- a/Minecraft.Client/Durango/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/Durango/4JLibs/inc/4J_Profile.h @@ -132,7 +132,7 @@ class C_4JProfile // ACHIEVEMENTS & AWARDS //void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false, - // CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L); + // CXuiStringTable*pStringTable=nullptr, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=nullptr, unsigned int uiThemeSize=0L); //int GetAwardId(int iAwardNumber); eAwardType GetAwardType(int iAwardNumber); bool CanBeAwarded(int iQuadrant, int iAwardNumber); diff --git a/Minecraft.Client/Durango/4JLibs/inc/4J_Render.h b/Minecraft.Client/Durango/4JLibs/inc/4J_Render.h index 737caa98b..fb16ccb32 100644 --- a/Minecraft.Client/Durango/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/Durango/4JLibs/inc/4J_Render.h @@ -16,8 +16,8 @@ class ImageFileBuffer int GetType() { return m_type; } void *GetBufferPointer() { return m_pBuffer; } int GetBufferSize() { return m_bufferSize; } - void Release() { free(m_pBuffer); m_pBuffer = NULL; } - bool Allocated() { return m_pBuffer != NULL; } + void Release() { free(m_pBuffer); m_pBuffer = nullptr; } + bool Allocated() { return m_pBuffer != nullptr; } }; typedef struct @@ -60,7 +60,7 @@ class C4JRender void StartFrame(); void DoScreenGrabOnNextPresent(); void Present(); - void Clear(int flags, D3D11_RECT *pRect = NULL); + void Clear(int flags, D3D11_RECT *pRect = nullptr); void SetClearColour(const float colourRGBA[4]); bool IsWidescreen(); bool IsHiDef(); diff --git a/Minecraft.Client/Durango/4JLibs/inc/4J_Storage.h b/Minecraft.Client/Durango/4JLibs/inc/4J_Storage.h index be5d57fd7..624939520 100644 --- a/Minecraft.Client/Durango/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/Durango/4JLibs/inc/4J_Storage.h @@ -378,7 +378,7 @@ class C4JStorage // Get details of existing savedata C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(LPVOID lpParam,SAVE_DETAILS *pSaveDetails,const bool),LPVOID lpParam,char *pszSavePackName); // Start search - PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or NULL if not yet received) + PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or nullptr if not yet received) void ClearSavesInfo(); // Clears results C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam, bool force=false); // Get the thumbnail for an individual save referenced by pSaveInfo @@ -442,8 +442,8 @@ class C4JStorage void SetLicenseChangeFn(void( *Func)(void)); XCONTENT_DATA& GetDLC(DWORD dw); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPWSTR szMountDrive = NULL); - DWORD UnmountInstalledDLC(LPWSTR szMountDrive = NULL); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPWSTR szMountDrive = nullptr); + DWORD UnmountInstalledDLC(LPWSTR szMountDrive = nullptr); void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); std::wstring GetMountedPath(std::wstring szMount); XCONTENT_DATA * GetInstalledDLC(WCHAR *wszProductID); @@ -470,10 +470,10 @@ class C4JStorage // TMS++ C4JStorage::ETMSStatus TMSPP_GetUserQuotaInfo(C4JStorage::eGlobalStorage eStorageFacility,int iPad);//,TMSCLIENT_CALLBACK Func,LPVOID lpParam, int iUserData=0); - eTitleStorageState TMSPP_WriteFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,BYTE *pbBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID lpParam=NULL, int iUserData=0); + eTitleStorageState TMSPP_WriteFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,BYTE *pbBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); eTitleStorageState TMSPP_ReadFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,int( *Func)(LPVOID,int,int,LPVOID, WCHAR *),LPVOID lpParam, int iUserData); eTitleStorageState TMSPP_DeleteFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,int( *Func)(LPVOID,int,int),LPVOID lpParam, int iUserData); - eTitleStorageState TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,int( *Func)(LPVOID,int,int,LPVOID,WCHAR *)=NULL,LPVOID lpParam=NULL, int iUserData=0); + eTitleStorageState TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,int( *Func)(LPVOID,int,int,LPVOID,WCHAR *)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const wstring &Filename); eTitleStorageState TMSPP_GetTitleStorageState(int iPad); diff --git a/Minecraft.Client/Durango/Durango_App.cpp b/Minecraft.Client/Durango/Durango_App.cpp index e58a57c12..cb8e4fd82 100644 --- a/Minecraft.Client/Durango/Durango_App.cpp +++ b/Minecraft.Client/Durango/Durango_App.cpp @@ -42,7 +42,7 @@ void CConsoleMinecraftApp::HandleDLCLicenseChange() XCONTENT_DATA *pContentData=StorageManager.GetInstalledDLC(xOffer.wszProductID); - if((pContentData!=NULL) &&(pContentData->bTrialLicense==false)) + if((pContentData!=nullptr) &&(pContentData->bTrialLicense==false)) { DLCPack *pack = app.m_dlcManager.getPackFromProductID(xOffer.wszProductID); if(pack) @@ -193,7 +193,7 @@ void CConsoleMinecraftApp::FreeLocalDLCImages() { free(pDLCInfo->pbImageData); pDLCInfo->dwImageBytes=0; - pDLCInfo->pbImageData=NULL; + pDLCInfo->pbImageData=nullptr; } } } @@ -207,7 +207,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImage(WCHAR *wchName,PBYTE *ppbImageData,D // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds swprintf(wchFilename,L"DLCImages/%s",wchName); - HANDLE hFile = CreateFile(wchFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(wchFilename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( hFile == INVALID_HANDLE_VALUE ) { @@ -223,7 +223,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImage(WCHAR *wchName,PBYTE *ppbImageData,D DWORD dwBytesRead; PBYTE pbImageData=static_cast(malloc(*pdwBytes)); - if(ReadFile(hFile,pbImageData,*pdwBytes,&dwBytesRead,NULL)==FALSE) + if(ReadFile(hFile,pbImageData,*pdwBytes,&dwBytesRead,nullptr)==FALSE) { // failed free(pbImageData); @@ -244,7 +244,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -273,7 +273,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() NetworkGameInitData *param = new NetworkGameInitData(); param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; app.SetGameHostOption(eGameHostOption_Difficulty,0); app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); @@ -386,7 +386,7 @@ bool CConsoleMinecraftApp::UpdateProductId(XCONTENT_DATA &Data) // Do we have a product id for this? DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName(Data.wszDisplayName); - if(pDLCInfo!=NULL) + if(pDLCInfo!=nullptr) { app.DebugPrintf("Updating product id for %ls\n",Data.wszDisplayName); swprintf_s(Data.wszProductID, 64,L"%ls",pDLCInfo->wsProductId.c_str()); @@ -557,7 +557,7 @@ int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad, { CConsoleMinecraftApp* pClass = static_cast(pParam); app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList\n"); - if(lpvData!=NULL) + if(lpvData!=nullptr) { vector *pvTmsFileDetails=static_cast *>(lpvData); @@ -635,7 +635,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i // hack for now to upload the file // open the local file - file = CreateFile(L"DLCXbox1.cmp", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile(L"DLCXbox1.cmp", GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { DWORD error = GetLastError(); @@ -653,12 +653,12 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i PBYTE pbData= new BYTE [dwFileSize]; - ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bytesRead==dwFileSize) { - //StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"DLCXbox1.cmp",(PBYTE) pbData, dwFileSize,NULL,NULL, 0); - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.cmp",(PBYTE) pbData, dwFileSize,NULL,NULL, 0); + //StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"DLCXbox1.cmp",(PBYTE) pbData, dwFileSize,nullptr,nullptr, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.cmp",(PBYTE) pbData, dwFileSize,nullptr,nullptr, 0); } Sleep(5000); } @@ -667,7 +667,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i /* // now the icon - file = CreateFile(L"TP06.png", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile(L"TP06.png", GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { DWORD error = GetLastError(); @@ -684,11 +684,11 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i PBYTE pbData= new BYTE [dwFileSize]; - ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); + ReadFile(file,pbData,dwFileSize,&bytesRead,nullptr); if(bytesRead==dwFileSize) { - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",(PBYTE) pbData, dwFileSize,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",(PBYTE) pbData, dwFileSize,nullptr,nullptr, 0); } Sleep(5000); } @@ -757,7 +757,7 @@ int CConsoleMinecraftApp::Callback_SaveGameIncompleteMessageBoxReturned(void *pP StorageManager.CancelIncompleteOperation(); break; case C4JStorage::EMessage_ResultThirdOption: - ui.NavigateToScene(iPad, eUIScene_InGameSaveManagementMenu, NULL, eUILayer_Error, eUIGroup_Fullscreen); + ui.NavigateToScene(iPad, eUIScene_InGameSaveManagementMenu, nullptr, eUILayer_Error, eUIGroup_Fullscreen); break; } return 0; diff --git a/Minecraft.Client/Durango/Durango_App.h b/Minecraft.Client/Durango/Durango_App.h index 4ae2a020c..ba4b26fb9 100644 --- a/Minecraft.Client/Durango/Durango_App.h +++ b/Minecraft.Client/Durango/Durango_App.h @@ -58,7 +58,7 @@ class CConsoleMinecraftApp : public CMinecraftApp static void Callback_SaveGameIncomplete(void *pParam, C4JStorage::ESaveIncompleteType saveIncompleteType); static int Callback_SaveGameIncompleteMessageBoxReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - C4JStringTable *GetStringTable() { return NULL;} + C4JStringTable *GetStringTable() { return nullptr;} // original code virtual void TemporaryCreateGameStart(); diff --git a/Minecraft.Client/Durango/Durango_Minecraft.cpp b/Minecraft.Client/Durango/Durango_Minecraft.cpp index b8487aec9..6e8b06cb4 100644 --- a/Minecraft.Client/Durango/Durango_Minecraft.cpp +++ b/Minecraft.Client/Durango/Durango_Minecraft.cpp @@ -271,7 +271,7 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, return pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, - NULL, + nullptr, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, pd3dPP, ppDevice ); @@ -290,7 +290,7 @@ void MemSect(int sect) #endif -HINSTANCE g_hInst = NULL; +HINSTANCE g_hInst = nullptr; Platform::Agile g_window; Windows::Foundation::Rect g_windowBounds; @@ -473,7 +473,7 @@ void oldWinMainInit() MSG msg = {0}; while( WM_QUIT != msg.message ) { - if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) + if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); @@ -545,7 +545,7 @@ void oldWinMainInit() } // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers) - hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); + hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, nullptr); if ( FAILED( hr ) ) { app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr ); @@ -784,7 +784,7 @@ void oldWinMainTick() else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true,false); IntCache::Reset(); diff --git a/Minecraft.Client/Durango/Durango_UIController.cpp b/Minecraft.Client/Durango/Durango_UIController.cpp index 7c9313e61..e27d91d23 100644 --- a/Minecraft.Client/Durango/Durango_UIController.cpp +++ b/Minecraft.Client/Durango/Durango_UIController.cpp @@ -75,7 +75,7 @@ void ConsoleUIController::render() example, no resolve targets are required. */ gdraw_D3D11_SetTileOrigin( m_pRenderTargetView.Get(), m_pDepthStencilView.Get(), - NULL, + nullptr, 0, 0 ); @@ -153,7 +153,7 @@ void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) { gdraw_D3D11_SetTileOrigin( m_pRenderTargetView.Get(), m_pDepthStencilView.Get(), - NULL, + nullptr, xPos, yPos ); } diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d10_shaders.inl b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d10_shaders.inl index d4d2bb229..6ea0d142f 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d10_shaders.inl +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d10_shaders.inl @@ -1364,7 +1364,7 @@ static DWORD pshader_exceptional_blend_12[276] = { }; static ProgramWithCachedVariableLocations pshader_exceptional_blend_arr[13] = { - { NULL, 0, }, + { nullptr, 0, }, { pshader_exceptional_blend_1, 1340, }, { pshader_exceptional_blend_2, 1444, }, { pshader_exceptional_blend_3, 1424, }, @@ -2672,10 +2672,10 @@ static ProgramWithCachedVariableLocations pshader_filter_arr[32] = { { pshader_filter_9, 708, }, { pshader_filter_10, 1644, }, { pshader_filter_11, 1372, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, { pshader_filter_16, 1740, }, { pshader_filter_17, 1732, }, { pshader_filter_18, 1820, }, @@ -2688,10 +2688,10 @@ static ProgramWithCachedVariableLocations pshader_filter_arr[32] = { { pshader_filter_25, 1468, }, { pshader_filter_26, 1820, }, { pshader_filter_27, 1548, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, }; static DWORD pshader_blur_2[320] = { @@ -3193,8 +3193,8 @@ static DWORD pshader_blur_9[621] = { }; static ProgramWithCachedVariableLocations pshader_blur_arr[10] = { - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, { pshader_blur_2, 1280, }, { pshader_blur_3, 1452, }, { pshader_blur_4, 1624, }, diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.cpp b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.cpp index 0c106b3fd..b5bfe1f69 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.cpp +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.cpp @@ -64,7 +64,7 @@ static void *map_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf, bool discard) HRESULT hr = ctx->Map(buf, 0, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE, 0, &msr); if (FAILED(hr)) { report_d3d_error(hr, "Map", "of buffer"); - return NULL; + return nullptr; } else return msr.pData; } @@ -76,12 +76,12 @@ static void unmap_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf) static RADINLINE void set_pixel_shader(ID3D11DeviceContext *ctx, ID3D11PixelShader *shader) { - ctx->PSSetShader(shader, NULL, 0); + ctx->PSSetShader(shader, nullptr, 0); } static RADINLINE void set_vertex_shader(ID3D11DeviceContext *ctx, ID3D11VertexShader *shader) { - ctx->VSSetShader(shader, NULL, 0); + ctx->VSSetShader(shader, nullptr, 0); } static ID3D11BlendState *create_blend_state(ID3D11Device *dev, BOOL blend, D3D11_BLEND src, D3D11_BLEND dst) @@ -100,7 +100,7 @@ static ID3D11BlendState *create_blend_state(ID3D11Device *dev, BOOL blend, D3D11 HRESULT hr = dev->CreateBlendState(&desc, &res); if (FAILED(hr)) { report_d3d_error(hr, "CreateBlendState", ""); - res = NULL; + res = nullptr; } return res; @@ -113,10 +113,10 @@ static void create_pixel_shader(ProgramWithCachedVariableLocations *p, ProgramWi { *p = *src; if(p->bytecode) { - HRESULT hr = gdraw->d3d_device->CreatePixelShader(p->bytecode, p->size, NULL, &p->pshader); + HRESULT hr = gdraw->d3d_device->CreatePixelShader(p->bytecode, p->size, nullptr, &p->pshader); if (FAILED(hr)) { report_d3d_error(hr, "CreatePixelShader", ""); - p->pshader = NULL; + p->pshader = nullptr; return; } } @@ -126,10 +126,10 @@ static void create_vertex_shader(ProgramWithCachedVariableLocations *p, ProgramW { *p = *src; if(p->bytecode) { - HRESULT hr = gdraw->d3d_device->CreateVertexShader(p->bytecode, p->size, NULL, &p->vshader); + HRESULT hr = gdraw->d3d_device->CreateVertexShader(p->bytecode, p->size, nullptr, &p->vshader); if (FAILED(hr)) { report_d3d_error(hr, "CreateVertexShader", ""); - p->vshader = NULL; + p->vshader = nullptr; return; } } diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.h b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.h index c8db492a6..f8a5dc6d9 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.h +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d11.h @@ -41,7 +41,7 @@ IDOC extern GDrawFunctions * gdraw_D3D11_CreateContext(ID3D11Device *dev, ID3D11 There can only be one D3D GDraw context active at any one time. If initialization fails for some reason (the main reason would be an out of memory condition), - NULL is returned. Otherwise, you can pass the return value to IggySetGDraw. */ + nullptr is returned. Otherwise, you can pass the return value to IggySetGDraw. */ IDOC extern void gdraw_D3D11_DestroyContext(void); /* Destroys the current GDraw context, if any. */ @@ -69,7 +69,7 @@ IDOC extern void gdraw_D3D11_SetTileOrigin(ID3D11RenderTargetView *main_rt, ID3D If your rendertarget uses multisampling, you also need to specify a shader resource view for a non-MSAA rendertarget texture (identically sized to main_rt) in non_msaa_rt. This is only used if the Flash content includes non-standard - blend modes which have to use a special blend shader, so you can leave it NULL + blend modes which have to use a special blend shader, so you can leave it nullptr if you forbid such content. You need to call this before Iggy calls any rendering functions. */ diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl index 1ab1f13f7..1cbac10fa 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_d3d1x_shared.inl @@ -196,16 +196,16 @@ static void safe_release(T *&p) { if (p) { p->Release(); - p = NULL; + p = nullptr; } } static void report_d3d_error(HRESULT hr, char *call, char *context) { if (hr == E_OUTOFMEMORY) - IggyGDrawSendWarning(NULL, "GDraw D3D out of memory in %s%s", call, context); + IggyGDrawSendWarning(nullptr, "GDraw D3D out of memory in %s%s", call, context); else - IggyGDrawSendWarning(NULL, "GDraw D3D error in %s%s: 0x%08x", call, context, hr); + IggyGDrawSendWarning(nullptr, "GDraw D3D error in %s%s: 0x%08x", call, context, hr); } static void unbind_resources(void) @@ -215,12 +215,12 @@ static void unbind_resources(void) // unset active textures and vertex/index buffers, // to make sure there are no dangling refs static ID3D1X(ShaderResourceView) *no_views[3] = { 0 }; - ID3D1X(Buffer) *no_vb = NULL; + ID3D1X(Buffer) *no_vb = nullptr; UINT no_offs = 0; d3d->PSSetShaderResources(0, 3, no_views); d3d->IASetVertexBuffers(0, 1, &no_vb, &no_offs, &no_offs); - d3d->IASetIndexBuffer(NULL, DXGI_FORMAT_UNKNOWN, 0); + d3d->IASetIndexBuffer(nullptr, DXGI_FORMAT_UNKNOWN, 0); } static void api_free_resource(GDrawHandle *r) @@ -251,11 +251,11 @@ static void RADLINK gdraw_UnlockHandles(GDrawStats * /*stats*/) static void *start_write_dyn(DynBuffer *buf, U32 size) { - U8 *ptr = NULL; + U8 *ptr = nullptr; if (size > buf->size) { - IggyGDrawSendWarning(NULL, "GDraw dynamic vertex buffer usage of %d bytes in one call larger than buffer size %d", size, buf->size); - return NULL; + IggyGDrawSendWarning(nullptr, "GDraw dynamic vertex buffer usage of %d bytes in one call larger than buffer size %d", size, buf->size); + return nullptr; } // update statistics @@ -373,19 +373,19 @@ extern GDrawTexture *gdraw_D3D1X_(WrappedTextureCreate)(ID3D1X(ShaderResourceVie { GDrawStats stats={0}; GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats); // it may need to free one item to give us a handle - p->handle.tex.d3d = NULL; + p->handle.tex.d3d = nullptr; p->handle.tex.d3d_view = tex_view; - p->handle.tex.d3d_rtview = NULL; + p->handle.tex.d3d_rtview = nullptr; p->handle.tex.w = 1; p->handle.tex.h = 1; - gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned); + gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned); return (GDrawTexture *) p; } extern void gdraw_D3D1X_(WrappedTextureChange)(GDrawTexture *tex, ID3D1X(ShaderResourceView) *tex_view) { GDrawHandle *p = (GDrawHandle *) tex; - p->handle.tex.d3d = NULL; + p->handle.tex.d3d = nullptr; p->handle.tex.d3d_view = tex_view; } @@ -407,12 +407,12 @@ static void RADLINK gdraw_SetTextureUniqueID(GDrawTexture *tex, void *old_id, vo static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format format, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) { - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; DXGI_FORMAT dxgi_fmt; S32 bpp, size = 0, nmips = 0; if (width >= 16384 || height >= 16384) { - IggyGDrawSendWarning(NULL, "GDraw texture size too large (%d x %d), dimension limit is 16384", width, height); + IggyGDrawSendWarning(nullptr, "GDraw texture size too large (%d x %d), dimension limit is 16384", width, height); return false; } @@ -433,7 +433,7 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, // try to allocate memory for the client to write to p->texture_data = (U8 *) IggyGDrawMalloc(size); if (!p->texture_data) { - IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); + IggyGDrawSendWarning(nullptr, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); return false; } @@ -446,9 +446,9 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, t->handle.tex.w = width; t->handle.tex.h = height; - t->handle.tex.d3d = NULL; - t->handle.tex.d3d_view = NULL; - t->handle.tex.d3d_rtview = NULL; + t->handle.tex.d3d = nullptr; + t->handle.tex.d3d_view = nullptr; + t->handle.tex.d3d_rtview = nullptr; p->texture_type = GDRAW_TEXTURE_TYPE_rgba; p->p0 = t; @@ -512,7 +512,7 @@ static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingI // and create a corresponding shader resource view failed_call = "CreateShaderResourceView"; - hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_view); + hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_view); done: if (!FAILED(hr)) { @@ -525,7 +525,7 @@ done: safe_release(t->handle.tex.d3d_view); gdraw_HandleCacheAllocateFail(t); - t = NULL; + t = nullptr; report_d3d_error(hr, failed_call, " while creating texture"); } @@ -554,8 +554,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void * /*unique_id*/ static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats) { GDrawHandle *t = (GDrawHandle *) tt; - assert(t != NULL); // @GDRAW_ASSERT - if (t->owner == unique_id || unique_id == NULL) { + assert(t != nullptr); // @GDRAW_ASSERT + if (t->owner == unique_id || unique_id == nullptr) { if (t->cache == &gdraw->rendertargets) { gdraw_HandleCacheUnlock(t); // cache it by simply not freeing it @@ -595,7 +595,7 @@ static void RADLINK gdraw_SetAntialiasTexture(S32 width, U8 *rgba) return; } - hr = gdraw->d3d_device->CreateShaderResourceView(gdraw->aa_tex, NULL, &gdraw->aa_tex_view); + hr = gdraw->d3d_device->CreateShaderResourceView(gdraw->aa_tex, nullptr, &gdraw->aa_tex_view); if (FAILED(hr)) { report_d3d_error(hr, "CreateShaderResourceView", " while creating texture"); safe_release(gdraw->aa_tex); @@ -616,8 +616,8 @@ static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat if (p->vertex_data && p->index_data) { GDrawHandle *vb = gdraw_res_alloc_begin(gdraw->vbufcache, vbuf_size + ibuf_size, stats); if (vb) { - vb->handle.vbuf.verts = NULL; - vb->handle.vbuf.inds = NULL; + vb->handle.vbuf.verts = nullptr; + vb->handle.vbuf.inds = nullptr; p->vertex_data_length = vbuf_size; p->index_data_length = ibuf_size; @@ -661,7 +661,7 @@ static GDrawVertexBuffer * RADLINK gdraw_MakeVertexBufferEnd(GDraw_MakeVertexBuf safe_release(vb->handle.vbuf.inds); gdraw_HandleCacheAllocateFail(vb); - vb = NULL; + vb = nullptr; report_d3d_error(hr, "CreateBuffer", " creating vertex buffer"); } else { @@ -682,7 +682,7 @@ static rrbool RADLINK gdraw_TryLockVertexBuffer(GDrawVertexBuffer *vb, void *uni static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) { GDrawHandle *h = (GDrawHandle *) vb; - assert(h != NULL); // @GDRAW_ASSERT + assert(h != nullptr); // @GDRAW_ASSERT if (h->owner == unique_id) gdraw_res_free(h, stats); } @@ -712,31 +712,31 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats) // ran out of RTs, allocate a new one S32 size = gdraw->frametex_width * gdraw->frametex_height * 4; if (gdraw->rendertargets.bytes_free < size) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit size limit of %d bytes", gdraw->rendertargets.total_bytes); - return NULL; + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit size limit of %d bytes", gdraw->rendertargets.total_bytes); + return nullptr; } t = gdraw_HandleCacheAllocateBegin(&gdraw->rendertargets); if (!t) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit handle limit"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit handle limit"); return t; } D3D1X_(TEXTURE2D_DESC) desc = { gdraw->frametex_width, gdraw->frametex_height, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_SHADER_RESOURCE) | D3D1X_(BIND_RENDER_TARGET), 0, 0 }; - t->handle.tex.d3d = NULL; - t->handle.tex.d3d_view = NULL; - t->handle.tex.d3d_rtview = NULL; + t->handle.tex.d3d = nullptr; + t->handle.tex.d3d_view = nullptr; + t->handle.tex.d3d_rtview = nullptr; - HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &t->handle.tex.d3d); + HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, nullptr, &t->handle.tex.d3d); failed_call = "CreateTexture2D"; if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_view); + hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_view); failed_call = "CreateTexture2D"; } if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateRenderTargetView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_rtview); + hr = gdraw->d3d_device->CreateRenderTargetView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_rtview); failed_call = "CreateRenderTargetView"; } @@ -748,7 +748,7 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats) report_d3d_error(hr, failed_call, " creating rendertarget"); - return NULL; + return nullptr; } gdraw_HandleCacheAllocateEnd(t, size, (void *) 1, GDRAW_HANDLE_STATE_locked); @@ -768,10 +768,10 @@ static ID3D1X(DepthStencilView) *get_rendertarget_depthbuffer(GDrawStats *stats) D3D1X_(TEXTURE2D_DESC) desc = { gdraw->frametex_width, gdraw->frametex_height, 1, 1, DXGI_FORMAT_D24_UNORM_S8_UINT, { 1, 0 }, D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_DEPTH_STENCIL), 0, 0 }; - HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &gdraw->rt_depth_buffer); + HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, nullptr, &gdraw->rt_depth_buffer); failed_call = "CreateTexture2D"; if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateDepthStencilView(gdraw->rt_depth_buffer, NULL, &gdraw->depth_buffer[1]); + hr = gdraw->d3d_device->CreateDepthStencilView(gdraw->rt_depth_buffer, nullptr, &gdraw->depth_buffer[1]); failed_call = "CreateDepthStencilView while creating rendertarget"; } @@ -1110,7 +1110,7 @@ static void set_render_target(GDrawStats *stats) gdraw->d3d_context->OMSetRenderTargets(1, &target, gdraw->depth_buffer[0]); gdraw->d3d_context->RSSetState(gdraw->raster_state[gdraw->main_msaa]); } else { - ID3D1X(DepthStencilView) *depth = NULL; + ID3D1X(DepthStencilView) *depth = nullptr; if (gdraw->cur->flags & (GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_id | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_stencil)) depth = get_rendertarget_depthbuffer(stats); @@ -1125,15 +1125,15 @@ static void set_render_target(GDrawStats *stats) static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_texture_format /*format*/, U32 flags, void *owner, GDrawStats *stats) { GDrawFramebufferState *n = gdraw->cur+1; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (gdraw->tw == 0 || gdraw->th == 0) { - IggyGDrawSendWarning(NULL, "GDraw warning: w=0,h=0 rendertarget"); + IggyGDrawSendWarning(nullptr, "GDraw warning: w=0,h=0 rendertarget"); return false; } if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) { assert(0); - IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); return false; } @@ -1147,10 +1147,10 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex n->flags = flags; n->color_buffer = t; - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT ++gdraw->cur; - gdraw->cur->cached = owner != NULL; + gdraw->cur->cached = owner != nullptr; if (owner) { gdraw->cur->base_x = region->x0; gdraw->cur->base_y = region->y0; @@ -1229,9 +1229,9 @@ static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats) assert(m >= gdraw->frame); // bug in Iggy -- unbalanced if (m != gdraw->frame) { - assert(m->color_buffer != NULL); // @GDRAW_ASSERT + assert(m->color_buffer != nullptr); // @GDRAW_ASSERT } - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT // switch back to old render target set_render_target(stats); @@ -1288,8 +1288,8 @@ static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap { ID3D1XContext *d3d = gdraw->d3d_context; - if (tex == NULL) { - ID3D1X(ShaderResourceView) *notex = NULL; + if (tex == nullptr) { + ID3D1X(ShaderResourceView) *notex = nullptr; d3d->PSSetShaderResources(texunit, 1, ¬ex); } else { GDrawHandle *h = (GDrawHandle *) tex; @@ -1300,7 +1300,7 @@ static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap static void RADLINK gdraw_Set3DTransform(F32 *mat) { - if (mat == NULL) + if (mat == nullptr) gdraw->use_3d = 0; else { gdraw->use_3d = 1; @@ -1363,9 +1363,9 @@ static int set_renderstate_full(S32 vertex_format, GDrawRenderState *r, GDrawSta // in stencil set mode, prefer not doing any shading at all // but if alpha test is on, we need to make an exception -#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do NULL PS it seems +#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do nullptr PS it seems if (which != GDRAW_TEXTURE_alpha_test) - program = NULL; + program = nullptr; else #endif { @@ -1475,7 +1475,7 @@ static int vertsize[GDRAW_vformat__basic_count] = { // Draw triangles with a given renderstate // -static void tag_resources(void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL) +static void tag_resources(void *r1, void *r2=nullptr, void *r3=nullptr, void *r4=nullptr) { U64 now = gdraw->frame_counter; if (r1) ((GDrawHandle *) r1)->fence.value = now; @@ -1687,7 +1687,7 @@ static void set_clamp_constant(F32 *constant, GDrawTexture *tex) static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbevel, GDrawStats *stats) { - if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, stats)) + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, nullptr, stats)) return; set_texture(0, r->tex[0], false, GDRAW_WRAP_clamp); @@ -1775,7 +1775,7 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 assert(0); } } else { - GDrawHandle *blend_tex = NULL; + GDrawHandle *blend_tex = nullptr; // for crazy blend modes, we need to read back from the framebuffer // and do the blending in the pixel shader. we do this with copies @@ -1859,18 +1859,18 @@ static void destroy_shader(ProgramWithCachedVariableLocations *p) { if (p->pshader) { p->pshader->Release(); - p->pshader = NULL; + p->pshader = nullptr; } } static ID3D1X(Buffer) *create_dynamic_buffer(U32 size, U32 bind) { D3D1X_(BUFFER_DESC) desc = { size, D3D1X_(USAGE_DYNAMIC), bind, D3D1X_(CPU_ACCESS_WRITE), 0 }; - ID3D1X(Buffer) *buf = NULL; - HRESULT hr = gdraw->d3d_device->CreateBuffer(&desc, NULL, &buf); + ID3D1X(Buffer) *buf = nullptr; + HRESULT hr = gdraw->d3d_device->CreateBuffer(&desc, nullptr, &buf); if (FAILED(hr)) { report_d3d_error(hr, "CreateBuffer", " creating dynamic vertex buffer"); - buf = NULL; + buf = nullptr; } return buf; } @@ -1907,7 +1907,7 @@ static void create_all_shaders_and_state(void) HRESULT hr = d3d->CreateInputLayout(vformats[i].desc, vformats[i].nelem, vsh->bytecode, vsh->size, &gdraw->inlayout[i]); if (FAILED(hr)) { report_d3d_error(hr, "CreateInputLayout", ""); - gdraw->inlayout[i] = NULL; + gdraw->inlayout[i] = nullptr; } } @@ -2026,11 +2026,11 @@ static void create_all_shaders_and_state(void) hr = gdraw->d3d_device->CreateBuffer(&bufdesc, &data, &gdraw->quad_ib); if (FAILED(hr)) { report_d3d_error(hr, "CreateBuffer", " for constants"); - gdraw->quad_ib = NULL; + gdraw->quad_ib = nullptr; } IggyGDrawFree(inds); } else - gdraw->quad_ib = NULL; + gdraw->quad_ib = nullptr; } static void destroy_all_shaders_and_state() @@ -2103,7 +2103,7 @@ static void free_gdraw() if (gdraw->texturecache) IggyGDrawFree(gdraw->texturecache); if (gdraw->vbufcache) IggyGDrawFree(gdraw->vbufcache); IggyGDrawFree(gdraw); - gdraw = NULL; + gdraw = nullptr; } static bool alloc_dynbuffer(U32 size) @@ -2139,7 +2139,7 @@ static bool alloc_dynbuffer(U32 size) gdraw->max_quad_vert_count = RR_MIN(size / sizeof(gswf_vertex_xyst), QUAD_IB_COUNT * 4); gdraw->max_quad_vert_count &= ~3; // must be multiple of four - return gdraw->dyn_vb.buffer != NULL && gdraw->dyn_ib.buffer != NULL; + return gdraw->dyn_vb.buffer != nullptr && gdraw->dyn_ib.buffer != nullptr; } int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S32 num_bytes) @@ -2178,7 +2178,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 IggyGDrawFree(gdraw->texturecache); } gdraw->texturecache = make_handle_cache(GDRAW_D3D1X_(RESOURCE_texture)); - return gdraw->texturecache != NULL; + return gdraw->texturecache != nullptr; case GDRAW_D3D1X_(RESOURCE_vertexbuffer): if (gdraw->vbufcache) { @@ -2186,7 +2186,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 IggyGDrawFree(gdraw->vbufcache); } gdraw->vbufcache = make_handle_cache(GDRAW_D3D1X_(RESOURCE_vertexbuffer)); - return gdraw->vbufcache != NULL; + return gdraw->vbufcache != nullptr; case GDRAW_D3D1X_(RESOURCE_dynbuffer): unbind_resources(); @@ -2202,7 +2202,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 static GDrawFunctions *create_context(ID3D1XDevice *dev, ID3D1XContext *ctx, S32 w, S32 h) { gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw)); - if (!gdraw) return NULL; + if (!gdraw) return nullptr; memset(gdraw, 0, sizeof(*gdraw)); @@ -2217,7 +2217,7 @@ static GDrawFunctions *create_context(ID3D1XDevice *dev, ID3D1XContext *ctx, S32 if (!gdraw->texturecache || !gdraw->vbufcache || !alloc_dynbuffer(gdraw_limits[GDRAW_D3D1X_(RESOURCE_dynbuffer)].num_bytes)) { free_gdraw(); - return NULL; + return nullptr; } create_all_shaders_and_state(); @@ -2288,7 +2288,7 @@ void gdraw_D3D1X_(DestroyContext)(void) if (gdraw->texturecache) gdraw_res_flush(gdraw->texturecache, &stats); if (gdraw->vbufcache) gdraw_res_flush(gdraw->vbufcache, &stats); - gdraw->d3d_device = NULL; + gdraw->d3d_device = nullptr; } free_gdraw(); @@ -2351,7 +2351,7 @@ void RADLINK gdraw_D3D1X_(GetResourceUsageStats)(gdraw_resourcetype type, S32 *h case GDRAW_D3D1X_(RESOURCE_texture): cache = gdraw->texturecache; break; case GDRAW_D3D1X_(RESOURCE_vertexbuffer): cache = gdraw->vbufcache; break; case GDRAW_D3D1X_(RESOURCE_dynbuffer): *handles_used = 0; *bytes_used = gdraw->last_dyn_maxalloc; return; - default: cache = NULL; break; + default: cache = nullptr; break; } *handles_used = *bytes_used = 0; @@ -2408,7 +2408,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, case IFT_FORMAT_DXT3 : size=16; d3dfmt = DXGI_FORMAT_BC2_UNORM; blk = 4; break; case IFT_FORMAT_DXT5 : size=16; d3dfmt = DXGI_FORMAT_BC3_UNORM; blk = 4; break; default: { - IggyGDrawSendWarning(NULL, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format); + IggyGDrawSendWarning(nullptr, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format); goto done; } } @@ -2424,7 +2424,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, free_data = (U8 *) IggyGDrawMalloc(total_size); if (!free_data) { - IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); + IggyGDrawSendWarning(nullptr, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); goto done; } @@ -2457,7 +2457,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, if (FAILED(hr)) goto done; failed_call = "CreateShaderResourceView for texture creation"; - hr = gdraw->d3d_device->CreateShaderResourceView(tex, NULL, &view); + hr = gdraw->d3d_device->CreateShaderResourceView(tex, nullptr, &view); if (FAILED(hr)) goto done; t = gdraw_D3D1X_(WrappedTextureCreate)(view); diff --git a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl index 11a197e67..1790de77e 100644 --- a/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/Durango/Iggy/gdraw/gdraw_shared.inl @@ -226,7 +226,7 @@ static void debug_check_raw_values(GDrawHandleCache *c) s = s->next; } s = c->active; - while (s != NULL) { + while (s != nullptr) { assert(s->raw_ptr != t->raw_ptr); s = s->next; } @@ -433,7 +433,7 @@ static rrbool gdraw_HandleCacheLockStats(GDrawHandle *t, void *owner, GDrawStats static rrbool gdraw_HandleCacheLock(GDrawHandle *t, void *owner) { - return gdraw_HandleCacheLockStats(t, owner, NULL); + return gdraw_HandleCacheLockStats(t, owner, nullptr); } static void gdraw_HandleCacheUnlock(GDrawHandle *t) @@ -461,11 +461,11 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->is_thrashing = false; c->did_defragment = false; for (i=0; i < GDRAW_HANDLE_STATE__count; i++) { - c->state[i].owner = NULL; - c->state[i].cache = NULL; // should never follow cache link from sentinels! + c->state[i].owner = nullptr; + c->state[i].cache = nullptr; // should never follow cache link from sentinels! c->state[i].next = c->state[i].prev = &c->state[i]; #ifdef GDRAW_MANAGE_MEM - c->state[i].raw_ptr = NULL; + c->state[i].raw_ptr = nullptr; #endif c->state[i].fence.value = 0; c->state[i].bytes = 0; @@ -478,7 +478,7 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->handle[i].bytes = 0; c->handle[i].state = GDRAW_HANDLE_STATE_free; #ifdef GDRAW_MANAGE_MEM - c->handle[i].raw_ptr = NULL; + c->handle[i].raw_ptr = nullptr; #endif } c->state[GDRAW_HANDLE_STATE_free].next = &c->handle[0]; @@ -486,10 +486,10 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->prev_frame_start.value = 0; c->prev_frame_end.value = 0; #ifdef GDRAW_MANAGE_MEM - c->alloc = NULL; + c->alloc = nullptr; #endif #ifdef GDRAW_MANAGE_MEM_TWOPOOL - c->alloc_other = NULL; + c->alloc_other = nullptr; #endif check_lists(c); } @@ -497,14 +497,14 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte static GDrawHandle *gdraw_HandleCacheAllocateBegin(GDrawHandleCache *c) { GDrawHandle *free_list = &c->state[GDRAW_HANDLE_STATE_free]; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (free_list->next != free_list) { t = free_list->next; gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_alloc); t->bytes = 0; t->owner = 0; #ifdef GDRAW_MANAGE_MEM - t->raw_ptr = NULL; + t->raw_ptr = nullptr; #endif #ifdef GDRAW_CORRUPTION_CHECK t->has_check_value = false; @@ -558,7 +558,7 @@ static GDrawHandle *gdraw_HandleCacheGetLRU(GDrawHandleCache *c) // at the front of the LRU list are the oldest ones, since in-use resources // will get appended on every transition from "locked" to "live". GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_live]; - return (sentinel->next != sentinel) ? sentinel->next : NULL; + return (sentinel->next != sentinel) ? sentinel->next : nullptr; } static void gdraw_HandleCacheTick(GDrawHandleCache *c, GDrawFence now) @@ -1090,7 +1090,7 @@ static void make_pool_aligned(void **start, S32 *num_bytes, U32 alignment) if (addr_aligned != addr_orig) { S32 diff = (S32) (addr_aligned - addr_orig); if (*num_bytes < diff) { - *start = NULL; + *start = nullptr; *num_bytes = 0; return; } else { @@ -1127,7 +1127,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) UINTa remaining = arena->end - arena->current; UINTa total_size = (ptr - arena->current) + size; if (remaining < total_size) // doesn't fit - return NULL; + return nullptr; arena->current = ptr + size; return ptr; @@ -1152,7 +1152,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // (i.e. block->next->prev == block->prev->next == block) // - All allocated blocks are also kept in a hash table, indexed by their // pointer (to allow free to locate the corresponding block_info quickly). -// There's a single-linked, NULL-terminated list of elements in each hash +// There's a single-linked, nullptr-terminated list of elements in each hash // bucket. // - The physical block list is ordered. It always contains all currently // active blocks and spans the whole managed memory range. There are no @@ -1161,7 +1161,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // they are coalesced immediately. // - The maximum number of blocks that could ever be necessary is allocated // on initialization. All block_infos not currently in use are kept in a -// single-linked, NULL-terminated list of unused blocks. Every block is either +// single-linked, nullptr-terminated list of unused blocks. Every block is either // in the physical block list or the unused list, and the total number of // blocks is constant. // These invariants always hold before and after an allocation/free. @@ -1379,7 +1379,7 @@ static void gfxalloc_check2(gfx_allocator *alloc) static gfx_block_info *gfxalloc_pop_unused(gfx_allocator *alloc) { - GFXALLOC_ASSERT(alloc->unused_list != NULL); + GFXALLOC_ASSERT(alloc->unused_list != nullptr); GFXALLOC_ASSERT(alloc->unused_list->is_unused); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_unused);) @@ -1452,7 +1452,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma U32 i, max_blocks, size; if (!align || (align & (align - 1)) != 0) // align must be >0 and a power of 2 - return NULL; + return nullptr; // for <= max_allocs live allocs, there's <= 2*max_allocs+1 blocks. worst case: // [free][used][free] .... [free][used][free] @@ -1460,7 +1460,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma size = sizeof(gfx_allocator) + max_blocks * sizeof(gfx_block_info); a = (gfx_allocator *) IggyGDrawMalloc(size); if (!a) - return NULL; + return nullptr; memset(a, 0, size); @@ -1501,16 +1501,16 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma a->blocks[i].is_unused = 1; gfxalloc_check(a); - debug_complete_check(a, NULL, 0,0); + debug_complete_check(a, nullptr, 0,0); return a; } static void *gfxalloc_alloc(gfx_allocator *alloc, U32 size_in_bytes) { - gfx_block_info *cur, *best = NULL; + gfx_block_info *cur, *best = nullptr; U32 i, best_wasted = ~0u; U32 size = size_in_bytes; -debug_complete_check(alloc, NULL, 0,0); +debug_complete_check(alloc, nullptr, 0,0); gfxalloc_check(alloc); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) @@ -1560,7 +1560,7 @@ gfxalloc_check(alloc); debug_check_overlap(alloc->cache, best->ptr, best->size); return best->ptr; } else - return NULL; // not enough space! + return nullptr; // not enough space! } static void gfxalloc_free(gfx_allocator *alloc, void *ptr) @@ -1730,7 +1730,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta // (unused for allocated blocks, we'll use it to store a back-pointer to the corresponding handle) for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys) if (!b->is_free) - b->prev = NULL; + b->prev = nullptr; // go through all handles and store a pointer to the handle in the corresponding memory block for (i=0; i < c->max_handles; i++) @@ -1743,7 +1743,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta break; } - GFXALLOC_ASSERT(b != NULL); // didn't find this block anywhere! + GFXALLOC_ASSERT(b != nullptr); // didn't find this block anywhere! } // clear alloc hash table (we rebuild it during defrag) @@ -1905,7 +1905,7 @@ static rrbool gdraw_CanDefragment(GDrawHandleCache *c) static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats) { GDrawHandleCache *c = t->cache; - void *ptr = NULL; + void *ptr = nullptr; assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); // anything we migrate should be in the "other" (old) pool @@ -2295,7 +2295,7 @@ static void gdraw_bufring_init(gdraw_bufring * RADRESTRICT ring, void *ptr, U32 static void gdraw_bufring_shutdown(gdraw_bufring * RADRESTRICT ring) { - ring->cur = NULL; + ring->cur = nullptr; ring->seg_size = 0; } @@ -2305,7 +2305,7 @@ static void *gdraw_bufring_alloc(gdraw_bufring * RADRESTRICT ring, U32 size, U32 gdraw_bufring_seg *seg; if (size > ring->seg_size) - return NULL; // nope, won't fit + return nullptr; // nope, won't fit assert(align <= ring->align); @@ -2410,7 +2410,7 @@ static rrbool gdraw_res_free_lru(GDrawHandleCache *c, GDrawStats *stats) // was it referenced since end of previous frame (=in this frame)? // if some, we're thrashing; report it to the user, but only once per frame. if (c->prev_frame_end.value < r->fence.value && !c->is_thrashing) { - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); c->is_thrashing = true; } @@ -2430,8 +2430,8 @@ static GDrawHandle *gdraw_res_alloc_outofmem(GDrawHandleCache *c, GDrawHandle *t { if (t) gdraw_HandleCacheAllocateFail(t); - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); - return NULL; + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); + return nullptr; } #ifndef GDRAW_MANAGE_MEM @@ -2440,7 +2440,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt { GDrawHandle *t; if (size > c->total_bytes) - gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); else { // given how much data we're going to allocate, throw out // data until there's "room" (this basically lets us use @@ -2448,7 +2448,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // packing it and being exact) while (c->bytes_free < size) { if (!gdraw_res_free_lru(c, stats)) { - gdraw_res_alloc_outofmem(c, NULL, "memory"); + gdraw_res_alloc_outofmem(c, nullptr, "memory"); break; } } @@ -2463,8 +2463,8 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // we'd trade off cost of regenerating) if (gdraw_res_free_lru(c, stats)) { t = gdraw_HandleCacheAllocateBegin(c); - if (t == NULL) { - gdraw_res_alloc_outofmem(c, NULL, "handles"); + if (t == nullptr) { + gdraw_res_alloc_outofmem(c, nullptr, "handles"); } } } @@ -2508,7 +2508,7 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) { GDRAW_FENCE_FLUSH(); // dead list is sorted by fence index - make sure all fence values are current. - r->owner = NULL; + r->owner = nullptr; gdraw_HandleCacheInsertDead(r); gdraw_res_reap(r->cache, stats); } @@ -2516,11 +2516,11 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats) { GDrawHandle *t; - void *ptr = NULL; + void *ptr = nullptr; gdraw_res_reap(c, stats); // NB this also does GDRAW_FENCE_FLUSH(); if (size > c->total_bytes) - return gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + return gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); // now try to allocate a handle t = gdraw_HandleCacheAllocateBegin(c); @@ -2532,7 +2532,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt gdraw_res_free_lru(c, stats); t = gdraw_HandleCacheAllocateBegin(c); if (!t) - return gdraw_res_alloc_outofmem(c, NULL, "handles"); + return gdraw_res_alloc_outofmem(c, nullptr, "handles"); } // try to allocate first diff --git a/Minecraft.Client/Durango/Iggy/include/gdraw.h b/Minecraft.Client/Durango/Iggy/include/gdraw.h index 404a2642b..7cc4ddd0e 100644 --- a/Minecraft.Client/Durango/Iggy/include/gdraw.h +++ b/Minecraft.Client/Durango/Iggy/include/gdraw.h @@ -356,13 +356,13 @@ IDOC typedef struct GDrawPrimitive IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats); /* Draws a collection of indexed triangles, ignoring special filters or blend modes. - If buf is NULL, then the pointers in 'prim' are machine pointers, and + If buf is nullptr, then the pointers in 'prim' are machine pointers, and you need to make a copy of the data (note currently all triangles implementing strokes (wide lines) go this path). - If buf is non-NULL, then use the appropriate vertex buffer, and the + If buf is non-nullptr, then use the appropriate vertex buffer, and the pointers in prim are actually offsets from the beginning of the - vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL; + vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) nullptr; (note there are separate spaces for vertices and indices; e.g. the first mesh in a given vertex buffer will normally have a 0 offset for the vertices and a 0 offset for the indices) @@ -455,7 +455,7 @@ IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_Pro /* Ends specification of a new texture. $:info The same handle initially passed to $gdraw_make_texture_begin - $:return Handle for the newly created texture, or NULL if an error occured + $:return Handle for the newly created texture, or nullptr if an error occured */ IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats); diff --git a/Minecraft.Client/Durango/Iggy/include/iggyexpruntime.h b/Minecraft.Client/Durango/Iggy/include/iggyexpruntime.h index 1f1a90a1c..a42ccbfff 100644 --- a/Minecraft.Client/Durango/Iggy/include/iggyexpruntime.h +++ b/Minecraft.Client/Durango/Iggy/include/iggyexpruntime.h @@ -25,8 +25,8 @@ IDOC RADEXPFUNC HIGGYEXP RADEXPLINK IggyExpCreate(char *ip_address, S32 port, vo $:storage A small block of storage that needed to store the $HIGGYEXP, must be at least $IGGYEXP_MIN_STORAGE $:storage_size_in_bytes The size of the block pointer to by storage -Returns a NULL HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer -can be contacted at the specified address/port. Otherwise returns a non-NULL $HIGGYEXP +Returns a nullptr HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer +can be contacted at the specified address/port. Otherwise returns a non-nullptr $HIGGYEXP which you can pass to $IggyUseExplorer. */ IDOC RADEXPFUNC void RADEXPLINK IggyExpDestroy(HIGGYEXP p); diff --git a/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp b/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp index e1d056a7d..cc19b7382 100644 --- a/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp +++ b/Minecraft.Client/Durango/Leaderboards/DurangoLeaderboardManager.cpp @@ -14,7 +14,7 @@ DurangoLeaderboardManager::DurangoLeaderboardManager() m_openSessions = 0; m_xboxLiveContext = nullptr; - m_scores = NULL; + m_scores = nullptr; m_readCount = 0; m_maxRank = 0; m_waitingForProfiles = false; @@ -160,7 +160,7 @@ void DurangoLeaderboardManager::Tick() m_displayNames.clear(); } - //assert(m_scores != NULL || m_readCount == 0); + //assert(m_scores != nullptr || m_readCount == 0); view.m_numQueries = m_readCount; view.m_queries = m_scores; @@ -170,7 +170,7 @@ void DurangoLeaderboardManager::Tick() eStatsReturn ret = view.m_numQueries > 0 ? eStatsReturn_Success : eStatsReturn_NoResults; - if (m_readListener != NULL) + if (m_readListener != nullptr) { app.DebugPrintf("[LeaderboardManager] OnStatsReadComplete(%i, %i, _)\n", ret, m_readCount); m_readListener->OnStatsReadComplete(ret, m_maxRank, view); @@ -178,7 +178,7 @@ void DurangoLeaderboardManager::Tick() app.DebugPrintf("[LeaderboardManager] Deleting scores\n"); delete [] m_scores; - m_scores = NULL; + m_scores = nullptr; setState(eStatsState_Idle); } @@ -186,9 +186,9 @@ void DurangoLeaderboardManager::Tick() case eStatsState_Failed: view.m_numQueries = 0; - view.m_queries = NULL; + view.m_queries = nullptr; - if ( m_readListener != NULL ) + if ( m_readListener != nullptr ) { m_readListener->OnStatsReadComplete(eStatsReturn_NetworkError, 0, view); } @@ -371,7 +371,7 @@ void DurangoLeaderboardManager::FlushStats() //Cancel the current operation void DurangoLeaderboardManager::CancelOperation() { - m_readListener = NULL; + m_readListener = nullptr; setState(eStatsState_Canceled); if(m_leaderboardAsyncOp) m_leaderboardAsyncOp->Cancel(); @@ -458,7 +458,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperationTotalRowCount; m_readCount = lastResult->Rows->Size; - if (m_scores != NULL) delete [] m_scores; + if (m_scores != nullptr) delete [] m_scores; m_scores = new ReadScore[m_readCount]; ZeroMemory(m_scores, sizeof(ReadScore) * m_readCount); diff --git a/Minecraft.Client/Durango/Leaderboards/DurangoStatsDebugger.cpp b/Minecraft.Client/Durango/Leaderboards/DurangoStatsDebugger.cpp index caa5857e9..5ac711417 100644 --- a/Minecraft.Client/Durango/Leaderboards/DurangoStatsDebugger.cpp +++ b/Minecraft.Client/Durango/Leaderboards/DurangoStatsDebugger.cpp @@ -84,7 +84,7 @@ vector *StatParam::getStats() return out; } -DurangoStatsDebugger *DurangoStatsDebugger::instance = NULL; +DurangoStatsDebugger *DurangoStatsDebugger::instance = nullptr; DurangoStatsDebugger::DurangoStatsDebugger() { @@ -320,7 +320,7 @@ DurangoStatsDebugger *DurangoStatsDebugger::Initialize() void DurangoStatsDebugger::PrintStats(int iPad) { - if (instance == NULL) instance = Initialize(); + if (instance == nullptr) instance = Initialize(); vector *tmp = instance->getStats(); instance->m_printQueue.insert(instance->m_printQueue.end(), tmp->begin(), tmp->end()); diff --git a/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp b/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp index 18f4328c5..f97f9bb33 100644 --- a/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp +++ b/Minecraft.Client/Durango/Leaderboards/GameProgress.cpp @@ -10,11 +10,11 @@ namespace WFC = Windows::Foundation::Collections; namespace MXSA = Microsoft::Xbox::Services::Achievements; namespace CC = concurrency; -GameProgress *GameProgress::instance = NULL; +GameProgress *GameProgress::instance = nullptr; void GameProgress::Flush(int iPad) { - if (instance == NULL) + if (instance == nullptr) instance = new GameProgress(); instance->updatePlayer(iPad); @@ -22,7 +22,7 @@ void GameProgress::Flush(int iPad) void GameProgress::Tick() { - if (instance == NULL) + if (instance == nullptr) instance = new GameProgress(); long long currentTime = System::currentTimeMillis(); diff --git a/Minecraft.Client/Durango/Miles/include/mss.h b/Minecraft.Client/Durango/Miles/include/mss.h index 531dcbc92..a9fd231a9 100644 --- a/Minecraft.Client/Durango/Miles/include/mss.h +++ b/Minecraft.Client/Durango/Miles/include/mss.h @@ -584,7 +584,7 @@ typedef enum } MSS_SPEAKER; // -// Pass to AIL_midiOutOpen for NULL MIDI driver +// Pass to AIL_midiOutOpen for nullptr MIDI driver // #define MIDI_NULL_DRIVER ((U32)(S32)-2) @@ -833,7 +833,7 @@ the enumeration function until it returns 0. #define DEFAULT_DPWOD ((UINTa)-1) // Preferred WaveOut device == WAVE_MAPPER #define DIG_PREFERRED_DS_DEVICE 20 -#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default NULL GUID +#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default nullptr GUID #define MDI_SEQUENCES 21 @@ -1305,7 +1305,7 @@ typedef ASIRESULT (AILCALL *ASI_STARTUP)(void); typedef ASIRESULT (AILCALL * ASI_SHUTDOWN)(void); // -// Return codec error message, or NULL if no errors have occurred since +// Return codec error message, or nullptr if no errors have occurred since // last call // // The ASI error text state is global to all streams @@ -1878,7 +1878,7 @@ typedef struct _S3DSTATE // Portion of HSAMPLE that deals with 3D posi F32 spread; - HSAMPLE owner; // May be NULL if used for temporary/internal calculations + HSAMPLE owner; // May be nullptr if used for temporary/internal calculations AILFALLOFFCB falloff_function; // User function for min/max distance calculations, if desired MSSVECTOR3D position_graph[MILES_MAX_SEGMENT_COUNT]; @@ -2460,7 +2460,7 @@ typedef struct _DIG_DRIVER // Handle to digital audio driver S32 DS_initialized; - AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or NULL if none) + AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or nullptr if none) AILLPDIRECTSOUNDBUFFER DS_out_buff; // Output buffer (may be sec or prim) S32 DS_buffer_size; // Size of entire output buffer @@ -4866,10 +4866,10 @@ typedef struct U8 *MP3_file_image; // Original MP3_file_image pointer passed to AIL_inspect_MP3() S32 MP3_image_size; // Original MP3_image_size passed to AIL_inspect_MP3() - U8 *ID3v2; // ID3v2 tag, if not NULL + U8 *ID3v2; // ID3v2 tag, if not nullptr S32 ID3v2_size; // Size of tag in bytes - U8 *ID3v1; // ID3v1 tag, if not NULL (always 128 bytes long if present) + U8 *ID3v1; // ID3v1 tag, if not nullptr (always 128 bytes long if present) U8 *start_MP3_data; // Pointer to start of data area in file (not necessarily first valid frame) U8 *end_MP3_data; // Pointer to last valid byte in MP3 data area (before ID3v1 tag, if any) diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp index a054a716d..cb39b5629 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp @@ -25,7 +25,7 @@ int DQRNetworkManager::m_bootUserIndex; wstring DQRNetworkManager::m_bootSessionName; wstring DQRNetworkManager::m_bootServiceConfig; wstring DQRNetworkManager::m_bootSessionTemplate; -DQRNetworkManager * DQRNetworkManager::s_pDQRManager = NULL; +DQRNetworkManager * DQRNetworkManager::s_pDQRManager = nullptr; //using namespace Windows::Xbox::Networking; @@ -87,16 +87,16 @@ DQRNetworkManager::DQRNetworkManager(IDQRNetworkManagerListener *listener) memset(&m_roomSyncData, 0, sizeof(m_roomSyncData)); memset(m_players, 0, sizeof(m_players)); - m_CreateSessionThread = NULL; - m_GetFriendPartyThread = NULL; - m_UpdateCustomSessionDataThread = NULL; + m_CreateSessionThread = nullptr; + m_GetFriendPartyThread = nullptr; + m_UpdateCustomSessionDataThread = nullptr; - m_CheckPartyInviteThread = NULL; + m_CheckPartyInviteThread = nullptr; m_notifyForFullParty = false; m_customDataDirtyUpdateTicks = 0; m_sessionResultCount = 0; - m_sessionSearchResults = NULL; + m_sessionSearchResults = nullptr; m_joinSessionUserMask = 0; m_cancelJoinFromSearchResult = false; @@ -274,7 +274,7 @@ void DQRNetworkManager::JoinSession(int playerMask) // If we found the session, then set the status of this member to be active (should be reserved). This will stop our slot timing out and us being dropped out of the session. if( session != nullptr ) { - if(!IsPlayerInSession(joiningUser->XboxUserId, session, NULL) ) + if(!IsPlayerInSession(joiningUser->XboxUserId, session, nullptr) ) { app.DebugPrintf("DNM_INT_STATE_JOINING_FAILED didn't find required player in session\n"); SetState(DNM_INT_STATE_JOINING_FAILED); @@ -600,7 +600,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex) m_joinSessionXUIDs[userIndex] = ProfileManager.GetUser(userIndex)->XboxUserId; m_partyController->AddLocalUsersToParty(1 << userIndex, ProfileManager.GetUser(0)); - m_addLocalPlayerSuccessPlayer = NULL; + m_addLocalPlayerSuccessPlayer = nullptr; m_addLocalPlayerState = DNM_ADD_PLAYER_STATE_COMPLETE_SUCCESS; } } @@ -763,7 +763,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetPlayerBySmallId(int idx) } } } - return NULL; + return nullptr; } DQRNetworkPlayer *DQRNetworkManager::GetPlayerByXuid(PlayerUID xuid) @@ -778,7 +778,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetPlayerByXuid(PlayerUID xuid) } } } - return NULL; + return nullptr; } // Retrieve player display name by gamertag @@ -809,7 +809,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetLocalPlayerByUserIndex(int idx) } } } - return NULL; + return nullptr; } DQRNetworkPlayer *DQRNetworkManager::GetHostPlayer() @@ -967,19 +967,19 @@ void DQRNetworkManager::Tick_Party() void DQRNetworkManager::Tick_CustomSessionData() { // If there was a thread updaing our custom session data, then clear it up if it is done - if( m_UpdateCustomSessionDataThread != NULL ) + if( m_UpdateCustomSessionDataThread != nullptr ) { if( !m_UpdateCustomSessionDataThread->isRunning() ) { delete m_UpdateCustomSessionDataThread; - m_UpdateCustomSessionDataThread = NULL; + m_UpdateCustomSessionDataThread = nullptr; } } // If our custom data is dirty, and we aren't currently updating, then kick off a thread to update it if( m_isHosting && ( !m_isOfflineGame ) ) { - if( m_UpdateCustomSessionDataThread == NULL ) + if( m_UpdateCustomSessionDataThread == nullptr ) { if( m_customDataDirtyUpdateTicks ) { @@ -1003,7 +1003,7 @@ void DQRNetworkManager::Tick_AddAndRemoveLocalPlayers() // A lot of handling adding local players is handled asynchronously. Trying to avoid having the callbacks that may result from this being called from the task threads, so handling this aspect of it here in the tick if( m_addLocalPlayerState == DNM_ADD_PLAYER_STATE_COMPLETE_SUCCESS ) { - // If we've completed, and we're the host, then we should have the new player to create stored here in m_localPlayerSuccessCreated. For clients, this will just be NULL as the actual + // If we've completed, and we're the host, then we should have the new player to create stored here in m_localPlayerSuccessCreated. For clients, this will just be nullptr as the actual // adding of the player happens as part of a longer process of the host creating us a reserved slot etc. etc. if( m_addLocalPlayerSuccessPlayer ) { @@ -1201,7 +1201,7 @@ void DQRNetworkManager::Tick_StateMachine() break; case DNM_INT_STATE_HOSTING_WAITING_TO_PLAY: delete m_CreateSessionThread; - m_CreateSessionThread = NULL; + m_CreateSessionThread = nullptr; // If the game is offline we can transition straight to playing if (m_isOfflineGame) StartGame(); break; @@ -1247,10 +1247,10 @@ void DQRNetworkManager::Tick_CheckInviteParty() if( !m_CheckPartyInviteThread->isRunning() ) { delete m_CheckPartyInviteThread; - m_CheckPartyInviteThread = NULL; + m_CheckPartyInviteThread = nullptr; } } - if( m_CheckPartyInviteThread == NULL ) + if( m_CheckPartyInviteThread == nullptr ) { m_inviteReceived = false; m_CheckPartyInviteThread = new C4JThread(&DQRNetworkManager::_CheckInviteThreadProc, this, "Check invite thread"); @@ -1449,7 +1449,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData) for( int j = 0; j < m_roomSyncData.playerCount; j++ ) { tempPlayers.push_back(m_players[j]); - m_players[j] = NULL; + m_players[j] = nullptr; } // For each new player, it's either: @@ -1597,7 +1597,7 @@ void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int ses m_listener->HandlePlayerLeaving(removedPlayers[i]); delete removedPlayers[i]; memset(&m_roomSyncData.players[m_roomSyncData.playerCount + i], 0, sizeof(PlayerSyncData)); - m_players[m_roomSyncData.playerCount + i] = NULL; + m_players[m_roomSyncData.playerCount + i] = nullptr; } LeaveCriticalSection(&m_csRoomSyncData); } @@ -1628,7 +1628,7 @@ void DQRNetworkManager::RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer) m_listener->HandlePlayerLeaving(removedPlayers[i]); delete removedPlayers[i]; memset(&m_roomSyncData.players[m_roomSyncData.playerCount + i], 0, sizeof(PlayerSyncData)); - m_players[m_roomSyncData.playerCount + i] = NULL; + m_players[m_roomSyncData.playerCount + i] = nullptr; } } @@ -1643,7 +1643,7 @@ void DQRNetworkManager::SendRoomSyncInfo() // (2) A single byte internal data tag // (3) An unsigned int encoding the size of the combined size of all the strings in stage (5) // (4) The RoomSyncData structure itself - // (5) A wchar NULL terminated string for every active player to encode the XUID + // (5) A wchar nullptr terminated string for every active player to encode the XUID unsigned int xuidBytes = 0; for( int i = 0 ; i < m_roomSyncData.playerCount; i++ ) { @@ -1689,7 +1689,7 @@ void DQRNetworkManager::SendAddPlayerFailed(Platform::String^ xuid) // (1) 2 byte general header // (2) A single byte internal data tag // (3) An unsigned int encoding the size size of the string - // (5) A wchar NULL terminated string storing the xuid of the player which has failed to join + // (5) A wchar nullptr terminated string storing the xuid of the player which has failed to join unsigned int xuidBytes = sizeof(wchar_t) * ( xuid->Length() + 1 ); @@ -2614,7 +2614,7 @@ void DQRNetworkManager::LeaveRoom() for( int i = 0; i < m_roomSyncData.playerCount; i++ ) { delete m_players[i]; - m_players[i] = NULL; + m_players[i] = nullptr; } memset(&m_roomSyncData, 0, sizeof(m_roomSyncData)); m_displayNames.clear(); diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager.h b/Minecraft.Client/Durango/Network/DQRNetworkManager.h index 5f7b8d908..e0d4d9c76 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager.h +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager.h @@ -221,7 +221,7 @@ class DQRNetworkManager class SessionSearchResult { public: - SessionSearchResult() { m_extData = NULL; } + SessionSearchResult() { m_extData = nullptr; } ~SessionSearchResult() { free(m_extData); } wstring m_partyId; wstring m_sessionName; diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp index 86d37a6e0..0822a93c6 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp @@ -49,7 +49,7 @@ bool DQRNetworkManager::FriendPartyManagerSearch() m_sessionResultCount = 0; delete [] m_sessionSearchResults; - m_sessionSearchResults = NULL; + m_sessionSearchResults = nullptr; m_GetFriendPartyThread = new C4JThread(&_GetFriendsThreadProc,this,"GetFriendsThreadProc"); m_GetFriendPartyThread->Run(); @@ -61,7 +61,7 @@ bool DQRNetworkManager::FriendPartyManagerSearch() void DQRNetworkManager::FriendPartyManagerGetSessionInfo(int idx, SessionSearchResult *searchResult) { assert( idx < m_sessionResultCount ); - assert( ( m_GetFriendPartyThread == NULL ) || ( !m_GetFriendPartyThread->isRunning()) ); + assert( ( m_GetFriendPartyThread == nullptr ) || ( !m_GetFriendPartyThread->isRunning()) ); // Need to make sure that copied data has independently allocated m_extData, so both copies can be freed *searchResult = m_sessionSearchResults[idx]; diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp index 9494683d4..eed3e8511 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp @@ -24,7 +24,7 @@ void DQRNetworkManager::BytesReceived(int smallId, BYTE *bytes, int byteCount) DQRNetworkPlayer *host = GetPlayerBySmallId(m_hostSmallId); DQRNetworkPlayer *client = GetPlayerBySmallId(smallId); - if( ( host == NULL ) || ( client == NULL ) ) + if( ( host == nullptr ) || ( client == nullptr ) ) { return; } @@ -238,7 +238,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, UpdateRoomSyncPlayers((RoomSyncData *)connectionInfo->m_pucRoomSyncData); delete connectionInfo->m_pucRoomSyncData; - connectionInfo->m_pucRoomSyncData = NULL; + connectionInfo->m_pucRoomSyncData = nullptr; connectionInfo->m_internalDataState = DQRConnectionInfo::ConnectionState_InternalHeaderByte; // If we haven't actually established a connection yet for this channel, then this is the point where we can consider this active @@ -267,7 +267,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, { if( m_currentUserMask & ( 1 << i ) ) { - if( GetLocalPlayerByUserIndex(i) == NULL ) + if( GetLocalPlayerByUserIndex(i) == nullptr ) { allLocalPlayersHere = false; } @@ -307,7 +307,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo, // XUID fully read, can now handle what to do with it AddPlayerFailed(ref new Platform::String( (wchar_t *)connectionInfo->m_pucAddFailedPlayerData ) ); delete [] connectionInfo->m_pucAddFailedPlayerData; - connectionInfo->m_pucAddFailedPlayerData = NULL; + connectionInfo->m_pucAddFailedPlayerData = nullptr; connectionInfo->m_internalDataState = DQRConnectionInfo::ConnectionState_InternalHeaderByte; } diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp index 29daa23e6..ae7094fb3 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp @@ -603,7 +603,7 @@ void DQRNetworkManager::RTS_StartCient() EnterCriticalSection(&m_csRTSMessageQueueOutgoing); RTS_Message message; message.m_eType = eRTSMessageType::RTS_MESSAGE_START_CLIENT; - message.m_pucData = NULL; + message.m_pucData = nullptr; message.m_dataSize = 0; m_RTSMessageQueueOutgoing.push(message); LeaveCriticalSection(&m_csRTSMessageQueueOutgoing); @@ -614,7 +614,7 @@ void DQRNetworkManager::RTS_StartHost() EnterCriticalSection(&m_csRTSMessageQueueOutgoing); RTS_Message message; message.m_eType = eRTSMessageType::RTS_MESSAGE_START_HOST; - message.m_pucData = NULL; + message.m_pucData = nullptr; message.m_dataSize = 0; m_RTSMessageQueueOutgoing.push(message); LeaveCriticalSection(&m_csRTSMessageQueueOutgoing); @@ -625,7 +625,7 @@ void DQRNetworkManager::RTS_Terminate() EnterCriticalSection(&m_csRTSMessageQueueOutgoing); RTS_Message message; message.m_eType = eRTSMessageType::RTS_MESSAGE_TERMINATE; - message.m_pucData = NULL; + message.m_pucData = nullptr; message.m_dataSize = 0; m_RTSMessageQueueOutgoing.push(message); LeaveCriticalSection(&m_csRTSMessageQueueOutgoing); diff --git a/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp b/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp index bfb3c9a84..84a34a97e 100644 --- a/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp +++ b/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp @@ -4,7 +4,7 @@ NetworkPlayerDurango::NetworkPlayerDurango(DQRNetworkPlayer *qnetPlayer) { m_dqrPlayer = qnetPlayer; - m_pSocket = NULL; + m_pSocket = nullptr; } unsigned char NetworkPlayerDurango::GetSmallId() diff --git a/Minecraft.Client/Durango/Network/PartyController.cpp b/Minecraft.Client/Durango/Network/PartyController.cpp index 4e1a7e611..1dfd5eb0a 100644 --- a/Minecraft.Client/Durango/Network/PartyController.cpp +++ b/Minecraft.Client/Durango/Network/PartyController.cpp @@ -181,7 +181,7 @@ bool PartyController::AddLocalUsersToParty(int userMask, Windows::Xbox::System:: bool alreadyInSession = false; if( session ) { - if( m_pDQRNet->IsPlayerInSession( ProfileManager.GetUser(i, true)->XboxUserId, session, NULL ) ) + if( m_pDQRNet->IsPlayerInSession( ProfileManager.GetUser(i, true)->XboxUserId, session, nullptr ) ) { alreadyInSession = true; } @@ -621,7 +621,7 @@ void PartyController::AddAvailableGamePlayers(IVectorView^ availabl } #endif - if( m_pDQRNet->IsPlayerInSession(player->XboxUserId, currentSession, NULL)) + if( m_pDQRNet->IsPlayerInSession(player->XboxUserId, currentSession, nullptr)) { DQRNetworkManager::LogComment( L"Player is already in session; skipping join request: " + player->XboxUserId->ToString() ); continue; @@ -639,7 +639,7 @@ void PartyController::AddAvailableGamePlayers(IVectorView^ availabl { bFoundLocal = true; // Check that they aren't in the game already (don't see how this could be the case anyway) - if( m_pDQRNet->GetPlayerByXuid( static_cast(player->XboxUserId->Data()) ) == NULL ) + if( m_pDQRNet->GetPlayerByXuid( static_cast(player->XboxUserId->Data()) ) == nullptr ) { // And check whether they are signed in yet or not int userIdx = -1; @@ -838,7 +838,7 @@ void PartyController::OnGameSessionReady( GameSessionReadyEventArgs^ eventArgs ) if( !isAJoiningXuid ) // Isn't someone we are actively trying to join { if( (!bInSession) || // If not in a game session at all - ( ( m_pDQRNet->GetState() == DQRNetworkManager::DNM_INT_STATE_PLAYING ) && ( m_pDQRNet->GetPlayerByXuid( static_cast(memberXUID->Data()) ) == NULL ) ) // Or we're fully in, and this player isn't in it + ( ( m_pDQRNet->GetState() == DQRNetworkManager::DNM_INT_STATE_PLAYING ) && ( m_pDQRNet->GetPlayerByXuid( static_cast(memberXUID->Data()) ) == nullptr ) ) // Or we're fully in, and this player isn't in it ) { for( int j = 4; j < 12; j++ ) // Final check that we have a gamepad for this xuid so that we might possibly be able to pair someone up diff --git a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp index 7171895a1..5e3a08245 100644 --- a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp +++ b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp @@ -166,7 +166,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, false ); } @@ -175,7 +175,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -198,7 +198,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP { // Get our wrapper object associated with this player. Socket *socket = networkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { // If we are in game then remove this player from the game as well. // We may get here either from the player requesting to exit the game, @@ -214,14 +214,14 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP // We need this as long as the game server still needs to communicate with the player //delete socket; - networkPlayer->SetSocket( NULL ); + networkPlayer->SetSocket( nullptr ); } if( m_pDQRNet->IsHost() && !m_bHostChanged ) { if( isSystemPrimaryPlayer(pDQRPlayer) ) { - DQRNetworkPlayer *pNewDQRPrimaryPlayer = NULL; + DQRNetworkPlayer *pNewDQRPrimaryPlayer = nullptr; for(unsigned int i = 0; i < m_pDQRNet->GetPlayerCount(); ++i ) { DQRNetworkPlayer *pDQRPlayer2 = m_pDQRNet->GetPlayerByIndex( i ); @@ -238,7 +238,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP m_machineDQRPrimaryPlayers.erase( it ); } - if( pNewDQRPrimaryPlayer != NULL ) + if( pNewDQRPrimaryPlayer != nullptr ) m_machineDQRPrimaryPlayers.push_back( pNewDQRPrimaryPlayer ); } @@ -251,7 +251,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, true ); } @@ -260,7 +260,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -289,7 +289,7 @@ void CPlatformNetworkManagerDurango::HandleDataReceived(DQRNetworkPlayer *player INetworkPlayer *pPlayerFrom = getNetworkPlayer(playerFrom); Socket *socket = pPlayerFrom->GetSocket(); - if(socket != NULL) + if(socket != nullptr) socket->pushDataToQueue(data, dataSize, false); } else @@ -298,7 +298,7 @@ void CPlatformNetworkManagerDurango::HandleDataReceived(DQRNetworkPlayer *player INetworkPlayer *pPlayerTo = getNetworkPlayer(playerTo); Socket *socket = pPlayerTo->GetSocket(); //app.DebugPrintf( "Pushing data into read queue for user \"%ls\"\n", apPlayersTo[dwPlayer]->GetGamertag()); - if(socket != NULL) + if(socket != nullptr) socket->pushDataToQueue(data, dataSize); } } @@ -319,7 +319,7 @@ bool CPlatformNetworkManagerDurango::Initialise(CGameNetworkManager *pGameNetwor g_pPlatformNetworkManager = this; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - playerChangedCallback[ i ] = NULL; + playerChangedCallback[ i ] = nullptr; } m_bLeavingGame = false; @@ -330,14 +330,14 @@ bool CPlatformNetworkManagerDurango::Initialise(CGameNetworkManager *pGameNetwor m_bSearchPending = false; m_bIsOfflineGame = false; - m_pSearchParam = NULL; - m_SessionsUpdatedCallback = NULL; + m_pSearchParam = nullptr; + m_SessionsUpdatedCallback = nullptr; m_searchResultsCount = 0; m_lastSearchStartTime = 0; // The results that will be filled in with the current search - m_pSearchResults = NULL; + m_pSearchResults = nullptr; Windows::Networking::Connectivity::NetworkInformation::NetworkStatusChanged += ref new Windows::Networking::Connectivity::NetworkStatusChangedEventHandler( []( Platform::Object^ pxObject ) { @@ -585,8 +585,8 @@ void CPlatformNetworkManagerDurango::UnRegisterPlayerChangedCallback(int iPad, v { if(playerChangedCallbackParam[iPad] == callbackParam) { - playerChangedCallback[iPad] = NULL; - playerChangedCallbackParam[iPad] = NULL; + playerChangedCallback[iPad] = nullptr; + playerChangedCallbackParam[iPad] = nullptr; } } @@ -613,12 +613,12 @@ bool CPlatformNetworkManagerDurango::_RunNetworkGame() return true; } -void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/) +void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= nullptr*/) { if( this->m_bLeavingGame ) return; - if( GetHostPlayer() == NULL ) + if( GetHostPlayer() == nullptr ) return; m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All); @@ -632,14 +632,14 @@ int CPlatformNetworkManagerDurango::RemovePlayerOnSocketClosedThreadProc( void* Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { //printf("Waiting for socket closed event\n"); socket->m_socketClosedEvent->WaitForSignal(INFINITE); //printf("Socket closed event has fired\n"); // 4J Stu - Clear our reference to this socket - pNetworkPlayer->SetSocket( NULL ); + pNetworkPlayer->SetSocket( nullptr ); delete socket; } @@ -712,7 +712,7 @@ void CPlatformNetworkManagerDurango::SystemFlagReset() void CPlatformNetworkManagerDurango::SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return; - if( pNetworkPlayer == NULL ) return; + if( pNetworkPlayer == nullptr ) return; for( unsigned int i = 0; i < m_playerFlags.size(); i++ ) { @@ -728,7 +728,7 @@ void CPlatformNetworkManagerDurango::SystemFlagSet(INetworkPlayer *pNetworkPlaye bool CPlatformNetworkManagerDurango::SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return false; - if( pNetworkPlayer == NULL ) + if( pNetworkPlayer == nullptr ) { return false; } @@ -769,7 +769,7 @@ void CPlatformNetworkManagerDurango::TickSearch() } m_bSearchPending = false; - if( m_SessionsUpdatedCallback != NULL ) m_SessionsUpdatedCallback(m_pSearchParam); + if( m_SessionsUpdatedCallback != nullptr ) m_SessionsUpdatedCallback(m_pSearchParam); } } else @@ -777,7 +777,7 @@ void CPlatformNetworkManagerDurango::TickSearch() if( !m_pDQRNet->FriendPartyManagerIsBusy() ) { // Don't start searches unless we have registered a callback - if( m_SessionsUpdatedCallback != NULL && (m_lastSearchStartTime + MINECRAFT_DURANGO_PARTY_SEARCH_DELAY_MILLISECONDS) < GetTickCount() ) + if( m_SessionsUpdatedCallback != nullptr && (m_lastSearchStartTime + MINECRAFT_DURANGO_PARTY_SEARCH_DELAY_MILLISECONDS) < GetTickCount() ) { if( m_pDQRNet->FriendPartyManagerSearch() ); { @@ -800,7 +800,7 @@ vector *CPlatformNetworkManagerDurango::GetSessionList(int { FriendSessionInfo *session = new FriendSessionInfo(); session->searchResult = m_pSearchResults[i]; - session->searchResult.m_extData = NULL; // We have another copy of the GameSessionData, so don't need to make another copy of this here + session->searchResult.m_extData = nullptr; // We have another copy of the GameSessionData, so don't need to make another copy of this here session->displayLabelLength = session->searchResult.m_playerNames[0].size(); session->displayLabel = new wchar_t[ session->displayLabelLength + 1 ]; memcpy(&session->data, gameSessionData, sizeof(GameSessionData)); @@ -832,7 +832,7 @@ void CPlatformNetworkManagerDurango::ForceFriendsSessionRefresh() m_lastSearchStartTime = 0; m_searchResultsCount = 0; delete [] m_pSearchResults; - m_pSearchResults = NULL; + m_pSearchResults = nullptr; } INetworkPlayer *CPlatformNetworkManagerDurango::addNetworkPlayer(DQRNetworkPlayer *pDQRPlayer) @@ -858,7 +858,7 @@ void CPlatformNetworkManagerDurango::removeNetworkPlayer(DQRNetworkPlayer *pDQRP INetworkPlayer *CPlatformNetworkManagerDurango::getNetworkPlayer(DQRNetworkPlayer *pDQRPlayer) { - return pDQRPlayer ? (INetworkPlayer *)(pDQRPlayer->GetCustomDataValue()) : NULL; + return pDQRPlayer ? (INetworkPlayer *)(pDQRPlayer->GetCustomDataValue()) : nullptr; } diff --git a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h index 558072275..5626b0120 100644 --- a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h +++ b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h @@ -87,7 +87,7 @@ class CPlatformNetworkManagerDurango : public CPlatformNetworkManager, IDQRNetwo bool m_hostGameSessionIsJoinable; CGameNetworkManager *m_pGameNetworkManager; public: - virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL); + virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr); private: // TODO 4J Stu - Do we need to be able to have more than one of these? diff --git a/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp b/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp index 25ca46b28..31ab9d64b 100644 --- a/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp +++ b/Minecraft.Client/Durango/Sentient/DurangoTelemetry.cpp @@ -64,7 +64,7 @@ bool CDurangoTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus) // 4J-JEV: Still needed to flush cached travel stats. DurangoStats::playerSessionEnd(iPad); - if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL) + if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr) { ULONG hr = EventWritePlayerSessionEnd( DurangoStats::getUserId(iPad), @@ -131,7 +131,7 @@ bool CDurangoTelemetryManager::RecordLevelStart(int iPad, ESen_FriendOrMatch fri ProfileManager.GetXUID(iPad, &puid, true); plr = Minecraft::GetInstance()->localplayers[iPad]; - if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL) + if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr) { hr = EventWritePlayerSessionStart( DurangoStats::getUserId(iPad), diff --git a/Minecraft.Client/Durango/ServiceConfig/Events-XBLA.8-149E11AEEvents.h b/Minecraft.Client/Durango/ServiceConfig/Events-XBLA.8-149E11AEEvents.h index 5fc804385..8bd113549 100644 --- a/Minecraft.Client/Durango/ServiceConfig/Events-XBLA.8-149E11AEEvents.h +++ b/Minecraft.Client/Durango/ServiceConfig/Events-XBLA.8-149E11AEEvents.h @@ -195,7 +195,7 @@ EventWriteAchievementGet(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, _ EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &AchievementId, sizeof(AchievementId)); @@ -216,7 +216,7 @@ EventWriteAchievemntUnlocked(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionI EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -246,7 +246,7 @@ EventWriteBanLevel(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in co EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -274,7 +274,7 @@ EventWriteBlockBroken(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &BlockId, sizeof(BlockId)); @@ -298,7 +298,7 @@ EventWriteBlockPlaced(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &BlockId, sizeof(BlockId)); @@ -322,7 +322,7 @@ EventWriteChestfulOfCobblestone(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessi EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &Cobblecount, sizeof(Cobblecount)); @@ -343,7 +343,7 @@ EventWriteEnteredNewBiome(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &BiomeId, sizeof(BiomeId)); @@ -364,7 +364,7 @@ EventWriteGameProgress(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __i EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &CompletionPercent, sizeof(CompletionPercent)); @@ -385,7 +385,7 @@ EventWriteIncDistanceTravelled(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessio EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &Distance, sizeof(Distance)); @@ -408,7 +408,7 @@ EventWriteIncTimePlayed(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __ EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &TimePlayed, sizeof(TimePlayed)); @@ -430,7 +430,7 @@ EventWriteLeaderboardTotals(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[4], &LeaderboardId, sizeof(LeaderboardId)); @@ -453,7 +453,7 @@ EventWriteLevelExit(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in c EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -482,7 +482,7 @@ EventWriteLevelResume(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -516,7 +516,7 @@ EventWriteLevelSaveOrCheckpoint(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessi EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -546,7 +546,7 @@ EventWriteLevelStart(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -579,10 +579,10 @@ EventWriteMcItemAcquired(__in_opt PCWSTR UserId, __in const signed int SectionId EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[3], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[5], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[6], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[7], &ItemId, sizeof(ItemId)); @@ -610,10 +610,10 @@ EventWriteMcItemUsed(__in_opt PCWSTR UserId, __in const signed int SectionId, __ EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[3], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[5], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[6], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[7], &ItemId, sizeof(ItemId)); @@ -641,7 +641,7 @@ EventWriteMenuShown(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in c EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -671,7 +671,7 @@ EventWriteMobInteract(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &MobId, sizeof(MobId)); EventDataDescCreate(&EventData[4], &InteractionId, sizeof(InteractionId)); @@ -693,10 +693,10 @@ EventWriteMobKilled(__in_opt PCWSTR UserId, __in const signed int SectionId, __i EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[3], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[4], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[5], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[6], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[7], RoundId, sizeof(GUID)); @@ -728,11 +728,11 @@ EventWriteMultiplayerRoundEnd(__in_opt PCWSTR UserId, __in LPCGUID RoundId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], RoundId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[4], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[5], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[5], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[6], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[7], &MatchTypeId, sizeof(MatchTypeId)); EventDataDescCreate(&EventData[8], &DifficultyLevelId, sizeof(DifficultyLevelId)); @@ -756,11 +756,11 @@ EventWriteMultiplayerRoundStart(__in_opt PCWSTR UserId, __in LPCGUID RoundId, __ EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], RoundId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SectionId, sizeof(SectionId)); EventDataDescCreate(&EventData[4], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[5], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[5], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[6], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[7], &MatchTypeId, sizeof(MatchTypeId)); EventDataDescCreate(&EventData[8], &DifficultyLevelId, sizeof(DifficultyLevelId)); @@ -782,7 +782,7 @@ EventWriteOnARail(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in con EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &Distance, sizeof(Distance)); @@ -803,7 +803,7 @@ EventWriteOverkill(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in co EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &Damage, sizeof(Damage)); @@ -824,7 +824,7 @@ EventWritePauseOrInactive(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -852,7 +852,7 @@ EventWritePlayedMusicDisc(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &DiscId, sizeof(DiscId)); @@ -873,7 +873,7 @@ EventWritePlayerDiedOrFailed(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionI EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -908,9 +908,9 @@ EventWritePlayerSessionEnd(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[4], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[5], &DifficultyLevelId, sizeof(DifficultyLevelId)); EventDataDescCreate(&EventData[6], &ExitStatusId, sizeof(ExitStatusId)); @@ -932,9 +932,9 @@ EventWritePlayerSessionPause(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionI EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); return EtxEventWrite(&XBLA_149E11AEEvents[28], &XBLA_149E11AEProvider, XBLA_149E11AEHandle, ARGUMENT_COUNT_XBLA_149E11AE_PlayerSessionPause, EventData); } @@ -953,9 +953,9 @@ EventWritePlayerSessionResume(__in_opt PCWSTR UserId, __in LPCGUID PlayerSession EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[4], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[5], &DifficultyLevelId, sizeof(DifficultyLevelId)); @@ -976,9 +976,9 @@ EventWritePlayerSessionStart(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionI EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); - EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != NULL) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != NULL) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[3], (MultiplayerCorrelationId != nullptr) ? MultiplayerCorrelationId : L"", (MultiplayerCorrelationId != nullptr) ? (ULONG)((wcslen(MultiplayerCorrelationId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[4], &GameplayModeId, sizeof(GameplayModeId)); EventDataDescCreate(&EventData[5], &DifficultyLevelId, sizeof(DifficultyLevelId)); @@ -999,7 +999,7 @@ EventWriteRecordMediaShareUpload(__in_opt PCWSTR UserId, __in LPCGUID PlayerSess EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1027,7 +1027,7 @@ EventWriteRichPresenceState(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &ContextID, sizeof(ContextID)); @@ -1048,7 +1048,7 @@ EventWriteSkinChanged(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1077,7 +1077,7 @@ EventWriteTexturePackLoaded(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1107,7 +1107,7 @@ EventWriteUnbanLevel(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1135,7 +1135,7 @@ EventWriteUnpauseOrActive(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1163,7 +1163,7 @@ EventWriteUpsellPresented(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); @@ -1193,7 +1193,7 @@ EventWriteUpsellResponded(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, EtxFillCommonFields_v7(&EventData[0], scratch, 64); - EventDataDescCreate(&EventData[1], (UserId != NULL) ? UserId : L"", (UserId != NULL) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); + EventDataDescCreate(&EventData[1], (UserId != nullptr) ? UserId : L"", (UserId != nullptr) ? (ULONG)((wcslen(UserId) + 1) * sizeof(WCHAR)) : (ULONG)sizeof(L"")); EventDataDescCreate(&EventData[2], PlayerSessionId, sizeof(GUID)); EventDataDescCreate(&EventData[3], &SecondsSinceInitialize, sizeof(SecondsSinceInitialize)); EventDataDescCreate(&EventData[4], &Mode, sizeof(Mode)); diff --git a/Minecraft.Client/Durango/XML/ATGXmlParser.cpp b/Minecraft.Client/Durango/XML/ATGXmlParser.cpp index dea8c1859..581ea27ec 100644 --- a/Minecraft.Client/Durango/XML/ATGXmlParser.cpp +++ b/Minecraft.Client/Durango/XML/ATGXmlParser.cpp @@ -27,7 +27,7 @@ XMLParser::XMLParser() { m_pWritePtr = m_pWriteBuf; m_pReadPtr = m_pReadBuf; - m_pISAXCallback = NULL; + m_pISAXCallback = nullptr; m_hFile = INVALID_HANDLE_VALUE; } @@ -49,7 +49,7 @@ VOID XMLParser::FillBuffer() m_pReadPtr = m_pReadBuf; - if( m_hFile == NULL ) + if( m_hFile == nullptr ) { if( m_uInXMLBufferCharsLeft > XML_READ_BUFFER_SIZE ) NChars = XML_READ_BUFFER_SIZE; @@ -62,7 +62,7 @@ VOID XMLParser::FillBuffer() } else { - if( !ReadFile( m_hFile, m_pReadBuf, XML_READ_BUFFER_SIZE, &NChars, NULL )) + if( !ReadFile( m_hFile, m_pReadBuf, XML_READ_BUFFER_SIZE, &NChars, nullptr )) { return; } @@ -359,7 +359,7 @@ HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail ) // Read more from the file FillBuffer(); - // We are at EOF if it is still NULL + // We are at EOF if it is still nullptr if ( ( m_pReadPtr[0] == '\0' ) && ( m_pReadPtr[1] == '\0' ) ) { if( !bOkToFail ) @@ -861,7 +861,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) { HRESULT hr; - if( m_pISAXCallback == NULL ) + if( m_pISAXCallback == nullptr ) return E_NOINTERFACE; m_pISAXCallback->m_LineNum = 1; @@ -874,14 +874,14 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) m_pReadBuf[ 0 ] = '\0'; m_pReadBuf[ 1 ] = '\0'; - m_pInXMLBuffer = NULL; + m_pInXMLBuffer = nullptr; m_uInXMLBufferCharsLeft = 0; WCHAR wchFilename[ 64 ]; swprintf_s(wchFilename,64,L"%s",strFilename); - m_hFile = CreateFile( wchFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL ); + m_hFile = CreateFile( wchFilename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr ); if( m_hFile == INVALID_HANDLE_VALUE ) { @@ -904,7 +904,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) m_hFile = INVALID_HANDLE_VALUE; // we no longer own strFilename, so un-set it - m_pISAXCallback->m_strFilename = NULL; + m_pISAXCallback->m_strFilename = nullptr; return hr; } @@ -917,7 +917,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) { HRESULT hr; - if( m_pISAXCallback == NULL ) + if( m_pISAXCallback == nullptr ) return E_NOINTERFACE; m_pISAXCallback->m_LineNum = 1; @@ -930,7 +930,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) m_pReadBuf[ 0 ] = '\0'; m_pReadBuf[ 1 ] = '\0'; - m_hFile = NULL; + m_hFile = nullptr; m_pInXMLBuffer = strBuffer; m_uInXMLBufferCharsLeft = uBufferSize; m_dwCharsTotal = uBufferSize; @@ -939,7 +939,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) hr = MainParseLoop(); // we no longer own strFilename, so un-set it - m_pISAXCallback->m_strFilename = NULL; + m_pISAXCallback->m_strFilename = nullptr; return hr; } diff --git a/Minecraft.Client/Durango/XML/ATGXmlParser.h b/Minecraft.Client/Durango/XML/ATGXmlParser.h index 75142e3e3..12f597372 100644 --- a/Minecraft.Client/Durango/XML/ATGXmlParser.h +++ b/Minecraft.Client/Durango/XML/ATGXmlParser.h @@ -138,7 +138,7 @@ class XMLParser DWORD m_dwCharsTotal; DWORD m_dwCharsConsumed; - BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing NULL + BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing nullptr WCHAR m_pWriteBuf[ XML_WRITE_BUFFER_SIZE ]; BYTE* m_pReadPtr; diff --git a/Minecraft.Client/Durango/XML/xmlFilesCallback.h b/Minecraft.Client/Durango/XML/xmlFilesCallback.h index deba843d6..161493404 100644 --- a/Minecraft.Client/Durango/XML/xmlFilesCallback.h +++ b/Minecraft.Client/Durango/XML/xmlFilesCallback.h @@ -47,7 +47,7 @@ class xmlMojangCallback : public ATG::ISAXCallback { ZeroMemory(wTemp,sizeof(WCHAR)*35); wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); - xuid=_wcstoui64(wTemp,NULL,10); + xuid=_wcstoui64(wTemp,nullptr,10); } } else if (_wcsicmp(wAttName,L"cape")==0) @@ -138,7 +138,7 @@ class xmlConfigCallback : public ATG::ISAXCallback #ifdef _XBOX iValue=_wtoi(wValue); #else - iValue=wcstol(wValue, NULL, 10); + iValue=wcstol(wValue, nullptr, 10); #endif } } @@ -220,7 +220,7 @@ class xmlDLCInfoCallback : public ATG::ISAXCallback { ZeroMemory(wTemp,sizeof(WCHAR)*35); wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); - uiSortIndex=wcstoul(wTemp,NULL,10); + uiSortIndex=wcstoul(wTemp,nullptr,10); } } else if (_wcsicmp(wAttName,L"Banner")==0) @@ -269,7 +269,7 @@ class xmlDLCInfoCallback : public ATG::ISAXCallback #ifdef _XBOX iConfig=_wtoi(wConfig); #else - iConfig=wcstol(wConfig, NULL, 10); + iConfig=wcstol(wConfig, nullptr, 10); #endif } } diff --git a/Minecraft.Client/EnderDragonRenderer.cpp b/Minecraft.Client/EnderDragonRenderer.cpp index a0d66cb3e..8b5b248c2 100644 --- a/Minecraft.Client/EnderDragonRenderer.cpp +++ b/Minecraft.Client/EnderDragonRenderer.cpp @@ -90,7 +90,7 @@ void EnderDragonRenderer::render(shared_ptr _mob, double x, double y, do shared_ptr mob = dynamic_pointer_cast(_mob); BossMobGuiInfo::setBossHealth(mob, false); MobRenderer::render(mob, x, y, z, rot, a); - if (mob->nearestCrystal != NULL) + if (mob->nearestCrystal != nullptr) { float tt = mob->nearestCrystal->time + a; float hh = sin(tt * 0.2f) / 2 + 0.5f; diff --git a/Minecraft.Client/EntityRenderDispatcher.cpp b/Minecraft.Client/EntityRenderDispatcher.cpp index abfc2993e..cc14558f9 100644 --- a/Minecraft.Client/EntityRenderDispatcher.cpp +++ b/Minecraft.Client/EntityRenderDispatcher.cpp @@ -87,7 +87,7 @@ double EntityRenderDispatcher::xOff = 0.0; double EntityRenderDispatcher::yOff = 0.0; double EntityRenderDispatcher::zOff = 0.0; -EntityRenderDispatcher *EntityRenderDispatcher::instance = NULL; +EntityRenderDispatcher *EntityRenderDispatcher::instance = nullptr; void EntityRenderDispatcher::staticCtor() { @@ -280,7 +280,7 @@ void EntityRenderDispatcher::render(shared_ptr entity, float a) void EntityRenderDispatcher::render(shared_ptr entity, double x, double y, double z, float rot, float a, bool bItemFrame, bool bRenderPlayerShadow) { EntityRenderer *renderer = getRenderer(entity); - if (renderer != NULL) + if (renderer != nullptr) { renderer->SetItemFrame(bItemFrame); diff --git a/Minecraft.Client/EntityRenderer.cpp b/Minecraft.Client/EntityRenderer.cpp index 4ead9f4a9..fa41dfa60 100644 --- a/Minecraft.Client/EntityRenderer.cpp +++ b/Minecraft.Client/EntityRenderer.cpp @@ -18,7 +18,7 @@ ResourceLocation EntityRenderer::SHADOW_LOCATION = ResourceLocation(TN__CLAMP__M // 4J - added EntityRenderer::EntityRenderer() { - model = NULL; + model = nullptr; tileRenderer = new TileRenderer(); shadowRadius = 0; shadowStrength = 1.0f; @@ -113,7 +113,7 @@ void EntityRenderer::renderFlame(shared_ptr e, double x, double y, doubl t->begin(); while (h > 0) { - Icon *tex = NULL; + Icon *tex = nullptr; if (ss % 2 == 0) { tex = fire1; @@ -406,5 +406,5 @@ void EntityRenderer::registerTerrainTextures(IconRegister *iconRegister) ResourceLocation *EntityRenderer::getTextureLocation(shared_ptr mob) { - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.Client/EntityTracker.cpp b/Minecraft.Client/EntityTracker.cpp index db175542e..8171e50d4 100644 --- a/Minecraft.Client/EntityTracker.cpp +++ b/Minecraft.Client/EntityTracker.cpp @@ -59,7 +59,7 @@ void EntityTracker::addEntity(shared_ptr e) else if (e->instanceof(eTYPE_SQUID)) addEntity(e, 16 * 4, 1, true); else if (e->instanceof(eTYPE_WITHERBOSS)) addEntity(e, 16 * 5, 1, false); else if (e->instanceof(eTYPE_BAT)) addEntity(e, 16 * 5, 1, false); - else if (dynamic_pointer_cast(e)!=NULL) addEntity(e, 16 * 5, 1, true); + else if (dynamic_pointer_cast(e)!=nullptr) addEntity(e, 16 * 5, 1, true); else if (e->instanceof(eTYPE_ENDERDRAGON)) addEntity(e, 16 * 10, 1, true); else if (e->instanceof(eTYPE_PRIMEDTNT)) addEntity(e, 16 * 10, 10, true); else if (e->instanceof(eTYPE_FALLINGTILE)) addEntity(e, 16 * 10, 20, true); @@ -145,9 +145,9 @@ void EntityTracker::tick() shared_ptr ep = server->getPlayers()->players[i]; if( ep->dimension != level->dimension->id ) continue; - if( ep->connection == NULL ) continue; + if( ep->connection == nullptr ) continue; INetworkPlayer *thisPlayer = ep->connection->getNetworkPlayer(); - if( thisPlayer == NULL ) continue; + if( thisPlayer == nullptr ) continue; bool addPlayer = false; for (unsigned int j = 0; j < movedPlayers.size(); j++) @@ -156,9 +156,9 @@ void EntityTracker::tick() if( sp == ep ) break; - if(sp->connection == NULL) continue; + if(sp->connection == nullptr) continue; INetworkPlayer *otherPlayer = sp->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { addPlayer = true; break; @@ -170,7 +170,7 @@ void EntityTracker::tick() for (unsigned int i = 0; i < movedPlayers.size(); i++) { shared_ptr player = movedPlayers[i]; - if(player->connection == NULL) continue; + if(player->connection == nullptr) continue; for( auto& te : entities ) { if ( te && te->e != player) diff --git a/Minecraft.Client/Extrax64Stubs.cpp b/Minecraft.Client/Extrax64Stubs.cpp index 984397b8c..b03efe86c 100644 --- a/Minecraft.Client/Extrax64Stubs.cpp +++ b/Minecraft.Client/Extrax64Stubs.cpp @@ -58,7 +58,7 @@ bool CSocialManager::IsTitleAllowedToPostImages() { return false; } bool CSocialManager::PostLinkToSocialNetwork(ESocialNetwork eSocialNetwork, DWORD dwUserIndex, bool bUsingKinect) { return false; } bool CSocialManager::PostImageToSocialNetwork(ESocialNetwork eSocialNetwork, DWORD dwUserIndex, bool bUsingKinect) { return false; } -CSocialManager* CSocialManager::Instance() { return NULL; } +CSocialManager* CSocialManager::Instance() { return nullptr; } void CSocialManager::SetSocialPostText(LPCWSTR Title, LPCWSTR Caption, LPCWSTR Desc) {}; DWORD XShowPartyUI(DWORD dwUserIndex) { return 0; } @@ -159,7 +159,7 @@ void PIXSetMarkerDeprecated(int a, char* b, ...) {} //} #endif -// void *D3DXBUFFER::GetBufferPointer() { return NULL; } +// void *D3DXBUFFER::GetBufferPointer() { return nullptr; } // int D3DXBUFFER::GetBufferSize() { return 0; } // void D3DXBUFFER::Release() {} @@ -253,16 +253,16 @@ IQNetPlayer* IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex) !m_player[dwUserIndex].m_isRemote && Win64_IsActivePlayer(&m_player[dwUserIndex], dwUserIndex)) return &m_player[dwUserIndex]; - return NULL; + return nullptr; } if (dwUserIndex != 0) - return NULL; + return nullptr; for (DWORD i = 0; i < s_playerCount; i++) { if (!m_player[i].m_isRemote && Win64_IsActivePlayer(&m_player[i], i)) return &m_player[i]; } - return NULL; + return nullptr; } static bool Win64_IsActivePlayer(IQNetPlayer * p, DWORD index) { @@ -289,7 +289,7 @@ IQNetPlayer* IQNet::GetPlayerBySmallId(BYTE SmallId) { if (m_player[i].m_smallId == SmallId && Win64_IsActivePlayer(&m_player[i], i)) return &m_player[i]; } - return NULL; + return nullptr; } IQNetPlayer* IQNet::GetPlayerByXuid(PlayerUID xuid) { @@ -301,7 +301,7 @@ IQNetPlayer* IQNet::GetPlayerByXuid(PlayerUID xuid) if (m_player[i].GetXuid() == xuid) return &m_player[i]; } - // Keep existing stub behavior: return host slot instead of NULL on miss. + // Keep existing stub behavior: return host slot instead of nullptr on miss. return &m_player[0]; } DWORD IQNet::GetPlayerCount() @@ -453,11 +453,11 @@ HRESULT XMemCreateCompressionContext( ) { /* - COMPRESSOR_HANDLE Compressor = NULL; + COMPRESSOR_HANDLE Compressor = nullptr; HRESULT hr = CreateCompressor( COMPRESS_ALGORITHM_XPRESS_HUFF, // Compression Algorithm - NULL, // Optional allocation routine + nullptr, // Optional allocation routine &Compressor); // Handle pContext = (XMEMDECOMPRESSION_CONTEXT *)Compressor; @@ -474,11 +474,11 @@ HRESULT XMemCreateDecompressionContext( ) { /* - DECOMPRESSOR_HANDLE Decompressor = NULL; + DECOMPRESSOR_HANDLE Decompressor = nullptr; HRESULT hr = CreateDecompressor( COMPRESS_ALGORITHM_XPRESS_HUFF, // Compression Algorithm - NULL, // Optional allocation routine + nullptr, // Optional allocation routine &Decompressor); // Handle pContext = (XMEMDECOMPRESSION_CONTEXT *)Decompressor; @@ -645,8 +645,8 @@ bool C_4JProfile::LocaleIsUSorCanada(void) { return false; } HRESULT C_4JProfile::GetLiveConnectionStatus() { return S_OK; } bool C_4JProfile::IsSystemUIDisplayed() { return false; } void C_4JProfile::SetProfileReadErrorCallback(void (*Func)(LPVOID), LPVOID lpParam) {} -int(*defaultOptionsCallback)(LPVOID, C_4JProfile::PROFILESETTINGS*, const int iPad) = NULL; -LPVOID lpProfileParam = NULL; +int(*defaultOptionsCallback)(LPVOID, C_4JProfile::PROFILESETTINGS*, const int iPad) = nullptr; +LPVOID lpProfileParam = nullptr; int C_4JProfile::SetDefaultOptionsCallback(int(*Func)(LPVOID, PROFILESETTINGS*, const int iPad), LPVOID lpParam) { defaultOptionsCallback = Func; @@ -724,7 +724,7 @@ void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, XCONTENT_DATA & xCont void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, PBYTE * ppbImageData, DWORD * pdwImageBytes) {} C4JStorage::ESaveGameState C4JStorage::LoadSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam) { return C4JStorage::ESaveGame_Idle; } C4JStorage::EDeleteGameStatus C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool), LPVOID lpParam) { return C4JStorage::EDeleteGame_Idle; } -PSAVE_DETAILS C4JStorage::ReturnSavesInfo() { return NULL; } +PSAVE_DETAILS C4JStorage::ReturnSavesInfo() { return nullptr; } void C4JStorage::RegisterMarketplaceCountsCallback(int (*Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS*, int), LPVOID lpParam) {} void C4JStorage::SetDLCPackageRoot(char* pszDLCRoot) {} @@ -746,7 +746,7 @@ void C4JStorage::StoreTMSPathName(WCHAR * pwchName) {} unsigned int C4JStorage::CRC(unsigned char* buf, int len) { return 0; } struct PTMSPP_FILEDATA; -C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename, int(*Func)(LPVOID, int, int, PTMSPP_FILEDATA, LPCSTR)/*=NULL*/, LPVOID lpParam/*=NULL*/, int iUserData/*=0*/) { return C4JStorage::ETMSStatus_Idle; } +C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename, int(*Func)(LPVOID, int, int, PTMSPP_FILEDATA, LPCSTR)/*=nullptr*/, LPVOID lpParam/*=nullptr*/, int iUserData/*=0*/) { return C4JStorage::ETMSStatus_Idle; } #endif // _WINDOWS64 #endif // __PS3__ diff --git a/Minecraft.Client/FallingTileRenderer.cpp b/Minecraft.Client/FallingTileRenderer.cpp index c46b83c5c..132f033a5 100644 --- a/Minecraft.Client/FallingTileRenderer.cpp +++ b/Minecraft.Client/FallingTileRenderer.cpp @@ -51,7 +51,7 @@ void FallingTileRenderer::render(shared_ptr _tile, double x, double y, d t->offset(0, 0, 0); t->end(); } - else if( tt != NULL ) + else if( tt != nullptr ) { tileRenderer->setShape(tt); tileRenderer->renderBlock(tt, level, Mth::floor(tile->x), Mth::floor(tile->y), Mth::floor(tile->z), tile->data); diff --git a/Minecraft.Client/FileTexturePack.cpp b/Minecraft.Client/FileTexturePack.cpp index af58dc1e1..711f67362 100644 --- a/Minecraft.Client/FileTexturePack.cpp +++ b/Minecraft.Client/FileTexturePack.cpp @@ -36,7 +36,7 @@ InputStream *FileTexturePack::getResourceImplementation(const wstring &name) //t return zipFile.getInputStream(entry); #endif - return NULL; + return nullptr; } bool FileTexturePack::hasFile(const wstring &name) diff --git a/Minecraft.Client/FireworksParticles.cpp b/Minecraft.Client/FireworksParticles.cpp index 9fdaebb92..c8a109c4b 100644 --- a/Minecraft.Client/FireworksParticles.cpp +++ b/Minecraft.Client/FireworksParticles.cpp @@ -15,12 +15,12 @@ FireworksParticles::FireworksStarter::FireworksStarter(Level *level, double x, d this->engine = engine; lifetime = 8; - if (infoTag != NULL) + if (infoTag != nullptr) { explosions = static_cast *>(infoTag->getList(FireworksItem::TAG_EXPLOSIONS)->copy()); if (explosions->size() == 0) { - explosions = NULL; + explosions = nullptr; } else { @@ -42,7 +42,7 @@ FireworksParticles::FireworksStarter::FireworksStarter(Level *level, double x, d else { // 4J: - explosions = NULL; + explosions = nullptr; } } @@ -53,7 +53,7 @@ void FireworksParticles::FireworksStarter::render(Tesselator *t, float a, float void FireworksParticles::FireworksStarter::tick() { - if (life == 0 && explosions != NULL) + if (life == 0 && explosions != nullptr) { bool farEffect = isFarAwayFromCamera(); @@ -97,7 +97,7 @@ void FireworksParticles::FireworksStarter::tick() level->playLocalSound(x, y, z, soundId, 20, .95f + random->nextFloat() * .1f, true, 100.0f); } - if ((life % 2) == 0 && explosions != NULL && (life / 2) < explosions->size()) + if ((life % 2) == 0 && explosions != nullptr && (life / 2) < explosions->size()) { int eIndex = life / 2; CompoundTag *compoundTag = explosions->get(eIndex); @@ -212,7 +212,7 @@ void FireworksParticles::FireworksStarter::tick() bool FireworksParticles::FireworksStarter::isFarAwayFromCamera() { Minecraft *instance = Minecraft::GetInstance(); - if (instance != NULL && instance->cameraTargetPlayer != NULL) + if (instance != nullptr && instance->cameraTargetPlayer != nullptr) { if (instance->cameraTargetPlayer->distanceToSqr(x, y, z) < 16 * 16) { @@ -231,7 +231,7 @@ void FireworksParticles::FireworksStarter::createParticle(double x, double y, do int color = random->nextInt(rgbColors.length); fireworksSparkParticle->setColor(rgbColors[color]); - if (/*fadeColors != NULL &&*/ fadeColors.length > 0) + if (/*fadeColors != nullptr &&*/ fadeColors.length > 0) { fireworksSparkParticle->setFadeColor(fadeColors[random->nextInt(fadeColors.length)]); } @@ -382,7 +382,7 @@ void FireworksParticles::FireworksSparkParticle::setFadeColor(int rgb) AABB *FireworksParticles::FireworksSparkParticle::getCollideBox() { - return NULL; + return nullptr; } bool FireworksParticles::FireworksSparkParticle::isPushable() diff --git a/Minecraft.Client/FishingHookRenderer.cpp b/Minecraft.Client/FishingHookRenderer.cpp index 6a55468db..d587ddb87 100644 --- a/Minecraft.Client/FishingHookRenderer.cpp +++ b/Minecraft.Client/FishingHookRenderer.cpp @@ -49,7 +49,7 @@ void FishingHookRenderer::render(shared_ptr _hook, double x, double y, d glPopMatrix(); - if (hook->owner != NULL) + if (hook->owner != nullptr) { float swing = hook->owner->getAttackAnim(a); float swing2 = (float) Mth::sin(sqrt(swing) * PI); diff --git a/Minecraft.Client/FolderTexturePack.cpp b/Minecraft.Client/FolderTexturePack.cpp index 4b65dc7f0..05feca664 100644 --- a/Minecraft.Client/FolderTexturePack.cpp +++ b/Minecraft.Client/FolderTexturePack.cpp @@ -31,7 +31,7 @@ InputStream *FolderTexturePack::getResourceImplementation(const wstring &name) / #endif InputStream *resource = InputStream::getResourceAsStream(wDrive + name); //InputStream *stream = DefaultTexturePack::class->getResourceAsStream(name); - //if (stream == NULL) + //if (stream == nullptr) //{ // throw new FileNotFoundException(name); //} @@ -85,7 +85,7 @@ void FolderTexturePack::loadUI() swprintf(szResourceLocator, LOCATOR_SIZE,L"file://%lsTexturePack.xzp#skin_Minecraft.xur",getPath().c_str()); XuiFreeVisuals(L""); - app.LoadSkin(szResourceLocator,NULL);//L"TexturePack"); + app.LoadSkin(szResourceLocator,nullptr);//L"TexturePack"); bUILoaded = true; //CXuiSceneBase::GetInstance()->SetVisualPrefix(L"TexturePack"); } diff --git a/Minecraft.Client/FolderTexturePack.h b/Minecraft.Client/FolderTexturePack.h index 409210780..4327698d5 100644 --- a/Minecraft.Client/FolderTexturePack.h +++ b/Minecraft.Client/FolderTexturePack.h @@ -20,7 +20,7 @@ class FolderTexturePack : public AbstractTexturePack bool isTerrainUpdateCompatible(); // 4J Added - virtual wstring getPath(bool bTitleUpdateTexture = false, const char *pchBDPatchFilename=NULL); + virtual wstring getPath(bool bTitleUpdateTexture = false, const char *pchBDPatchFilename=nullptr); virtual void loadUI(); virtual void unloadUI(); }; \ No newline at end of file diff --git a/Minecraft.Client/Font.cpp b/Minecraft.Client/Font.cpp index cb2f56324..37294f530 100644 --- a/Minecraft.Client/Font.cpp +++ b/Minecraft.Client/Font.cpp @@ -30,7 +30,7 @@ Font::Font(Options *options, const wstring& name, Textures* textures, bool enfor m_textureLocation = textureLocation; // Build character map - if (charMap != NULL) + if (charMap != nullptr) { for(int i = 0; i < charC; i++) { @@ -273,7 +273,7 @@ int Font::width(const wstring& str) { wstring cleanStr = sanitize(str); - if (cleanStr == L"") return 0; // 4J - was NULL comparison + if (cleanStr == L"") return 0; // 4J - was nullptr comparison int len = 0; for (int i = 0; i < cleanStr.length(); ++i) diff --git a/Minecraft.Client/Font.h b/Minecraft.Client/Font.h index 18d9bf91d..3c326f9af 100644 --- a/Minecraft.Client/Font.h +++ b/Minecraft.Client/Font.h @@ -32,7 +32,7 @@ class Font std::map m_charMap; public: - Font(Options *options, const wstring& name, Textures* textures, bool enforceUnicode, ResourceLocation *textureLocation, int cols, int rows, int charWidth, int charHeight, unsigned short charMap[] = NULL); + Font(Options *options, const wstring& name, Textures* textures, bool enforceUnicode, ResourceLocation *textureLocation, int cols, int rows, int charWidth, int charHeight, unsigned short charMap[] = nullptr); #ifndef _XBOX // 4J Stu - This dtor clashes with one in xui! We never delete these anyway so take it out for now. Can go back when we have got rid of XUI ~Font(); diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index be2b5f0c1..3c11db1f6 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -106,8 +106,8 @@ GameRenderer::GameRenderer(Minecraft *mc) zoom = 1; zoom_x = 0; zoom_y = 0; - rainXa = NULL; - rainZa = NULL; + rainXa = nullptr; + rainZa = nullptr; lastActiveTime = Minecraft::currentTimeMillis(); lastNsTime = 0; random = new Random(); @@ -139,7 +139,7 @@ GameRenderer::GameRenderer(Minecraft *mc) } this->mc = mc; - itemInHandRenderer = NULL; + itemInHandRenderer = nullptr; // 4J-PB - set up the local players iteminhand renderers here - needs to be done with lighting enabled so that the render geometry gets compiled correctly glEnable(GL_LIGHTING); @@ -170,7 +170,7 @@ GameRenderer::GameRenderer(Minecraft *mc) m_updateEvents->Set(eUpdateEventIsFinished); InitializeCriticalSection(&m_csDeleteStack); - m_updateThread = new C4JThread(runUpdate, NULL, "Chunk update"); + m_updateThread = new C4JThread(runUpdate, nullptr, "Chunk update"); #ifdef __PS3__ m_updateThread->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL); #endif// __PS3__ @@ -182,8 +182,8 @@ GameRenderer::GameRenderer(Minecraft *mc) // 4J Stu Added to go with 1.8.2 change GameRenderer::~GameRenderer() { - if(rainXa != NULL) delete [] rainXa; - if(rainZa != NULL) delete [] rainZa; + if(rainXa != nullptr) delete [] rainXa; + if(rainZa != nullptr) delete [] rainZa; } void GameRenderer::tick(bool first) // 4J - add bFirst @@ -211,7 +211,7 @@ void GameRenderer::tick(bool first) // 4J - add bFirst accumulatedSmoothYO = 0; } - if (mc->cameraTargetPlayer == NULL) + if (mc->cameraTargetPlayer == nullptr) { mc->cameraTargetPlayer = dynamic_pointer_cast(mc->player); } @@ -249,8 +249,8 @@ void GameRenderer::tick(bool first) // 4J - add bFirst void GameRenderer::pick(float a) { - if (mc->cameraTargetPlayer == NULL) return; - if (mc->level == NULL) return; + if (mc->cameraTargetPlayer == nullptr) return; + if (mc->level == nullptr) return; mc->crosshairPickMob = nullptr; @@ -280,7 +280,7 @@ void GameRenderer::pick(float a) ( hitz < minxz ) || ( hitz > maxxz) ) { delete mc->hitResult; - mc->hitResult = NULL; + mc->hitResult = nullptr; } } @@ -297,7 +297,7 @@ void GameRenderer::pick(float a) range = dist; } - if (mc->hitResult != NULL) + if (mc->hitResult != nullptr) { dist = mc->hitResult->pos->distanceTo(from); } @@ -327,7 +327,7 @@ void GameRenderer::pick(float a) else if (p != nullptr) { double dd = from->distanceTo(p->pos); - if (e == mc->cameraTargetPlayer->riding != NULL) + if (e == mc->cameraTargetPlayer->riding != nullptr) { if (nearest == 0) { @@ -343,11 +343,11 @@ void GameRenderer::pick(float a) delete p; } - if (hovered != NULL) + if (hovered != nullptr) { - if (nearest < dist || (mc->hitResult == NULL)) + if (nearest < dist || (mc->hitResult == nullptr)) { - if( mc->hitResult != NULL ) + if( mc->hitResult != nullptr ) delete mc->hitResult; mc->hitResult = new HitResult(hovered); if (hovered->instanceof(eTYPE_LIVINGENTITY)) @@ -532,7 +532,7 @@ void GameRenderer::moveCameraToPlayer(float a) // 4J - corrected bug here where zo was also added to x component HitResult *hr = mc->level->clip(Vec3::newTemp(x + xo, y + yo, z + zo), Vec3::newTemp(x - xd + xo, y - yd + yo, z - zd + zo)); - if (hr != NULL) + if (hr != nullptr) { double dist = hr->pos->distanceTo(Vec3::newTemp(x, y, z)); if (dist < cameraDist) cameraDist = dist; @@ -692,7 +692,7 @@ void GameRenderer::renderItemInHand(float a, int eye) bool renderHand = true; // 4J-PB - to turn off the hand for screenshots, but not when the item held is a map - if ( localplayer!=NULL) + if ( localplayer!=nullptr) { shared_ptr item = localplayer->inventory->getSelected(); if(!(item && item->getItem()->id==Item::map_Id) && app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_DisplayHand)==0 ) renderHand = false; @@ -1156,7 +1156,7 @@ void GameRenderer::render(float a, bool bFirst) int maxFps = getFpsCap(mc->options->framerateLimit); - if (mc->level != NULL) + if (mc->level != nullptr) { if (mc->options->framerateLimit == 0) { @@ -1171,9 +1171,9 @@ void GameRenderer::render(float a, bool bFirst) ApplyGammaPostProcess(); - if (!mc->options->hideGui || mc->screen != NULL) + if (!mc->options->hideGui || mc->screen != nullptr) { - mc->gui->render(a, mc->screen != NULL, xMouse, yMouse); + mc->gui->render(a, mc->screen != nullptr, xMouse, yMouse); } } else @@ -1189,11 +1189,11 @@ void GameRenderer::render(float a, bool bFirst) } - if (mc->screen != NULL) + if (mc->screen != nullptr) { glClear(GL_DEPTH_BUFFER_BIT); mc->screen->render(xMouse, yMouse, a); - if (mc->screen != NULL && mc->screen->particles != NULL) mc->screen->particles->render(a); + if (mc->screen != nullptr && mc->screen->particles != nullptr) mc->screen->particles->render(a); } } @@ -1362,7 +1362,7 @@ void GameRenderer::renderLevel(float a, __int64 until) // going to do for the primary player, and the other players can just view whatever they have loaded in - we're sharing render data between players. bool updateChunks = ( mc->player == mc->localplayers[ProfileManager.GetPrimaryPad()] ); - // if (mc->cameraTargetPlayer == NULL) // 4J - removed condition as we want to update this is mc->player changes for different local players + // if (mc->cameraTargetPlayer == nullptr) // 4J - removed condition as we want to update this is mc->player changes for different local players { mc->cameraTargetPlayer = mc->player; } @@ -1490,7 +1490,7 @@ void GameRenderer::renderLevel(float a, __int64 until) PIXEndNamedEvent(); turnOffLightLayer(a); // 4J - brought forward from 1.8.2 - if ( (mc->hitResult != NULL) && cameraEntity->isUnderLiquid(Material::water) && cameraEntity->instanceof(eTYPE_PLAYER) ) //&& !mc->options.hideGui) + if ( (mc->hitResult != nullptr) && cameraEntity->isUnderLiquid(Material::water) && cameraEntity->instanceof(eTYPE_PLAYER) ) //&& !mc->options.hideGui) { shared_ptr player = dynamic_pointer_cast(cameraEntity); glDisable(GL_ALPHA_TEST); @@ -1559,7 +1559,7 @@ void GameRenderer::renderLevel(float a, __int64 until) if ( (zoom == 1) && cameraEntity->instanceof(eTYPE_PLAYER) ) //&& !mc->options.hideGui) { - if (mc->hitResult != NULL && !cameraEntity->isUnderLiquid(Material::water)) + if (mc->hitResult != nullptr && !cameraEntity->isUnderLiquid(Material::water)) { shared_ptr player = dynamic_pointer_cast(cameraEntity); glDisable(GL_ALPHA_TEST); @@ -1717,7 +1717,7 @@ void GameRenderer::renderSnowAndRain(float a) turnOnLightLayer(a); - if (rainXa == NULL) + if (rainXa == nullptr) { rainXa = new float[32 * 32]; rainZa = new float[32 * 32]; @@ -1942,7 +1942,7 @@ void GameRenderer::setupClearColor(float a) if (d > 0) { float *c = level->dimension->getSunriseColor(level->getTimeOfDay(a), a); - if (c != NULL) + if (c != nullptr) { d *= c[3]; fr = fr * (1 - d) + c[0] * d; diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index 44315340b..921472f20 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -240,8 +240,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) shared_ptr headGear = minecraft->player->inventory->getArmor(3); // 4J-PB - changing this to be per player - //if (!minecraft->options->thirdPersonView && headGear != NULL && headGear->id == Tile::pumpkin_Id) renderPumpkin(screenWidth, screenHeight); - if ((minecraft->player->ThirdPersonView()==0) && headGear != NULL && headGear->id == Tile::pumpkin_Id) renderPumpkin(screenWidth, screenHeight); + //if (!minecraft->options->thirdPersonView && headGear != nullptr && headGear->id == Tile::pumpkin_Id) renderPumpkin(screenWidth, screenHeight); + if ((minecraft->player->ThirdPersonView()==0) && headGear != nullptr && headGear->id == Tile::pumpkin_Id) renderPumpkin(screenWidth, screenHeight); if (!minecraft->player->hasEffect(MobEffect::confusion)) { float pt = minecraft->player->oPortalTime + (minecraft->player->portalTime - minecraft->player->oPortalTime) * a; @@ -525,7 +525,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) std::shared_ptr riding = minecraft->localplayers[iPad].get()->riding; std::shared_ptr living = dynamic_pointer_cast(riding); - if (riding == NULL) + if (riding == nullptr) { // render food for (int i = 0; i < FoodConstants::MAX_FOOD / 2; i++) @@ -908,7 +908,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) int px = Mth::floor(minecraft->player->x); int py = Mth::floor(minecraft->player->y); int pz = Mth::floor(minecraft->player->z); - if (minecraft->level != NULL && minecraft->level->hasChunkAt(px, py, pz)) + if (minecraft->level != nullptr && minecraft->level->hasChunkAt(px, py, pz)) { LevelChunk *chunkAt = minecraft->level->getChunkAt(px, pz); Biome *biome = chunkAt->getBiome(px & 15, pz & 15, minecraft->level->getBiomeSource()); @@ -961,7 +961,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) unsigned int max = 10; bool isChatting = false; - if (dynamic_cast(minecraft->screen) != NULL) + if (dynamic_cast(minecraft->screen) != nullptr) { max = 20; isChatting = true; @@ -1090,10 +1090,10 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) // Moved to the xui base scene // void Gui::renderBossHealth(void) // { -// if (EnderDragonRenderer::bossInstance == NULL) return; +// if (EnderDragonRenderer::bossInstance == nullptr) return; // // shared_ptr boss = EnderDragonRenderer::bossInstance; -// EnderDragonRenderer::bossInstance = NULL; +// EnderDragonRenderer::bossInstance = nullptr; // // Minecraft *pMinecraft=Minecraft::GetInstance(); // @@ -1214,7 +1214,7 @@ void Gui::renderTp(float br, int w, int h) void Gui::renderSlot(int slot, int x, int y, float a) { shared_ptr item = minecraft->player->inventory->items[slot]; - if (item == NULL) return; + if (item == nullptr) return; float pop = item->popTime - a; if (pop > 0) @@ -1460,7 +1460,7 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64 *dataA, float dataASc int height = minecraft->height; // This causes us to cover xScale*dataLength pixels in the horizontal int xScale = 1; - if(dataA != NULL && dataB != NULL) xScale = 2; + if(dataA != nullptr && dataB != nullptr) xScale = 2; glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); @@ -1483,7 +1483,7 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64 *dataA, float dataASc int cc2 = cc * cc / 255; cc2 = cc2 * cc2 / 255; - if( dataA != NULL ) + if( dataA != nullptr ) { if (dataA[i] > dataAWarning) { @@ -1500,7 +1500,7 @@ void Gui::renderGraph(int dataLength, int dataPos, __int64 *dataA, float dataASc t->vertex((float)(xScale*i + 0.5f), (float)( height + 0.5f), static_cast(0)); } - if( dataB != NULL ) + if( dataB != nullptr ) { if (dataB[i]>dataBWarning) { diff --git a/Minecraft.Client/HugeExplosionSeedParticle.cpp b/Minecraft.Client/HugeExplosionSeedParticle.cpp index 67d68d460..bb8c8f223 100644 --- a/Minecraft.Client/HugeExplosionSeedParticle.cpp +++ b/Minecraft.Client/HugeExplosionSeedParticle.cpp @@ -26,7 +26,7 @@ void HugeExplosionSeedParticle::tick() double zz = z + (random->nextDouble() - random->nextDouble()) * 4; level->addParticle(eParticleType_largeexplode, xx, yy, zz, life / static_cast(lifeTime), 0, 0); } - Minecraft::GetInstance()->animateTickLevel = NULL; + Minecraft::GetInstance()->animateTickLevel = nullptr; life++; if (life == lifeTime) remove(); } diff --git a/Minecraft.Client/HumanoidMobRenderer.cpp b/Minecraft.Client/HumanoidMobRenderer.cpp index 2d513875c..284b084d4 100644 --- a/Minecraft.Client/HumanoidMobRenderer.cpp +++ b/Minecraft.Client/HumanoidMobRenderer.cpp @@ -17,8 +17,8 @@ void HumanoidMobRenderer::_init(HumanoidModel *humanoidModel, float scale) { this->humanoidModel = humanoidModel; this->_scale = scale; - armorParts1 = NULL; - armorParts2 = NULL; + armorParts1 = nullptr; + armorParts2 = nullptr; createArmorParts(); } @@ -76,9 +76,9 @@ ResourceLocation *HumanoidMobRenderer::getArmorLocation(ArmorItem *armorItem, in void HumanoidMobRenderer::prepareSecondPassArmor(shared_ptr mob, int layer, float a) { shared_ptr itemInstance = mob->getArmor(3 - layer); - if (itemInstance != NULL) { + if (itemInstance != nullptr) { Item *item = itemInstance->getItem(); - if (dynamic_cast(item) != NULL) + if (dynamic_cast(item) != nullptr) { bindTexture(getArmorLocation(dynamic_cast(item), layer, true)); @@ -99,10 +99,10 @@ int HumanoidMobRenderer::prepareArmor(shared_ptr _mob, int layer, shared_ptr mob = dynamic_pointer_cast(_mob); shared_ptr itemInstance = mob->getArmor(3 - layer); - if (itemInstance != NULL) + if (itemInstance != nullptr) { Item *item = itemInstance->getItem(); - if (dynamic_cast(item) != NULL) + if (dynamic_cast(item) != nullptr) { ArmorItem *armorItem = dynamic_cast(item); bindTexture(getArmorLocation(armorItem, layer)); @@ -171,12 +171,12 @@ void HumanoidMobRenderer::render(shared_ptr _mob, double x, double y, do ResourceLocation *HumanoidMobRenderer::getTextureLocation(shared_ptr mob) { // TODO -- Figure out of we need some data in here - return NULL; + return nullptr; } void HumanoidMobRenderer::prepareCarriedItem(shared_ptr mob, shared_ptr item) { - armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = item != NULL ? 1 : 0; + armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = item != nullptr ? 1 : 0; armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking = mob->isSneaking(); } @@ -187,7 +187,7 @@ void HumanoidMobRenderer::additionalRendering(shared_ptr mob, floa shared_ptr item = mob->getCarriedItem(); shared_ptr headGear = mob->getArmor(3); - if (headGear != NULL) + if (headGear != nullptr) { // don't render the pumpkin of skulls for the skins with that disabled // 4J-PB - need to disable rendering armour/skulls/pumpkins for some special skins (Daleks) @@ -199,7 +199,7 @@ void HumanoidMobRenderer::additionalRendering(shared_ptr mob, floa if (headGear->getItem()->id < 256) { - if (Tile::tiles[headGear->id] != NULL && TileRenderer::canRender(Tile::tiles[headGear->id]->getRenderShape())) + if (Tile::tiles[headGear->id] != nullptr && TileRenderer::canRender(Tile::tiles[headGear->id]->getRenderShape())) { float s = 10 / 16.0f; glTranslatef(-0 / 16.0f, -4 / 16.0f, 0 / 16.0f); @@ -226,7 +226,7 @@ void HumanoidMobRenderer::additionalRendering(shared_ptr mob, floa } } - if (item != NULL) + if (item != nullptr) { glPushMatrix(); diff --git a/Minecraft.Client/HumanoidModel.cpp b/Minecraft.Client/HumanoidModel.cpp index 1e76f45a6..c6c6b9f4f 100644 --- a/Minecraft.Client/HumanoidModel.cpp +++ b/Minecraft.Client/HumanoidModel.cpp @@ -8,7 +8,7 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) { - ModelPart *pAttachTo=NULL; + ModelPart *pAttachTo=nullptr; switch(pBox->ePart) { @@ -40,10 +40,10 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) if((pNewBox->getfU()!=static_cast(pBox->fU)) || (pNewBox->getfV()!=static_cast(pBox->fV))) { app.DebugPrintf("HumanoidModel::AddOrRetrievePart - Box geometry was found, but with different uvs\n"); - pNewBox=NULL; + pNewBox=nullptr; } } - if(pNewBox==NULL) + if(pNewBox==nullptr) { //app.DebugPrintf("HumanoidModel::AddOrRetrievePart - Adding box to model part\n"); @@ -142,7 +142,7 @@ HumanoidModel::HumanoidModel(float g, float yOffset, int texWidth, int texHeight void HumanoidModel::render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) { - if(entity != NULL) + if(entity != nullptr) { m_uiAnimOverrideBitmask=entity->getAnimOverrideBitmask(); } diff --git a/Minecraft.Client/Input.cpp b/Minecraft.Client/Input.cpp index cbcd317f6..c9b04e78f 100644 --- a/Minecraft.Client/Input.cpp +++ b/Minecraft.Client/Input.cpp @@ -84,7 +84,7 @@ void Input::tick(LocalPlayer *player) } // 4J: In flying mode, don't actually toggle sneaking (unless we're riding in which case we need to sneak to dismount) - if(!player->abilities.flying || player->riding != NULL) + if(!player->abilities.flying || player->riding != nullptr) { if((player->ullButtonsPressed&(1LL<localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SNEAK_TOGGLE)) { diff --git a/Minecraft.Client/ItemFrameRenderer.cpp b/Minecraft.Client/ItemFrameRenderer.cpp index 54633deb3..33c4cd8ac 100644 --- a/Minecraft.Client/ItemFrameRenderer.cpp +++ b/Minecraft.Client/ItemFrameRenderer.cpp @@ -110,7 +110,7 @@ void ItemFrameRenderer::drawItem(shared_ptr entity) Minecraft *pMinecraft=Minecraft::GetInstance(); shared_ptr instance = entity->getItem(); - if (instance == NULL) return; + if (instance == nullptr) return; shared_ptr itemEntity = shared_ptr(new ItemEntity(entity->level, 0, 0, 0, instance)); itemEntity->getItem()->count = 1; @@ -154,7 +154,7 @@ void ItemFrameRenderer::drawItem(shared_ptr entity) t->end(); shared_ptr data = Item::map->getSavedData(itemEntity->getItem(), entity->level); - if (data != NULL) + if (data != nullptr) { entityRenderDispatcher->itemInHandRenderer->minimap->render(nullptr, entityRenderDispatcher->textures, data, entity->entityId); } diff --git a/Minecraft.Client/ItemInHandRenderer.cpp b/Minecraft.Client/ItemInHandRenderer.cpp index b7aa4f8b5..4cebda2fd 100644 --- a/Minecraft.Client/ItemInHandRenderer.cpp +++ b/Minecraft.Client/ItemInHandRenderer.cpp @@ -226,7 +226,7 @@ void ItemInHandRenderer::renderItem(shared_ptr mob, shared_ptrid]->getColor(item,0); float red = ((col >> 16) & 0xff) / 255.0f; @@ -238,7 +238,7 @@ void ItemInHandRenderer::renderItem(shared_ptr mob, shared_ptrid]; - if (item->getIconType() == Icon::TYPE_TERRAIN && tile != NULL && TileRenderer::canRender(tile->getRenderShape())) + if (item->getIconType() == Icon::TYPE_TERRAIN && tile != nullptr && TileRenderer::canRender(tile->getRenderShape())) { MemSect(31); minecraft->textures->bindTexture(minecraft->textures->getTextureLocation(Icon::TYPE_TERRAIN)); @@ -249,7 +249,7 @@ void ItemInHandRenderer::renderItem(shared_ptr mob, shared_ptrgetItemInHandIcon(item, layer); - if (icon == NULL) + if (icon == nullptr) { glPopMatrix(); MemSect(0); @@ -299,7 +299,7 @@ void ItemInHandRenderer::renderItem(shared_ptr mob, shared_ptrgetSourceWidth(), icon->getSourceHeight(), 1 / 16.0f, false, bIsTerrain); - if (item != NULL && item->isFoil() && layer == 0) + if (item != nullptr && item->isFoil() && layer == 0) { glDepthFunc(GL_EQUAL); glDisable(GL_LIGHTING); @@ -425,7 +425,7 @@ void ItemInHandRenderer::render(float a) glMultiTexCoord2f(GL_TEXTURE1, u / 1.0f, v / 1.0f); glColor4f(1, 1, 1, 1); } - if (item != NULL) + if (item != nullptr) { int col = Item::items[item->id]->getColor(item,0); float red = ((col >> 16) & 0xff) / 255.0f; @@ -439,7 +439,7 @@ void ItemInHandRenderer::render(float a) glColor4f(br, br, br, 1); } - if (item != NULL && item->id == Item::map->id) + if (item != nullptr && item->id == Item::map->id) { glPushMatrix(); float d = 0.8f; @@ -538,12 +538,12 @@ void ItemInHandRenderer::render(float a) shared_ptr data = Item::map->getSavedData(item, minecraft->level); PIXBeginNamedEvent(0,"Minimap render"); - if(data != NULL) minimap->render(minecraft->player, minecraft->textures, data, minecraft->player->entityId); + if(data != nullptr) minimap->render(minecraft->player, minecraft->textures, data, minecraft->player->entityId); PIXEndNamedEvent(); glPopMatrix(); } - else if (item != NULL) + else if (item != nullptr) { glPushMatrix(); float d = 0.8f; @@ -762,7 +762,7 @@ void ItemInHandRenderer::renderScreenEffect(float a) } } - if (Tile::tiles[tile] != NULL) renderTex(a, Tile::tiles[tile]->getTexture(2)); + if (Tile::tiles[tile] != nullptr) renderTex(a, Tile::tiles[tile]->getTexture(2)); } if (minecraft->player->isUnderLiquid(Material::water)) @@ -905,11 +905,11 @@ void ItemInHandRenderer::tick() shared_ptr nextTile = player->inventory->getSelected(); bool matches = lastSlot == player->inventory->selected && nextTile == selectedItem; - if (selectedItem == NULL && nextTile == NULL) + if (selectedItem == nullptr && nextTile == nullptr) { matches = true; } - if (nextTile != NULL && selectedItem != NULL && nextTile != selectedItem && nextTile->id == selectedItem->id && nextTile->getAuxValue() == selectedItem->getAuxValue()) + if (nextTile != nullptr && selectedItem != nullptr && nextTile != selectedItem && nextTile->id == selectedItem->id && nextTile->getAuxValue() == selectedItem->getAuxValue()) { selectedItem = nextTile; matches = true; diff --git a/Minecraft.Client/ItemRenderer.cpp b/Minecraft.Client/ItemRenderer.cpp index 849195a65..a7a3a1bf6 100644 --- a/Minecraft.Client/ItemRenderer.cpp +++ b/Minecraft.Client/ItemRenderer.cpp @@ -65,7 +65,7 @@ void ItemRenderer::render(shared_ptr _itemEntity, double x, double y, do random->setSeed(187); shared_ptr item = itemEntity->getItem(); - if (item->getItem() == NULL) return; + if (item->getItem() == nullptr) return; glPushMatrix(); float bob = Mth::sin((itemEntity->age + a) / 10.0f + itemEntity->bobOffs) * 0.1f + 0.1f; @@ -82,7 +82,7 @@ void ItemRenderer::render(shared_ptr _itemEntity, double x, double y, do Tile *tile = Tile::tiles[item->id]; - if (item->getIconType() == Icon::TYPE_TERRAIN && tile != NULL && TileRenderer::canRender(tile->getRenderShape())) + if (item->getIconType() == Icon::TYPE_TERRAIN && tile != nullptr && TileRenderer::canRender(tile->getRenderShape())) { glRotatef(spin, 0, 1, 0); @@ -200,7 +200,7 @@ void ItemRenderer::renderItemBillboard(shared_ptr entity, Icon *icon { Tesselator *t = Tesselator::getInstance(); - if (icon == NULL) icon = entityRenderDispatcher->textures->getMissingIcon(entity->getItem()->getIconType()); + if (icon == nullptr) icon = entityRenderDispatcher->textures->getMissingIcon(entity->getItem()->getIconType()); float u0 = icon->getU0(); float u1 = icon->getU1(); float v0 = icon->getV0(); @@ -264,7 +264,7 @@ void ItemRenderer::renderItemBillboard(shared_ptr entity, Icon *icon glTranslatef(0, 0, width + margin); bool bIsTerrain = false; - if (item->getIconType() == Icon::TYPE_TERRAIN && Tile::tiles[item->id] != NULL) + if (item->getIconType() == Icon::TYPE_TERRAIN && Tile::tiles[item->id] != nullptr) { bIsTerrain = true; bindTexture(&TextureAtlas::LOCATION_BLOCKS); // TODO: Do this sanely by Icon @@ -279,7 +279,7 @@ void ItemRenderer::renderItemBillboard(shared_ptr entity, Icon *icon //ItemInHandRenderer::renderItem3D(t, u1, v0, u0, v1, icon->getSourceWidth(), icon->getSourceHeight(), width, false); ItemInHandRenderer::renderItem3D(t, u0, v0, u1, v1, icon->getSourceWidth(), icon->getSourceHeight(), width, false, bIsTerrain); - if (item != NULL && item->isFoil()) + if (item != nullptr && item->isFoil()) { glDepthFunc(GL_EQUAL); glDisable(GL_LIGHTING); @@ -443,7 +443,7 @@ void ItemRenderer::renderGuiItem(Font *font, Textures *textures, shared_ptrgetMissingIcon(item->getIconType()); } @@ -481,7 +481,7 @@ void ItemRenderer::renderGuiItem(Font *font, Textures *textures, shared_ptr item, float x, float y,float fScale,float fAlpha, bool isFoil) { - if(item==NULL) return; + if(item==nullptr) return; renderAndDecorateItem(font, textures, item, x, y,fScale, fScale, fAlpha, isFoil, true); } @@ -489,7 +489,7 @@ void ItemRenderer::renderAndDecorateItem(Font *font, Textures *textures, const s // (ie from the gui rather than xui). In this case we dno't want to enable/disable blending, and do need to restore the blend state when we are done. void ItemRenderer::renderAndDecorateItem(Font *font, Textures *textures, const shared_ptr item, float x, float y,float fScaleX, float fScaleY,float fAlpha, bool isFoil, bool isConstantBlended, bool useCompiled) { - if (item == NULL) + if (item == nullptr) { return; } @@ -593,7 +593,7 @@ void ItemRenderer::renderGuiItemDecorations(Font *font, Textures *textures, shar void ItemRenderer::renderGuiItemDecorations(Font *font, Textures *textures, shared_ptr item, int x, int y, const wstring &countText, float fAlpha) { - if (item == NULL) + if (item == nullptr) { return; } diff --git a/Minecraft.Client/ItemSpriteRenderer.cpp b/Minecraft.Client/ItemSpriteRenderer.cpp index b8a4a3770..afe8023ee 100644 --- a/Minecraft.Client/ItemSpriteRenderer.cpp +++ b/Minecraft.Client/ItemSpriteRenderer.cpp @@ -22,7 +22,7 @@ void ItemSpriteRenderer::render(shared_ptr e, double x, double y, double { // the icon is already cached in the item object, so there should not be any performance impact by not caching it here Icon *icon = sourceItem->getIcon(sourceItemAuxValue); - if (icon == NULL) + if (icon == nullptr) { return; } diff --git a/Minecraft.Client/JoinMultiplayerScreen.cpp b/Minecraft.Client/JoinMultiplayerScreen.cpp index 7ef19663c..2e0c64d9e 100644 --- a/Minecraft.Client/JoinMultiplayerScreen.cpp +++ b/Minecraft.Client/JoinMultiplayerScreen.cpp @@ -7,7 +7,7 @@ JoinMultiplayerScreen::JoinMultiplayerScreen(Screen *lastScreen) { - ipEdit = NULL; + ipEdit = nullptr; this->lastScreen = lastScreen; } diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index 109fab3f5..dc7b8987d 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -111,12 +111,12 @@ const int LevelRenderer::DIMENSION_OFFSETS[3] = { 0, (80 * 80 * CHUNK_Y_COUNT) , LevelRenderer::LevelRenderer(Minecraft *mc, Textures *textures) { - breakingTextures = NULL; + breakingTextures = nullptr; for( int i = 0; i < 4; i++ ) { - level[i] = NULL; - tileRenderer[i] = NULL; + level[i] = nullptr; + tileRenderer[i] = nullptr; xOld[i] = -9999; yOld[i] = -9999; zOld[i] = -9999; @@ -142,7 +142,7 @@ LevelRenderer::LevelRenderer(Minecraft *mc, Textures *textures) totalChunks= offscreenChunks= occludedChunks= renderedChunks= emptyChunks = 0; for( int i = 0; i < 4; i++ ) { - // sortedChunks[i] = NULL; // 4J - removed - not sorting our chunks anymore + // sortedChunks[i] = nullptr; // 4J - removed - not sorting our chunks anymore chunks[i] = ClipChunkArray(); lastPlayerCount[i] = 0; } @@ -323,7 +323,7 @@ void LevelRenderer::renderStars() void LevelRenderer::setLevel(int playerIndex, MultiPlayerLevel *level) { - if (this->level[playerIndex] != NULL) + if (this->level[playerIndex] != nullptr) { // Remove listener for this level if this is the last player referencing it Level *prevLevel = this->level[playerIndex]; @@ -343,12 +343,12 @@ void LevelRenderer::setLevel(int playerIndex, MultiPlayerLevel *level) zOld[playerIndex] = -9999; this->level[playerIndex] = level; - if( tileRenderer[playerIndex] != NULL ) + if( tileRenderer[playerIndex] != nullptr ) { delete tileRenderer[playerIndex]; } tileRenderer[playerIndex] = new TileRenderer(level); - if (level != NULL) + if (level != nullptr) { // If we're the only player referencing this level, add a new listener for it int refCount = 0; @@ -366,7 +366,7 @@ void LevelRenderer::setLevel(int playerIndex, MultiPlayerLevel *level) else { // printf("NULLing player %d, chunks @ 0x%x\n",playerIndex,chunks[playerIndex]); - if( chunks[playerIndex].data != NULL ) + if( chunks[playerIndex].data != nullptr ) { for (unsigned int i = 0; i < chunks[playerIndex].length; i++) { @@ -374,14 +374,14 @@ void LevelRenderer::setLevel(int playerIndex, MultiPlayerLevel *level) delete chunks[playerIndex][i].chunk; } delete chunks[playerIndex].data; - chunks[playerIndex].data = NULL; + chunks[playerIndex].data = nullptr; chunks[playerIndex].length = 0; // delete sortedChunks[playerIndex]; // 4J - removed - not sorting our chunks anymore - // sortedChunks[playerIndex] = NULL; // 4J - removed - not sorting our chunks anymore + // sortedChunks[playerIndex] = nullptr; // 4J - removed - not sorting our chunks anymore } // 4J Stu - If we do this for splitscreen players leaving, then all the tile entities in the world dissappear - // We should only do this when actually exiting the game, so only when the primary player sets there level to NULL + // We should only do this when actually exiting the game, so only when the primary player sets there level to nullptr if(playerIndex == ProfileManager.GetPrimaryPad()) renderableTileEntities.clear(); } } @@ -416,7 +416,7 @@ void LevelRenderer::allChanged(int playerIndex) // If this CS is entered before DisableUpdateThread is 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 == nullptr ) { return; } @@ -440,7 +440,7 @@ void LevelRenderer::allChanged(int playerIndex) yChunks = Level::maxBuildHeight / CHUNK_SIZE; zChunks = dist; - if( chunks[playerIndex].data != NULL ) + if( chunks[playerIndex].data != nullptr ) { for (unsigned int i = 0; i < chunks[playerIndex].length; i++) { @@ -463,7 +463,7 @@ void LevelRenderer::allChanged(int playerIndex) yMaxChunk = yChunks; zMaxChunk = zChunks; - // 4J removed - we now only fully clear this on exiting the game (setting level to NULL). Apart from that, the chunk rebuilding is responsible for maintaining this + // 4J removed - we now only fully clear this on exiting the game (setting level to nullptr). Apart from that, the chunk rebuilding is responsible for maintaining this // renderableTileEntities.clear(); for (int x = 0; x < xChunks; x++) @@ -483,10 +483,10 @@ void LevelRenderer::allChanged(int playerIndex) } nonStackDirtyChunksAdded(); - if (level != NULL) + if (level != nullptr) { shared_ptr player = mc->cameraTargetPlayer; - if (player != NULL) + if (player != nullptr) { this->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 @@ -547,7 +547,7 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a) if ( !shouldRender && entity->instanceof(eTYPE_MOB) ) { shared_ptr mob = dynamic_pointer_cast(entity); - if ( mob->isLeashed() && (mob->getLeashHolder() != NULL) ) + if ( mob->isLeashed() && (mob->getLeashHolder() != nullptr) ) { shared_ptr leashHolder = mob->getLeashHolder(); shouldRender = culler->isVisible(leashHolder->bb); @@ -1027,7 +1027,7 @@ void LevelRenderer::renderSky(float alpha) Lighting::turnOff(); float *c = level[playerIndex]->dimension->getSunriseColor(level[playerIndex]->getTimeOfDay(alpha), alpha); - if (c != NULL) + if (c != nullptr) { glDisable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); @@ -1813,7 +1813,7 @@ bool LevelRenderer::updateDirtyChunks() std::list< std::pair > nearestClipChunks; #endif - ClipChunk *nearChunk = NULL; // Nearest chunk that is dirty + ClipChunk *nearChunk = nullptr; // Nearest chunk that is dirty int veryNearCount = 0; int minDistSq = 0x7fffffff; // Distances to this chunk @@ -1891,15 +1891,15 @@ bool LevelRenderer::updateDirtyChunks() g_findNearestChunkDataIn.chunks[i] = (LevelRenderer_FindNearestChunk_DataIn::ClipChunk*)chunks[i].data; g_findNearestChunkDataIn.chunkLengths[i] = chunks[i].length; g_findNearestChunkDataIn.level[i] = level[i]; - g_findNearestChunkDataIn.playerData[i].bValid = mc->localplayers[i] != NULL; - if(mc->localplayers[i] != NULL) + g_findNearestChunkDataIn.playerData[i].bValid = mc->localplayers[i] != nullptr; + if(mc->localplayers[i] != nullptr) { g_findNearestChunkDataIn.playerData[i].x = mc->localplayers[i]->x; g_findNearestChunkDataIn.playerData[i].y = mc->localplayers[i]->y; g_findNearestChunkDataIn.playerData[i].z = mc->localplayers[i]->z; } - if(level[i] != NULL) + if(level[i] != nullptr) { g_findNearestChunkDataIn.multiplayerChunkCache[i].XZOFFSET = ((MultiPlayerChunkCache*)(level[i]->chunkSource))->XZOFFSET; g_findNearestChunkDataIn.multiplayerChunkCache[i].XZSIZE = ((MultiPlayerChunkCache*)(level[i]->chunkSource))->XZSIZE; @@ -1923,12 +1923,12 @@ bool LevelRenderer::updateDirtyChunks() // Find nearest chunk that is dirty for( int p = 0; p < XUSER_MAX_COUNT; p++ ) { - // It's possible that the localplayers member can be set to NULL on the main thread when a player chooses to exit the game + // It's possible that the localplayers member can be set to nullptr on the main thread when a player chooses to exit the game // So take a reference to the player object now. As it is a shared_ptr it should live as long as we need it shared_ptr player = mc->localplayers[p]; - if( player == NULL ) continue; - if( chunks[p].data == NULL ) continue; - if( level[p] == NULL ) continue; + if( player == nullptr ) continue; + if( chunks[p].data == nullptr ) continue; + if( level[p] == nullptr ) continue; if( chunks[p].length != xChunks * zChunks * CHUNK_Y_COUNT ) continue; int px = static_cast(player->x); int py = static_cast(player->y); @@ -2031,7 +2031,7 @@ bool LevelRenderer::updateDirtyChunks() - Chunk *chunk = NULL; + Chunk *chunk = nullptr; #ifdef _LARGE_WORLDS if(!nearestClipChunks.empty()) { @@ -2182,7 +2182,7 @@ void LevelRenderer::renderHit(shared_ptr player, HitResult *h, int mode, glEnable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor4f(1, 1, 1, ((float) (Mth::sin(Minecraft::currentTimeMillis() / 100.0f)) * 0.2f + 0.4f) * 0.5f); - if (mode != 0 && inventoryItem != NULL) + if (mode != 0 && inventoryItem != nullptr) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); float br = (Mth::sin(Minecraft::currentTimeMillis() / 100.0f) * 0.2f + 0.8f); @@ -2237,8 +2237,8 @@ void LevelRenderer::renderDestroyAnimation(Tesselator *t, shared_ptr pla { int iPad = mc->player->GetXboxPad(); // 4J added int tileId = level[iPad]->getTile(block->getX(), block->getY(), block->getZ()); - Tile *tile = tileId > 0 ? Tile::tiles[tileId] : NULL; - if (tile == NULL) tile = Tile::stone; + Tile *tile = tileId > 0 ? Tile::tiles[tileId] : nullptr; + if (tile == nullptr) tile = Tile::stone; tileRenderer[iPad]->tesselateInWorldFixedTexture(tile, block->getX(), block->getY(), block->getZ(), breakingTextures[block->getProgress()]); // 4J renamed to differentiate from tesselateInWorld } ++it; @@ -2329,7 +2329,7 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, Lev { // 4J - level is passed if this is coming from setTilesDirty, which could come from when connection is being ticked outside of normal level tick, and player won't // be set up - if( level == NULL ) level = this->level[mc->player->GetXboxPad()]; + if( level == nullptr ) level = this->level[mc->player->GetXboxPad()]; // EnterCriticalSection(&m_csDirtyChunks); int _x0 = Mth::intFloorDiv(x0, CHUNK_XZSIZE); int _y0 = Mth::intFloorDiv(y0, CHUNK_SIZE); @@ -2350,7 +2350,7 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, Lev // These chunks are then added to the global flags in the render update thread. // An XLockFreeQueue actually implements a queue of pointers to its templated type, and I don't want to have to go allocating ints here just to store the // pointer to them in a queue. Hence actually pretending that the int Is a pointer here. Our Index has a a valid range from 0 to something quite big, - // but including zero. The lock free queue, since it thinks it is dealing with pointers, uses a NULL pointer to signify that a Pop hasn't succeeded. + // but including zero. The lock free queue, since it thinks it is dealing with pointers, uses a nullptr pointer to signify that a Pop hasn't succeeded. // We also want to reserve one special value (of 1 ) for use when multiple chunks not individually listed are made dirty. Therefore adding 2 to our // index value here to move our valid range from 1 to something quite big + 2 if( index > -1 ) @@ -2408,12 +2408,12 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, Lev void LevelRenderer::tileChanged(int x, int y, int z) { - setDirty(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1, NULL); + setDirty(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1, nullptr); } void LevelRenderer::tileLightChanged(int x, int y, int z) { - setDirty(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1, NULL); + setDirty(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1, nullptr); } void LevelRenderer::setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level) // 4J - added level param @@ -2620,7 +2620,7 @@ void LevelRenderer::playSoundExceptPlayer(shared_ptr player, int iSound, /* void LevelRenderer::addParticle(const wstring& name, double x, double y, double z, double xa, double ya, double za) { -if (mc == NULL || mc->cameraTargetPlayer == NULL || mc->particleEngine == NULL) return; +if (mc == nullptr || mc->cameraTargetPlayer == nullptr || mc->particleEngine == nullptr) return; double xd = mc->cameraTargetPlayer->x - x; double yd = mc->cameraTargetPlayer->y - y; @@ -2656,7 +2656,7 @@ void LevelRenderer::addParticle(ePARTICLE_TYPE eParticleType, double x, double y shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticleType, double x, double y, double z, double xa, double ya, double za) { - if (mc == NULL || mc->cameraTargetPlayer == NULL || mc->particleEngine == NULL) + if (mc == nullptr || mc->cameraTargetPlayer == nullptr || mc->particleEngine == nullptr) { return nullptr; } @@ -2691,12 +2691,12 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle distCull = false; } - // 4J - this is a bit of hack to get communication through from the level itself, but if Minecraft::animateTickLevel is NULL then + // 4J - this is a bit of hack to get communication through from the level itself, but if Minecraft::animateTickLevel is nullptr then // we are to behave as normal, and if it is set, then we should use that as a pointer to the level the particle is to be created with // rather than try to work it out from the current player. This is because in this state we are calling from a loop that is trying // to amalgamate particle creation between all players for a particular level. Also don't do distance clipping as it isn't for a particular // player, and distance is already taken into account before we get here anyway by the code in Level::animateTickDoWork - if( mc->animateTickLevel == NULL ) + if( mc->animateTickLevel == nullptr ) { double particleDistanceSquared = 16 * 16; double xd = 0.0f; @@ -2709,7 +2709,7 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { shared_ptr thisPlayer = mc->localplayers[i]; - if(thisPlayer != NULL && level[i] == lev) + if(thisPlayer != nullptr && level[i] == lev) { xd = thisPlayer->x - x; yd = thisPlayer->y - y; @@ -2909,7 +2909,7 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle } } - if (particle != NULL) + if (particle != nullptr) { mc->particleEngine->add(particle); } @@ -2985,7 +2985,7 @@ void LevelRenderer::globalLevelEvent(int type, int sourceX, int sourceY, int sou { case LevelEvent::SOUND_WITHER_BOSS_SPAWN: case LevelEvent::SOUND_DRAGON_DEATH: - if (mc->cameraTargetPlayer != NULL) + if (mc->cameraTargetPlayer != nullptr) { // play the sound at an offset from the player double dx = sourceX - mc->cameraTargetPlayer->x; @@ -3024,7 +3024,7 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y { //case LevelEvent::SOUND_WITHER_BOSS_SPAWN: case LevelEvent::SOUND_DRAGON_DEATH: - if (mc->cameraTargetPlayer != NULL) + if (mc->cameraTargetPlayer != nullptr) { // play the sound at an offset from the player double dx = x - mc->cameraTargetPlayer->x; @@ -3129,7 +3129,7 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y double zs = sin(angle) * dist; shared_ptr spellParticle = addParticleInternal(particleName, xp + xs * 0.1, yp + 0.3, zp + zs * 0.1, xs, ys, zs); - if (spellParticle != NULL) + if (spellParticle != nullptr) { float randBrightness = 0.75f + random->nextFloat() * 0.25f; spellParticle->setColor(red * randBrightness, green * randBrightness, blue * randBrightness); @@ -3156,7 +3156,7 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y double zs = sin(angle) * dist; shared_ptr acidParticle = addParticleInternal(particleName, xp + xs * 0.1, yp + 0.3, zp + zs * 0.1, xs, ys, zs); - if (acidParticle != NULL) + if (acidParticle != nullptr) { float randBrightness = 0.75f + random->nextFloat() * 0.25f; acidParticle->setPower(static_cast(dist)); @@ -3217,7 +3217,7 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y case LevelEvent::SOUND_PLAY_RECORDING: { RecordingItem *rci = dynamic_cast(Item::items[data]); - if (rci != NULL) + if (rci != nullptr) { level[playerIndex]->playStreamingMusic(rci->recording, x, y, z); } @@ -3226,7 +3226,7 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y // 4J-PB - only play streaming music if there isn't already some playing - the CD playing may have finished, and game music started playing already if(!mc->soundEngine->GetIsPlayingStreamingGameMusic()) { - level[playerIndex]->playStreamingMusic(L"", x, y, z); // 4J - used to pass NULL, but using empty string here now instead + level[playerIndex]->playStreamingMusic(L"", x, y, z); // 4J - used to pass nullptr, but using empty string here now instead } } mc->localplayers[playerIndex]->updateRichPresence(); @@ -3286,12 +3286,12 @@ void LevelRenderer::destroyTileProgress(int id, int x, int y, int z, int progres } else { - BlockDestructionProgress *entry = NULL; + BlockDestructionProgress *entry = nullptr; auto it = destroyingBlocks.find(id); if(it != destroyingBlocks.end()) entry = it->second; - if (entry == NULL || entry->getX() != x || entry->getY() != y || entry->getZ() != z) + if (entry == nullptr || entry->getX() != x || entry->getY() != y || entry->getZ() != z) { entry = new BlockDestructionProgress(id, x, y, z); destroyingBlocks.insert( unordered_map::value_type(id, entry) ); @@ -3553,7 +3553,7 @@ void LevelRenderer::DestroyedTileManager::destroyingTileAt( Level *level, int x, AABB *box = AABB::newTemp(static_cast(x), static_cast(y), static_cast(z), static_cast(x + 1), static_cast(y + 1), static_cast(z + 1)); Tile *tile = Tile::tiles[level->getTile(x, y, z)]; - if (tile != NULL) + if (tile != nullptr) { tile->addAABBs(level, x, y, z, box, &recentTile->boxes, nullptr); } diff --git a/Minecraft.Client/LivingEntityRenderer.cpp b/Minecraft.Client/LivingEntityRenderer.cpp index f713c20e5..7e99f0ba6 100644 --- a/Minecraft.Client/LivingEntityRenderer.cpp +++ b/Minecraft.Client/LivingEntityRenderer.cpp @@ -17,7 +17,7 @@ LivingEntityRenderer::LivingEntityRenderer(Model *model, float shadow) { this->model = model; shadowRadius = shadow; - armor = NULL; + armor = nullptr; } void LivingEntityRenderer::setArmor(Model *armor) @@ -43,11 +43,11 @@ void LivingEntityRenderer::render(shared_ptr _mob, double x, double y, d glDisable(GL_CULL_FACE); model->attackTime = getAttackAnim(mob, a); - if (armor != NULL) armor->attackTime = model->attackTime; + if (armor != nullptr) armor->attackTime = model->attackTime; model->riding = mob->isRiding(); - if (armor != NULL) armor->riding = model->riding; + if (armor != nullptr) armor->riding = model->riding; model->young = mob->isBaby(); - if (armor != NULL) armor->young = model->young; + if (armor != nullptr) armor->young = model->young; /*try*/ { @@ -448,7 +448,7 @@ void LivingEntityRenderer::renderName(shared_ptr mob, double x, do bool LivingEntityRenderer::shouldShowName(shared_ptr mob) { - return Minecraft::renderNames() && mob != entityRenderDispatcher->cameraEntity && !mob->isInvisibleTo(Minecraft::GetInstance()->player) && mob->rider.lock() == NULL; + return Minecraft::renderNames() && mob != entityRenderDispatcher->cameraEntity && !mob->isInvisibleTo(Minecraft::GetInstance()->player) && mob->rider.lock() == nullptr; } void LivingEntityRenderer::renderNameTags(shared_ptr mob, double x, double y, double z, const wstring &msg, float scale, double dist) diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index 46d231d46..6e06f9ef6 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -79,11 +79,11 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim this->minecraft = minecraft; this->dimension = dimension; - if (user != NULL && user->name.length() > 0) + if (user != nullptr && user->name.length() > 0) { customTextureUrl = L"http://s3.amazonaws.com/MinecraftSkins/" + user->name + L".png"; } - if( user != NULL ) + if( user != nullptr ) { this->name = user->name; //wprintf(L"Created LocalPlayer with name %ls\n", name.c_str() ); @@ -95,7 +95,7 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim } } - input = NULL; + input = nullptr; m_iPad = -1; m_iScreenSection=C4JRender::VIEWPORT_TYPE_FULLSCREEN; // assume singleplayer default m_bPlayerRespawned=false; @@ -124,7 +124,7 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim LocalPlayer::~LocalPlayer() { - if( this->input != NULL ) + if( this->input != nullptr ) delete input; } @@ -188,9 +188,9 @@ void LocalPlayer::aiStep() { if (!level->isClientSide) { - if (riding != NULL) this->ride(nullptr); + if (riding != nullptr) this->ride(nullptr); } - if (minecraft->screen != NULL) minecraft->setScreen(NULL); + if (minecraft->screen != nullptr) minecraft->setScreen(nullptr); if (portalTime == 0) { @@ -574,7 +574,7 @@ void LocalPlayer::readAdditionalSaveData(CompoundTag *entityTag) void LocalPlayer::closeContainer() { Player::closeContainer(); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // 4J - Close any xui here // Fix for #9164 - CRASH: MP: Title crashes upon opening a chest and having another user destroy it. @@ -755,7 +755,7 @@ void LocalPlayer::hurtTo(float newHealth, ETelemetryChallenges damageSource) if( this->getHealth() <= 0) { int deathTime = static_cast(level->getGameTime() % Level::TICKS_PER_DAY)/1000; - int carriedId = inventory->getSelected() == NULL ? 0 : inventory->getSelected()->id; + int carriedId = inventory->getSelected() == nullptr ? 0 : inventory->getSelected()->id; TelemetryManager->RecordPlayerDiedOrFailed(GetXboxPad(), 0, y, 0, 0, carriedId, 0, damageSource); // if there are any xuiscenes up for this player, close them @@ -800,7 +800,7 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param) delete [] param.data; if (!app.CanRecordStatsAndAchievements()) return; - if (stat == NULL) return; + if (stat == nullptr) return; if (stat->isAchievement()) { @@ -1196,7 +1196,7 @@ void LocalPlayer::playSound(int soundId, float volume, float pitch) bool LocalPlayer::isRidingJumpable() { - return riding != NULL && riding->GetType() == eTYPE_HORSE; + return riding != nullptr && riding->GetType() == eTYPE_HORSE; } float LocalPlayer::getJumpRidingScale() @@ -1215,7 +1215,7 @@ bool LocalPlayer::hasPermission(EGameCommand command) void LocalPlayer::onCrafted(shared_ptr item) { - if( minecraft->localgameModes[m_iPad] != NULL ) + if( minecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(minecraft->localgameModes[m_iPad]); gameMode->getTutorial()->onCrafted(item); @@ -1272,14 +1272,14 @@ void LocalPlayer::mapPlayerChunk(const unsigned int flagTileType) void LocalPlayer::handleMouseDown(int button, bool down) { // 4J Stu - We should not accept any input while asleep, except the above to wake up - if(isSleeping() && level != NULL && level->isClientSide) + if(isSleeping() && level != nullptr && level->isClientSide) { return; } if (!down) missTime = 0; if (button == 0 && missTime > 0) return; - if (down && minecraft->hitResult != NULL && minecraft->hitResult->type == HitResult::TILE && button == 0) + if (down && minecraft->hitResult != nullptr && minecraft->hitResult->type == HitResult::TILE && button == 0) { int x = minecraft->hitResult->x; int y = minecraft->hitResult->y; @@ -1486,7 +1486,7 @@ bool LocalPlayer::handleMouseClick(int button) // 4J-PB - Adding a special case in here for sleeping in a bed in a multiplayer game - we need to wake up, and we don't have the inbedchatscreen with a button - if(button==1 && (isSleeping() && level != NULL && level->isClientSide)) + if(button==1 && (isSleeping() && level != nullptr && level->isClientSide)) { if(lastClickState == lastClick_oldRepeat) return false; @@ -1497,14 +1497,14 @@ bool LocalPlayer::handleMouseClick(int button) } // 4J Stu - We should not accept any input while asleep, except the above to wake up - if(isSleeping() && level != NULL && level->isClientSide) + if(isSleeping() && level != nullptr && level->isClientSide) { return false; } shared_ptr oldItem = inventory->getSelected(); - if (minecraft->hitResult == NULL) + if (minecraft->hitResult == nullptr) { if (button == 0 && minecraft->localgameModes[GetXboxPad()]->hasMissTime()) missTime = 10; } @@ -1555,7 +1555,7 @@ bool LocalPlayer::handleMouseClick(int button) else { shared_ptr item = oldItem; - int oldCount = item != NULL ? item->count : 0; + int oldCount = item != nullptr ? item->count : 0; bool usedItem = false; if (minecraft->gameMode->useItemOn(minecraft->localplayers[GetXboxPad()], level, item, x, y, z, face, minecraft->hitResult->pos, false, &usedItem)) { @@ -1568,7 +1568,7 @@ bool LocalPlayer::handleMouseClick(int button) //app.DebugPrintf("Player %d is swinging\n",GetXboxPad()); swing(); } - if (item == NULL) + if (item == nullptr) { return false; } @@ -1587,7 +1587,7 @@ bool LocalPlayer::handleMouseClick(int button) if (mayUse && button == 1) { shared_ptr item = inventory->getSelected(); - if (item != NULL) + if (item != nullptr) { if (minecraft->gameMode->useItem(minecraft->localplayers[GetXboxPad()], level, item)) { @@ -1603,23 +1603,23 @@ void LocalPlayer::updateRichPresence() if((m_iPad!=-1)/* && !ui.GetMenuDisplayed(m_iPad)*/ ) { shared_ptr selectedItem = inventory->getSelected(); - if(selectedItem != NULL && selectedItem->id == Item::fishingRod_Id) + if(selectedItem != nullptr && selectedItem->id == Item::fishingRod_Id) { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FISHING); } - else if(selectedItem != NULL && selectedItem->id == Item::map_Id) + else if(selectedItem != nullptr && selectedItem->id == Item::map_Id) { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_MAP); } - else if ( (riding != NULL) && riding->instanceof(eTYPE_MINECART) ) + else if ( (riding != nullptr) && riding->instanceof(eTYPE_MINECART) ) { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_MINECART); } - else if ( (riding != NULL) && riding->instanceof(eTYPE_BOAT) ) + else if ( (riding != nullptr) && riding->instanceof(eTYPE_BOAT) ) { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BOATING); } - else if ( (riding != NULL) && riding->instanceof(eTYPE_PIG) ) + else if ( (riding != nullptr) && riding->instanceof(eTYPE_PIG) ) { app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_PIG); } @@ -1660,13 +1660,13 @@ float LocalPlayer::getAndResetChangeDimensionTimer() void LocalPlayer::handleCollectItem(shared_ptr item) { - if(item != NULL) + if(item != nullptr) { unsigned int itemCountAnyAux = 0; unsigned int itemCountThisAux = 0; for (unsigned int k = 0; k < inventory->items.length; ++k) { - if (inventory->items[k] != NULL) + if (inventory->items[k] != nullptr) { // do they have the item if(inventory->items[k]->id == item->id) diff --git a/Minecraft.Client/MemTexture.cpp b/Minecraft.Client/MemTexture.cpp index f587e82f1..ee3ba7981 100644 --- a/Minecraft.Client/MemTexture.cpp +++ b/Minecraft.Client/MemTexture.cpp @@ -15,7 +15,7 @@ MemTexture::MemTexture(const wstring& _url, PBYTE pbData,DWORD dwBytes, MemTextu //loadedImage=Textures::getTexture() // 4J - remember to add deletes in here for any created BufferedImages when implemented loadedImage = new BufferedImage(pbData,dwBytes); - if(processor==NULL) + if(processor==nullptr) { } diff --git a/Minecraft.Client/MinecartRenderer.cpp b/Minecraft.Client/MinecartRenderer.cpp index 29b97b7ea..6bb8b26d3 100644 --- a/Minecraft.Client/MinecartRenderer.cpp +++ b/Minecraft.Client/MinecartRenderer.cpp @@ -42,12 +42,12 @@ void MinecartRenderer::render(shared_ptr _cart, double x, double y, doub float xRot = cart->xRotO + (cart->xRot - cart->xRotO) * a; - if (p != NULL) + if (p != nullptr) { Vec3 *p0 = cart->getPosOffs(xx, yy, zz, r); Vec3 *p1 = cart->getPosOffs(xx, yy, zz, -r); - if (p0 == NULL) p0 = p; - if (p1 == NULL) p1 = p; + if (p0 == nullptr) p0 = p; + if (p1 == nullptr) p1 = p; x += p->x - xx; y += (p0->y + p1->y) / 2 - yy; @@ -80,7 +80,7 @@ void MinecartRenderer::render(shared_ptr _cart, double x, double y, doub Tile *tile = cart->getDisplayTile(); int tileData = cart->getDisplayData(); - if (tile != NULL) + if (tile != nullptr) { glPushMatrix(); diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 01e07a6c1..7048c8d01 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -84,7 +84,7 @@ // from the main thread, and have longer to run, since it's called at 20Hz instead of 60 #define DISABLE_LEVELTICK_THREAD -Minecraft *Minecraft::m_instance = NULL; +Minecraft *Minecraft::m_instance = nullptr; __int64 Minecraft::frameTimes[512]; __int64 Minecraft::tickTimes[512]; int Minecraft::frameTimePos = 0; @@ -119,33 +119,33 @@ ResourceLocation Minecraft::ALT_FONT_LOCATION = ResourceLocation(TN_ALT_FONT); Minecraft::Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet *minecraftApplet, int width, int height, bool fullscreen) { // 4J - added this block of initialisers - gameMode = NULL; + gameMode = nullptr; hasCrashed = false; timer = new Timer(SharedConstants::TICKS_PER_SECOND); - oldLevel = NULL; //4J Stu added - level = NULL; + oldLevel = nullptr; //4J Stu added + level = nullptr; levels = MultiPlayerLevelArray(3); // 4J Added - levelRenderer = NULL; + levelRenderer = nullptr; player = nullptr; cameraTargetPlayer = nullptr; - particleEngine = NULL; - user = NULL; - parent = NULL; + particleEngine = nullptr; + user = nullptr; + parent = nullptr; pause = false; - textures = NULL; - font = NULL; - screen = NULL; + textures = nullptr; + font = nullptr; + screen = nullptr; localPlayerIdx = 0; rightClickDelay = 0; // 4J Stu Added InitializeCriticalSection( &ProgressRenderer::s_progress ); InitializeCriticalSection(&m_setLevelCS); - //m_hPlayerRespawned = CreateEvent(NULL, FALSE, FALSE, NULL); + //m_hPlayerRespawned = CreateEvent(nullptr, FALSE, FALSE, nullptr); - progressRenderer = NULL; - gameRenderer = NULL; - bgLoader = NULL; + progressRenderer = nullptr; + gameRenderer = nullptr; + bgLoader = nullptr; ticks = 0; // 4J-PB - moved into the local player @@ -156,20 +156,20 @@ Minecraft::Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet orgWidth = orgHeight = 0; achievementPopup = new AchievementPopup(this); - gui = NULL; + gui = nullptr; noRender = false; humanoidModel = new HumanoidModel(0); hitResult = 0; - options = NULL; + options = nullptr; soundEngine = new SoundEngine(); - mouseHandler = NULL; - skins = NULL; + mouseHandler = nullptr; + skins = nullptr; workingDirectory = File(L""); - levelSource = NULL; - stats[0] = NULL; - stats[1] = NULL; - stats[2] = NULL; - stats[3] = NULL; + levelSource = nullptr; + stats[0] = nullptr; + stats[1] = nullptr; + stats[2] = nullptr; + stats[3] = nullptr; connectToPort = 0; workDir = File(L""); // 4J removed @@ -186,7 +186,7 @@ Minecraft::Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet orgHeight = height; this->fullscreen = fullscreen; - this->minecraftApplet = NULL; + this->minecraftApplet = nullptr; this->parent = parent; // 4J - Our actual physical frame buffer is always 1280x720 ie in a 16:9 ratio. If we want to do a 4:3 mode, we are telling the original minecraft code @@ -213,12 +213,12 @@ Minecraft::Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet for(int i=0;isoundEngine->init(NULL); + this->soundEngine->init(nullptr); #endif #ifndef DISABLE_LEVELTICK_THREAD @@ -353,7 +353,7 @@ void Minecraft::init() stats[i] = new StatsCounter(); /* 4J - TODO, 4J-JEV: Unnecessary. - Achievements::openInventory->setDescFormatter(NULL); + Achievements::openInventory->setDescFormatter(nullptr); Achievements.openInventory.setDescFormatter(new DescFormatter(){ public String format(String i18nValue) { return String.format(i18nValue, Keyboard.getKeyName(options.keyBuild.key)); @@ -414,7 +414,7 @@ void Minecraft::init() MemSect(0); gui = new Gui(this); - if (connectToIp != L"") // 4J - was NULL comparison + if (connectToIp != L"") // 4J - was nullptr comparison { // setScreen(new ConnectScreen(this, connectToIp, connectToPort)); // 4J TODO - put back in } @@ -498,30 +498,30 @@ LevelStorageSource *Minecraft::getLevelSource() void Minecraft::setScreen(Screen *screen) { - if (this->screen != NULL) + if (this->screen != nullptr) { this->screen->removed(); } #ifdef _WINDOWS64 - if (screen != NULL && g_KBMInput.IsMouseGrabbed()) + if (screen != nullptr && g_KBMInput.IsMouseGrabbed()) { g_KBMInput.SetMouseGrabbed(false); } #endif //4J Gordon: Do not force a stats save here - /*if (dynamic_cast(screen)!=NULL) + /*if (dynamic_cast(screen)!=nullptr) { stats->forceSend(); } stats->forceSave();*/ - if (screen == NULL && level == NULL) + if (screen == nullptr && level == nullptr) { screen = new TitleScreen(); } - else if (player != NULL && !ui.GetMenuDisplayed(player->GetXboxPad()) && player->getHealth() <= 0) + else if (player != nullptr && !ui.GetMenuDisplayed(player->GetXboxPad()) && player->getHealth() <= 0) { //screen = new DeathScreen(); @@ -534,18 +534,18 @@ void Minecraft::setScreen(Screen *screen) } else { - ui.NavigateToScene(player->GetXboxPad(),eUIScene_DeathMenu,NULL); + ui.NavigateToScene(player->GetXboxPad(),eUIScene_DeathMenu,nullptr); } } - if (dynamic_cast(screen)!=NULL) + if (dynamic_cast(screen)!=nullptr) { options->renderDebug = false; gui->clearMessages(); } this->screen = screen; - if (screen != NULL) + if (screen != nullptr) { // releaseMouse(); // 4J - removed ScreenSizeCalculator ssc(options, width, height); @@ -561,7 +561,7 @@ void Minecraft::setScreen(Screen *screen) // 4J-PB - if a screen has been set, go into menu mode // it's possible that player doesn't exist here yet - /*if(screen!=NULL) + /*if(screen!=nullptr) { if(player && player->GetXboxPad()!=-1) { @@ -598,7 +598,7 @@ void Minecraft::destroy() stats->forceSave();*/ // try { - setLevel(NULL); + setLevel(nullptr); // } catch (Throwable e) { // } @@ -645,11 +645,11 @@ void Minecraft::run() AABB::resetPool(); Vec3::resetPool(); - // if (parent == NULL && Display.isCloseRequested()) { // 4J - removed + // if (parent == nullptr && Display.isCloseRequested()) { // 4J - removed // stop(); // } - if (pause && level != NULL) + if (pause && level != nullptr) { float lastA = timer->a; timer->advanceTime(); @@ -682,14 +682,14 @@ void Minecraft::run() soundEngine->update(player, timer->a); glEnable(GL_TEXTURE_2D); - if (level != NULL) level->updateLights(); + if (level != nullptr) level->updateLights(); // if (!Keyboard::isKeyDown(Keyboard.KEY_F7)) Display.update(); // 4J - removed - if (player != NULL && player->isInWall()) options->thirdPersonView = false; + if (player != nullptr && player->isInWall()) options->thirdPersonView = false; if (!noRender) { - if (gameMode != NULL) gameMode->render(timer->a); + if (gameMode != nullptr) gameMode->render(timer->a); gameRenderer->render(timer->a); } @@ -723,7 +723,7 @@ void Minecraft::run() // checkScreenshot(); // 4J - removed /* 4J - removed - if (parent != NULL && !fullscreen) + if (parent != nullptr && !fullscreen) { if (parent.getWidth() != width || parent.getHeight() != height) { @@ -738,7 +738,7 @@ void Minecraft::run() */ checkGlError(L"Post render"); frames++; - pause = !isClientSide() && screen != NULL && screen->isPauseScreen(); + pause = !isClientSide() && screen != nullptr && screen->isPauseScreen(); while (System::currentTimeMillis() >= lastTime + 1000) { @@ -792,7 +792,7 @@ bool Minecraft::setLocalPlayerIdx(int idx) localPlayerIdx = idx; // If the player is not null, but the game mode is then this is just a temp player // whose only real purpose is to hold the viewport position - if( localplayers[idx] == NULL || localgameModes[idx] == NULL ) return false; + if( localplayers[idx] == nullptr || localgameModes[idx] == nullptr ) return false; gameMode = localgameModes[idx]; player = localplayers[idx]; @@ -816,7 +816,7 @@ void Minecraft::updatePlayerViewportAssignments() int viewportsRequired = 0; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - if( localplayers[i] != NULL ) viewportsRequired++; + if( localplayers[i] != nullptr ) viewportsRequired++; } if( viewportsRequired == 3 ) viewportsRequired = 4; @@ -826,7 +826,7 @@ void Minecraft::updatePlayerViewportAssignments() // Single viewport for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - if( localplayers[i] != NULL ) localplayers[i]->m_iScreenSection = C4JRender::VIEWPORT_TYPE_FULLSCREEN; + if( localplayers[i] != nullptr ) localplayers[i]->m_iScreenSection = C4JRender::VIEWPORT_TYPE_FULLSCREEN; } } else if( viewportsRequired == 2 ) @@ -835,7 +835,7 @@ void Minecraft::updatePlayerViewportAssignments() int found = 0; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - if( localplayers[i] != NULL ) + if( localplayers[i] != nullptr ) { // Primary player settings decide what the mode is if(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_SplitScreenVertical)) @@ -858,7 +858,7 @@ void Minecraft::updatePlayerViewportAssignments() for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - if( localplayers[i] != NULL ) + if( localplayers[i] != nullptr ) { // 4J Stu - If the game hasn't started, ignore current allocations (as the players won't have seen them) @@ -882,7 +882,7 @@ void Minecraft::updatePlayerViewportAssignments() // Found which quadrants are currently in use, now allocate out any spares that are required for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - if( localplayers[i] != NULL ) + if( localplayers[i] != nullptr ) { if( ( localplayers[i]->m_iScreenSection < C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT ) || ( localplayers[i]->m_iScreenSection > C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT ) ) @@ -918,22 +918,22 @@ void Minecraft::updatePlayerViewportAssignments() bool Minecraft::addLocalPlayer(int idx) { //int iLocalPlayerC=app.GetLocalPlayerCount(); - if( m_pendingLocalConnections[idx] != NULL ) + if( m_pendingLocalConnections[idx] != nullptr ) { // 4J Stu - Should we ever be in a state where this happens? assert(false); m_pendingLocalConnections[idx]->close(); } m_connectionFailed[idx] = false; - m_pendingLocalConnections[idx] = NULL; + m_pendingLocalConnections[idx] = nullptr; bool success=g_NetworkManager.AddLocalPlayerByUserIndex(idx); if(success) { app.DebugPrintf("Adding temp local player on pad %d\n", idx); - localplayers[idx] = shared_ptr( new MultiplayerLocalPlayer(this, level, user, NULL ) ); - localgameModes[idx] = NULL; + localplayers[idx] = shared_ptr( new MultiplayerLocalPlayer(this, level, user, nullptr ) ); + localgameModes[idx] = nullptr; updatePlayerViewportAssignments(); @@ -946,7 +946,7 @@ bool Minecraft::addLocalPlayer(int idx) // send the message for(int i=0;i Minecraft::createExtraLocalPlayer(int idx, const wstring& name, int iPad, int iDimension, ClientConnection *clientConnection /*= NULL*/,MultiPlayerLevel *levelpassedin) +shared_ptr Minecraft::createExtraLocalPlayer(int idx, const wstring& name, int iPad, int iDimension, ClientConnection *clientConnection /*= nullptr*/,MultiPlayerLevel *levelpassedin) { - if( clientConnection == NULL) return nullptr; + if( clientConnection == nullptr) return nullptr; if( clientConnection == m_pendingLocalConnections[idx] ) { int tempScreenSection = C4JRender::VIEWPORT_TYPE_FULLSCREEN; - if( localplayers[idx] != NULL && localgameModes[idx] == NULL ) + if( localplayers[idx] != nullptr && localgameModes[idx] == nullptr ) { // A temp player displaying a connecting screen tempScreenSection = localplayers[idx]->m_iScreenSection; @@ -996,7 +996,7 @@ shared_ptr Minecraft::createExtraLocalPlayer(int idx, co user->name = name; // Don't need this any more - m_pendingLocalConnections[idx] = NULL; + m_pendingLocalConnections[idx] = nullptr; // Add the connection to the level which will now take responsibility for ticking it // 4J-PB - can't use the dimension from localplayers[idx], since there may be no localplayers at this point @@ -1043,7 +1043,7 @@ shared_ptr Minecraft::createExtraLocalPlayer(int idx, co // Compatibility rule for Win64 id migration // host keeps legacy host XUID, non-host uses persistent uid.dat XUID. INetworkPlayer *localNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx); - if(localNetworkPlayer != NULL && localNetworkPlayer->IsHost()) + if(localNetworkPlayer != nullptr && localNetworkPlayer->IsHost()) { playerXUIDOffline = Win64Xuid::GetLegacyEmbeddedHostXuid(); } @@ -1060,11 +1060,11 @@ shared_ptr Minecraft::createExtraLocalPlayer(int idx, co localplayers[idx]->m_iScreenSection = tempScreenSection; - if( levelpassedin == NULL) level->addEntity(localplayers[idx]); // Don't add if we're passing the level in, we only do this from the client connection & we'll be handling adding it ourselves + if( levelpassedin == nullptr) level->addEntity(localplayers[idx]); // Don't add if we're passing the level in, we only do this from the client connection & we'll be handling adding it ourselves localplayers[idx]->SetXboxPad(iPad); - if( localplayers[idx]->input != NULL ) delete localplayers[idx]->input; + if( localplayers[idx]->input != nullptr ) delete localplayers[idx]->input; localplayers[idx]->input = new Input(); localplayers[idx]->resetPos(); @@ -1093,7 +1093,7 @@ void Minecraft::storeExtraLocalPlayer(int idx) { localplayers[idx] = player; - if( localplayers[idx]->input != NULL ) delete localplayers[idx]->input; + if( localplayers[idx]->input != nullptr ) delete localplayers[idx]->input; localplayers[idx]->input = new Input(); if(ProfileManager.IsSignedIn(idx)) @@ -1105,14 +1105,14 @@ void Minecraft::storeExtraLocalPlayer(int idx) void Minecraft::removeLocalPlayerIdx(int idx) { bool updateXui = true; - if(localgameModes[idx] != NULL) + if(localgameModes[idx] != nullptr) { if( getLevel( localplayers[idx]->dimension )->isClientSide ) { shared_ptr mplp = localplayers[idx]; ( (MultiPlayerLevel *)getLevel( localplayers[idx]->dimension ) )->removeClientConnection(mplp->connection, true); delete mplp->connection; - mplp->connection = NULL; + mplp->connection = nullptr; g_NetworkManager.RemoveLocalPlayerByUserIndex(idx); } getLevel( localplayers[idx]->dimension )->removeEntity(localplayers[idx]); @@ -1127,13 +1127,13 @@ void Minecraft::removeLocalPlayerIdx(int idx) playerLeftTutorial( idx ); delete localgameModes[idx]; - localgameModes[idx] = NULL; + localgameModes[idx] = nullptr; } - else if( m_pendingLocalConnections[idx] != NULL ) + else if( m_pendingLocalConnections[idx] != nullptr ) { m_pendingLocalConnections[idx]->sendAndDisconnect( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );; delete m_pendingLocalConnections[idx]; - m_pendingLocalConnections[idx] = NULL; + m_pendingLocalConnections[idx] = nullptr; g_NetworkManager.RemoveLocalPlayerByUserIndex(idx); } else @@ -1158,18 +1158,18 @@ void Minecraft::removeLocalPlayerIdx(int idx) /* // If we are removing the primary player then there can't be a valid gamemode left anymore, this // pointer will be referring to the one we've just deleted - gameMode = NULL; + gameMode = nullptr; // Remove references to player - player = NULL; - cameraTargetPlayer = NULL; - EntityRenderDispatcher::instance->cameraEntity = NULL; - TileEntityRenderDispatcher::instance->cameraEntity = NULL; + player = nullptr; + cameraTargetPlayer = nullptr; + EntityRenderDispatcher::instance->cameraEntity = nullptr; + TileEntityRenderDispatcher::instance->cameraEntity = nullptr; */ } else if( updateXui ) { gameRenderer->DisableUpdateThread(); - levelRenderer->setLevel(idx, NULL); + levelRenderer->setLevel(idx, nullptr); gameRenderer->EnableUpdateThread(); ui.CloseUIScenes(idx,true); updatePlayerViewportAssignments(); @@ -1197,16 +1197,16 @@ void Minecraft::applyFrameMouseLook() // Per-frame mouse look: consume mouse deltas every frame instead of waiting // for the 20Hz game tick. Apply the same delta to both xRot/yRot AND xRotO/yRotO // so the render interpolation instantly reflects the change without waiting for a tick. - if (level == NULL) return; + if (level == nullptr) return; for (int i = 0; i < XUSER_MAX_COUNT; i++) { - if (localplayers[i] == NULL) continue; + if (localplayers[i] == nullptr) continue; int iPad = localplayers[i]->GetXboxPad(); if (iPad != 0) continue; // Mouse only applies to pad 0 if (!g_KBMInput.IsMouseGrabbed()) continue; - if (localgameModes[iPad] == NULL) continue; + if (localgameModes[iPad] == nullptr) continue; float rawDx, rawDy; g_KBMInput.ConsumeMouseDelta(rawDx, rawDy); @@ -1265,12 +1265,12 @@ void Minecraft::run_middle() AABB::resetPool(); Vec3::resetPool(); - // if (parent == NULL && Display.isCloseRequested()) { // 4J - removed + // if (parent == nullptr && Display.isCloseRequested()) { // 4J - removed // stop(); // } // 4J-PB - AUTOSAVE TIMER - only in the full game and if the player is the host - if(level!=NULL && ProfileManager.IsFullVersion() && g_NetworkManager.IsHost()) + if(level!=nullptr && ProfileManager.IsFullVersion() && g_NetworkManager.IsHost()) { /*if(!bAutosaveTimerSet) { @@ -1390,7 +1390,7 @@ void Minecraft::run_middle() } // When we go into the first loaded level, check if the console has active joypads that are not in the game, and bring up the quadrant display to remind them to press start (if the session has space) - if(level!=NULL && bFirstTimeIntoGame && g_NetworkManager.SessionHasSpace()) + if(level!=nullptr && bFirstTimeIntoGame && g_NetworkManager.SessionHasSpace()) { // have a short delay before the display if(iFirstTimeCountdown==0) @@ -1401,7 +1401,7 @@ void Minecraft::run_middle() { for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - if((localplayers[i] == NULL) && InputManager.IsPadConnected(i)) + if((localplayers[i] == nullptr) && InputManager.IsPadConnected(i)) { if(!ui.PressStartPlaying(i)) { @@ -1418,10 +1418,10 @@ void Minecraft::run_middle() for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { #ifdef __ORBIS__ - if ( m_pPsPlusUpsell != NULL && m_pPsPlusUpsell->hasResponse() && m_pPsPlusUpsell->m_userIndex == i ) + if ( m_pPsPlusUpsell != nullptr && m_pPsPlusUpsell->hasResponse() && m_pPsPlusUpsell->m_userIndex == i ) { delete m_pPsPlusUpsell; - m_pPsPlusUpsell = NULL; + m_pPsPlusUpsell = nullptr; if ( ProfileManager.HasPlayStationPlus(i) ) { @@ -1604,7 +1604,7 @@ void Minecraft::run_middle() // 4J Stu - Check that content restriction information has been received if( !g_NetworkManager.IsLocalGame() ) { - tryJoin = tryJoin && ProfileManager.GetChatAndContentRestrictions(i,true,NULL,NULL,NULL); + tryJoin = tryJoin && ProfileManager.GetChatAndContentRestrictions(i,true,nullptr,nullptr,nullptr); } #endif if(tryJoin) @@ -1644,7 +1644,7 @@ void Minecraft::run_middle() { #ifdef __ORBIS__ bool contentRestricted = false; - ProfileManager.GetChatAndContentRestrictions(i,false,NULL,&contentRestricted,NULL); // TODO! + ProfileManager.GetChatAndContentRestrictions(i,false,nullptr,&contentRestricted,nullptr); // TODO! if (!g_NetworkManager.IsLocalGame() && contentRestricted) { @@ -1672,7 +1672,7 @@ void Minecraft::run_middle() if(g_NetworkManager.IsLocalGame() == false) { bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(i,false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(i,false,&chatRestricted,nullptr,nullptr); if(chatRestricted) { ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, i ); @@ -1685,7 +1685,7 @@ void Minecraft::run_middle() { // create the localplayer shared_ptr player = localplayers[i]; - if( player == NULL) + if( player == nullptr) { player = createExtraLocalPlayer(i, (convStringToWstring( ProfileManager.GetGamertag(i) )).c_str(), i, level->dimension->id); } @@ -1759,7 +1759,7 @@ void Minecraft::run_middle() int firstEmptyUser = 0; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - if(localplayers[i] == NULL) + if(localplayers[i] == nullptr) { firstEmptyUser = i; break; @@ -1793,7 +1793,7 @@ void Minecraft::run_middle() } #endif - if (pause && level != NULL) + if (pause && level != nullptr) { float lastA = timer->a; timer->advanceTime(); @@ -1822,13 +1822,13 @@ void Minecraft::run_middle() { // 4J - If we are waiting for this connection to do something, then tick it here. // This replaces many of the original Java scenes which would tick the connection while showing that scene - if( m_pendingLocalConnections[idx] != NULL ) + if( m_pendingLocalConnections[idx] != nullptr ) { m_pendingLocalConnections[idx]->tick(); } // reset the player inactive tick - if(localplayers[idx]!=NULL) + if(localplayers[idx]!=nullptr) { // any input received? if((localplayers[idx]->ullButtonsPressed!=0) || InputManager.GetJoypadStick_LX(idx,false)!=0.0f || @@ -1912,8 +1912,8 @@ void Minecraft::run_middle() // if (!Keyboard::isKeyDown(Keyboard.KEY_F7)) Display.update(); // 4J - removed // 4J-PB - changing this to be per player - //if (player != NULL && player->isInWall()) options->thirdPersonView = false; - if (player != NULL && player->isInWall()) player->SetThirdPersonView(0); + //if (player != nullptr && player->isInWall()) options->thirdPersonView = false; + if (player != nullptr && player->isInWall()) player->SetThirdPersonView(0); if (!noRender) { @@ -2023,7 +2023,7 @@ void Minecraft::run_middle() // checkScreenshot(); // 4J - removed /* 4J - removed - if (parent != NULL && !fullscreen) + if (parent != nullptr && !fullscreen) { if (parent.getWidth() != width || parent.getHeight() != height) { @@ -2040,7 +2040,7 @@ void Minecraft::run_middle() checkGlError(L"Post render"); MemSect(0); frames++; - //pause = !isClientSide() && screen != NULL && screen->isPauseScreen(); + //pause = !isClientSide() && screen != nullptr && screen->isPauseScreen(); //pause = g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()); pause = app.IsAppPaused(); @@ -2092,7 +2092,7 @@ void Minecraft::emergencySave() levelRenderer->clear(); AABB::clearPool(); Vec3::clearPool(); - setLevel(NULL); + setLevel(nullptr); } void Minecraft::renderFpsMeter(__int64 tickTime) @@ -2191,7 +2191,7 @@ void Minecraft::stop() void Minecraft::pauseGame() { - if (screen != NULL) return; + if (screen != nullptr) return; // setScreen(new PauseScreen()); // 4J - TODO put back in } @@ -2203,7 +2203,7 @@ void Minecraft::resize(int width, int height) this->width = width; this->height = height; - if (screen != NULL) + if (screen != nullptr) { ScreenSizeCalculator ssc(options, width, height); int screenWidth = ssc.getWidth(); @@ -2270,10 +2270,10 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) gameRenderer->pick(1); #if 0 // 4J - removed - we don't use ChunkCache anymore - if (player != NULL) + if (player != nullptr) { ChunkSource *cs = level->getChunkSource(); - if (dynamic_cast(cs) != NULL) + if (dynamic_cast(cs) != nullptr) { ChunkCache *spcc = (ChunkCache *)cs; @@ -2287,7 +2287,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) // soundEngine.playMusicTick(); - if (!pause && level != NULL) gameMode->tick(); + if (!pause && level != nullptr) gameMode->tick(); MemSect(31); glBindTexture(GL_TEXTURE_2D, textures->loadTexture(TN_TERRAIN)); //L"/terrain.png")); MemSect(0); @@ -2305,33 +2305,33 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) * progressRenderer.progressStagePercentage(0); } else { * serverConnection.tick(); serverConnection.sendPosition(player); } } */ - if (screen == NULL && player != NULL ) + if (screen == nullptr && player != nullptr ) { if (player->getHealth() <= 0 && !ui.GetMenuDisplayed(iPad) ) { - setScreen(NULL); + setScreen(nullptr); } - else if (player->isSleeping() && level != NULL && level->isClientSide) + else if (player->isSleeping() && level != nullptr && level->isClientSide) { // setScreen(new InBedChatScreen()); // 4J - TODO put back in } } - else if (screen != NULL && (dynamic_cast(screen)!=NULL) && !player->isSleeping()) + else if (screen != nullptr && (dynamic_cast(screen)!=nullptr) && !player->isSleeping()) { - setScreen(NULL); + setScreen(nullptr); } - if (screen != NULL) + if (screen != nullptr) { player->missTime = 10000; player->lastClickTick[0] = ticks + 10000; player->lastClickTick[1] = ticks + 10000; } - if (screen != NULL) + if (screen != nullptr) { screen->updateEvents(); - if (screen != NULL) + if (screen != nullptr) { screen->particles->tick(); screen->tick(); @@ -2339,13 +2339,13 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } #ifdef _WINDOWS64 - if ((screen != NULL || ui.GetMenuDisplayed(iPad)) && g_KBMInput.IsMouseGrabbed()) + if ((screen != nullptr || ui.GetMenuDisplayed(iPad)) && g_KBMInput.IsMouseGrabbed()) { g_KBMInput.SetMouseGrabbed(false); } #endif - if (screen == NULL && !ui.GetMenuDisplayed(iPad) ) + if (screen == nullptr && !ui.GetMenuDisplayed(iPad) ) { #ifdef _WINDOWS64 if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsWindowFocused()) @@ -2457,7 +2457,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) *piAlt=-1; // 4J-PB another special case for when the player is sleeping in a bed - if (player->isSleeping() && (level != NULL) && level->isClientSide) + if (player->isSleeping() && (level != nullptr) && level->isClientSide) { *piUse=IDS_TOOLTIPS_WAKEUP; } @@ -2514,7 +2514,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) // Check that we are actually hungry so will eat this item { FoodItem *food = static_cast(itemInstance->getItem()); - if (food != NULL && food->canEat(player)) + if (food != nullptr && food->canEat(player)) { *piUse=IDS_TOOLTIPS_EAT; } @@ -2592,7 +2592,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } } - if (hitResult!=NULL) + if (hitResult!=nullptr) { switch(hitResult->type) { @@ -2607,7 +2607,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) int iTileID=level->getTile(x,y ,z ); int iData = level->getData(x, y, z); - if( gameMode != NULL && gameMode->getTutorial() != NULL ) + if( gameMode != nullptr && gameMode->getTutorial() != nullptr ) { // 4J Stu - For the tutorial we want to be able to record what items we look at so that we can give hints gameMode->getTutorial()->onLookAt(iTileID,iData); @@ -2621,7 +2621,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) * for noteblocks, enderportals and flowerpots in case of non-standard items. * (ie. ignite behaviour) */ - if (bUseItemOn && itemInstance!=NULL) + if (bUseItemOn && itemInstance!=nullptr) { switch (itemInstance->getItem()->id) { @@ -2716,7 +2716,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case Tile::chest_Id: *piAction = IDS_TOOLTIPS_MINE; - *piUse = (Tile::chest->getContainer(level,x,y,z) != NULL) ? IDS_TOOLTIPS_OPEN : -1; + *piUse = (Tile::chest->getContainer(level,x,y,z) != nullptr) ? IDS_TOOLTIPS_OPEN : -1; break; case Tile::enderChest_Id: @@ -2785,7 +2785,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) break; case Tile::jukebox_Id: - if (!bUseItemOn && itemInstance!=NULL) + if (!bUseItemOn && itemInstance!=nullptr) { int iID=itemInstance->getItem()->id; if ( (iID>=Item::record_01_Id) && (iID<=Item::record_12_Id) ) @@ -2805,7 +2805,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) break; case Tile::flowerPot_Id: - if ( !bUseItemOn && (itemInstance != NULL) && (iData == 0) ) + if ( !bUseItemOn && (itemInstance != nullptr) && (iData == 0) ) { int iID = itemInstance->getItem()->id; if (iID<256) // is it a tile? @@ -2866,7 +2866,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) case HitResult::ENTITY: eINSTANCEOF entityType = hitResult->entity->GetType(); - if ( (gameMode != NULL) && (gameMode->getTutorial() != NULL) ) + if ( (gameMode != nullptr) && (gameMode->getTutorial() != nullptr) ) { // 4J Stu - For the tutorial we want to be able to record what items we look at so that we can give hints gameMode->getTutorial()->onLookAtEntity(hitResult->entity); @@ -2877,7 +2877,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { heldItem = player->inventory->getSelected(); } - int heldItemId = heldItem != NULL ? heldItem->getItem()->id : -1; + int heldItemId = heldItem != nullptr ? heldItem->getItem()->id : -1; switch(entityType) { @@ -3312,7 +3312,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) shared_ptr itemFrame = dynamic_pointer_cast(hitResult->entity); // is the frame occupied? - if(itemFrame->getItem()!=NULL) + if(itemFrame->getItem()!=nullptr) { // rotate the item *piUse=IDS_TOOLTIPS_ROTATE; @@ -3515,7 +3515,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { player->inventory->swapPaint(wheel); - if( gameMode != NULL && gameMode->getTutorial() != NULL ) + if( gameMode != nullptr && gameMode->getTutorial() != nullptr ) { // 4J Stu - For the tutorial we want to be able to record what items we are using so that we can give hints gameMode->getTutorial()->onSelectedItemChanged(player->inventory->getSelected()); @@ -3665,7 +3665,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) app.EnableDebugOverlay(options->renderDebug,iPad); #else // 4J Stu - The xbox uses a completely different way of navigating to this scene - ui.NavigateToScene(0, eUIScene_DebugOverlay, NULL, eUILayer_Debug); + ui.NavigateToScene(0, eUIScene_DebugOverlay, nullptr, eUILayer_Debug); #endif #endif } @@ -3729,7 +3729,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) app.LoadCreativeMenu(iPad,player); } // 4J-PB - Microsoft request that we use the 3x3 crafting if someone presses X while at the workbench - else if ((hitResult!=NULL) && (hitResult->type == HitResult::TILE) && (level->getTile(hitResult->x, hitResult->y, hitResult->z) == Tile::workBench_Id)) + else if ((hitResult!=nullptr) && (hitResult->type == HitResult::TILE) && (level->getTile(hitResult->x, hitResult->y, hitResult->z) == Tile::workBench_Id)) { //ui.PlayUISFX(eSFX_Press); //app.LoadXuiCrafting3x3Menu(iPad,player,hitResult->x, hitResult->y, hitResult->z); @@ -3751,7 +3751,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { app.DebugPrintf("PAUSE PRESS PROCESSING - ipad = %d, NavigateToScene\n",player->GetXboxPad()); ui.PlayUISFX(eSFX_Press); - ui.NavigateToScene(iPad, eUIScene_PauseMenu, NULL, eUILayer_Scene); + ui.NavigateToScene(iPad, eUIScene_PauseMenu, nullptr, eUILayer_Scene); } if((player->ullButtonsPressed&(1LL<isInputAllowed(MINECRAFT_ACTION_DROP)) @@ -3786,12 +3786,12 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) // Dropping items happens over network, so if we only have one then assume that we dropped it and should hide the item int iCount=0; - if(selectedItem != NULL) iCount=selectedItem->GetCount(); - if(selectedItem != NULL && !( (player->ullButtonsPressed&(1LL<GetCount() == 1)) + if(selectedItem != nullptr) iCount=selectedItem->GetCount(); + if(selectedItem != nullptr && !( (player->ullButtonsPressed&(1LL<GetCount() == 1)) { itemName = selectedItem->getHoverName(); } - if( !(player->ullButtonsPressed&(1LL<GetCount() <= 1) ) ui.SetSelectedItem( iPad, itemName ); + if( !(player->ullButtonsPressed&(1LL<GetCount() <= 1) ) ui.SetSelectedItem( iPad, itemName ); } } else @@ -3799,7 +3799,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) // 4J-PB if (InputManager.GetValue(iPad, ACTION_MENU_CANCEL) > 0 && gameMode->isInputAllowed(ACTION_MENU_CANCEL)) { - setScreen(NULL); + setScreen(nullptr); } } @@ -3823,7 +3823,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) #if 0 // 4J - TODO - some replacement for input handling... - if (screen == NULL || screen.passEvents) + if (screen == nullptr || screen.passEvents) { while (Mouse.next()) { @@ -3966,9 +3966,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) } #endif - if (level != NULL) + if (level != nullptr) { - if (player != NULL) + if (player != nullptr) { recheckPlayerIn++; if (recheckPlayerIn == 30) @@ -4014,7 +4014,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) // 4J - this doesn't fully tick the animateTick here, but does register this player's position. The actual // work is now done in Level::animateTickDoWork() so we can take into account multiple players in the one level. - if (!pause && levels[i] != NULL) levels[i]->animateTick(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); + if (!pause && levels[i] != nullptr) levels[i]->animateTick(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); if( levelsTickedFlags & ( 1 << i ) ) continue; // Don't tick further if we've already ticked this level this frame levelsTickedFlags |= (1 << i); @@ -4027,7 +4027,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) // level.addEntity(player); // } // } - if( levels[i] != NULL ) + if( levels[i] != nullptr ) { if (!pause) { @@ -4043,7 +4043,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) int currPlayerIdx = getLocalPlayerIdx(); for( int idx = 0; idx < XUSER_MAX_COUNT; idx++ ) { - if(localplayers[idx]!=NULL) + if(localplayers[idx]!=nullptr) { if( localplayers[idx]->level == levels[i] ) { @@ -4121,7 +4121,7 @@ void Minecraft::reloadSound() bool Minecraft::isClientSide() { - return level != NULL && level->isClientSide; + return level != nullptr && level->isClientSide; } void Minecraft::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, const wstring& levelName, LevelSettings *levelSettings) @@ -4140,8 +4140,8 @@ bool Minecraft::loadSlot(const wstring& userName, int slot) void Minecraft::releaseLevel(int message) { - //this->level = NULL; - setLevel(NULL, message); + //this->level = nullptr; + setLevel(nullptr, message); } // 4J Stu - This code was within setLevel, but I moved it out so that I can call it at a better @@ -4172,14 +4172,14 @@ MultiPlayerLevel *Minecraft::getLevel(int dimension) // 4J Stu - Removed as redundant with default values in params. //void Minecraft::setLevel(Level *level, bool doForceStatsSave /*= true*/) //{ -// setLevel(level, -1, NULL, doForceStatsSave); +// setLevel(level, -1, nullptr, doForceStatsSave); //} // Also causing ambiguous call for some reason // as it is matching shared_ptr from the func below with bool from this one //void Minecraft::setLevel(Level *level, const wstring& message, bool doForceStatsSave /*= true*/) //{ -// setLevel(level, message, NULL, doForceStatsSave); +// setLevel(level, message, nullptr, doForceStatsSave); //} void Minecraft::forceaddLevel(MultiPlayerLevel *level) @@ -4190,13 +4190,13 @@ void Minecraft::forceaddLevel(MultiPlayerLevel *level) else levels[0] = level; } -void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_ptr forceInsertPlayer /*=NULL*/, bool doForceStatsSave /*=true*/, bool bPrimaryPlayerSignedOut /*=false*/) +void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_ptr forceInsertPlayer /*=nullptr*/, bool doForceStatsSave /*=true*/, bool bPrimaryPlayerSignedOut /*=false*/) { EnterCriticalSection(&m_setLevelCS); bool playerAdded = false; this->cameraTargetPlayer = nullptr; - if(progressRenderer != NULL) + if(progressRenderer != nullptr) { this->progressRenderer->progressStart(message); this->progressRenderer->progressStage(-1); @@ -4205,80 +4205,80 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt // 4J-PB - since we now play music in the menu, just let it keep playing //soundEngine->playStreaming(L"", 0, 0, 0, 0, 0); - // 4J - stop update thread from processing this level, which blocks until it is safe to move on - will be re-enabled if we set the level to be non-NULL + // 4J - stop update thread from processing this level, which blocks until it is safe to move on - will be re-enabled if we set the level to be non-nullptr gameRenderer->DisableUpdateThread(); for(unsigned int i = 0; i < levels.length; ++i) { - // 4J We only need to save out in multiplayer is we are setting the level to NULL + // 4J We only need to save out in multiplayer is we are setting the level to nullptr // If we ever go back to making single player only then this will not work properly! - if (levels[i] != NULL && level == NULL) + if (levels[i] != nullptr && level == nullptr) { // 4J Stu - This is really only relevant for single player (ie not what we do at the moment) - if((doForceStatsSave==true) && player!=NULL) + if((doForceStatsSave==true) && player!=nullptr) forceStatsSave(player->GetXboxPad() ); - // 4J Stu - Added these for the case when we exit a level so we are setting the level to NULL - // The level renderer needs to have it's stored level set to NULL so that it doesn't break next time we set one - if (levelRenderer != NULL) + // 4J Stu - Added these for the case when we exit a level so we are setting the level to nullptr + // The level renderer needs to have it's stored level set to nullptr so that it doesn't break next time we set one + if (levelRenderer != nullptr) { for(DWORD p = 0; p < XUSER_MAX_COUNT; ++p) { - levelRenderer->setLevel(p, NULL); + levelRenderer->setLevel(p, nullptr); } } - if (particleEngine != NULL) particleEngine->setLevel(NULL); + if (particleEngine != nullptr) particleEngine->setLevel(nullptr); } } - // 4J If we are setting the level to NULL then we are exiting, so delete the levels - if( level == NULL ) + // 4J If we are setting the level to nullptr then we are exiting, so delete the levels + if( level == nullptr ) { - if(levels[0]!=NULL) + if(levels[0]!=nullptr) { delete levels[0]; - levels[0] = NULL; + levels[0] = nullptr; // Both level share the same savedDataStorage - if(levels[1]!=NULL) levels[1]->savedDataStorage = NULL; + if(levels[1]!=nullptr) levels[1]->savedDataStorage = nullptr; } - if(levels[1]!=NULL) + if(levels[1]!=nullptr) { delete levels[1]; - levels[1] = NULL; + levels[1] = nullptr; } - if(levels[2]!=NULL) + if(levels[2]!=nullptr) { delete levels[2]; - levels[2] = NULL; + levels[2] = nullptr; } // Delete all the player objects for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { shared_ptr mplp = localplayers[idx]; - if(mplp != NULL && mplp->connection != NULL ) + if(mplp != nullptr && mplp->connection != nullptr ) { delete mplp->connection; - mplp->connection = NULL; + mplp->connection = nullptr; } - if( localgameModes[idx] != NULL ) + if( localgameModes[idx] != nullptr ) { delete localgameModes[idx]; - localgameModes[idx] = NULL; + localgameModes[idx] = nullptr; } - if( m_pendingLocalConnections[idx] != NULL ) + if( m_pendingLocalConnections[idx] != nullptr ) { delete m_pendingLocalConnections[idx]; - m_pendingLocalConnections[idx] = NULL; + m_pendingLocalConnections[idx] = nullptr; } localplayers[idx] = nullptr; } // If we are removing the primary player then there can't be a valid gamemode left anymore, this // pointer will be referring to the one we've just deleted - gameMode = NULL; + gameMode = nullptr; // Remove references to player player = nullptr; cameraTargetPlayer = nullptr; @@ -4287,7 +4287,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt } this->level = level; - if (level != NULL) + if (level != nullptr) { int dimId = level->dimension->id; if (dimId == -1) levels[1] = level; @@ -4296,7 +4296,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt // If no player has been set, then this is the first level to be set this game, so set up // a primary player & initialise some other things - if (player == NULL) + if (player == nullptr) { int iPrimaryPlayer = ProfileManager.GetPrimaryPad(); @@ -4317,7 +4317,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt // On Windows, the implementation has been changed to use a per-client pseudo XUID based on `uid.dat`. // To maintain player data compatibility with existing worlds, the world host (the first player) will use the previous embedded pseudo XUID. INetworkPlayer *localNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(iPrimaryPlayer); - if(localNetworkPlayer != NULL && localNetworkPlayer->IsHost()) + if(localNetworkPlayer != nullptr && localNetworkPlayer->IsHost()) { playerXUIDOffline = Win64Xuid::GetLegacyEmbeddedHostXuid(); } @@ -4340,32 +4340,32 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt for(int i=0;iresetPos(); // gameMode.initPlayer(player); - if (level != NULL) + if (level != nullptr) { level->addEntity(player); playerAdded = true; } } - if(player->input != NULL) delete player->input; + if(player->input != nullptr) delete player->input; player->input = new Input(); - if (levelRenderer != NULL) levelRenderer->setLevel(player->GetXboxPad(), level); - if (particleEngine != NULL) particleEngine->setLevel(level); + if (levelRenderer != nullptr) levelRenderer->setLevel(player->GetXboxPad(), level); + if (particleEngine != nullptr) particleEngine->setLevel(level); #if 0 // 4J - removed - we don't use ChunkCache anymore ChunkSource *cs = level->getChunkSource(); - if (dynamic_cast(cs) != NULL) + if (dynamic_cast(cs) != nullptr) { ChunkCache *spcc = (ChunkCache *)cs; @@ -4380,7 +4380,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt for(int i=0;iclearAll(); player = nullptr; - // Clear all players if the new level is NULL + // Clear all players if the new level is nullptr for(int i=0;iclose(); - m_pendingLocalConnections[i] = NULL; + if( m_pendingLocalConnections[i] != nullptr ) m_pendingLocalConnections[i]->close(); + m_pendingLocalConnections[i] = nullptr; localplayers[i] = nullptr; - localgameModes[i] = NULL; + localgameModes[i] = nullptr; } } @@ -4412,7 +4412,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt void Minecraft::prepareLevel(int title) { - if(progressRenderer != NULL) + if(progressRenderer != nullptr) { this->progressRenderer->progressStart(title); this->progressRenderer->progressStage(IDS_PROGRESS_BUILDING_TERRAIN); @@ -4425,7 +4425,7 @@ void Minecraft::prepareLevel(int title) ChunkSource *cs = level->getChunkSource(); Pos *spawnPos = level->getSharedSpawnPos(); - if (player != NULL) + if (player != nullptr) { spawnPos->x = static_cast(player->x); spawnPos->z = static_cast(player->z); @@ -4433,7 +4433,7 @@ void Minecraft::prepareLevel(int title) #if 0 // 4J - removed - we don't use ChunkCache anymore - if (dynamic_cast(cs)!=NULL) + if (dynamic_cast(cs)!=nullptr) { ChunkCache *spcc = (ChunkCache *) cs; @@ -4445,7 +4445,7 @@ void Minecraft::prepareLevel(int title) { for (int z = -r; z <= r; z += 16) { - if(progressRenderer != NULL) this->progressRenderer->progressStagePercentage((pp++) * 100 / max); + if(progressRenderer != nullptr) this->progressRenderer->progressStagePercentage((pp++) * 100 / max); level->getTile(spawnPos->x + x, 64, spawnPos->z + z); if (!gameMode->isCutScene()) { } @@ -4454,7 +4454,7 @@ void Minecraft::prepareLevel(int title) delete spawnPos; if (!gameMode->isCutScene()) { - if(progressRenderer != NULL) this->progressRenderer->progressStage(IDS_PROGRESS_SIMULATING_WORLD); + if(progressRenderer != nullptr) this->progressRenderer->progressStage(IDS_PROGRESS_SIMULATING_WORLD); max = 2000; } } @@ -4490,7 +4490,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) level->validateSpawn(); level->removeAllPendingEntityRemovals(); - if (localPlayer != NULL) + if (localPlayer != nullptr) { level->removeEntity(localPlayer); } @@ -4511,7 +4511,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) #ifdef _WINDOWS64 // Same compatibility rule as create/init paths. INetworkPlayer *localNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(iTempPad); - if(localNetworkPlayer != NULL && localNetworkPlayer->IsHost()) + if(localNetworkPlayer != nullptr && localNetworkPlayer->IsHost()) { playerXUIDOffline = Win64Xuid::GetLegacyEmbeddedHostXuid(); } @@ -4575,7 +4575,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) level->addEntity(player); gameMode->initPlayer(player); - if(player->input != NULL) delete player->input; + if(player->input != nullptr) delete player->input; player->input = new Input(); player->entityId = newEntityId; player->animateRespawn(); @@ -4591,7 +4591,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) //SetEvent(m_hPlayerRespawned); player->SetPlayerRespawned(true); - if (dynamic_cast(screen) != NULL) setScreen(NULL); + if (dynamic_cast(screen) != nullptr) setScreen(nullptr); gameRenderer->EnableUpdateThread(); } @@ -4623,9 +4623,9 @@ void Minecraft::startAndConnectTo(const wstring& name, const wstring& sid, const */ Minecraft *minecraft; - // 4J - was new Minecraft(frame, canvas, NULL, 854, 480, fullScreen); + // 4J - was new Minecraft(frame, canvas, nullptr, 854, 480, fullScreen); - minecraft = new Minecraft(NULL, NULL, NULL, 1280, 720, fullScreen); + minecraft = new Minecraft(nullptr, nullptr, nullptr, 1280, 720, fullScreen); /* - 4J - removed { @@ -4646,7 +4646,7 @@ void Minecraft::startAndConnectTo(const wstring& name, const wstring& sid, const // 4J Stu - We never want the player to be DemoUser, we always want them to have their gamertag displayed //if (ProfileManager.IsFullVersion()) { - if (userName != L"" && sid != L"") // 4J - username & side were compared with NULL rather than empty strings + if (userName != L"" && sid != L"") // 4J - username & side were compared with nullptr rather than empty strings { minecraft->user = new User(userName, sid); } @@ -4661,7 +4661,7 @@ void Minecraft::startAndConnectTo(const wstring& name, const wstring& sid, const //} /* 4J - TODO - if (url != NULL) + if (url != nullptr) { String[] tokens = url.split(":"); minecraft.connectTo(tokens[0], Integer.parseInt(tokens[1])); @@ -4726,7 +4726,7 @@ void Minecraft::main() #if 0 for(unsigned int i = 0; i < Item::items.length; ++i) { - if(Item::items[i] != NULL) + if(Item::items[i] != nullptr) { app.DebugPrintf("%ls\n", i, app.GetString( Item::items[i]->getDescriptionId() )); } @@ -4736,7 +4736,7 @@ void Minecraft::main() for(unsigned int i = 0; i < 256; ++i) { - if(Tile::tiles[i] != NULL) + if(Tile::tiles[i] != nullptr) { app.DebugPrintf("%ls\n", i, app.GetString( Tile::tiles[i]->getDescriptionId() )); } @@ -4768,7 +4768,7 @@ void Minecraft::main() bool Minecraft::renderNames() { - if (m_instance == NULL || !m_instance->options->hideGui) + if (m_instance == nullptr || !m_instance->options->hideGui) { return true; } @@ -4777,17 +4777,17 @@ bool Minecraft::renderNames() bool Minecraft::useFancyGraphics() { - return (m_instance != NULL && m_instance->options->fancyGraphics); + return (m_instance != nullptr && m_instance->options->fancyGraphics); } bool Minecraft::useAmbientOcclusion() { - return (m_instance != NULL && m_instance->options->ambientOcclusion != Options::AO_OFF); + return (m_instance != nullptr && m_instance->options->ambientOcclusion != Options::AO_OFF); } bool Minecraft::renderDebug() { - return (m_instance != NULL && m_instance->options->renderDebug); + return (m_instance != nullptr && m_instance->options->renderDebug); } bool Minecraft::handleClientSideCommand(const wstring& chatMessage) @@ -4826,7 +4826,7 @@ if (gameMode->instaBuild) return; if (!down) missTime = 0; if (button == 0 && missTime > 0) return; -if (down && hitResult != NULL && hitResult->type == HitResult::TILE && button == 0) +if (down && hitResult != nullptr && hitResult->type == HitResult::TILE && button == 0) { int x = hitResult->x; int y = hitResult->y; @@ -4858,7 +4858,7 @@ bool mayUse = true; // 4J-PB - Adding a special case in here for sleeping in a bed in a multiplayer game - we need to wake up, and we don't have the inbedchatscreen with a button -if(button==1 && (player->isSleeping() && level != NULL && level->isClientSide)) +if(button==1 && (player->isSleeping() && level != nullptr && level->isClientSide)) { shared_ptr mplp = dynamic_pointer_cast( player ); @@ -4872,9 +4872,9 @@ if(mplp) mplp->StopSleeping(); //} } -if (hitResult == NULL) +if (hitResult == nullptr) { -if (button == 0 && !(dynamic_cast(gameMode) != NULL)) missTime = 10; +if (button == 0 && !(dynamic_cast(gameMode) != nullptr)) missTime = 10; } else if (hitResult->type == HitResult::ENTITY) { @@ -4910,21 +4910,21 @@ gameMode->startDestroyBlock(x, y, z, hitResult->f); else { shared_ptr item = player->inventory->getSelected(); -int oldCount = item != NULL ? item->count : 0; +int oldCount = item != nullptr ? item->count : 0; if (gameMode->useItemOn(player, level, item, x, y, z, face)) { mayUse = false; app.DebugPrintf("Player %d is swinging\n",player->GetXboxPad()); player->swing(); } -if (item == NULL) +if (item == nullptr) { return; } if (item->count == 0) { -player->inventory->items[player->inventory->selected] = NULL; +player->inventory->items[player->inventory->selected] = nullptr; } else if (item->count != oldCount) { @@ -4936,7 +4936,7 @@ gameRenderer->itemInHandRenderer->itemPlaced(); if (mayUse && button == 1) { shared_ptr item = player->inventory->getSelected(); -if (item != NULL) +if (item != nullptr) { if (gameMode->useItem(player, level, item)) { @@ -4957,7 +4957,7 @@ bool Minecraft::isTutorial() { return m_inFullTutorialBits > 0; - /*if( gameMode != NULL && gameMode->isTutorial() ) + /*if( gameMode != nullptr && gameMode->isTutorial() ) { return true; } @@ -4992,7 +4992,7 @@ void Minecraft::playerLeftTutorial(int iPad) #ifndef _XBOX_ONE for(DWORD idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(localplayers[idx] != NULL) + if(localplayers[idx] != nullptr) { TelemetryManager->RecordLevelStart(idx, eSen_FriendOrMatch_Playing_With_Invited_Friends, eSen_CompeteOrCoop_Coop_and_Competitive, level->difficulty, app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount()); } @@ -5023,7 +5023,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP { // create the local player for the iPad shared_ptr player = pClass->localplayers[iPad]; - if( player == NULL) + if( player == nullptr) { if( pClass->level->isClientSide ) { @@ -5033,7 +5033,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP { // create the local player for the iPad shared_ptr player = pClass->localplayers[iPad]; - if( player == NULL) + if( player == nullptr) { player = pClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pClass->level->dimension->id); } @@ -5061,7 +5061,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) } // If sign in succeded, we're in game and this player isn't already playing, continue - if(bContinue==true && g_NetworkManager.IsInSession() && pMinecraftClass->localplayers[iPad] == NULL) + if(bContinue==true && g_NetworkManager.IsInSession() && pMinecraftClass->localplayers[iPad] == nullptr) { // It's possible that the player has not signed in - they can back out or choose no for the converttoguest if(ProfileManager.IsSignedIn(iPad)) @@ -5087,7 +5087,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) { #ifdef __ORBIS__ bool contentRestricted = false; - ProfileManager.GetChatAndContentRestrictions(iPad,false,NULL,&contentRestricted,NULL); // TODO! + ProfileManager.GetChatAndContentRestrictions(iPad,false,nullptr,&contentRestricted,nullptr); // TODO! if (!g_NetworkManager.IsLocalGame() && contentRestricted) { @@ -5108,7 +5108,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) { // create the local player for the iPad shared_ptr player = pMinecraftClass->localplayers[iPad]; - if( player == NULL) + if( player == nullptr) { player = pMinecraftClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pMinecraftClass->level->dimension->id); } @@ -5177,7 +5177,7 @@ ColourTable *Minecraft::getColourTable() ColourTable *colours = selected->getColourTable(); - if(colours == NULL) + if(colours == nullptr) { colours = skins->getDefault()->getColourTable(); } diff --git a/Minecraft.Client/Minecraft.h b/Minecraft.Client/Minecraft.h index cc1e5d18a..ef138d0af 100644 --- a/Minecraft.Client/Minecraft.h +++ b/Minecraft.Client/Minecraft.h @@ -114,7 +114,7 @@ class Minecraft void addPendingLocalConnection(int idx, ClientConnection *connection); void connectionDisconnected(int idx, DisconnectPacket::eDisconnectReason reason) { m_connectionFailed[idx] = true; m_connectionFailedReason[idx] = reason; } - shared_ptr createExtraLocalPlayer(int idx, const wstring& name, int pad, int iDimension, ClientConnection *clientConnection = NULL,MultiPlayerLevel *levelpassedin=NULL); + shared_ptr createExtraLocalPlayer(int idx, const wstring& name, int pad, int iDimension, ClientConnection *clientConnection = nullptr,MultiPlayerLevel *levelpassedin=nullptr); void createPrimaryLocalPlayer(int iPad); bool setLocalPlayerIdx(int idx); int getLocalPlayerIdx(); diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index f469c8b11..ad68b47fd 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -66,7 +66,7 @@ #define DEBUG_SERVER_DONT_SPAWN_MOBS 0 //4J Added -MinecraftServer *MinecraftServer::server = NULL; +MinecraftServer *MinecraftServer::server = nullptr; bool MinecraftServer::setTimeAtEndOfTick = false; __int64 MinecraftServer::setTime = 0; bool MinecraftServer::setTimeOfDayAtEndOfTick = false; @@ -97,17 +97,17 @@ static bool ShouldUseDedicatedServerProperties() static int GetDedicatedServerInt(Settings *settings, const wchar_t *key, int defaultValue) { - return (ShouldUseDedicatedServerProperties() && settings != NULL) ? settings->getInt(key, defaultValue) : defaultValue; + return (ShouldUseDedicatedServerProperties() && settings != nullptr) ? settings->getInt(key, defaultValue) : defaultValue; } static bool GetDedicatedServerBool(Settings *settings, const wchar_t *key, bool defaultValue) { - return (ShouldUseDedicatedServerProperties() && settings != NULL) ? settings->getBoolean(key, defaultValue) : defaultValue; + return (ShouldUseDedicatedServerProperties() && settings != nullptr) ? settings->getBoolean(key, defaultValue) : defaultValue; } static wstring GetDedicatedServerString(Settings *settings, const wchar_t *key, const wstring &defaultValue) { - return (ShouldUseDedicatedServerProperties() && settings != NULL) ? settings->getString(key, defaultValue) : defaultValue; + return (ShouldUseDedicatedServerProperties() && settings != nullptr) ? settings->getString(key, defaultValue) : defaultValue; } static void PrintConsoleLine(const wchar_t *prefix, const wstring &message) @@ -148,12 +148,12 @@ static wstring JoinConsoleCommandTokens(const vector &tokens, size_t st static shared_ptr FindPlayerByName(PlayerList *playerList, const wstring &name) { - if (playerList == NULL) return nullptr; + if (playerList == nullptr) return nullptr; for (size_t i = 0; i < playerList->players.size(); ++i) { shared_ptr player = playerList->players[i]; - if (player != NULL && equalsIgnoreCase(player->getName(), name)) + if (player != nullptr && equalsIgnoreCase(player->getName(), name)) { return player; } @@ -166,7 +166,7 @@ static void SetAllLevelTimes(MinecraftServer *server, int value) { for (unsigned int i = 0; i < server->levels.length; ++i) { - if (server->levels[i] != NULL) + if (server->levels[i] != nullptr) { server->levels[i]->setDayTime(value); } @@ -175,7 +175,7 @@ static void SetAllLevelTimes(MinecraftServer *server, int value) static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCommand) { - if (server == NULL) + if (server == nullptr) return false; wstring command = trimString(rawCommand); @@ -209,9 +209,9 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom if (action == L"list") { - wstring playerNames = (playerList != NULL) ? playerList->getPlayerNames() : L""; + wstring playerNames = (playerList != nullptr) ? playerList->getPlayerNames() : L""; if (playerNames.empty()) playerNames = L"(none)"; - server->info(L"Players (" + std::to_wstring((playerList != NULL) ? playerList->getPlayerCount() : 0) + L"): " + playerNames); + server->info(L"Players (" + std::to_wstring((playerList != nullptr) ? playerList->getPlayerCount() : 0) + L"): " + playerNames); return true; } @@ -224,7 +224,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom } wstring message = L"[Server] " + JoinConsoleCommandTokens(tokens, 1); - if (playerList != NULL) + if (playerList != nullptr) { playerList->broadcastAll(shared_ptr(new ChatPacket(message))); } @@ -234,9 +234,9 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom if (action == L"save-all") { - if (playerList != NULL) + if (playerList != nullptr) { - playerList->saveAll(NULL, false); + playerList->saveAll(nullptr, false); } server->info(L"World saved."); return true; @@ -267,7 +267,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom for (unsigned int i = 0; i < server->levels.length; ++i) { - if (server->levels[i] != NULL) + if (server->levels[i] != nullptr) { server->levels[i]->setDayTime(server->levels[i]->getDayTime() + delta); } @@ -323,7 +323,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom return false; } - if (server->levels[0] == NULL) + if (server->levels[0] == nullptr) { server->warn(L"The overworld is not loaded."); return false; @@ -370,12 +370,12 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom shared_ptr subject = FindPlayerByName(playerList, tokens[1]); shared_ptr destination = FindPlayerByName(playerList, tokens[2]); - if (subject == NULL) + if (subject == nullptr) { server->warn(L"Unknown player: " + tokens[1]); return false; } - if (destination == NULL) + if (destination == nullptr) { server->warn(L"Unknown player: " + tokens[2]); return false; @@ -401,7 +401,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom } shared_ptr player = FindPlayerByName(playerList, tokens[1]); - if (player == NULL) + if (player == nullptr) { server->warn(L"Unknown player: " + tokens[1]); return false; @@ -425,7 +425,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom server->warn(L"Invalid aux value: " + tokens[4]); return false; } - if (itemId <= 0 || Item::items[itemId] == NULL) + if (itemId <= 0 || Item::items[itemId] == nullptr) { server->warn(L"Unknown item id: " + std::to_wstring(itemId)); return false; @@ -438,7 +438,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom shared_ptr itemInstance(new ItemInstance(itemId, amount, aux)); shared_ptr drop = player->drop(itemInstance); - if (drop != NULL) + if (drop != nullptr) { drop->throwTime = 0; } @@ -455,7 +455,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom } shared_ptr player = FindPlayerByName(playerList, tokens[1]); - if (player == NULL) + if (player == nullptr) { server->warn(L"Unknown player: " + tokens[1]); return false; @@ -475,14 +475,14 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom } shared_ptr selectedItem = player->getSelectedItem(); - if (selectedItem == NULL) + if (selectedItem == nullptr) { server->warn(L"The player is not holding an item."); return false; } Enchantment *enchantment = Enchantment::enchantments[enchantmentId]; - if (enchantment == NULL) + if (enchantment == nullptr) { server->warn(L"Unknown enchantment id: " + std::to_wstring(enchantmentId)); return false; @@ -499,12 +499,12 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom if (selectedItem->hasTag()) { ListTag *enchantmentTags = selectedItem->getEnchantmentTags(); - if (enchantmentTags != NULL) + if (enchantmentTags != nullptr) { for (int i = 0; i < enchantmentTags->size(); i++) { int type = enchantmentTags->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_ID); - if (Enchantment::enchantments[type] != NULL && !Enchantment::enchantments[type]->isCompatibleWith(enchantment)) + if (Enchantment::enchantments[type] != nullptr && !Enchantment::enchantments[type]->isCompatibleWith(enchantment)) { server->warn(L"That enchantment conflicts with an existing enchantment on the selected item."); return false; @@ -527,7 +527,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom } shared_ptr player = FindPlayerByName(playerList, tokens[1]); - if (player == NULL) + if (player == nullptr) { server->warn(L"Unknown player: " + tokens[1]); return false; @@ -545,10 +545,10 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom MinecraftServer::MinecraftServer() { // 4J - added initialisers - connection = NULL; - settings = NULL; - players = NULL; - commands = NULL; + connection = nullptr; + settings = nullptr; + players = nullptr; + commands = nullptr; running = true; m_bLoaded = false; stopped = false; @@ -567,7 +567,7 @@ MinecraftServer::MinecraftServer() m_texturePackId = 0; maxBuildHeight = Level::maxBuildHeight; playerIdleTimeout = 0; - m_postUpdateThread = NULL; + m_postUpdateThread = nullptr; forceGameType = false; commandDispatcher = new ServerCommandDispatcher(); @@ -684,10 +684,10 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW setPlayers(new PlayerList(this)); // 4J-JEV: Need to wait for levelGenerationOptions to load. - while ( app.getLevelGenerationOptions() != NULL && !app.getLevelGenerationOptions()->hasLoadedData() ) + while ( app.getLevelGenerationOptions() != nullptr && !app.getLevelGenerationOptions()->hasLoadedData() ) Sleep(1); - if ( app.getLevelGenerationOptions() != NULL && !app.getLevelGenerationOptions()->ready() ) + if ( app.getLevelGenerationOptions() != nullptr && !app.getLevelGenerationOptions()->ready() ) { // TODO: Stop loading, add error message. } @@ -698,7 +698,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW wstring levelTypeString; bool gameRuleUseFlatWorld = false; - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { gameRuleUseFlatWorld = app.getLevelGenerationOptions()->getuseFlatWorld(); } @@ -712,7 +712,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW } LevelType *pLevelType = LevelType::getLevelType(levelTypeString); - if (pLevelType == NULL) + if (pLevelType == nullptr) { pLevelType = LevelType::lvl_normal; } @@ -862,7 +862,7 @@ void MinecraftServer::postProcessTerminate(ProgressRenderer *mcprogress) } } while ( status == WAIT_TIMEOUT ); delete m_postUpdateThread; - m_postUpdateThread = NULL; + m_postUpdateThread = nullptr; DeleteCriticalSection(&m_postProcessCS); } @@ -888,7 +888,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring // 4J - temp - load existing level shared_ptr storage = nullptr; bool levelChunksNeedConverted = false; - if( initData->saveData != NULL ) + if( initData->saveData != nullptr ) { // We are loading a file from disk with the data passed in @@ -912,13 +912,13 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring #ifdef SPLIT_SAVES bool bLevelGenBaseSave = false; LevelGenerationOptions *levelGen = app.getLevelGenerationOptions(); - if( levelGen != NULL && levelGen->requiresBaseSave()) + if( levelGen != nullptr && levelGen->requiresBaseSave()) { DWORD fileSize = 0; LPVOID pvSaveData = levelGen->getBaseSaveData(fileSize); if(pvSaveData && fileSize != 0) bLevelGenBaseSave = true; } - ConsoleSaveFileSplit *newFormatSave = NULL; + ConsoleSaveFileSplit *newFormatSave = nullptr; if(bLevelGenBaseSave) { ConsoleSaveFileOriginal oldFormatSave( L"" ); @@ -952,11 +952,11 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring if (i == 0) { levels[i] = new ServerLevel(this, storage, name, dimension, levelSettings); - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *mapOptions = app.getLevelGenerationOptions(); Pos *spawnPos = mapOptions->getSpawnPos(); - if( spawnPos != NULL ) + if( spawnPos != nullptr ) { levels[i]->setSpawnPos( spawnPos ); } @@ -981,7 +981,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring #endif levels[i]->getLevelData()->setGameType(gameType); - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *mapOptions = app.getLevelGenerationOptions(); levels[i]->getLevelData()->setHasBeenInCreative(mapOptions->getLevelHasBeenInCreative() ); @@ -1038,7 +1038,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring ba_gameRules.length = fe->getFileSize(); ba_gameRules.data = new BYTE[ ba_gameRules.length ]; - csf->setFilePointer(fe,0,NULL,FILE_BEGIN); + csf->setFilePointer(fe,0,nullptr,FILE_BEGIN); csf->readFile(fe, ba_gameRules.data, ba_gameRules.length, &numberOfBytesRead); assert(numberOfBytesRead == ba_gameRules.length); @@ -1349,7 +1349,7 @@ void MinecraftServer::saveAllChunks() // with the data from the nethers leveldata. // Fix for #7418 - Functional: Gameplay: Saving after sleeping in a bed will place player at nighttime when restarting. ServerLevel *level = levels[levels.length - 1 - i]; - if( level ) // 4J - added check as level can be NULL if we end up in stopServer really early on due to network failure + if( level ) // 4J - added check as level can be nullptr if we end up in stopServer really early on due to network failure { level->save(true, Minecraft::GetInstance()->progressRenderer); @@ -1375,14 +1375,14 @@ void MinecraftServer::saveGameRules() #endif { byteArray ba; - ba.data = NULL; + ba.data = nullptr; app.m_gameRules.saveGameRules( &ba.data, &ba.length ); - if (ba.data != NULL) + if (ba.data != nullptr) { ConsoleSaveFile *csf = getLevel(0)->getLevelStorage()->getSaveFile(); FileEntry *fe = csf->createFile(ConsoleSavePath(GAME_RULE_SAVENAME)); - csf->setFilePointer(fe, 0, NULL, FILE_BEGIN); + csf->setFilePointer(fe, 0, nullptr, FILE_BEGIN); DWORD length; csf->writeFile(fe, ba.data, ba.length, &length ); @@ -1406,9 +1406,9 @@ void MinecraftServer::Suspend() QueryPerformanceCounter( &qwTime ); if(m_bLoaded && ProfileManager.IsFullVersion() && (!StorageManager.GetSaveDisabled())) { - if (players != NULL) + if (players != nullptr) { - players->saveAll(NULL); + players->saveAll(nullptr); } for (unsigned int j = 0; j < levels.length; j++) { @@ -1422,7 +1422,7 @@ void MinecraftServer::Suspend() if( !s_bServerHalted ) { saveGameRules(); - levels[0]->saveToDisc(NULL, true); + levels[0]->saveToDisc(nullptr, true); } } QueryPerformanceCounter( &qwNewTime ); @@ -1481,7 +1481,7 @@ void MinecraftServer::stopServer(bool didInit) // if trial version or saving is disabled, then don't save anything. Also don't save anything if we didn't actually get through the server initialisation. if(m_saveOnExit && ProfileManager.IsFullVersion() && (!StorageManager.GetSaveDisabled()) && didInit) { - if (players != NULL) + if (players != nullptr) { players->saveAll(Minecraft::GetInstance()->progressRenderer, true); } @@ -1491,7 +1491,7 @@ void MinecraftServer::stopServer(bool didInit) //for (unsigned int i = levels.length - 1; i >= 0; i--) //{ // ServerLevel *level = levels[i]; - // if (level != NULL) + // if (level != nullptr) // { saveAllChunks(); // } @@ -1499,7 +1499,7 @@ void MinecraftServer::stopServer(bool didInit) saveGameRules(); app.m_gameRules.unloadCurrentGameRules(); - if( levels[0] != NULL ) // This can be null if stopServer happens very quickly due to network error + if( levels[0] != nullptr ) // This can be null if stopServer happens very quickly due to network error { levels[0]->saveToDisc(Minecraft::GetInstance()->progressRenderer, false); } @@ -1522,10 +1522,10 @@ void MinecraftServer::stopServer(bool didInit) unsigned int iServerLevelC=levels.length; for (unsigned int i = 0; i < iServerLevelC; i++) { - if(levels[i]!=NULL) + if(levels[i]!=nullptr) { delete levels[i]; - levels[i] = NULL; + levels[i] = nullptr; } } @@ -1535,11 +1535,11 @@ void MinecraftServer::stopServer(bool didInit) #endif delete connection; - connection = NULL; + connection = nullptr; delete players; - players = NULL; + players = nullptr; delete settings; - settings = NULL; + settings = nullptr; g_NetworkManager.ServerStopped(); } @@ -1697,10 +1697,10 @@ void MinecraftServer::setPlayerIdleTimeout(int playerIdleTimeout) extern int c0a, c0b, c1a, c1b, c1c, c2a, c2b; void MinecraftServer::run(__int64 seed, void *lpParameter) { - NetworkGameInitData *initData = NULL; + NetworkGameInitData *initData = nullptr; DWORD initSettings = 0; bool findSeed = false; - if(lpParameter != NULL) + if(lpParameter != nullptr) { initData = static_cast(lpParameter); initSettings = app.GetGameHostOption(eGameHostOption_All); @@ -1843,9 +1843,9 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) // Save the start time QueryPerformanceCounter( &qwTime ); - if (players != NULL) + if (players != nullptr) { - players->saveAll(NULL); + players->saveAll(nullptr); } for (unsigned int j = 0; j < levels.length; j++) @@ -1856,7 +1856,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) // Fix for #7418 - Functional: Gameplay: Saving after sleeping in a bed will place player at nighttime when restarting. ServerLevel *level = levels[levels.length - 1 - j]; PIXBeginNamedEvent(0, "Saving level %d",levels.length - 1 - j); - level->save(false, NULL, true); + level->save(false, nullptr, true); PIXEndNamedEvent(); } if( !s_bServerHalted ) @@ -1880,7 +1880,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) #endif case eXuiServerAction_SaveGame: app.EnterSaveNotificationSection(); - if (players != NULL) + if (players != nullptr) { players->saveAll(Minecraft::GetInstance()->progressRenderer); } @@ -2214,14 +2214,14 @@ void MinecraftServer::main(__int64 seed, void *lpParameter) server = new MinecraftServer(); server->run(seed, lpParameter); delete server; - server = NULL; + server = nullptr; ShutdownManager::HasFinished(ShutdownManager::eServerThread ); } void MinecraftServer::HaltServer(bool bPrimaryPlayerSignedOut) { s_bServerHalted = true; - if( server != NULL ) + if( server != nullptr ) { m_bPrimaryPlayerSignedOut=bPrimaryPlayerSignedOut; server->halt(); @@ -2267,7 +2267,7 @@ void MinecraftServer::setLevel(int dimension, ServerLevel *level) bool MinecraftServer::chunkPacketManagement_CanSendTo(INetworkPlayer *player) { if( s_hasSentEnoughPackets ) return false; - if( player == NULL ) return false; + if( player == nullptr ) return false; for( int i = 0; i < s_sentTo.size(); i++ ) { @@ -2350,7 +2350,7 @@ void MinecraftServer::chunkPacketManagement_PostTick() // 4J Added bool MinecraftServer::chunkPacketManagement_CanSendTo(INetworkPlayer *player) { - if( player == NULL ) return false; + if( player == nullptr ) return false; int time = GetTickCount(); if( player->GetSessionIndex() == s_slowQueuePlayerIndex && (time - s_slowQueueLastTime) > MINECRAFT_SERVER_SLOW_QUEUE_DELAY ) @@ -2393,7 +2393,7 @@ void MinecraftServer::cycleSlowQueueIndex() if( !g_NetworkManager.IsInSession() ) return; int startingIndex = s_slowQueuePlayerIndex; - INetworkPlayer *currentPlayer = NULL; + INetworkPlayer *currentPlayer = nullptr; DWORD currentPlayerCount = 0; do { @@ -2415,7 +2415,7 @@ void MinecraftServer::cycleSlowQueueIndex() } while ( g_NetworkManager.IsInSession() && currentPlayerCount > 0 && s_slowQueuePlayerIndex != startingIndex && - currentPlayer != NULL && + currentPlayer != nullptr && currentPlayer->IsLocal() ); // app.DebugPrintf("Cycled slow queue index to %d\n", s_slowQueuePlayerIndex); diff --git a/Minecraft.Client/MinecraftServer.h b/Minecraft.Client/MinecraftServer.h index 7fa8c7522..3332c6ae8 100644 --- a/Minecraft.Client/MinecraftServer.h +++ b/Minecraft.Client/MinecraftServer.h @@ -48,9 +48,9 @@ typedef struct _NetworkGameInitData _NetworkGameInitData() { seed = 0; - saveData = NULL; + saveData = nullptr; settings = 0; - levelGen = NULL; + levelGen = nullptr; texturePackId = 0; findSeed = false; xzSize = LEVEL_LEGACY_WIDTH; @@ -233,7 +233,7 @@ class MinecraftServer : public ConsoleInputSource void addPostProcessRequest(ChunkSource *chunkSource, int x, int z); public: - static PlayerList *getPlayerList() { if( server != NULL ) return server->players; else return NULL; } + static PlayerList *getPlayerList() { if( server != nullptr ) return server->players; else return nullptr; } static void SetTimeOfDay(__int64 time) { setTimeOfDayAtEndOfTick = true; setTimeOfDay = time; } static void SetTime(__int64 time) { setTimeAtEndOfTick = true; setTime = time; } diff --git a/Minecraft.Client/Minimap.cpp b/Minecraft.Client/Minimap.cpp index 9e07dbdf2..4f6ccd6b6 100644 --- a/Minecraft.Client/Minimap.cpp +++ b/Minecraft.Client/Minimap.cpp @@ -165,9 +165,9 @@ void Minimap::render(shared_ptr player, Textures *textures, shared_ptrentityId != entityId) continue; glPushMatrix(); @@ -201,9 +201,9 @@ void Minimap::render(shared_ptr player, Textures *textures, shared_ptrimg; imgIndex -= 16; - // 4J Stu - For item frame renders, the player is NULL. We do not want to show player icons on the frames. - if(player == NULL && (imgIndex != 12)) continue; - else if (player != NULL && imgIndex == 12) continue; + // 4J Stu - For item frame renders, the player is nullptr. We do not want to show player icons on the frames. + if(player == nullptr && (imgIndex != 12)) continue; + else if (player != nullptr && imgIndex == 12) continue; else if( imgIndex == 12 && dec->entityId != entityId) continue; glPushMatrix(); @@ -239,7 +239,7 @@ void Minimap::render(shared_ptr player, Textures *textures, shared_ptr entity, double x, double y, double { shared_ptr roper = entity->getLeashHolder(); // roper = entityRenderDispatcher.cameraEntity; - if (roper != NULL) + if (roper != nullptr) { glColor4f(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/Minecraft.Client/MobSkinMemTextureProcessor.cpp b/Minecraft.Client/MobSkinMemTextureProcessor.cpp index a6fdf5270..c841c3f5a 100644 --- a/Minecraft.Client/MobSkinMemTextureProcessor.cpp +++ b/Minecraft.Client/MobSkinMemTextureProcessor.cpp @@ -3,14 +3,14 @@ BufferedImage *MobSkinMemTextureProcessor::process(BufferedImage *in) { - if (in == NULL) return NULL; + if (in == nullptr) return nullptr; width = 64; height = 32; BufferedImage *out = new BufferedImage(width, height, BufferedImage::TYPE_INT_ARGB); Graphics *g = out->getGraphics(); - g->drawImage(in, 0, 0, NULL); + g->drawImage(in, 0, 0, nullptr); g->dispose(); pixels = out->getData(); diff --git a/Minecraft.Client/MobSkinTextureProcessor.cpp b/Minecraft.Client/MobSkinTextureProcessor.cpp index dffb467a8..37d2ab46c 100644 --- a/Minecraft.Client/MobSkinTextureProcessor.cpp +++ b/Minecraft.Client/MobSkinTextureProcessor.cpp @@ -3,14 +3,14 @@ BufferedImage *MobSkinTextureProcessor::process(BufferedImage *in) { - if (in == NULL) return NULL; + if (in == nullptr) return nullptr; width = 64; height = 32; BufferedImage *out = new BufferedImage(width, height, BufferedImage::TYPE_INT_ARGB); Graphics *g = out->getGraphics(); - g->drawImage(in, 0, 0, NULL); + g->drawImage(in, 0, 0, nullptr); g->dispose(); pixels = out->getData(); diff --git a/Minecraft.Client/MobSpawnerRenderer.cpp b/Minecraft.Client/MobSpawnerRenderer.cpp index 9b6e6a0e2..1a083fabd 100644 --- a/Minecraft.Client/MobSpawnerRenderer.cpp +++ b/Minecraft.Client/MobSpawnerRenderer.cpp @@ -19,7 +19,7 @@ void MobSpawnerRenderer::render(BaseMobSpawner *spawner, double x, double y, dou glTranslatef(static_cast(x) + 0.5f, static_cast(y), static_cast(z) + 0.5f); shared_ptr e = spawner->getDisplayEntity(); - if (e != NULL) + if (e != nullptr) { e->setLevel(spawner->getLevel()); float s = 7 / 16.0f; diff --git a/Minecraft.Client/Model.h b/Minecraft.Client/Model.h index 305c5a0a1..6a797a258 100644 --- a/Minecraft.Client/Model.h +++ b/Minecraft.Client/Model.h @@ -24,7 +24,7 @@ class Model virtual void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr entity, unsigned int uiBitmaskOverrideAnim=0) {} virtual void prepareMobModel(shared_ptr mob, float time, float r, float a) {} virtual ModelPart *getRandomModelPart(Random random) {return cubes.at(random.nextInt(static_cast(cubes.size())));} - virtual ModelPart * AddOrRetrievePart(SKIN_BOX *pBox) { return NULL;} + virtual ModelPart * AddOrRetrievePart(SKIN_BOX *pBox) { return nullptr;} void setMapTex(wstring id, int x, int y); TexOffs *getMapTex(wstring id); diff --git a/Minecraft.Client/ModelHorse.cpp b/Minecraft.Client/ModelHorse.cpp index 7a13d0adc..81ff7ea61 100644 --- a/Minecraft.Client/ModelHorse.cpp +++ b/Minecraft.Client/ModelHorse.cpp @@ -252,7 +252,7 @@ void ModelHorse::render(shared_ptr entity, float time, float r, float bo bool largeEars = type == EntityHorse::TYPE_DONKEY || type == EntityHorse::TYPE_MULE; float sizeFactor = entityhorse->getFoalScale(); - bool rider = (entityhorse->rider.lock() != NULL); + bool rider = (entityhorse->rider.lock() != nullptr); if (saddled) { @@ -401,7 +401,7 @@ void ModelHorse::prepareMobModel(shared_ptr mob, float wp, float w float openMouth = entityhorse->getMouthAnim(a); bool tail = entityhorse->tailCounter != 0; bool saddled = entityhorse->isSaddled(); - bool rider = entityhorse->rider.lock() != NULL; + bool rider = entityhorse->rider.lock() != nullptr; float bob = mob->tickCount + a; float legAnim1 = cos((wp * 0.6662f) + 3.141593f); diff --git a/Minecraft.Client/ModelPart.cpp b/Minecraft.Client/ModelPart.cpp index 57424bc66..e423a4ae2 100644 --- a/Minecraft.Client/ModelPart.cpp +++ b/Minecraft.Client/ModelPart.cpp @@ -65,7 +65,7 @@ void ModelPart::construct(Model *model, int xTexOffs, int yTexOffs) void ModelPart::addChild(ModelPart *child) { - //if (children == NULL) children = new ModelPartArray; + //if (children == nullptr) children = new ModelPartArray; children.push_back(child); } @@ -89,7 +89,7 @@ ModelPart * ModelPart::retrieveChild(SKIN_BOX *pBox) } } - return NULL; + return nullptr; } ModelPart *ModelPart::mirror() @@ -180,7 +180,7 @@ void ModelPart::render(float scale, bool usecompiled, bool bHideParentBodyPart) } } } - //if (children != NULL) + //if (children != nullptr) { for (unsigned int i = 0; i < children.size(); i++) { @@ -208,7 +208,7 @@ void ModelPart::render(float scale, bool usecompiled, bool bHideParentBodyPart) } } } - //if (children != NULL) + //if (children != nullptr) { for (unsigned int i = 0; i < children.size(); i++) { @@ -234,7 +234,7 @@ void ModelPart::render(float scale, bool usecompiled, bool bHideParentBodyPart) } } } - //if (children != NULL) + //if (children != nullptr) { for (unsigned int i = 0; i < children.size(); i++) { diff --git a/Minecraft.Client/MultiPlayerChunkCache.cpp b/Minecraft.Client/MultiPlayerChunkCache.cpp index 4a9ca59ae..62361ce36 100644 --- a/Minecraft.Client/MultiPlayerChunkCache.cpp +++ b/Minecraft.Client/MultiPlayerChunkCache.cpp @@ -88,7 +88,7 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level) } else { - waterChunk = NULL; + waterChunk = nullptr; } this->level = level; @@ -132,7 +132,7 @@ bool MultiPlayerChunkCache::reallyHasChunk(int x, int z) int idx = ix * XZSIZE + iz; LevelChunk *chunk = cache[idx]; - if( chunk == NULL ) + if( chunk == nullptr ) { return false; } @@ -166,7 +166,7 @@ LevelChunk *MultiPlayerChunkCache::create(int x, int z) LevelChunk *chunk = cache[idx]; LevelChunk *lastChunk = chunk; - if( chunk == NULL ) + if( chunk == nullptr ) { EnterCriticalSection(&m_csLoadCreate); @@ -174,7 +174,7 @@ LevelChunk *MultiPlayerChunkCache::create(int x, int z) if( g_NetworkManager.IsHost() ) // force here to disable sharing of data { // 4J-JEV: We are about to use shared data, abort if the server is stopped and the data is deleted. - if (MinecraftServer::getInstance()->serverHalted()) return NULL; + if (MinecraftServer::getInstance()->serverHalted()) return nullptr; // If we're the host, then don't create the chunk, share data from the server's copy #ifdef _LARGE_WORLDS @@ -248,7 +248,7 @@ LevelChunk *MultiPlayerChunkCache::getChunk(int x, int z) int idx = ix * XZSIZE + iz; LevelChunk *chunk = cache[idx]; - if( chunk == NULL ) + if( chunk == nullptr ) { return emptyChunk; } @@ -279,12 +279,12 @@ void MultiPlayerChunkCache::postProcess(ChunkSource *parent, int x, int z) vector *MultiPlayerChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { - return NULL; + return nullptr; } TilePos *MultiPlayerChunkCache::findNearestMapFeature(Level *level, const wstring &featureName, int x, int y, int z) { - return NULL; + return nullptr; } void MultiPlayerChunkCache::recreateLogicStructuresForChunk(int chunkX, int chunkZ) diff --git a/Minecraft.Client/MultiPlayerGameMode.cpp b/Minecraft.Client/MultiPlayerGameMode.cpp index bf3550956..50e3080d7 100644 --- a/Minecraft.Client/MultiPlayerGameMode.cpp +++ b/Minecraft.Client/MultiPlayerGameMode.cpp @@ -75,7 +75,7 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) if (localPlayerMode->isCreative()) { - if (minecraft->player->getCarriedItem() != NULL && dynamic_cast(minecraft->player->getCarriedItem()->getItem()) != NULL) + if (minecraft->player->getCarriedItem() != nullptr && dynamic_cast(minecraft->player->getCarriedItem()->getItem()) != nullptr) { return false; } @@ -84,7 +84,7 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) Level *level = minecraft->level; Tile *oldTile = Tile::tiles[level->getTile(x, y, z)]; - if (oldTile == NULL) return false; + if (oldTile == nullptr) return false; level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT)); @@ -99,7 +99,7 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) if (!localPlayerMode->isCreative()) { shared_ptr item = minecraft->player->getSelectedItem(); - if (item != NULL) + if (item != nullptr) { item->mineBlock(level, oldTile->id, x, y, z, minecraft->player); if (item->count == 0) @@ -212,7 +212,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) if (destroyTicks % 4 == 0) { - if (tile != NULL) + if (tile != nullptr) { int iStepSound=tile->soundType->getStepSound(); @@ -259,8 +259,8 @@ void MultiPlayerGameMode::tick() bool MultiPlayerGameMode::sameDestroyTarget(int x, int y, int z) { shared_ptr selected = minecraft->player->getCarriedItem(); - bool sameItems = destroyingItem == NULL && selected == NULL; - if (destroyingItem != NULL && selected != NULL) + bool sameItems = destroyingItem == nullptr && selected == nullptr; + if (destroyingItem != nullptr && selected != nullptr) { sameItems = selected->id == destroyingItem->id && @@ -294,7 +294,7 @@ bool MultiPlayerGameMode::useItemOn(shared_ptr player, Level *level, sha float clickZ = static_cast(hit->z) - z; bool didSomething = false; - if (!player->isSneaking() || player->getCarriedItem() == NULL) + if (!player->isSneaking() || player->getCarriedItem() == nullptr) { int t = level->getTile(x, y, z); if (t > 0 && player->isAllowedToUse(Tile::tiles[t])) @@ -327,15 +327,15 @@ bool MultiPlayerGameMode::useItemOn(shared_ptr player, Level *level, sha } } - if (!didSomething && item != NULL && dynamic_cast(item->getItem())) + if (!didSomething && item != nullptr && dynamic_cast(item->getItem())) { TileItem *tile = dynamic_cast(item->getItem()); if (!tile->mayPlace(level, x, y, z, face, player, item)) return false; } - // 4J Stu - In Java we send the use packet before the above check for item being NULL + // 4J Stu - In Java we send the use packet before the above check for item being nullptr // so the following never gets executed but the packet still gets sent (for opening chests etc) - if(item != NULL) + if(item != nullptr) { if(!didSomething && player->isAllowedToUse(item)) { @@ -408,7 +408,7 @@ bool MultiPlayerGameMode::useItem(shared_ptr player, Level *level, share { int oldCount = item->count; shared_ptr itemInstance = item->use(level, player); - if ((itemInstance != NULL && itemInstance != item) || (itemInstance != NULL && itemInstance->count != oldCount)) + if ((itemInstance != nullptr && itemInstance != item) || (itemInstance != nullptr && itemInstance->count != oldCount)) { player->inventory->items[player->inventory->selected] = itemInstance; if (itemInstance->count == 0) @@ -470,7 +470,7 @@ void MultiPlayerGameMode::handleCreativeModeItemAdd(shared_ptr cli void MultiPlayerGameMode::handleCreativeModeItemDrop(shared_ptr clicked) { - if (localPlayerMode->isCreative() && clicked != NULL) + if (localPlayerMode->isCreative() && clicked != nullptr) { connection->send(shared_ptr( new SetCreativeModeSlotPacket(-1, clicked) ) ); } diff --git a/Minecraft.Client/MultiPlayerGameMode.h b/Minecraft.Client/MultiPlayerGameMode.h index 76aa8fc84..fb21bb67c 100644 --- a/Minecraft.Client/MultiPlayerGameMode.h +++ b/Minecraft.Client/MultiPlayerGameMode.h @@ -42,7 +42,7 @@ class MultiPlayerGameMode bool sameDestroyTarget(int x, int y, int z); void ensureHasSentCarriedItem(); public: - virtual bool useItemOn(shared_ptr player, Level *level, shared_ptr item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly=false, bool *pbUsedItem=NULL); + virtual bool useItemOn(shared_ptr player, Level *level, shared_ptr item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly=false, bool *pbUsedItem=nullptr); virtual bool useItem(shared_ptr player, Level *level, shared_ptr item, bool bTestUseOnly=false); virtual shared_ptr createPlayer(Level *level); virtual void attack(shared_ptr player, shared_ptr entity); @@ -65,5 +65,5 @@ class MultiPlayerGameMode // 4J Stu - Added for tutorial checks virtual bool isInputAllowed(int mapping) { return true; } virtual bool isTutorial() { return false; } - virtual Tutorial *getTutorial() { return NULL; } + virtual Tutorial *getTutorial() { return nullptr; } }; \ No newline at end of file diff --git a/Minecraft.Client/MultiPlayerLevel.cpp b/Minecraft.Client/MultiPlayerLevel.cpp index 4b74bbf17..d91a1affc 100644 --- a/Minecraft.Client/MultiPlayerLevel.cpp +++ b/Minecraft.Client/MultiPlayerLevel.cpp @@ -43,7 +43,7 @@ MultiPlayerLevel::MultiPlayerLevel(ClientConnection *connection, LevelSettings * levelData->setInitialized(true); } - if(connection !=NULL) + if(connection !=nullptr) { this->connections.push_back( connection ); } @@ -54,7 +54,7 @@ MultiPlayerLevel::MultiPlayerLevel(ClientConnection *connection, LevelSettings * //setSpawnPos(new Pos(8, 64, 8)); // The base ctor already has made some storage, so need to delete that if( this->savedDataStorage ) delete savedDataStorage; - if(connection !=NULL) + if(connection !=nullptr) { savedDataStorage = connection->savedDataStorage; } @@ -70,7 +70,7 @@ MultiPlayerLevel::MultiPlayerLevel(ClientConnection *connection, LevelSettings * MultiPlayerLevel::~MultiPlayerLevel() { // Don't let the base class delete this, it comes from the connection for multiplayerlevels, and we'll delete there - this->savedDataStorage = NULL; + this->savedDataStorage = nullptr; } void MultiPlayerLevel::unshareChunkAt(int x, int z) @@ -465,7 +465,7 @@ void MultiPlayerLevel::entityRemoved(shared_ptr e) void MultiPlayerLevel::putEntity(int id, shared_ptr e) { shared_ptr old = getEntity(id); - if (old != NULL) + if (old != nullptr) { removeEntity(old); } @@ -633,7 +633,7 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/) Tickable *MultiPlayerLevel::makeSoundUpdater(shared_ptr minecart) { - return NULL; //new MinecartSoundUpdater(minecraft->soundEngine, minecart, minecraft->player); + return nullptr; //new MinecartSoundUpdater(minecraft->soundEngine, minecart, minecraft->player); } void MultiPlayerLevel::tickWeather() @@ -732,7 +732,7 @@ void MultiPlayerLevel::animateTickDoWork() } } - Minecraft::GetInstance()->animateTickLevel = NULL; + Minecraft::GetInstance()->animateTickLevel = nullptr; delete animateRandom; chunksToAnimate.clear(); @@ -860,7 +860,7 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals() { shared_ptr e = *it;//entities.at(i); - if (e->riding != NULL) + if (e->riding != nullptr) { if (e->riding->removed || e->riding->rider.lock() != e) { @@ -937,11 +937,11 @@ void MultiPlayerLevel::removeUnusedTileEntitiesInRegion(int x0, int y0, int z0, if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && te->y < y1 && te->z < z1) { LevelChunk *lc = getChunk(te->x >> 4, te->z >> 4); - if (lc != NULL) + if (lc != nullptr) { // Only remove tile entities where this is no longer a tile entity int tileId = lc->getTile(te->x & 15, te->y, te->z & 15 ); - if( Tile::tiles[tileId] == NULL || !Tile::tiles[tileId]->isEntityTile()) + if( Tile::tiles[tileId] == nullptr || !Tile::tiles[tileId]->isEntityTile()) { tileEntityList[i] = tileEntityList.back(); tileEntityList.pop_back(); diff --git a/Minecraft.Client/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/MultiPlayerLocalPlayer.cpp index 3c3c34310..57ffb2906 100644 --- a/Minecraft.Client/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/MultiPlayerLocalPlayer.cpp @@ -129,7 +129,7 @@ void MultiplayerLocalPlayer::sendPosition() bool move = (xdd * xdd + ydd1 * ydd1 + zdd * zdd) > 0.03 * 0.03 || positionReminder >= POSITION_REMINDER_INTERVAL; bool rot = rydd != 0 || rxdd != 0; - if (riding != NULL) + if (riding != nullptr) { connection->send( shared_ptr( new MovePlayerPacket::PosRot(xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying) ) ); move = false; @@ -211,7 +211,7 @@ void MultiplayerLocalPlayer::actuallyHurt(DamageSource *source, float dmg) void MultiplayerLocalPlayer::completeUsingItem() { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(useItem != NULL && pMinecraft->localgameModes[m_iPad] != NULL ) + if(useItem != nullptr && pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); Tutorial *tutorial = gameMode->getTutorial(); @@ -223,7 +223,7 @@ void MultiplayerLocalPlayer::completeUsingItem() void MultiplayerLocalPlayer::onEffectAdded(MobEffectInstance *effect) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localgameModes[m_iPad] != NULL ) + if(pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); Tutorial *tutorial = gameMode->getTutorial(); @@ -236,7 +236,7 @@ void MultiplayerLocalPlayer::onEffectAdded(MobEffectInstance *effect) void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance *effect, bool doRefreshAttributes) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localgameModes[m_iPad] != NULL ) + if(pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); Tutorial *tutorial = gameMode->getTutorial(); @@ -249,7 +249,7 @@ void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance *effect, bool doR void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance *effect) { Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localgameModes[m_iPad] != NULL ) + if(pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); Tutorial *tutorial = gameMode->getTutorial(); @@ -286,7 +286,7 @@ void MultiplayerLocalPlayer::hurtTo(float newHealth, ETelemetryChallenges damage void MultiplayerLocalPlayer::awardStat(Stat *stat, byteArray param) { - if (stat == NULL) + if (stat == nullptr) { delete [] param.data; return; @@ -305,7 +305,7 @@ void MultiplayerLocalPlayer::awardStat(Stat *stat, byteArray param) void MultiplayerLocalPlayer::awardStatFromServer(Stat *stat, byteArray param) { - if ( stat != NULL && !stat->awardLocallyOnly ) + if ( stat != nullptr && !stat->awardLocallyOnly ) { LocalPlayer::awardStat(stat, param); } @@ -334,9 +334,9 @@ void MultiplayerLocalPlayer::sendOpenInventory() void MultiplayerLocalPlayer::ride(shared_ptr e) { - bool wasRiding = riding != NULL; + bool wasRiding = riding != nullptr; LocalPlayer::ride(e); - bool isRiding = riding != NULL; + bool isRiding = riding != nullptr; // 4J Added if(wasRiding && !isRiding) @@ -348,7 +348,7 @@ void MultiplayerLocalPlayer::ride(shared_ptr e) if( isRiding ) { ETelemetryChallenges eventType = eTelemetryChallenges_Unknown; - if( this->riding != NULL ) + if( this->riding != nullptr ) { switch(riding->GetType()) { @@ -370,7 +370,7 @@ void MultiplayerLocalPlayer::ride(shared_ptr e) Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localgameModes[m_iPad] != NULL ) + if( pMinecraft->localgameModes[m_iPad] != nullptr ) { TutorialMode *gameMode = static_cast(pMinecraft->localgameModes[m_iPad]); if(wasRiding && !isRiding) diff --git a/Minecraft.Client/NameEntryScreen.cpp b/Minecraft.Client/NameEntryScreen.cpp index c9df70245..f498d4ea3 100644 --- a/Minecraft.Client/NameEntryScreen.cpp +++ b/Minecraft.Client/NameEntryScreen.cpp @@ -41,7 +41,7 @@ void NameEntryScreen::buttonClicked(Button button) if (button.id == 0 && trimString(name).length() > 1) { minecraft->saveSlot(slot, trimString(name)); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J - removed } if (button.id == 1) diff --git a/Minecraft.Client/Options.cpp b/Minecraft.Client/Options.cpp index d7e032fc6..9c0156322 100644 --- a/Minecraft.Client/Options.cpp +++ b/Minecraft.Client/Options.cpp @@ -152,8 +152,8 @@ void Options::init() keyMappings[12] = keyPickItem; keyMappings[13] = keyToggleFog; - minecraft = NULL; - //optionsFile = NULL; + minecraft = nullptr; + //optionsFile = nullptr; difficulty = 2; hideGui = false; @@ -412,7 +412,7 @@ void Options::load() BufferedReader *br = new BufferedReader(new InputStreamReader( new FileInputStream( optionsFile ) ) ); wstring line = L""; - while ((line = br->readLine()) != L"") // 4J - was check against NULL - do we need to distinguish between empty lines and a fail here? + while ((line = br->readLine()) != L"") // 4J - was check against nullptr - do we need to distinguish between empty lines and a fail here? { // 4J - removed try/catch // try { diff --git a/Minecraft.Client/OptionsScreen.cpp b/Minecraft.Client/OptionsScreen.cpp index 197d74763..507640066 100644 --- a/Minecraft.Client/OptionsScreen.cpp +++ b/Minecraft.Client/OptionsScreen.cpp @@ -47,7 +47,7 @@ void OptionsScreen::init() void OptionsScreen::buttonClicked(Button *button) { if (!button->active) return; - if (button->id < 100 && (dynamic_cast(button) != NULL)) + if (button->id < 100 && (dynamic_cast(button) != nullptr)) { options->toggle(static_cast(button)->getOption(), 1); button->msg = options->getMessage(Options::Option::getItem(button->id)); diff --git a/Minecraft.Client/Orbis/4JLibs/inc/4J_Profile.h b/Minecraft.Client/Orbis/4JLibs/inc/4J_Profile.h index 03651b8fe..d988adbfe 100644 --- a/Minecraft.Client/Orbis/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/Orbis/4JLibs/inc/4J_Profile.h @@ -120,7 +120,7 @@ class C_4JProfile // ACHIEVEMENTS & AWARDS void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false, - CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L); + CXuiStringTable*pStringTable=nullptr, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=nullptr, unsigned int uiThemeSize=0L); int GetAwardId(int iAwardNumber); eAwardType GetAwardType(int iAwardNumber); bool CanBeAwarded(int iQuadrant, int iAwardNumber); diff --git a/Minecraft.Client/Orbis/4JLibs/inc/4J_Render.h b/Minecraft.Client/Orbis/4JLibs/inc/4J_Render.h index 6083654d2..00210f609 100644 --- a/Minecraft.Client/Orbis/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/Orbis/4JLibs/inc/4J_Render.h @@ -19,8 +19,8 @@ class ImageFileBuffer int GetType() { return m_type; } void *GetBufferPointer() { return m_pBuffer; } int GetBufferSize() { return m_bufferSize; } - void Release() { free(m_pBuffer); m_pBuffer = NULL; } - bool Allocated() { return m_pBuffer != NULL; } + void Release() { free(m_pBuffer); m_pBuffer = nullptr; } + bool Allocated() { return m_pBuffer != nullptr; } }; typedef struct @@ -62,7 +62,7 @@ class C4JRender void InitialiseContext(); void StartFrame(bool actualFrameStart = true); void Present(); - void Clear(int flags);//, D3D11_RECT *pRect = NULL); + void Clear(int flags);//, D3D11_RECT *pRect = nullptr); void SetClearColour(const float colourRGBA[4]); bool IsWidescreen(); bool IsHiDef(); diff --git a/Minecraft.Client/Orbis/4JLibs/inc/4J_Storage.h b/Minecraft.Client/Orbis/4JLibs/inc/4J_Storage.h index d4d845dfa..467c7a116 100644 --- a/Minecraft.Client/Orbis/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/Orbis/4JLibs/inc/4J_Storage.h @@ -28,7 +28,7 @@ typedef struct int newSaveBlocksUsed; int iSaveC; PSAVE_INFO SaveInfoA; - PSAVE_INFO pCurrentSaveInfo; // Pointer to SAVE_INFO for the save that has just been loaded, or NULL if no save has been loaded (ie this is a newly created game) + PSAVE_INFO pCurrentSaveInfo; // Pointer to SAVE_INFO for the save that has just been loaded, or nullptr if no save has been loaded (ie this is a newly created game) } SAVE_DETAILS,*PSAVE_DETAILS; @@ -315,7 +315,7 @@ class C4JStorage // Get details of existing savedata C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(LPVOID lpParam,SAVE_DETAILS *pSaveDetails,const bool),LPVOID lpParam,char *pszSavePackName); // Start search - PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or NULL if not yet received) + PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or nullptr if not yet received) void ClearSavesInfo(); // Clears results C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam); // Get the thumbnail for an individual save referenced by pSaveInfo @@ -398,8 +398,8 @@ class C4JStorage EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); CONTENT_DATA& GetDLC(DWORD dw); DWORD GetAvailableDLCCount( int iPad ); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = NULL); - DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = nullptr); + DWORD UnmountInstalledDLC(LPCSTR szMountDrive = nullptr); void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); std::string GetMountedPath(std::string szMount); void SetDLCProductCode(const char* szProductCode); diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.cpp b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.cpp index 122333607..33fd6b4a7 100644 --- a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.cpp +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.cpp @@ -353,7 +353,7 @@ static void gdraw_defragment_cache(GDrawHandleCache *c, GDrawStats *stats) // synchronize compute_to_graphics_sync(); - gdraw->gfxc->setCsShader(NULL); + gdraw->gfxc->setCsShader(nullptr); gdraw->gfxc->setShaderType(Gnm::kShaderTypeGraphics); // don't need to wait till GPU is done since we never access GPU memory from the @@ -365,7 +365,7 @@ static void api_free_resource(GDrawHandle *r) if (!r->cache->is_vertex) { for (S32 i=0; i < MAX_SAMPLERS; i++) if (gdraw->active_tex[i] == (GDrawTexture *) r) - gdraw->active_tex[i] = NULL; + gdraw->active_tex[i] = nullptr; } } @@ -410,7 +410,7 @@ static void track_staging_alloc_attempt(U32 size, U32 align) static void track_staging_alloc_failed() { if (gdraw->staging_stats.allocs_attempted == gdraw->staging_stats.allocs_succeeded + 1) { // warn the first time we run out of mem - IggyGDrawSendWarning(NULL, "GDraw out of staging memory"); + IggyGDrawSendWarning(nullptr, "GDraw out of staging memory"); } } @@ -537,7 +537,7 @@ static void gpu_compute_memset(void *ptr, U32 value, U32 size_in_bytes) // through the regular caches. gfxc->flushShaderCachesAndWait(Gnm::kCacheActionWriteBackL2Volatile, 0, Gnm::kStallCommandBufferParserDisable); gfxc->setShaderType(Gnm::kShaderTypeGraphics); - gfxc->setCsShader(NULL); + gfxc->setCsShader(nullptr); } //////////////////////////////////////////////////////////////////////// @@ -549,8 +549,8 @@ GDrawTexture * RADLINK gdraw_orbis_WrappedTextureCreate(Gnm::Texture *tex) { GDrawStats stats = {}; GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats); - p->handle.tex.gnm_ptr = NULL; - gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned); + p->handle.tex.gnm_ptr = nullptr; + gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned); gdraw_orbis_WrappedTextureChange((GDrawTexture *) p, tex); return (GDrawTexture *) p; } @@ -583,13 +583,13 @@ static void RADLINK gdraw_SetTextureUniqueID(GDrawTexture *tex, void *old_id, vo static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format gformat, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) { S32 bytes_pixel = 4; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; Gnm::Texture gt; Gnm::SizeAlign sa; Gnm::DataFormat format = Gnm::kDataFormatR8G8B8A8Unorm; if (width > MAX_TEXTURE2D_DIM || height > MAX_TEXTURE2D_DIM) { - IggyGDrawSendWarning(NULL, "GDraw %d x %d texture not supported by hardware (dimension limit %d)", width, height, MAX_TEXTURE2D_DIM); + IggyGDrawSendWarning(nullptr, "GDraw %d x %d texture not supported by hardware (dimension limit %d)", width, height, MAX_TEXTURE2D_DIM); return false; } @@ -742,8 +742,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void *unique_id, GDr static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats) { GDrawHandle *t = (GDrawHandle *) tt; - assert(t != NULL); - if (t->owner == unique_id || unique_id == NULL) { + assert(t != nullptr); + if (t->owner == unique_id || unique_id == nullptr) { if (t->cache == &gdraw->rendertargets) { gdraw_HandleCacheUnlock(t); // cache it by simply not freeing it @@ -863,7 +863,7 @@ static rrbool RADLINK gdraw_TryLockVertexBuffer(GDrawVertexBuffer *vb, void *uni static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) { GDrawHandle *h = (GDrawHandle *) vb; - assert(h != NULL); // @GDRAW_ASSERT + assert(h != nullptr); // @GDRAW_ASSERT if (h->owner == unique_id) gdraw_res_kill(h, stats); } @@ -891,19 +891,19 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats) t = gdraw_HandleCacheAllocateBegin(&gdraw->rendertargets); if (!t) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit handle limit"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit handle limit"); return t; } U8 *ptr = (U8 *)gdraw_arena_alloc(&gdraw->rt_arena, gdraw->rt_colorbuffer_sa.m_size, gdraw->rt_colorbuffer_sa.m_align); if (!ptr) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: out of rendertarget texture memory"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: out of rendertarget texture memory"); gdraw_HandleCacheAllocateFail(t); - return NULL; + return nullptr; } t->fence = get_next_fence(); - t->raw_ptr = NULL; + t->raw_ptr = nullptr; t->handle.tex.gnm_ptr = ptr; t->handle.tex.gnm->initFromRenderTarget(&gdraw->rt_colorbuffer, false); @@ -1065,7 +1065,7 @@ static void set_common_renderstate() // clear our state caching memset(gdraw->active_tex, 0, sizeof(gdraw->active_tex)); - gdraw->cur_ps = NULL; + gdraw->cur_ps = nullptr; gdraw->scissor_state = ~0u; gdraw->blend_mode = -1; @@ -1230,7 +1230,7 @@ static void eliminate_fast_clear() } gfxc->setCbControl(Gnm::kCbModeEliminateFastClear, Gnm::kRasterOpSrcCopy); - gfxc->setPsShader(NULL); + gfxc->setPsShader(nullptr); set_viewport_raw(r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0); set_projection_raw(r.x0, r.x1, r.y1, r.y0); GDrawStats stats = {}; // we already counted these clears once, so don't add to main stats @@ -1245,7 +1245,7 @@ static void eliminate_fast_clear() set_viewport(); set_projection(); - gdraw->cur_ps = NULL; + gdraw->cur_ps = nullptr; gdraw->cur->needs_clear_eliminate = false; } @@ -1276,7 +1276,7 @@ static inline U32 pack_color_8888(F32 x, F32 y, F32 z, F32 w) void gdraw_orbis_ClearWholeRenderTarget(const F32 clear_color_rgba[4]) { - assert(gdraw->gfxc != NULL); // call after gdraw_orbis_Begin + assert(gdraw->gfxc != nullptr); // call after gdraw_orbis_Begin gdraw->cur = gdraw->frame; set_common_renderstate(); @@ -1336,16 +1336,16 @@ static void RADLINK gdraw_SetViewSizeAndWorldScale(S32 w, S32 h, F32 scalex, F32 // must include anything necessary for texture creation/update static void RADLINK gdraw_RenderingBegin(void) { - assert(gdraw->gfxc != NULL); // call after gdraw_orbis_Begin + assert(gdraw->gfxc != nullptr); // call after gdraw_orbis_Begin // unbind all shaders Gnmx::GfxContext *gfxc = gdraw->gfxc; - gfxc->setVsShader(NULL, 0, (void*)0); - gfxc->setPsShader(NULL); - gfxc->setCsShader(NULL); - gfxc->setLsHsShaders(NULL, 0, (void*)0, NULL, 0); - gfxc->setEsShader(NULL, 0, (void *) 0); - gfxc->setGsVsShaders(NULL); + gfxc->setVsShader(nullptr, 0, (void*)0); + gfxc->setPsShader(nullptr); + gfxc->setCsShader(nullptr); + gfxc->setLsHsShaders(nullptr, 0, (void*)0, nullptr, 0); + gfxc->setEsShader(nullptr, 0, (void *) 0); + gfxc->setGsVsShaders(nullptr); set_common_renderstate(); } @@ -1406,7 +1406,7 @@ GDRAW_MAYBE_UNUSED static bool mem_is_direct_and_write_combined_or_cached(const void gdraw_orbis_Begin(sce::Gnmx::GfxContext *context, void *staging_buffer, U32 staging_buf_bytes) { - assert(gdraw->gfxc == NULL); // may not nest Begin calls + assert(gdraw->gfxc == nullptr); // may not nest Begin calls // make sure that the memory setup is sensible. // if any of these asserts fire, please relocate your command buffers @@ -1426,13 +1426,13 @@ void gdraw_orbis_Begin(sce::Gnmx::GfxContext *context, void *staging_buffer, U32 void gdraw_orbis_End(gdraw_orbis_staging_stats *stats) { - assert(gdraw->gfxc != NULL); // please keep Begin / End pairs properly matched + assert(gdraw->gfxc != nullptr); // please keep Begin / End pairs properly matched gdraw_HandleCacheTick(gdraw->texturecache, gdraw->tile_end_fence); gdraw_HandleCacheTick(gdraw->vbufcache, gdraw->tile_end_fence); - gdraw_arena_init(&gdraw->staging, NULL, 0); - gdraw->gfxc = NULL; + gdraw_arena_init(&gdraw->staging, nullptr, 0); + gdraw->gfxc = nullptr; if (stats) *stats = gdraw->staging_stats; @@ -1440,7 +1440,7 @@ void gdraw_orbis_End(gdraw_orbis_staging_stats *stats) void gdraw_orbis_EliminateFastClears(void) { - assert(gdraw->gfxc != NULL); // call between gdraw_orbis_Begin and gdraw_orbis_End + assert(gdraw->gfxc != nullptr); // call between gdraw_orbis_Begin and gdraw_orbis_End eliminate_fast_clear(); } @@ -1469,18 +1469,18 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex GDrawFramebufferState *n = gdraw->cur+1; GDrawHandle *t; if (gdraw->tw == 0 || gdraw->th == 0) { - IggyGDrawSendWarning(NULL, "GDraw warning: w=0,h=0 rendertarget"); + IggyGDrawSendWarning(nullptr, "GDraw warning: w=0,h=0 rendertarget"); return false; } if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); return false; } if (owner) { // @TODO implement - t = NULL; + t = nullptr; assert(0); // nyi } else { t = get_color_rendertarget(stats); @@ -1489,9 +1489,9 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex } n->color_buffer = t; - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT - n->cached = owner != NULL; + n->cached = owner != nullptr; if (owner) { n->base_x = region->x0; n->base_y = region->y0; @@ -1571,9 +1571,9 @@ static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats) assert(m >= gdraw->frame); // bug in Iggy -- unbalanced if (m != gdraw->frame) { - assert(m->color_buffer != NULL); // @GDRAW_ASSERT + assert(m->color_buffer != nullptr); // @GDRAW_ASSERT } - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT // sync on draw completion for this render target rtt_sync(n->color_buffer->handle.tex.gnm_ptr, gdraw->rt_colorbuffer_sa.m_size >> 8); @@ -1615,7 +1615,7 @@ static void RADLINK gdraw_ClearID(void) static RADINLINE void set_texture(U32 texunit, GDrawTexture *tex) { assert(texunit < MAX_SAMPLERS); - assert(tex != NULL); + assert(tex != nullptr); if (gdraw->active_tex[texunit] != tex) { gdraw->active_tex[texunit] = tex; @@ -1791,7 +1791,7 @@ static void set_vertex_buffer(const GDraw::VFormatDesc *fmtdesc, void *ptr, U32 gdraw->gfxc->setBuffers(Gnm::kShaderStageVs, 0, fmtdesc->num_attribs, bufs); } -static RADINLINE void fence_resources(void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL) +static RADINLINE void fence_resources(void *r1, void *r2=nullptr, void *r3=nullptr, void *r4=nullptr) { GDrawFence fence = get_next_fence(); if (r1) ((GDrawHandle *) r1)->fence = fence; @@ -1937,7 +1937,7 @@ static void set_clamp_constant(F32 *constant, GDrawTexture *tex) static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbevel, GDrawStats *stats) { - if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, stats)) + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, nullptr, stats)) return; set_texture(0, r->tex[0]); @@ -2236,7 +2236,7 @@ static GDrawHandleCache *make_handle_cache(gdraw_orbis_resourcetype type, U32 al cache->alloc = gfxalloc_create(gdraw_limits[type].ptr, num_bytes, align, num_handles); if (!cache->alloc) { IggyGDrawFree(cache); - cache = NULL; + cache = nullptr; } } @@ -2302,12 +2302,12 @@ int gdraw_orbis_SetResourceMemory(gdraw_orbis_resourcetype type, S32 num_handles case GDRAW_ORBIS_RESOURCE_texture: free_handle_cache(gdraw->texturecache); gdraw->texturecache = make_handle_cache(GDRAW_ORBIS_RESOURCE_texture, GDRAW_ORBIS_TEXTURE_ALIGNMENT); - return gdraw->texturecache != NULL; + return gdraw->texturecache != nullptr; case GDRAW_ORBIS_RESOURCE_vertexbuffer: free_handle_cache(gdraw->vbufcache); gdraw->vbufcache = make_handle_cache(GDRAW_ORBIS_RESOURCE_vertexbuffer, GDRAW_ORBIS_VERTEXBUFFER_ALIGNMENT); - return gdraw->vbufcache != NULL; + return gdraw->vbufcache != nullptr; default: return 0; @@ -2316,9 +2316,9 @@ int gdraw_orbis_SetResourceMemory(gdraw_orbis_resourcetype type, S32 num_handles void gdraw_orbis_ResetAllResourceMemory() { - gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_rendertarget, 0, NULL, 0); - gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_texture, 0, NULL, 0); - gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_vertexbuffer, 0, NULL, 0); + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_rendertarget, 0, nullptr, 0); + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_texture, 0, nullptr, 0); + gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_vertexbuffer, 0, nullptr, 0); } GDrawFunctions *gdraw_orbis_CreateContext(S32 w, S32 h, void *context_shared_mem) @@ -2326,7 +2326,7 @@ GDrawFunctions *gdraw_orbis_CreateContext(S32 w, S32 h, void *context_shared_mem U32 cpram_shadow_size = Gnmx::ConstantUpdateEngine::computeCpRamShadowSize(); gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw) + cpram_shadow_size); - if (!gdraw) return NULL; + if (!gdraw) return nullptr; memset(gdraw, 0, sizeof(*gdraw)); @@ -2349,7 +2349,7 @@ GDrawFunctions *gdraw_orbis_CreateContext(S32 w, S32 h, void *context_shared_mem Gnm::DataFormat rtFormat = Gnm::kDataFormatR8G8B8A8Unorm; Gnm::TileMode tileMode; GpuAddress::computeSurfaceTileMode(&tileMode, GpuAddress::kSurfaceTypeRwTextureFlat, rtFormat, 1); - gdraw->rt_colorbuffer_sa = gdraw->rt_colorbuffer.init(gdraw->frametex_width, gdraw->frametex_height, 1, rtFormat, tileMode, Gnm::kNumSamples1, Gnm::kNumFragments1, NULL, NULL); + gdraw->rt_colorbuffer_sa = gdraw->rt_colorbuffer.init(gdraw->frametex_width, gdraw->frametex_height, 1, rtFormat, tileMode, Gnm::kNumSamples1, Gnm::kNumFragments1, nullptr, nullptr); gdraw->rt_colorbuffer.setCmaskFastClearEnable(false); // shaders and state @@ -2418,7 +2418,7 @@ void gdraw_orbis_DestroyContext(void) free_handle_cache(gdraw->texturecache); free_handle_cache(gdraw->vbufcache); IggyGDrawFree(gdraw); - gdraw = NULL; + gdraw = nullptr; } } diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.h b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.h index 9fecfb085..13964e078 100644 --- a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.h +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis.h @@ -50,7 +50,7 @@ IDOC extern int gdraw_orbis_SetResourceMemory(gdraw_orbis_resourcetype type, S32 currently hold. SetResourceMemory takes a void* argument for the address of the resource pool. - Pass in NULL and zero bytes to reset a specific pool. + Pass in nullptr and zero bytes to reset a specific pool. Resource pool memory has certain alignment requirements - see the #defines above. If you pass in an unaligned pointer, GDraw will automatically clip off @@ -86,7 +86,7 @@ IDOC extern GDrawFunctions * gdraw_orbis_CreateContext(S32 w, S32 h, void *conte There can only be one GDraw context active at any one time. If initialization fails for some reason (the main reason would be an out of memory condition), - NULL is returned. Otherwise, you can pass the return value to IggySetGDraw. */ + nullptr is returned. Otherwise, you can pass the return value to IggySetGDraw. */ IDOC extern void gdraw_orbis_DestroyContext(void); /* Destroys the current GDraw context, if any. @@ -126,7 +126,7 @@ IDOC extern void gdraw_orbis_End(gdraw_orbis_staging_stats *staging_stats); staging_stats will be filled with stats for the staging buffer, denoting how much memory was actually used and which allocations were attempted. If you're not interested, just - pass NULL. */ + pass nullptr. */ IDOC extern void gdraw_orbis_SetTileOrigin(sce::Gnm::RenderTarget *color, sce::Gnm::DepthRenderTarget *depth, S32 x, S32 y); /* This sets the main color and depth buffers that GDraw should render to and the diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis_shaders.inl b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis_shaders.inl index fc3e31a38..00010f809 100644 --- a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis_shaders.inl +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_orbis_shaders.inl @@ -517,24 +517,24 @@ static unsigned char pshader_basic_17[412] = { }; static ShaderCode pshader_basic_arr[18] = { - { pshader_basic_0, { NULL } }, - { pshader_basic_1, { NULL } }, - { pshader_basic_2, { NULL } }, - { pshader_basic_3, { NULL } }, - { pshader_basic_4, { NULL } }, - { pshader_basic_5, { NULL } }, - { pshader_basic_6, { NULL } }, - { pshader_basic_7, { NULL } }, - { pshader_basic_8, { NULL } }, - { pshader_basic_9, { NULL } }, - { pshader_basic_10, { NULL } }, - { pshader_basic_11, { NULL } }, - { pshader_basic_12, { NULL } }, - { pshader_basic_13, { NULL } }, - { pshader_basic_14, { NULL } }, - { pshader_basic_15, { NULL } }, - { pshader_basic_16, { NULL } }, - { pshader_basic_17, { NULL } }, + { pshader_basic_0, { nullptr } }, + { pshader_basic_1, { nullptr } }, + { pshader_basic_2, { nullptr } }, + { pshader_basic_3, { nullptr } }, + { pshader_basic_4, { nullptr } }, + { pshader_basic_5, { nullptr } }, + { pshader_basic_6, { nullptr } }, + { pshader_basic_7, { nullptr } }, + { pshader_basic_8, { nullptr } }, + { pshader_basic_9, { nullptr } }, + { pshader_basic_10, { nullptr } }, + { pshader_basic_11, { nullptr } }, + { pshader_basic_12, { nullptr } }, + { pshader_basic_13, { nullptr } }, + { pshader_basic_14, { nullptr } }, + { pshader_basic_15, { nullptr } }, + { pshader_basic_16, { nullptr } }, + { pshader_basic_17, { nullptr } }, }; static unsigned char pshader_exceptional_blend_1[440] = { @@ -917,19 +917,19 @@ static unsigned char pshader_exceptional_blend_12[336] = { }; static ShaderCode pshader_exceptional_blend_arr[13] = { - { NULL, { NULL } }, - { pshader_exceptional_blend_1, { NULL } }, - { pshader_exceptional_blend_2, { NULL } }, - { pshader_exceptional_blend_3, { NULL } }, - { pshader_exceptional_blend_4, { NULL } }, - { pshader_exceptional_blend_5, { NULL } }, - { pshader_exceptional_blend_6, { NULL } }, - { pshader_exceptional_blend_7, { NULL } }, - { pshader_exceptional_blend_8, { NULL } }, - { pshader_exceptional_blend_9, { NULL } }, - { pshader_exceptional_blend_10, { NULL } }, - { pshader_exceptional_blend_11, { NULL } }, - { pshader_exceptional_blend_12, { NULL } }, + { nullptr, { nullptr } }, + { pshader_exceptional_blend_1, { nullptr } }, + { pshader_exceptional_blend_2, { nullptr } }, + { pshader_exceptional_blend_3, { nullptr } }, + { pshader_exceptional_blend_4, { nullptr } }, + { pshader_exceptional_blend_5, { nullptr } }, + { pshader_exceptional_blend_6, { nullptr } }, + { pshader_exceptional_blend_7, { nullptr } }, + { pshader_exceptional_blend_8, { nullptr } }, + { pshader_exceptional_blend_9, { nullptr } }, + { pshader_exceptional_blend_10, { nullptr } }, + { pshader_exceptional_blend_11, { nullptr } }, + { pshader_exceptional_blend_12, { nullptr } }, }; static unsigned char pshader_filter_0[420] = { @@ -1685,38 +1685,38 @@ static unsigned char pshader_filter_27[412] = { }; static ShaderCode pshader_filter_arr[32] = { - { pshader_filter_0, { NULL } }, - { pshader_filter_1, { NULL } }, - { pshader_filter_2, { NULL } }, - { pshader_filter_3, { NULL } }, - { pshader_filter_4, { NULL } }, - { pshader_filter_5, { NULL } }, - { pshader_filter_6, { NULL } }, - { pshader_filter_7, { NULL } }, - { pshader_filter_8, { NULL } }, - { pshader_filter_9, { NULL } }, - { pshader_filter_10, { NULL } }, - { pshader_filter_11, { NULL } }, - { NULL, { NULL } }, - { NULL, { NULL } }, - { NULL, { NULL } }, - { NULL, { NULL } }, - { pshader_filter_16, { NULL } }, - { pshader_filter_17, { NULL } }, - { pshader_filter_18, { NULL } }, - { pshader_filter_19, { NULL } }, - { pshader_filter_20, { NULL } }, - { pshader_filter_21, { NULL } }, - { pshader_filter_22, { NULL } }, - { pshader_filter_23, { NULL } }, - { pshader_filter_24, { NULL } }, - { pshader_filter_25, { NULL } }, - { pshader_filter_26, { NULL } }, - { pshader_filter_27, { NULL } }, - { NULL, { NULL } }, - { NULL, { NULL } }, - { NULL, { NULL } }, - { NULL, { NULL } }, + { pshader_filter_0, { nullptr } }, + { pshader_filter_1, { nullptr } }, + { pshader_filter_2, { nullptr } }, + { pshader_filter_3, { nullptr } }, + { pshader_filter_4, { nullptr } }, + { pshader_filter_5, { nullptr } }, + { pshader_filter_6, { nullptr } }, + { pshader_filter_7, { nullptr } }, + { pshader_filter_8, { nullptr } }, + { pshader_filter_9, { nullptr } }, + { pshader_filter_10, { nullptr } }, + { pshader_filter_11, { nullptr } }, + { nullptr, { nullptr } }, + { nullptr, { nullptr } }, + { nullptr, { nullptr } }, + { nullptr, { nullptr } }, + { pshader_filter_16, { nullptr } }, + { pshader_filter_17, { nullptr } }, + { pshader_filter_18, { nullptr } }, + { pshader_filter_19, { nullptr } }, + { pshader_filter_20, { nullptr } }, + { pshader_filter_21, { nullptr } }, + { pshader_filter_22, { nullptr } }, + { pshader_filter_23, { nullptr } }, + { pshader_filter_24, { nullptr } }, + { pshader_filter_25, { nullptr } }, + { pshader_filter_26, { nullptr } }, + { pshader_filter_27, { nullptr } }, + { nullptr, { nullptr } }, + { nullptr, { nullptr } }, + { nullptr, { nullptr } }, + { nullptr, { nullptr } }, }; static unsigned char pshader_blur_2[356] = { @@ -2024,16 +2024,16 @@ static unsigned char pshader_blur_9[748] = { }; static ShaderCode pshader_blur_arr[10] = { - { NULL, { NULL } }, - { NULL, { NULL } }, - { pshader_blur_2, { NULL } }, - { pshader_blur_3, { NULL } }, - { pshader_blur_4, { NULL } }, - { pshader_blur_5, { NULL } }, - { pshader_blur_6, { NULL } }, - { pshader_blur_7, { NULL } }, - { pshader_blur_8, { NULL } }, - { pshader_blur_9, { NULL } }, + { nullptr, { nullptr } }, + { nullptr, { nullptr } }, + { pshader_blur_2, { nullptr } }, + { pshader_blur_3, { nullptr } }, + { pshader_blur_4, { nullptr } }, + { pshader_blur_5, { nullptr } }, + { pshader_blur_6, { nullptr } }, + { pshader_blur_7, { nullptr } }, + { pshader_blur_8, { nullptr } }, + { pshader_blur_9, { nullptr } }, }; static unsigned char pshader_color_matrix_0[348] = { @@ -2062,7 +2062,7 @@ static unsigned char pshader_color_matrix_0[348] = { }; static ShaderCode pshader_color_matrix_arr[1] = { - { pshader_color_matrix_0, { NULL } }, + { pshader_color_matrix_0, { nullptr } }, }; static unsigned char pshader_manual_clear_0[164] = { @@ -2080,7 +2080,7 @@ static unsigned char pshader_manual_clear_0[164] = { }; static ShaderCode pshader_manual_clear_arr[1] = { - { pshader_manual_clear_0, { NULL } }, + { pshader_manual_clear_0, { nullptr } }, }; static unsigned char vshader_vsps4_0[580] = { @@ -2124,7 +2124,7 @@ static unsigned char vshader_vsps4_0[580] = { }; static ShaderCode vshader_vsps4_arr[1] = { - { vshader_vsps4_0, { NULL } }, + { vshader_vsps4_0, { nullptr } }, }; static unsigned char cshader_tex_upload_0[212] = { @@ -2145,7 +2145,7 @@ static unsigned char cshader_tex_upload_0[212] = { }; static ShaderCode cshader_tex_upload_arr[1] = { - { cshader_tex_upload_0, { NULL } }, + { cshader_tex_upload_0, { nullptr } }, }; static unsigned char cshader_memset_0[196] = { @@ -2165,7 +2165,7 @@ static unsigned char cshader_memset_0[196] = { }; static ShaderCode cshader_memset_arr[1] = { - { cshader_memset_0, { NULL } }, + { cshader_memset_0, { nullptr } }, }; static unsigned char cshader_defragment_0[204] = { @@ -2185,7 +2185,7 @@ static unsigned char cshader_defragment_0[204] = { }; static ShaderCode cshader_defragment_arr[1] = { - { cshader_defragment_0, { NULL } }, + { cshader_defragment_0, { nullptr } }, }; static unsigned char cshader_mipgen_0[340] = { @@ -2214,6 +2214,6 @@ static unsigned char cshader_mipgen_0[340] = { }; static ShaderCode cshader_mipgen_arr[1] = { - { cshader_mipgen_0, { NULL } }, + { cshader_mipgen_0, { nullptr } }, }; diff --git a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl index b0bf146dc..1b7c1cc1e 100644 --- a/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/Orbis/Iggy/gdraw/gdraw_shared.inl @@ -226,7 +226,7 @@ static void debug_check_raw_values(GDrawHandleCache *c) s = s->next; } s = c->active; - while (s != NULL) { + while (s != nullptr) { assert(s->raw_ptr != t->raw_ptr); s = s->next; } @@ -433,7 +433,7 @@ static rrbool gdraw_HandleCacheLockStats(GDrawHandle *t, void *owner, GDrawStats static rrbool gdraw_HandleCacheLock(GDrawHandle *t, void *owner) { - return gdraw_HandleCacheLockStats(t, owner, NULL); + return gdraw_HandleCacheLockStats(t, owner, nullptr); } static void gdraw_HandleCacheUnlock(GDrawHandle *t) @@ -461,11 +461,11 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->is_thrashing = false; c->did_defragment = false; for (i=0; i < GDRAW_HANDLE_STATE__count; i++) { - c->state[i].owner = NULL; - c->state[i].cache = NULL; // should never follow cache link from sentinels! + c->state[i].owner = nullptr; + c->state[i].cache = nullptr; // should never follow cache link from sentinels! c->state[i].next = c->state[i].prev = &c->state[i]; #ifdef GDRAW_MANAGE_MEM - c->state[i].raw_ptr = NULL; + c->state[i].raw_ptr = nullptr; #endif c->state[i].fence.value = 0; c->state[i].bytes = 0; @@ -478,7 +478,7 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->handle[i].bytes = 0; c->handle[i].state = GDRAW_HANDLE_STATE_free; #ifdef GDRAW_MANAGE_MEM - c->handle[i].raw_ptr = NULL; + c->handle[i].raw_ptr = nullptr; #endif } c->state[GDRAW_HANDLE_STATE_free].next = &c->handle[0]; @@ -486,10 +486,10 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->prev_frame_start.value = 0; c->prev_frame_end.value = 0; #ifdef GDRAW_MANAGE_MEM - c->alloc = NULL; + c->alloc = nullptr; #endif #ifdef GDRAW_MANAGE_MEM_TWOPOOL - c->alloc_other = NULL; + c->alloc_other = nullptr; #endif check_lists(c); } @@ -497,14 +497,14 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte static GDrawHandle *gdraw_HandleCacheAllocateBegin(GDrawHandleCache *c) { GDrawHandle *free_list = &c->state[GDRAW_HANDLE_STATE_free]; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (free_list->next != free_list) { t = free_list->next; gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_alloc); t->bytes = 0; t->owner = 0; #ifdef GDRAW_MANAGE_MEM - t->raw_ptr = NULL; + t->raw_ptr = nullptr; #endif #ifdef GDRAW_CORRUPTION_CHECK t->has_check_value = false; @@ -563,7 +563,7 @@ static GDrawHandle *gdraw_HandleCacheGetLRU(GDrawHandleCache *c) // at the front of the LRU list are the oldest ones, since in-use resources // will get appended on every transition from "locked" to "live". GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_live]; - return (sentinel->next != sentinel) ? sentinel->next : NULL; + return (sentinel->next != sentinel) ? sentinel->next : nullptr; } static void gdraw_HandleCacheTick(GDrawHandleCache *c, GDrawFence now) @@ -1095,7 +1095,7 @@ static void make_pool_aligned(void **start, S32 *num_bytes, U32 alignment) if (addr_aligned != addr_orig) { S32 diff = (S32) (addr_aligned - addr_orig); if (*num_bytes < diff) { - *start = NULL; + *start = nullptr; *num_bytes = 0; return; } else { @@ -1132,7 +1132,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) UINTa remaining = arena->end - arena->current; UINTa total_size = (ptr - arena->current) + size; if (remaining < total_size) // doesn't fit - return NULL; + return nullptr; arena->current = ptr + size; return ptr; @@ -1157,7 +1157,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // (i.e. block->next->prev == block->prev->next == block) // - All allocated blocks are also kept in a hash table, indexed by their // pointer (to allow free to locate the corresponding block_info quickly). -// There's a single-linked, NULL-terminated list of elements in each hash +// There's a single-linked, nullptr-terminated list of elements in each hash // bucket. // - The physical block list is ordered. It always contains all currently // active blocks and spans the whole managed memory range. There are no @@ -1166,7 +1166,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // they are coalesced immediately. // - The maximum number of blocks that could ever be necessary is allocated // on initialization. All block_infos not currently in use are kept in a -// single-linked, NULL-terminated list of unused blocks. Every block is either +// single-linked, nullptr-terminated list of unused blocks. Every block is either // in the physical block list or the unused list, and the total number of // blocks is constant. // These invariants always hold before and after an allocation/free. @@ -1384,7 +1384,7 @@ static void gfxalloc_check2(gfx_allocator *alloc) static gfx_block_info *gfxalloc_pop_unused(gfx_allocator *alloc) { - GFXALLOC_ASSERT(alloc->unused_list != NULL); + GFXALLOC_ASSERT(alloc->unused_list != nullptr); GFXALLOC_ASSERT(alloc->unused_list->is_unused); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_unused);) @@ -1457,7 +1457,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma U32 i, max_blocks, size; if (!align || (align & (align - 1)) != 0) // align must be >0 and a power of 2 - return NULL; + return nullptr; // for <= max_allocs live allocs, there's <= 2*max_allocs+1 blocks. worst case: // [free][used][free] .... [free][used][free] @@ -1465,7 +1465,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma size = sizeof(gfx_allocator) + max_blocks * sizeof(gfx_block_info); a = (gfx_allocator *) IggyGDrawMalloc(size); if (!a) - return NULL; + return nullptr; memset(a, 0, size); @@ -1506,16 +1506,16 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma a->blocks[i].is_unused = 1; gfxalloc_check(a); - debug_complete_check(a, NULL, 0,0); + debug_complete_check(a, nullptr, 0,0); return a; } static void *gfxalloc_alloc(gfx_allocator *alloc, U32 size_in_bytes) { - gfx_block_info *cur, *best = NULL; + gfx_block_info *cur, *best = nullptr; U32 i, best_wasted = ~0u; U32 size = size_in_bytes; -debug_complete_check(alloc, NULL, 0,0); +debug_complete_check(alloc, nullptr, 0,0); gfxalloc_check(alloc); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) @@ -1565,7 +1565,7 @@ gfxalloc_check(alloc); debug_check_overlap(alloc->cache, best->ptr, best->size); return best->ptr; } else - return NULL; // not enough space! + return nullptr; // not enough space! } static void gfxalloc_free(gfx_allocator *alloc, void *ptr) @@ -1735,7 +1735,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta // (unused for allocated blocks, we'll use it to store a back-pointer to the corresponding handle) for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys) if (!b->is_free) - b->prev = NULL; + b->prev = nullptr; // go through all handles and store a pointer to the handle in the corresponding memory block for (i=0; i < c->max_handles; i++) @@ -1748,7 +1748,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta break; } - GFXALLOC_ASSERT(b != NULL); // didn't find this block anywhere! + GFXALLOC_ASSERT(b != nullptr); // didn't find this block anywhere! } // clear alloc hash table (we rebuild it during defrag) @@ -1910,7 +1910,7 @@ static rrbool gdraw_CanDefragment(GDrawHandleCache *c) static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats) { GDrawHandleCache *c = t->cache; - void *ptr = NULL; + void *ptr = nullptr; assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); // anything we migrate should be in the "other" (old) pool @@ -2300,7 +2300,7 @@ static void gdraw_bufring_init(gdraw_bufring * RADRESTRICT ring, void *ptr, U32 static void gdraw_bufring_shutdown(gdraw_bufring * RADRESTRICT ring) { - ring->cur = NULL; + ring->cur = nullptr; ring->seg_size = 0; } @@ -2310,7 +2310,7 @@ static void *gdraw_bufring_alloc(gdraw_bufring * RADRESTRICT ring, U32 size, U32 gdraw_bufring_seg *seg; if (size > ring->seg_size) - return NULL; // nope, won't fit + return nullptr; // nope, won't fit assert(align <= ring->align); @@ -2415,7 +2415,7 @@ static rrbool gdraw_res_free_lru(GDrawHandleCache *c, GDrawStats *stats) // was it referenced since end of previous frame (=in this frame)? // if some, we're thrashing; report it to the user, but only once per frame. if (c->prev_frame_end.value < r->fence.value && !c->is_thrashing) { - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); c->is_thrashing = true; } @@ -2435,8 +2435,8 @@ static GDrawHandle *gdraw_res_alloc_outofmem(GDrawHandleCache *c, GDrawHandle *t { if (t) gdraw_HandleCacheAllocateFail(t); - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); - return NULL; + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); + return nullptr; } #ifndef GDRAW_MANAGE_MEM @@ -2445,7 +2445,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt { GDrawHandle *t; if (size > c->total_bytes) - gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); else { // given how much data we're going to allocate, throw out // data until there's "room" (this basically lets us use @@ -2453,7 +2453,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // packing it and being exact) while (c->bytes_free < size) { if (!gdraw_res_free_lru(c, stats)) { - gdraw_res_alloc_outofmem(c, NULL, "memory"); + gdraw_res_alloc_outofmem(c, nullptr, "memory"); break; } } @@ -2468,8 +2468,8 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // we'd trade off cost of regenerating) if (gdraw_res_free_lru(c, stats)) { t = gdraw_HandleCacheAllocateBegin(c); - if (t == NULL) { - gdraw_res_alloc_outofmem(c, NULL, "handles"); + if (t == nullptr) { + gdraw_res_alloc_outofmem(c, nullptr, "handles"); } } } @@ -2513,7 +2513,7 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) { GDRAW_FENCE_FLUSH(); // dead list is sorted by fence index - make sure all fence values are current. - r->owner = NULL; + r->owner = nullptr; gdraw_HandleCacheInsertDead(r); gdraw_res_reap(r->cache, stats); } @@ -2521,11 +2521,11 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats) { GDrawHandle *t; - void *ptr = NULL; + void *ptr = nullptr; gdraw_res_reap(c, stats); // NB this also does GDRAW_FENCE_FLUSH(); if (size > c->total_bytes) - return gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + return gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); // now try to allocate a handle t = gdraw_HandleCacheAllocateBegin(c); @@ -2537,7 +2537,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt gdraw_res_free_lru(c, stats); t = gdraw_HandleCacheAllocateBegin(c); if (!t) - return gdraw_res_alloc_outofmem(c, NULL, "handles"); + return gdraw_res_alloc_outofmem(c, nullptr, "handles"); } // try to allocate first diff --git a/Minecraft.Client/Orbis/Iggy/include/gdraw.h b/Minecraft.Client/Orbis/Iggy/include/gdraw.h index 404a2642b..7cc4ddd0e 100644 --- a/Minecraft.Client/Orbis/Iggy/include/gdraw.h +++ b/Minecraft.Client/Orbis/Iggy/include/gdraw.h @@ -356,13 +356,13 @@ IDOC typedef struct GDrawPrimitive IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats); /* Draws a collection of indexed triangles, ignoring special filters or blend modes. - If buf is NULL, then the pointers in 'prim' are machine pointers, and + If buf is nullptr, then the pointers in 'prim' are machine pointers, and you need to make a copy of the data (note currently all triangles implementing strokes (wide lines) go this path). - If buf is non-NULL, then use the appropriate vertex buffer, and the + If buf is non-nullptr, then use the appropriate vertex buffer, and the pointers in prim are actually offsets from the beginning of the - vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL; + vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) nullptr; (note there are separate spaces for vertices and indices; e.g. the first mesh in a given vertex buffer will normally have a 0 offset for the vertices and a 0 offset for the indices) @@ -455,7 +455,7 @@ IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_Pro /* Ends specification of a new texture. $:info The same handle initially passed to $gdraw_make_texture_begin - $:return Handle for the newly created texture, or NULL if an error occured + $:return Handle for the newly created texture, or nullptr if an error occured */ IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats); diff --git a/Minecraft.Client/Orbis/Iggy/include/iggyexpruntime.h b/Minecraft.Client/Orbis/Iggy/include/iggyexpruntime.h index 1f1a90a1c..a42ccbfff 100644 --- a/Minecraft.Client/Orbis/Iggy/include/iggyexpruntime.h +++ b/Minecraft.Client/Orbis/Iggy/include/iggyexpruntime.h @@ -25,8 +25,8 @@ IDOC RADEXPFUNC HIGGYEXP RADEXPLINK IggyExpCreate(char *ip_address, S32 port, vo $:storage A small block of storage that needed to store the $HIGGYEXP, must be at least $IGGYEXP_MIN_STORAGE $:storage_size_in_bytes The size of the block pointer to by storage -Returns a NULL HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer -can be contacted at the specified address/port. Otherwise returns a non-NULL $HIGGYEXP +Returns a nullptr HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer +can be contacted at the specified address/port. Otherwise returns a non-nullptr $HIGGYEXP which you can pass to $IggyUseExplorer. */ IDOC RADEXPFUNC void RADEXPLINK IggyExpDestroy(HIGGYEXP p); diff --git a/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.cpp b/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.cpp index b76621970..b2492381b 100644 --- a/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.cpp +++ b/Minecraft.Client/Orbis/Leaderboards/OrbisLeaderboardManager.cpp @@ -29,7 +29,7 @@ OrbisLeaderboardManager::OrbisLeaderboardManager() m_myXUID = INVALID_XUID; - m_scores = NULL; //m_stats = NULL; + m_scores = nullptr; //m_stats = nullptr; m_statsType = eStatsType_Kills; m_difficulty = 0; @@ -41,7 +41,7 @@ OrbisLeaderboardManager::OrbisLeaderboardManager() InitializeCriticalSection(&m_csViewsLock); m_running = false; - m_threadScoreboard = NULL; + m_threadScoreboard = nullptr; } OrbisLeaderboardManager::~OrbisLeaderboardManager() @@ -181,7 +181,7 @@ bool OrbisLeaderboardManager::getScoreByIds() SceRtcTick last_sort_date; SceNpScoreRankNumber mTotalRecord; - SceNpId *npIds = NULL; + SceNpId *npIds = nullptr; int ret; @@ -267,7 +267,7 @@ bool OrbisLeaderboardManager::getScoreByIds() ZeroMemory(comments, sizeof(SceNpScoreComment) * num); /* app.DebugPrintf("sceNpScoreGetRankingByNpId(\n\t transaction=%i,\n\t boardID=0,\n\t npId=%i,\n\t friendCount*sizeof(SceNpId)=%i*%i=%i,\ - rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t NULL, 0, NULL, 0,\n\t friendCount=%i,\n...\n", + rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t nullptr, 0, nullptr, 0,\n\t friendCount=%i,\n...\n", transaction, npId, friendCount, sizeof(SceNpId), friendCount*sizeof(SceNpId), rankData, friendCount*sizeof(SceNpScorePlayerRankData), friendCount ); */ @@ -284,9 +284,9 @@ bool OrbisLeaderboardManager::getScoreByIds() sceNpScoreDestroyTransactionCtx(ret); - if (npIds != NULL) delete [] npIds; - if (ptr != NULL) delete [] ptr; - if (comments != NULL) delete [] comments; + if (npIds != nullptr) delete [] npIds; + if (ptr != nullptr) delete [] ptr; + if (comments != nullptr) delete [] comments; return false; } @@ -297,9 +297,9 @@ bool OrbisLeaderboardManager::getScoreByIds() m_eStatsState = eStatsState_Failed; - if (npIds != NULL) delete [] npIds; - if (ptr != NULL) delete [] ptr; - if (comments != NULL) delete [] comments; + if (npIds != nullptr) delete [] npIds; + if (ptr != nullptr) delete [] ptr; + if (comments != nullptr) delete [] comments; return false; } @@ -322,14 +322,14 @@ bool OrbisLeaderboardManager::getScoreByIds() batch + comments, sizeof(SceNpScoreComment) * tmpNum, //OUT: Comments - NULL, 0, // GameData. (unused) + nullptr, 0, // GameData. (unused) tmpNum, &last_sort_date, &mTotalRecord, - NULL // Reserved, specify null. + nullptr // Reserved, specify null. ); if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) @@ -357,7 +357,7 @@ bool OrbisLeaderboardManager::getScoreByIds() m_readCount = num; // Filter scorers and construct output structure. - if (m_scores != NULL) delete [] m_scores; + if (m_scores != nullptr) delete [] m_scores; m_scores = new ReadScore[m_readCount]; convertToOutput(m_readCount, m_scores, ptr, comments); m_maxRank = m_readCount; @@ -390,7 +390,7 @@ bool OrbisLeaderboardManager::getScoreByIds() delete [] ptr; delete [] comments; error2: - if (npIds != NULL) delete [] npIds; + if (npIds != nullptr) delete [] npIds; error1: if (m_eStatsState != eStatsState_Canceled) m_eStatsState = eStatsState_Failed; app.DebugPrintf("[LeaderboardManger] getScoreByIds() FAILED, ret=0x%X\n", ret); @@ -443,14 +443,14 @@ bool OrbisLeaderboardManager::getScoreByRange() comments, sizeof(SceNpScoreComment) * num, //OUT: Comment Data - NULL, 0, // GameData. + nullptr, 0, // GameData. num, &last_sort_date, &m_maxRank, // 'Total number of players registered in the target scoreboard.' - NULL // Reserved, specify null. + nullptr // Reserved, specify null. ); if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) @@ -471,7 +471,7 @@ bool OrbisLeaderboardManager::getScoreByRange() delete [] ptr; delete [] comments; - m_scores = NULL; + m_scores = nullptr; m_readCount = 0; m_eStatsState = eStatsState_Ready; @@ -489,7 +489,7 @@ bool OrbisLeaderboardManager::getScoreByRange() //m_stats = ptr; //Maybe: addPadding(num,ptr); - if (m_scores != NULL) delete [] m_scores; + if (m_scores != nullptr) delete [] m_scores; m_readCount = ret; m_scores = new ReadScore[m_readCount]; for (int i=0; i 0) ret = eStatsReturn_Success; - if (m_readListener != NULL) + if (m_readListener != nullptr) { app.DebugPrintf("[LeaderboardManager] OnStatsReadComplete(%i, %i, _), m_readCount=%i.\n", ret, m_maxRank, m_readCount); m_readListener->OnStatsReadComplete(ret, m_maxRank, view); @@ -636,16 +636,16 @@ void OrbisLeaderboardManager::Tick() m_eStatsState = eStatsState_Idle; delete [] m_scores; - m_scores = NULL; + m_scores = nullptr; } break; case eStatsState_Failed: { view.m_numQueries = 0; - view.m_queries = NULL; + view.m_queries = nullptr; - if ( m_readListener != NULL ) + if ( m_readListener != nullptr ) m_readListener->OnStatsReadComplete(eStatsReturn_NetworkError, 0, view); m_eStatsState = eStatsState_Idle; @@ -667,7 +667,7 @@ bool OrbisLeaderboardManager::OpenSession() { if (m_openSessions == 0) { - if (m_threadScoreboard == NULL) + if (m_threadScoreboard == nullptr) { m_threadScoreboard = new C4JThread(&scoreboardThreadEntry, this, "4JScoreboard"); m_threadScoreboard->SetProcessor(CPU_CORE_LEADERBOARDS); @@ -762,7 +762,7 @@ void OrbisLeaderboardManager::FlushStats() {} void OrbisLeaderboardManager::CancelOperation() { - m_readListener = NULL; + m_readListener = nullptr; m_eStatsState = eStatsState_Canceled; if (m_requestId != 0) @@ -912,7 +912,7 @@ void OrbisLeaderboardManager::fromBase32(void *out, SceNpScoreComment *in) for (int i = 0; i < SCE_NP_SCORE_COMMENT_MAXLEN; i++) { ch[0] = in->utf8Comment[i]; - unsigned char fivebits = strtol(ch, NULL, 32) << 3; + unsigned char fivebits = strtol(ch, nullptr, 32) << 3; int sByte = (i*5) / 8; int eByte = (5+(i*5)) / 8; @@ -973,7 +973,7 @@ bool OrbisLeaderboardManager::test_string(string testing) int ctx = sceNpScoreCreateTransactionCtx(m_titleContext); if (ctx<0) return false; - int ret = sceNpScoreCensorComment(ctx, (const char *) &comment, NULL); + int ret = sceNpScoreCensorComment(ctx, (const char *) &comment, nullptr); if (ret == SCE_NP_COMMUNITY_SERVER_ERROR_CENSORED) { diff --git a/Minecraft.Client/Orbis/Miles/include/mss.h b/Minecraft.Client/Orbis/Miles/include/mss.h index 531dcbc92..a9fd231a9 100644 --- a/Minecraft.Client/Orbis/Miles/include/mss.h +++ b/Minecraft.Client/Orbis/Miles/include/mss.h @@ -584,7 +584,7 @@ typedef enum } MSS_SPEAKER; // -// Pass to AIL_midiOutOpen for NULL MIDI driver +// Pass to AIL_midiOutOpen for nullptr MIDI driver // #define MIDI_NULL_DRIVER ((U32)(S32)-2) @@ -833,7 +833,7 @@ the enumeration function until it returns 0. #define DEFAULT_DPWOD ((UINTa)-1) // Preferred WaveOut device == WAVE_MAPPER #define DIG_PREFERRED_DS_DEVICE 20 -#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default NULL GUID +#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default nullptr GUID #define MDI_SEQUENCES 21 @@ -1305,7 +1305,7 @@ typedef ASIRESULT (AILCALL *ASI_STARTUP)(void); typedef ASIRESULT (AILCALL * ASI_SHUTDOWN)(void); // -// Return codec error message, or NULL if no errors have occurred since +// Return codec error message, or nullptr if no errors have occurred since // last call // // The ASI error text state is global to all streams @@ -1878,7 +1878,7 @@ typedef struct _S3DSTATE // Portion of HSAMPLE that deals with 3D posi F32 spread; - HSAMPLE owner; // May be NULL if used for temporary/internal calculations + HSAMPLE owner; // May be nullptr if used for temporary/internal calculations AILFALLOFFCB falloff_function; // User function for min/max distance calculations, if desired MSSVECTOR3D position_graph[MILES_MAX_SEGMENT_COUNT]; @@ -2460,7 +2460,7 @@ typedef struct _DIG_DRIVER // Handle to digital audio driver S32 DS_initialized; - AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or NULL if none) + AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or nullptr if none) AILLPDIRECTSOUNDBUFFER DS_out_buff; // Output buffer (may be sec or prim) S32 DS_buffer_size; // Size of entire output buffer @@ -4866,10 +4866,10 @@ typedef struct U8 *MP3_file_image; // Original MP3_file_image pointer passed to AIL_inspect_MP3() S32 MP3_image_size; // Original MP3_image_size passed to AIL_inspect_MP3() - U8 *ID3v2; // ID3v2 tag, if not NULL + U8 *ID3v2; // ID3v2 tag, if not nullptr S32 ID3v2_size; // Size of tag in bytes - U8 *ID3v1; // ID3v1 tag, if not NULL (always 128 bytes long if present) + U8 *ID3v1; // ID3v1 tag, if not nullptr (always 128 bytes long if present) U8 *start_MP3_data; // Pointer to start of data area in file (not necessarily first valid frame) U8 *end_MP3_data; // Pointer to last valid byte in MP3 data area (before ID3v1 tag, if any) diff --git a/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.cpp b/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.cpp index d1c9cf15f..5db367d4c 100644 --- a/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.cpp +++ b/Minecraft.Client/Orbis/Network/Orbis_NPToolkit.cpp @@ -309,7 +309,7 @@ void hexStrToBin( val <<= 4; } else { - if (pBinBuf != NULL && binOffset < binBufSize) { + if (pBinBuf != nullptr && binOffset < binBufSize) { memcpy(pBinBuf + binOffset, &val, 1); val = 0; } @@ -317,7 +317,7 @@ void hexStrToBin( } } - if (val != 0 && pBinBuf != NULL && binOffset < binBufSize) { + if (val != 0 && pBinBuf != nullptr && binOffset < binBufSize) { memcpy(pBinBuf + binOffset, &val, 1); } diff --git a/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp index 650683b0a..13b3c32bd 100644 --- a/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp +++ b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp @@ -17,8 +17,8 @@ // #include "..\PS3Extras\PS3Strings.h" -int (* SQRNetworkManager_Orbis::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = NULL; -void * SQRNetworkManager_Orbis::s_SignInCompleteParam = NULL; +int (* SQRNetworkManager_Orbis::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = nullptr; +void * SQRNetworkManager_Orbis::s_SignInCompleteParam = nullptr; sce::Toolkit::NP::PresenceDetails SQRNetworkManager_Orbis::s_lastPresenceInfo; __int64 SQRNetworkManager_Orbis::s_lastPresenceTime = 0; @@ -109,8 +109,8 @@ SQRNetworkManager_Orbis::SQRNetworkManager_Orbis(ISQRNetworkManagerListener *lis m_isInSession = false; m_offlineGame = false; m_offlineSQR = false; - m_aServerId = NULL; - m_gameBootInvite = NULL; + m_aServerId = nullptr; + m_gameBootInvite = nullptr; m_onlineStatus = false; m_bLinkDisconnected = false; m_bRefreshingRestrictionsForInvite = false; @@ -137,7 +137,7 @@ void SQRNetworkManager_Orbis::Initialise() int32_t ret = 0; int32_t libCtxId = 0; - ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, NULL); + ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, nullptr); assert (ret >= 0); libCtxId = ret; @@ -251,7 +251,7 @@ void SQRNetworkManager_Orbis::InitialiseAfterOnline() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,s_SignInCompleteCallbackPad); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; s_SignInCompleteCallbackPad = -1; } return; @@ -334,7 +334,7 @@ void SQRNetworkManager_Orbis::RefreshChatAndContentRestrictionsReturned_HandleIn SQRNetworkManager_Orbis *netMan = (SQRNetworkManager_Orbis *)pParam; netMan->m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), netMan->m_gameBootInvite ); - netMan->m_gameBootInvite = NULL; + netMan->m_gameBootInvite = nullptr; netMan->m_bRefreshingRestrictionsForInvite = false; } @@ -357,7 +357,7 @@ void SQRNetworkManager_Orbis::Tick() m_bRefreshingRestrictionsForInvite = true; ProfileManager.RefreshChatAndContentRestrictions(RefreshChatAndContentRestrictionsReturned_HandleInvite, this); //m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), m_gameBootInvite ); - //m_gameBootInvite = NULL; + //m_gameBootInvite = nullptr; } ErrorHandlingTick(); @@ -431,14 +431,14 @@ void SQRNetworkManager_Orbis::Tick() if(s_SignInCompleteCallbackFn) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,s_SignInCompleteCallbackPad); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } s_SignInCompleteCallbackPad = -1; } else if(s_SignInCompleteCallbackFn) { s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, s_SignInCompleteCallbackPad); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; s_SignInCompleteCallbackPad = -1; } } @@ -539,7 +539,7 @@ void SQRNetworkManager_Orbis::ErrorHandlingTick() m_bCallPSNSignInCallback=true; //s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,s_SignInCompleteCallbackPad); } - //s_SignInCompleteCallbackFn = NULL; + //s_SignInCompleteCallbackFn = nullptr; //s_SignInCompleteCallbackPad = -1; } app.DebugPrintf("Network error: SNM_INT_STATE_INITIALISE_FAILED\n"); @@ -655,7 +655,7 @@ void SQRNetworkManager_Orbis::UpdateExternalRoomData() reqParam.roomBinAttrExternalNum = 1; reqParam.roomBinAttrExternal = &roomBinAttr; - int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, nullptr, &m_setRoomDataRequestId ); app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2SetRoomDataExternal returns 0x%x, number of players %d\n",ret,((char *)m_joinExtData)[174]); if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_SET_EXTERNAL_ROOM_DATA ) ) { @@ -689,7 +689,7 @@ bool SQRNetworkManager_Orbis::FriendRoomManagerSearch() { if(m_aFriendSearchResults[i].m_RoomExtDataReceived) free(m_aFriendSearchResults[i].m_RoomExtDataReceived); - m_aFriendSearchResults[i].m_RoomExtDataReceived = NULL; + m_aFriendSearchResults[i].m_RoomExtDataReceived = nullptr; } m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_COUNT; @@ -755,7 +755,7 @@ void SQRNetworkManager_Orbis::FriendSearchTick() { m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO; delete m_getFriendCountThread; - m_getFriendCountThread = NULL; + m_getFriendCountThread = nullptr; FriendRoomManagerSearch2(); } } @@ -773,7 +773,7 @@ int SQRNetworkManager_Orbis::BasicEventThreadProc( void *lpParameter ) do { - ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, NULL); + ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, nullptr); // If the sys_event_t we've sent here from the handler has a non-zero data1 element, this is to signify that we should terminate the thread if( event.udata == 0 ) @@ -979,7 +979,7 @@ SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerByIndex(int idx) } else { - return NULL; + return nullptr; } } @@ -996,7 +996,7 @@ SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerBySmallId(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerByXuid(PlayerUID xuid) @@ -1012,7 +1012,7 @@ SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerByXuid(PlayerUID xuid) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_Orbis::GetLocalPlayerByUserIndex(int idx) @@ -1028,7 +1028,7 @@ SQRNetworkPlayer *SQRNetworkManager_Orbis::GetLocalPlayerByUserIndex(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_Orbis::GetHostPlayer() @@ -1041,11 +1041,11 @@ SQRNetworkPlayer *SQRNetworkManager_Orbis::GetHostPlayer() SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerIfReady(SQRNetworkPlayer *player) { - if( player == NULL ) return NULL; + if( player == nullptr ) return nullptr; if( player->IsReady() ) return player; - return NULL; + return nullptr; } // Update state internally @@ -1099,7 +1099,7 @@ bool SQRNetworkManager_Orbis::JoinRoom(SQRNetworkManager_Orbis::SessionSearchRes { // Set up the presence info we would like to synchronise out when we have fully joined the game CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData(&s_lastPresenceSyncInfo, searchResult->m_extData, searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId); - return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, NULL); + return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, nullptr); } // Join room with a specified roomId. This is used when joining from an invite, as well as by the previous method @@ -1165,7 +1165,7 @@ void SQRNetworkManager_Orbis::LeaveRoom(bool bActuallyLeaveRoom) reqParam.roomId = m_room; SetState(SNM_INT_STATE_LEAVING); - int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, NULL, &m_leaveRoomRequestId ); + int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, nullptr, &m_leaveRoomRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_LEAVE_ROOM) ) { SetState(SNM_INT_STATE_LEAVING_FAILED); @@ -1274,7 +1274,7 @@ bool SQRNetworkManager_Orbis::AddLocalPlayerByUserIndex(int idx) reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_setRoomMemberInternalDataRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL) ) { @@ -1326,7 +1326,7 @@ bool SQRNetworkManager_Orbis::RemoveLocalPlayerByUserIndex(int idx) // And do any adjusting necessary to the mappings from this room data, to the SQRNetworkPlayers. // This will also delete the SQRNetworkPlayer and do all the callbacks that requires etc. MapRoomSlotPlayers(roomSlotPlayerCount); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; // Sync this back out to our networked clients... SyncRoomData(); @@ -1367,7 +1367,7 @@ bool SQRNetworkManager_Orbis::RemoveLocalPlayerByUserIndex(int idx) reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_setRoomMemberInternalDataRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL2) ) { @@ -1388,7 +1388,7 @@ void SQRNetworkManager_Orbis::UpdateRemotePlay() int localPlayerCount = 0; for(int i = 0; i < XUSER_MAX_COUNT; i++) { - if(GetLocalPlayerByUserIndex(i) != NULL) localPlayerCount++; + if(GetLocalPlayerByUserIndex(i) != nullptr) localPlayerCount++; } InputManager.SetLocalMultiplayer(localPlayerCount > 1); } @@ -1427,7 +1427,7 @@ void SQRNetworkManager_Orbis::SendInviteGUI() messData.body.assign(body); messData.dialogFlag = SCE_TOOLKIT_NP_DIALOG_TYPE_USER_EDITABLE; messData.npIdsCount = 2; // TODO: Set this to the number of available slots - messData.npIds = NULL; + messData.npIds = nullptr; messData.userInfo.userId = userId; // Set expire to maximum @@ -1602,7 +1602,7 @@ void SQRNetworkManager_Orbis::FindOrCreateNonNetworkPlayer(int slot, int playerT } } // Create the player - non-network players can be considered complete as soon as we create them as we aren't waiting on their network connections becoming complete, so can flag them as such and notify via callback - PlayerUID *pUID = NULL; + PlayerUID *pUID = nullptr; PlayerUID localUID; if( ( playerType == SQRNetworkPlayer::SNP_TYPE_LOCAL ) || (m_isHosting && ( playerType == SQRNetworkPlayer::SNP_TYPE_HOST )) ) @@ -1669,7 +1669,7 @@ void SQRNetworkManager_Orbis::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_REMOTE ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1725,7 +1725,7 @@ void SQRNetworkManager_Orbis::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_LOCAL ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1817,7 +1817,7 @@ void SQRNetworkManager_Orbis::UpdatePlayersFromRoomSyncUIDs() } // Host only - add remote players to our internal storage of player slots, and synchronise this with other room members. -bool SQRNetworkManager_Orbis::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==NULL*/ ) +bool SQRNetworkManager_Orbis::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==nullptr*/ ) { assert( m_isHosting ); @@ -1939,7 +1939,7 @@ void SQRNetworkManager_Orbis::RemoveRemotePlayersAndSync( SceNpMatching2RoomMemb } // Zero last element, that isn't part of the currently sized array anymore memset(&m_roomSyncData.players[m_roomSyncData.getPlayerCount()],0,sizeof(PlayerSyncData)); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; } else { @@ -1984,7 +1984,7 @@ void SQRNetworkManager_Orbis::RemoveNetworkPlayers( int mask ) { if( m_aRoomSlotPlayers[i] == player ) { - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } // And delete the reference from the ctx->player map @@ -2037,7 +2037,7 @@ void SQRNetworkManager_Orbis::SyncRoomData() roomBinAttr.size = sizeof( m_roomSyncData ); reqParam.roomBinAttrInternalNum = 1; reqParam.roomBinAttrInternal = &roomBinAttr; - sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, nullptr, &m_setRoomDataRequestId ); } // Check if the matching context is valid, and if not attempt to create one. If to do this requires starting an asynchronous process, then sets the internal state to the state passed in @@ -2159,7 +2159,7 @@ bool SQRNetworkManager_Orbis::GetServerContext(SceNpMatching2ServerId serverId) // { // // Get list of server IDs of servers allocated to the application. We don't actually need to do this, but it is as good a way as any to try a matching2 service and check that // // the context *really* is valid. -// int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, NULL, 0 ); +// int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, nullptr, 0 ); // // If an error is returned here, we need to destroy and recerate our server - if this goes ok we should come back through this path again // if( ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_UNAVAILABLE ) || // This error has been seen (occasionally) in a normal working environment // ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED ) ) // Also checking for this as a means of simulating the previous error @@ -2253,7 +2253,7 @@ void SQRNetworkManager_Orbis::RoomCreateTick() SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM); app.DebugPrintf(CMinecraftApp::USER_RR,">> Creating room start\n"); s_roomStartTime = System::currentTimeMillis(); - int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, NULL, &m_createRoomRequestId ); + int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, nullptr, &m_createRoomRequestId ); if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_JOIN_ROOM) ) { SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED); @@ -2493,7 +2493,7 @@ bool SQRNetworkManager_Orbis::CreateVoiceRudpConnections(SceNpMatching2RoomId ro // create this connection if we don't have it already SQRVoiceConnection* pConnection = SonyVoiceChat_Orbis::getVoiceConnectionFromRoomMemberID(peerMemberId); - if(pConnection == NULL) + if(pConnection == nullptr) { // Create an Rudp context for the voice connection, this will happen regardless of whether the peer is client or host @@ -2573,7 +2573,7 @@ bool SQRNetworkManager_Orbis::CreateRudpConnections(SceNpMatching2RoomId roomId, if( m_isHosting ) { - m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, NULL ); + m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, nullptr ); } else { @@ -2611,7 +2611,7 @@ SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerFromRudpCtx(int rudpCtx) { return it->second; } - return NULL; + return nullptr; } @@ -2625,7 +2625,7 @@ SQRNetworkPlayer *SQRNetworkManager_Orbis::GetPlayerFromRoomMemberAndLocalIdx(in return it->second; } } - return NULL; + return nullptr; } @@ -2720,7 +2720,7 @@ void SQRNetworkManager_Orbis::ContextCallback(SceNpMatching2ContextId id, SceNp if( manager->m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { manager->SetState( SNM_INT_STATE_IDLE ); - manager->GetExtDataForRoom(0, NULL, NULL, NULL); + manager->GetExtDataForRoom(0, nullptr, nullptr, nullptr); break; } @@ -2759,7 +2759,7 @@ void SQRNetworkManager_Orbis::ContextCallback(SceNpMatching2ContextId id, SceNp // if(s_SignInCompleteCallbackFn) // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } @@ -2966,12 +2966,12 @@ void SQRNetworkManager_Orbis::DefaultRequestCallback(SceNpMatching2ContextId id, // Set flag to indicate whether we were kicked for being out of room or not reqParam.optData.data[0] = isFull ? 1 : 0; reqParam.optData.len = 1; - int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, NULL, &manager->m_kickRequestId); + int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, nullptr, &manager->m_kickRequestId); app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2KickoutRoomMember returns error 0x%x\n",ret); } else { - if(pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternal->data.ptr == NULL) + if(pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternal->data.ptr == nullptr) { // the host doesn't send out data, so this must be the host we're connecting to @@ -3213,7 +3213,7 @@ void SQRNetworkManager_Orbis::RoomEventCallback(SceNpMatching2ContextId id, SceN reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, NULL, &manager->m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, nullptr, &manager->m_setRoomMemberInternalDataRequestId ); } else { @@ -3349,7 +3349,7 @@ void SQRNetworkManager_Orbis::ProcessSignallingEvent(SceNpMatching2ContextId ctx reqParam.attrId = attrs; reqParam.attrIdNum = 1; - sceNpMatching2GetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_roomMemberDataRequestId); + sceNpMatching2GetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_roomMemberDataRequestId); } break; } @@ -3376,7 +3376,7 @@ int SQRNetworkManager_Orbis::BasicEventCallback(int event, int retCode, uint32_t ORBIS_STUBBED; // SQRNetworkManager_Orbis *manager = (SQRNetworkManager_Orbis *)arg; // // We aren't allowed to actually get the event directly from this callback, so send our own internal event to a thread dedicated to doing this -// sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, NULL); +// sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, nullptr); return 0; } @@ -3422,7 +3422,7 @@ void SQRNetworkManager_Orbis::SysUtilCallback(uint64_t status, uint64_t param, v // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } -// s_SignInCompleteCallbackFn = NULL; +// s_SignInCompleteCallbackFn = nullptr; // } // return; // } @@ -3437,7 +3437,7 @@ void SQRNetworkManager_Orbis::SysUtilCallback(uint64_t status, uint64_t param, v // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } -// s_SignInCompleteCallbackFn = NULL; +// s_SignInCompleteCallbackFn = nullptr; // } // } // @@ -3534,7 +3534,7 @@ void SQRNetworkManager_Orbis::RudpContextCallback(int ctx_id, int event_id, int if( dataSize >= sizeof(SQRNetworkPlayer::InitSendData) ) { SQRNetworkPlayer::InitSendData ISD; - int bytesRead = sceRudpRead( ctx_id, &ISD, sizeof(SQRNetworkPlayer::InitSendData), 0, NULL ); + int bytesRead = sceRudpRead( ctx_id, &ISD, sizeof(SQRNetworkPlayer::InitSendData), 0, nullptr ); if( bytesRead == sizeof(SQRNetworkPlayer::InitSendData) ) { manager->NetworkPlayerInitialDataReceived(playerFrom, &ISD); @@ -3555,7 +3555,7 @@ void SQRNetworkManager_Orbis::RudpContextCallback(int ctx_id, int event_id, int if( dataSize > 0 ) { unsigned char *data = new unsigned char [ dataSize ]; - int bytesRead = sceRudpRead( ctx_id, data, dataSize, 0, NULL ); + int bytesRead = sceRudpRead( ctx_id, data, dataSize, 0, nullptr ); if( bytesRead > 0 ) { SQRNetworkPlayer *playerFrom, *playerTo; @@ -3571,7 +3571,7 @@ void SQRNetworkManager_Orbis::RudpContextCallback(int ctx_id, int event_id, int playerFrom = manager->m_aRoomSlotPlayers[0]; playerTo = manager->GetPlayerFromRudpCtx( ctx_id ); } - if( ( playerFrom != NULL ) && ( playerTo != NULL ) ) + if( ( playerFrom != nullptr ) && ( playerTo != nullptr ) ) { manager->m_listener->HandleDataReceived( playerFrom, playerTo, data, bytesRead ); } @@ -3632,7 +3632,7 @@ void SQRNetworkManager_Orbis::ServerContextValid_CreateRoom() int ret = -1; if( !ForceErrorPoint(SNM_FORCE_ERROR_GET_WORLD_INFO_LIST) ) { - ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, NULL, &m_getWorldRequestId); + ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, nullptr, &m_getWorldRequestId); } if (ret < 0) { @@ -3661,7 +3661,7 @@ void SQRNetworkManager_Orbis::ServerContextValid_JoinRoom() reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, NULL, &m_joinRoomRequestId ); + int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, nullptr, &m_joinRoomRequestId ); if ( (ret < 0) || ForceErrorPoint(SNM_FORCE_ERROR_JOIN_ROOM) ) { if( ret == SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH) @@ -3722,9 +3722,9 @@ void SQRNetworkManager_Orbis::GetExtDataForRoom( SceNpMatching2RoomId roomId, vo static SceNpMatching2RoomId aRoomId[1]; static SceNpMatching2AttributeId attr[1]; - // All parameters will be NULL if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). - // NULL parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList - if( extData != NULL ) + // All parameters will be nullptr if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). + // nullptr parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList + if( extData != nullptr ) { aRoomId[0] = roomId; attr[0] = SCE_NP_MATCHING2_ROOM_BIN_ATTR_EXTERNAL_1_ID; @@ -3748,14 +3748,14 @@ void SQRNetworkManager_Orbis::GetExtDataForRoom( SceNpMatching2RoomId roomId, vo return; } - // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with nullptr params) once done, so we can reattempt. Don't do anything more now. if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { app.DebugPrintf("Having to recreate matching context, setting state to SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT\n"); return; } - int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, NULL, &m_roomDataExternalListRequestId ); + int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, nullptr, &m_roomDataExternalListRequestId ); // If we hadn't properly detected that a matching context was unvailable, we might still get an error indicating that it is from the previous call. Handle similarly, but we need // to destroy the context first. @@ -3769,7 +3769,7 @@ void SQRNetworkManager_Orbis::GetExtDataForRoom( SceNpMatching2RoomId roomId, vo m_FriendSessionUpdatedFn(false, m_pParamFriendSessionUpdated); return; }; - // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with nullptr params) once done, so we can reattempt. Don't do anything more now. if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { return; @@ -3907,7 +3907,7 @@ void SQRNetworkManager_Orbis::AttemptPSNSignIn(int (*SignInCompleteCallbackFn)(v //s_signInCompleteCallbackIfFailed=false; //s_SignInCompleteCallbackFn(s_SignInCompleteParam, false, iPad); } - //s_SignInCompleteCallbackFn = NULL; + //s_SignInCompleteCallbackFn = nullptr; } } } @@ -4145,11 +4145,11 @@ void SQRNetworkManager_Orbis::NotifyRealtimePlusFeature(int iQuadrant) // bool isSignedIn = ProfileManager.IsSignedInLive(s_SignInCompleteCallbackPad); // // s_SignInCompleteCallbackFn(s_SignInCompleteParam, isSignedIn, s_SignInCompleteCallbackPad); -// s_SignInCompleteCallbackFn = NULL; +// s_SignInCompleteCallbackFn = nullptr; // s_SignInCompleteCallbackPad = -1; // } // else // { -// app.DebugPrintf("============ Calling CallSignInCompleteCallback but s_SignInCompleteCallbackFn is NULL\n"); +// app.DebugPrintf("============ Calling CallSignInCompleteCallback but s_SignInCompleteCallbackFn is nullptr\n"); // } //} \ No newline at end of file diff --git a/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.h b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.h index 5b19f63ec..d2ff09d96 100644 --- a/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.h +++ b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.h @@ -139,7 +139,7 @@ class SQRNetworkManager_Orbis : public SQRNetworkManager void LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize); int GetSessionIndex(SQRNetworkPlayer *player); - bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = NULL ); + bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = nullptr ); void RemoveRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int mask ); void RemoveNetworkPlayers( int mask ); void SetLocalPlayersAndSync(); diff --git a/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.cpp index 34ab67e40..67ae639bc 100644 --- a/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.cpp +++ b/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.cpp @@ -9,22 +9,22 @@ bool SonyCommerce_Orbis::m_bCommerceInitialised = false; // SceNpCommerce2SessionInfo SonyCommerce_Orbis::m_sessionInfo; SonyCommerce_Orbis::State SonyCommerce_Orbis::m_state = e_state_noSession; int SonyCommerce_Orbis::m_errorCode = 0; -LPVOID SonyCommerce_Orbis::m_callbackParam = NULL; +LPVOID SonyCommerce_Orbis::m_callbackParam = nullptr; -void* SonyCommerce_Orbis::m_receiveBuffer = NULL; +void* SonyCommerce_Orbis::m_receiveBuffer = nullptr; SonyCommerce_Orbis::Event SonyCommerce_Orbis::m_event; std::queue SonyCommerce_Orbis::m_messageQueue; -std::vector* SonyCommerce_Orbis::m_pProductInfoList = NULL; -SonyCommerce_Orbis::ProductInfoDetailed* SonyCommerce_Orbis::m_pProductInfoDetailed = NULL; -SonyCommerce_Orbis::ProductInfo* SonyCommerce_Orbis::m_pProductInfo = NULL; +std::vector* SonyCommerce_Orbis::m_pProductInfoList = nullptr; +SonyCommerce_Orbis::ProductInfoDetailed* SonyCommerce_Orbis::m_pProductInfoDetailed = nullptr; +SonyCommerce_Orbis::ProductInfo* SonyCommerce_Orbis::m_pProductInfo = nullptr; -SonyCommerce_Orbis::CategoryInfo* SonyCommerce_Orbis::m_pCategoryInfo = NULL; -const char* SonyCommerce_Orbis::m_pProductID = NULL; -char* SonyCommerce_Orbis::m_pCategoryID = NULL; +SonyCommerce_Orbis::CategoryInfo* SonyCommerce_Orbis::m_pCategoryInfo = nullptr; +const char* SonyCommerce_Orbis::m_pProductID = nullptr; +char* SonyCommerce_Orbis::m_pCategoryID = nullptr; SonyCommerce_Orbis::CheckoutInputParams SonyCommerce_Orbis::m_checkoutInputParams; SonyCommerce_Orbis::DownloadListInputParams SonyCommerce_Orbis::m_downloadInputParams; -SonyCommerce_Orbis::CallbackFunc SonyCommerce_Orbis::m_callbackFunc = NULL; +SonyCommerce_Orbis::CallbackFunc SonyCommerce_Orbis::m_callbackFunc = nullptr; // sys_memory_container_t SonyCommerce_Orbis::m_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; bool SonyCommerce_Orbis::m_bUpgradingTrial = false; @@ -38,7 +38,7 @@ bool SonyCommerce_Orbis::m_contextCreated=false; ///< npcommerce2 cont SonyCommerce_Orbis::Phase SonyCommerce_Orbis::m_currentPhase = e_phase_stopped; ///< Current commerce2 util // char SonyCommerce_Orbis::m_commercebuffer[SCE_NP_COMMERCE2_RECV_BUF_SIZE]; -C4JThread* SonyCommerce_Orbis::m_tickThread = NULL; +C4JThread* SonyCommerce_Orbis::m_tickThread = nullptr; bool SonyCommerce_Orbis::m_bLicenseChecked=false; // Check the trial/full license for the game @@ -52,12 +52,12 @@ sce::Toolkit::NP::Utilities::Future g_d SonyCommerce_Orbis::ProductInfoDetailed s_trialUpgradeProductInfoDetailed; void SonyCommerce_Orbis::Delete() { - m_pProductInfoList=NULL; - m_pProductInfoDetailed=NULL; - m_pProductInfo=NULL; - m_pCategoryInfo = NULL; - m_pProductID = NULL; - m_pCategoryID = NULL; + m_pProductInfoList=nullptr; + m_pProductInfoDetailed=nullptr; + m_pProductInfo=nullptr; + m_pCategoryInfo = nullptr; + m_pProductID = nullptr; + m_pCategoryID = nullptr; } void SonyCommerce_Orbis::Init() @@ -95,7 +95,7 @@ bool SonyCommerce_Orbis::LicenseChecked() void SonyCommerce_Orbis::CheckForTrialUpgradeKey() { - StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, NULL); + StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, nullptr); } int SonyCommerce_Orbis::Shutdown() @@ -112,7 +112,7 @@ int SonyCommerce_Orbis::Shutdown() DeleteCriticalSection(&m_queueLock); // clear any possible callback function - m_callbackFunc = NULL; + m_callbackFunc = nullptr; return ret; } @@ -582,7 +582,7 @@ int SonyCommerce_Orbis::createContext() // } // // // Create commerce2 context -// ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, NULL, &m_contextId); +// ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, nullptr, &m_contextId); // if (ret < 0) // { // app.DebugPrintf(4,"createContext sceNpCommerce2CreateCtx problem\n"); @@ -657,7 +657,7 @@ void SonyCommerce_Orbis::commerce2Handler( const sce::Toolkit::NP::Event& event) case sce::Toolkit::NP::Event::UserEvent::commerceGotCategoryInfo: { copyCategoryInfo(m_pCategoryInfo, g_categoryInfo.get()); - m_pCategoryInfo = NULL; + m_pCategoryInfo = nullptr; m_event = e_event_commerceGotCategoryInfo; break; } @@ -665,7 +665,7 @@ void SonyCommerce_Orbis::commerce2Handler( const sce::Toolkit::NP::Event& event) case sce::Toolkit::NP::Event::UserEvent::commerceGotProductList: { copyProductList(m_pProductInfoList, g_productList.get()); - m_pProductInfoDetailed = NULL; + m_pProductInfoDetailed = nullptr; m_event = e_event_commerceGotProductList; break; } @@ -675,12 +675,12 @@ void SonyCommerce_Orbis::commerce2Handler( const sce::Toolkit::NP::Event& event) if(m_pProductInfoDetailed) { copyDetailedProductInfo(m_pProductInfoDetailed, g_detailedProductInfo.get()); - m_pProductInfoDetailed = NULL; + m_pProductInfoDetailed = nullptr; } else { copyAddDetailedProductInfo(m_pProductInfo, g_detailedProductInfo.get()); - m_pProductInfo = NULL; + m_pProductInfo = nullptr; } m_event = e_event_commerceGotDetailedProductInfo; break; @@ -1027,7 +1027,7 @@ void SonyCommerce_Orbis::processEvent() case e_event_commerceProductBrowseFinished: app.DebugPrintf(4,"e_event_commerceProductBrowseFinished succeeded: 0x%x\n", m_errorCode); - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1076,7 +1076,7 @@ void SonyCommerce_Orbis::processEvent() } // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1094,7 +1094,7 @@ void SonyCommerce_Orbis::processEvent() } // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1154,8 +1154,8 @@ void SonyCommerce_Orbis::CreateSession( CallbackFunc cb, LPVOID lpParam ) m_messageQueue.push(e_message_commerceEnd); m_event = e_event_commerceSessionCreated; - if(m_tickThread == NULL) - m_tickThread = new C4JThread(TickLoop, NULL, "SonyCommerce_Orbis tick"); + if(m_tickThread == nullptr) + m_tickThread = new C4JThread(TickLoop, nullptr, "SonyCommerce_Orbis tick"); if(m_tickThread->isRunning() == false) { m_currentPhase = e_phase_idle; diff --git a/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.h b/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.h index a2a42d574..dc7671f46 100644 --- a/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.h +++ b/Minecraft.Client/Orbis/Network/SonyCommerce_Orbis.h @@ -107,14 +107,14 @@ class SonyCommerce_Orbis : public SonyCommerce { assert(m_callbackFunc); CallbackFunc func = m_callbackFunc; - m_callbackFunc = NULL; + m_callbackFunc = nullptr; if(func) func(m_callbackParam, m_errorCode); m_errorCode = SCE_OK; } static void setCallback(CallbackFunc cb,LPVOID lpParam) { - assert(m_callbackFunc == NULL); + assert(m_callbackFunc == nullptr); m_callbackFunc = cb; m_callbackParam = lpParam; } diff --git a/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp index b9c4a6ed1..3387839fd 100644 --- a/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp +++ b/Minecraft.Client/Orbis/Network/SonyHttp_Orbis.cpp @@ -100,16 +100,16 @@ void SonyHttp_Orbis::printSslError(SceInt32 sslErr, SceUInt32 sslErrDetail) void SonyHttp_Orbis::printSslCertInfo(int libsslCtxId,SceSslCert *sslCert) { SceInt32 ret; - SceUChar8 *sboData = NULL ; + SceUChar8 *sboData = nullptr ; SceSize sboLen, counter; - ret = sceSslGetSerialNumber(libsslCtxId, sslCert, NULL, &sboLen); + ret = sceSslGetSerialNumber(libsslCtxId, sslCert, nullptr, &sboLen); if (ret < 0){ app.DebugPrintf("sceSslGetSerialNumber() returns 0x%x\n", ret); } else { sboData = static_cast(malloc(sboLen)); - if ( sboData != NULL ) { + if ( sboData != nullptr ) { ret = sceSslGetSerialNumber(libsslCtxId, sslCert, sboData, &sboLen); if (ret < 0){ app.DebugPrintf ("sceSslGetSerialNumber() returns 0x%x\n", ret); @@ -225,7 +225,7 @@ bool SonyHttp_Orbis::http_get(const char *targetUrl, void** ppOutData, int* pDat } reqId = ret; - ret = sceHttpSendRequest(reqId, NULL, 0); + ret = sceHttpSendRequest(reqId, nullptr, 0); if (ret < 0) { app.DebugPrintf("sceHttpSendRequest() error: 0x%08X\n", ret); diff --git a/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp index 0af059a90..008879cb3 100644 --- a/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp +++ b/Minecraft.Client/Orbis/Network/SonyRemoteStorage_Orbis.cpp @@ -196,7 +196,7 @@ bool SonyRemoteStorage_Orbis::init(CallbackFunc cb, LPVOID lpParam) // memcpy(clientId.id, CLIENT_ID, strlen(CLIENT_ID)); // authParams.pClientId = &clientId; -// ret = sceNpAuthGetAuthorizationCode(reqId, &authParams, &authCode, NULL); +// ret = sceNpAuthGetAuthorizationCode(reqId, &authParams, &authCode, nullptr); // if (ret < 0) { // app.DebugPrintf("Failed to get auth code 0x%x\n", ret); // } @@ -223,7 +223,7 @@ bool SonyRemoteStorage_Orbis::init(CallbackFunc cb, LPVOID lpParam) params.timeout.sendMs = 120 * 1000; //120 seconds is the default params.pool.memPoolSize = 7 * 1024 * 1024; - if(m_memPoolBuffer == NULL) + if(m_memPoolBuffer == nullptr) m_memPoolBuffer = malloc(params.pool.memPoolSize); params.pool.memPoolBuffer = m_memPoolBuffer; diff --git a/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.cpp b/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.cpp index d869d38bf..c075badb6 100644 --- a/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.cpp +++ b/Minecraft.Client/Orbis/Network/SonyVoiceChat_Orbis.cpp @@ -67,7 +67,7 @@ void LoadPCMVoiceData() { char filename[64]; sprintf(filename, "voice%d.pcm", i+1); - HANDLE file = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(filename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); DWORD dwHigh=0; g_loadedPCMVoiceDataSizes[i] = GetFileSize(file,&dwHigh); @@ -75,7 +75,7 @@ void LoadPCMVoiceData() { g_loadedPCMVoiceData[i] = new char[g_loadedPCMVoiceDataSizes[i]]; DWORD bytesRead; - BOOL bSuccess = ReadFile(file, g_loadedPCMVoiceData[i], g_loadedPCMVoiceDataSizes[i], &bytesRead, NULL); + BOOL bSuccess = ReadFile(file, g_loadedPCMVoiceData[i], g_loadedPCMVoiceDataSizes[i], &bytesRead, nullptr); assert(bSuccess); } g_loadedPCMVoiceDataPos[i] = 0; @@ -274,7 +274,7 @@ void SQRVoiceConnection::readRemoteData() if( dataSize > 0 ) { VoicePacket packet; - int bytesRead = sceRudpRead( m_rudpCtx, &packet, dataSize, 0, NULL ); + int bytesRead = sceRudpRead( m_rudpCtx, &packet, dataSize, 0, nullptr ); unsigned int writeSize; if( bytesRead > 0 ) { @@ -468,7 +468,7 @@ void SonyVoiceChat_Orbis::sendAllVoiceData() if(m_localVoiceDevices[i].isValid()) { bool bChatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(i,true,&bChatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(i,true,&bChatRestricted,nullptr,nullptr); if(bChatRestricted) { @@ -928,7 +928,7 @@ void SonyVoiceChat_Orbis::initLocalPlayer(int playerIndex) if(m_localVoiceDevices[playerIndex].isValid() == false) { bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,nullptr,nullptr); // create all device ports required m_localVoiceDevices[playerIndex].init(ProfileManager.getUserID(playerIndex), chatRestricted); @@ -965,7 +965,7 @@ SQRVoiceConnection* SonyVoiceChat_Orbis::GetVoiceConnectionFromRudpCtx( int Rudp if(m_remoteConnections[i]->m_rudpCtx == RudpCtx) return m_remoteConnections[i]; } - return NULL; + return nullptr; } void SonyVoiceChat_Orbis::connectPlayerToAll( int playerIndex ) @@ -990,7 +990,7 @@ SQRVoiceConnection* SonyVoiceChat_Orbis::getVoiceConnectionFromRoomMemberID( Sce } } - return NULL; + return nullptr; } void SonyVoiceChat_Orbis::disconnectLocalPlayer( int localIdx ) diff --git a/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.cpp b/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.cpp index d3a21ac4f..92718f7e1 100644 --- a/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.cpp +++ b/Minecraft.Client/Orbis/OrbisExtras/OrbisStubs.cpp @@ -35,8 +35,8 @@ int _wcsicmp( const wchar_t * dst, const wchar_t * src ) wchar_t f,l; // validation section - // _VALIDATE_RETURN(dst != NULL, EINVAL, _NLSCMPERROR); - // _VALIDATE_RETURN(src != NULL, EINVAL, _NLSCMPERROR); + // _VALIDATE_RETURN(dst != nullptr, EINVAL, _NLSCMPERROR); + // _VALIDATE_RETURN(src != nullptr, EINVAL, _NLSCMPERROR); do { f = towlower(*dst); @@ -51,7 +51,7 @@ size_t wcsnlen(const wchar_t *wcs, size_t maxsize) { size_t n; -// Note that we do not check if s == NULL, because we do not +// Note that we do not check if s == nullptr, because we do not // return errno_t... for (n = 0; n < maxsize && *wcs; n++, wcs++) @@ -94,7 +94,7 @@ VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) lpSystemTime->wMilliseconds = sceRtcGetMicrosecond(&dateTime)/1000; } -HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { ORBIS_STUBBED; return NULL; } +HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { ORBIS_STUBBED; return nullptr; } VOID Sleep(DWORD dwMilliseconds) { C4JThread::Sleep(dwMilliseconds); @@ -203,7 +203,7 @@ VOID InitializeCriticalSection(PCRITICAL_SECTION CriticalSection) CriticalSection->m_cLock = 0; assert(err == SCE_OK); #ifdef _DEBUG - CriticalSection->m_pOwnerThread = NULL; + CriticalSection->m_pOwnerThread = nullptr; #endif } @@ -247,7 +247,7 @@ VOID LeaveCriticalSection(PCRITICAL_SECTION CriticalSection) int err = scePthreadMutexUnlock(&CriticalSection->mutex); assert(err == SCE_OK ); #ifdef _DEBUG - CriticalSection->m_pOwnerThread = NULL; + CriticalSection->m_pOwnerThread = nullptr; #endif } @@ -268,7 +268,7 @@ DWORD WaitForMultipleObjects(DWORD nCount, CONST HANDLE *lpHandles,BOOL bWaitAll BOOL CloseHandle(HANDLE hObject) { - sceFiosFHCloseSync(NULL,(SceFiosFH)((int64_t)hObject)); + sceFiosFHCloseSync(nullptr,(SceFiosFH)((int64_t)hObject)); return true; // ORBIS_STUBBED; // return false; @@ -342,7 +342,7 @@ class OrbisVAlloc if(err != SCE_OK) { assert(0); - return NULL; + return nullptr; } // work out where the next page should be in virtual addr space, and pass that to the mapping function void* pageVirtualAddr = ((char*)m_virtualAddr) + m_allocatedSize; @@ -359,12 +359,12 @@ class OrbisVAlloc if(inAddr != pageVirtualAddr) // make sure we actually get the virtual address that we requested { assert(0); - return NULL; + return nullptr; } if(err != SCE_OK) { assert(0); - return NULL; + return nullptr; } m_pagesAllocated.push_back(PageInfo(physAddr, pageVirtualAddr, sizeToAdd)); m_allocatedSize += sizeToAdd; @@ -395,14 +395,14 @@ static std::vector s_orbisVAllocs; LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) { - if(lpAddress == NULL) + if(lpAddress == nullptr) { void *pAddr = (void*)SCE_KERNEL_APP_MAP_AREA_START_ADDR; int err = sceKernelReserveVirtualRange(&pAddr, dwSize, 0, 16*1024); if( err != SCE_OK ) { app.DebugPrintf("sceKernelReserveVirtualRange failed: 0x%08X\n", err); - return NULL; + return nullptr; } s_orbisVAllocs.push_back(new OrbisVAlloc(pAddr, dwSize)); return (LPVOID)pAddr; @@ -419,10 +419,10 @@ LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWO } } assert(0); // failed to find the virtual alloc in our table - return NULL; + return nullptr; } } - return NULL; + return nullptr; } BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) @@ -483,7 +483,7 @@ BOOL WriteFile( { SceFiosFH fh = (SceFiosFH)((int64_t)hFile); // sceFiosFHReadSync - Non-negative values are the number of bytes read, 0 <= result <= length. Negative values are error codes. - SceFiosSize bytesRead = sceFiosFHWriteSync(NULL, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToWrite); + SceFiosSize bytesRead = sceFiosFHWriteSync(nullptr, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToWrite); if(bytesRead < 0) { // error @@ -500,7 +500,7 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD { SceFiosFH fh = (SceFiosFH)((int64_t)hFile); // sceFiosFHReadSync - Non-negative values are the number of bytes read, 0 <= result <= length. Negative values are error codes. - SceFiosSize bytesRead = sceFiosFHReadSync(NULL, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToRead); + SceFiosSize bytesRead = sceFiosFHReadSync(nullptr, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToRead); *lpNumberOfBytesRead = (DWORD)bytesRead; if(bytesRead < 0) { @@ -520,7 +520,7 @@ BOOL SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHi uint64_t bitsToMove = (int64_t) lDistanceToMove; SceFiosOffset pos = 0; - if (lpDistanceToMoveHigh != NULL) + if (lpDistanceToMoveHigh != nullptr) bitsToMove |= ((uint64_t) (*lpDistanceToMoveHigh)) << 32; SceFiosWhence whence = SCE_FIOS_SEEK_SET; @@ -581,7 +581,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, case TRUNCATE_EXISTING: break; } - int err = sceFiosFHOpenSync(NULL, &fh, filePath, &openParams); + int err = sceFiosFHOpenSync(nullptr, &fh, filePath, &openParams); if(err != SCE_FIOS_OK) { @@ -597,7 +597,7 @@ BOOL DeleteFileA(LPCSTR lpFileName) { ORBIS_STUBBED; return false; } // BOOL XCloseHandle(HANDLE a) // { -// sceFiosFHCloseSync(NULL,(SceFiosFH)((int64_t)a)); +// sceFiosFHCloseSync(nullptr,(SceFiosFH)((int64_t)a)); // return true; // } @@ -617,7 +617,7 @@ DWORD GetFileAttributesA(LPCSTR lpFileName) // check if the file exists first SceFiosStat statData; - if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK) + if(sceFiosStatSync(nullptr, filePath, &statData) != SCE_FIOS_OK) { app.DebugPrintf("*** sceFiosStatSync Failed\n"); return -1; diff --git a/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.cpp b/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.cpp index 9f17e999d..4229b61d1 100644 --- a/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.cpp +++ b/Minecraft.Client/Orbis/OrbisExtras/TLSStorage.cpp @@ -4,7 +4,7 @@ -TLSStorageOrbis* TLSStorageOrbis::m_pInstance = NULL; +TLSStorageOrbis* TLSStorageOrbis::m_pInstance = nullptr; BOOL TLSStorageOrbis::m_activeList[sc_maxSlots]; __thread LPVOID TLSStorageOrbis::m_values[sc_maxSlots]; @@ -16,7 +16,7 @@ TLSStorageOrbis::TLSStorageOrbis() for(int i=0;isecond; } @@ -124,7 +124,7 @@ SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfoFromKeyname(char *pchKeyName) } } - return NULL; + return nullptr; } #define WRAPPED_READFILE(hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,lpOverlapped) {if(ReadFile(hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,lpOverlapped)==FALSE) { return FALSE;}} @@ -133,8 +133,8 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() char chDLCTitle[64]; // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds - //HANDLE file = CreateFile("orbis/DLCImages/TP01_360x360.png", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - HANDLE file = CreateFile("orbis/PS4ProductCodes.bin", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + //HANDLE file = CreateFile("orbis/DLCImages/TP01_360x360.png", GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + HANDLE file = CreateFile("orbis/PS4ProductCodes.bin", GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { DWORD error = GetLastError(); @@ -149,12 +149,12 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() { DWORD bytesRead; - WRAPPED_READFILE(file,ProductCodes.chProductCode,PRODUCT_CODE_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chCommerceCategory,COMMERCE_CATEGORY_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chTexturePackID,SCE_NP_COMMERCE2_CATEGORY_ID_LEN,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chUpgradeKey,UPGRADE_KEY_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chSkuPostfix,SKU_POSTFIX_SIZE,&bytesRead,NULL); + WRAPPED_READFILE(file,ProductCodes.chProductCode,PRODUCT_CODE_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chCommerceCategory,COMMERCE_CATEGORY_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chTexturePackID,SCE_NP_COMMERCE2_CATEGORY_ID_LEN,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chUpgradeKey,UPGRADE_KEY_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chSkuPostfix,SKU_POSTFIX_SIZE,&bytesRead,nullptr); app.DebugPrintf("ProductCodes.chProductCode %s\n",ProductCodes.chProductCode); app.DebugPrintf("ProductCodes.chSaveFolderPrefix %s\n",ProductCodes.chSaveFolderPrefix); @@ -165,7 +165,7 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() // DLC unsigned int uiDLC; - WRAPPED_READFILE(file,&uiDLC,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&uiDLC,sizeof(int),&bytesRead,nullptr); for(unsigned int i=0;ichDLCKeyname,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,pDLCInfo->chDLCKeyname,sizeof(char)*uiVal,&bytesRead,nullptr); - WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,nullptr); app.DebugPrintf("DLC title %s\n",chDLCTitle); - WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,nullptr); - WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,pDLCInfo->chDLCPicname,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,pDLCInfo->chDLCPicname,sizeof(char)*uiVal,&bytesRead,nullptr); - WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,nullptr); // push this into a vector @@ -310,7 +310,7 @@ void CConsoleMinecraftApp::FreeLocalDLCImages() { free(pDLCInfo->pbImageData); pDLCInfo->dwImageBytes=0; - pDLCInfo->pbImageData=NULL; + pDLCInfo->pbImageData=nullptr; } } } @@ -323,7 +323,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImage(SONYDLC *pDLCInfo) sprintf(pchFilename,"orbis/DLCImages/%s_360x360.png",pDLCInfo->chDLCPicname); // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds - HANDLE hFile = CreateFile(pchFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(pchFilename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( hFile == INVALID_HANDLE_VALUE ) { @@ -339,7 +339,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImage(SONYDLC *pDLCInfo) DWORD dwBytesRead; pDLCInfo->pbImageData=(PBYTE)malloc(pDLCInfo->dwImageBytes); - if(ReadFile(hFile,pDLCInfo->pbImageData,pDLCInfo->dwImageBytes,&dwBytesRead,NULL)==FALSE) + if(ReadFile(hFile,pDLCInfo->pbImageData,pDLCInfo->dwImageBytes,&dwBytesRead,nullptr)==FALSE) { // failed free(pDLCInfo->pbImageData); @@ -375,7 +375,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -404,7 +404,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() NetworkGameInitData *param = new NetworkGameInitData(); param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; app.SetGameHostOption(eGameHostOption_Difficulty,0); app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); @@ -620,7 +620,7 @@ SonyCommerce::CategoryInfo *CConsoleMinecraftApp::GetCategoryInfo() { if(m_bCommerceCategoriesRetrieved==false) { - return NULL; + return nullptr; } return &m_CategoryInfo; @@ -636,10 +636,10 @@ void CConsoleMinecraftApp::ClearCommerceDetails() pProductList->clear(); } - if(m_ProductListA!=NULL) + if(m_ProductListA!=nullptr) { delete [] m_ProductListA; - m_ProductListA=NULL; + m_ProductListA=nullptr; } m_ProductListRetrievedC=0; @@ -727,7 +727,7 @@ std::vector* CConsoleMinecraftApp::GetProductList(int { if((m_bCommerceProductListRetrieved==false) || (m_bProductListAdditionalDetailsRetrieved==false) ) { - return NULL; + return nullptr; } return &m_ProductListA[iIndex]; @@ -1175,7 +1175,7 @@ int CConsoleMinecraftApp::Callback_SaveGameIncompleteMessageBoxReturned(void *pP StorageManager.CancelIncompleteOperation(); break; case C4JStorage::EMessage_ResultThirdOption: - ui.NavigateToScene(iPad, eUIScene_InGameSaveManagementMenu, NULL, eUILayer_Error, eUIGroup_Fullscreen); + ui.NavigateToScene(iPad, eUIScene_InGameSaveManagementMenu, nullptr, eUILayer_Error, eUIGroup_Fullscreen); break; } return 0; @@ -1186,7 +1186,7 @@ bool CConsoleMinecraftApp::CheckForEmptyStore(int iPad) SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); bool bEmptyStore=true; - if(pCategories!=NULL) + if(pCategories!=nullptr) { if(pCategories->countOfProducts>0) { @@ -1244,7 +1244,7 @@ void CConsoleMinecraftApp::PatchAvailableDialogTick() UINT uiIDA[1]; uiIDA[0]=IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION_PATCH_AVAILABLE, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL, app.GetStringTable()); + ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION_PATCH_AVAILABLE, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr, app.GetStringTable()); m_bPatchAvailableDialogRunning=false; } } diff --git a/Minecraft.Client/Orbis/Orbis_App.h b/Minecraft.Client/Orbis/Orbis_App.h index 1c09579f7..06b6e83a8 100644 --- a/Minecraft.Client/Orbis/Orbis_App.h +++ b/Minecraft.Client/Orbis/Orbis_App.h @@ -86,7 +86,7 @@ class CConsoleMinecraftApp : public CMinecraftApp // BANNED LEVEL LIST virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {} - C4JStringTable *GetStringTable() { return NULL;} + C4JStringTable *GetStringTable() { return nullptr;} // original code virtual void TemporaryCreateGameStart(); diff --git a/Minecraft.Client/Orbis/Orbis_Minecraft.cpp b/Minecraft.Client/Orbis/Orbis_Minecraft.cpp index 646165652..01d24fe1d 100644 --- a/Minecraft.Client/Orbis/Orbis_Minecraft.cpp +++ b/Minecraft.Client/Orbis/Orbis_Minecraft.cpp @@ -362,7 +362,7 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, return pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, - NULL, + nullptr, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, pd3dPP, ppDevice ); @@ -381,16 +381,16 @@ void MemSect(int sect) #endif #ifndef __ORBIS__ -HINSTANCE g_hInst = NULL; -HWND g_hWnd = NULL; +HINSTANCE g_hInst = nullptr; +HWND g_hWnd = nullptr; D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; -ID3D11Device* g_pd3dDevice = NULL; -ID3D11DeviceContext* g_pImmediateContext = NULL; -IDXGISwapChain* g_pSwapChain = NULL; -ID3D11RenderTargetView* g_pRenderTargetView = NULL; -ID3D11DepthStencilView* g_pDepthStencilView = NULL; -ID3D11Texture2D* g_pDepthStencilBuffer = NULL; +ID3D11Device* g_pd3dDevice = nullptr; +ID3D11DeviceContext* g_pImmediateContext = nullptr; +IDXGISwapChain* g_pSwapChain = nullptr; +ID3D11RenderTargetView* g_pRenderTargetView = nullptr; +ID3D11DepthStencilView* g_pDepthStencilView = nullptr; +ID3D11Texture2D* g_pDepthStencilBuffer = nullptr; // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) @@ -455,7 +455,7 @@ ATOM MyRegisterClass(HINSTANCE hInstance) wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, "Minecraft"); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = "Minecraft"; wcex.lpszClassName = "MinecraftClass"; @@ -479,7 +479,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) g_hInst = hInstance; // Store instance handle in our global variable g_hWnd = CreateWindow("MinecraftClass", "Minecraft", WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); if (!g_hWnd) { @@ -543,7 +543,7 @@ HRESULT InitDevice() for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) { g_driverType = driverTypes[driverTypeIndex]; - hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, + hr = D3D11CreateDeviceAndSwapChain( nullptr, g_driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext ); if( HRESULT_SUCCEEDED( hr ) ) break; @@ -552,7 +552,7 @@ HRESULT InitDevice() return hr; // Create a render target view - ID3D11Texture2D* pBackBuffer = NULL; + ID3D11Texture2D* pBackBuffer = nullptr; hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer ); if( FAILED( hr ) ) return hr; @@ -571,7 +571,7 @@ HRESULT InitDevice() descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; descDepth.CPUAccessFlags = 0; descDepth.MiscFlags = 0; - hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); + hr = g_pd3dDevice->CreateTexture2D(&descDepth, nullptr, &g_pDepthStencilBuffer); D3D11_DEPTH_STENCIL_VIEW_DESC descDSView; descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; @@ -580,7 +580,7 @@ HRESULT InitDevice() hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); - hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView ); + hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, nullptr, &g_pRenderTargetView ); pBackBuffer->Release(); if( FAILED( hr ) ) return hr; @@ -773,7 +773,7 @@ int main(int argc, const char *argv[] ) MSG msg = {0}; while( WM_QUIT != msg.message ) { - if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) + if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); @@ -919,7 +919,7 @@ int main(int argc, const char *argv[] ) StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app,""); StorageManager.SetSaveTitleExtraFileSuffix(app.GetString(IDS_SAVE_SUBTITLE_SUFFIX)); StorageManager.SetDLCInfoMap(app.GetSonyDLCMap()); - app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL + app.CommerceInit(); // MGH - moved this here so GetCommerce isn't nullptr // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised app.GetCommerce()->CheckForTrialUpgradeKey(); @@ -939,7 +939,7 @@ int main(int argc, const char *argv[] ) } // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers) - hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); + hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, nullptr); if ( FAILED( hr ) ) { app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr ); @@ -1089,7 +1089,7 @@ int main(int argc, const char *argv[] ) // Minecraft::main () used to call Minecraft::Start, but this takes ~2.5 seconds, so now running this in another thread // so we can do some basic renderer calls whilst it is happening. This is at attempt to stop getting TRC failure on SubmitDone taking > 5 seconds on boot - C4JThread *minecraftThread = new C4JThread(&StartMinecraftThreadProc, NULL, "Running minecraft start"); + C4JThread *minecraftThread = new C4JThread(&StartMinecraftThreadProc, nullptr, "Running minecraft start"); minecraftThread->Run(); do { @@ -1194,7 +1194,7 @@ int main(int argc, const char *argv[] ) // We should track down why though... app.DebugPrintf("---init sound engine()\n"); - pMinecraft->soundEngine->init(NULL); + pMinecraft->soundEngine->init(nullptr); while (TRUE) { @@ -1249,7 +1249,7 @@ int main(int argc, const char *argv[] ) else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true,false); IntCache::Reset(); @@ -1487,7 +1487,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID) uint8_t * AddRichPresenceString(int iID) { uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); - if( strUtf8 != NULL ) + if( strUtf8 != nullptr ) { vRichPresenceStrings.push_back(strUtf8); } diff --git a/Minecraft.Client/Orbis/Orbis_UIController.cpp b/Minecraft.Client/Orbis/Orbis_UIController.cpp index 38cc79e94..a6ed530e4 100644 --- a/Minecraft.Client/Orbis/Orbis_UIController.cpp +++ b/Minecraft.Client/Orbis/Orbis_UIController.cpp @@ -182,7 +182,7 @@ void ConsoleUIController::render() throttle++; #else - gdraw_orbis_End(NULL); + gdraw_orbis_End(nullptr); #endif #endif @@ -252,7 +252,7 @@ GDrawTexture *ConsoleUIController::getSubstitutionTexture(int textureId) GDrawTexture *gdrawTex = gdraw_orbis_WrappedTextureCreate(tex); return gdrawTex; - return NULL; + return nullptr; } void ConsoleUIController::destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle) diff --git a/Minecraft.Client/Orbis/XML/ATGXmlParser.h b/Minecraft.Client/Orbis/XML/ATGXmlParser.h index 75142e3e3..12f597372 100644 --- a/Minecraft.Client/Orbis/XML/ATGXmlParser.h +++ b/Minecraft.Client/Orbis/XML/ATGXmlParser.h @@ -138,7 +138,7 @@ class XMLParser DWORD m_dwCharsTotal; DWORD m_dwCharsConsumed; - BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing NULL + BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing nullptr WCHAR m_pWriteBuf[ XML_WRITE_BUFFER_SIZE ]; BYTE* m_pReadPtr; diff --git a/Minecraft.Client/Orbis/user_malloc.cpp b/Minecraft.Client/Orbis/user_malloc.cpp index 6a85e83b5..d7552b5ba 100644 --- a/Minecraft.Client/Orbis/user_malloc.cpp +++ b/Minecraft.Client/Orbis/user_malloc.cpp @@ -54,7 +54,7 @@ int user_malloc_init(void) return 1; } - addr = NULL; + addr = nullptr; //E Map direct memory to the process address space res = sceKernelMapDirectMemory(&addr, s_heapLength, SCE_KERNEL_PROT_CPU_READ | SCE_KERNEL_PROT_CPU_WRITE, 0, s_memStart, s_memAlign); if (res < 0) { @@ -64,7 +64,7 @@ int user_malloc_init(void) //E Generate mspace s_mspace = sceLibcMspaceCreate("User Malloc", addr, s_heapLength, 0); - if (s_mspace == NULL) { + if (s_mspace == nullptr) { //E Error handling return 1; } @@ -77,7 +77,7 @@ int user_malloc_finalize(void) { int res; - if (s_mspace != NULL) { + if (s_mspace != nullptr) { //E Free mspace //J mspace を解放する res = sceLibcMspaceDestroy(s_mspace); diff --git a/Minecraft.Client/Orbis/user_malloc_for_tls.cpp b/Minecraft.Client/Orbis/user_malloc_for_tls.cpp index d1a8d2555..d862b6b9f 100644 --- a/Minecraft.Client/Orbis/user_malloc_for_tls.cpp +++ b/Minecraft.Client/Orbis/user_malloc_for_tls.cpp @@ -39,7 +39,7 @@ int user_malloc_init_for_tls(void) return 1; } - addr = NULL; + addr = nullptr; //E Map direct memory to the process address space //J ダイレクトメモリをプロセスアドレス空間にマップする res = sceKernelMapDirectMemory(&addr, HEAP_SIZE, SCE_KERNEL_PROT_CPU_READ | SCE_KERNEL_PROT_CPU_WRITE, 0, s_memStart, s_memAlign); @@ -52,7 +52,7 @@ int user_malloc_init_for_tls(void) //E Generate mspace //J mspace を生成する s_mspace = sceLibcMspaceCreate("User Malloc For TLS", addr, HEAP_SIZE, 0); - if (s_mspace == NULL) { + if (s_mspace == nullptr) { //E Error handling //J エラー処理 return 1; @@ -67,7 +67,7 @@ int user_malloc_fini_for_tls(void) { int res; - if (s_mspace != NULL) { + if (s_mspace != nullptr) { //E Free mspace //J mspace を解放する res = sceLibcMspaceDestroy(s_mspace); diff --git a/Minecraft.Client/Orbis/user_new.cpp b/Minecraft.Client/Orbis/user_new.cpp index 83aa3f8ca..e31083544 100644 --- a/Minecraft.Client/Orbis/user_new.cpp +++ b/Minecraft.Client/Orbis/user_new.cpp @@ -26,13 +26,13 @@ void *user_new(std::size_t size) throw(std::bad_alloc) if (size == 0) size = 1; - while ((ptr = (void *)std::malloc(size)) == NULL) { + while ((ptr = (void *)std::malloc(size)) == nullptr) { //E Obtain new_handler //J new_handler を取得する std::new_handler handler = std::get_new_handler(); - //E When new_handler is a NULL pointer, bad_alloc is send. If not, new_handler is called. - //J new_handler が NULL ポインタの場合、bad_alloc を送出する、そうでない場合、new_handler を呼び出す + //E When new_handler is a nullptr pointer, bad_alloc is send. If not, new_handler is called. + //J new_handler が nullptr ポインタの場合、bad_alloc を送出する、そうでない場合、new_handler を呼び出す if (!handler) { assert(0);//throw std::bad_alloc(); @@ -54,27 +54,27 @@ void *user_new(std::size_t size, const std::nothrow_t& x) throw() // if (size == 0) // size = 1; // -// while ((ptr = (void *)std::malloc(size)) == NULL) { +// while ((ptr = (void *)std::malloc(size)) == nullptr) { // //E Obtain new_handler // //J new_handler を取得する // std::new_handler handler = std::get_new_handler(); // -// //E When new_handler is a NULL pointer, NULL is returned. -// //J new_handler が NULL ポインタの場合、NULL を返す +// //E When new_handler is a nullptr pointer, nullptr is returned. +// //J new_handler が nullptr ポインタの場合、nullptr を返す // if (!handler) -// return NULL; +// return nullptr; // -// //E Call new_handler. If new_handler sends bad_alloc, NULL is returned. -// //J new_handler を呼び出す、new_handler が bad_alloc を送出した場合、NULL を返す +// //E Call new_handler. If new_handler sends bad_alloc, nullptr is returned. +// //J new_handler を呼び出す、new_handler が bad_alloc を送出した場合、nullptr を返す // try { // (*handler)(); // } catch (std::bad_alloc) { -// return NULL; +// return nullptr; // } // } // return ptr; assert(0); - return NULL; + return nullptr; } //E Replace operator new[]. @@ -95,9 +95,9 @@ void *user_new_array(std::size_t size, const std::nothrow_t& x) throw() //J operator delete と置き換わる void user_delete(void *ptr) throw() { - //E In the case of the NULL pointer, no action will be taken. - //J NULL ポインタの場合、何も行わない - if (ptr != NULL) + //E In the case of the nullptr pointer, no action will be taken. + //J nullptr ポインタの場合、何も行わない + if (ptr != nullptr) std::free(ptr); } diff --git a/Minecraft.Client/PS3/4JLibs/STO_TitleSmallStorage.cpp b/Minecraft.Client/PS3/4JLibs/STO_TitleSmallStorage.cpp index f3d2729f0..bb7c88c7e 100644 --- a/Minecraft.Client/PS3/4JLibs/STO_TitleSmallStorage.cpp +++ b/Minecraft.Client/PS3/4JLibs/STO_TitleSmallStorage.cpp @@ -58,7 +58,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) { int32_t ret = 0; int32_t transId = 0; - void *data=NULL; + void *data=nullptr; size_t dataSize=0; SceNpId npId; @@ -100,7 +100,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) //memset(&npclient_info, 0x00, sizeof(npclient_info)); data = malloc(SCE_NET_NP_TSS_MAX_SIZE); - if (data == NULL) + if (data == nullptr) { printf("out of memory: can't allocate memory for titleSmallStorage\n"); ret = -1; @@ -121,7 +121,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) // data, // SCE_NET_NP_TSS_MAX_SIZE, // &dataSize, -// NULL); +// nullptr); // if (ret < 0) // { // printf("sceNpLookupTitleSmallStorage() failed. ret = 0x%x\n", ret); @@ -150,7 +150,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) size_t dataSize; SceNpTssSlotId slotId=SLOTID; SceNpTssDataStatus dataStatus; - const char *ptr =NULL; + const char *ptr =nullptr; size_t recvdSize=0; size_t totalSize=0; size_t recvSize=0; @@ -163,7 +163,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) sizeof(SceNpTssDataStatus), ptr, recvSize, - NULL); + nullptr); if (ret < 0) { // Error handling @@ -174,10 +174,10 @@ int32_t CTSS::doLookupTitleSmallStorage(void) // Processing when there is no data goto finish; } - if (ptr == NULL) + if (ptr == nullptr) { ptr = malloc(dataStatus.contentLength); - if (ptr == NULL){ + if (ptr == nullptr){ // Error handling goto error; } @@ -197,7 +197,7 @@ int32_t CTSS::doLookupTitleSmallStorage(void) ret = sceNpLookupDestroyTransactionCtx(transId); printf("sceNpLookupDestroyTransactionCtx() done. ret = 0x%x\n", ret); } - if (data != NULL) + if (data != nullptr) { free(data); } diff --git a/Minecraft.Client/PS3/4JLibs/inc/4J_Input.h b/Minecraft.Client/PS3/4JLibs/inc/4J_Input.h index 6f51bba51..9d46e7413 100644 --- a/Minecraft.Client/PS3/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/PS3/4JLibs/inc/4J_Input.h @@ -130,8 +130,8 @@ class C_4JInput void SetMenuDisplayed(int iPad, bool bVal); -// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); -// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); +// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); +// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); void DestroyKeyboard(); void GetText(uint16_t *UTF16String); diff --git a/Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h b/Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h index 888c38cc5..4a65dcb96 100644 --- a/Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/PS3/4JLibs/inc/4J_Profile.h @@ -109,7 +109,7 @@ class C_4JProfile // ACHIEVEMENTS & AWARDS void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false, - CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L); + CXuiStringTable*pStringTable=nullptr, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=nullptr, unsigned int uiThemeSize=0L); int GetAwardId(int iAwardNumber); eAwardType GetAwardType(int iAwardNumber); bool CanBeAwarded(int iQuadrant, int iAwardNumber); diff --git a/Minecraft.Client/PS3/4JLibs/inc/4J_Render.h b/Minecraft.Client/PS3/4JLibs/inc/4J_Render.h index d55f440bf..1b68695f0 100644 --- a/Minecraft.Client/PS3/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/PS3/4JLibs/inc/4J_Render.h @@ -17,8 +17,8 @@ class ImageFileBuffer int GetType() { return m_type; } void *GetBufferPointer() { return m_pBuffer; } int GetBufferSize() { return m_bufferSize; } - void Release() { delete m_pBuffer; m_pBuffer = NULL; } - bool Allocated() { return m_pBuffer != NULL; } + void Release() { delete m_pBuffer; m_pBuffer = nullptr; } + bool Allocated() { return m_pBuffer != nullptr; } }; typedef struct @@ -60,7 +60,7 @@ class C4JRender void InitialiseContext(); void StartFrame(); void Present(); - void Clear(int flags, D3D11_RECT *pRect = NULL); + void Clear(int flags, D3D11_RECT *pRect = nullptr); void SetClearColour(const float colourRGBA[4]); bool IsWidescreen(); bool IsHiDef(); diff --git a/Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h b/Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h index 3950bbad6..b95325b37 100644 --- a/Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/PS3/4JLibs/inc/4J_Storage.h @@ -293,7 +293,7 @@ typedef struct // Messages C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=USER_INDEX_ANY, - int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, StringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0); + int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=nullptr,LPVOID lpParam=nullptr, StringTable *pStringTable=nullptr, WCHAR *pwchFormatString=nullptr,DWORD dwFocusButton=0); C4JStorage::EMessageResult GetMessageBoxResult(); @@ -350,7 +350,7 @@ typedef struct void FreeSaveData(); void SetSaveDataSize(unsigned int uiBytes); // after a successful compression, update the size of the gamedata - //void SaveSaveData(unsigned int uiBytes,PBYTE pbThumbnail=NULL,DWORD cbThumbnail=0,PBYTE pbTextData=NULL, DWORD dwTextLen=0); + //void SaveSaveData(unsigned int uiBytes,PBYTE pbThumbnail=nullptr,DWORD cbThumbnail=0,PBYTE pbTextData=nullptr, DWORD dwTextLen=0); C4JStorage::ESaveGameState SaveSaveData(int( *Func)(LPVOID ,const bool),LPVOID lpParam, bool bDataFileOnly = false); void CopySaveDataToNewSave(PBYTE pbThumbnail,DWORD cbThumbnail,WCHAR *wchNewName,int ( *Func)(LPVOID lpParam, bool), LPVOID lpParam); void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected); @@ -383,8 +383,8 @@ typedef struct DWORD GetAvailableDLCCount( int iPad); CONTENT_DATA& GetDLC(DWORD dw); C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = NULL); - DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = nullptr); + DWORD UnmountInstalledDLC(LPCSTR szMountDrive = nullptr); void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); std::string GetMountedPath(std::string szMount); C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType, WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(LPVOID, WCHAR *,int, bool, int),LPVOID lpParam, int iAction) { return C4JStorage::ETMSStatus_Idle; } @@ -400,7 +400,7 @@ typedef struct bool CheckForTrialUpgradeKey(void( *Func)(LPVOID, bool),LPVOID lpParam); - C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)/*=NULL*/,LPVOID lpParam/*=NULL*/, int iUserData/*=0*/) {return C4JStorage::ETMSStatus_Idle;} + C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)/*=nullptr*/,LPVOID lpParam/*=nullptr*/, int iUserData/*=0*/) {return C4JStorage::ETMSStatus_Idle;} // PROFILE DATA int SetDefaultOptionsCallback(int( *Func)(LPVOID,PROFILESETTINGS *, const int iPad),LPVOID lpParam); diff --git a/Minecraft.Client/PS3/Audio/PS3_SoundEngine.cpp b/Minecraft.Client/PS3/Audio/PS3_SoundEngine.cpp index fcce5f05a..1c7edba30 100644 --- a/Minecraft.Client/PS3/Audio/PS3_SoundEngine.cpp +++ b/Minecraft.Client/PS3/Audio/PS3_SoundEngine.cpp @@ -37,7 +37,7 @@ int SoundEngine::initAudioHardware( int minimum_chans ) a_config.channel = ch_pcm; a_config.encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; a_config.downMixer = CELL_AUDIO_OUT_DOWNMIXER_NONE; /* No downmixer is used */ - cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, NULL, 0 ); + cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, nullptr, 0 ); ret = ch_pcm; } @@ -51,7 +51,7 @@ int SoundEngine::initAudioHardware( int minimum_chans ) a_config.channel = 6; a_config.encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; a_config.downMixer = CELL_AUDIO_OUT_DOWNMIXER_TYPE_B; - if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, NULL, 0 ) != CELL_OK ) + if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, nullptr, 0 ) != CELL_OK ) { return 0; // error - the downmixer didn't init } @@ -83,7 +83,7 @@ int SoundEngine::initAudioHardware( int minimum_chans ) ret = 8; } - if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, NULL, 0 ) == CELL_OK ) + if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, nullptr, 0 ) == CELL_OK ) { break; } @@ -94,7 +94,7 @@ int SoundEngine::initAudioHardware( int minimum_chans ) a_config.channel = 2; a_config.encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; a_config.downMixer = CELL_AUDIO_OUT_DOWNMIXER_TYPE_A; - if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, NULL, 0 ) != CELL_OK ) + if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, nullptr, 0 ) != CELL_OK ) { return 0; // error - downmixer didn't work } diff --git a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm.cpp b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm.cpp index 997e8d837..e8bd03679 100644 --- a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm.cpp +++ b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm.cpp @@ -751,7 +751,7 @@ static void api_free_resource(GDrawHandle *r) S32 i; for (i=0; i < MAX_SAMPLERS; i++) if (gdraw->active_tex[i] == (GDrawTexture *) r) - gdraw->active_tex[i] = NULL; + gdraw->active_tex[i] = nullptr; } static void RADLINK gdraw_UnlockHandles(GDrawStats *stats) @@ -772,7 +772,7 @@ extern GDrawTexture *gdraw_GCM_WrappedTextureCreate(CellGcmTexture *gcm_tex) memset(&stats, 0, sizeof(stats)); GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats); // it may need to free one item to give us a handle p->handle.tex.gcm_ptr = 0; - gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned); + gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned); gdraw_GCM_WrappedTextureChange((GDrawTexture *) p, gcm_tex); return (GDrawTexture *) p; } @@ -816,11 +816,11 @@ static bool is_texture_swizzled(S32 w, S32 h) static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format gformat, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) { S32 bytes_pixel = 4; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; bool swizzled = false; if (width > 4096 || height > 4096) { - IggyGDrawSendWarning(NULL, "GDraw %d x %d texture not supported by hardware (dimension size limit 4096)", width, height); + IggyGDrawSendWarning(nullptr, "GDraw %d x %d texture not supported by hardware (dimension size limit 4096)", width, height); return false; } @@ -893,7 +893,7 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, if (swizzled || (flags & GDRAW_MAKETEXTURE_FLAGS_mipmap)) { rrbool ok; - assert(p->temp_buffer != NULL); + assert(p->temp_buffer != nullptr); ok = gdraw_MipmapBegin(&gdraw->mipmap, width, height, mipmaps, bytes_pixel, p->temp_buffer, p->temp_buffer_bytes); assert(ok); // this should never hit unless the temp_buffer is way too small @@ -1023,8 +1023,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void *unique_id, GDr static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats) { GDrawHandle *t = (GDrawHandle *) tt; - assert(t != NULL); // @GDRAW_ASSERT - if (t->owner == unique_id || unique_id == NULL) { + assert(t != nullptr); // @GDRAW_ASSERT + if (t->owner == unique_id || unique_id == nullptr) { if (t->cache == &gdraw->rendertargets) { gdraw_HandleCacheUnlock(t); // cache it by simply not freeing it @@ -1121,7 +1121,7 @@ static rrbool RADLINK gdraw_TryLockVertexBuffer(GDrawVertexBuffer *vb, void *uni static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) { GDrawHandle *h = (GDrawHandle *) vb; - assert(h != NULL); // @GDRAW_ASSERT + assert(h != nullptr); // @GDRAW_ASSERT if (h->owner == unique_id) gdraw_res_kill(h, stats); } @@ -1152,19 +1152,19 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats) t = gdraw_HandleCacheAllocateBegin(&gdraw->rendertargets); if (!t) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit handle limit"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit handle limit"); return t; } void *ptr = gdraw_arena_alloc(&gdraw->rt_arena, size, 1); if (!ptr) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: out of rendertarget texture memory"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: out of rendertarget texture memory"); gdraw_HandleCacheAllocateFail(t); - return NULL; + return nullptr; } t->fence = get_next_fence(); // we're about to start using it immediately, so... - t->raw_ptr = NULL; + t->raw_ptr = nullptr; t->handle.tex.gcm_ptr = ptr; @@ -1329,14 +1329,14 @@ static void set_common_renderstate() // reset our state caching for (i=0; i < MAX_SAMPLERS; i++) { - gdraw->active_tex[i] = NULL; + gdraw->active_tex[i] = nullptr; cellGcmSetTextureControl(gcm, i, CELL_GCM_FALSE, 0, 0, 0); } assert(gdraw->aa_tex.offset != 0); // if you hit this, your initialization is screwed up. set_rsx_texture(gdraw->gcm, AATEX_SAMPLER, &gdraw->aa_tex, GDRAW_WRAP_clamp, 0); - gdraw->cur_fprog = NULL; + gdraw->cur_fprog = nullptr; gdraw->vert_format = -1; gdraw->scissor_state = ~0u; gdraw->blend_mode = -1; @@ -1363,7 +1363,7 @@ static void clear_renderstate(void) static void set_render_target() { - GcmTexture *tex = NULL; + GcmTexture *tex = nullptr; S32 i; CellGcmSurface surf = gdraw->main_surface; @@ -1384,7 +1384,7 @@ static void set_render_target() // invalidate current textures (need to reset them to force L1 texture cache flush) for (i=0; i < MAX_SAMPLERS; ++i) - gdraw->active_tex[i] = NULL; + gdraw->active_tex[i] = nullptr; } //////////////////////////////////////////////////////////////////////// @@ -1513,19 +1513,19 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex GDrawFramebufferState *n = gdraw->cur+1; GDrawHandle *t; if (gdraw->tw == 0 || gdraw->th == 0) { - IggyGDrawSendWarning(NULL, "GDraw warning: w=0,h=0 rendertarget"); + IggyGDrawSendWarning(nullptr, "GDraw warning: w=0,h=0 rendertarget"); return false; } if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) { assert(0); - IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); return false; } if (owner) { // @TODO implement - t = NULL; + t = nullptr; assert(0); // nyi } else { t = get_color_rendertarget(stats); @@ -1534,9 +1534,9 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex } n->color_buffer = t; - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT - n->cached = owner != NULL; + n->cached = owner != nullptr; if (owner) { n->base_x = region->x0; n->base_y = region->y0; @@ -1617,9 +1617,9 @@ static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats) assert(m >= gdraw->frame); // bug in Iggy -- unbalanced if (m != gdraw->frame) { - assert(m->color_buffer != NULL); // @GDRAW_ASSERT + assert(m->color_buffer != nullptr); // @GDRAW_ASSERT } - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT // wait for render to texture operation to finish // can't put down a backend fence directly, there might still be @@ -1694,7 +1694,7 @@ static void set_fragment_para(GDraw * RADRESTRICT gd, U32 ucode_offs, int para, if (para == -1) return; - gd->cur_fprog = NULL; // need to re-set shader after patching + gd->cur_fprog = nullptr; // need to re-set shader after patching const U64 *inv = (const U64 *) values; const int *patch_offs = (const int *) para; @@ -1728,7 +1728,7 @@ static void set_fragment_para(GDraw * RADRESTRICT gd, U32 ucode_offs, int para, static RADINLINE void set_texture(S32 texunit, GDrawTexture *tex) { assert(texunit < MAX_SAMPLERS); - assert(tex != NULL); + assert(tex != nullptr); if (gdraw->active_tex[texunit] != tex) { gdraw->active_tex[texunit] = tex; @@ -1983,7 +1983,7 @@ static RADINLINE void set_vertex_decl(GDraw * RADRESTRICT gd, CellGcmContextData // Draw triangles with a given renderstate // -static RADINLINE void fence_resources(GDraw * RADRESTRICT gd, void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL) +static RADINLINE void fence_resources(GDraw * RADRESTRICT gd, void *r1, void *r2=nullptr, void *r3=nullptr, void *r4=nullptr) { GDrawFence fence; fence.value = gd->next_fence_index; @@ -2046,7 +2046,7 @@ static void RADLINK gdraw_DrawIndexedTriangles(GDrawRenderState *r, GDrawPrimiti while (pos < p->num_indices) { S32 vert_count = RR_MIN(p->num_indices - pos, verts_per_chunk); void *ring = gdraw_bufring_alloc(&gd->dyn_vb, vert_count * vsize, CELL_GCM_VERTEX_TEXTURE_CACHE_LINE_SIZE); - assert(ring != NULL); // we specifically chunked so this alloc succeeds! + assert(ring != nullptr); // we specifically chunked so this alloc succeeds! // prepare for painting... cellGcmSetInvalidateVertexCache(gcm); @@ -2083,7 +2083,7 @@ static void RADLINK gdraw_DrawIndexedTriangles(GDrawRenderState *r, GDrawPrimiti S32 vert_count = RR_MIN(p->num_vertices - pos, verts_per_chunk); U32 chunk_bytes = vert_count * vsize; void *ring = gdraw_bufring_alloc(&gd->dyn_vb, chunk_bytes, CELL_GCM_VERTEX_TEXTURE_CACHE_LINE_SIZE); - assert(ring != NULL); // we picked the chunk size so this alloc succeeds! + assert(ring != nullptr); // we picked the chunk size so this alloc succeeds! memcpy(ring, (U8 *)p->vertices + pos * vsize, chunk_bytes); cellGcmSetInvalidateVertexCache(gcm); @@ -2203,7 +2203,7 @@ static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbe { ProgramWithCachedVariableLocations *prg = &gdraw->filter_prog[isbevel][r->filter_mode]; U32 ucode_offs = prg->cfg.offset; - if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, stats)) + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, nullptr, stats)) return; set_texture(0, r->tex[0]); @@ -2287,14 +2287,14 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 assert(0); } } else { - GDrawHandle *blend_tex = NULL; + GDrawHandle *blend_tex = nullptr; GDraw *gd = gdraw; // for crazy blend modes, we need to read back from the framebuffer // and do the blending in the pixel shader. so we need to copy the // relevant pixels from our active render target into a texture. if (r->blend_mode == GDRAW_BLEND_special && - (blend_tex = get_color_rendertarget(stats)) != NULL) { + (blend_tex = get_color_rendertarget(stats)) != nullptr) { // slightly different logic depending on whether we were rendering // to the main color buffer or a render target, because the former // has tile origin-based coordinates while the latter don't. also, @@ -2344,7 +2344,7 @@ static void create_fragment_program(ProgramWithCachedVariableLocations *p, Progr cellGcmCgGetUCode(p->program, &ucode_main, &ucode_size); ucode_local = gdraw_arena_alloc(&gdraw->local_arena, ucode_size + 400, CELL_GCM_FRAGMENT_UCODE_LOCAL_ALIGN_OFFSET); // 400 for overfetch - assert(ucode_local != NULL); // if this triggers, it's a GDraw bug + assert(ucode_local != nullptr); // if this triggers, it's a GDraw bug memcpy(ucode_local, ucode_main, ucode_size); cellGcmCgGetCgbFragmentProgramConfiguration(p->program, &p->cfg, 0, 1, 0); @@ -2408,7 +2408,7 @@ static GDrawHandleCache *make_handle_cache(gdraw_gcm_resourcetype type, U32 alig U32 header_size = is_vertex ? 0 : sizeof(GcmTexture) * num_handles; if (!num_handles) - return NULL; + return nullptr; GDrawHandleCache *cache = (GDrawHandleCache *) IggyGDrawMalloc(cache_size + header_size); if (cache) { @@ -2427,7 +2427,7 @@ static GDrawHandleCache *make_handle_cache(gdraw_gcm_resourcetype type, U32 alig cache->alloc = gfxalloc_create(gdraw_mem[type].ptr, num_bytes, align, num_handles); if (!cache->alloc) { IggyGDrawFree(cache); - cache = NULL; + cache = nullptr; } } @@ -2496,14 +2496,14 @@ int gdraw_GCM_SetResourceMemory(gdraw_gcm_resourcetype type, S32 num_handles, vo free_handle_cache(gdraw->texturecache); gdraw->texturecache = make_handle_cache(GDRAW_GCM_RESOURCE_texture, CELL_GCM_TEXTURE_SWIZZLE_ALIGN_OFFSET); gdraw->tex_loc = get_location(ptr); - return gdraw->texturecache != NULL; + return gdraw->texturecache != nullptr; case GDRAW_GCM_RESOURCE_vertexbuffer: free_handle_cache(gdraw->vbufcache); gdraw->vbufcache = make_handle_cache(GDRAW_GCM_RESOURCE_vertexbuffer, CELL_GCM_SURFACE_LINEAR_ALIGN_OFFSET); gdraw->vbuf_base = ptr ? (U8 *) ptr - addr2offs(ptr) : 0; gdraw->vbuf_loc = get_location(ptr); - return gdraw->vbufcache != NULL; + return gdraw->vbufcache != nullptr; case GDRAW_GCM_RESOURCE_dyn_vertexbuffer: gdraw_bufring_shutdown(&gdraw->dyn_vb); @@ -2549,10 +2549,10 @@ int gdraw_GCM_SetRendertargetMemory(void *ptr, S32 num_bytes, S32 width, S32 hei void gdraw_GCM_ResetAllResourceMemory() { - gdraw_GCM_SetResourceMemory(GDRAW_GCM_RESOURCE_texture, 0, NULL, 0); - gdraw_GCM_SetResourceMemory(GDRAW_GCM_RESOURCE_vertexbuffer, 0, NULL, 0); - gdraw_GCM_SetResourceMemory(GDRAW_GCM_RESOURCE_dyn_vertexbuffer, 0, NULL, 0); - gdraw_GCM_SetRendertargetMemory(NULL, 0, 0, 0, 0); + gdraw_GCM_SetResourceMemory(GDRAW_GCM_RESOURCE_texture, 0, nullptr, 0); + gdraw_GCM_SetResourceMemory(GDRAW_GCM_RESOURCE_vertexbuffer, 0, nullptr, 0); + gdraw_GCM_SetResourceMemory(GDRAW_GCM_RESOURCE_dyn_vertexbuffer, 0, nullptr, 0); + gdraw_GCM_SetRendertargetMemory(nullptr, 0, 0, 0, 0); } GDrawFunctions *gdraw_GCM_CreateContext(CellGcmContextData *gcm, void *local_workmem, U8 rsx_label_index) @@ -2560,7 +2560,7 @@ GDrawFunctions *gdraw_GCM_CreateContext(CellGcmContextData *gcm, void *local_wor S32 i; gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw)); // make sure gdraw struct is PPU cache line aligned - if (!gdraw) return NULL; + if (!gdraw) return nullptr; memset(gdraw, 0, sizeof(*gdraw)); @@ -2648,7 +2648,7 @@ void gdraw_GCM_DestroyContext(void) free_handle_cache(gdraw->texturecache); free_handle_cache(gdraw->vbufcache); IggyGDrawFree(gdraw); - gdraw = NULL; + gdraw = nullptr; } } diff --git a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm.h b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm.h index f8ec8705e..cf691d067 100644 --- a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm.h +++ b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm.h @@ -108,7 +108,7 @@ IDOC extern GDrawFunctions * gdraw_GCM_CreateContext(CellGcmContextData *gcm, vo There can only be one GCM GDraw context active at any one time. If initialization fails for some reason (the main reason would be an out of memory condition), - NULL is returned. Otherwise, you can pass the return value to IggySetGDraw. */ + nullptr is returned. Otherwise, you can pass the return value to IggySetGDraw. */ IDOC extern void gdraw_GCM_DestroyContext(void); /* Destroys the current GDraw context, if any. */ diff --git a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl index c8a3b42ea..4d3c91bb0 100644 --- a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl +++ b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_ps3gcm_shaders.inl @@ -273,24 +273,24 @@ static int pshader_basic_econst[28] = { }; static ProgramWithCachedVariableLocations pshader_basic_arr[18] = { - { { pshader_basic_0 }, { NULL }, { -1, 7, -1, -1, -1, } }, - { { pshader_basic_1 }, { NULL }, { -1, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 0)), -1, } }, - { { pshader_basic_2 }, { NULL }, { -1, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 0)), -1, } }, - { { pshader_basic_3 }, { NULL }, { 0, 7, -1, -1, -1, } }, - { { pshader_basic_4 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 2)), -1, } }, - { { pshader_basic_5 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 4)), -1, } }, - { { pshader_basic_6 }, { NULL }, { 0, 7, -1, -1, -1, } }, - { { pshader_basic_7 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, - { { pshader_basic_8 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, - { { pshader_basic_9 }, { NULL }, { 0, 7, -1, -1, -1, } }, - { { pshader_basic_10 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 8)), -1, } }, - { { pshader_basic_11 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 10)), -1, } }, - { { pshader_basic_12 }, { NULL }, { 0, 7, -1, -1, static_cast((intptr_t)(pshader_basic_econst + 12)), } }, - { { pshader_basic_13 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 16)), static_cast((intptr_t)(pshader_basic_econst + 18)), } }, - { { pshader_basic_14 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 22)), static_cast((intptr_t)(pshader_basic_econst + 24)), } }, - { { pshader_basic_15 }, { NULL }, { 0, 7, -1, -1, -1, } }, - { { pshader_basic_16 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 2)), -1, } }, - { { pshader_basic_17 }, { NULL }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, + { { pshader_basic_0 }, { nullptr }, { -1, 7, -1, -1, -1, } }, + { { pshader_basic_1 }, { nullptr }, { -1, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 0)), -1, } }, + { { pshader_basic_2 }, { nullptr }, { -1, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 0)), -1, } }, + { { pshader_basic_3 }, { nullptr }, { 0, 7, -1, -1, -1, } }, + { { pshader_basic_4 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 2)), -1, } }, + { { pshader_basic_5 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 4)), -1, } }, + { { pshader_basic_6 }, { nullptr }, { 0, 7, -1, -1, -1, } }, + { { pshader_basic_7 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, + { { pshader_basic_8 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, + { { pshader_basic_9 }, { nullptr }, { 0, 7, -1, -1, -1, } }, + { { pshader_basic_10 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 8)), -1, } }, + { { pshader_basic_11 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 10)), -1, } }, + { { pshader_basic_12 }, { nullptr }, { 0, 7, -1, -1, static_cast((intptr_t)(pshader_basic_econst + 12)), } }, + { { pshader_basic_13 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 16)), static_cast((intptr_t)(pshader_basic_econst + 18)), } }, + { { pshader_basic_14 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 22)), static_cast((intptr_t)(pshader_basic_econst + 24)), } }, + { { pshader_basic_15 }, { nullptr }, { 0, 7, -1, -1, -1, } }, + { { pshader_basic_16 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 2)), -1, } }, + { { pshader_basic_17 }, { nullptr }, { 0, 7, -1, static_cast((intptr_t)(pshader_basic_econst + 6)), -1, } }, }; static unsigned char pshader_exceptional_blend_1[368] = { @@ -536,19 +536,19 @@ static int pshader_exceptional_blend_econst[4] = { }; static ProgramWithCachedVariableLocations pshader_exceptional_blend_arr[13] = { - { { NULL }, { NULL }, { -1, -1, -1, -1, } }, - { { pshader_exceptional_blend_1 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_2 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_3 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_4 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_5 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_6 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_7 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_8 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_9 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_10 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, - { { pshader_exceptional_blend_11 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 2)), } }, - { { pshader_exceptional_blend_12 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 2)), } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, } }, + { { pshader_exceptional_blend_1 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_2 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_3 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_4 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_5 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_6 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_7 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_8 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_9 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_10 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 0)), } }, + { { pshader_exceptional_blend_11 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 2)), } }, + { { pshader_exceptional_blend_12 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_exceptional_blend_econst + 2)), } }, }; static unsigned char pshader_filter_0[416] = { @@ -1121,38 +1121,38 @@ static int pshader_filter_econst[90] = { }; static ProgramWithCachedVariableLocations pshader_filter_arr[32] = { - { { pshader_filter_0 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 0)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, - { { pshader_filter_1 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 11)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, - { { pshader_filter_2 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, - { { pshader_filter_3 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, - { { pshader_filter_4 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 19)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, - { { pshader_filter_5 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 11)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, - { { pshader_filter_6 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 2)), 2, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, - { { pshader_filter_7 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, - { { pshader_filter_8 }, { NULL }, { -1, 1, static_cast((intptr_t)(pshader_filter_econst + 21)), -1, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 24)), -1, } }, - { { pshader_filter_9 }, { NULL }, { -1, -1, static_cast((intptr_t)(pshader_filter_econst + 27)), -1, -1, -1, -1, -1, } }, - { { pshader_filter_10 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 2)), 2, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, - { { pshader_filter_11 }, { NULL }, { 0, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 29)), 2, static_cast((intptr_t)(pshader_filter_econst + 32)), -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, - { { pshader_filter_16 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, - { { pshader_filter_17 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 47)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 51)), static_cast((intptr_t)(pshader_filter_econst + 35)), } }, - { { pshader_filter_18 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 37)), 2, static_cast((intptr_t)(pshader_filter_econst + 54)), static_cast((intptr_t)(pshader_filter_econst + 59)), -1, } }, - { { pshader_filter_19 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 62)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 66)), -1, } }, - { { pshader_filter_20 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, - { { pshader_filter_21 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 47)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 51)), static_cast((intptr_t)(pshader_filter_econst + 35)), } }, - { { pshader_filter_22 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 69)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 73)), -1, } }, - { { pshader_filter_23 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 62)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 66)), -1, } }, - { { pshader_filter_24 }, { NULL }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, - { { pshader_filter_25 }, { NULL }, { 0, -1, static_cast((intptr_t)(pshader_filter_econst + 76)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), -1, static_cast((intptr_t)(pshader_filter_econst + 67)), } }, - { { pshader_filter_26 }, { NULL }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 78)), 2, static_cast((intptr_t)(pshader_filter_econst + 82)), static_cast((intptr_t)(pshader_filter_econst + 87)), -1, } }, - { { pshader_filter_27 }, { NULL }, { 0, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 37)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, + { { pshader_filter_0 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 0)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_1 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 11)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_2 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, + { { pshader_filter_3 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, + { { pshader_filter_4 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 19)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_5 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 11)), static_cast((intptr_t)(pshader_filter_econst + 2)), -1, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_6 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 2)), 2, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_7 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 13)), 2, static_cast((intptr_t)(pshader_filter_econst + 16)), static_cast((intptr_t)(pshader_filter_econst + 5)), -1, } }, + { { pshader_filter_8 }, { nullptr }, { -1, 1, static_cast((intptr_t)(pshader_filter_econst + 21)), -1, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 24)), -1, } }, + { { pshader_filter_9 }, { nullptr }, { -1, -1, static_cast((intptr_t)(pshader_filter_econst + 27)), -1, -1, -1, -1, -1, } }, + { { pshader_filter_10 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 2)), 2, static_cast((intptr_t)(pshader_filter_econst + 5)), static_cast((intptr_t)(pshader_filter_econst + 8)), -1, } }, + { { pshader_filter_11 }, { nullptr }, { 0, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 29)), 2, static_cast((intptr_t)(pshader_filter_econst + 32)), -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, + { { pshader_filter_16 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, + { { pshader_filter_17 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 47)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 51)), static_cast((intptr_t)(pshader_filter_econst + 35)), } }, + { { pshader_filter_18 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 37)), 2, static_cast((intptr_t)(pshader_filter_econst + 54)), static_cast((intptr_t)(pshader_filter_econst + 59)), -1, } }, + { { pshader_filter_19 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 62)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 66)), -1, } }, + { { pshader_filter_20 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, + { { pshader_filter_21 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 47)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 51)), static_cast((intptr_t)(pshader_filter_econst + 35)), } }, + { { pshader_filter_22 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 69)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 73)), -1, } }, + { { pshader_filter_23 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 62)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 66)), -1, } }, + { { pshader_filter_24 }, { nullptr }, { 0, 1, static_cast((intptr_t)(pshader_filter_econst + 35)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), static_cast((intptr_t)(pshader_filter_econst + 46)), static_cast((intptr_t)(pshader_filter_econst + 49)), } }, + { { pshader_filter_25 }, { nullptr }, { 0, -1, static_cast((intptr_t)(pshader_filter_econst + 76)), static_cast((intptr_t)(pshader_filter_econst + 37)), -1, static_cast((intptr_t)(pshader_filter_econst + 41)), -1, static_cast((intptr_t)(pshader_filter_econst + 67)), } }, + { { pshader_filter_26 }, { nullptr }, { 0, 1, -1, static_cast((intptr_t)(pshader_filter_econst + 78)), 2, static_cast((intptr_t)(pshader_filter_econst + 82)), static_cast((intptr_t)(pshader_filter_econst + 87)), -1, } }, + { { pshader_filter_27 }, { nullptr }, { 0, -1, -1, static_cast((intptr_t)(pshader_filter_econst + 37)), 2, static_cast((intptr_t)(pshader_filter_econst + 41)), -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, -1, -1, -1, -1, -1, } }, }; static unsigned char pshader_blur_2[368] = { @@ -1560,16 +1560,16 @@ static int pshader_blur_econst[256] = { }; static ProgramWithCachedVariableLocations pshader_blur_arr[10] = { - { { NULL }, { NULL }, { -1, -1, -1, } }, - { { NULL }, { NULL }, { -1, -1, -1, } }, - { { pshader_blur_2 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 0)), static_cast((intptr_t)(pshader_blur_econst + 13)), } }, - { { pshader_blur_3 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 18)), static_cast((intptr_t)(pshader_blur_econst + 33)), } }, - { { pshader_blur_4 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 40)), static_cast((intptr_t)(pshader_blur_econst + 57)), } }, - { { pshader_blur_5 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 66)), static_cast((intptr_t)(pshader_blur_econst + 85)), } }, - { { pshader_blur_6 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 96)), static_cast((intptr_t)(pshader_blur_econst + 117)), } }, - { { pshader_blur_7 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 130)), static_cast((intptr_t)(pshader_blur_econst + 153)), } }, - { { pshader_blur_8 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 168)), static_cast((intptr_t)(pshader_blur_econst + 193)), } }, - { { pshader_blur_9 }, { NULL }, { 0, static_cast((intptr_t)(pshader_blur_econst + 210)), static_cast((intptr_t)(pshader_blur_econst + 237)), } }, + { { nullptr }, { nullptr }, { -1, -1, -1, } }, + { { nullptr }, { nullptr }, { -1, -1, -1, } }, + { { pshader_blur_2 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_blur_econst + 0)), static_cast((intptr_t)(pshader_blur_econst + 13)), } }, + { { pshader_blur_3 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_blur_econst + 18)), static_cast((intptr_t)(pshader_blur_econst + 33)), } }, + { { pshader_blur_4 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_blur_econst + 40)), static_cast((intptr_t)(pshader_blur_econst + 57)), } }, + { { pshader_blur_5 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_blur_econst + 66)), static_cast((intptr_t)(pshader_blur_econst + 85)), } }, + { { pshader_blur_6 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_blur_econst + 96)), static_cast((intptr_t)(pshader_blur_econst + 117)), } }, + { { pshader_blur_7 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_blur_econst + 130)), static_cast((intptr_t)(pshader_blur_econst + 153)), } }, + { { pshader_blur_8 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_blur_econst + 168)), static_cast((intptr_t)(pshader_blur_econst + 193)), } }, + { { pshader_blur_9 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_blur_econst + 210)), static_cast((intptr_t)(pshader_blur_econst + 237)), } }, }; static unsigned char pshader_color_matrix_0[336] = { @@ -1598,7 +1598,7 @@ static int pshader_color_matrix_econst[12] = { }; static ProgramWithCachedVariableLocations pshader_color_matrix_arr[1] = { - { { pshader_color_matrix_0 }, { NULL }, { 0, static_cast((intptr_t)(pshader_color_matrix_econst + 0)), } }, + { { pshader_color_matrix_0 }, { nullptr }, { 0, static_cast((intptr_t)(pshader_color_matrix_econst + 0)), } }, }; static unsigned char vshader_vsps3_0[272] = { @@ -1655,8 +1655,8 @@ static unsigned char vshader_vsps3_2[240] = { }; static ProgramWithCachedVariableLocations vshader_vsps3_arr[3] = { - { { vshader_vsps3_0 }, { NULL }, { } }, - { { vshader_vsps3_1 }, { NULL }, { } }, - { { vshader_vsps3_2 }, { NULL }, { } }, + { { vshader_vsps3_0 }, { nullptr }, { } }, + { { vshader_vsps3_1 }, { nullptr }, { } }, + { { vshader_vsps3_2 }, { nullptr }, { } }, }; diff --git a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_shared.inl index 639b4c921..6f8dd9c02 100644 --- a/Minecraft.Client/PS3/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/PS3/Iggy/gdraw/gdraw_shared.inl @@ -226,7 +226,7 @@ static void debug_check_raw_values(GDrawHandleCache *c) s = s->next; } s = c->active; - while (s != NULL) { + while (s != nullptr) { assert(s->raw_ptr != t->raw_ptr); s = s->next; } @@ -433,7 +433,7 @@ static rrbool gdraw_HandleCacheLockStats(GDrawHandle *t, void *owner, GDrawStats static rrbool gdraw_HandleCacheLock(GDrawHandle *t, void *owner) { - return gdraw_HandleCacheLockStats(t, owner, NULL); + return gdraw_HandleCacheLockStats(t, owner, nullptr); } static void gdraw_HandleCacheUnlock(GDrawHandle *t) @@ -461,11 +461,11 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->is_thrashing = false; c->did_defragment = false; for (i=0; i < GDRAW_HANDLE_STATE__count; i++) { - c->state[i].owner = NULL; - c->state[i].cache = NULL; // should never follow cache link from sentinels! + c->state[i].owner = nullptr; + c->state[i].cache = nullptr; // should never follow cache link from sentinels! c->state[i].next = c->state[i].prev = &c->state[i]; #ifdef GDRAW_MANAGE_MEM - c->state[i].raw_ptr = NULL; + c->state[i].raw_ptr = nullptr; #endif c->state[i].fence.value = 0; c->state[i].bytes = 0; @@ -478,7 +478,7 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->handle[i].bytes = 0; c->handle[i].state = GDRAW_HANDLE_STATE_free; #ifdef GDRAW_MANAGE_MEM - c->handle[i].raw_ptr = NULL; + c->handle[i].raw_ptr = nullptr; #endif } c->state[GDRAW_HANDLE_STATE_free].next = &c->handle[0]; @@ -486,10 +486,10 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->prev_frame_start.value = 0; c->prev_frame_end.value = 0; #ifdef GDRAW_MANAGE_MEM - c->alloc = NULL; + c->alloc = nullptr; #endif #ifdef GDRAW_MANAGE_MEM_TWOPOOL - c->alloc_other = NULL; + c->alloc_other = nullptr; #endif check_lists(c); } @@ -497,14 +497,14 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte static GDrawHandle *gdraw_HandleCacheAllocateBegin(GDrawHandleCache *c) { GDrawHandle *free_list = &c->state[GDRAW_HANDLE_STATE_free]; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (free_list->next != free_list) { t = free_list->next; gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_alloc); t->bytes = 0; t->owner = 0; #ifdef GDRAW_MANAGE_MEM - t->raw_ptr = NULL; + t->raw_ptr = nullptr; #endif #ifdef GDRAW_CORRUPTION_CHECK t->has_check_value = false; @@ -563,7 +563,7 @@ static GDrawHandle *gdraw_HandleCacheGetLRU(GDrawHandleCache *c) // at the front of the LRU list are the oldest ones, since in-use resources // will get appended on every transition from "locked" to "live". GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_live]; - return (sentinel->next != sentinel) ? sentinel->next : NULL; + return (sentinel->next != sentinel) ? sentinel->next : nullptr; } static void gdraw_HandleCacheTick(GDrawHandleCache *c, GDrawFence now) @@ -1095,7 +1095,7 @@ static void make_pool_aligned(void **start, S32 *num_bytes, U32 alignment) if (addr_aligned != addr_orig) { S32 diff = (S32) (addr_aligned - addr_orig); if (*num_bytes < diff) { - *start = NULL; + *start = nullptr; *num_bytes = 0; return; } else { @@ -1132,7 +1132,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) UINTa remaining = arena->end - arena->current; UINTa total_size = (ptr - arena->current) + size; if (remaining < total_size) // doesn't fit - return NULL; + return nullptr; arena->current = ptr + size; return ptr; @@ -1157,7 +1157,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // (i.e. block->next->prev == block->prev->next == block) // - All allocated blocks are also kept in a hash table, indexed by their // pointer (to allow free to locate the corresponding block_info quickly). -// There's a single-linked, NULL-terminated list of elements in each hash +// There's a single-linked, nullptr-terminated list of elements in each hash // bucket. // - The physical block list is ordered. It always contains all currently // active blocks and spans the whole managed memory range. There are no @@ -1166,7 +1166,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // they are coalesced immediately. // - The maximum number of blocks that could ever be necessary is allocated // on initialization. All block_infos not currently in use are kept in a -// single-linked, NULL-terminated list of unused blocks. Every block is either +// single-linked, nullptr-terminated list of unused blocks. Every block is either // in the physical block list or the unused list, and the total number of // blocks is constant. // These invariants always hold before and after an allocation/free. @@ -1384,7 +1384,7 @@ static void gfxalloc_check2(gfx_allocator *alloc) static gfx_block_info *gfxalloc_pop_unused(gfx_allocator *alloc) { - GFXALLOC_ASSERT(alloc->unused_list != NULL); + GFXALLOC_ASSERT(alloc->unused_list != nullptr); GFXALLOC_ASSERT(alloc->unused_list->is_unused); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_unused);) @@ -1457,7 +1457,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma U32 i, max_blocks, size; if (!align || (align & (align - 1)) != 0) // align must be >0 and a power of 2 - return NULL; + return nullptr; // for <= max_allocs live allocs, there's <= 2*max_allocs+1 blocks. worst case: // [free][used][free] .... [free][used][free] @@ -1465,7 +1465,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma size = sizeof(gfx_allocator) + max_blocks * sizeof(gfx_block_info); a = (gfx_allocator *) IggyGDrawMalloc(size); if (!a) - return NULL; + return nullptr; memset(a, 0, size); @@ -1506,16 +1506,16 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma a->blocks[i].is_unused = 1; gfxalloc_check(a); - debug_complete_check(a, NULL, 0,0); + debug_complete_check(a, nullptr, 0,0); return a; } static void *gfxalloc_alloc(gfx_allocator *alloc, U32 size_in_bytes) { - gfx_block_info *cur, *best = NULL; + gfx_block_info *cur, *best = nullptr; U32 i, best_wasted = ~0u; U32 size = size_in_bytes; -debug_complete_check(alloc, NULL, 0,0); +debug_complete_check(alloc, nullptr, 0,0); gfxalloc_check(alloc); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) @@ -1565,7 +1565,7 @@ gfxalloc_check(alloc); debug_check_overlap(alloc->cache, best->ptr, best->size); return best->ptr; } else - return NULL; // not enough space! + return nullptr; // not enough space! } static void gfxalloc_free(gfx_allocator *alloc, void *ptr) @@ -1735,7 +1735,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta // (unused for allocated blocks, we'll use it to store a back-pointer to the corresponding handle) for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys) if (!b->is_free) - b->prev = NULL; + b->prev = nullptr; // go through all handles and store a pointer to the handle in the corresponding memory block for (i=0; i < c->max_handles; i++) @@ -1748,7 +1748,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta break; } - GFXALLOC_ASSERT(b != NULL); // didn't find this block anywhere! + GFXALLOC_ASSERT(b != nullptr); // didn't find this block anywhere! } // clear alloc hash table (we rebuild it during defrag) @@ -1910,7 +1910,7 @@ static rrbool gdraw_CanDefragment(GDrawHandleCache *c) static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats) { GDrawHandleCache *c = t->cache; - void *ptr = NULL; + void *ptr = nullptr; assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); // anything we migrate should be in the "other" (old) pool @@ -2300,7 +2300,7 @@ static void gdraw_bufring_init(gdraw_bufring * RADRESTRICT ring, void *ptr, U32 static void gdraw_bufring_shutdown(gdraw_bufring * RADRESTRICT ring) { - ring->cur = NULL; + ring->cur = nullptr; ring->seg_size = 0; } @@ -2310,7 +2310,7 @@ static void *gdraw_bufring_alloc(gdraw_bufring * RADRESTRICT ring, U32 size, U32 gdraw_bufring_seg *seg; if (size > ring->seg_size) - return NULL; // nope, won't fit + return nullptr; // nope, won't fit assert(align <= ring->align); @@ -2415,7 +2415,7 @@ static rrbool gdraw_res_free_lru(GDrawHandleCache *c, GDrawStats *stats) // was it referenced since end of previous frame (=in this frame)? // if some, we're thrashing; report it to the user, but only once per frame. if (c->prev_frame_end.value < r->fence.value && !c->is_thrashing) { - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); c->is_thrashing = true; } @@ -2435,8 +2435,8 @@ static GDrawHandle *gdraw_res_alloc_outofmem(GDrawHandleCache *c, GDrawHandle *t { if (t) gdraw_HandleCacheAllocateFail(t); - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); - return NULL; + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); + return nullptr; } #ifndef GDRAW_MANAGE_MEM @@ -2445,7 +2445,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt { GDrawHandle *t; if (size > c->total_bytes) - gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); else { // given how much data we're going to allocate, throw out // data until there's "room" (this basically lets us use @@ -2453,7 +2453,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // packing it and being exact) while (c->bytes_free < size) { if (!gdraw_res_free_lru(c, stats)) { - gdraw_res_alloc_outofmem(c, NULL, "memory"); + gdraw_res_alloc_outofmem(c, nullptr, "memory"); break; } } @@ -2468,8 +2468,8 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // we'd trade off cost of regenerating) if (gdraw_res_free_lru(c, stats)) { t = gdraw_HandleCacheAllocateBegin(c); - if (t == NULL) { - gdraw_res_alloc_outofmem(c, NULL, "handles"); + if (t == nullptr) { + gdraw_res_alloc_outofmem(c, nullptr, "handles"); } } } @@ -2513,7 +2513,7 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) { GDRAW_FENCE_FLUSH(); // dead list is sorted by fence index - make sure all fence values are current. - r->owner = NULL; + r->owner = nullptr; gdraw_HandleCacheInsertDead(r); gdraw_res_reap(r->cache, stats); } @@ -2521,11 +2521,11 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats) { GDrawHandle *t; - void *ptr = NULL; + void *ptr = nullptr; gdraw_res_reap(c, stats); // NB this also does GDRAW_FENCE_FLUSH(); if (size > c->total_bytes) - return gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + return gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); // now try to allocate a handle t = gdraw_HandleCacheAllocateBegin(c); @@ -2537,7 +2537,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt gdraw_res_free_lru(c, stats); t = gdraw_HandleCacheAllocateBegin(c); if (!t) - return gdraw_res_alloc_outofmem(c, NULL, "handles"); + return gdraw_res_alloc_outofmem(c, nullptr, "handles"); } // try to allocate first diff --git a/Minecraft.Client/PS3/Iggy/include/gdraw.h b/Minecraft.Client/PS3/Iggy/include/gdraw.h index 404a2642b..7cc4ddd0e 100644 --- a/Minecraft.Client/PS3/Iggy/include/gdraw.h +++ b/Minecraft.Client/PS3/Iggy/include/gdraw.h @@ -356,13 +356,13 @@ IDOC typedef struct GDrawPrimitive IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats); /* Draws a collection of indexed triangles, ignoring special filters or blend modes. - If buf is NULL, then the pointers in 'prim' are machine pointers, and + If buf is nullptr, then the pointers in 'prim' are machine pointers, and you need to make a copy of the data (note currently all triangles implementing strokes (wide lines) go this path). - If buf is non-NULL, then use the appropriate vertex buffer, and the + If buf is non-nullptr, then use the appropriate vertex buffer, and the pointers in prim are actually offsets from the beginning of the - vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL; + vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) nullptr; (note there are separate spaces for vertices and indices; e.g. the first mesh in a given vertex buffer will normally have a 0 offset for the vertices and a 0 offset for the indices) @@ -455,7 +455,7 @@ IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_Pro /* Ends specification of a new texture. $:info The same handle initially passed to $gdraw_make_texture_begin - $:return Handle for the newly created texture, or NULL if an error occured + $:return Handle for the newly created texture, or nullptr if an error occured */ IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats); diff --git a/Minecraft.Client/PS3/Iggy/include/iggyexpruntime.h b/Minecraft.Client/PS3/Iggy/include/iggyexpruntime.h index 1f1a90a1c..a42ccbfff 100644 --- a/Minecraft.Client/PS3/Iggy/include/iggyexpruntime.h +++ b/Minecraft.Client/PS3/Iggy/include/iggyexpruntime.h @@ -25,8 +25,8 @@ IDOC RADEXPFUNC HIGGYEXP RADEXPLINK IggyExpCreate(char *ip_address, S32 port, vo $:storage A small block of storage that needed to store the $HIGGYEXP, must be at least $IGGYEXP_MIN_STORAGE $:storage_size_in_bytes The size of the block pointer to by storage -Returns a NULL HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer -can be contacted at the specified address/port. Otherwise returns a non-NULL $HIGGYEXP +Returns a nullptr HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer +can be contacted at the specified address/port. Otherwise returns a non-nullptr $HIGGYEXP which you can pass to $IggyUseExplorer. */ IDOC RADEXPFUNC void RADEXPLINK IggyExpDestroy(HIGGYEXP p); diff --git a/Minecraft.Client/PS3/Leaderboards/PS3LeaderboardManager.cpp b/Minecraft.Client/PS3/Leaderboards/PS3LeaderboardManager.cpp index 38380bfb4..274061866 100644 --- a/Minecraft.Client/PS3/Leaderboards/PS3LeaderboardManager.cpp +++ b/Minecraft.Client/PS3/Leaderboards/PS3LeaderboardManager.cpp @@ -30,7 +30,7 @@ PS3LeaderboardManager::PS3LeaderboardManager() m_myXUID = INVALID_XUID; - m_scores = NULL; //m_stats = NULL; + m_scores = nullptr; //m_stats = nullptr; m_statsType = eStatsType_Kills; m_difficulty = 0; @@ -42,7 +42,7 @@ PS3LeaderboardManager::PS3LeaderboardManager() InitializeCriticalSection(&m_csViewsLock); m_running = false; - m_threadScoreboard = NULL; + m_threadScoreboard = nullptr; } PS3LeaderboardManager::~PS3LeaderboardManager() @@ -196,7 +196,7 @@ bool PS3LeaderboardManager::getScoreByIds() CellRtcTick last_sort_date; SceNpScoreRankNumber mTotalRecord; - SceNpId *npIds = NULL; + SceNpId *npIds = nullptr; int ret; @@ -246,7 +246,7 @@ bool PS3LeaderboardManager::getScoreByIds() sceNpScoreDestroyTransactionCtx(ret); - if (npIds != NULL) delete [] npIds; + if (npIds != nullptr) delete [] npIds; return false; } else if (ret < 0) @@ -256,7 +256,7 @@ bool PS3LeaderboardManager::getScoreByIds() m_eStatsState = eStatsState_Failed; - if (npIds != NULL) delete [] npIds; + if (npIds != nullptr) delete [] npIds; return false; } else @@ -270,7 +270,7 @@ bool PS3LeaderboardManager::getScoreByIds() comments = new SceNpScoreComment[num]; /* app.DebugPrintf("sceNpScoreGetRankingByNpId(\n\t transaction=%i,\n\t boardID=0,\n\t npId=%i,\n\t friendCount*sizeof(SceNpId)=%i*%i=%i,\ - rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t NULL, 0, NULL, 0,\n\t friendCount=%i,\n...\n", + rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t nullptr, 0, nullptr, 0,\n\t friendCount=%i,\n...\n", transaction, npId, friendCount, sizeof(SceNpId), friendCount*sizeof(SceNpId), rankData, friendCount*sizeof(SceNpScorePlayerRankData), friendCount ); */ @@ -285,14 +285,14 @@ bool PS3LeaderboardManager::getScoreByIds() comments, sizeof(SceNpScoreComment) * num, //OUT: Comments - NULL, 0, // GameData. (unused) + nullptr, 0, // GameData. (unused) num, &last_sort_date, &mTotalRecord, - NULL // Reserved, specify null. + nullptr // Reserved, specify null. ); if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) @@ -319,7 +319,7 @@ bool PS3LeaderboardManager::getScoreByIds() delete [] comments; delete [] npIds; - m_scores = NULL; + m_scores = nullptr; m_readCount = 0; m_maxRank = num; @@ -335,7 +335,7 @@ bool PS3LeaderboardManager::getScoreByIds() m_readCount = num; // Filter scorers and construct output structure. - if (m_scores != NULL) delete [] m_scores; + if (m_scores != nullptr) delete [] m_scores; m_scores = new ReadScore[m_readCount]; convertToOutput(m_readCount, m_scores, ptr, comments); m_maxRank = m_readCount; @@ -368,7 +368,7 @@ bool PS3LeaderboardManager::getScoreByIds() delete [] ptr; delete [] comments; error2: - if (npIds != NULL) delete [] npIds; + if (npIds != nullptr) delete [] npIds; error1: if (m_eStatsState != eStatsState_Canceled) m_eStatsState = eStatsState_Failed; app.DebugPrintf("[LeaderboardManger] getScoreByIds() FAILED, ret=0x%X\n", ret); @@ -422,14 +422,14 @@ bool PS3LeaderboardManager::getScoreByRange() comments, sizeof(SceNpScoreComment) * num, //OUT: Comment Data - NULL, 0, // GameData. + nullptr, 0, // GameData. num, &last_sort_date, &m_maxRank, // 'Total number of players registered in the target scoreboard.' - NULL // Reserved, specify null. + nullptr // Reserved, specify null. ); if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) @@ -454,7 +454,7 @@ bool PS3LeaderboardManager::getScoreByRange() delete [] ptr; delete [] comments; - m_scores = NULL; + m_scores = nullptr; m_readCount = 0; m_eStatsState = eStatsState_Ready; @@ -472,7 +472,7 @@ bool PS3LeaderboardManager::getScoreByRange() //m_stats = ptr; //Maybe: addPadding(num,ptr); - if (m_scores != NULL) delete [] m_scores; + if (m_scores != nullptr) delete [] m_scores; m_readCount = ret; m_scores = new ReadScore[m_readCount]; for (int i=0; i 0) ret = eStatsReturn_Success; - if (m_readListener != NULL) + if (m_readListener != nullptr) { app.DebugPrintf("[LeaderboardManager] OnStatsReadComplete(%i, %i, _), m_readCount=%i.\n", ret, m_maxRank, m_readCount); m_readListener->OnStatsReadComplete(ret, m_maxRank, view); @@ -621,16 +621,16 @@ void PS3LeaderboardManager::Tick() m_eStatsState = eStatsState_Idle; delete [] m_scores; - m_scores = NULL; + m_scores = nullptr; } break; case eStatsState_Failed: { view.m_numQueries = 0; - view.m_queries = NULL; + view.m_queries = nullptr; - if ( m_readListener != NULL ) + if ( m_readListener != nullptr ) m_readListener->OnStatsReadComplete(eStatsReturn_NetworkError, 0, view); m_eStatsState = eStatsState_Idle; @@ -652,7 +652,7 @@ bool PS3LeaderboardManager::OpenSession() { if (m_openSessions == 0) { - if (m_threadScoreboard == NULL) + if (m_threadScoreboard == nullptr) { m_threadScoreboard = new C4JThread(&scoreboardThreadEntry, this, "4JScoreboard"); m_threadScoreboard->SetProcessor(CPU_CORE_LEADERBOARDS); @@ -747,7 +747,7 @@ void PS3LeaderboardManager::FlushStats() {} void PS3LeaderboardManager::CancelOperation() { - m_readListener = NULL; + m_readListener = nullptr; m_eStatsState = eStatsState_Canceled; if (m_transactionCtx != 0) @@ -897,7 +897,7 @@ void PS3LeaderboardManager::fromBase32(void *out, SceNpScoreComment *in) for (int i = 0; i < SCE_NP_SCORE_COMMENT_MAXLEN; i++) { ch[0] = in->data[i]; - unsigned char fivebits = strtol(ch, NULL, 32) << 3; + unsigned char fivebits = strtol(ch, nullptr, 32) << 3; int sByte = (i*5) / 8; int eByte = (5+(i*5)) / 8; @@ -958,7 +958,7 @@ bool PS3LeaderboardManager::test_string(string testing) int ctx = sceNpScoreCreateTransactionCtx(m_titleContext); if (ctx<0) return false; - int ret = sceNpScoreCensorComment(ctx, (const void *) &comment, NULL); + int ret = sceNpScoreCensorComment(ctx, (const void *) &comment, nullptr); if (ret == SCE_NP_COMMUNITY_SERVER_ERROR_CENSORED) { diff --git a/Minecraft.Client/PS3/Miles/include/mss.h b/Minecraft.Client/PS3/Miles/include/mss.h index 531dcbc92..a9fd231a9 100644 --- a/Minecraft.Client/PS3/Miles/include/mss.h +++ b/Minecraft.Client/PS3/Miles/include/mss.h @@ -584,7 +584,7 @@ typedef enum } MSS_SPEAKER; // -// Pass to AIL_midiOutOpen for NULL MIDI driver +// Pass to AIL_midiOutOpen for nullptr MIDI driver // #define MIDI_NULL_DRIVER ((U32)(S32)-2) @@ -833,7 +833,7 @@ the enumeration function until it returns 0. #define DEFAULT_DPWOD ((UINTa)-1) // Preferred WaveOut device == WAVE_MAPPER #define DIG_PREFERRED_DS_DEVICE 20 -#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default NULL GUID +#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default nullptr GUID #define MDI_SEQUENCES 21 @@ -1305,7 +1305,7 @@ typedef ASIRESULT (AILCALL *ASI_STARTUP)(void); typedef ASIRESULT (AILCALL * ASI_SHUTDOWN)(void); // -// Return codec error message, or NULL if no errors have occurred since +// Return codec error message, or nullptr if no errors have occurred since // last call // // The ASI error text state is global to all streams @@ -1878,7 +1878,7 @@ typedef struct _S3DSTATE // Portion of HSAMPLE that deals with 3D posi F32 spread; - HSAMPLE owner; // May be NULL if used for temporary/internal calculations + HSAMPLE owner; // May be nullptr if used for temporary/internal calculations AILFALLOFFCB falloff_function; // User function for min/max distance calculations, if desired MSSVECTOR3D position_graph[MILES_MAX_SEGMENT_COUNT]; @@ -2460,7 +2460,7 @@ typedef struct _DIG_DRIVER // Handle to digital audio driver S32 DS_initialized; - AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or NULL if none) + AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or nullptr if none) AILLPDIRECTSOUNDBUFFER DS_out_buff; // Output buffer (may be sec or prim) S32 DS_buffer_size; // Size of entire output buffer @@ -4866,10 +4866,10 @@ typedef struct U8 *MP3_file_image; // Original MP3_file_image pointer passed to AIL_inspect_MP3() S32 MP3_image_size; // Original MP3_image_size passed to AIL_inspect_MP3() - U8 *ID3v2; // ID3v2 tag, if not NULL + U8 *ID3v2; // ID3v2 tag, if not nullptr S32 ID3v2_size; // Size of tag in bytes - U8 *ID3v1; // ID3v1 tag, if not NULL (always 128 bytes long if present) + U8 *ID3v1; // ID3v1 tag, if not nullptr (always 128 bytes long if present) U8 *start_MP3_data; // Pointer to start of data area in file (not necessarily first valid frame) U8 *end_MP3_data; // Pointer to last valid byte in MP3 data area (before ID3v1 tag, if any) diff --git a/Minecraft.Client/PS3/Network/SQRNetworkManager_PS3.cpp b/Minecraft.Client/PS3/Network/SQRNetworkManager_PS3.cpp index 8ab30bebd..a1a57443d 100644 --- a/Minecraft.Client/PS3/Network/SQRNetworkManager_PS3.cpp +++ b/Minecraft.Client/PS3/Network/SQRNetworkManager_PS3.cpp @@ -19,8 +19,8 @@ #include "..\PS3Extras\PS3Strings.h" #include "PS3\Network\SonyRemoteStorage_PS3.h" -int (* SQRNetworkManager_PS3::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = NULL; -void * SQRNetworkManager_PS3::s_SignInCompleteParam = NULL; +int (* SQRNetworkManager_PS3::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = nullptr; +void * SQRNetworkManager_PS3::s_SignInCompleteParam = nullptr; SceNpBasicPresenceDetails2 SQRNetworkManager_PS3::s_lastPresenceInfo = { 0 }; int SQRNetworkManager_PS3::s_resendPresenceCountdown = 0; bool SQRNetworkManager_PS3::s_presenceStatusDirty = false; @@ -96,8 +96,8 @@ SQRNetworkManager_PS3::SQRNetworkManager_PS3(ISQRNetworkManagerListener *listene m_isInSession = false; m_offlineGame = false; m_offlineSQR = false; - m_aServerId = NULL; - m_gameBootInvite = NULL; + m_aServerId = nullptr; + m_gameBootInvite = nullptr; m_onlineStatus = false; m_bLinkDisconnected = false; @@ -151,7 +151,7 @@ void SQRNetworkManager_PS3::Initialise() // Initialise RUDP #ifdef __PS3__ - ret = cellRudpInit(NULL); + ret = cellRudpInit(nullptr); #else const int RUDP_POOL_SIZE = (500 * 1024); // TODO - find out what we need, this size is copied from library reference uint8_t *rudp_pool = (uint8_t *)malloc(RUDP_POOL_SIZE); @@ -258,7 +258,7 @@ void SQRNetworkManager_PS3::InitialiseAfterOnline() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } return; } @@ -268,7 +268,7 @@ void SQRNetworkManager_PS3::InitialiseAfterOnline() int ret = 0; if( !m_matching2initialised) { - ret = sceNpMatching2Init2(0, 0, NULL); + ret = sceNpMatching2Init2(0, 0, nullptr); } #else SceNpMatching2InitializeParameter initParam; @@ -339,7 +339,7 @@ void SQRNetworkManager_PS3::Tick() if( ( m_gameBootInvite ) && ( s_safeToRespondToGameBootInvite ) ) { m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), m_gameBootInvite ); - m_gameBootInvite = NULL; + m_gameBootInvite = nullptr; } ErrorHandlingTick(); @@ -399,12 +399,12 @@ void SQRNetworkManager_PS3::Tick() if( s_signInCompleteCallbackIfFailed ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } else if(s_SignInCompleteCallbackFn) { s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -421,7 +421,7 @@ void SQRNetworkManager_PS3::ErrorHandlingTick() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } app.DebugPrintf("Network error: SNM_INT_STATE_INITIALISE_FAILED\n"); if( m_isInSession && m_offlineGame) // m_offlineSQR ) // MGH - changed this to m_offlineGame, as m_offlineSQR can be true when running an online game but the init has failed because the servers are down @@ -531,7 +531,7 @@ void SQRNetworkManager_PS3::UpdateExternalRoomData() reqParam.roomBinAttrExternalNum = 1; reqParam.roomBinAttrExternal = &roomBinAttr; - int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, nullptr, &m_setRoomDataRequestId ); app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2SetRoomDataExternal returns 0x%x, number of players %d\n",ret,((char *)m_joinExtData)[174]); if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_SET_EXTERNAL_ROOM_DATA ) ) { @@ -564,7 +564,7 @@ bool SQRNetworkManager_PS3::FriendRoomManagerSearch() for( int i = 0; i < m_searchResultCount; i++ ) { free(m_aSearchResultRoomExtDataReceived[i]); - m_aSearchResultRoomExtDataReceived[i] = NULL; + m_aSearchResultRoomExtDataReceived[i] = nullptr; } m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_COUNT; @@ -639,7 +639,7 @@ void SQRNetworkManager_PS3::FriendSearchTick() { m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO; delete m_getFriendCountThread; - m_getFriendCountThread = NULL; + m_getFriendCountThread = nullptr; FriendRoomManagerSearch2(); } } @@ -813,7 +813,7 @@ SQRNetworkPlayer *SQRNetworkManager_PS3::GetPlayerByIndex(int idx) } else { - return NULL; + return nullptr; } } @@ -830,7 +830,7 @@ SQRNetworkPlayer *SQRNetworkManager_PS3::GetPlayerBySmallId(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_PS3::GetPlayerByXuid(PlayerUID xuid) @@ -846,7 +846,7 @@ SQRNetworkPlayer *SQRNetworkManager_PS3::GetPlayerByXuid(PlayerUID xuid) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_PS3::GetLocalPlayerByUserIndex(int idx) @@ -862,7 +862,7 @@ SQRNetworkPlayer *SQRNetworkManager_PS3::GetLocalPlayerByUserIndex(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_PS3::GetHostPlayer() @@ -875,11 +875,11 @@ SQRNetworkPlayer *SQRNetworkManager_PS3::GetHostPlayer() SQRNetworkPlayer *SQRNetworkManager_PS3::GetPlayerIfReady(SQRNetworkPlayer *player) { - if( player == NULL ) return NULL; + if( player == nullptr ) return nullptr; if( player->IsReady() ) return player; - return NULL; + return nullptr; } // Update state internally @@ -930,7 +930,7 @@ bool SQRNetworkManager_PS3::JoinRoom(SQRNetworkManager_PS3::SessionSearchResult { // Set up the presence info we would like to synchronise out when we have fully joined the game CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData(&s_lastPresenceSyncInfo, searchResult->m_extData, searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId); - return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, NULL); + return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, nullptr); } // Join room with a specified roomId. This is used when joining from an invite, as well as by the previous method @@ -996,7 +996,7 @@ void SQRNetworkManager_PS3::LeaveRoom(bool bActuallyLeaveRoom) reqParam.roomId = m_room; SetState(SNM_INT_STATE_LEAVING); - int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, NULL, &m_leaveRoomRequestId ); + int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, nullptr, &m_leaveRoomRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_LEAVE_ROOM) ) { SetState(SNM_INT_STATE_LEAVING_FAILED); @@ -1100,7 +1100,7 @@ bool SQRNetworkManager_PS3::AddLocalPlayerByUserIndex(int idx) reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_setRoomMemberInternalDataRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL) ) { @@ -1148,7 +1148,7 @@ bool SQRNetworkManager_PS3::RemoveLocalPlayerByUserIndex(int idx) // And do any adjusting necessary to the mappings from this room data, to the SQRNetworkPlayers. // This will also delete the SQRNetworkPlayer and do all the callbacks that requires etc. MapRoomSlotPlayers(roomSlotPlayerCount); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; // Sync this back out to our networked clients... SyncRoomData(); @@ -1184,7 +1184,7 @@ bool SQRNetworkManager_PS3::RemoveLocalPlayerByUserIndex(int idx) reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_setRoomMemberInternalDataRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL2) ) { @@ -1216,7 +1216,7 @@ void SQRNetworkManager_PS3::SendInviteGUI() msg.mainType = SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE; msg.subType = SCE_NP_BASIC_MESSAGE_INVITE_SUBTYPE_ACTION_ACCEPT; msg.msgFeatures = SCE_NP_BASIC_MESSAGE_FEATURES_BOOTABLE; - msg.npids = NULL; + msg.npids = nullptr; msg.count = 0; uint8_t *subject = mallocAndCreateUTF8ArrayFromString(IDS_INVITATION_SUBJECT_MAX_18_CHARS); @@ -1284,7 +1284,7 @@ void SQRNetworkManager_PS3::FindOrCreateNonNetworkPlayer(int slot, int playerTyp } } // Create the player - non-network players can be considered complete as soon as we create them as we aren't waiting on their network connections becoming complete, so can flag them as such and notify via callback - PlayerUID *pUID = NULL; + PlayerUID *pUID = nullptr; PlayerUID localUID; if( ( playerType == SQRNetworkPlayer::SNP_TYPE_LOCAL ) || m_isHosting && ( playerType == SQRNetworkPlayer::SNP_TYPE_HOST ) ) @@ -1351,7 +1351,7 @@ void SQRNetworkManager_PS3::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_REMOTE ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1407,7 +1407,7 @@ void SQRNetworkManager_PS3::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_LOCAL ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1499,7 +1499,7 @@ void SQRNetworkManager_PS3::UpdatePlayersFromRoomSyncUIDs() } // Host only - add remote players to our internal storage of player slots, and synchronise this with other room members. -bool SQRNetworkManager_PS3::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==NULL*/ ) +bool SQRNetworkManager_PS3::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==nullptr*/ ) { assert( m_isHosting ); @@ -1618,7 +1618,7 @@ void SQRNetworkManager_PS3::RemoveRemotePlayersAndSync( SceNpMatching2RoomMember } // Zero last element, that isn't part of the currently sized array anymore memset(&m_roomSyncData.players[m_roomSyncData.getPlayerCount()],0,sizeof(PlayerSyncData)); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; } else { @@ -1660,7 +1660,7 @@ void SQRNetworkManager_PS3::RemoveNetworkPlayers( int mask ) { if( m_aRoomSlotPlayers[i] == player ) { - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } // And delete the reference from the ctx->player map @@ -1711,7 +1711,7 @@ void SQRNetworkManager_PS3::SyncRoomData() roomBinAttr.size = sizeof( m_roomSyncData ); reqParam.roomBinAttrInternalNum = 1; reqParam.roomBinAttrInternal = &roomBinAttr; - sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, nullptr, &m_setRoomDataRequestId ); } // Check if the matching context is valid, and if not attempt to create one. If to do this requires starting an asynchronous process, then sets the internal state to the state passed in @@ -1724,7 +1724,7 @@ bool SQRNetworkManager_PS3::GetMatchingContext(eSQRNetworkManagerInternalState a int ret = 0; if( !m_matching2initialised) { - ret = sceNpMatching2Init2(0, 0, NULL); + ret = sceNpMatching2Init2(0, 0, nullptr); } if( ret < 0 ) { @@ -1797,7 +1797,7 @@ bool SQRNetworkManager_PS3::GetServerContext() bool SQRNetworkManager_PS3::GetServerContext2() { // Get list of server IDs of servers allocated to the application - int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, NULL, 0 ); + int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, nullptr, 0 ); // If an error is returned here, we need to destroy and recerate our server - if this goes ok we should come back through this path again if( ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_UNAVAILABLE ) || // This error has been seen (occasionally) in a normal working environment ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED ) ) // Also checking for this as a means of simulating the previous error @@ -1852,7 +1852,7 @@ bool SQRNetworkManager_PS3::GetServerContext(SceNpMatching2ServerId serverId) { // Get list of server IDs of servers allocated to the application. We don't actually need to do this, but it is as good a way as any to try a matching2 service and check that // the context *really* is valid. - int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, NULL, 0 ); + int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, nullptr, 0 ); // If an error is returned here, we need to destroy and recerate our server - if this goes ok we should come back through this path again if( ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_UNAVAILABLE ) || // This error has been seen (occasionally) in a normal working environment ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED ) ) // Also checking for this as a means of simulating the previous error @@ -1906,7 +1906,7 @@ void SQRNetworkManager_PS3::ServerContextTick() reqParam.serverId = m_serverId; SetState((m_state==SNM_INT_STATE_HOSTING_SERVER_FOUND)?SNM_INT_STATE_HOSTING_SERVER_SEARCH_CREATING_CONTEXT:SNM_INT_STATE_JOINING_SERVER_SEARCH_CREATING_CONTEXT); // Found a server - now try and create a context for it - int ret = sceNpMatching2CreateServerContext( m_matchingContext, &reqParam, NULL, &m_serverContextRequestId ); + int ret = sceNpMatching2CreateServerContext( m_matchingContext, &reqParam, nullptr, &m_serverContextRequestId ); if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_SERVER_CONTEXT) ) { SetState((m_state==SNM_INT_STATE_HOSTING_SERVER_FOUND)?SNM_INT_STATE_HOSTING_SERVER_SEARCH_FAILED:SNM_INT_STATE_JOINING_SERVER_SEARCH_FAILED); @@ -1958,7 +1958,7 @@ void SQRNetworkManager_PS3::RoomCreateTick() SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM); app.DebugPrintf(CMinecraftApp::USER_RR,">> Creating room start\n"); s_roomStartTime = System::currentTimeMillis(); - int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, NULL, &m_createRoomRequestId ); + int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, nullptr, &m_createRoomRequestId ); if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_JOIN_ROOM) ) { SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED); @@ -2105,7 +2105,7 @@ bool SQRNetworkManager_PS3::SelectRandomServer() // Kick off the search - we'll get a callback to DefaultRequestCallback with the result from this app.DebugPrintf(CMinecraftApp::USER_RR,"Kicking off sceNpMatching2GetServerInfo for server id %d\n",reqParam.serverId); - int ret = sceNpMatching2GetServerInfo( m_matchingContext, &reqParam, NULL, &m_serverSearchRequestId); + int ret = sceNpMatching2GetServerInfo( m_matchingContext, &reqParam, nullptr, &m_serverSearchRequestId); if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_GET_SERVER_INFO) ) { // Jump straight to an error state for this server @@ -2125,7 +2125,7 @@ void SQRNetworkManager_PS3::DeleteServerContext() reqParam.serverId = m_serverId; m_serverContextValid = false; SetState(SNM_INT_STATE_SERVER_DELETING_CONTEXT); - int ret = sceNpMatching2DeleteServerContext( m_matchingContext, &reqParam, NULL, &m_serverContextRequestId ); + int ret = sceNpMatching2DeleteServerContext( m_matchingContext, &reqParam, nullptr, &m_serverContextRequestId ); if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_DELETE_SERVER_CONTEXT) ) { ResetToIdle(); @@ -2203,7 +2203,7 @@ bool SQRNetworkManager_PS3::CreateRudpConnections(SceNpMatching2RoomId roomId, S if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT) ) return false; if( m_isHosting ) { - m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, NULL ); + m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, nullptr ); } else { @@ -2237,7 +2237,7 @@ SQRNetworkPlayer *SQRNetworkManager_PS3::GetPlayerFromRudpCtx(int rudpCtx) { return it->second; } - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_PS3::GetPlayerFromRoomMemberAndLocalIdx(int roomMember, int localIdx) @@ -2249,7 +2249,7 @@ SQRNetworkPlayer *SQRNetworkManager_PS3::GetPlayerFromRoomMemberAndLocalIdx(int return it->second; } } - return NULL; + return nullptr; } @@ -2342,7 +2342,7 @@ void SQRNetworkManager_PS3::ContextCallback(SceNpMatching2ContextId id, SceNpMa { manager->SetState( SNM_INT_STATE_IDLE ); - manager->GetExtDataForRoom(0, NULL, NULL, NULL); + manager->GetExtDataForRoom(0, nullptr, nullptr, nullptr); break; } @@ -2373,7 +2373,7 @@ void SQRNetworkManager_PS3::ContextCallback(SceNpMatching2ContextId id, SceNpMa // if(s_SignInCompleteCallbackFn) // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); -// s_SignInCompleteCallbackFn = NULL; +// s_SignInCompleteCallbackFn = nullptr; // } @@ -2510,7 +2510,7 @@ void SQRNetworkManager_PS3::DefaultRequestCallback(SceNpMatching2ContextId id, S } } - // If there was some problem getting data, then silently ignore as we don't want to go any further with a NULL data pointer, and this will just be indicating that the networking context + // If there was some problem getting data, then silently ignore as we don't want to go any further with a nullptr data pointer, and this will just be indicating that the networking context // is invalid which will be picked up elsewhere to shut everything down properly if( dataError ) { @@ -2706,7 +2706,7 @@ void SQRNetworkManager_PS3::DefaultRequestCallback(SceNpMatching2ContextId id, S // Set flag to indicate whether we were kicked for being out of room or not reqParam.optData.data[0] = isFull ? 1 : 0; reqParam.optData.len = 1; - int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, NULL, &manager->m_kickRequestId); + int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, nullptr, &manager->m_kickRequestId); app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2KickoutRoomMember returns error 0x%x\n",ret); break; } @@ -2814,7 +2814,7 @@ void SQRNetworkManager_PS3::RoomEventCallback(SceNpMatching2ContextId id, SceNpM case SCE_NP_MATCHING2_ROOM_EVENT_RoomDestroyed: { SonyVoiceChat::signalRoomDestroyed(); - SceNpMatching2RoomUpdateInfo *pUpdateInfo=NULL; + SceNpMatching2RoomUpdateInfo *pUpdateInfo=nullptr; if( dataSize <= SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomUpdateInfo ) { @@ -2937,7 +2937,7 @@ void SQRNetworkManager_PS3::RoomEventCallback(SceNpMatching2ContextId id, SceNpM reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, NULL, &manager->m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, nullptr, &manager->m_setRoomMemberInternalDataRequestId ); } } @@ -3037,7 +3037,7 @@ void SQRNetworkManager_PS3::SignallingCallback(SceNpMatching2ContextId ctxId, Sc reqParam.attrId = attrs; reqParam.attrIdNum = 1; - sceNpMatching2GetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, NULL, &manager->m_roomMemberDataRequestId); + sceNpMatching2GetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, nullptr, &manager->m_roomMemberDataRequestId); } else { @@ -3118,7 +3118,7 @@ void SQRNetworkManager_PS3::SysUtilCallback(uint64_t status, uint64_t param, voi { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } return; } @@ -3133,7 +3133,7 @@ void SQRNetworkManager_PS3::SysUtilCallback(uint64_t status, uint64_t param, voi { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } @@ -3204,7 +3204,7 @@ void SQRNetworkManager_PS3::RudpContextCallback(int ctx_id, int event_id, int er if( dataSize >= sizeof(SQRNetworkPlayer::InitSendData) ) { SQRNetworkPlayer::InitSendData ISD; - unsigned int bytesRead = cellRudpRead( ctx_id, &ISD, sizeof(SQRNetworkPlayer::InitSendData), 0, NULL ); + unsigned int bytesRead = cellRudpRead( ctx_id, &ISD, sizeof(SQRNetworkPlayer::InitSendData), 0, nullptr ); if( bytesRead == sizeof(SQRNetworkPlayer::InitSendData) ) { manager->NetworkPlayerInitialDataReceived(playerFrom, &ISD); @@ -3225,7 +3225,7 @@ void SQRNetworkManager_PS3::RudpContextCallback(int ctx_id, int event_id, int er if( dataSize > 0 ) { unsigned char *data = new unsigned char [ dataSize ]; - unsigned int bytesRead = cellRudpRead( ctx_id, data, dataSize, 0, NULL ); + unsigned int bytesRead = cellRudpRead( ctx_id, data, dataSize, 0, nullptr ); if( bytesRead > 0 ) { SQRNetworkPlayer *playerFrom, *playerTo; @@ -3241,7 +3241,7 @@ void SQRNetworkManager_PS3::RudpContextCallback(int ctx_id, int event_id, int er playerFrom = manager->m_aRoomSlotPlayers[0]; playerTo = manager->GetPlayerFromRudpCtx( ctx_id ); } - if( ( playerFrom != NULL ) && ( playerTo != NULL ) ) + if( ( playerFrom != nullptr ) && ( playerTo != nullptr ) ) { manager->m_listener->HandleDataReceived( playerFrom, playerTo, data, bytesRead ); } @@ -3306,7 +3306,7 @@ void SQRNetworkManager_PS3::ServerContextValid_CreateRoom() int ret = -1; if( !ForceErrorPoint(SNM_FORCE_ERROR_GET_WORLD_INFO_LIST) ) { - ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, NULL, &m_getWorldRequestId); + ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, nullptr, &m_getWorldRequestId); } if (ret < 0) { @@ -3335,7 +3335,7 @@ void SQRNetworkManager_PS3::ServerContextValid_JoinRoom() reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, NULL, &m_joinRoomRequestId ); + int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, nullptr, &m_joinRoomRequestId ); if ( (ret < 0) || ForceErrorPoint(SNM_FORCE_ERROR_JOIN_ROOM) ) { if( ret == SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH) @@ -3386,9 +3386,9 @@ void SQRNetworkManager_PS3::GetExtDataForRoom( SceNpMatching2RoomId roomId, void static SceNpMatching2RoomId aRoomId[1]; static SceNpMatching2AttributeId attr[1]; - // All parameters will be NULL if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). - // NULL parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList - if( extData != NULL ) + // All parameters will be nullptr if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). + // nullptr parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList + if( extData != nullptr ) { aRoomId[0] = roomId; attr[0] = SCE_NP_MATCHING2_ROOM_BIN_ATTR_EXTERNAL_1_ID; @@ -3412,14 +3412,14 @@ void SQRNetworkManager_PS3::GetExtDataForRoom( SceNpMatching2RoomId roomId, void return; } - // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with nullptr params) once done, so we can reattempt. Don't do anything more now. if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { app.DebugPrintf("Having to recreate matching context, setting state to SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT\n"); return; } - int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, NULL, &m_roomDataExternalListRequestId ); + int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, nullptr, &m_roomDataExternalListRequestId ); // If we hadn't properly detected that a matching context was unvailable, we might still get an error indicating that it is from the previous call. Handle similarly, but we need // to destroy the context first. @@ -3434,7 +3434,7 @@ void SQRNetworkManager_PS3::GetExtDataForRoom( SceNpMatching2RoomId roomId, void m_FriendSessionUpdatedFn(false, m_pParamFriendSessionUpdated); return; }; - // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with nullptr params) once done, so we can reattempt. Don't do anything more now. if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { return; @@ -3530,7 +3530,7 @@ void SQRNetworkManager_PS3::AttemptPSNSignIn(int (*SignInCompleteCallbackFn)(voi { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } diff --git a/Minecraft.Client/PS3/Network/SQRNetworkManager_PS3.h b/Minecraft.Client/PS3/Network/SQRNetworkManager_PS3.h index 6143bbb58..4953b08fa 100644 --- a/Minecraft.Client/PS3/Network/SQRNetworkManager_PS3.h +++ b/Minecraft.Client/PS3/Network/SQRNetworkManager_PS3.h @@ -125,7 +125,7 @@ class SQRNetworkManager_PS3 : public SQRNetworkManager void LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize); int GetSessionIndex(SQRNetworkPlayer *player); - bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = NULL ); + bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = nullptr ); void RemoveRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int mask ); void RemoveNetworkPlayers( int mask ); void SetLocalPlayersAndSync(); diff --git a/Minecraft.Client/PS3/Network/SonyCommerce_PS3.cpp b/Minecraft.Client/PS3/Network/SonyCommerce_PS3.cpp index 230e03099..8ba847975 100644 --- a/Minecraft.Client/PS3/Network/SonyCommerce_PS3.cpp +++ b/Minecraft.Client/PS3/Network/SonyCommerce_PS3.cpp @@ -9,22 +9,22 @@ bool SonyCommerce_PS3::m_bCommerceInitialised = false; SceNpCommerce2SessionInfo SonyCommerce_PS3::m_sessionInfo; SonyCommerce_PS3::State SonyCommerce_PS3::m_state = e_state_noSession; int SonyCommerce_PS3::m_errorCode = 0; -LPVOID SonyCommerce_PS3::m_callbackParam = NULL; +LPVOID SonyCommerce_PS3::m_callbackParam = nullptr; -void* SonyCommerce_PS3::m_receiveBuffer = NULL; +void* SonyCommerce_PS3::m_receiveBuffer = nullptr; SonyCommerce_PS3::Event SonyCommerce_PS3::m_event; std::queue SonyCommerce_PS3::m_messageQueue; -std::vector* SonyCommerce_PS3::m_pProductInfoList = NULL; -SonyCommerce_PS3::ProductInfoDetailed* SonyCommerce_PS3::m_pProductInfoDetailed = NULL; -SonyCommerce_PS3::ProductInfo* SonyCommerce_PS3::m_pProductInfo = NULL; +std::vector* SonyCommerce_PS3::m_pProductInfoList = nullptr; +SonyCommerce_PS3::ProductInfoDetailed* SonyCommerce_PS3::m_pProductInfoDetailed = nullptr; +SonyCommerce_PS3::ProductInfo* SonyCommerce_PS3::m_pProductInfo = nullptr; -SonyCommerce_PS3::CategoryInfo* SonyCommerce_PS3::m_pCategoryInfo = NULL; -const char* SonyCommerce_PS3::m_pProductID = NULL; -char* SonyCommerce_PS3::m_pCategoryID = NULL; +SonyCommerce_PS3::CategoryInfo* SonyCommerce_PS3::m_pCategoryInfo = nullptr; +const char* SonyCommerce_PS3::m_pProductID = nullptr; +char* SonyCommerce_PS3::m_pCategoryID = nullptr; SonyCommerce_PS3::CheckoutInputParams SonyCommerce_PS3::m_checkoutInputParams; SonyCommerce_PS3::DownloadListInputParams SonyCommerce_PS3::m_downloadInputParams; -SonyCommerce_PS3::CallbackFunc SonyCommerce_PS3::m_callbackFunc = NULL; +SonyCommerce_PS3::CallbackFunc SonyCommerce_PS3::m_callbackFunc = nullptr; sys_memory_container_t SonyCommerce_PS3::m_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; bool SonyCommerce_PS3::m_bUpgradingTrial = false; @@ -40,19 +40,19 @@ bool SonyCommerce_PS3::m_contextCreated=false; ///< npcommerce2 context ID c SonyCommerce_PS3::Phase SonyCommerce_PS3::m_currentPhase = e_phase_stopped; ///< Current commerce2 util char SonyCommerce_PS3::m_commercebuffer[SCE_NP_COMMERCE2_RECV_BUF_SIZE]; -C4JThread* SonyCommerce_PS3::m_tickThread = NULL; +C4JThread* SonyCommerce_PS3::m_tickThread = nullptr; bool SonyCommerce_PS3::m_bLicenseChecked=false; // Check the trial/full license for the game SonyCommerce_PS3::ProductInfoDetailed s_trialUpgradeProductInfoDetailed; void SonyCommerce_PS3::Delete() { - m_pProductInfoList=NULL; - m_pProductInfoDetailed=NULL; - m_pProductInfo=NULL; - m_pCategoryInfo = NULL; - m_pProductID = NULL; - m_pCategoryID = NULL; + m_pProductInfoList=nullptr; + m_pProductInfoDetailed=nullptr; + m_pProductInfo=nullptr; + m_pCategoryInfo = nullptr; + m_pProductID = nullptr; + m_pCategoryID = nullptr; } void SonyCommerce_PS3::Init() { @@ -106,11 +106,11 @@ void SonyCommerce_PS3::CheckForTrialUpgradeKey() // 4J-PB - If we are the blu ray disc then we are the full version if(StorageManager.GetBootTypeDisc()) { - CheckForTrialUpgradeKey_Callback(NULL,true); + CheckForTrialUpgradeKey_Callback(nullptr,true); } else { - StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, NULL); + StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, nullptr); } } @@ -498,7 +498,7 @@ int SonyCommerce_PS3::getDetailedProductInfo(ProductInfoDetailed *pInfo, const c if (categoryId && categoryId[0] != 0) { ret = sceNpCommerce2GetProductInfoStart(requestId, categoryId, productId); } else { - ret = sceNpCommerce2GetProductInfoStart(requestId, NULL, productId); + ret = sceNpCommerce2GetProductInfoStart(requestId, nullptr, productId); } if (ret < 0) { sceNpCommerce2DestroyReq(requestId); @@ -887,7 +887,7 @@ int SonyCommerce_PS3::createContext() } // Create commerce2 context - ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, NULL, &m_contextId); + ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, nullptr, &m_contextId); if (ret < 0) { app.DebugPrintf(4,"createContext sceNpCommerce2CreateCtx problem\n"); @@ -1325,7 +1325,7 @@ void SonyCommerce_PS3::processEvent() m_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1349,7 +1349,7 @@ void SonyCommerce_PS3::processEvent() m_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1410,8 +1410,8 @@ void SonyCommerce_PS3::CreateSession( CallbackFunc cb, LPVOID lpParam ) EnterCriticalSection(&m_queueLock); setCallback(cb,lpParam); m_messageQueue.push(e_message_commerceCreateSession); - if(m_tickThread == NULL) - m_tickThread = new C4JThread(TickLoop, NULL, "SonyCommerce_PS3 tick"); + if(m_tickThread == nullptr) + m_tickThread = new C4JThread(TickLoop, nullptr, "SonyCommerce_PS3 tick"); if(m_tickThread->isRunning() == false) { m_currentPhase = e_phase_idle; diff --git a/Minecraft.Client/PS3/Network/SonyCommerce_PS3.h b/Minecraft.Client/PS3/Network/SonyCommerce_PS3.h index 1f43341a0..05b48cf85 100644 --- a/Minecraft.Client/PS3/Network/SonyCommerce_PS3.h +++ b/Minecraft.Client/PS3/Network/SonyCommerce_PS3.h @@ -114,14 +114,14 @@ class SonyCommerce_PS3 : public SonyCommerce { assert(m_callbackFunc); CallbackFunc func = m_callbackFunc; - m_callbackFunc = NULL; + m_callbackFunc = nullptr; if(func) func(m_callbackParam, m_errorCode); m_errorCode = CELL_OK; } static void setCallback(CallbackFunc cb,LPVOID lpParam) { - assert(m_callbackFunc == NULL); + assert(m_callbackFunc == nullptr); m_callbackFunc = cb; m_callbackParam = lpParam; } diff --git a/Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp b/Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp index 5f804051e..4e681354f 100644 --- a/Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp +++ b/Minecraft.Client/PS3/Network/SonyHttp_PS3.cpp @@ -10,10 +10,10 @@ static const int sc_SSLPoolSize = (512 * 1024U); static const int sc_CookiePoolSize = (256 * 1024U); -void* SonyHttp_PS3::uriPool = NULL; -void* SonyHttp_PS3::httpPool = NULL; -void* SonyHttp_PS3::sslPool = NULL; -void* SonyHttp_PS3::cookiePool = NULL; +void* SonyHttp_PS3::uriPool = nullptr; +void* SonyHttp_PS3::httpPool = nullptr; +void* SonyHttp_PS3::sslPool = nullptr; +void* SonyHttp_PS3::cookiePool = nullptr; CellHttpClientId SonyHttp_PS3::client; CellHttpTransId SonyHttp_PS3::trans; bool SonyHttp_PS3:: bInitialised = false; @@ -22,31 +22,31 @@ bool SonyHttp_PS3:: bInitialised = false; bool SonyHttp_PS3::loadCerts(size_t *numBufPtr, CellHttpsData **caListPtr) { - CellHttpsData *caList = NULL; + CellHttpsData *caList = nullptr; size_t size = 0; int ret = 0; - char *buf = NULL; + char *buf = nullptr; caList = static_cast(malloc(sizeof(CellHttpsData) * 2)); - if (NULL == caList) { + if (nullptr == caList) { app.DebugPrintf("failed to malloc cert data"); return false; } - ret = cellSslCertificateLoader(CELL_SSL_LOAD_CERT_ALL, NULL, 0, &size); + ret = cellSslCertificateLoader(CELL_SSL_LOAD_CERT_ALL, nullptr, 0, &size); if (ret < 0) { app.DebugPrintf("cellSslCertifacateLoader() failed(1): 0x%08x", ret); return ret; } buf = static_cast(malloc(size)); - if (NULL == buf) { + if (nullptr == buf) { app.DebugPrintf("failed to malloc cert buffer"); free(caList); return false; } - ret = cellSslCertificateLoader(CELL_SSL_LOAD_CERT_ALL, buf, size, NULL); + ret = cellSslCertificateLoader(CELL_SSL_LOAD_CERT_ALL, buf, size, nullptr); if (ret < 0) { app.DebugPrintf("cellSslCertifacateLoader() failed(2): 0x%08x", ret); free(buf); @@ -72,7 +72,7 @@ bool SonyHttp_PS3::init() /*E startup procedures */ httpPool = malloc(sc_HTTPPoolSize); - if (httpPool == NULL) { + if (httpPool == nullptr) { app.DebugPrintf("failed to malloc libhttp memory pool\n"); return false; } @@ -84,7 +84,7 @@ bool SonyHttp_PS3::init() } cookiePool = malloc(sc_CookiePoolSize); - if (cookiePool == NULL) { + if (cookiePool == nullptr) { app.DebugPrintf("failed to malloc ssl memory pool\n"); return false; } @@ -97,7 +97,7 @@ bool SonyHttp_PS3::init() sslPool = malloc(sc_SSLPoolSize); - if (sslPool == NULL) { + if (sslPool == nullptr) { app.DebugPrintf("failed to malloc ssl memory pool\n"); return false; } @@ -109,7 +109,7 @@ bool SonyHttp_PS3::init() } size_t numBuf = 0; - CellHttpsData *caList = NULL; + CellHttpsData *caList = nullptr; if(!loadCerts(&numBuf, &caList)) return false; @@ -153,18 +153,18 @@ bool SonyHttp_PS3::parseUri(const char* szUri, CellHttpUri& parsedUri) { /*E the main part */ size_t poolSize = 0; - int ret = cellHttpUtilParseUri(NULL, szUri, NULL, 0, &poolSize); + int ret = cellHttpUtilParseUri(nullptr, szUri, nullptr, 0, &poolSize); if (0 > ret) { app.DebugPrintf("error parsing URI... (0x%x)\n\n", ret); return false; } - if (NULL == (uriPool = malloc(poolSize))) + if (nullptr == (uriPool = malloc(poolSize))) { app.DebugPrintf("error mallocing uriPool (%d)\n", poolSize); return false; } - ret = cellHttpUtilParseUri(&parsedUri, szUri, uriPool, poolSize, NULL); + ret = cellHttpUtilParseUri(&parsedUri, szUri, uriPool, poolSize, nullptr); if (0 > ret) { free(uriPool); @@ -185,7 +185,7 @@ void* SonyHttp_PS3::getData(const char* url, int* pDataSize) size_t localRecv = 0; if(!parseUri(url, uri)) - return NULL; + return nullptr; app.DebugPrintf(" scheme: %s\n", uri.scheme); app.DebugPrintf(" hostname: %s\n", uri.hostname); @@ -199,10 +199,10 @@ void* SonyHttp_PS3::getData(const char* url, int* pDataSize) if (0 > ret) { app.DebugPrintf("failed to create http transaction... (0x%x)\n\n", ret); - return NULL; + return nullptr; } - ret = cellHttpSendRequest(trans, NULL, 0, NULL); + ret = cellHttpSendRequest(trans, nullptr, 0, nullptr); if (0 > ret) { app.DebugPrintf("failed to complete http transaction... (0x%x)\n\n", ret); @@ -219,7 +219,7 @@ void* SonyHttp_PS3::getData(const char* url, int* pDataSize) app.DebugPrintf("failed to receive http response... (0x%x)\n\n", ret); cellHttpDestroyTransaction(trans); trans = 0; - return NULL; + return nullptr; } app.DebugPrintf("Status Code is %d\n", code); } @@ -232,14 +232,14 @@ void* SonyHttp_PS3::getData(const char* url, int* pDataSize) app.DebugPrintf("Only supporting data that has a content length : CELL_HTTP_ERROR_NO_CONTENT_LENGTH\n", ret); cellHttpDestroyTransaction(trans); trans = 0; - return NULL; + return nullptr; } else { app.DebugPrintf("error in receiving content length... (0x%x)\n\n", ret); cellHttpDestroyTransaction(trans); trans = 0; - return NULL; + return nullptr; } } @@ -261,7 +261,7 @@ void* SonyHttp_PS3::getData(const char* url, int* pDataSize) free(buffer); cellHttpDestroyTransaction(trans); trans = 0; - return NULL; + return nullptr; } else { diff --git a/Minecraft.Client/PS3/Network/SonyRemoteStorage_PS3.cpp b/Minecraft.Client/PS3/Network/SonyRemoteStorage_PS3.cpp index a1f6c7fde..221e9f8fc 100644 --- a/Minecraft.Client/PS3/Network/SonyRemoteStorage_PS3.cpp +++ b/Minecraft.Client/PS3/Network/SonyRemoteStorage_PS3.cpp @@ -35,7 +35,7 @@ void SonyRemoteStorage_PS3::npauthhandler(int event, int result, void *arg) { psnTicketSize = result; psnTicket = malloc(psnTicketSize); - if (psnTicket == NULL) + if (psnTicket == nullptr) { app.DebugPrintf("Failed to allocate for ticket\n"); } @@ -67,7 +67,7 @@ int SonyRemoteStorage_PS3::initPreconditions() SceNpTicketVersion ticketVersion; ticketVersion.major = 3; ticketVersion.minor = 0; - ret = sceNpManagerRequestTicket2(&npId, &ticketVersion, TICKETING_SERVICE_ID, NULL, 0, NULL, 0); + ret = sceNpManagerRequestTicket2(&npId, &ticketVersion, TICKETING_SERVICE_ID, nullptr, 0, nullptr, 0); if(ret < 0) { return ret; @@ -78,7 +78,7 @@ int SonyRemoteStorage_PS3::initPreconditions() cellSysutilCheckCallback(); sys_timer_usleep(50000); //50 milliseconds. } - if(psnTicket == NULL) + if(psnTicket == nullptr) return -1; return 0; @@ -239,7 +239,7 @@ bool SonyRemoteStorage_PS3::init(CallbackFunc cb, LPVOID lpParam) params.timeout.receiveMs = 120 * 1000; //120 seconds is the default params.timeout.sendMs = 120 * 1000; //120 seconds is the default params.pool.memPoolSize = 7 * 1024 * 1024; - if(m_memPoolBuffer == NULL) + if(m_memPoolBuffer == nullptr) m_memPoolBuffer = malloc(params.pool.memPoolSize); params.pool.memPoolBuffer = m_memPoolBuffer; @@ -345,7 +345,7 @@ bool SonyRemoteStorage_PS3::setDataInternal() char seed[22]; app.GetImageTextData(m_thumbnailData, m_thumbnailDataSize,(unsigned char *)seed, uiHostOptions, bHostOptionsRead, uiTexturePack); - __int64 iSeed = strtoll(seed,NULL,10); + __int64 iSeed = strtoll(seed,nullptr,10); char seedHex[17]; sprintf(seedHex,"%016llx",iSeed); memcpy(descData.m_seed,seedHex,16); // Don't copy null diff --git a/Minecraft.Client/PS3/Network/SonyVoiceChat.cpp b/Minecraft.Client/PS3/Network/SonyVoiceChat.cpp index 41c52bed9..7a4d95aa2 100644 --- a/Minecraft.Client/PS3/Network/SonyVoiceChat.cpp +++ b/Minecraft.Client/PS3/Network/SonyVoiceChat.cpp @@ -49,7 +49,7 @@ void SonyVoiceChat::init( SQRNetworkManager_PS3* pNetMan ) sm_pNetworkManager = pNetMan; setState(AVC_STATE_CHAT_INIT); - ProfileManager.GetChatAndContentRestrictions(0,false,&sm_isChatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(0,false,&sm_isChatRestricted,nullptr,nullptr); } void SonyVoiceChat::shutdown() @@ -225,11 +225,11 @@ void SonyVoiceChat::eventcb( CellSysutilAvc2EventId event_id, CellSysutilAvc2Eve { CELL_AVC2_EVENT_LEAVE_FAILED, eventcb_leave }, { CELL_AVC2_EVENT_UNLOAD_SUCCEEDED, eventcb_unload }, { CELL_AVC2_EVENT_UNLOAD_FAILED, eventcb_unload }, - { CELL_AVC2_EVENT_SYSTEM_NEW_MEMBER_JOINED, NULL }, - { CELL_AVC2_EVENT_SYSTEM_MEMBER_LEFT, NULL }, - { CELL_AVC2_EVENT_SYSTEM_SESSION_ESTABLISHED, NULL }, - { CELL_AVC2_EVENT_SYSTEM_SESSION_CANNOT_ESTABLISHED,NULL }, - { CELL_AVC2_EVENT_SYSTEM_SESSION_DISCONNECTED, NULL }, + { CELL_AVC2_EVENT_SYSTEM_NEW_MEMBER_JOINED, nullptr }, + { CELL_AVC2_EVENT_SYSTEM_MEMBER_LEFT, nullptr }, + { CELL_AVC2_EVENT_SYSTEM_SESSION_ESTABLISHED, nullptr }, + { CELL_AVC2_EVENT_SYSTEM_SESSION_CANNOT_ESTABLISHED,nullptr }, + { CELL_AVC2_EVENT_SYSTEM_SESSION_DISCONNECTED, nullptr }, { CELL_AVC2_EVENT_SYSTEM_VOICE_DETECTED, eventcb_voiceDetected }, }; @@ -258,7 +258,7 @@ int SonyVoiceChat::load() ret = cellSysutilAvc2LoadAsync( sm_pNetworkManager->m_matchingContext, SYS_MEMORY_CONTAINER_ID_INVALID, eventcb, - NULL, + nullptr, &g_chat_avc2param ); if( ret != CELL_OK ) { diff --git a/Minecraft.Client/PS3/PS3Extras/C4JSpursJob.cpp b/Minecraft.Client/PS3/PS3Extras/C4JSpursJob.cpp index fd8ddd9ad..bce76078f 100644 --- a/Minecraft.Client/PS3/PS3Extras/C4JSpursJob.cpp +++ b/Minecraft.Client/PS3/PS3Extras/C4JSpursJob.cpp @@ -16,13 +16,13 @@ static const unsigned int NUM_SUBMIT_JOBS = 128; #define DMA_ALIGNMENT (128) #define JOBHEADER_SYMBOL(JobName) _binary_jqjob_##JobName##_jobbin2_jobheader -C4JSpursJobQueue* C4JSpursJobQueue::m_pMainJobQueue = NULL; +C4JSpursJobQueue* C4JSpursJobQueue::m_pMainJobQueue = nullptr; uint16_t C4JSpursJobQueue::Port::s_jobTagBitmask = 0; -C4JSpursJobQueue::Port* C4JSpursJobQueue::Port::s_allocatedPorts[16] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; +C4JSpursJobQueue::Port* C4JSpursJobQueue::Port::s_allocatedPorts[16] = {nullptr,nullptr,nullptr,nullptr, + nullptr,nullptr,nullptr,nullptr, + nullptr,nullptr,nullptr,nullptr, + nullptr,nullptr,nullptr,nullptr }; bool C4JSpursJobQueue::Port::s_initialised; CRITICAL_SECTION C4JSpursJobQueue::Port::s_lock; @@ -43,7 +43,7 @@ C4JSpursJobQueue::C4JSpursJobQueue() //E create jobQueue pJobQueue = (JobQueue*)memalign(CELL_SPURS_JOBQUEUE_ALIGN, sizeof(JobQueue)); - assert(pJobQueue != NULL); + assert(pJobQueue != nullptr); ret = JobQueue::create( pJobQueue, spurs, @@ -168,7 +168,7 @@ int C4JSpursJobQueue::Port::getFreeJobTag() void C4JSpursJobQueue::Port::releaseJobTag( int tag ) { s_jobTagBitmask &= ~(1< *pJobQueue; public: - static C4JSpursJobQueue& getMainJobQueue() {if(m_pMainJobQueue == NULL) m_pMainJobQueue = new C4JSpursJobQueue; return *m_pMainJobQueue;} + static C4JSpursJobQueue& getMainJobQueue() {if(m_pMainJobQueue == nullptr) m_pMainJobQueue = new C4JSpursJobQueue; return *m_pMainJobQueue;} C4JSpursJobQueue(); void shutdown(); diff --git a/Minecraft.Client/PS3/PS3Extras/C4JThread_SPU.cpp b/Minecraft.Client/PS3/PS3Extras/C4JThread_SPU.cpp index 94d7ef87d..56dd98783 100644 --- a/Minecraft.Client/PS3/PS3Extras/C4JThread_SPU.cpp +++ b/Minecraft.Client/PS3/PS3Extras/C4JThread_SPU.cpp @@ -17,7 +17,7 @@ static const bool sc_verbose = true; -cell::Spurs::Spurs2* C4JThread_SPU::ms_spurs2Object = NULL; +cell::Spurs::Spurs2* C4JThread_SPU::ms_spurs2Object = nullptr; void C4JThread_SPU::initSPURS() { diff --git a/Minecraft.Client/PS3/PS3Extras/EdgeZLib.cpp b/Minecraft.Client/PS3/PS3Extras/EdgeZLib.cpp index 2b0a523fe..53a8639d4 100644 --- a/Minecraft.Client/PS3/PS3Extras/EdgeZLib.cpp +++ b/Minecraft.Client/PS3/PS3Extras/EdgeZLib.cpp @@ -3,7 +3,7 @@ #include "EdgeZLib.h" #include "edge/zlib/edgezlib_ppu.h" -static CellSpurs* s_pSpurs = NULL; +static CellSpurs* s_pSpurs = nullptr; //Set this to 5 if you want deflate/inflate to run in parallel on 5 SPUs. @@ -12,7 +12,7 @@ const uint32_t kMaxNumDeflateQueueEntries = 64; static CellSpursEventFlag s_eventFlagDeflate; //Cannot be on stack static CellSpursTaskset s_taskSetDeflate; //Cannot be on stack static EdgeZlibDeflateQHandle s_deflateQueue; -static void* s_pDeflateQueueBuffer = NULL; +static void* s_pDeflateQueueBuffer = nullptr; static void* s_pDeflateTaskContext[kNumDeflateTasks]; static uint32_t s_numElementsToCompress; //Cannot be on stack @@ -22,7 +22,7 @@ const uint32_t kMaxNumInflateQueueEntries = 64; static CellSpursEventFlag s_eventFlagInflate; //Cannot be on stack static CellSpursTaskset s_taskSetInflate; //Cannot be on stack static EdgeZlibInflateQHandle s_inflateQueue; -static void* s_pInflateQueueBuffer = NULL; +static void* s_pInflateQueueBuffer = nullptr; static void* s_pInflateTaskContext[kNumInflateTasks]; static uint32_t s_numElementsToDecompress; //Cannot be on stack @@ -195,9 +195,9 @@ bool EdgeZLib::Compress(void* pDestination, uint32_t* pDestSize, const void* pSo // The Deflate Task will wake up and process this work. // ////////////////////////////////////////////////////////////////////////// - uint32_t* pDst = NULL; + uint32_t* pDst = nullptr; bool findingSizeOnly = false; - if(pDestination == NULL && *pDestSize == 0) + if(pDestination == nullptr && *pDestSize == 0) { pDst = (uint32_t*)malloc(SrcSize); findingSizeOnly = true; diff --git a/Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp b/Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp index a07646047..442aab06f 100644 --- a/Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp +++ b/Minecraft.Client/PS3/PS3Extras/PS3Strings.cpp @@ -13,10 +13,10 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID) if( (cd = l10n_get_converter( L10N_UTF16, L10N_UTF8 )) == -1 ) { app.DebugPrintf("l10n_get_converter: no such converter\n"); - return NULL; + return nullptr; } - l10n_convert_str( cd, wchString, &src_len, NULL, &dst_len ); + l10n_convert_str( cd, wchString, &src_len, nullptr, &dst_len ); uint8_t *strUtf8=static_cast(malloc(dst_len)); memset(strUtf8,0,dst_len); @@ -24,7 +24,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID) if( result != ConversionOK ) { app.DebugPrintf("l10n_convert: conversion error : 0x%x\n", result); - return NULL; + return nullptr; } return strUtf8; diff --git a/Minecraft.Client/PS3/PS3Extras/Ps3Stubs.cpp b/Minecraft.Client/PS3/PS3Extras/Ps3Stubs.cpp index 2177739a6..9c462e728 100644 --- a/Minecraft.Client/PS3/PS3Extras/Ps3Stubs.cpp +++ b/Minecraft.Client/PS3/PS3Extras/Ps3Stubs.cpp @@ -74,8 +74,8 @@ int _wcsicmp( const wchar_t * dst, const wchar_t * src ) wchar_t f,l; // validation section - // _VALIDATE_RETURN(dst != NULL, EINVAL, _NLSCMPERROR); - // _VALIDATE_RETURN(src != NULL, EINVAL, _NLSCMPERROR); + // _VALIDATE_RETURN(dst != nullptr, EINVAL, _NLSCMPERROR); + // _VALIDATE_RETURN(src != nullptr, EINVAL, _NLSCMPERROR); do { f = towlower(*dst); @@ -90,7 +90,7 @@ size_t wcsnlen(const wchar_t *wcs, size_t maxsize) { size_t n; -// Note that we do not check if s == NULL, because we do not +// Note that we do not check if s == nullptr, because we do not // return errno_t... for (n = 0; n < maxsize && *wcs; n++, wcs++) @@ -134,7 +134,7 @@ VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) lpSystemTime->wMilliseconds = cellRtcGetMicrosecond(&dateTime)/1000; } -HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { PS3_STUBBED; return NULL; } +HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { PS3_STUBBED; return nullptr; } VOID Sleep(DWORD dwMilliseconds) { C4JThread::Sleep(dwMilliseconds); @@ -267,8 +267,8 @@ BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) { return TLSStoragePS3::In LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) { int err; - sys_addr_t newAddress = NULL; - if(lpAddress == NULL) + sys_addr_t newAddress = nullptr; + if(lpAddress == nullptr) { // reserve, and possibly commit also int commitSize = 0; @@ -382,7 +382,7 @@ BOOL SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHi int fd = (int) hFile; uint64_t pos = 0, bitsToMove = (int64_t) lDistanceToMove; - if (lpDistanceToMoveHigh != NULL) + if (lpDistanceToMoveHigh != nullptr) bitsToMove |= ((uint64_t) (*lpDistanceToMoveHigh)) << 32; int whence = 0; @@ -490,7 +490,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, } else { - err = cellFsOpen(filePath, flags, &fd ,NULL, 0); + err = cellFsOpen(filePath, flags, &fd ,nullptr, 0); iFilesOpen++; //printf("\n\nFiles Open - %d\n\n",iFilesOpen); } @@ -675,7 +675,7 @@ errno_t _i64toa_s(__int64 _Val, char * _DstBuf, size_t _Size, int _Radix) { if(_ int _wtoi(const wchar_t *_Str) { - return wcstol(_Str, NULL, 10); + return wcstol(_Str, nullptr, 10); } diff --git a/Minecraft.Client/PS3/PS3Extras/ShutdownManager.cpp b/Minecraft.Client/PS3/PS3Extras/ShutdownManager.cpp index e7eca53f4..a04e45d9f 100644 --- a/Minecraft.Client/PS3/PS3Extras/ShutdownManager.cpp +++ b/Minecraft.Client/PS3/PS3Extras/ShutdownManager.cpp @@ -16,12 +16,12 @@ C4JThread::EventArray *ShutdownManager::s_eventArray[eThreadIdCount]; void ShutdownManager::Initialise() { #ifdef __PS3__ - cellSysutilRegisterCallback( 1, SysUtilCallback, NULL ); + cellSysutilRegisterCallback( 1, SysUtilCallback, nullptr ); for( int i = 0; i < eThreadIdCount; i++ ) { s_threadShouldRun[i] = true; s_threadRunning[i] = 0; - s_eventArray[i] = NULL; + s_eventArray[i] = nullptr; } // Special case for storage manager, which we will manually set now to be considered as running - this will be unset by StorageManager.ExitRequest if required s_threadRunning[eStorageManagerThreads] = true; diff --git a/Minecraft.Client/PS3/PS3Extras/TLSStorage.cpp b/Minecraft.Client/PS3/PS3Extras/TLSStorage.cpp index 0906802df..a3b09d6d1 100644 --- a/Minecraft.Client/PS3/PS3Extras/TLSStorage.cpp +++ b/Minecraft.Client/PS3/PS3Extras/TLSStorage.cpp @@ -4,7 +4,7 @@ -TLSStoragePS3* TLSStoragePS3::m_pInstance = NULL; +TLSStoragePS3* TLSStoragePS3::m_pInstance = nullptr; BOOL TLSStoragePS3::m_activeList[sc_maxSlots]; __thread LPVOID TLSStoragePS3::m_values[sc_maxSlots]; @@ -16,7 +16,7 @@ TLSStoragePS3::TLSStoragePS3() for(int i=0;ichDLCKeyname,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,pDLCInfo->chDLCKeyname,sizeof(char)*uiVal,&bytesRead,nullptr); - WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,nullptr); app.DebugPrintf("DLC title %s\n",chDLCTitle); - WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,nullptr); // push this into a vector @@ -345,7 +345,7 @@ void CConsoleMinecraftApp::FatalLoadError() } app.DebugPrintf("Requesting Message Box for Fatal Error\n"); - EMsgBoxResult eResult=InputManager.RequestMessageBox(EMSgBoxType_None,0,NULL,this,(char *)u8Message,0); + EMsgBoxResult eResult=InputManager.RequestMessageBox(EMSgBoxType_None,0,nullptr,this,(char *)u8Message,0); while ((eResult==EMsgBox_Busy) || (eResult==EMsgBox_SysUtilBusy)) { @@ -359,7 +359,7 @@ void CConsoleMinecraftApp::FatalLoadError() _Exit(0); } app.DebugPrintf("Requesting Message Box for Fatal Error again due to BUSY\n"); - eResult=InputManager.RequestMessageBox(EMSgBoxType_None,0,NULL,this,(char *)u8Message,0); + eResult=InputManager.RequestMessageBox(EMSgBoxType_None,0,nullptr,this,(char *)u8Message,0); } while(1) @@ -483,7 +483,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -521,7 +521,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() #ifdef SAVE_GAME_TO_LOAD param->saveData = LoadSaveFromDisk(wstring(SAVE_GAME_TO_LOAD)); #else - param->saveData = NULL; + param->saveData = nullptr; #endif app.SetGameHostOption(eGameHostOption_Difficulty,0); app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); @@ -728,7 +728,7 @@ SonyCommerce::CategoryInfo *CConsoleMinecraftApp::GetCategoryInfo() { if(m_bCommerceCategoriesRetrieved==false) { - return NULL; + return nullptr; } return &m_CategoryInfo; @@ -742,10 +742,10 @@ void CConsoleMinecraftApp::ClearCommerceDetails() pProductList->clear(); } - if(m_ProductListA!=NULL) + if(m_ProductListA!=nullptr) { delete [] m_ProductListA; - m_ProductListA=NULL; + m_ProductListA=nullptr; } m_ProductListRetrievedC=0; @@ -831,7 +831,7 @@ std::vector* CConsoleMinecraftApp::GetProductList(int { if((m_bCommerceProductListRetrieved==false) || (m_bProductListAdditionalDetailsRetrieved==false) ) { - return NULL; + return nullptr; } return &m_ProductListA[iIndex]; @@ -1181,7 +1181,7 @@ char *PatchFilelist[] = - NULL + nullptr }; bool CConsoleMinecraftApp::IsFileInPatchList(LPCSTR lpFileName) @@ -1226,7 +1226,7 @@ bool CConsoleMinecraftApp::CheckForEmptyStore(int iPad) SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); bool bEmptyStore=true; - if(pCategories!=NULL) + if(pCategories!=nullptr) { if(pCategories->countOfProducts>0) { diff --git a/Minecraft.Client/PS3/PS3_App.h b/Minecraft.Client/PS3/PS3_App.h index d1ecdb6f5..f9293b6fd 100644 --- a/Minecraft.Client/PS3/PS3_App.h +++ b/Minecraft.Client/PS3/PS3_App.h @@ -88,7 +88,7 @@ class CConsoleMinecraftApp : public CMinecraftApp // void SetVoiceChatAndUGCRestricted(bool bRestricted); // bool GetVoiceChatAndUGCRestricted(void); - StringTable *GetStringTable() { return NULL;} + StringTable *GetStringTable() { return nullptr;} // original code virtual void TemporaryCreateGameStart(); diff --git a/Minecraft.Client/PS3/PS3_Minecraft.cpp b/Minecraft.Client/PS3/PS3_Minecraft.cpp index 53b47d2d0..2210a5651 100644 --- a/Minecraft.Client/PS3/PS3_Minecraft.cpp +++ b/Minecraft.Client/PS3/PS3_Minecraft.cpp @@ -355,9 +355,9 @@ void MemSect(int sect) #endif -ID3D11Device* g_pd3dDevice = NULL; -ID3D11DeviceContext* g_pImmediateContext = NULL; -IDXGISwapChain* g_pSwapChain = NULL; +ID3D11Device* g_pd3dDevice = nullptr; +ID3D11DeviceContext* g_pImmediateContext = nullptr; +IDXGISwapChain* g_pSwapChain = nullptr; bool g_bBootedFromInvite = false; //-------------------------------------------------------------------------------------- @@ -419,7 +419,7 @@ static void * load_file( char const * name ) void debugSaveGameDirect() { - C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, NULL, "debugSaveGameDirect"); + C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, nullptr, "debugSaveGameDirect"); thread->Run(); thread->WaitForCompletion(1000); } @@ -446,7 +446,7 @@ int simpleMessageBoxCallback( UINT uiTitle, UINT uiText, ui.RequestMessageBox( uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, lpParam, app.GetStringTable(), - NULL, 0 + nullptr, 0 ); return 0; @@ -632,7 +632,7 @@ int LoadSysModules() DEBUG_PRINTF("contentInfoPath - %s\n",contentInfoPath); DEBUG_PRINTF("usrdirPath - %s\n",usrdirPath); - ret=cellGamePatchCheck(&sizeBD,NULL); + ret=cellGamePatchCheck(&sizeBD,nullptr); if(ret < 0) { DEBUG_PRINTF("cellGamePatchCheck() Error: 0x%x\n", ret); @@ -838,7 +838,7 @@ int main() else ui.init(1280,480); - app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL + app.CommerceInit(); // MGH - moved this here so GetCommerce isn't nullptr // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised app.GetCommerce()->CheckForTrialUpgradeKey(); @@ -861,7 +861,7 @@ int main() } // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers) - hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); + hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, nullptr); if ( FAILED( hr ) ) { app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr ); @@ -976,24 +976,24 @@ int main() free(szTemp); StorageManager.SetDefaultImages((PBYTE)baOptionsIcon.data, baOptionsIcon.length,(PBYTE)baSaveImage.data, baSaveImage.length,(PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); - if(baOptionsIcon.data!=NULL) + if(baOptionsIcon.data!=nullptr) { delete [] baOptionsIcon.data; } - if(baSaveThumbnail.data!=NULL) + if(baSaveThumbnail.data!=nullptr) { delete [] baSaveThumbnail.data; } - if(baSaveImage.data!=NULL) + if(baSaveImage.data!=nullptr) { delete [] baSaveImage.data; } wstring wsName=L"Graphics\\SaveChest.png"; byteArray baSaveLoadIcon = app.getArchiveFile(wsName); - if(baSaveLoadIcon.data!=NULL) + if(baSaveLoadIcon.data!=nullptr) { StorageManager.SetSaveLoadIcon((PBYTE)baSaveLoadIcon.data, baSaveLoadIcon.length); delete [] baSaveLoadIcon.data; @@ -1038,7 +1038,7 @@ int main() }*/ // set the achievement text for a trial achievement, now we have the string table loaded - ProfileManager.SetTrialTextStringTable(NULL, IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL); + ProfileManager.SetTrialTextStringTable(nullptr, IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL); ProfileManager.SetTrialAwardText(eAwardType_Achievement,IDS_UNLOCK_TITLE,IDS_UNLOCK_ACHIEVEMENT_TEXT); #ifndef __PS3__ ProfileManager.SetTrialAwardText(eAwardType_GamerPic,IDS_UNLOCK_TITLE,IDS_UNLOCK_GAMERPIC_TEXT); @@ -1108,7 +1108,7 @@ int main() // It's ok to do this for the primary PSN player here - it has this data locally. All other players need to do it on PSN sign in. // bool bChatRestricted=false; -// ProfileManager.GetChatAndContentRestrictions(0,&bChatRestricted,NULL,NULL); +// ProfileManager.GetChatAndContentRestrictions(0,&bChatRestricted,nullptr,nullptr); // 4J-PB - really want to wait until we've read the options, so we can set the right language if they've chosen one other than the default // bool bOptionsRead=false; @@ -1197,7 +1197,7 @@ int main() else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true,false); IntCache::Reset(); @@ -1366,7 +1366,7 @@ vector vRichPresenceStrings; uint8_t * AddRichPresenceString(int iID) { uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); - if( strUtf8 != NULL ) + if( strUtf8 != nullptr ) { vRichPresenceStrings.push_back(strUtf8); } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h index 8196032ec..929cc0d11 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h @@ -17,10 +17,10 @@ class BedTile_SPU : public Tile_SPU BedTile_SPU(int id) : Tile_SPU(id) {} - virtual Icon_SPU *getTexture(int face, int data) { return NULL; } + virtual Icon_SPU *getTexture(int face, int data) { return nullptr; } virtual int getRenderShape() { return Tile_SPU::SHAPE_BED; } virtual bool isSolidRender(bool isServerLevel = false) { return false; } - virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { setShape(); } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h index f34a5ec94..1009396c0 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h @@ -18,7 +18,7 @@ class ButtonTile_SPU : public Tile_SPU virtual bool blocksLight() { return false; } virtual bool isSolidRender(bool isServerLevel = false) { return false; } virtual bool isCubeShaped() { return false; } - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { int data = level->getData(x, y, z); int dir = data & 7; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h index 07eb3d86f..e617e84cf 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h @@ -5,7 +5,7 @@ class CakeTile_SPU : public Tile_SPU { public: CakeTile_SPU(int id) : Tile_SPU(id) {} - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { int d = level->getData(x, y, z); float r = 1 / 16.0f; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h index 2854b48bb..199fceb6c 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h @@ -6,7 +6,7 @@ class CauldronTile_SPU : public Tile_SPU { public: CauldronTile_SPU(int id) : Tile_SPU(id) {} - virtual Icon_SPU *getTexture(int face, int data) { return NULL; } + virtual Icon_SPU *getTexture(int face, int data) { return nullptr; } //@Override // virtual void updateDefaultShape(); virtual bool isSolidRender(bool isServerLevel = false) { return false; } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp index 9aa7978a2..ac71c572a 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp @@ -696,7 +696,7 @@ bool ChunkRebuildData::isEmptyTile(int x, int y, int z) bool ChunkRebuildData::isSolidRenderTile(int x, int y, int z) { TileRef_SPU tile(getTile(x,y,z)); - if (tile.getPtr() == NULL) return false; + if (tile.getPtr() == nullptr) return false; // 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so @@ -727,7 +727,7 @@ bool ChunkRebuildData::isSolidRenderTile(int x, int y, int z) bool ChunkRebuildData::isSolidBlockingTile(int x, int y, int z) { TileRef_SPU tile(getTile(x, y, z)); - if (tile.getPtr() == NULL) return false; + if (tile.getPtr() == nullptr) return false; bool ret = tile->getMaterial()->blocksMotion() && tile->isCubeShaped(); return ret; } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h index f6671db49..2fcb15146 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h @@ -24,7 +24,7 @@ class DoorTile_SPU : public Tile_SPU virtual bool blocksLight() { return false; } virtual bool isSolidRender(bool isServerLevel = false) { return false; } virtual int getRenderShape() { return Tile_SPU::SHAPE_DOOR; } - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr); // 4J added forceData, forceEntity param int getDir(ChunkRebuildData *level, int x, int y, int z); bool isOpen(ChunkRebuildData *level, int x, int y, int z); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h index 6e86d1f03..5e99cc320 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h @@ -12,7 +12,7 @@ class FenceGateTile_SPU : public Tile_SPU Icon_SPU *getTexture(int face, int data) { return TileRef_SPU(wood_Id)->getTexture(face); } static int getDirection(int data) { return (data & DIRECTION_MASK); } - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param // Brought forward from 1.2.3 + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param // Brought forward from 1.2.3 { int data = getDirection(level->getData(x, y, z)); if (data == Direction::NORTH || data == Direction::SOUTH) diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp index fcb3baefb..63c206d1d 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp @@ -59,7 +59,7 @@ bool FenceTile_SPU::connectsTo(ChunkRebuildData *level, int x, int y, int z) return true; } TileRef_SPU tileInstance(tile); - if (tileInstance.getPtr() != NULL) + if (tileInstance.getPtr() != nullptr) { if (tileInstance->getMaterial()->isSolidBlocking() && tileInstance->isCubeShaped()) { diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h index 50a775fb4..bed2e3b72 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h @@ -5,7 +5,7 @@ class FenceTile_SPU : public Tile_SPU { public: FenceTile_SPU(int id) : Tile_SPU(id) {} - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr); // 4J added forceData, forceEntity param virtual bool blocksLight(); virtual bool isSolidRender(bool isServerLevel = false); virtual int getRenderShape(); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.cpp index 1cf838219..1dba9757c 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.cpp @@ -3,7 +3,7 @@ #include "Facing_SPU.h" #include "ChunkRebuildData.h" -void HalfSlabTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData /* = -1 */, TileEntity* forceEntity /* = NULL */) +void HalfSlabTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData /* = -1 */, TileEntity* forceEntity /* = nullptr */) { if (fullSize()) { diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h index fd525e96b..c89581ad9 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h @@ -9,7 +9,7 @@ class HalfSlabTile_SPU : public Tile_SPU static const int TOP_SLOT_BIT = 8; HalfSlabTile_SPU(int id) : Tile_SPU(id) {} - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr); // 4J added forceData, forceEntity param virtual void updateDefaultShape(); virtual bool isSolidRender(bool isServerLevel); virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonBaseTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonBaseTile_SPU.h index e8411c885..81ba68c19 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonBaseTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonBaseTile_SPU.h @@ -8,7 +8,7 @@ class PistonBaseTile_SPU : public Tile_SPU public: PistonBaseTile_SPU(int id) : Tile_SPU(id) {} // virtual void updateShape(float x0, float y0, float z0, float x1, float y1, float z1); - virtual Icon_SPU *getTexture(int face, int data) { return NULL; } + virtual Icon_SPU *getTexture(int face, int data) { return nullptr; } virtual int getRenderShape() { return SHAPE_PISTON_BASE; } virtual bool isSolidRender(bool isServerLevel = false) { return false; } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonExtensionTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonExtensionTile_SPU.h index d5460492e..ee559eff2 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonExtensionTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonExtensionTile_SPU.h @@ -6,7 +6,7 @@ class PistonExtensionTile_SPU : public Tile_SPU public: PistonExtensionTile_SPU(int id) : Tile_SPU(id) {} - virtual Icon_SPU *getTexture(int face, int data) { return NULL; } + virtual Icon_SPU *getTexture(int face, int data) { return nullptr; } virtual int getRenderShape() { return SHAPE_PISTON_EXTENSION; } virtual bool isSolidRender(bool isServerLevel = false) { return false; } // virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr forceEntity = shared_ptr()); // 4J added forceData, forceEntity param diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonMovingPiece_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonMovingPiece_SPU.h index 48fc52e91..6ea12648f 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonMovingPiece_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonMovingPiece_SPU.h @@ -10,7 +10,7 @@ class PistonMovingPiece_SPU : public EntityTile_SPU virtual int getRenderShape() { return SHAPE_INVISIBLE; } virtual bool isSolidRender(bool isServerLevel = false) { return false; } - virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { // should never get here. } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PortalTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PortalTile_SPU.h index f01313a11..a5a4652d8 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PortalTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PortalTile_SPU.h @@ -5,7 +5,7 @@ class PortalTile_SPU : public HalfTransparentTile_SPU { public: PortalTile_SPU(int id): HalfTransparentTile_SPU(id) {} - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { if (level->getTile(x - 1, y, z) == id || level->getTile(x + 1, y, z) == id) { diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.h index 133ec52e5..6742e6f6c 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.h @@ -16,6 +16,6 @@ class PressurePlateTile_SPU : public Tile_SPU virtual bool isSolidRender(bool isServerLevel = false); virtual bool blocksLight(); - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr); // 4J added forceData, forceEntity param virtual void updateDefaultShape(); }; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h index 615ebec92..2f8639d4f 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h @@ -10,7 +10,7 @@ class RailTile_SPU : public Tile_SPU RailTile_SPU(int id) : Tile_SPU(id) {} virtual bool isSolidRender(bool isServerLevel = false) { return false; } - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { int data = level->getData(x, y, z); if (data >= 2 && data <= 5) diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedStoneDustTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedStoneDustTile_SPU.h index 0e461118e..218cbd646 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedStoneDustTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedStoneDustTile_SPU.h @@ -26,7 +26,7 @@ class RedStoneDustTile_SPU : public Tile_SPU case TEXTURE_CROSS_OVERLAY: return &ms_pTileData->redStoneDust_iconCrossOver; case TEXTURE_LINE_OVERLAY: return &ms_pTileData->redStoneDust_iconLineOver; } - return NULL; + return nullptr; } static bool shouldConnectTo(ChunkRebuildData *level, int x, int y, int z, int direction) diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h index 7fe54d991..74bdb95d9 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h @@ -16,7 +16,7 @@ class SignTile_SPU : public EntityTile_SPU } Icon_SPU *getTexture(int face, int data){ return TileRef_SPU(wood_Id)->getTexture(face); } - void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { if (onGround()) return; int face = level->getData(x, y, z); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h index eefa36b2a..ca5ba279f 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h @@ -15,7 +15,7 @@ class StairTile_SPU : public Tile_SPU public: StairTile_SPU(int id) : Tile_SPU(id) {} - void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param + void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr); // 4J added forceData, forceEntity param bool isSolidRender(bool isServerLevel = false); int getRenderShape(); void setBaseShape(ChunkRebuildData *level, int x, int y, int z); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h index 89cd3739c..4923e862d 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h @@ -35,7 +35,7 @@ class StemTile_SPU : public Bush_SPU this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, 0.25f, 0.5f + ss); } - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { ms_pTileData->yy1[id] = (level->getData(x, y, z) * 2 + 2) / 16.0f; float ss = 0.125f; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp index 7772aba9f..efcd44f01 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp @@ -170,7 +170,7 @@ float convertHFloatToFloat(hfloat hf) // Tesselator_SPU *Tesselator_SPU::getInstance() { - return NULL; + return nullptr; // return (Tesselator_SPU *)TlsGetValue(tlsIdx); } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortalFrameTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortalFrameTile_SPU.h index 8aab31a35..87d87bcfa 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortalFrameTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortalFrameTile_SPU.h @@ -5,7 +5,7 @@ class TheEndPortalFrameTile_SPU : public Tile_SPU { public: TheEndPortalFrameTile_SPU(int id) : Tile_SPU(id) {} - virtual Icon_SPU *getTexture(int face, int data) { return NULL; } + virtual Icon_SPU *getTexture(int face, int data) { return nullptr; } virtual bool isSolidRender(bool isServerLevel = false) { return false; } virtual int getRenderShape() { return SHAPE_PORTAL_FRAME; } // virtual void updateDefaultShape(); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp index 20393f6ea..9e7d30de6 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp @@ -74,7 +74,7 @@ Icon_SPU *ThinFenceTile_SPU::getEdgeTexture() #ifndef SN_TARGET_PS3_SPU assert(0); #endif - return NULL; + return nullptr; } bool ThinFenceTile_SPU::attachsTo(int tile) diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h index 61c392010..8f7b601b3 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h @@ -11,7 +11,7 @@ class ThinFenceTile_SPU : public Tile_SPU virtual int getRenderShape(); virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face); virtual void updateDefaultShape(); - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr); // 4J added forceData, forceEntity param virtual Icon_SPU *getEdgeTexture(); bool attachsTo(int tile); }; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp index fd9421af0..22c3a26d3 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp @@ -71,7 +71,7 @@ const float smallUV = ( 1.0f / 16.0f ); void TileRenderer_SPU::_init() { - fixedTexture = NULL; + fixedTexture = nullptr; xFlipTexture = false; noCulling = false; blsmooth = 1; @@ -103,7 +103,7 @@ TileRenderer_SPU::TileRenderer_SPU( ChunkRebuildData* level ) TileRenderer_SPU::TileRenderer_SPU() { - this->level = NULL; + this->level = nullptr; _init(); } @@ -122,12 +122,12 @@ void TileRenderer_SPU::setFixedTexture( Icon_SPU *fixedTexture ) void TileRenderer_SPU::clearFixedTexture() { - this->fixedTexture = NULL; + this->fixedTexture = nullptr; } bool TileRenderer_SPU::hasFixedTexture() { - return fixedTexture != NULL; + return fixedTexture != nullptr; } void TileRenderer_SPU::setShape(float x0, float y0, float z0, float x1, float y1, float z1) @@ -838,7 +838,7 @@ bool TileRenderer_SPU::tesselateFlowerPotInWorld(FlowerPotTile_SPU *tt, int x, i float xOff = 0; float yOff = 4; float zOff = 0; - Tile *plant = NULL; + Tile *plant = nullptr; switch (type) { @@ -858,7 +858,7 @@ bool TileRenderer_SPU::tesselateFlowerPotInWorld(FlowerPotTile_SPU *tt, int x, i t->addOffset(xOff / 16.0f, yOff / 16.0f, zOff / 16.0f); - if (plant != NULL) + if (plant != nullptr) { tesselateInWorld(plant, x, y, z); } @@ -1724,7 +1724,7 @@ bool TileRenderer_SPU::tesselateLeverInWorld( Tile_SPU* tt, int x, int y, int z } } - Vec3* c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL; + Vec3* c0 = nullptr, *c1 = nullptr, *c2 = nullptr, *c3 = nullptr; for ( int i = 0; i < 6; i++ ) { if ( i == 0 ) @@ -1897,7 +1897,7 @@ bool TileRenderer_SPU::tesselateTripwireSourceInWorld(Tile_SPU *tt, int x, int y corners[i]->z += z + 0.5; } - Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL; + Vec3 *c0 = nullptr, *c1 = nullptr, *c2 = nullptr, *c3 = nullptr; int stickX0 = 7; int stickX1 = 9; int stickY0 = 9; @@ -4586,7 +4586,7 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Ti else { /*#ifdef _DEBUG - if(dynamic_cast(tt)!=NULL) + if(dynamic_cast(tt)!=nullptr) { // stair tile faceFlags |= tt->shouldRenderFace( level, pX, pY - 1, pZ, 0 ) ? 0x01 : 0; @@ -7626,7 +7626,7 @@ Icon_SPU *TileRenderer_SPU::getTexture(Tile_SPU *tile) Icon_SPU *TileRenderer_SPU::getTextureOrMissing(Icon_SPU *Icon_SPU) { - if (Icon_SPU == NULL) + if (Icon_SPU == nullptr) { assert(0); // return minecraft->textures->getMissingIcon_SPU(Icon_SPU::TYPE_TERRAIN); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h index 2c484faaa..3f34a778a 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h @@ -72,8 +72,8 @@ class TileRenderer_SPU void tesselateInWorldFixedTexture( Tile_SPU* tile, int x, int y, int z, Icon_SPU *fixedTexture ); // 4J renamed to differentiate from tesselateInWorld void tesselateInWorldNoCulling( Tile_SPU* tile, int x, int y, int z, int forceData = -1, - TileEntity* forceEntity = NULL ); // 4J added forceData, forceEntity param - bool tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL ); // 4J added forceData, forceEntity param + TileEntity* forceEntity = nullptr ); // 4J added forceData, forceEntity param + bool tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr ); // 4J added forceData, forceEntity param private: bool tesselateAirPortalFrameInWorld(TheEndPortalFrameTile *tt, int x, int y, int z); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp index f2dfeaac7..c5a9be4d7 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp @@ -92,7 +92,7 @@ #include #include "AnvilTile_SPU.h" -TileData_SPU* Tile_SPU::ms_pTileData = NULL; +TileData_SPU* Tile_SPU::ms_pTileData = nullptr; Tile_SPU Tile_SPU::m_tiles[256]; @@ -181,7 +181,7 @@ Icon_SPU *Tile_SPU::getTexture(ChunkRebuildData *level, int x, int y, int z, int } - Icon_SPU *icon = NULL; + Icon_SPU *icon = nullptr; if(opaque) { LeafTile_SPU::setFancy(false); @@ -215,13 +215,13 @@ Icon_SPU *Tile_SPU::getTexture(int face) // void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, Entity *source) // { // AABB *aabb = getAABB(level, x, y, z); -// if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb); +// if (aabb != nullptr && box->intersects(aabb)) boxes->push_back(aabb); // } // // void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes) // { // AABB *aabb = getAABB(level, x, y, z); -// if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb); +// if (aabb != nullptr && box->intersects(aabb)) boxes->push_back(aabb); // } // // AABB *Tile_SPU::getAABB(Level *level, int x, int y, int z) @@ -368,18 +368,18 @@ Icon_SPU *Tile_SPU::getTexture(int face) // Vec3 *zh0 = a->clipZ(b, zz0); // Vec3 *zh1 = a->clipZ(b, zz1); // -// Vec3 *closest = NULL; +// Vec3 *closest = nullptr; // -// if (containsX(xh0) && (closest == NULL || a->distanceTo(xh0) < a->distanceTo(closest))) closest = xh0; -// if (containsX(xh1) && (closest == NULL || a->distanceTo(xh1) < a->distanceTo(closest))) closest = xh1; -// if (containsY(yh0) && (closest == NULL || a->distanceTo(yh0) < a->distanceTo(closest))) closest = yh0; -// if (containsY(yh1) && (closest == NULL || a->distanceTo(yh1) < a->distanceTo(closest))) closest = yh1; -// if (containsZ(zh0) && (closest == NULL || a->distanceTo(zh0) < a->distanceTo(closest))) closest = zh0; -// if (containsZ(zh1) && (closest == NULL || a->distanceTo(zh1) < a->distanceTo(closest))) closest = zh1; +// if (containsX(xh0) && (closest == nullptr || a->distanceTo(xh0) < a->distanceTo(closest))) closest = xh0; +// if (containsX(xh1) && (closest == nullptr || a->distanceTo(xh1) < a->distanceTo(closest))) closest = xh1; +// if (containsY(yh0) && (closest == nullptr || a->distanceTo(yh0) < a->distanceTo(closest))) closest = yh0; +// if (containsY(yh1) && (closest == nullptr || a->distanceTo(yh1) < a->distanceTo(closest))) closest = yh1; +// if (containsZ(zh0) && (closest == nullptr || a->distanceTo(zh0) < a->distanceTo(closest))) closest = zh0; +// if (containsZ(zh1) && (closest == nullptr || a->distanceTo(zh1) < a->distanceTo(closest))) closest = zh1; // // LeaveCriticalSection(&m_csShape); // -// if (closest == NULL) return NULL; +// if (closest == nullptr) return nullptr; // // int face = -1; // @@ -395,19 +395,19 @@ Icon_SPU *Tile_SPU::getTexture(int face) // // bool Tile_SPU::containsX(Vec3 *v) // { -// if( v == NULL) return false; +// if( v == nullptr) return false; // return v->y >= yy0 && v->y <= yy1 && v->z >= zz0 && v->z <= zz1; // } // // bool Tile_SPU::containsY(Vec3 *v) // { -// if( v == NULL) return false; +// if( v == nullptr) return false; // return v->x >= xx0 && v->x <= xx1 && v->z >= zz0 && v->z <= zz1; // } // // bool Tile_SPU::containsZ(Vec3 *v) // { -// if( v == NULL) return false; +// if( v == nullptr) return false; // return v->x >= xx0 && v->x <= xx1 && v->y >= yy0 && v->y <= yy1; // } // @@ -516,7 +516,7 @@ void Tile_SPU::updateDefaultShape() // // 4J Stu - Special case - only record a crop destroy if is fully grown // if(id==Tile_SPU::crops_Id) // { -// if( Tile_SPU::crops->getResource(data, NULL, 0) > 0 ) +// if( Tile_SPU::crops->getResource(data, nullptr, 0) > 0 ) // player->awardStat(Stats::blocksMined[id], 1); // } // else @@ -533,7 +533,7 @@ void Tile_SPU::updateDefaultShape() // if (isCubeShaped() && !isEntityTile[id] && EnchantmentHelper::hasSilkTouch(player->inventory)) // { // shared_ptr item = getSilkTouchItemInstance(data); -// if (item != NULL) +// if (item != nullptr) // { // popResource(level, x, y, z, item); // } @@ -625,7 +625,7 @@ float Tile_SPU::getShadeBrightness(ChunkRebuildData *level, int x, int y, int z) Tile_SPU* Tile_SPU::createFromID( int tileID ) { if(tileID == 0) - return NULL; + return nullptr; if(m_tiles[tileID].id != -1) return &m_tiles[tileID]; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h index 484823efa..e3d11f044 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h @@ -242,7 +242,7 @@ class TileData_SPU Icon_SPU *getTexture(int face, int data); Icon_SPU *getTexture(int face); public: - void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param + void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr); // 4J added forceData, forceEntity param double getShapeX0(); double getShapeX1(); double getShapeY0(); @@ -465,7 +465,7 @@ class Tile_SPU double getShapeZ1() { return ms_pTileData->zz1[id]; } Material_SPU* getMaterial(); - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr); // 4J added forceData, forceEntity param virtual void updateDefaultShape(); virtual void setShape(float x0, float y0, float z0, float x1, float y1, float z1); virtual float getBrightness(ChunkRebuildData *level, int x, int y, int z); diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h index 2b5f86a58..43cffbf8e 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h @@ -14,7 +14,7 @@ class TopSnowTile_SPU : public Tile_SPU bool blocksLight() { return false; } bool isSolidRender(bool isServerLevel = false) { return false; } bool isCubeShaped() { return false; } - void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { int height = level->getData(x, y, z) & HEIGHT_MASK; float o = 2 * (1 + height) / 16.0f; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h index 6f096a17f..4f72c543f 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h @@ -21,7 +21,7 @@ class TrapDoorTile_SPU : public Tile_SPU bool isSolidRender(bool isServerLevel = false) { return false; } bool isCubeShaped() { return false; } int getRenderShape() { return Tile_SPU::SHAPE_BLOCK;} - void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { setShape(level->getData(x, y, z)); } diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h index e2f4a4ad4..7d94e750d 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h @@ -27,7 +27,7 @@ class VineTile_SPU : public Tile_SPU return false; } - virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param + virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = nullptr) // 4J added forceData, forceEntity param { const float thickness = 1.0f / 16.0f; diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h index e298ae2dc..7065210fe 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h +++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h @@ -172,15 +172,15 @@ class GL11 // { // public: // ZipFile(File *file) {} -// InputStream *getInputStream(ZipEntry *entry) { return NULL; } -// ZipEntry *getEntry(const wstring& name) {return NULL;} +// InputStream *getInputStream(ZipEntry *entry) { return nullptr; } +// ZipEntry *getEntry(const wstring& name) {return nullptr;} // void close() {} // }; // // class ImageIO // { // public: -// static BufferedImage *read(InputStream *in) { return NULL; } +// static BufferedImage *read(InputStream *in) { return nullptr; } // }; // // class Keyboard diff --git a/Minecraft.Client/PS3/SPU_Tasks/CompressedTile/CompressedTileStorage_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/CompressedTile/CompressedTileStorage_SPU.cpp index dc134ecaf..16ea17bb5 100644 --- a/Minecraft.Client/PS3/SPU_Tasks/CompressedTile/CompressedTileStorage_SPU.cpp +++ b/Minecraft.Client/PS3/SPU_Tasks/CompressedTile/CompressedTileStorage_SPU.cpp @@ -315,7 +315,7 @@ void TileCompressData_SPU::loadAndUncompressLowerSection(int block, int x0, int // tile IDs first // --------------------------- - if(m_lowerBlocks[block] != NULL) + if(m_lowerBlocks[block] != nullptr) { int dmaSize = padTo16(m_lowerBlocksSize[block]); DmaData_SPU::getAndWait(m_pTileStorage->getDataPtr(), (uint32_t)m_lowerBlocks[block], dmaSize); @@ -366,7 +366,7 @@ void TileCompressData_SPU::loadAndUncompressLowerSection(int block, int x0, int void TileCompressData_SPU::loadAndUncompressUpperSection(int block, int x0, int z0, int x1, int z1) { - if(m_upperBlocks[block] != NULL) + if(m_upperBlocks[block] != nullptr) { int dmaSize = padTo16(m_upperBlocksSize[block]); DmaData_SPU::getAndWait(m_pTileStorage->getDataPtr(), (uint32_t)m_upperBlocks[block], dmaSize); @@ -507,7 +507,7 @@ void TileCompressData_SPU::setForChunk( Region* region, int x0, int y0, int z0 ) } else { - m_lowerBlocks[i*3+j] = NULL; + m_lowerBlocks[i*3+j] = nullptr; m_lowerBlocksSize[i*3+j] = 0; m_lowerSkyLight[i*3+j] = 0; m_lowerBlockLight[i*3+j] = 0; @@ -527,7 +527,7 @@ void TileCompressData_SPU::setForChunk( Region* region, int x0, int y0, int z0 ) } else { - m_upperBlocks[i*3+j] = NULL; + m_upperBlocks[i*3+j] = nullptr; m_upperBlocksSize[i*3+j] = 0; m_upperSkyLight[i*3+j] = 0; m_upperBlockLight[i*3+j] = 0; diff --git a/Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h b/Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h index c0209eb66..644ab3e74 100644 --- a/Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h @@ -145,8 +145,8 @@ class C_4JInput void SetMenuDisplayed(int iPad, bool bVal); -// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); -// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); +// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); +// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); void GetText(uint16_t *UTF16String); diff --git a/Minecraft.Client/PSVita/4JLibs/inc/4J_Profile.h b/Minecraft.Client/PSVita/4JLibs/inc/4J_Profile.h index ab6b6131f..4c1f4e013 100644 --- a/Minecraft.Client/PSVita/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/PSVita/4JLibs/inc/4J_Profile.h @@ -191,7 +191,7 @@ class C_4JProfile ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void InitialiseTrophies(); //CD - Don't use this, auto setup after login void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false, - CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L); + CXuiStringTable*pStringTable=nullptr, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=nullptr, unsigned int uiThemeSize=0L); int GetAwardId(int iAwardNumber); eAwardType GetAwardType(int iAwardNumber); bool CanBeAwarded(int iQuadrant, int iAwardNumber); diff --git a/Minecraft.Client/PSVita/4JLibs/inc/4J_Render.h b/Minecraft.Client/PSVita/4JLibs/inc/4J_Render.h index b08c9fba6..e5d19e20e 100644 --- a/Minecraft.Client/PSVita/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/PSVita/4JLibs/inc/4J_Render.h @@ -20,8 +20,8 @@ class ImageFileBuffer int GetType() { return m_type; } void *GetBufferPointer() { return m_pBuffer; } int GetBufferSize() { return m_bufferSize; } - void Release() { free(m_pBuffer); m_pBuffer = NULL; } - bool Allocated() { return m_pBuffer != NULL; } + void Release() { free(m_pBuffer); m_pBuffer = nullptr; } + bool Allocated() { return m_pBuffer != nullptr; } }; typedef struct @@ -63,7 +63,7 @@ class C4JRender void InitialiseContext(); void StartFrame(); void Present(); - void Clear(int flags, D3D11_RECT *pRect = NULL); + void Clear(int flags, D3D11_RECT *pRect = nullptr); void SetClearColour(const float colourRGBA[4]); bool IsWidescreen(); bool IsHiDef(); diff --git a/Minecraft.Client/PSVita/4JLibs/inc/4J_Storage.h b/Minecraft.Client/PSVita/4JLibs/inc/4J_Storage.h index 552c247d4..4c9219a9f 100644 --- a/Minecraft.Client/PSVita/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/PSVita/4JLibs/inc/4J_Storage.h @@ -298,7 +298,7 @@ class C4JStorage // Get details of existing savedata C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(LPVOID lpParam,SAVE_DETAILS *pSaveDetails,const bool),LPVOID lpParam,char *pszSavePackName); // Start search - PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or NULL if not yet received) + PSAVE_DETAILS ReturnSavesInfo(); // Returns result of search (or nullptr if not yet received) void ClearSavesInfo(); // Clears results C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam); // Get the thumbnail for an individual save referenced by pSaveInfo @@ -374,8 +374,8 @@ class C4JStorage EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); CONTENT_DATA& GetDLC(DWORD dw); DWORD GetAvailableDLCCount( int iPad ); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = NULL); - DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive = nullptr); + DWORD UnmountInstalledDLC(LPCSTR szMountDrive = nullptr); void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); std::string GetMountedPath(std::string szMount); void SetDLCProductCode(const char* szProductCode); diff --git a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2.cpp b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2.cpp index fc5b190ad..7594f7ec9 100644 --- a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2.cpp +++ b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2.cpp @@ -311,7 +311,7 @@ extern "C" void gdraw_psp2_wait(U64 fence_val) // // (once or several times) here // SceGxmNotification notify = gdraw_psp2_End(); // // --- again, may issue rendering calls here (but not draw Iggys) - // sceGxmEndScene(imm_ctx, NULL, ¬ify); + // sceGxmEndScene(imm_ctx, nullptr, ¬ify); // // That is, exactly one gdraw_psp2_Begin/_End pair for that scene, and // all IggyPlayerDraws must be inside that pair. That's it. @@ -360,7 +360,7 @@ static void gdraw_gpu_memcpy(GDrawHandleCache *c, void *dst, void *src, U32 num_ 0, 0, SCE_GXM_TRANSFER_COLORKEY_NONE, SCE_GXM_TRANSFER_FORMAT_RAW128, SCE_GXM_TRANSFER_LINEAR, srcp + offs, 0, 0, row_size, SCE_GXM_TRANSFER_FORMAT_RAW128, SCE_GXM_TRANSFER_LINEAR, dstp + offs, 0, 0, row_size, - NULL, 0, NULL); + nullptr, 0, nullptr); offs += num_rows * row_size; } @@ -375,7 +375,7 @@ static void gdraw_gpu_memcpy(GDrawHandleCache *c, void *dst, void *src, U32 num_ 0, 0, SCE_GXM_TRANSFER_COLORKEY_NONE, SCE_GXM_TRANSFER_FORMAT_RAW128, SCE_GXM_TRANSFER_LINEAR, srcp + offs, 0, 0, row_size, SCE_GXM_TRANSFER_FORMAT_RAW128, SCE_GXM_TRANSFER_LINEAR, dstp + offs, 0, 0, row_size, - NULL, 0, NULL); + nullptr, 0, nullptr); } if (c->is_vertex) @@ -436,7 +436,7 @@ static void api_free_resource(GDrawHandle *r) if (!r->cache->is_vertex) { for (S32 i=0; i < MAX_SAMPLERS; i++) if (gdraw->active_tex[i] == (GDrawTexture *) r) - gdraw->active_tex[i] = NULL; + gdraw->active_tex[i] = nullptr; } } @@ -462,7 +462,7 @@ static void track_dynamic_alloc_attempt(U32 size, U32 align) static void track_dynamic_alloc_failed() { if (gdraw->dynamic_stats.allocs_attempted == gdraw->dynamic_stats.allocs_succeeded + 1) { // warn the first time we run out of mem - IggyGDrawSendWarning(NULL, "GDraw out of dynamic memory"); + IggyGDrawSendWarning(nullptr, "GDraw out of dynamic memory"); } } @@ -506,7 +506,7 @@ GDrawTexture * RADLINK gdraw_psp2_WrappedTextureCreate(SceGxmTexture *tex) { GDrawStats stats = {}; GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats); - gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned); + gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned); gdraw_psp2_WrappedTextureChange((GDrawTexture *) p, tex); return (GDrawTexture *) p; } @@ -561,11 +561,11 @@ static U32 tex_linear_stride(U32 width) static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format gformat, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) { S32 bytes_pixel = 4; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; SceGxmTextureFormat format = SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR; if (width > MAX_TEXTURE2D_DIM || height > MAX_TEXTURE2D_DIM) { - IggyGDrawSendWarning(NULL, "GDraw %d x %d texture not supported by hardware (dimension limit %d)", width, height, MAX_TEXTURE2D_DIM); + IggyGDrawSendWarning(nullptr, "GDraw %d x %d texture not supported by hardware (dimension limit %d)", width, height, MAX_TEXTURE2D_DIM); return false; } @@ -611,7 +611,7 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, if (flags & GDRAW_MAKETEXTURE_FLAGS_mipmap) { rrbool ok; - assert(p->temp_buffer != NULL); + assert(p->temp_buffer != nullptr); ok = gdraw_MipmapBegin(&gdraw->mipmap, width, height, mipmaps, bytes_pixel, p->temp_buffer, p->temp_buffer_bytes); if (!ok) @@ -626,7 +626,7 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, p->i2 = height; } else { // non-mipmapped textures, we just upload straight to their destination - p->p1 = NULL; + p->p1 = nullptr; p->texture_data = (U8 *)t->raw_ptr; p->num_rows = height; p->stride_in_bytes = base_stride * bytes_pixel; @@ -723,8 +723,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void *unique_id, GDr static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats) { GDrawHandle *t = (GDrawHandle *) tt; - assert(t != NULL); - if (t->owner == unique_id || unique_id == NULL) { + assert(t != nullptr); + if (t->owner == unique_id || unique_id == nullptr) { gdraw_res_kill(t, stats); } } @@ -744,7 +744,7 @@ static void RADLINK gdraw_DescribeTexture(GDrawTexture *tex, GDraw_Texture_Descr static void RADLINK gdraw_SetAntialiasTexture(S32 width, U8 *rgba) { - if (sceGxmTextureGetData(&gdraw->aa_tex) != NULL) + if (sceGxmTextureGetData(&gdraw->aa_tex) != nullptr) return; assert(width <= MAX_AATEX_WIDTH); @@ -801,7 +801,7 @@ static rrbool RADLINK gdraw_TryLockVertexBuffer(GDrawVertexBuffer *vb, void *uni static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) { GDrawHandle *h = (GDrawHandle *) vb; - assert(h != NULL); // @GDRAW_ASSERT + assert(h != nullptr); // @GDRAW_ASSERT if (h->owner == unique_id) gdraw_res_kill(h, stats); } @@ -931,8 +931,8 @@ static void set_common_renderstate() // clear our state caching memset(gdraw->active_tex, 0, sizeof(gdraw->active_tex)); gdraw->scissor_state = 0; - gdraw->cur_fp = NULL; - gdraw->cur_vp = NULL; + gdraw->cur_fp = nullptr; + gdraw->cur_vp = nullptr; // all the state we won't touch again until we're done rendering sceGxmSetCullMode(gxm, SCE_GXM_CULL_NONE); @@ -1032,7 +1032,7 @@ static void RADLINK gdraw_SetViewSizeAndWorldScale(S32 w, S32 h, F32 scalex, F32 // must include anything necessary for texture creation/update static void RADLINK gdraw_RenderingBegin(void) { - assert(gdraw->gxm != NULL); // call after gdraw_psp2_Begin + assert(gdraw->gxm != nullptr); // call after gdraw_psp2_Begin set_common_renderstate(); } @@ -1061,7 +1061,7 @@ static void RADLINK gdraw_RenderTileBegin(S32 x0, S32 y0, S32 x1, S32 y1, S32 pa // clear our depth/stencil buffers (and also color if requested) clear_whole_surf(true, true, gdraw->next_tile_clear, stats); - gdraw->next_tile_clear = NULL; + gdraw->next_tile_clear = nullptr; } static void RADLINK gdraw_RenderTileEnd(GDrawStats *stats) @@ -1079,7 +1079,7 @@ void gdraw_psp2_Begin(SceGxmContext *context, const SceGxmColorSurface *color, c { U32 xmin, ymin, xmax, ymax; - assert(gdraw->gxm == NULL); // may not nest Begin calls + assert(gdraw->gxm == nullptr); // may not nest Begin calls // need to wait for the buffer to become idle before we can use it! gdraw_psp2_WaitForDynamicBufferIdle(dynamic_buf); @@ -1106,7 +1106,7 @@ void gdraw_psp2_Begin(SceGxmContext *context, const SceGxmColorSurface *color, c // - We need the stencil buffer to support Flash masking operations. // - We need the mask bit to perform pixel-accurate scissor testing. // There's only one format that satisfies both requirements. - IggyGDrawSendWarning(NULL, "Iggy rendering will not work correctly unless a depth/stencil buffer in DF32M_S8 format is provided."); + IggyGDrawSendWarning(nullptr, "Iggy rendering will not work correctly unless a depth/stencil buffer in DF32M_S8 format is provided."); } // For immediate contexts, we need to flush pending vertex transfers before @@ -1125,15 +1125,15 @@ SceGxmNotification gdraw_psp2_End() GDrawStats gdraw_stats = {}; SceGxmNotification notify; - assert(gdraw->gxm != NULL); // please keep Begin / End pairs properly matched + assert(gdraw->gxm != nullptr); // please keep Begin / End pairs properly matched notify = scene_end_notification(); gdraw->dyn_buf->sync = gdraw->scene_end_fence.value; gdraw->dyn_buf->stats = gdraw->dynamic_stats; - gdraw_arena_init(&gdraw->dynamic, NULL, 0); - gdraw->gxm = NULL; - gdraw->dyn_buf = NULL; + gdraw_arena_init(&gdraw->dynamic, nullptr, 0); + gdraw->gxm = nullptr; + gdraw->dyn_buf = nullptr; // NOTE: the stats from these go nowhere. That's a bit unfortunate, but the // GDrawStats model is that things can be accounted to something in the @@ -1173,13 +1173,13 @@ static void RADLINK gdraw_GetInfo(GDrawInfo *d) static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_texture_format format, U32 flags, void *owner, GDrawStats *stats) { - IggyGDrawSendWarning(NULL, "GDraw no rendertarget support on PSP2"); + IggyGDrawSendWarning(nullptr, "GDraw no rendertarget support on PSP2"); return false; } static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats) { - return NULL; + return nullptr; } //////////////////////////////////////////////////////////////////////// @@ -1190,13 +1190,13 @@ static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats) static void RADLINK gdraw_ClearStencilBits(U32 bits) { GDrawStats stats = {}; - clear_whole_surf(false, true, NULL, &stats); + clear_whole_surf(false, true, nullptr, &stats); } static void RADLINK gdraw_ClearID(void) { GDrawStats stats = {}; - clear_whole_surf(true, false, NULL, &stats); + clear_whole_surf(true, false, nullptr, &stats); } //////////////////////////////////////////////////////////////////////// @@ -1451,7 +1451,7 @@ static GDrawHandle *check_resource(void *ptr) #define check_resource(ptr) ((GDrawHandle *)(ptr)) #endif -static RADINLINE void fence_resources(void *r1, void *r2=NULL, void *r3=NULL) +static RADINLINE void fence_resources(void *r1, void *r2=nullptr, void *r3=nullptr) { GDrawFence fence = get_next_fence(); if (r1) check_resource(r1)->fence = fence; @@ -1592,7 +1592,7 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 // actual filter effects and special blends aren't supported on PSP2. if (r->blend_mode == GDRAW_BLEND_filter || r->blend_mode == GDRAW_BLEND_special) { - IggyGDrawSendWarning(NULL, "GDraw no filter or special blend support on PSP2"); + IggyGDrawSendWarning(nullptr, "GDraw no filter or special blend support on PSP2"); // just don't do anything. } else { // just a plain quad. @@ -1614,7 +1614,7 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 static bool gxm_check(SceGxmErrorCode err) { if (err != SCE_OK) - IggyGDrawSendWarning(NULL, "GXM error"); + IggyGDrawSendWarning(nullptr, "GXM error"); return err == SCE_OK; } @@ -1643,9 +1643,9 @@ static bool register_and_create_vertex_prog(SceGxmVertexProgram **out_prog, SceG SceGxmVertexStream stream; if (!register_shader(patcher, shader)) - return NULL; + return nullptr; - *out_prog = NULL; + *out_prog = nullptr; if (attr_bytes) { attr.streamIndex = 0; @@ -1659,7 +1659,7 @@ static bool register_and_create_vertex_prog(SceGxmVertexProgram **out_prog, SceG return gxm_check(sceGxmShaderPatcherCreateVertexProgram(patcher, shader->id, &attr, 1, &stream, 1, out_prog)); } else - return gxm_check(sceGxmShaderPatcherCreateVertexProgram(patcher, shader->id, NULL, 0, NULL, 0, out_prog)); + return gxm_check(sceGxmShaderPatcherCreateVertexProgram(patcher, shader->id, nullptr, 0, nullptr, 0, out_prog)); } static void destroy_vertex_prog(SceGxmShaderPatcher *patcher, SceGxmVertexProgram *prog) @@ -1670,8 +1670,8 @@ static void destroy_vertex_prog(SceGxmShaderPatcher *patcher, SceGxmVertexProgra static bool create_fragment_prog(SceGxmFragmentProgram **out_prog, SceGxmShaderPatcher *patcher, ShaderCode *shader, const SceGxmBlendInfo *blend, SceGxmOutputRegisterFormat out_fmt) { - *out_prog = NULL; - return gxm_check(sceGxmShaderPatcherCreateFragmentProgram(patcher, shader->id, out_fmt, SCE_GXM_MULTISAMPLE_NONE, blend, NULL, out_prog)); + *out_prog = nullptr; + return gxm_check(sceGxmShaderPatcherCreateFragmentProgram(patcher, shader->id, out_fmt, SCE_GXM_MULTISAMPLE_NONE, blend, nullptr, out_prog)); } static void destroy_fragment_prog(SceGxmShaderPatcher *patcher, SceGxmFragmentProgram *prog) @@ -1731,10 +1731,10 @@ static bool create_all_programs(SceGxmOutputRegisterFormat reg_format) } if (!register_shader(patcher, pshader_manual_clear_arr) || - !create_fragment_prog(&gdraw->clear_fp, patcher, pshader_manual_clear_arr, NULL, reg_format)) + !create_fragment_prog(&gdraw->clear_fp, patcher, pshader_manual_clear_arr, nullptr, reg_format)) return false; - gdraw->mask_update_fp = NULL; + gdraw->mask_update_fp = nullptr; return gxm_check(sceGxmShaderPatcherCreateMaskUpdateFragmentProgram(patcher, &gdraw->mask_update_fp)); } @@ -1786,7 +1786,7 @@ static GDrawHandleCache *make_handle_cache(gdraw_psp2_resourcetype type, U32 ali one_pool_bytes = align_down(one_pool_bytes / 2, align); if (one_pool_bytes < (S32)align) - return NULL; + return nullptr; cache = (GDrawHandleCache *) IggyGDrawMalloc(cache_size + header_size); if (cache) { @@ -1805,7 +1805,7 @@ static GDrawHandleCache *make_handle_cache(gdraw_psp2_resourcetype type, U32 ali cache->alloc = gfxalloc_create(gdraw_limits[type].ptr, one_pool_bytes, align, num_handles); if (!cache->alloc) { IggyGDrawFree(cache); - return NULL; + return nullptr; } if (use_twopool) { @@ -1813,7 +1813,7 @@ static GDrawHandleCache *make_handle_cache(gdraw_psp2_resourcetype type, U32 ali if (!cache->alloc_other) { IggyGDrawFree(cache->alloc); IggyGDrawFree(cache); - return NULL; + return nullptr; } // two dummy copies to make sure we have gpu read/write access @@ -1898,12 +1898,12 @@ int gdraw_psp2_SetResourceMemory(gdraw_psp2_resourcetype type, S32 num_handles, case GDRAW_PSP2_RESOURCE_texture: free_handle_cache(gdraw->texturecache); gdraw->texturecache = make_handle_cache(GDRAW_PSP2_RESOURCE_texture, GDRAW_PSP2_TEXTURE_ALIGNMENT, true); - return gdraw->texturecache != NULL; + return gdraw->texturecache != nullptr; case GDRAW_PSP2_RESOURCE_vertexbuffer: free_handle_cache(gdraw->vbufcache); gdraw->vbufcache = make_handle_cache(GDRAW_PSP2_RESOURCE_vertexbuffer, GDRAW_PSP2_VERTEXBUFFER_ALIGNMENT, true); - return gdraw->vbufcache != NULL; + return gdraw->vbufcache != nullptr; default: return 0; @@ -1912,8 +1912,8 @@ int gdraw_psp2_SetResourceMemory(gdraw_psp2_resourcetype type, S32 num_handles, void gdraw_psp2_ResetAllResourceMemory() { - gdraw_psp2_SetResourceMemory(GDRAW_PSP2_RESOURCE_texture, 0, NULL, 0); - gdraw_psp2_SetResourceMemory(GDRAW_PSP2_RESOURCE_vertexbuffer, 0, NULL, 0); + gdraw_psp2_SetResourceMemory(GDRAW_PSP2_RESOURCE_texture, 0, nullptr, 0); + gdraw_psp2_SetResourceMemory(GDRAW_PSP2_RESOURCE_vertexbuffer, 0, nullptr, 0); } GDrawFunctions *gdraw_psp2_CreateContext(SceGxmShaderPatcher *shader_patcher, void *context_mem, volatile U32 *notification, SceGxmOutputRegisterFormat reg_format) @@ -1935,7 +1935,7 @@ GDrawFunctions *gdraw_psp2_CreateContext(SceGxmShaderPatcher *shader_patcher, vo }; gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw)); - if (!gdraw) return NULL; + if (!gdraw) return nullptr; memset(gdraw, 0, sizeof(*gdraw)); @@ -1961,7 +1961,7 @@ GDrawFunctions *gdraw_psp2_CreateContext(SceGxmShaderPatcher *shader_patcher, vo if (!gdraw->quad_ib || !gdraw->mask_ib || !create_all_programs(reg_format)) { gdraw_psp2_DestroyContext(); - return NULL; + return nullptr; } // init quad index buffer @@ -1977,7 +1977,7 @@ GDrawFunctions *gdraw_psp2_CreateContext(SceGxmShaderPatcher *shader_patcher, vo gdraw->mask_draw_gpu = gdraw_arena_alloc(&gdraw->context_arena, sceGxmGetPrecomputedDrawSize(gdraw->mask_vp), SCE_GXM_PRECOMPUTED_ALIGNMENT); if (!gdraw->mask_draw_gpu) { gdraw_psp2_DestroyContext(); - return NULL; + return nullptr; } memcpy(gdraw->mask_ib, mask_ib_data, sizeof(mask_ib_data)); @@ -2048,7 +2048,7 @@ void gdraw_psp2_DestroyContext(void) free_handle_cache(gdraw->vbufcache); destroy_all_programs(); IggyGDrawFree(gdraw); - gdraw = NULL; + gdraw = nullptr; } } @@ -2070,7 +2070,7 @@ void RADLINK gdraw_psp2_EndCustomDraw(IggyCustomDrawCallbackRegion *region) GDrawTexture * RADLINK gdraw_psp2_MakeTextureFromResource(U8 *file_in_memory, S32 len, IggyFileTexturePSP2 *tex) { - SceGxmErrorCode (*init_func)(SceGxmTexture *texture, const void *data, SceGxmTextureFormat texFormat, uint32_t width, uint32_t height, uint32_t mipCount) = NULL; + SceGxmErrorCode (*init_func)(SceGxmTexture *texture, const void *data, SceGxmTextureFormat texFormat, uint32_t width, uint32_t height, uint32_t mipCount) = nullptr; switch (tex->texture.type) { case SCE_GXM_TEXTURE_SWIZZLED: init_func = sceGxmTextureInitSwizzled; break; @@ -2080,15 +2080,15 @@ GDrawTexture * RADLINK gdraw_psp2_MakeTextureFromResource(U8 *file_in_memory, S3 } if (!init_func) { - IggyGDrawSendWarning(NULL, "Unsupported texture type in MakeTextureFromResource"); - return NULL; + IggyGDrawSendWarning(nullptr, "Unsupported texture type in MakeTextureFromResource"); + return nullptr; } SceGxmTexture gxm; SceGxmErrorCode err = init_func(&gxm, file_in_memory + tex->file_offset, (SceGxmTextureFormat)tex->texture.format, tex->texture.width, tex->texture.height, tex->texture.mip_count); if (err != SCE_OK) { - IggyGDrawSendWarning(NULL, "Texture init failed in MakeTextureFromResource (bad data?)"); - return NULL; + IggyGDrawSendWarning(nullptr, "Texture init failed in MakeTextureFromResource (bad data?)"); + return nullptr; } return gdraw_psp2_WrappedTextureCreate(&gxm); diff --git a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2.h b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2.h index a606fbe3b..da31de707 100644 --- a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2.h +++ b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2.h @@ -68,7 +68,7 @@ IDOC extern int gdraw_psp2_SetResourceMemory(gdraw_psp2_resourcetype type, S32 n mapped to the GPU and *writeable*. If it isn't, the GPU will crash during either this function or CreateContext! - Pass in NULL for "ptr" and zero "num_bytes" to free the memory allocated to + Pass in nullptr for "ptr" and zero "num_bytes" to free the memory allocated to a specific pool. GDraw can run into cases where resource memory gets fragmented; we defragment @@ -121,7 +121,7 @@ IDOC extern GDrawFunctions * gdraw_psp2_CreateContext(SceGxmShaderPatcher *shade be valid for as long as a GDraw context is alive. If initialization fails for some reason (the main reason would be an out of memory condition), - NULL is returned. Otherwise, you can pass the return value to IggySetGDraw. */ + nullptr is returned. Otherwise, you can pass the return value to IggySetGDraw. */ IDOC extern void gdraw_psp2_DestroyContext(void); /* Destroys the current GDraw context, if any. diff --git a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2_shaders.inl b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2_shaders.inl index 9e2870eb2..6b0448f5c 100644 --- a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2_shaders.inl +++ b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_psp2_shaders.inl @@ -532,24 +532,24 @@ static unsigned char pshader_basic_17[436] = { }; static ShaderCode pshader_basic_arr[18] = { - { pshader_basic_0, { NULL } }, - { pshader_basic_1, { NULL } }, - { pshader_basic_2, { NULL } }, - { pshader_basic_3, { NULL } }, - { pshader_basic_4, { NULL } }, - { pshader_basic_5, { NULL } }, - { pshader_basic_6, { NULL } }, - { pshader_basic_7, { NULL } }, - { pshader_basic_8, { NULL } }, - { pshader_basic_9, { NULL } }, - { pshader_basic_10, { NULL } }, - { pshader_basic_11, { NULL } }, - { pshader_basic_12, { NULL } }, - { pshader_basic_13, { NULL } }, - { pshader_basic_14, { NULL } }, - { pshader_basic_15, { NULL } }, - { pshader_basic_16, { NULL } }, - { pshader_basic_17, { NULL } }, + { pshader_basic_0, { nullptr } }, + { pshader_basic_1, { nullptr } }, + { pshader_basic_2, { nullptr } }, + { pshader_basic_3, { nullptr } }, + { pshader_basic_4, { nullptr } }, + { pshader_basic_5, { nullptr } }, + { pshader_basic_6, { nullptr } }, + { pshader_basic_7, { nullptr } }, + { pshader_basic_8, { nullptr } }, + { pshader_basic_9, { nullptr } }, + { pshader_basic_10, { nullptr } }, + { pshader_basic_11, { nullptr } }, + { pshader_basic_12, { nullptr } }, + { pshader_basic_13, { nullptr } }, + { pshader_basic_14, { nullptr } }, + { pshader_basic_15, { nullptr } }, + { pshader_basic_16, { nullptr } }, + { pshader_basic_17, { nullptr } }, }; static unsigned char pshader_manual_clear_0[220] = { @@ -570,7 +570,7 @@ static unsigned char pshader_manual_clear_0[220] = { }; static ShaderCode pshader_manual_clear_arr[1] = { - { pshader_manual_clear_0, { NULL } }, + { pshader_manual_clear_0, { nullptr } }, }; static unsigned char vshader_vspsp2_0[360] = { @@ -664,9 +664,9 @@ static unsigned char vshader_vspsp2_2[336] = { }; static ShaderCode vshader_vspsp2_arr[3] = { - { vshader_vspsp2_0, { NULL } }, - { vshader_vspsp2_1, { NULL } }, - { vshader_vspsp2_2, { NULL } }, + { vshader_vspsp2_0, { nullptr } }, + { vshader_vspsp2_1, { nullptr } }, + { vshader_vspsp2_2, { nullptr } }, }; static unsigned char vshader_vspsp2_mask_0[304] = { @@ -692,6 +692,6 @@ static unsigned char vshader_vspsp2_mask_0[304] = { }; static ShaderCode vshader_vspsp2_mask_arr[1] = { - { vshader_vspsp2_mask_0, { NULL } }, + { vshader_vspsp2_mask_0, { nullptr } }, }; diff --git a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_shared.inl index ab78cd93a..6a439d8f1 100644 --- a/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/PSVita/Iggy/gdraw/gdraw_shared.inl @@ -226,7 +226,7 @@ static void debug_check_raw_values(GDrawHandleCache *c) s = s->next; } s = c->active; - while (s != NULL) { + while (s != nullptr) { assert(s->raw_ptr != t->raw_ptr); s = s->next; } @@ -433,7 +433,7 @@ static rrbool gdraw_HandleCacheLockStats(GDrawHandle *t, void *owner, GDrawStats static rrbool gdraw_HandleCacheLock(GDrawHandle *t, void *owner) { - return gdraw_HandleCacheLockStats(t, owner, NULL); + return gdraw_HandleCacheLockStats(t, owner, nullptr); } static void gdraw_HandleCacheUnlock(GDrawHandle *t) @@ -461,11 +461,11 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->is_thrashing = false; c->did_defragment = false; for (i=0; i < GDRAW_HANDLE_STATE__count; i++) { - c->state[i].owner = NULL; - c->state[i].cache = NULL; // should never follow cache link from sentinels! + c->state[i].owner = nullptr; + c->state[i].cache = nullptr; // should never follow cache link from sentinels! c->state[i].next = c->state[i].prev = &c->state[i]; #ifdef GDRAW_MANAGE_MEM - c->state[i].raw_ptr = NULL; + c->state[i].raw_ptr = nullptr; #endif c->state[i].fence.value = 0; c->state[i].bytes = 0; @@ -478,7 +478,7 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->handle[i].bytes = 0; c->handle[i].state = GDRAW_HANDLE_STATE_free; #ifdef GDRAW_MANAGE_MEM - c->handle[i].raw_ptr = NULL; + c->handle[i].raw_ptr = nullptr; #endif } c->state[GDRAW_HANDLE_STATE_free].next = &c->handle[0]; @@ -486,10 +486,10 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->prev_frame_start.value = 0; c->prev_frame_end.value = 0; #ifdef GDRAW_MANAGE_MEM - c->alloc = NULL; + c->alloc = nullptr; #endif #ifdef GDRAW_MANAGE_MEM_TWOPOOL - c->alloc_other = NULL; + c->alloc_other = nullptr; #endif check_lists(c); } @@ -497,14 +497,14 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte static GDrawHandle *gdraw_HandleCacheAllocateBegin(GDrawHandleCache *c) { GDrawHandle *free_list = &c->state[GDRAW_HANDLE_STATE_free]; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (free_list->next != free_list) { t = free_list->next; gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_alloc); t->bytes = 0; t->owner = 0; #ifdef GDRAW_MANAGE_MEM - t->raw_ptr = NULL; + t->raw_ptr = nullptr; #endif #ifdef GDRAW_CORRUPTION_CHECK t->has_check_value = false; @@ -562,7 +562,7 @@ static GDrawHandle *gdraw_HandleCacheGetLRU(GDrawHandleCache *c) // at the front of the LRU list are the oldest ones, since in-use resources // will get appended on every transition from "locked" to "live". GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_live]; - return (sentinel->next != sentinel) ? sentinel->next : NULL; + return (sentinel->next != sentinel) ? sentinel->next : nullptr; } static void gdraw_HandleCacheTick(GDrawHandleCache *c, GDrawFence now) @@ -1094,7 +1094,7 @@ static void make_pool_aligned(void **start, S32 *num_bytes, U32 alignment) if (addr_aligned != addr_orig) { S32 diff = (S32) (addr_aligned - addr_orig); if (*num_bytes < diff) { - *start = NULL; + *start = nullptr; *num_bytes = 0; return; } else { @@ -1131,7 +1131,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) UINTa remaining = arena->end - arena->current; UINTa total_size = (ptr - arena->current) + size; if (remaining < total_size) // doesn't fit - return NULL; + return nullptr; arena->current = ptr + size; return ptr; @@ -1156,7 +1156,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // (i.e. block->next->prev == block->prev->next == block) // - All allocated blocks are also kept in a hash table, indexed by their // pointer (to allow free to locate the corresponding block_info quickly). -// There's a single-linked, NULL-terminated list of elements in each hash +// There's a single-linked, nullptr-terminated list of elements in each hash // bucket. // - The physical block list is ordered. It always contains all currently // active blocks and spans the whole managed memory range. There are no @@ -1165,7 +1165,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // they are coalesced immediately. // - The maximum number of blocks that could ever be necessary is allocated // on initialization. All block_infos not currently in use are kept in a -// single-linked, NULL-terminated list of unused blocks. Every block is either +// single-linked, nullptr-terminated list of unused blocks. Every block is either // in the physical block list or the unused list, and the total number of // blocks is constant. // These invariants always hold before and after an allocation/free. @@ -1383,7 +1383,7 @@ static void gfxalloc_check2(gfx_allocator *alloc) static gfx_block_info *gfxalloc_pop_unused(gfx_allocator *alloc) { - GFXALLOC_ASSERT(alloc->unused_list != NULL); + GFXALLOC_ASSERT(alloc->unused_list != nullptr); GFXALLOC_ASSERT(alloc->unused_list->is_unused); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_unused);) @@ -1456,7 +1456,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma U32 i, max_blocks, size; if (!align || (align & (align - 1)) != 0) // align must be >0 and a power of 2 - return NULL; + return nullptr; // for <= max_allocs live allocs, there's <= 2*max_allocs+1 blocks. worst case: // [free][used][free] .... [free][used][free] @@ -1464,7 +1464,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma size = sizeof(gfx_allocator) + max_blocks * sizeof(gfx_block_info); a = (gfx_allocator *) IggyGDrawMalloc(size); if (!a) - return NULL; + return nullptr; memset(a, 0, size); @@ -1505,16 +1505,16 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma a->blocks[i].is_unused = 1; gfxalloc_check(a); - debug_complete_check(a, NULL, 0,0); + debug_complete_check(a, nullptr, 0,0); return a; } static void *gfxalloc_alloc(gfx_allocator *alloc, U32 size_in_bytes) { - gfx_block_info *cur, *best = NULL; + gfx_block_info *cur, *best = nullptr; U32 i, best_wasted = ~0u; U32 size = size_in_bytes; -debug_complete_check(alloc, NULL, 0,0); +debug_complete_check(alloc, nullptr, 0,0); gfxalloc_check(alloc); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) @@ -1564,7 +1564,7 @@ gfxalloc_check(alloc); debug_check_overlap(alloc->cache, best->ptr, best->size); return best->ptr; } else - return NULL; // not enough space! + return nullptr; // not enough space! } static void gfxalloc_free(gfx_allocator *alloc, void *ptr) @@ -1734,7 +1734,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta // (unused for allocated blocks, we'll use it to store a back-pointer to the corresponding handle) for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys) if (!b->is_free) - b->prev = NULL; + b->prev = nullptr; // go through all handles and store a pointer to the handle in the corresponding memory block for (i=0; i < c->max_handles; i++) @@ -1747,7 +1747,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta break; } - GFXALLOC_ASSERT(b != NULL); // didn't find this block anywhere! + GFXALLOC_ASSERT(b != nullptr); // didn't find this block anywhere! } // clear alloc hash table (we rebuild it during defrag) @@ -1909,7 +1909,7 @@ static rrbool gdraw_CanDefragment(GDrawHandleCache *c) static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats) { GDrawHandleCache *c = t->cache; - void *ptr = NULL; + void *ptr = nullptr; assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); // anything we migrate should be in the "other" (old) pool @@ -2299,7 +2299,7 @@ static void gdraw_bufring_init(gdraw_bufring * RADRESTRICT ring, void *ptr, U32 static void gdraw_bufring_shutdown(gdraw_bufring * RADRESTRICT ring) { - ring->cur = NULL; + ring->cur = nullptr; ring->seg_size = 0; } @@ -2309,7 +2309,7 @@ static void *gdraw_bufring_alloc(gdraw_bufring * RADRESTRICT ring, U32 size, U32 gdraw_bufring_seg *seg; if (size > ring->seg_size) - return NULL; // nope, won't fit + return nullptr; // nope, won't fit assert(align <= ring->align); @@ -2414,7 +2414,7 @@ static rrbool gdraw_res_free_lru(GDrawHandleCache *c, GDrawStats *stats) // was it referenced since end of previous frame (=in this frame)? // if some, we're thrashing; report it to the user, but only once per frame. if (c->prev_frame_end.value < r->fence.value && !c->is_thrashing) { - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); c->is_thrashing = true; } @@ -2434,8 +2434,8 @@ static GDrawHandle *gdraw_res_alloc_outofmem(GDrawHandleCache *c, GDrawHandle *t { if (t) gdraw_HandleCacheAllocateFail(t); - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); - return NULL; + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); + return nullptr; } #ifndef GDRAW_MANAGE_MEM @@ -2444,7 +2444,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt { GDrawHandle *t; if (size > c->total_bytes) - gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); else { // given how much data we're going to allocate, throw out // data until there's "room" (this basically lets us use @@ -2452,7 +2452,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // packing it and being exact) while (c->bytes_free < size) { if (!gdraw_res_free_lru(c, stats)) { - gdraw_res_alloc_outofmem(c, NULL, "memory"); + gdraw_res_alloc_outofmem(c, nullptr, "memory"); break; } } @@ -2467,8 +2467,8 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // we'd trade off cost of regenerating) if (gdraw_res_free_lru(c, stats)) { t = gdraw_HandleCacheAllocateBegin(c); - if (t == NULL) { - gdraw_res_alloc_outofmem(c, NULL, "handles"); + if (t == nullptr) { + gdraw_res_alloc_outofmem(c, nullptr, "handles"); } } } @@ -2512,7 +2512,7 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) { GDRAW_FENCE_FLUSH(); // dead list is sorted by fence index - make sure all fence values are current. - r->owner = NULL; + r->owner = nullptr; gdraw_HandleCacheInsertDead(r); gdraw_res_reap(r->cache, stats); } @@ -2520,11 +2520,11 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats) { GDrawHandle *t; - void *ptr = NULL; + void *ptr = nullptr; gdraw_res_reap(c, stats); // NB this also does GDRAW_FENCE_FLUSH(); if (size > c->total_bytes) - return gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + return gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); // now try to allocate a handle t = gdraw_HandleCacheAllocateBegin(c); @@ -2536,7 +2536,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt gdraw_res_free_lru(c, stats); t = gdraw_HandleCacheAllocateBegin(c); if (!t) - return gdraw_res_alloc_outofmem(c, NULL, "handles"); + return gdraw_res_alloc_outofmem(c, nullptr, "handles"); } // try to allocate first diff --git a/Minecraft.Client/PSVita/Iggy/include/gdraw.h b/Minecraft.Client/PSVita/Iggy/include/gdraw.h index 404a2642b..7cc4ddd0e 100644 --- a/Minecraft.Client/PSVita/Iggy/include/gdraw.h +++ b/Minecraft.Client/PSVita/Iggy/include/gdraw.h @@ -356,13 +356,13 @@ IDOC typedef struct GDrawPrimitive IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats); /* Draws a collection of indexed triangles, ignoring special filters or blend modes. - If buf is NULL, then the pointers in 'prim' are machine pointers, and + If buf is nullptr, then the pointers in 'prim' are machine pointers, and you need to make a copy of the data (note currently all triangles implementing strokes (wide lines) go this path). - If buf is non-NULL, then use the appropriate vertex buffer, and the + If buf is non-nullptr, then use the appropriate vertex buffer, and the pointers in prim are actually offsets from the beginning of the - vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL; + vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) nullptr; (note there are separate spaces for vertices and indices; e.g. the first mesh in a given vertex buffer will normally have a 0 offset for the vertices and a 0 offset for the indices) @@ -455,7 +455,7 @@ IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_Pro /* Ends specification of a new texture. $:info The same handle initially passed to $gdraw_make_texture_begin - $:return Handle for the newly created texture, or NULL if an error occured + $:return Handle for the newly created texture, or nullptr if an error occured */ IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats); diff --git a/Minecraft.Client/PSVita/Iggy/include/iggyexpruntime.h b/Minecraft.Client/PSVita/Iggy/include/iggyexpruntime.h index 1f1a90a1c..a42ccbfff 100644 --- a/Minecraft.Client/PSVita/Iggy/include/iggyexpruntime.h +++ b/Minecraft.Client/PSVita/Iggy/include/iggyexpruntime.h @@ -25,8 +25,8 @@ IDOC RADEXPFUNC HIGGYEXP RADEXPLINK IggyExpCreate(char *ip_address, S32 port, vo $:storage A small block of storage that needed to store the $HIGGYEXP, must be at least $IGGYEXP_MIN_STORAGE $:storage_size_in_bytes The size of the block pointer to by storage -Returns a NULL HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer -can be contacted at the specified address/port. Otherwise returns a non-NULL $HIGGYEXP +Returns a nullptr HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer +can be contacted at the specified address/port. Otherwise returns a non-nullptr $HIGGYEXP which you can pass to $IggyUseExplorer. */ IDOC RADEXPFUNC void RADEXPLINK IggyExpDestroy(HIGGYEXP p); diff --git a/Minecraft.Client/PSVita/Leaderboards/PSVitaLeaderboardManager.cpp b/Minecraft.Client/PSVita/Leaderboards/PSVitaLeaderboardManager.cpp index 958999e4b..c5a44878d 100644 --- a/Minecraft.Client/PSVita/Leaderboards/PSVitaLeaderboardManager.cpp +++ b/Minecraft.Client/PSVita/Leaderboards/PSVitaLeaderboardManager.cpp @@ -20,7 +20,7 @@ PSVitaLeaderboardManager::PSVitaLeaderboardManager() : SonyLeaderboardManager() HRESULT PSVitaLeaderboardManager::initialiseScoreUtility() { - return sceNpScoreInit( SCE_KERNEL_DEFAULT_PRIORITY_USER, SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT, NULL); + return sceNpScoreInit( SCE_KERNEL_DEFAULT_PRIORITY_USER, SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT, nullptr); } bool PSVitaLeaderboardManager::scoreUtilityAlreadyInitialised(HRESULT hr) diff --git a/Minecraft.Client/PSVita/Miles/include/mss.h b/Minecraft.Client/PSVita/Miles/include/mss.h index 531dcbc92..a9fd231a9 100644 --- a/Minecraft.Client/PSVita/Miles/include/mss.h +++ b/Minecraft.Client/PSVita/Miles/include/mss.h @@ -584,7 +584,7 @@ typedef enum } MSS_SPEAKER; // -// Pass to AIL_midiOutOpen for NULL MIDI driver +// Pass to AIL_midiOutOpen for nullptr MIDI driver // #define MIDI_NULL_DRIVER ((U32)(S32)-2) @@ -833,7 +833,7 @@ the enumeration function until it returns 0. #define DEFAULT_DPWOD ((UINTa)-1) // Preferred WaveOut device == WAVE_MAPPER #define DIG_PREFERRED_DS_DEVICE 20 -#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default NULL GUID +#define DEFAULT_DPDSD 0 // Preferred DirectSound device == default nullptr GUID #define MDI_SEQUENCES 21 @@ -1305,7 +1305,7 @@ typedef ASIRESULT (AILCALL *ASI_STARTUP)(void); typedef ASIRESULT (AILCALL * ASI_SHUTDOWN)(void); // -// Return codec error message, or NULL if no errors have occurred since +// Return codec error message, or nullptr if no errors have occurred since // last call // // The ASI error text state is global to all streams @@ -1878,7 +1878,7 @@ typedef struct _S3DSTATE // Portion of HSAMPLE that deals with 3D posi F32 spread; - HSAMPLE owner; // May be NULL if used for temporary/internal calculations + HSAMPLE owner; // May be nullptr if used for temporary/internal calculations AILFALLOFFCB falloff_function; // User function for min/max distance calculations, if desired MSSVECTOR3D position_graph[MILES_MAX_SEGMENT_COUNT]; @@ -2460,7 +2460,7 @@ typedef struct _DIG_DRIVER // Handle to digital audio driver S32 DS_initialized; - AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or NULL if none) + AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or nullptr if none) AILLPDIRECTSOUNDBUFFER DS_out_buff; // Output buffer (may be sec or prim) S32 DS_buffer_size; // Size of entire output buffer @@ -4866,10 +4866,10 @@ typedef struct U8 *MP3_file_image; // Original MP3_file_image pointer passed to AIL_inspect_MP3() S32 MP3_image_size; // Original MP3_image_size passed to AIL_inspect_MP3() - U8 *ID3v2; // ID3v2 tag, if not NULL + U8 *ID3v2; // ID3v2 tag, if not nullptr S32 ID3v2_size; // Size of tag in bytes - U8 *ID3v1; // ID3v1 tag, if not NULL (always 128 bytes long if present) + U8 *ID3v1; // ID3v1 tag, if not nullptr (always 128 bytes long if present) U8 *start_MP3_data; // Pointer to start of data area in file (not necessarily first valid frame) U8 *end_MP3_data; // Pointer to last valid byte in MP3 data area (before ID3v1 tag, if any) diff --git a/Minecraft.Client/PSVita/Network/PSVita_NPToolkit.cpp b/Minecraft.Client/PSVita/Network/PSVita_NPToolkit.cpp index 1c5c45e31..9ed61d214 100644 --- a/Minecraft.Client/PSVita/Network/PSVita_NPToolkit.cpp +++ b/Minecraft.Client/PSVita/Network/PSVita_NPToolkit.cpp @@ -331,7 +331,7 @@ void hexStrToBin( val <<= 4; } else { - if (pBinBuf != NULL && binOffset < binBufSize) { + if (pBinBuf != nullptr && binOffset < binBufSize) { memcpy(pBinBuf + binOffset, &val, 1); val = 0; } @@ -339,7 +339,7 @@ void hexStrToBin( } } - if (val != 0 && pBinBuf != NULL && binOffset < binBufSize) { + if (val != 0 && pBinBuf != nullptr && binOffset < binBufSize) { memcpy(pBinBuf + binOffset, &val, 1); } @@ -403,7 +403,7 @@ void PSVitaNPToolkit::init() // extern void npStateCallback(SceNpServiceState state, int retCode, void *userdata); - ret = sceNpRegisterServiceStateCallback(npStateCallback, NULL); + ret = sceNpRegisterServiceStateCallback(npStateCallback, nullptr); if (ret < 0) { app.DebugPrintf("sceNpRegisterServiceStateCallback() failed. ret = 0x%x\n", ret); diff --git a/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.cpp b/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.cpp index dc9ad61e6..1483d8e9d 100644 --- a/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.cpp @@ -45,8 +45,8 @@ int SQRNetworkManager_AdHoc_Vita::m_adhocStatus = false; static unsigned char s_Matching2Pool[SCE_NET_ADHOC_MATCHING_POOLSIZE_DEFAULT]; -int (* SQRNetworkManager_AdHoc_Vita::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = NULL; -void * SQRNetworkManager_AdHoc_Vita::s_SignInCompleteParam = NULL; +int (* SQRNetworkManager_AdHoc_Vita::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = nullptr; +void * SQRNetworkManager_AdHoc_Vita::s_SignInCompleteParam = nullptr; sce::Toolkit::NP::PresenceDetails SQRNetworkManager_AdHoc_Vita::s_lastPresenceInfo; int SQRNetworkManager_AdHoc_Vita::s_resendPresenceCountdown = 0; bool SQRNetworkManager_AdHoc_Vita::s_presenceStatusDirty = false; @@ -127,8 +127,8 @@ SQRNetworkManager_AdHoc_Vita::SQRNetworkManager_AdHoc_Vita(ISQRNetworkManagerLis m_isInSession = false; m_offlineGame = false; m_offlineSQR = false; - m_aServerId = NULL; -// m_gameBootInvite = NULL; + m_aServerId = nullptr; +// m_gameBootInvite = nullptr; m_adhocStatus = false; m_bLinkDisconnected = false; m_bIsInitialised=false; @@ -166,7 +166,7 @@ void SQRNetworkManager_AdHoc_Vita::Initialise() int32_t ret = 0; // int32_t libCtxId = 0; -// ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, NULL); +// ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, nullptr); // assert (ret >= 0); // libCtxId = ret; @@ -203,7 +203,7 @@ void SQRNetworkManager_AdHoc_Vita::Initialise() // npConf.commId = &s_npCommunicationId; // npConf.commPassphrase = &s_npCommunicationPassphrase; // npConf.commSignature = &s_npCommunicationSignature; -// ret = sceNpInit(&npConf, NULL); +// ret = sceNpInit(&npConf, nullptr); // if (ret < 0 && ret != SCE_NP_ERROR_ALREADY_INITIALIZED) // { // app.DebugPrintf("sceNpInit failed, ret=%x\n", ret); @@ -392,10 +392,10 @@ bool SQRNetworkManager_AdHoc_Vita::CreateMatchingContext(bool bServer /*= false* { if(m_aFriendSearchResults[i].m_RoomExtDataReceived) free(m_aFriendSearchResults[i].m_RoomExtDataReceived); - m_aFriendSearchResults[i].m_RoomExtDataReceived = NULL; + m_aFriendSearchResults[i].m_RoomExtDataReceived = nullptr; if(m_aFriendSearchResults[i].m_gameSessionData) free(m_aFriendSearchResults[i].m_gameSessionData); - m_aFriendSearchResults[i].m_gameSessionData = NULL; + m_aFriendSearchResults[i].m_gameSessionData = nullptr; } m_friendCount = 0; m_aFriendSearchResults.clear(); @@ -406,7 +406,7 @@ bool SQRNetworkManager_AdHoc_Vita::CreateMatchingContext(bool bServer /*= false* ret = sceNetAdhocMatchingStart(m_matchingContext, SCE_KERNEL_DEFAULT_PRIORITY_USER, MATCHING_EVENT_HANDLER_STACK_SIZE, SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT, - 0, NULL);//sizeof(g_myInfo.name), &g_myInfo.name); + 0, nullptr);//sizeof(g_myInfo.name), &g_myInfo.name); if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_CONTEXT_START_ASYNC ) ) { @@ -448,7 +448,7 @@ void SQRNetworkManager_AdHoc_Vita::InitialiseAfterOnline() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } return; } @@ -512,7 +512,7 @@ void SQRNetworkManager_AdHoc_Vita::Tick() // if( ( m_gameBootInvite m) && ( s_safeToRespondToGameBootInvite ) ) // { // m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), m_gameBootInvite ); -// m_gameBootInvite = NULL; +// m_gameBootInvite = nullptr; // } ErrorHandlingTick(); @@ -585,7 +585,7 @@ void SQRNetworkManager_AdHoc_Vita::ErrorHandlingTick() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } app.DebugPrintf("Network error: SNM_INT_STATE_INITIALISE_FAILED\n"); if( m_isInSession && m_offlineSQR ) @@ -777,7 +777,7 @@ void SQRNetworkManager_AdHoc_Vita::FriendSearchTick() // { // m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO; // delete m_getFriendCountThread; -// m_getFriendCountThread = NULL; +// m_getFriendCountThread = nullptr; FriendRoomManagerSearch2(); // } } @@ -797,7 +797,7 @@ int SQRNetworkManager_AdHoc_Vita::BasicEventThreadProc( void *lpParameter ) // // do // { -// ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, NULL); +// ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, nullptr); // // // If the sys_event_t we've sent here from the handler has a non-zero data1 element, this is to signify that we should terminate the thread // if( event.udata == 0 ) @@ -855,7 +855,7 @@ int SQRNetworkManager_AdHoc_Vita::BasicEventThreadProc( void *lpParameter ) // // There shouldn't ever be more than 100 friends returned but limit here just in case // if( manager->m_friendCount > 100 ) manager->m_friendCount = 100; // -// SceNpId* friendIDs = NULL; +// SceNpId* friendIDs = nullptr; // if(manager->m_friendCount > 0) // { // // grab all the friend IDs first @@ -995,7 +995,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerByIndex(int idx) } else { - return NULL; + return nullptr; } } @@ -1012,7 +1012,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerBySmallId(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetLocalPlayerByUserIndex(int idx) @@ -1028,7 +1028,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetLocalPlayerByUserIndex(int id } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetHostPlayer() @@ -1041,11 +1041,11 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetHostPlayer() SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerIfReady(SQRNetworkPlayer *player) { - if( player == NULL ) return NULL; + if( player == nullptr ) return nullptr; if( player->IsReady() ) return player; - return NULL; + return nullptr; } // Update state internally @@ -1117,7 +1117,7 @@ bool SQRNetworkManager_AdHoc_Vita::JoinRoom(SQRNetworkManager_AdHoc_Vita::Sessio { // Set up the presence info we would like to synchronise out when we have fully joined the game // CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData(&s_lastPresenceSyncInfo, searchResult->m_extData, searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId); - return JoinRoom(searchResult->m_netAddr, localPlayerMask, NULL); + return JoinRoom(searchResult->m_netAddr, localPlayerMask, nullptr); } bool SQRNetworkManager_AdHoc_Vita::JoinRoom(SceNpMatching2RoomId roomId, SceNpMatching2ServerId serverId, int localPlayerMask, const PresenceSyncInfo *presence) @@ -1162,7 +1162,7 @@ bool SQRNetworkManager_AdHoc_Vita::JoinRoom(SceNetInAddr netAddr, int localPlaye if(!CreateMatchingContext()) return false; - int err = sceNetAdhocMatchingSelectTarget(m_matchingContext, &netAddr, 0, NULL); + int err = sceNetAdhocMatchingSelectTarget(m_matchingContext, &netAddr, 0, nullptr); m_hostMemberId = getRoomMemberID(&netAddr); m_hostIPAddr = netAddr; @@ -1323,7 +1323,7 @@ void SQRNetworkManager_AdHoc_Vita::FindOrCreateNonNetworkPlayer(int slot, int pl } } // Create the player - non-network players can be considered complete as soon as we create them as we aren't waiting on their network connections becoming complete, so can flag them as such and notify via callback - PlayerUID *pUID = NULL; + PlayerUID *pUID = nullptr; PlayerUID localUID; if( ( playerType == SQRNetworkPlayer::SNP_TYPE_LOCAL ) || m_isHosting && ( playerType == SQRNetworkPlayer::SNP_TYPE_HOST ) ) @@ -1390,7 +1390,7 @@ void SQRNetworkManager_AdHoc_Vita::MapRoomSlotPlayers(int roomSlotPlayerCount/*= if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_REMOTE ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1446,7 +1446,7 @@ void SQRNetworkManager_AdHoc_Vita::MapRoomSlotPlayers(int roomSlotPlayerCount/*= if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_LOCAL ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1538,7 +1538,7 @@ void SQRNetworkManager_AdHoc_Vita::UpdatePlayersFromRoomSyncUIDs() } // Host only - add remote players to our internal storage of player slots, and synchronise this with other room members. -bool SQRNetworkManager_AdHoc_Vita::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==NULL*/ ) +bool SQRNetworkManager_AdHoc_Vita::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==nullptr*/ ) { assert( m_isHosting ); @@ -1658,7 +1658,7 @@ void SQRNetworkManager_AdHoc_Vita::RemoveRemotePlayersAndSync( SceNpMatching2Roo } // Zero last element, that isn't part of the currently sized array anymore memset(&m_roomSyncData.players[m_roomSyncData.getPlayerCount()],0,sizeof(PlayerSyncData)); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; } else { @@ -1701,7 +1701,7 @@ void SQRNetworkManager_AdHoc_Vita::RemoveNetworkPlayers( int mask ) { if( m_aRoomSlotPlayers[i] == player ) { - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } // And delete the reference from the ctx->player map @@ -1843,7 +1843,7 @@ void SQRNetworkManager_AdHoc_Vita::MatchingEventHandler(int id, int event, SceNe case SCE_NET_ADHOC_MATCHING_EVENT_REQUEST: // A join request was received app.DebugPrintf("P2P SCE_NET_ADHOC_MATCHING_EVENT_REQUEST Received!!\n"); - if (optlen > 0 && opt != NULL) + if (optlen > 0 && opt != nullptr) { ret = SCE_OK;// parentRequestAdd(opt); if (ret != SCE_OK) @@ -1987,7 +1987,7 @@ void SQRNetworkManager_AdHoc_Vita::MatchingEventHandler(int id, int event, SceNe { app.DebugPrintf("P2P SCE_NET_ADHOC_MATCHING_EVENT_DATA Received!!\n"); - if (optlen <= 0 || opt == NULL) + if (optlen <= 0 || opt == nullptr) { assert(0); break; @@ -2270,7 +2270,7 @@ bool SQRNetworkManager_AdHoc_Vita::CreateRudpConnections(SceNetInAddr peer) if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT) ) return false; if( m_isHosting ) { - m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, getRoomMemberID((&peer)), 0, rudpCtx, NULL ); + m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, getRoomMemberID((&peer)), 0, rudpCtx, nullptr ); m_RudpCtxToIPAddrMap[ rudpCtx ] = peer; } else @@ -2311,7 +2311,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerFromRudpCtx(int rudpCtx { return it->second; } - return NULL; + return nullptr; } @@ -2322,7 +2322,7 @@ SceNetInAddr* SQRNetworkManager_AdHoc_Vita::GetIPAddrFromRudpCtx(int rudpCtx) { return &it->second; } - return NULL; + return nullptr; } @@ -2336,7 +2336,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerFromRoomMemberAndLocalI return it->second; } } - return NULL; + return nullptr; } @@ -2406,7 +2406,7 @@ void SQRNetworkManager_AdHoc_Vita::HandleMatchingContextStart() if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { SetState( SNM_INT_STATE_IDLE ); - GetExtDataForRoom(0, NULL, NULL, NULL); + GetExtDataForRoom(0, nullptr, nullptr, nullptr); } else if( m_state == SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT ) { @@ -2431,7 +2431,7 @@ void SQRNetworkManager_AdHoc_Vita::HandleMatchingContextStart() if(s_SignInCompleteCallbackFn) { s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -2446,7 +2446,7 @@ int SQRNetworkManager_AdHoc_Vita::BasicEventCallback(int event, int retCode, uin PSVITA_STUBBED; // SQRNetworkManager_AdHoc_Vita *manager = (SQRNetworkManager_AdHoc_Vita *)arg; // // We aren't allowed to actually get the event directly from this callback, so send our own internal event to a thread dedicated to doing this - // sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, NULL); + // sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, nullptr); return 0; } @@ -2490,7 +2490,7 @@ void SQRNetworkManager_AdHoc_Vita::SysUtilCallback(uint64_t status, uint64_t par // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } // return; // } @@ -2505,7 +2505,7 @@ void SQRNetworkManager_AdHoc_Vita::SysUtilCallback(uint64_t status, uint64_t par // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } // } // @@ -2542,7 +2542,7 @@ void SQRNetworkManager_AdHoc_Vita::updateNetCheckDialog() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } else @@ -2561,7 +2561,7 @@ void SQRNetworkManager_AdHoc_Vita::updateNetCheckDialog() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -2577,7 +2577,7 @@ void SQRNetworkManager_AdHoc_Vita::RudpContextCallback(int ctx_id, int event_id, { case SCE_RUDP_CONTEXT_EVENT_CLOSED: { - SQRVoiceConnection* pVoice = NULL; + SQRVoiceConnection* pVoice = nullptr; if(sc_voiceChatEnabled) SonyVoiceChat_Vita::GetVoiceConnectionFromRudpCtx(ctx_id); @@ -2638,7 +2638,7 @@ void SQRNetworkManager_AdHoc_Vita::RudpContextCallback(int ctx_id, int event_id, case SCE_RUDP_CONTEXT_EVENT_READABLE: if( manager->m_listener ) { - SQRVoiceConnection* pVoice = NULL; + SQRVoiceConnection* pVoice = nullptr; if(sc_voiceChatEnabled) { SonyVoiceChat_Vita::GetVoiceConnectionFromRudpCtx(ctx_id); @@ -2698,7 +2698,7 @@ void SQRNetworkManager_AdHoc_Vita::RudpContextCallback(int ctx_id, int event_id, playerFrom = manager->m_aRoomSlotPlayers[0]; playerTo = manager->GetPlayerFromRudpCtx( ctx_id ); } - if( ( playerFrom != NULL ) && ( playerTo != NULL ) ) + if( ( playerFrom != nullptr ) && ( playerTo != nullptr ) ) { manager->m_listener->HandleDataReceived( playerFrom, playerTo, data, bytesRead ); } @@ -2761,7 +2761,7 @@ void SQRNetworkManager_AdHoc_Vita::ServerContextValid_CreateRoom() int ret = -1; if( !ForceErrorPoint(SNM_FORCE_ERROR_GET_WORLD_INFO_LIST) ) { - ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, NULL, &m_getWorldRequestId); + ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, nullptr, &m_getWorldRequestId); } if (ret < 0) { @@ -2790,7 +2790,7 @@ void SQRNetworkManager_AdHoc_Vita::ServerContextValid_JoinRoom() reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, NULL, &m_joinRoomRequestId ); + int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, nullptr, &m_joinRoomRequestId ); if ( (ret < 0) || ForceErrorPoint(SNM_FORCE_ERROR_JOIN_ROOM) ) { if( ret == SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH) @@ -2814,14 +2814,14 @@ const SceNpCommunicationSignature* SQRNetworkManager_AdHoc_Vita::GetSceNpCommsSi const SceNpTitleId* SQRNetworkManager_AdHoc_Vita::GetSceNpTitleId() { PSVITA_STUBBED; - return NULL; + return nullptr; // return &s_npTitleId; } const SceNpTitleSecret* SQRNetworkManager_AdHoc_Vita::GetSceNpTitleSecret() { PSVITA_STUBBED; - return NULL; + return nullptr; // return &s_npTitleSecret; } @@ -2964,7 +2964,7 @@ void SQRNetworkManager_AdHoc_Vita::AttemptAdhocSignIn(int (*SignInCompleteCallba { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -3039,7 +3039,7 @@ void SQRNetworkManager_AdHoc_Vita::AttemptPSNSignIn(int (*SignInCompleteCallback { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -3234,7 +3234,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerByXuid(PlayerUID xuid) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } void SQRNetworkManager_AdHoc_Vita::UpdateLocalIPAddress() diff --git a/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.h b/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.h index c1b2d2668..a5b9513ee 100644 --- a/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.h +++ b/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.h @@ -163,7 +163,7 @@ class SQRNetworkManager_AdHoc_Vita : public SQRNetworkManager void LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize); int GetSessionIndex(SQRNetworkPlayer *player); - bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = NULL ); + bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = nullptr ); void RemoveRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int mask ); void RemoveNetworkPlayers( int mask ); void SetLocalPlayersAndSync(); diff --git a/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.cpp b/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.cpp index a1534f541..93021dd4d 100644 --- a/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.cpp @@ -16,8 +16,8 @@ // image used for the invite gui, filesize must be smaller than SCE_NP_MESSAGE_DIALOG_MAX_INDEX_ICON_SIZE ( 64K ) #define SESSION_IMAGE_PATH "app0:PSVita/session_image.png" -int (* SQRNetworkManager_Vita::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = NULL; -void * SQRNetworkManager_Vita::s_SignInCompleteParam = NULL; +int (* SQRNetworkManager_Vita::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = nullptr; +void * SQRNetworkManager_Vita::s_SignInCompleteParam = nullptr; sce::Toolkit::NP::PresenceDetails SQRNetworkManager_Vita::s_lastPresenceInfo; int SQRNetworkManager_Vita::s_resendPresenceCountdown = 0; bool SQRNetworkManager_Vita::s_presenceStatusDirty = false; @@ -98,8 +98,8 @@ SQRNetworkManager_Vita::SQRNetworkManager_Vita(ISQRNetworkManagerListener *liste m_isInSession = false; m_offlineGame = false; m_offlineSQR = false; - m_aServerId = NULL; - m_gameBootInvite = NULL; + m_aServerId = nullptr; + m_gameBootInvite = nullptr; m_onlineStatus = false; m_bLinkDisconnected = false; m_bShuttingDown = false; @@ -129,7 +129,7 @@ void SQRNetworkManager_Vita::Initialise() m_bShuttingDown = false; int32_t ret = 0; // int32_t libCtxId = 0; - // ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, NULL); + // ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, nullptr); // assert (ret >= 0); // libCtxId = ret; @@ -162,7 +162,7 @@ void SQRNetworkManager_Vita::Initialise() } SetState(SNM_INT_STATE_SIGNING_IN); - // AttemptPSNSignIn(NULL, NULL); + // AttemptPSNSignIn(nullptr, nullptr); // SonyHttp::init(); @@ -170,7 +170,7 @@ void SQRNetworkManager_Vita::Initialise() // npConf.commId = &s_npCommunicationId; // npConf.commPassphrase = &s_npCommunicationPassphrase; // npConf.commSignature = &s_npCommunicationSignature; - // ret = sceNpInit(&npConf, NULL); + // ret = sceNpInit(&npConf, nullptr); // if (ret < 0 && ret != SCE_NP_ERROR_ALREADY_INITIALIZED) // { // app.DebugPrintf("sceNpInit failed, ret=%x\n", ret); @@ -295,7 +295,7 @@ void SQRNetworkManager_Vita::InitialiseAfterOnline() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } return; } @@ -329,7 +329,7 @@ void SQRNetworkManager_Vita::InitialiseAfterOnline() app.DebugPrintf("sceNpMatching2CreateContext\n"); ret = sceNpMatching2CreateContext(&npID, GetSceNpCommsId(), &s_npCommunicationPassphrase, &m_matchingContext); - //ret = sceNpMatching2CreateContext(&npID, NULL, NULL, &m_matchingContext); + //ret = sceNpMatching2CreateContext(&npID, nullptr, nullptr, &m_matchingContext); if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_CREATE_MATCHING_CONTEXT ) ) { @@ -377,7 +377,7 @@ void SQRNetworkManager_Vita::Tick() if( ( m_gameBootInvite ) && ( s_safeToRespondToGameBootInvite ) ) { m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), m_gameBootInvite ); - m_gameBootInvite = NULL; + m_gameBootInvite = nullptr; } ErrorHandlingTick(); @@ -444,12 +444,12 @@ void SQRNetworkManager_Vita::Tick() if( s_signInCompleteCallbackIfFailed ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } else if(s_SignInCompleteCallbackFn) { s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } @@ -467,7 +467,7 @@ void SQRNetworkManager_Vita::ErrorHandlingTick() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } app.DebugPrintf("Network error: SNM_INT_STATE_INITIALISE_FAILED\n"); if( m_isInSession && m_offlineGame) // m_offlineSQR ) // MGH - changed this to m_offlineGame, as m_offlineSQR can be true when running an online game but the init has failed because the servers are down @@ -578,7 +578,7 @@ void SQRNetworkManager_Vita::UpdateExternalRoomData() reqParam.roomBinAttrExternal = &roomBinAttr; app.DebugPrintf("sceNpMatching2SetRoomDataExternal\n"); - int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, nullptr, &m_setRoomDataRequestId ); app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2SetRoomDataExternal returns 0x%x, number of players %d\n",ret,((char *)m_joinExtData)[174]); if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_SET_EXTERNAL_ROOM_DATA ) ) { @@ -612,7 +612,7 @@ bool SQRNetworkManager_Vita::FriendRoomManagerSearch() { if(m_aFriendSearchResults[i].m_RoomExtDataReceived) free(m_aFriendSearchResults[i].m_RoomExtDataReceived); - m_aFriendSearchResults[i].m_RoomExtDataReceived = NULL; + m_aFriendSearchResults[i].m_RoomExtDataReceived = nullptr; } m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_COUNT; @@ -675,7 +675,7 @@ void SQRNetworkManager_Vita::FriendSearchTick() { m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO; delete m_getFriendCountThread; - m_getFriendCountThread = NULL; + m_getFriendCountThread = nullptr; FriendRoomManagerSearch2(); } } @@ -695,7 +695,7 @@ int SQRNetworkManager_Vita::BasicEventThreadProc( void *lpParameter ) // // do // { - // ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, NULL); + // ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, nullptr); // // // If the sys_event_t we've sent here from the handler has a non-zero data1 element, this is to signify that we should terminate the thread // if( event.udata == 0 ) @@ -753,7 +753,7 @@ int SQRNetworkManager_Vita::GetFriendsThreadProc( void* lpParameter ) // There shouldn't ever be more than 100 friends returned but limit here just in case if( manager->m_friendCount > 100 ) manager->m_friendCount = 100; - SceNpId* friendIDs = NULL; + SceNpId* friendIDs = nullptr; if(manager->m_friendCount > 0) { // grab all the friend IDs first @@ -890,7 +890,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerByIndex(int idx) } else { - return NULL; + return nullptr; } } @@ -907,7 +907,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerBySmallId(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_Vita::GetLocalPlayerByUserIndex(int idx) @@ -923,7 +923,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetLocalPlayerByUserIndex(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_Vita::GetHostPlayer() @@ -936,11 +936,11 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetHostPlayer() SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerIfReady(SQRNetworkPlayer *player) { - if( player == NULL ) return NULL; + if( player == nullptr ) return nullptr; if( player->IsReady() ) return player; - return NULL; + return nullptr; } // Update state internally @@ -1039,7 +1039,7 @@ bool SQRNetworkManager_Vita::JoinRoom(SQRNetworkManager_Vita::SessionSearchResul { // Set up the presence info we would like to synchronise out when we have fully joined the game CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData(&s_lastPresenceSyncInfo, searchResult->m_extData, searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId); - return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, NULL); + return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, nullptr); } // Join room with a specified roomId. This is used when joining from an invite, as well as by the previous method @@ -1106,7 +1106,7 @@ void SQRNetworkManager_Vita::LeaveRoom(bool bActuallyLeaveRoom) SetState(SNM_INT_STATE_LEAVING); app.DebugPrintf("sceNpMatching2LeaveRoom\n"); - int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, NULL, &m_leaveRoomRequestId ); + int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, nullptr, &m_leaveRoomRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_LEAVE_ROOM) ) { SetState(SNM_INT_STATE_LEAVING_FAILED); @@ -1214,7 +1214,7 @@ bool SQRNetworkManager_Vita::AddLocalPlayerByUserIndex(int idx) reqParam.roomMemberBinAttrInternal = &binAttr; app.DebugPrintf("sceNpMatching2SetRoomMemberDataInternal\n"); - int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_setRoomMemberInternalDataRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL) ) { @@ -1264,7 +1264,7 @@ bool SQRNetworkManager_Vita::RemoveLocalPlayerByUserIndex(int idx) // And do any adjusting necessary to the mappings from this room data, to the SQRNetworkPlayers. // This will also delete the SQRNetworkPlayer and do all the callbacks that requires etc. MapRoomSlotPlayers(roomSlotPlayerCount); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; // Sync this back out to our networked clients... SyncRoomData(); @@ -1302,7 +1302,7 @@ bool SQRNetworkManager_Vita::RemoveLocalPlayerByUserIndex(int idx) reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_setRoomMemberInternalDataRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL2) ) { @@ -1526,14 +1526,14 @@ void SQRNetworkManager_Vita::TickJoinablePresenceData() // // Signed in to PSN but not connected (no internet access) // UINT uiIDA[1]; // uiIDA[0] = IDS_OK; - // ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL, app.GetStringTable()); + // ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr, app.GetStringTable()); // } // else { // Not signed in to PSN UINT uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), &MustSignInReturnedPresenceInvite, NULL); + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), &MustSignInReturnedPresenceInvite, nullptr); } } @@ -1573,7 +1573,7 @@ void SQRNetworkManager_Vita::FindOrCreateNonNetworkPlayer(int slot, int playerTy } } // Create the player - non-network players can be considered complete as soon as we create them as we aren't waiting on their network connections becoming complete, so can flag them as such and notify via callback - PlayerUID *pUID = NULL; + PlayerUID *pUID = nullptr; PlayerUID localUID; if( ( playerType == SQRNetworkPlayer::SNP_TYPE_LOCAL ) || m_isHosting && ( playerType == SQRNetworkPlayer::SNP_TYPE_HOST ) ) @@ -1640,7 +1640,7 @@ void SQRNetworkManager_Vita::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_REMOTE ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1696,7 +1696,7 @@ void SQRNetworkManager_Vita::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_LOCAL ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1788,7 +1788,7 @@ void SQRNetworkManager_Vita::UpdatePlayersFromRoomSyncUIDs() } // Host only - add remote players to our internal storage of player slots, and synchronise this with other room members. -bool SQRNetworkManager_Vita::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==NULL*/ ) +bool SQRNetworkManager_Vita::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==nullptr*/ ) { assert( m_isHosting ); @@ -1908,7 +1908,7 @@ void SQRNetworkManager_Vita::RemoveRemotePlayersAndSync( SceNpMatching2RoomMembe } // Zero last element, that isn't part of the currently sized array anymore memset(&m_roomSyncData.players[m_roomSyncData.getPlayerCount()],0,sizeof(PlayerSyncData)); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; } else { @@ -1951,7 +1951,7 @@ void SQRNetworkManager_Vita::RemoveNetworkPlayers( int mask ) { if( m_aRoomSlotPlayers[i] == player ) { - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } // And delete the reference from the ctx->player map @@ -2004,7 +2004,7 @@ void SQRNetworkManager_Vita::SyncRoomData() roomBinAttr.size = sizeof( m_roomSyncData ); reqParam.roomBinAttrInternalNum = 1; reqParam.roomBinAttrInternal = &roomBinAttr; - sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, nullptr, &m_setRoomDataRequestId ); } // Check if the matching context is valid, and if not attempt to create one. If to do this requires starting an asynchronous process, then sets the internal state to the state passed in @@ -2037,7 +2037,7 @@ bool SQRNetworkManager_Vita::GetMatchingContext(eSQRNetworkManagerInternalState // Create context app.DebugPrintf("sceNpMatching2CreateContext\n"); ret = sceNpMatching2CreateContext(&npId, &s_npCommunicationId, &s_npCommunicationPassphrase, &m_matchingContext/*, option*/); - //ret = sceNpMatching2CreateContext(&npId, NULL,NULL, &m_matchingContext/*, option*/); + //ret = sceNpMatching2CreateContext(&npId, nullptr,nullptr, &m_matchingContext/*, option*/); if( ret < 0 ) { app.DebugPrintf("SQRNetworkManager::GetMatchingContext - sceNpMatching2CreateContext failed with code 0x%08x\n", ret); @@ -2137,7 +2137,7 @@ bool SQRNetworkManager_Vita::GetServerContext(SceNpMatching2ServerId serverId) // { // // Get list of server IDs of servers allocated to the application. We don't actually need to do this, but it is as good a way as any to try a matching2 service and check that // // the context *really* is valid. - // int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, NULL, 0 ); + // int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, nullptr, 0 ); // // If an error is returned here, we need to destroy and recerate our server - if this goes ok we should come back through this path again // if( ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_UNAVAILABLE ) || // This error has been seen (occasionally) in a normal working environment // ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED ) ) // Also checking for this as a means of simulating the previous error @@ -2233,7 +2233,7 @@ void SQRNetworkManager_Vita::RoomCreateTick() app.DebugPrintf(CMinecraftApp::USER_RR,">> Creating room start\n"); s_roomStartTime = System::currentTimeMillis(); app.DebugPrintf("sceNpMatching2CreateJoinRoom\n"); - int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, NULL, &m_createRoomRequestId ); + int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, nullptr, &m_createRoomRequestId ); if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_JOIN_ROOM) ) { SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED); @@ -2468,7 +2468,7 @@ bool SQRNetworkManager_Vita::CreateVoiceRudpConnections(SceNpMatching2RoomId roo // create this connection if we don't have it already SQRVoiceConnection* pConnection = SonyVoiceChat_Vita::getVoiceConnectionFromRoomMemberID(peerMemberId); - if(pConnection == NULL) + if(pConnection == nullptr) { // Create an Rudp context for the voice connection, this will happen regardless of whether the peer is client or host @@ -2542,7 +2542,7 @@ bool SQRNetworkManager_Vita::CreateRudpConnections(SceNpMatching2RoomId roomId, if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT) ) return false; if( m_isHosting ) { - m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, NULL ); + m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, nullptr ); } else { @@ -2576,7 +2576,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerFromRudpCtx(int rudpCtx) { return it->second; } - return NULL; + return nullptr; } @@ -2590,7 +2590,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerFromRoomMemberAndLocalIdx(int return it->second; } } - return NULL; + return nullptr; } @@ -2693,7 +2693,7 @@ void SQRNetworkManager_Vita::ContextCallback(SceNpMatching2ContextId id, SceNpM if( manager->m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { manager->SetState( SNM_INT_STATE_IDLE ); - manager->GetExtDataForRoom(0, NULL, NULL, NULL); + manager->GetExtDataForRoom(0, nullptr, nullptr, nullptr); break; } @@ -2729,7 +2729,7 @@ void SQRNetworkManager_Vita::ContextCallback(SceNpMatching2ContextId id, SceNpM // if(s_SignInCompleteCallbackFn) // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } @@ -2966,12 +2966,12 @@ void SQRNetworkManager_Vita::DefaultRequestCallback(SceNpMatching2ContextId id, // Set flag to indicate whether we were kicked for being out of room or not reqParam.optData.data[0] = isFull ? 1 : 0; reqParam.optData.len = 1; - int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, NULL, &manager->m_kickRequestId); + int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, nullptr, &manager->m_kickRequestId); app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2KickoutRoomMember returns error 0x%x\n",ret); } else { - if(pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternal->data.ptr == NULL) + if(pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternal->data.ptr == nullptr) { // the host doesn't send out data, so this must be the host we're connecting to @@ -3220,7 +3220,7 @@ void SQRNetworkManager_Vita::RoomEventCallback(SceNpMatching2ContextId id, SceNp reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, NULL, &manager->m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, nullptr, &manager->m_setRoomMemberInternalDataRequestId ); } else { @@ -3309,7 +3309,7 @@ void SQRNetworkManager_Vita::SignallingCallback(SceNpMatching2ContextId ctxId, S { SonyVoiceChat_Vita::disconnectRemoteConnection(pVoice); } - if(peerMemberId == manager->m_hostMemberId || pVoice == NULL) // MGH - added check for voice, as we sometime get here before m_hostMemberId has been filled in + if(peerMemberId == manager->m_hostMemberId || pVoice == nullptr) // MGH - added check for voice, as we sometime get here before m_hostMemberId has been filled in { // Host has left the game... so its all over for this client too. Finish everything up now, including deleting the server context which belongs to this gaming session // This also might be a response to a request to leave the game from our end too so don't need to do anything in that case @@ -3336,7 +3336,7 @@ void SQRNetworkManager_Vita::SignallingCallback(SceNpMatching2ContextId ctxId, S reqParam.attrId = attrs; reqParam.attrIdNum = 1; - sceNpMatching2GetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, NULL, &manager->m_roomMemberDataRequestId); + sceNpMatching2GetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, nullptr, &manager->m_roomMemberDataRequestId); } break; } @@ -3349,7 +3349,7 @@ int SQRNetworkManager_Vita::BasicEventCallback(int event, int retCode, uint32_t PSVITA_STUBBED; // SQRNetworkManager_Vita *manager = (SQRNetworkManager_Vita *)arg; // // We aren't allowed to actually get the event directly from this callback, so send our own internal event to a thread dedicated to doing this - // sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, NULL); + // sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, nullptr); return 0; } @@ -3408,7 +3408,7 @@ void SQRNetworkManager_Vita::SysUtilCallback(uint64_t status, uint64_t param, vo // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } // return; // } @@ -3423,7 +3423,7 @@ void SQRNetworkManager_Vita::SysUtilCallback(uint64_t status, uint64_t param, vo // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } // } // @@ -3472,7 +3472,7 @@ void SQRNetworkManager_Vita::updateNetCheckDialog() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } else @@ -3488,7 +3488,7 @@ void SQRNetworkManager_Vita::updateNetCheckDialog() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -3611,7 +3611,7 @@ void SQRNetworkManager_Vita::RudpContextCallback(int ctx_id, int event_id, int e playerFrom = manager->m_aRoomSlotPlayers[0]; playerTo = manager->GetPlayerFromRudpCtx( ctx_id ); } - if( ( playerFrom != NULL ) && ( playerTo != NULL ) ) + if( ( playerFrom != nullptr ) && ( playerTo != nullptr ) ) { manager->m_listener->HandleDataReceived( playerFrom, playerTo, data, bytesRead ); } @@ -3677,7 +3677,7 @@ void SQRNetworkManager_Vita::ServerContextValid_CreateRoom() { app.DebugPrintf("sceNpMatching2GetWorldInfoList\n"); m_getWorldRequestId=0; - ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, NULL, &m_getWorldRequestId); + ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, nullptr, &m_getWorldRequestId); } if (ret < 0) { @@ -3706,7 +3706,7 @@ void SQRNetworkManager_Vita::ServerContextValid_JoinRoom() reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, NULL, &m_joinRoomRequestId ); + int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, nullptr, &m_joinRoomRequestId ); if ( (ret < 0) || ForceErrorPoint(SNM_FORCE_ERROR_JOIN_ROOM) ) { if( ret == SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH) @@ -3730,14 +3730,14 @@ const SceNpCommunicationSignature* SQRNetworkManager_Vita::GetSceNpCommsSig() const SceNpTitleId* SQRNetworkManager_Vita::GetSceNpTitleId() { PSVITA_STUBBED; - return NULL; + return nullptr; // return &s_npTitleId; } const SceNpTitleSecret* SQRNetworkManager_Vita::GetSceNpTitleSecret() { PSVITA_STUBBED; - return NULL; + return nullptr; // return &s_npTitleSecret; } @@ -3771,9 +3771,9 @@ void SQRNetworkManager_Vita::GetExtDataForRoom( SceNpMatching2RoomId roomId, voi static SceNpMatching2RoomId aRoomId[1]; static SceNpMatching2AttributeId attr[1]; - // All parameters will be NULL if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). - // NULL parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList - if( extData != NULL ) + // All parameters will be nullptr if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). + // nullptr parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList + if( extData != nullptr ) { aRoomId[0] = roomId; attr[0] = SCE_NP_MATCHING2_ROOM_BIN_ATTR_EXTERNAL_1_ID; @@ -3797,14 +3797,14 @@ void SQRNetworkManager_Vita::GetExtDataForRoom( SceNpMatching2RoomId roomId, voi return; } - // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with nullptr params) once done, so we can reattempt. Don't do anything more now. if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { app.DebugPrintf("Having to recreate matching context, setting state to SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT\n"); return; } - int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, NULL, &m_roomDataExternalListRequestId ); + int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, nullptr, &m_roomDataExternalListRequestId ); // If we hadn't properly detected that a matching context was unvailable, we might still get an error indicating that it is from the previous call. Handle similarly, but we need // to destroy the context first. @@ -3818,7 +3818,7 @@ void SQRNetworkManager_Vita::GetExtDataForRoom( SceNpMatching2RoomId roomId, voi m_FriendSessionUpdatedFn(false, m_pParamFriendSessionUpdated); return; }; - // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with nullptr params) once done, so we can reattempt. Don't do anything more now. if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { return; @@ -3957,7 +3957,7 @@ void SQRNetworkManager_Vita::AttemptPSNSignIn(int (*SignInCompleteCallbackFn)(vo { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -4127,6 +4127,6 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerByXuid(PlayerUID xuid) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } diff --git a/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.h b/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.h index 0fd0b4149..79befe039 100644 --- a/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.h +++ b/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.h @@ -149,7 +149,7 @@ class SQRNetworkManager_Vita : public SQRNetworkManager void LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize); int GetSessionIndex(SQRNetworkPlayer *player); - bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = NULL ); + bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = nullptr ); void RemoveRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int mask ); void RemoveNetworkPlayers( int mask ); void SetLocalPlayersAndSync(); diff --git a/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.cpp index 09852ccbe..88e661c6c 100644 --- a/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.cpp @@ -10,22 +10,22 @@ bool SonyCommerce_Vita::m_bCommerceInitialised = false; // SceNpCommerce2SessionInfo SonyCommerce_Vita::m_sessionInfo; SonyCommerce_Vita::State SonyCommerce_Vita::m_state = e_state_noSession; int SonyCommerce_Vita::m_errorCode = 0; -LPVOID SonyCommerce_Vita::m_callbackParam = NULL; +LPVOID SonyCommerce_Vita::m_callbackParam = nullptr; -void* SonyCommerce_Vita::m_receiveBuffer = NULL; +void* SonyCommerce_Vita::m_receiveBuffer = nullptr; SonyCommerce_Vita::Event SonyCommerce_Vita::m_event; std::queue SonyCommerce_Vita::m_messageQueue; -std::vector* SonyCommerce_Vita::m_pProductInfoList = NULL; -SonyCommerce_Vita::ProductInfoDetailed* SonyCommerce_Vita::m_pProductInfoDetailed = NULL; -SonyCommerce_Vita::ProductInfo* SonyCommerce_Vita::m_pProductInfo = NULL; +std::vector* SonyCommerce_Vita::m_pProductInfoList = nullptr; +SonyCommerce_Vita::ProductInfoDetailed* SonyCommerce_Vita::m_pProductInfoDetailed = nullptr; +SonyCommerce_Vita::ProductInfo* SonyCommerce_Vita::m_pProductInfo = nullptr; -SonyCommerce_Vita::CategoryInfo* SonyCommerce_Vita::m_pCategoryInfo = NULL; -const char* SonyCommerce_Vita::m_pProductID = NULL; -char* SonyCommerce_Vita::m_pCategoryID = NULL; +SonyCommerce_Vita::CategoryInfo* SonyCommerce_Vita::m_pCategoryInfo = nullptr; +const char* SonyCommerce_Vita::m_pProductID = nullptr; +char* SonyCommerce_Vita::m_pCategoryID = nullptr; SonyCommerce_Vita::CheckoutInputParams SonyCommerce_Vita::m_checkoutInputParams; SonyCommerce_Vita::DownloadListInputParams SonyCommerce_Vita::m_downloadInputParams; -SonyCommerce_Vita::CallbackFunc SonyCommerce_Vita::m_callbackFunc = NULL; +SonyCommerce_Vita::CallbackFunc SonyCommerce_Vita::m_callbackFunc = nullptr; // sys_memory_container_t SonyCommerce_Vita::m_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; bool SonyCommerce_Vita::m_bUpgradingTrial = false; @@ -39,7 +39,7 @@ bool SonyCommerce_Vita::m_contextCreated=false; ///< npcommerce2 conte SonyCommerce_Vita::Phase SonyCommerce_Vita::m_currentPhase = e_phase_stopped; ///< Current commerce2 util // char SonyCommerce_Vita::m_commercebuffer[SCE_NP_COMMERCE2_RECV_BUF_SIZE]; -C4JThread* SonyCommerce_Vita::m_tickThread = NULL; +C4JThread* SonyCommerce_Vita::m_tickThread = nullptr; bool SonyCommerce_Vita::m_bLicenseChecked=false; // Check the trial/full license for the game bool SonyCommerce_Vita::m_bLicenseInstalled=false; // set to true when the licence has been downloaded and installed (but maybe not checked yet) bool SonyCommerce_Vita::m_bDownloadsPending=false; // set to true if there are any downloads happening in the background, so we check for them completing, and install when finished @@ -60,12 +60,12 @@ static bool s_showingPSStoreIcon = false; SonyCommerce_Vita::ProductInfoDetailed s_trialUpgradeProductInfoDetailed; void SonyCommerce_Vita::Delete() { - m_pProductInfoList=NULL; - m_pProductInfoDetailed=NULL; - m_pProductInfo=NULL; - m_pCategoryInfo = NULL; - m_pProductID = NULL; - m_pCategoryID = NULL; + m_pProductInfoList=nullptr; + m_pProductInfoDetailed=nullptr; + m_pProductInfo=nullptr; + m_pCategoryInfo = nullptr; + m_pProductID = nullptr; + m_pCategoryID = nullptr; } void SonyCommerce_Vita::Init() @@ -108,7 +108,7 @@ bool SonyCommerce_Vita::LicenseChecked() void SonyCommerce_Vita::CheckForTrialUpgradeKey() { - StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, NULL); + StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, nullptr); } int SonyCommerce_Vita::Shutdown() @@ -163,7 +163,7 @@ void SonyCommerce_Vita::checkBackgroundDownloadStatus() // install the content if(bInstallContent) { - InstallContent(InstallContentCallback, NULL); + InstallContent(InstallContentCallback, nullptr); } } } @@ -665,7 +665,7 @@ int SonyCommerce_Vita::createContext() // } // // // Create commerce2 context - // ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, NULL, &m_contextId); + // ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, nullptr, &m_contextId); // if (ret < 0) // { // app.DebugPrintf(4,"createContext sceNpCommerce2CreateCtx problem\n"); @@ -771,7 +771,7 @@ void SonyCommerce_Vita::commerce2Handler( const sce::Toolkit::NP::Event& event) // if(ret == SCE_OK) // { copyCategoryInfo(m_pCategoryInfo, g_categoryInfo.get()); - m_pCategoryInfo = NULL; + m_pCategoryInfo = nullptr; m_event = e_event_commerceGotCategoryInfo; // } @@ -781,7 +781,7 @@ void SonyCommerce_Vita::commerce2Handler( const sce::Toolkit::NP::Event& event) case sce::Toolkit::NP::Event::UserEvent::commerceGotProductList: { copyProductList(m_pProductInfoList, g_productList.get()); - m_pProductInfoDetailed = NULL; + m_pProductInfoDetailed = nullptr; m_event = e_event_commerceGotProductList; break; } @@ -791,12 +791,12 @@ void SonyCommerce_Vita::commerce2Handler( const sce::Toolkit::NP::Event& event) if(m_pProductInfoDetailed) { copyDetailedProductInfo(m_pProductInfoDetailed, g_detailedProductInfo.get()); - m_pProductInfoDetailed = NULL; + m_pProductInfoDetailed = nullptr; } else { copyAddDetailedProductInfo(m_pProductInfo, g_detailedProductInfo.get()); - m_pProductInfo = NULL; + m_pProductInfo = nullptr; } m_event = e_event_commerceGotDetailedProductInfo; break; @@ -1180,7 +1180,7 @@ void SonyCommerce_Vita::processEvent() break; case e_event_commerceProductBrowseFinished: app.DebugPrintf(4,"e_event_commerceProductBrowseFinished succeeded: 0x%x\n", m_errorCode); - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1232,7 +1232,7 @@ void SonyCommerce_Vita::processEvent() ProfileManager.SetSysUIShowing(false); // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { // get the detailed product info again, to see if the purchase has happened or not EnterCriticalSection(&m_queueLock); @@ -1260,7 +1260,7 @@ void SonyCommerce_Vita::processEvent() ProfileManager.SetSysUIShowing(false); // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1328,10 +1328,10 @@ void SonyCommerce_Vita::CreateSession( CallbackFunc cb, LPVOID lpParam ) if(m_tickThread && (m_tickThread->isRunning() == false)) { delete m_tickThread; - m_tickThread = NULL; + m_tickThread = nullptr; } - if(m_tickThread == NULL) - m_tickThread = new C4JThread(TickLoop, NULL, "SonyCommerce_Vita tick"); + if(m_tickThread == nullptr) + m_tickThread = new C4JThread(TickLoop, nullptr, "SonyCommerce_Vita tick"); if(m_tickThread->isRunning() == false) { m_currentPhase = e_phase_idle; @@ -1439,7 +1439,7 @@ void SonyCommerce_Vita::DownloadAlreadyPurchased_Game( CallbackFunc cb, LPVOID l void SonyCommerce_Vita::InstallContent( CallbackFunc cb, LPVOID lpParam ) { - if(m_callbackFunc == NULL && m_messageQueue.size() == 0) // wait till other processes have finished + if(m_callbackFunc == nullptr && m_messageQueue.size() == 0) // wait till other processes have finished { EnterCriticalSection(&m_queueLock); m_bInstallingContent = true; diff --git a/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.h b/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.h index 6285832cd..c8f76bf7d 100644 --- a/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.h +++ b/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.h @@ -121,14 +121,14 @@ class SonyCommerce_Vita : public SonyCommerce { assert(m_callbackFunc); CallbackFunc func = m_callbackFunc; - m_callbackFunc = NULL; + m_callbackFunc = nullptr; if(func) func(m_callbackParam, m_errorCode); m_errorCode = SCE_OK; } static void setCallback(CallbackFunc cb,LPVOID lpParam) { - assert(m_callbackFunc == NULL); + assert(m_callbackFunc == nullptr); m_callbackFunc = cb; m_callbackParam = lpParam; } diff --git a/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp index fd311fa7b..2015f9303 100644 --- a/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp @@ -215,7 +215,7 @@ bool SonyHttp_Vita::http_get(const char *targetUrl, void** ppOutData, int* pData } reqId = ret; - ret = sceHttpSendRequest(reqId, NULL, 0); + ret = sceHttpSendRequest(reqId, nullptr, 0); if (ret < 0) { app.DebugPrintf("sceHttpSendRequest() error: 0x%08X\n", ret); diff --git a/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp index ed7fa5ccb..dd6c83727 100644 --- a/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp @@ -218,7 +218,7 @@ bool SonyRemoteStorage_Vita::init(CallbackFunc cb, LPVOID lpParam) params.timeout.receiveMs = 120 * 1000; //120 seconds is the default params.timeout.sendMs = 120 * 1000; //120 seconds is the default params.pool.memPoolSize = 7 * 1024 * 1024; - if(m_memPoolBuffer == NULL) + if(m_memPoolBuffer == nullptr) m_memPoolBuffer = malloc(params.pool.memPoolSize); params.pool.memPoolBuffer = m_memPoolBuffer; @@ -298,7 +298,7 @@ bool SonyRemoteStorage_Vita::setDataInternal() snprintf(m_saveFilename, sizeof(m_saveFilename), "%s:%s/GAMEDATA.bin", "savedata0", m_setDataSaveInfo->UTF8SaveFilename); - SceFiosSize outSize = sceFiosFileGetSizeSync(NULL, m_saveFilename); + SceFiosSize outSize = sceFiosFileGetSizeSync(nullptr, m_saveFilename); m_uploadSaveSize = static_cast(outSize); strcpy(m_saveFileDesc, m_setDataSaveInfo->UTF8SaveTitle); diff --git a/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp index 842e6b8de..9833f6fe0 100644 --- a/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp @@ -67,7 +67,7 @@ void LoadPCMVoiceData() { char filename[64]; sprintf(filename, "voice%d.pcm", i+1); - HANDLE file = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(filename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); DWORD dwHigh=0; g_loadedPCMVoiceDataSizes[i] = GetFileSize(file,&dwHigh); @@ -75,7 +75,7 @@ void LoadPCMVoiceData() { g_loadedPCMVoiceData[i] = new char[g_loadedPCMVoiceDataSizes[i]]; DWORD bytesRead; - BOOL bSuccess = ReadFile(file, g_loadedPCMVoiceData[i], g_loadedPCMVoiceDataSizes[i], &bytesRead, NULL); + BOOL bSuccess = ReadFile(file, g_loadedPCMVoiceData[i], g_loadedPCMVoiceDataSizes[i], &bytesRead, nullptr); assert(bSuccess); } g_loadedPCMVoiceDataPos[i] = 0; @@ -285,7 +285,7 @@ void SQRVoiceConnection::readRemoteData() if( dataSize > 0 ) { VoicePacket packet; - unsigned int bytesRead = sceRudpRead( m_rudpCtx, &packet, dataSize, 0, NULL ); + unsigned int bytesRead = sceRudpRead( m_rudpCtx, &packet, dataSize, 0, nullptr ); unsigned int writeSize; if( bytesRead > 0 ) { @@ -470,7 +470,7 @@ void SonyVoiceChat_Vita::sendAllVoiceData() if(m_localVoiceDevices[i].isValid()) { bool bChatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(i,true,&bChatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(i,true,&bChatRestricted,nullptr,nullptr); if(bChatRestricted) { @@ -911,7 +911,7 @@ void SonyVoiceChat_Vita::initLocalPlayer(int playerIndex) if(m_localVoiceDevices[playerIndex].isValid() == false) { bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,nullptr,nullptr); // create all device ports required m_localVoiceDevices[playerIndex].init(chatRestricted); @@ -948,7 +948,7 @@ SQRVoiceConnection* SonyVoiceChat_Vita::GetVoiceConnectionFromRudpCtx( int RudpC if(m_remoteConnections[i]->m_rudpCtx == RudpCtx) return m_remoteConnections[i]; } - return NULL; + return nullptr; } void SonyVoiceChat_Vita::connectPlayerToAll( int playerIndex ) @@ -973,7 +973,7 @@ SQRVoiceConnection* SonyVoiceChat_Vita::getVoiceConnectionFromRoomMemberID( SceN } } - return NULL; + return nullptr; } void SonyVoiceChat_Vita::disconnectLocalPlayer( int localIdx ) diff --git a/Minecraft.Client/PSVita/PSVitaExtras/CustomMap.cpp b/Minecraft.Client/PSVita/PSVitaExtras/CustomMap.cpp index 9203c30d0..7265eb041 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/CustomMap.cpp +++ b/Minecraft.Client/PSVita/PSVitaExtras/CustomMap.cpp @@ -4,7 +4,7 @@ CustomMap::CustomMap() { - m_NodePool = NULL; + m_NodePool = nullptr; m_NodePoolSize = 0; m_NodePoolIndex = 0; @@ -87,7 +87,7 @@ void CustomMap::insert(const ChunkPos &Key, bool Value) Node->Hash = Hash; Node->first = Key; Node->second = Value; - Node->Next = NULL; + Node->Next = nullptr; // are any nodes in this hash index if( !m_HashTable[Index] ) diff --git a/Minecraft.Client/PSVita/PSVitaExtras/CustomSet.cpp b/Minecraft.Client/PSVita/PSVitaExtras/CustomSet.cpp index 108425931..4b96f1aa7 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/CustomSet.cpp +++ b/Minecraft.Client/PSVita/PSVitaExtras/CustomSet.cpp @@ -4,7 +4,7 @@ CustomSet::CustomSet() { - m_NodePool = NULL; + m_NodePool = nullptr; m_NodePoolSize = 0; m_NodePoolIndex = 0; @@ -85,7 +85,7 @@ void CustomSet::insert(const ChunkPos &Key) unsigned int Index = Hash & (m_HashSize-1); Node->Hash = Hash; Node->key = Key; - Node->Next = NULL; + Node->Next = nullptr; // are any nodes in this hash index if( !m_HashTable[Index] ) diff --git a/Minecraft.Client/PSVita/PSVitaExtras/PSVitaStrings.cpp b/Minecraft.Client/PSVita/PSVitaExtras/PSVitaStrings.cpp index ad9e423bb..b33a56015 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/PSVitaStrings.cpp +++ b/Minecraft.Client/PSVita/PSVitaExtras/PSVitaStrings.cpp @@ -15,7 +15,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID) if( result != S_OK ) { app.DebugPrintf("sceCesUcsContextInit failed\n"); - return NULL; + return nullptr; } uint32_t utf16Len; @@ -44,7 +44,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID) if( result != SCE_OK ) { app.DebugPrintf("sceCesUtf16StrToUtf8Str: conversion error : 0x%x\n", result); - return NULL; + return nullptr; } return strUtf8; diff --git a/Minecraft.Client/PSVita/PSVitaExtras/PSVitaTLSStorage.cpp b/Minecraft.Client/PSVita/PSVitaExtras/PSVitaTLSStorage.cpp index 0261f318a..054e9f025 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/PSVitaTLSStorage.cpp +++ b/Minecraft.Client/PSVita/PSVitaExtras/PSVitaTLSStorage.cpp @@ -137,7 +137,7 @@ BOOL PSVitaTLSStorage::SetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) #else -PSVitaTLSStorage* m_pInstance = NULL; +PSVitaTLSStorage* m_pInstance = nullptr; #define sc_maxSlots 64 BOOL m_activeList[sc_maxSlots]; @@ -157,7 +157,7 @@ void PSVitaTLSStorage::Init() for(int i=0;iwMilliseconds = sceRtcGetMicrosecond(&dateTime)/1000; } -HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { PSVITA_STUBBED; return NULL; } +HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { PSVITA_STUBBED; return nullptr; } VOID Sleep(DWORD dwMilliseconds) { C4JThread::Sleep(dwMilliseconds); @@ -186,7 +186,7 @@ VOID InitializeCriticalSection(PCRITICAL_SECTION CriticalSection) { char name[1] = {0}; - int err = sceKernelCreateLwMutex((SceKernelLwMutexWork *)(&CriticalSection->mutex), name, SCE_KERNEL_LW_MUTEX_ATTR_TH_PRIO | SCE_KERNEL_LW_MUTEX_ATTR_RECURSIVE, 0, NULL); + int err = sceKernelCreateLwMutex((SceKernelLwMutexWork *)(&CriticalSection->mutex), name, SCE_KERNEL_LW_MUTEX_ATTR_TH_PRIO | SCE_KERNEL_LW_MUTEX_ATTR_RECURSIVE, 0, nullptr); PSVITA_ASSERT_SCE_ERROR(err); } @@ -207,7 +207,7 @@ extern CRITICAL_SECTION g_singleThreadCS; VOID EnterCriticalSection(PCRITICAL_SECTION CriticalSection) { - int err = sceKernelLockLwMutex ((SceKernelLwMutexWork *)(&CriticalSection->mutex), 1, NULL); + int err = sceKernelLockLwMutex ((SceKernelLwMutexWork *)(&CriticalSection->mutex), 1, nullptr); PSVITA_ASSERT_SCE_ERROR(err); } @@ -233,7 +233,7 @@ VOID InitializeCriticalRWSection(PCRITICAL_RW_SECTION CriticalSection) { char name[1] = {0}; - CriticalSection->RWLock = sceKernelCreateRWLock(name, SCE_KERNEL_RW_LOCK_ATTR_TH_PRIO | SCE_KERNEL_RW_LOCK_ATTR_RECURSIVE, NULL); + CriticalSection->RWLock = sceKernelCreateRWLock(name, SCE_KERNEL_RW_LOCK_ATTR_TH_PRIO | SCE_KERNEL_RW_LOCK_ATTR_RECURSIVE, nullptr); } VOID DeleteCriticalRWSection(PCRITICAL_RW_SECTION CriticalSection) @@ -274,7 +274,7 @@ VOID LeaveCriticalRWSection(PCRITICAL_RW_SECTION CriticalSection, bool Write) BOOL CloseHandle(HANDLE hObject) { - sceFiosFHCloseSync(NULL,(SceFiosFH)((int32_t)hObject)); + sceFiosFHCloseSync(nullptr,(SceFiosFH)((int32_t)hObject)); return true; } @@ -514,7 +514,7 @@ BOOL VirtualWriteFile(LPCSTR lpFileName, LPCVOID lpBuffer, DWORD nNumberOfBytesT void* Data = VirtualAllocs[Page]; DWORD numberOfBytesWritten=0; - WriteFileWithName(lpFileName, Data, BytesToWrite, &numberOfBytesWritten,NULL); + WriteFileWithName(lpFileName, Data, BytesToWrite, &numberOfBytesWritten,nullptr); *lpNumberOfBytesWritten += numberOfBytesWritten; nNumberOfBytesToWrite -= BytesToWrite; @@ -656,7 +656,7 @@ DWORD GetFileSize( HANDLE hFile, LPDWORD lpFileSizeHigh ) //SceFiosSize FileSize; //FileSize=sceFiosFHGetSize(fh); SceFiosStat statData; - int err = sceFiosFHStatSync(NULL,fh,&statData); + int err = sceFiosFHStatSync(nullptr,fh,&statData); SceFiosOffset FileSize = statData.fileSize; if(lpFileSizeHigh) @@ -675,7 +675,7 @@ BOOL WriteFileWithName(LPCSTR lpFileName, LPCVOID lpBuffer, DWORD nNumberOfByte { char filePath[256]; sprintf(filePath,"%s/%s",getUsrDirPath(), lpFileName ); - SceFiosSize bytesWritten = sceFiosFileWriteSync( NULL, filePath, lpBuffer, nNumberOfBytesToWrite, 0 ); + SceFiosSize bytesWritten = sceFiosFileWriteSync( nullptr, filePath, lpBuffer, nNumberOfBytesToWrite, 0 ); if(bytesWritten != nNumberOfBytesToWrite) { // error @@ -698,7 +698,7 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD { SceFiosFH fh = (SceFiosFH)((int64_t)hFile); // sceFiosFHReadSync - Non-negative values are the number of bytes read, 0 <= result <= length. Negative values are error codes. - SceFiosSize bytesRead = sceFiosFHReadSync(NULL, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToRead); + SceFiosSize bytesRead = sceFiosFHReadSync(nullptr, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToRead); if(bytesRead < 0) { // error @@ -718,7 +718,7 @@ BOOL SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHi uint64_t bitsToMove = (int64_t) lDistanceToMove; SceFiosOffset pos = 0; - if (lpDistanceToMoveHigh != NULL) + if (lpDistanceToMoveHigh != nullptr) bitsToMove |= ((uint64_t) (*lpDistanceToMoveHigh)) << 32; SceFiosWhence whence = SCE_FIOS_SEEK_SET; @@ -761,7 +761,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, if( dwDesiredAccess == GENERIC_WRITE ) { //CD - Create a blank file - int err = sceFiosFileWriteSync( NULL, filePath, NULL, 0, 0 ); + int err = sceFiosFileWriteSync( nullptr, filePath, nullptr, 0, 0 ); assert( err == SCE_FIOS_OK ); } @@ -770,7 +770,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, #endif SceFiosFH fh; - int err = sceFiosFHOpenSync(NULL, &fh, filePath, NULL); + int err = sceFiosFHOpenSync(nullptr, &fh, filePath, nullptr); assert( err == SCE_FIOS_OK ); return (void*)fh; @@ -816,7 +816,7 @@ DWORD GetFileAttributesA(LPCSTR lpFileName) // check if the file exists first SceFiosStat statData; - if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK) + if(sceFiosStatSync(nullptr, filePath, &statData) != SCE_FIOS_OK) { app.DebugPrintf("*** sceFiosStatSync Failed\n"); return -1; @@ -904,7 +904,7 @@ BOOL GetFileAttributesExA(LPCSTR lpFileName,GET_FILEEX_INFO_LEVELS fInfoLevelId, // check if the file exists first SceFiosStat statData; - if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK) + if(sceFiosStatSync(nullptr, filePath, &statData) != SCE_FIOS_OK) { app.DebugPrintf("*** sceFiosStatSync Failed\n"); return false; @@ -937,7 +937,7 @@ errno_t _i64toa_s(__int64 _Val, char * _DstBuf, size_t _Size, int _Radix) { if(_ int _wtoi(const wchar_t *_Str) { - return wcstol(_Str, NULL, 10); + return wcstol(_Str, nullptr, 10); } DWORD XGetLanguage() diff --git a/Minecraft.Client/PSVita/PSVitaExtras/ShutdownManager.cpp b/Minecraft.Client/PSVita/PSVitaExtras/ShutdownManager.cpp index e7eca53f4..a04e45d9f 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/ShutdownManager.cpp +++ b/Minecraft.Client/PSVita/PSVitaExtras/ShutdownManager.cpp @@ -16,12 +16,12 @@ C4JThread::EventArray *ShutdownManager::s_eventArray[eThreadIdCount]; void ShutdownManager::Initialise() { #ifdef __PS3__ - cellSysutilRegisterCallback( 1, SysUtilCallback, NULL ); + cellSysutilRegisterCallback( 1, SysUtilCallback, nullptr ); for( int i = 0; i < eThreadIdCount; i++ ) { s_threadShouldRun[i] = true; s_threadRunning[i] = 0; - s_eventArray[i] = NULL; + s_eventArray[i] = nullptr; } // Special case for storage manager, which we will manually set now to be considered as running - this will be unset by StorageManager.ExitRequest if required s_threadRunning[eStorageManagerThreads] = true; diff --git a/Minecraft.Client/PSVita/PSVitaExtras/libdivide.h b/Minecraft.Client/PSVita/PSVitaExtras/libdivide.h index e480ed198..d3a1d954a 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/libdivide.h +++ b/Minecraft.Client/PSVita/PSVitaExtras/libdivide.h @@ -478,7 +478,7 @@ static uint64_t libdivide_128_div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v, int s; // Shift amount for norm. if (u1 >= v) { // If overflow, set rem. - if (r != NULL) // to an impossible value, + if (r != nullptr) // to an impossible value, *r = static_cast(-1); // and return the largest return static_cast(-1);} // possible quotient. @@ -513,7 +513,7 @@ static uint64_t libdivide_128_div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v, rhat = rhat + vn1; if (rhat < b) goto again2;} - if (r != NULL) // If remainder is wanted, + if (r != nullptr) // If remainder is wanted, *r = (un21*b + un0 - q0*v) >> s; // return it. return q1*b + q0; } @@ -1141,11 +1141,11 @@ namespace libdivide_internal { #endif /* Some bogus unswitch functions for unsigned types so the same (presumably templated) code can work for both signed and unsigned. */ - uint32_t crash_u32(uint32_t, const libdivide_u32_t *) { abort(); return *static_cast(NULL); } - uint64_t crash_u64(uint64_t, const libdivide_u64_t *) { abort(); return *static_cast(NULL); } + uint32_t crash_u32(uint32_t, const libdivide_u32_t *) { abort(); return *static_cast(nullptr); } + uint64_t crash_u64(uint64_t, const libdivide_u64_t *) { abort(); return *static_cast(nullptr); } #if LIBDIVIDE_USE_SSE2 - __m128i crash_u32_vector(__m128i, const libdivide_u32_t *) { abort(); return *(__m128i *)NULL; } - __m128i crash_u64_vector(__m128i, const libdivide_u64_t *) { abort(); return *(__m128i *)NULL; } + __m128i crash_u32_vector(__m128i, const libdivide_u32_t *) { abort(); return *(__m128i *)nullptr; } + __m128i crash_u64_vector(__m128i, const libdivide_u64_t *) { abort(); return *(__m128i *)nullptr; } #endif template diff --git a/Minecraft.Client/PSVita/PSVitaExtras/user_malloc.c b/Minecraft.Client/PSVita/PSVitaExtras/user_malloc.c index 7036728f3..6b0e67b72 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/user_malloc.c +++ b/Minecraft.Client/PSVita/PSVitaExtras/user_malloc.c @@ -52,14 +52,14 @@ typedef struct int Malloc_BlocksAlloced; // this shows how many block node chunks have been allocated in Malloc_BlocksMemory } SThreadStorage; -__thread SThreadStorage *Malloc_ThreadStorage = NULL; +__thread SThreadStorage *Malloc_ThreadStorage = nullptr; /**E Replace _malloc_init function. */ /**J _malloc_init 関数と置き換わる */ void user_malloc_init(void) { int res; - void *base = NULL; + void *base = nullptr; /**E Allocate a memory block from the kernel */ /**J カーネルからメモリブロックを確保する */ @@ -80,7 +80,7 @@ void user_malloc_init(void) /**E Generate mspace */ /**J mspace を生成する */ s_mspace = mspace_create(base, HEAP_SIZE); - if (s_mspace == NULL) { + if (s_mspace == nullptr) { /**E Error handling */ /**J エラー処理 */ sceLibcSetHeapInitError(HEAP_ERROR3); @@ -95,7 +95,7 @@ void user_malloc_finalize(void) { int res; - if (s_mspace != NULL) { + if (s_mspace != nullptr) { /**E Free mspace */ /**J mspace を解放する */ res = mspace_destroy(s_mspace); @@ -104,7 +104,7 @@ void user_malloc_finalize(void) /**J エラー処理 */ __breakpoint(0); } - s_mspace = NULL; + s_mspace = nullptr; } if (SCE_OK <= s_heapUid) { @@ -125,9 +125,9 @@ void user_malloc_finalize(void) void user_registerthread() { Malloc_ThreadStorage = mspace_malloc(s_mspace, sizeof(SThreadStorage)); - Malloc_ThreadStorage->Malloc_Blocks = NULL; + Malloc_ThreadStorage->Malloc_Blocks = nullptr; Malloc_ThreadStorage->Malloc_BlocksAlloced = 0; - Malloc_ThreadStorage->Malloc_MemoryPool = NULL; + Malloc_ThreadStorage->Malloc_MemoryPool = nullptr; } // before a thread is destroyed make sure we free any space it might be holding on to @@ -157,7 +157,7 @@ void user_removethread() } mspace_free(s_mspace, psStorage); - Malloc_ThreadStorage = NULL; + Malloc_ThreadStorage = nullptr; } } @@ -165,19 +165,19 @@ void user_removethread() /**J malloc 関数と置き換わる */ void *user_malloc(size_t size) { - void *p = NULL; + void *p = nullptr; SThreadStorage *psStorage = Malloc_ThreadStorage; if( psStorage ) { // is this the first time we've malloced - if( psStorage->Malloc_MemoryPool == NULL ) + if( psStorage->Malloc_MemoryPool == nullptr ) { // create an array of pointers to Block nodes, one pointer for each memory bytes size up to 1036 psStorage->Malloc_MemoryPool = mspace_malloc(s_mspace, (MaxRetainedBytes+1) * 4); for( int i = 0;i < (MaxRetainedBytes+1);i += 1 ) { - psStorage->Malloc_MemoryPool[i] = NULL; + psStorage->Malloc_MemoryPool[i] = nullptr; } } @@ -261,7 +261,7 @@ void user_free(void *ptr) } // we need a block node to retain the memory on our stack. do we have any block nodes available - if( psStorage->Malloc_Blocks == NULL ) + if( psStorage->Malloc_Blocks == nullptr ) { if( psStorage->Malloc_BlocksAlloced == Malloc_BlocksMemorySize ) { @@ -319,7 +319,7 @@ void *user_calloc(size_t nelem, size_t size) /**J realloc 関数と置き換わる */ void *user_realloc(void *ptr, size_t size) { - void* p = NULL; + void* p = nullptr; if( Malloc_ThreadStorage ) { diff --git a/Minecraft.Client/PSVita/PSVitaExtras/user_malloc_for_tls.c b/Minecraft.Client/PSVita/PSVitaExtras/user_malloc_for_tls.c index 531bbd604..54cc0d728 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/user_malloc_for_tls.c +++ b/Minecraft.Client/PSVita/PSVitaExtras/user_malloc_for_tls.c @@ -27,7 +27,7 @@ void user_free_for_tls(void *ptr); void user_malloc_for_tls_init(void) { int res; - void *base = NULL; + void *base = nullptr; /**E Allocate a memory block from the kernel */ /**J カーネルからメモリブロックを確保する */ @@ -48,7 +48,7 @@ void user_malloc_for_tls_init(void) /**E Generate mspace */ /**J mspace を生成する */ s_mspace = mspace_create(base, HEAP_SIZE); - if (s_mspace == NULL) { + if (s_mspace == nullptr) { /**E Error handling */ /**J エラー処理 */ sceLibcSetHeapInitError(HEAP_ERROR3); @@ -63,7 +63,7 @@ void user_malloc_for_tls_finalize(void) { int res; - if (s_mspace != NULL) { + if (s_mspace != nullptr) { /**E Free mspace */ /**J mspace を解放する */ res = mspace_destroy(s_mspace); diff --git a/Minecraft.Client/PSVita/PSVitaExtras/user_new.cpp b/Minecraft.Client/PSVita/PSVitaExtras/user_new.cpp index 1f71f6d21..b9cc48502 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/user_new.cpp +++ b/Minecraft.Client/PSVita/PSVitaExtras/user_new.cpp @@ -28,13 +28,13 @@ void *user_new(std::size_t size) throw(std::bad_alloc) if (size == 0) size = 1; - while ((ptr = (void *)std::malloc(size)) == NULL) { + while ((ptr = (void *)std::malloc(size)) == nullptr) { /**E Obtain new_handler */ /**J new_handler を取得する */ std::new_handler handler = std::_get_new_handler(); - /**E When new_handler is a NULL pointer, bad_alloc is send. If not, new_handler is called. */ - /**J new_handler が NULL ポインタの場合、bad_alloc を送出する、そうでない場合、new_handler を呼び出す */ + /**E When new_handler is a nullptr pointer, bad_alloc is send. If not, new_handler is called. */ + /**J new_handler が nullptr ポインタの場合、bad_alloc を送出する、そうでない場合、new_handler を呼び出す */ if (!handler) throw std::bad_alloc(); else @@ -56,22 +56,22 @@ void *user_new(std::size_t size, const std::nothrow_t& x) throw() if (size == 0) size = 1; - while ((ptr = (void *)std::malloc(size)) == NULL) { + while ((ptr = (void *)std::malloc(size)) == nullptr) { /**E Obtain new_handler */ /**J new_handler を取得する */ std::new_handler handler = std::_get_new_handler(); - /**E When new_handler is a NULL pointer, NULL is returned. */ - /**J new_handler が NULL ポインタの場合、NULL を返す */ + /**E When new_handler is a nullptr pointer, nullptr is returned. */ + /**J new_handler が nullptr ポインタの場合、nullptr を返す */ if (!handler) - return NULL; + return nullptr; - /**E Call new_handler. If new_handler sends bad_alloc, NULL is returned. */ - /**J new_handler を呼び出す、new_handler が bad_alloc を送出した場合、NULL を返す */ + /**E Call new_handler. If new_handler sends bad_alloc, nullptr is returned. */ + /**J new_handler を呼び出す、new_handler が bad_alloc を送出した場合、nullptr を返す */ try { (*handler)(); } catch (std::bad_alloc) { - return NULL; + return nullptr; } } return ptr; @@ -98,9 +98,9 @@ void *user_new_array(std::size_t size, const std::nothrow_t& x) throw() void user_delete(void *ptr) throw() { // SCE_DBG_LOG_TRACE("Called operator delete(%p)", ptr); - /**E In the case of the NULL pointer, no action will be taken. */ - /**J NULL ポインタの場合、何も行わない */ - if (ptr != NULL) + /**E In the case of the nullptr pointer, no action will be taken. */ + /**J nullptr ポインタの場合、何も行わない */ + if (ptr != nullptr) std::free(ptr); } diff --git a/Minecraft.Client/PSVita/PSVitaExtras/zlib.h b/Minecraft.Client/PSVita/PSVitaExtras/zlib.h index 3e0c7672a..b0e74c454 100644 --- a/Minecraft.Client/PSVita/PSVitaExtras/zlib.h +++ b/Minecraft.Client/PSVita/PSVitaExtras/zlib.h @@ -91,7 +91,7 @@ typedef struct z_stream_s { uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total number of bytes output so far */ - z_const char *msg; /* last error message, NULL if no error */ + z_const char *msg; /* last error message, nullptr if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ @@ -1254,7 +1254,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); reading, this will be detected automatically by looking for the magic two- byte gzip header. - gzopen returns NULL if the file could not be opened, if there was + gzopen returns nullptr if the file could not be opened, if there was insufficient memory to allocate the gzFile state, or if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). errno can be checked to determine if the reason gzopen failed was that the @@ -1277,7 +1277,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); close the associated file descriptor, so they need to have different file descriptors. - gzdopen returns NULL if there was insufficient memory to allocate the + gzdopen returns nullptr if there was insufficient memory to allocate the gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided), or if fd is -1. The file descriptor is not used until the next gz* read, write, seek, or close operation, so gzdopen @@ -1377,7 +1377,7 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); string is terminated with a null character. If no characters are read due to an end-of-file or len < 1, then the buffer is left untouched. - gzgets returns buf which is a null-terminated string, or it returns NULL + gzgets returns buf which is a null-terminated string, or it returns nullptr for end-of-file or in case of error. If there was an error, the contents at buf are indeterminate. */ @@ -1393,7 +1393,7 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file + it does not check to see if file is nullptr, nor whether the structure file points to has been clobbered or not. */ diff --git a/Minecraft.Client/PSVita/PSVita_App.cpp b/Minecraft.Client/PSVita/PSVita_App.cpp index 956e10b62..8502e5208 100644 --- a/Minecraft.Client/PSVita/PSVita_App.cpp +++ b/Minecraft.Client/PSVita/PSVita_App.cpp @@ -32,15 +32,15 @@ CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() m_bVoiceChatAndUGCRestricted=false; m_bDisplayFullVersionPurchase=false; - m_ProductListA=NULL; + m_ProductListA=nullptr; m_pRemoteStorage = new SonyRemoteStorage_Vita; m_bSaveIncompleteDialogRunning = false; m_bSaveDataDeleteDialogState = eSaveDataDeleteState_idle; - m_pSaveToDelete = NULL; - m_pCheckoutProductInfo = NULL; + m_pSaveToDelete = nullptr; + m_pCheckoutProductInfo = nullptr; } void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) @@ -62,7 +62,7 @@ char *CConsoleMinecraftApp::GetCommerceCategory() } char *CConsoleMinecraftApp::GetTexturePacksCategoryID() { - return NULL; // ProductCodes.chTexturePackID; + return nullptr; // ProductCodes.chTexturePackID; } char *CConsoleMinecraftApp::GetUpgradeKey() { @@ -101,7 +101,7 @@ SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfo(char *pchTitle) { app.DebugPrintf("Couldn't find DLC info for %s\n", pchTitle); assert(0); - return NULL; + return nullptr; } return it->second; @@ -118,7 +118,7 @@ SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfo(int iTexturePackID) if(it->second->iConfig == iTexturePackID) return it->second; } - return NULL; + return nullptr; } @@ -128,7 +128,7 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() char chDLCTitle[64]; // 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds - HANDLE file = CreateFile("PSVita/PSVitaProductCodes.bin", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile("PSVita/PSVitaProductCodes.bin", GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { DWORD error = GetLastError(); @@ -143,13 +143,13 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() { DWORD bytesRead; - WRAPPED_READFILE(file,ProductCodes.chProductCode,PRODUCT_CODE_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,NULL); - //WRAPPED_READFILE(file,ProductCodes.chDiscSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,NULL); - WRAPPED_READFILE(file,ProductCodes.chCommerceCategory,COMMERCE_CATEGORY_SIZE,&bytesRead,NULL); - //WRAPPED_READFILE(file,ProductCodes.chTexturePackID,SCE_NP_COMMERCE2_CATEGORY_ID_LEN,&bytesRead,NULL); // TODO - WRAPPED_READFILE(file,ProductCodes.chUpgradeKey,UPGRADE_KEY_SIZE,&bytesRead,NULL); - //WRAPPED_READFILE(file,ProductCodes.chSkuPostfix,SKU_POSTFIX_SIZE,&bytesRead,NULL); + WRAPPED_READFILE(file,ProductCodes.chProductCode,PRODUCT_CODE_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,nullptr); + //WRAPPED_READFILE(file,ProductCodes.chDiscSaveFolderPrefix,SAVEFOLDERPREFIX_SIZE,&bytesRead,nullptr); + WRAPPED_READFILE(file,ProductCodes.chCommerceCategory,COMMERCE_CATEGORY_SIZE,&bytesRead,nullptr); + //WRAPPED_READFILE(file,ProductCodes.chTexturePackID,SCE_NP_COMMERCE2_CATEGORY_ID_LEN,&bytesRead,nullptr); // TODO + WRAPPED_READFILE(file,ProductCodes.chUpgradeKey,UPGRADE_KEY_SIZE,&bytesRead,nullptr); + //WRAPPED_READFILE(file,ProductCodes.chSkuPostfix,SKU_POSTFIX_SIZE,&bytesRead,nullptr); app.DebugPrintf("ProductCodes.chProductCode %s\n",ProductCodes.chProductCode); app.DebugPrintf("ProductCodes.chSaveFolderPrefix %s\n",ProductCodes.chSaveFolderPrefix); @@ -161,7 +161,7 @@ BOOL CConsoleMinecraftApp::ReadProductCodes() // DLC unsigned int uiDLC; - WRAPPED_READFILE(file,&uiDLC,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&uiDLC,sizeof(int),&bytesRead,nullptr); for(unsigned int i=0;ichDLCKeyname,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,pDLCInfo->chDLCKeyname,sizeof(char)*uiVal,&bytesRead,nullptr); - WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,NULL); + WRAPPED_READFILE(file,&uiVal,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,chDLCTitle,sizeof(char)*uiVal,&bytesRead,nullptr); app.DebugPrintf("DLC title %s\n",chDLCTitle); - WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,NULL); - WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,NULL); + WRAPPED_READFILE(file,&pDLCInfo->eDLCType,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,&pDLCInfo->iFirstSkin,sizeof(int),&bytesRead,nullptr); + WRAPPED_READFILE(file,&pDLCInfo->iConfig,sizeof(int),&bytesRead,nullptr); // push this into a vector @@ -296,7 +296,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -322,7 +322,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() NetworkGameInitData *param = new NetworkGameInitData(); param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; g_NetworkManager.HostGame(0,false,true,MINECRAFT_NET_MAX_PLAYERS,0); @@ -545,7 +545,7 @@ SonyCommerce::CategoryInfo *CConsoleMinecraftApp::GetCategoryInfo() { if(m_bCommerceCategoriesRetrieved==false) { - return NULL; + return nullptr; } return &m_CategoryInfo; @@ -561,10 +561,10 @@ void CConsoleMinecraftApp::ClearCommerceDetails() pProductList->clear(); } - if(m_ProductListA!=NULL) + if(m_ProductListA!=nullptr) { delete [] m_ProductListA; - m_ProductListA=NULL; + m_ProductListA=nullptr; } m_ProductListRetrievedC=0; @@ -613,7 +613,7 @@ void CConsoleMinecraftApp::GetDLCSkuIDFromProductList(char * pchDLCProductID, ch void CConsoleMinecraftApp::Checkout(char *pchSkuID) { - SonyCommerce::ProductInfo* productInfo = NULL; + SonyCommerce::ProductInfo* productInfo = nullptr; for(int i=0;i* CConsoleMinecraftApp::GetProductList(int { if((m_bCommerceProductListRetrieved==false) || (m_bProductListAdditionalDetailsRetrieved==false) ) { - return NULL; + return nullptr; } return &m_ProductListA[iIndex]; @@ -1076,7 +1076,7 @@ bool CConsoleMinecraftApp::CheckForEmptyStore(int iPad) SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo(); bool bEmptyStore=true; - if(pCategories!=NULL) + if(pCategories!=nullptr) { if(pCategories->countOfProducts>0) { @@ -1288,7 +1288,7 @@ int CConsoleMinecraftApp::cbConfirmDeleteMessageBox(void *pParam, int iPad, cons { CConsoleMinecraftApp *pClass = (CConsoleMinecraftApp*) pParam; - if (pClass != NULL && pClass->m_pSaveToDelete != NULL) + if (pClass != nullptr && pClass->m_pSaveToDelete != nullptr) { if (result == C4JStorage::EMessage_ResultDecline) { @@ -1408,12 +1408,12 @@ void CConsoleMinecraftApp::initSaveDataDeleteDialog() ui.SetSysUIShowing(true); // Start getting saves data to use when deleting. - if (StorageManager.ReturnSavesInfo() == NULL) + if (StorageManager.ReturnSavesInfo() == nullptr) { C4JStorage::ESaveGameState eSGIStatus = StorageManager.GetSavesInfo( ProfileManager.GetPrimaryPad(), - NULL, + nullptr, this, "save" ); @@ -1471,15 +1471,15 @@ void CConsoleMinecraftApp::updateSaveDataDeleteDialog() if ( dialogResult.result == SCE_COMMON_DIALOG_RESULT_OK ) { SceAppUtilSaveDataSlotParam slotParam; - ret = sceAppUtilSaveDataSlotGetParam( dialogResult.slotId, &slotParam, NULL ); + ret = sceAppUtilSaveDataSlotGetParam( dialogResult.slotId, &slotParam, nullptr ); if (ret == SCE_OK) { int saveindex = -1; - PSAVE_INFO pSaveInfo = NULL; + PSAVE_INFO pSaveInfo = nullptr; PSAVE_DETAILS pSaveDetails = StorageManager.ReturnSavesInfo(); - if (pSaveDetails != NULL) + if (pSaveDetails != nullptr) { app.DebugPrintf("[SaveDataDeleteDialog] Searching for save files:\n"); @@ -1504,7 +1504,7 @@ void CConsoleMinecraftApp::updateSaveDataDeleteDialog() app.DebugPrintf("[SaveDataDeleteDialog] ERROR: PERFORMING DELETE OPERATION, pSavesDetails is null.\n"); } - if (pSaveInfo != NULL) + if (pSaveInfo != nullptr) { app.DebugPrintf( "[SaveDataDeleteDialog] User wishes to delete slot_%d:\n\t" @@ -1603,7 +1603,7 @@ void CConsoleMinecraftApp::getSaveDataDeleteDialogParam(SceSaveDataDialogParam * for (unsigned int i = 2; i < SCE_APPUTIL_SAVEDATA_SLOT_MAX; i++) { SceAppUtilSaveDataSlotParam slotParam; - int ret = sceAppUtilSaveDataSlotGetParam( i, &slotParam, NULL ); + int ret = sceAppUtilSaveDataSlotGetParam( i, &slotParam, nullptr ); if (ret == SCE_OK) { @@ -1645,8 +1645,8 @@ void CConsoleMinecraftApp::getSaveDataDeleteDialogParam(SceSaveDataDialogParam * // baseParam->commonParam.dimmerColor = &s_dColor; - static uint8_t *strPtr = NULL; - if (strPtr != NULL) delete strPtr; + static uint8_t *strPtr = nullptr; + if (strPtr != nullptr) delete strPtr; strPtr = mallocAndCreateUTF8ArrayFromString( IDS_TOOLTIPS_DELETESAVE ); listParam.listTitle = (const SceChar8 *) strPtr; diff --git a/Minecraft.Client/PSVita/PSVita_App.h b/Minecraft.Client/PSVita/PSVita_App.h index 209fb91a0..5e31a3bea 100644 --- a/Minecraft.Client/PSVita/PSVita_App.h +++ b/Minecraft.Client/PSVita/PSVita_App.h @@ -83,7 +83,7 @@ class CConsoleMinecraftApp : public CMinecraftApp // BANNED LEVEL LIST virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {} - C4JStringTable *GetStringTable() { return NULL;} + C4JStringTable *GetStringTable() { return nullptr;} // original code virtual void TemporaryCreateGameStart(); diff --git a/Minecraft.Client/PSVita/PSVita_Minecraft.cpp b/Minecraft.Client/PSVita/PSVita_Minecraft.cpp index a82adf00f..f511bed3b 100644 --- a/Minecraft.Client/PSVita/PSVita_Minecraft.cpp +++ b/Minecraft.Client/PSVita/PSVita_Minecraft.cpp @@ -288,7 +288,7 @@ void MemSect(int sect) void debugSaveGameDirect() { - C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, NULL, "debugSaveGameDirect"); + C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, nullptr, "debugSaveGameDirect"); thread->Run(); thread->WaitForCompletion(1000); } @@ -520,7 +520,7 @@ int main() PSVitaNPToolkit::init(); // initialise the storage manager with a default save display name, a Minimum save size, and a callback for displaying the saving message - StorageManager.Init( 0, L"savegame.dat", "savePackName", FIFTY_ONE_MB, &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, NULL); + StorageManager.Init( 0, L"savegame.dat", "savePackName", FIFTY_ONE_MB, &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, nullptr); StorageManager.SetDLCProductCode(app.GetProductCode()); StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); ProfileManager.SetServiceID(app.GetCommerceCategory()); @@ -624,9 +624,9 @@ int main() StorageManager.SetDefaultImages((PBYTE)baOptionsIcon.data, baOptionsIcon.length,(PBYTE)baSaveImage.data, baSaveImage.length,(PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); - if(baOptionsIcon.data!=NULL){ delete [] baOptionsIcon.data; } - if(baSaveThumbnail.data!=NULL){ delete [] baSaveThumbnail.data; } - if(baSaveImage.data!=NULL){ delete [] baSaveImage.data; } + if(baOptionsIcon.data!=nullptr){ delete [] baOptionsIcon.data; } + if(baSaveThumbnail.data!=nullptr){ delete [] baSaveThumbnail.data; } + if(baSaveImage.data!=nullptr){ delete [] baSaveImage.data; } StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); @@ -655,7 +655,7 @@ int main() #endif StorageManager.SetDLCInfoMap(app.GetSonyDLCMap()); - app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL + app.CommerceInit(); // MGH - moved this here so GetCommerce isn't nullptr // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised app.GetCommerce()->CheckForTrialUpgradeKey(); @@ -856,7 +856,7 @@ int main() else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true,false); IntCache::Reset(); @@ -1064,7 +1064,7 @@ vector vRichPresenceStrings; uint8_t * AddRichPresenceString(int iID) { uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); - if( strUtf8 != NULL ) + if( strUtf8 != nullptr ) { vRichPresenceStrings.push_back(strUtf8); } diff --git a/Minecraft.Client/PSVita/PSVita_UIController.cpp b/Minecraft.Client/PSVita/PSVita_UIController.cpp index c3a03acea..fe6cf7582 100644 --- a/Minecraft.Client/PSVita/PSVita_UIController.cpp +++ b/Minecraft.Client/PSVita/PSVita_UIController.cpp @@ -145,7 +145,7 @@ void ConsoleUIController::render() /* End the GXM scene. Note that we pass "notify" (returned from $gdraw_psp2_End) as the fragment notification. */ - //sceGxmEndScene(gxm, NULL, ¬ify); + //sceGxmEndScene(gxm, nullptr, ¬ify); RenderManager.setFragmentNotification(notify); #endif } diff --git a/Minecraft.Client/PSVita/XML/ATGXmlParser.h b/Minecraft.Client/PSVita/XML/ATGXmlParser.h index 75142e3e3..12f597372 100644 --- a/Minecraft.Client/PSVita/XML/ATGXmlParser.h +++ b/Minecraft.Client/PSVita/XML/ATGXmlParser.h @@ -138,7 +138,7 @@ class XMLParser DWORD m_dwCharsTotal; DWORD m_dwCharsConsumed; - BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing NULL + BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing nullptr WCHAR m_pWriteBuf[ XML_WRITE_BUFFER_SIZE ]; BYTE* m_pReadPtr; diff --git a/Minecraft.Client/Particle.cpp b/Minecraft.Client/Particle.cpp index 25ec2ec4c..643dc6695 100644 --- a/Minecraft.Client/Particle.cpp +++ b/Minecraft.Client/Particle.cpp @@ -19,7 +19,7 @@ void Particle::_init(Level *level, double x, double y, double z) { // 4J - added these initialisers alpha = 1.0f; - tex = NULL; + tex = nullptr; gravity = 0.0f; setSize(0.2f, 0.2f); @@ -156,7 +156,7 @@ void Particle::render(Tesselator *t, float a, float xa, float ya, float za, floa float v1 = v0 + 0.999f / 16.0f; float r = 0.1f * size; - if (tex != NULL) + if (tex != nullptr) { u0 = tex->getU0(); u1 = tex->getU1(); diff --git a/Minecraft.Client/ParticleEngine.cpp b/Minecraft.Client/ParticleEngine.cpp index 7fe260632..82dd4ce1c 100644 --- a/Minecraft.Client/ParticleEngine.cpp +++ b/Minecraft.Client/ParticleEngine.cpp @@ -17,7 +17,7 @@ ResourceLocation ParticleEngine::PARTICLES_LOCATION = ResourceLocation(TN_PARTIC ParticleEngine::ParticleEngine(Level *level, Textures *textures) { -// if (level != NULL) // 4J - removed - we want level to be initialised to *something* +// if (level != nullptr) // 4J - removed - we want level to be initialised to *something* { this->level = level; } @@ -188,8 +188,8 @@ void ParticleEngine::renderLit(shared_ptr player, float a, int list) void ParticleEngine::setLevel(Level *level) { this->level = level; - // 4J - we've now got a set of particle vectors for each dimension, and only clearing them when its game over & the level is set to NULL - if( level == NULL ) + // 4J - we've now got a set of particle vectors for each dimension, and only clearing them when its game over & the level is set to nullptr + if( level == nullptr ) { for( int l = 0; l < 3; l++ ) { diff --git a/Minecraft.Client/PauseScreen.cpp b/Minecraft.Client/PauseScreen.cpp index 791d819b5..a17e52dfb 100644 --- a/Minecraft.Client/PauseScreen.cpp +++ b/Minecraft.Client/PauseScreen.cpp @@ -54,12 +54,12 @@ void PauseScreen::buttonClicked(Button button) minecraft->level->disconnect(); } - minecraft->setLevel(NULL); + minecraft->setLevel(nullptr); minecraft->setScreen(new TitleScreen()); } if (button.id == 4) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J - removed } diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp index 72b8f3825..2adc1bb1e 100644 --- a/Minecraft.Client/PendingConnection.cpp +++ b/Minecraft.Client/PendingConnection.cpp @@ -45,7 +45,7 @@ PendingConnection::~PendingConnection() void PendingConnection::tick() { - if (acceptedLogin != NULL) + if (acceptedLogin != nullptr) { this->handleAcceptedLogin(acceptedLogin); acceptedLogin = nullptr; @@ -121,7 +121,7 @@ void PendingConnection::sendPreLoginResponse() // Need to use the online XUID otherwise friend checks will fail on the client ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID; - if( player->connection->getNetworkPlayer() != NULL && player->connection->getNetworkPlayer()->IsHost() ) hostIndex = ugcXuidCount; + if( player->connection->getNetworkPlayer() != nullptr && player->connection->getNetworkPlayer()->IsHost() ) hostIndex = ugcXuidCount; ++ugcXuidCount; } @@ -199,7 +199,7 @@ void PendingConnection::handleLogin(shared_ptr packet) vector >& pl = server->getPlayers()->players; for (const auto& i : pl) { - if (i != NULL && i->name == name) + if (i != nullptr && i->name == name) { nameTaken = true; break; @@ -262,10 +262,10 @@ void PendingConnection::handleAcceptedLogin(shared_ptr packet) if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid; shared_ptr playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid); - if (playerEntity != NULL) + if (playerEntity != nullptr) { server->getPlayers()->placeNewPlayer(connection, playerEntity, packet); - connection = NULL; // We've moved responsibility for this over to the new PlayerConnection, NULL so we don't delete our reference to it here in our dtor + connection = nullptr; // We've moved responsibility for this over to the new PlayerConnection, nullptr so we don't delete our reference to it here in our dtor } done = true; diff --git a/Minecraft.Client/PistonPieceRenderer.cpp b/Minecraft.Client/PistonPieceRenderer.cpp index ca7294fc8..0982e69ae 100644 --- a/Minecraft.Client/PistonPieceRenderer.cpp +++ b/Minecraft.Client/PistonPieceRenderer.cpp @@ -12,7 +12,7 @@ ResourceLocation PistonPieceRenderer::SIGN_LOCATION = ResourceLocation(TN_ITEM_S PistonPieceRenderer::PistonPieceRenderer() { - tileRenderer = NULL; + tileRenderer = nullptr; } void PistonPieceRenderer::render(shared_ptr _entity, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) @@ -21,7 +21,7 @@ void PistonPieceRenderer::render(shared_ptr _entity, double x, doubl shared_ptr entity = dynamic_pointer_cast(_entity); Tile *tile = Tile::tiles[entity->getId()]; - if (tile != NULL && entity->getProgress(a) <= 1) // 4J - changed condition from < to <= as our chunk update is async to main thread and so we can have to render these with progress of 1 + if (tile != nullptr && entity->getProgress(a) <= 1) // 4J - changed condition from < to <= as our chunk update is async to main thread and so we can have to render these with progress of 1 { Tesselator *t = Tesselator::getInstance(); bindTexture(&TextureAtlas::LOCATION_BLOCKS); diff --git a/Minecraft.Client/PlayerChunkMap.cpp b/Minecraft.Client/PlayerChunkMap.cpp index 01d1b8fdb..2078093ed 100644 --- a/Minecraft.Client/PlayerChunkMap.cpp +++ b/Minecraft.Client/PlayerChunkMap.cpp @@ -82,7 +82,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr player, bool send void PlayerChunkMap::PlayerChunk::remove(shared_ptr player) { - PlayerChunkMap::PlayerChunk *toDelete = NULL; + PlayerChunkMap::PlayerChunk *toDelete = nullptr; //app.DebugPrintf("--- PlayerChunkMap::PlayerChunk::remove x=%d\tz=%d\n",x,z); auto it = find(players.begin(), players.end(), player); @@ -121,7 +121,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr player) // 4J - I don't think there's any point sending these anymore, as we don't need to unload chunks with fixed sized maps // 4J - We do need to send these to unload entities in chunks when players are dead. If we do not and the entity is removed // while they are dead, that entity will remain in the clients world - if (player->connection != NULL && player->seenChunks.find(pos) != player->seenChunks.end()) + if (player->connection != nullptr && player->seenChunks.find(pos) != player->seenChunks.end()) { INetworkPlayer *thisNetPlayer = player->connection->getNetworkPlayer(); bool noOtherPlayersFound = true; @@ -133,7 +133,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr player) if ( currPlayer ) { INetworkPlayer *currNetPlayer = currPlayer->connection->getNetworkPlayer(); - if( currNetPlayer != NULL && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() ) + if( currNetPlayer != nullptr && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() ) { noOtherPlayersFound = false; break; @@ -148,7 +148,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr player) } else { - //app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer is NULL\n"); + //app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer is nullptr\n"); } } @@ -220,7 +220,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr packet) if( sentTo.size() ) { INetworkPlayer *thisPlayer = player->connection->getNetworkPlayer(); - if( thisPlayer == NULL ) + if( thisPlayer == nullptr ) { dontSend = true; } @@ -230,7 +230,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr packet) { shared_ptr player2 = sentTo[j]; INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { dontSend = true; } @@ -269,7 +269,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr packet) { shared_ptr player = parent->level->getServer()->getPlayers()->players[i]; // Don't worry about local players, they get all their updates through sharing level with the server anyway - if ( player->connection == NULL ) continue; + if ( player->connection == nullptr ) continue; if( player->connection->isLocal() ) continue; // Don't worry about this player if they haven't had this chunk yet (this flag will be the @@ -282,7 +282,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr packet) if( sentTo.size() ) { INetworkPlayer *thisPlayer = player->connection->getNetworkPlayer(); - if( thisPlayer == NULL ) + if( thisPlayer == nullptr ) { dontSend = true; } @@ -292,7 +292,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr packet) { shared_ptr player2 = sentTo[j]; INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { dontSend = true; } @@ -386,10 +386,10 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr te) { - if (te != NULL) + if (te != nullptr) { shared_ptr p = te->getUpdatePacket(); - if (p != NULL) + if (p != nullptr) { broadcast(p); } @@ -579,7 +579,7 @@ void PlayerChunkMap::broadcastTileUpdate(shared_ptr packet, int x, int y int xc = x >> 4; int zc = z >> 4; PlayerChunk *chunk = getChunk(xc, zc, false); - if (chunk != NULL) + if (chunk != nullptr) { chunk->broadcast(packet); } @@ -590,7 +590,7 @@ void PlayerChunkMap::tileChanged(int x, int y, int z) int xc = x >> 4; int zc = z >> 4; PlayerChunk *chunk = getChunk(xc, zc, false); - if (chunk != NULL) + if (chunk != nullptr) { chunk->tileChanged(x & 15, y, z & 15); } @@ -611,7 +611,7 @@ void PlayerChunkMap::prioritiseTileChanges(int x, int y, int z) int xc = x >> 4; int zc = z >> 4; PlayerChunk *chunk = getChunk(xc, zc, false); - if (chunk != NULL) + if (chunk != nullptr) { chunk->prioritiseTileChanges(); } @@ -731,7 +731,7 @@ void PlayerChunkMap::remove(shared_ptr player) for (int z = zc - radius; z <= zc + radius; z++) { PlayerChunk *playerChunk = getChunk(x, z, false); - if (playerChunk != NULL) playerChunk->remove(player); + if (playerChunk != nullptr) playerChunk->remove(player); } auto it = find(players.begin(), players.end(), player); @@ -811,7 +811,7 @@ bool PlayerChunkMap::isPlayerIn(shared_ptr player, int xChunk, int { PlayerChunk *chunk = getChunk(xChunk, zChunk, false); - if(chunk == NULL) + if(chunk == nullptr) { return false; } @@ -822,7 +822,7 @@ bool PlayerChunkMap::isPlayerIn(shared_ptr player, int xChunk, int return it1 != chunk->players.end() && it2 == player->chunksToSend.end(); } - //return chunk == NULL ? false : chunk->players->contains(player) && !player->chunksToSend->contains(chunk->pos); + //return chunk == nullptr ? false : chunk->players->contains(player) && !player->chunksToSend->contains(chunk->pos); } int PlayerChunkMap::convertChunkRangeToBlock(int radius) diff --git a/Minecraft.Client/PlayerCloudParticle.cpp b/Minecraft.Client/PlayerCloudParticle.cpp index 5132dfc6b..476803a33 100644 --- a/Minecraft.Client/PlayerCloudParticle.cpp +++ b/Minecraft.Client/PlayerCloudParticle.cpp @@ -50,7 +50,7 @@ void PlayerCloudParticle::tick() yd *= 0.96f; zd *= 0.96f; shared_ptr p = level->getNearestPlayer(shared_from_this(), 2); - if (p != NULL) + if (p != nullptr) { if (y > p->bb->y0) { diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index c8311ebf1..48fd4e08d 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -164,7 +164,7 @@ void PlayerConnection::handleMovePlayer(shared_ptr packet) if (synched) { - if (player->riding != NULL) + if (player->riding != nullptr) { float yRotT = player->yRot; @@ -185,7 +185,7 @@ void PlayerConnection::handleMovePlayer(shared_ptr packet) player->doTick(false); player->ySlideOffset = 0; player->absMoveTo(xt, yt, zt, yRotT, xRotT); - if (player->riding != NULL) player->riding->positionRider(); + if (player->riding != nullptr) player->riding->positionRider(); server->getPlayers()->move(player); // player may have been kicked off the mount during the tick, so @@ -460,7 +460,7 @@ void PlayerConnection::handleUseItem(shared_ptr packet) bool canEditSpawn = level->canEditSpawn; // = level->dimension->id != 0 || server->players->isOp(player->name); if (packet->getFace() == 255) { - if (item == NULL) return; + if (item == nullptr) return; player->gameMode->useItem(player, level, item); } else if ((packet->getY() < server->getMaxBuildHeight() - 1) || (packet->getFace() != Facing::UP && packet->getY() < server->getMaxBuildHeight())) @@ -508,17 +508,17 @@ void PlayerConnection::handleUseItem(shared_ptr packet) item = player->inventory->getSelected(); bool forceClientUpdate = false; - if(item != NULL && packet->getItem() == NULL) + if(item != nullptr && packet->getItem() == nullptr) { forceClientUpdate = true; } - if (item != NULL && item->count == 0) + if (item != nullptr && item->count == 0) { player->inventory->items[player->inventory->selected] = nullptr; item = nullptr; } - if (item == NULL || item->getUseDuration() == 0) + if (item == nullptr || item->getUseDuration() == 0) { player->ignoreSlotUpdateHack = true; player->inventory->items[player->inventory->selected] = ItemInstance::clone(player->inventory->items[player->inventory->selected]); @@ -561,7 +561,7 @@ void PlayerConnection::onUnhandledPacket(shared_ptr packet) void PlayerConnection::send(shared_ptr packet) { - if( connection->getSocket() != NULL ) + if( connection->getSocket() != nullptr ) { if( !server->getPlayers()->canReceiveAllPackets( player ) ) { @@ -579,7 +579,7 @@ void PlayerConnection::send(shared_ptr packet) // 4J Added void PlayerConnection::queueSend(shared_ptr packet) { - if( connection->getSocket() != NULL ) + if( connection->getSocket() != nullptr ) { if( !server->getPlayers()->canReceiveAllPackets( player ) ) { @@ -685,7 +685,7 @@ void PlayerConnection::handlePlayerCommand(shared_ptr packe else if (packet->action == PlayerCommandPacket::RIDING_JUMP) { // currently only supported by horses... - if ( (player->riding != NULL) && player->riding->GetType() == eTYPE_HORSE) + if ( (player->riding != nullptr) && player->riding->GetType() == eTYPE_HORSE) { dynamic_pointer_cast(player->riding)->onPlayerJump(packet->data); } @@ -693,7 +693,7 @@ void PlayerConnection::handlePlayerCommand(shared_ptr packe else if (packet->action == PlayerCommandPacket::OPEN_INVENTORY) { // also only supported by horses... - if ( (player->riding != NULL) && player->riding->instanceof(eTYPE_HORSE) ) + if ( (player->riding != nullptr) && player->riding->instanceof(eTYPE_HORSE) ) { dynamic_pointer_cast(player->riding)->openInventory(player); } @@ -752,7 +752,7 @@ void PlayerConnection::handleInteract(shared_ptr packet) // 4J Stu - If the client says that we hit something, then agree with it. The canSee can fail here as it checks // a ray from head->head, but we may actually be looking at a different part of the entity that can be seen // even though the ray is blocked. - if (target != NULL) // && player->canSee(target) && player->distanceToSqr(target) < 6 * 6) + if (target != nullptr) // && player->canSee(target) && player->distanceToSqr(target) < 6 * 6) { //boole canSee = player->canSee(target); //double maxDist = 6 * 6; @@ -797,7 +797,7 @@ void PlayerConnection::handleTexture(shared_ptr packet) #ifndef _CONTENT_PACKAGE wprintf(L"Server received request for custom texture %ls\n",packet->textureName.c_str()); #endif - PBYTE pbData=NULL; + PBYTE pbData=nullptr; DWORD dwBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwBytes); @@ -831,7 +831,7 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptrtextureName.c_str()); #endif - PBYTE pbData=NULL; + PBYTE pbData=nullptr; DWORD dwTextureBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwTextureBytes); DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(packet->textureName); @@ -895,7 +895,7 @@ void PlayerConnection::handleTextureReceived(const wstring &textureName) auto it = find(m_texturesRequested.begin(), m_texturesRequested.end(), textureName); if( it != m_texturesRequested.end() ) { - PBYTE pbData=NULL; + PBYTE pbData=nullptr; DWORD dwBytes=0; app.GetMemFileDetails(textureName,&pbData,&dwBytes); @@ -913,7 +913,7 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa auto it = find(m_texturesRequested.begin(), m_texturesRequested.end(), textureName); if( it != m_texturesRequested.end() ) { - PBYTE pbData=NULL; + PBYTE pbData=nullptr; DWORD dwTextureBytes=0; app.GetMemFileDetails(textureName,&pbData,&dwTextureBytes); DLCSkinFile *pDLCSkinFile=app.m_dlcManager.getSkinFile(textureName); @@ -963,13 +963,13 @@ void PlayerConnection::handleTextureChange(shared_ptr packe #ifndef _CONTENT_PACKAGE wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TexturePacket(packet->path,NULL,0) ) ); + send(shared_ptr( new TexturePacket(packet->path,nullptr,0) ) ); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path,NULL,0); + app.AddMemoryTextureFile(packet->path,nullptr,0); } server->getPlayers()->broadcastAll( shared_ptr( new TextureChangePacket(player,packet->action,packet->path) ), player->dimension ); } @@ -990,13 +990,13 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptrpath.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TextureAndGeometryPacket(packet->path,NULL,0) ) ); + send(shared_ptr( new TextureAndGeometryPacket(packet->path,nullptr,0) ) ); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path,NULL,0); + app.AddMemoryTextureFile(packet->path,nullptr,0); player->setCustomSkin(packet->dwSkinID); @@ -1014,7 +1014,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptrIsHost()) || player->isModerator()) + if( (networkPlayer != nullptr && networkPlayer->IsHost()) || player->isModerator()) { app.SetGameHostOption(eGameHostOption_FireSpreads, app.GetGameHostOption(packet->data,eGameHostOption_FireSpreads)); app.SetGameHostOption(eGameHostOption_TNT, app.GetGameHostOption(packet->data,eGameHostOption_TNT)); @@ -1037,7 +1037,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptr packet) { INetworkPlayer *networkPlayer = getNetworkPlayer(); - if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator()) + if( (networkPlayer != nullptr && networkPlayer->IsHost()) || player->isModerator()) { server->getPlayers()->kickPlayerByShortId(packet->m_networkSmallId); } @@ -1106,9 +1106,9 @@ void PlayerConnection::handleContainerSetSlot(shared_ptr if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_INVENTORY && packet->slot >= 36 && packet->slot < 36 + 9) { shared_ptr lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem(); - if (packet->item != NULL) + if (packet->item != nullptr) { - if (lastItem == NULL || lastItem->count < packet->item->count) + if (lastItem == nullptr || lastItem->count < packet->item->count) { packet->item->popTime = Inventory::POP_TIME_DURATION; } @@ -1184,7 +1184,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptrslotNum < 0; shared_ptr item = packet->item; - if(item != NULL && item->id == Item::map_Id) + if(item != nullptr && item->id == Item::map_Id) { int mapScale = 3; #ifdef _LARGE_WORLDS @@ -1204,7 +1204,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptrgetAuxValue()); std::wstring id = wstring(buf); - if( data == NULL ) + if( data == nullptr ) { data = shared_ptr( new MapItemSavedData(id) ); } @@ -1219,12 +1219,12 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptrslotNum >= InventoryMenu::CRAFT_SLOT_START && packet->slotNum < (InventoryMenu::USE_ROW_SLOT_START + Inventory::getSelectionSize())); - bool validItem = item == NULL || (item->id < Item::items.length && item->id >= 0 && Item::items[item->id] != NULL); - bool validData = item == NULL || (item->getAuxValue() >= 0 && item->count > 0 && item->count <= 64); + bool validItem = item == nullptr || (item->id < Item::items.length && item->id >= 0 && Item::items[item->id] != nullptr); + bool validData = item == nullptr || (item->getAuxValue() >= 0 && item->count > 0 && item->count <= 64); if (validSlot && validItem && validData) { - if (item == NULL) + if (item == nullptr) { player->inventoryMenu->setItem(packet->slotNum, nullptr); } @@ -1242,14 +1242,14 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr dropped = player->drop(item); - if (dropped != NULL) + if (dropped != nullptr) { dropped->setShortLifeTime(); } } } - if( item != NULL && item->id == Item::map_Id ) + if( item != nullptr && item->id == Item::map_Id ) { // 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong // This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem @@ -1283,7 +1283,7 @@ void PlayerConnection::handleSignUpdate(shared_ptr packet) { shared_ptr te = level->getTileEntity(packet->x, packet->y, packet->z); - if (dynamic_pointer_cast(te) != NULL) + if (dynamic_pointer_cast(te) != nullptr) { shared_ptr ste = dynamic_pointer_cast(te); if (!ste->isEditable() || ste->getPlayerWhoMayEdit() != player) @@ -1294,7 +1294,7 @@ void PlayerConnection::handleSignUpdate(shared_ptr packet) } // 4J-JEV: Changed to allow characters to display as a []. - if (dynamic_pointer_cast(te) != NULL) + if (dynamic_pointer_cast(te) != nullptr) { int x = packet->x; int y = packet->y; @@ -1327,20 +1327,20 @@ void PlayerConnection::handlePlayerInfo(shared_ptr packet) // Need to check that this player has permission to change each individual setting? INetworkPlayer *networkPlayer = getNetworkPlayer(); - if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator() ) + if( (networkPlayer != nullptr && networkPlayer->IsHost()) || player->isModerator() ) { shared_ptr serverPlayer; // Find the player being edited for(auto& checkingPlayer : server->getPlayers()->players) { - if(checkingPlayer->connection->getNetworkPlayer() != NULL && checkingPlayer->connection->getNetworkPlayer()->GetSmallId() == packet->m_networkSmallId) + if(checkingPlayer->connection->getNetworkPlayer() != nullptr && checkingPlayer->connection->getNetworkPlayer()->GetSmallId() == packet->m_networkSmallId) { serverPlayer = checkingPlayer; break; } } - if(serverPlayer != NULL) + if(serverPlayer != nullptr) { unsigned int origPrivs = serverPlayer->getAllPlayerGamePrivileges(); @@ -1514,7 +1514,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr custo shared_ptr tileEntity = player->level->getTileEntity(x, y, z); shared_ptr cbe = dynamic_pointer_cast(tileEntity); - if (tileEntity != NULL && cbe != NULL) + if (tileEntity != nullptr && cbe != nullptr) { cbe->setCommand(command); player->level->sendTileUpdated(x, y, z); @@ -1528,7 +1528,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr custo } else if (CustomPayloadPacket::SET_BEACON_PACKET.compare(customPayloadPacket->identifier) == 0) { - if ( dynamic_cast( player->containerMenu) != NULL) + if ( dynamic_cast( player->containerMenu) != nullptr) { ByteArrayInputStream bais(customPayloadPacket->data); DataInputStream input(&bais); @@ -1552,7 +1552,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr custo AnvilMenu *menu = dynamic_cast( player->containerMenu); if (menu) { - if (customPayloadPacket->data.data == NULL || customPayloadPacket->data.length < 1) + if (customPayloadPacket->data.data == nullptr || customPayloadPacket->data.length < 1) { menu->setItemName(L""); } @@ -1616,7 +1616,7 @@ void PlayerConnection::handleCraftItem(shared_ptr packet) Recipy::INGREDIENTS_REQUIRED &req = pRecipeIngredientsRequired[iRecipe]; - if (req.iType == RECIPE_TYPE_3x3 && dynamic_cast(player->containerMenu) == NULL) + if (req.iType == RECIPE_TYPE_3x3 && dynamic_cast(player->containerMenu) == nullptr) { server->warn(L"Player " + player->getName() + L" tried to craft a 3x3 recipe without a crafting bench"); return; @@ -1651,7 +1651,7 @@ void PlayerConnection::handleCraftItem(shared_ptr packet) } // 4J Stu - Fix for #13097 - Bug: Milk Buckets are removed when crafting Cake - if (ingItemInst != NULL) + if (ingItemInst != nullptr) { if (ingItemInst->getItem()->hasCraftingRemainingItem()) { @@ -1735,7 +1735,7 @@ void PlayerConnection::handleTradeItem(shared_ptr packet) int buyAMatches = player->inventory->countMatches(buyAItem); int buyBMatches = player->inventory->countMatches(buyBItem); - if( (buyAItem != NULL && buyAMatches >= buyAItem->count) && (buyBItem == NULL || buyBMatches >= buyBItem->count) ) + if( (buyAItem != nullptr && buyAMatches >= buyAItem->count) && (buyBItem == nullptr || buyBMatches >= buyBItem->count) ) { menu->getMerchant()->notifyTrade(activeRecipe); @@ -1769,13 +1769,13 @@ void PlayerConnection::handleTradeItem(shared_ptr packet) INetworkPlayer *PlayerConnection::getNetworkPlayer() { - if( connection != NULL && connection->getSocket() != NULL) return connection->getSocket()->getPlayer(); - else return NULL; + if( connection != nullptr && connection->getSocket() != nullptr) return connection->getSocket()->getPlayer(); + else return nullptr; } bool PlayerConnection::isLocal() { - if( connection->getSocket() == NULL ) + if( connection->getSocket() == nullptr ) { return false; } @@ -1788,7 +1788,7 @@ bool PlayerConnection::isLocal() bool PlayerConnection::isGuest() { - if( connection->getSocket() == NULL ) + if( connection->getSocket() == nullptr ) { return false; } @@ -1796,7 +1796,7 @@ bool PlayerConnection::isGuest() { INetworkPlayer *networkPlayer = connection->getSocket()->getPlayer(); bool isGuest = false; - if(networkPlayer != NULL) + if(networkPlayer != nullptr) { isGuest = networkPlayer->IsGuest() == TRUE; } diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp index 3f5da980f..24457bee8 100644 --- a/Minecraft.Client/PlayerList.cpp +++ b/Minecraft.Client/PlayerList.cpp @@ -38,12 +38,12 @@ PlayerList::PlayerList(MinecraftServer *server) { - playerIo = NULL; + playerIo = nullptr; this->server = server; sendAllPlayerInfoIn = 0; - overrideGameMode = NULL; + overrideGameMode = nullptr; allowCheatsForAllPlayers = false; #ifdef __PSVITA__ @@ -83,14 +83,14 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr { CompoundTag *playerTag = load(player); - bool newPlayer = playerTag == NULL; + bool newPlayer = playerTag == nullptr; player->setLevel(server->getLevel(player->dimension)); player->gameMode->setLevel(static_cast(player->level)); // Make sure these privileges are always turned off for the host player INetworkPlayer *networkPlayer = connection->getSocket()->getPlayer(); - if(networkPlayer != NULL && networkPlayer->IsHost()) + if(networkPlayer != nullptr && networkPlayer->IsHost()) { player->enableAllPlayerPrivileges(true); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_HOST,1); @@ -100,18 +100,18 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr // PS3 networking library doesn't automatically assign PlayerUIDs to the network players for anything remote, so need to tell it what to set from the data in this packet now if( !g_NetworkManager.IsLocalGame() ) { - if( networkPlayer != NULL ) + if( networkPlayer != nullptr ) { ((NetworkPlayerSony *)networkPlayer)->SetUID( packet->m_onlineXuid ); } } #endif #ifdef _WINDOWS64 - if (networkPlayer != NULL) + if (networkPlayer != nullptr) { NetworkPlayerXbox* nxp = static_cast(networkPlayer); IQNetPlayer* qnp = nxp->GetQNetPlayer(); - if (qnp != NULL) + if (qnp != nullptr) { if (!networkPlayer->IsLocal()) { @@ -168,7 +168,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr #endif // 4J Added - Give every player a map the first time they join a server player->inventory->setItem( 9, shared_ptr( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) ); - if(app.getGameRuleDefinitions() != NULL) + if(app.getGameRuleDefinitions() != nullptr) { app.getGameRuleDefinitions()->postProcessPlayer(player); } @@ -181,13 +181,13 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr #ifndef _CONTENT_PACKAGE wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl.c_str(), player->name.c_str()); #endif - playerConnection->send(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) ); + playerConnection->send(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,nullptr,0) ) ); } } else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl,NULL,0); + app.AddMemoryTextureFile(player->customTextureUrl,nullptr,0); } if(!player->customTextureUrl2.empty() && player->customTextureUrl2.substr(0,3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl2)) @@ -197,13 +197,13 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr #ifndef _CONTENT_PACKAGE wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str()); #endif - playerConnection->send(shared_ptr( new TexturePacket(player->customTextureUrl2,NULL,0) ) ); + playerConnection->send(shared_ptr( new TexturePacket(player->customTextureUrl2,nullptr,0) ) ); } } else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl2,NULL,0); + app.AddMemoryTextureFile(player->customTextureUrl2,nullptr,0); } player->setIsGuest( packet->m_isGuest ); @@ -268,11 +268,11 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr player->initMenu(); - if (playerTag != NULL && playerTag->contains(Entity::RIDING_TAG)) + if (playerTag != nullptr && playerTag->contains(Entity::RIDING_TAG)) { // this player has been saved with a mount tag shared_ptr mount = EntityIO::loadStatic(playerTag->getCompound(Entity::RIDING_TAG), level); - if (mount != NULL) + if (mount != nullptr) { mount->forcedLoading = true; level->addEntity(mount); @@ -311,7 +311,7 @@ void PlayerList::updateEntireScoreboard(ServerScoreboard *scoreboard, shared_ptr //{ // Objective objective = scoreboard->getDisplayObjective(slot); - // if (objective != NULL && !objectives->contains(objective)) + // if (objective != nullptr && !objectives->contains(objective)) // { // vector > *packets = scoreboard->getStartTrackingPackets(objective); @@ -334,7 +334,7 @@ void PlayerList::changeDimension(shared_ptr player, ServerLevel *f { ServerLevel *to = player->getLevel(); - if (from != NULL) from->getChunkMap()->remove(player); + if (from != nullptr) from->getChunkMap()->remove(player); to->getChunkMap()->add(player); to->cache->create(static_cast(player->x) >> 4, static_cast(player->z) >> 4); @@ -406,10 +406,10 @@ void PlayerList::validatePlayerSpawnPosition(shared_ptr player) delete levelSpawn; Pos *bedPosition = player->getRespawnPosition(); - if (bedPosition != NULL) + if (bedPosition != nullptr) { Pos *respawnPosition = Player::checkBedValidRespawnPosition(server->getLevel(player->dimension), bedPosition, spawnForced); - if (respawnPosition != NULL) + if (respawnPosition != nullptr) { player->moveTo(respawnPosition->x + 0.5f, respawnPosition->y + 0.1f, respawnPosition->z + 0.5f, 0, 0); player->setRespawnPosition(bedPosition, spawnForced); @@ -447,7 +447,7 @@ void PlayerList::add(shared_ptr player) // 4J Stu - Swapped these lines about so that we get the chunk visiblity packet way ahead of all the add tracked entity packets // Fix for #9169 - ART : Sign text is replaced with the words �Awaiting approval�. - changeDimension(player, NULL); + changeDimension(player, nullptr); level->addEntity(player); for (int i = 0; i < players.size(); i++) @@ -468,7 +468,7 @@ void PlayerList::add(shared_ptr player) shared_ptr thisPlayer = players[i]; if(thisPlayer->isSleeping()) { - if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer; + if(firstSleepingPlayer == nullptr) firstSleepingPlayer = thisPlayer; thisPlayer->connection->send(shared_ptr( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep))); } } @@ -487,7 +487,7 @@ void PlayerList::remove(shared_ptr player) //4J Stu - We don't want to save the map data for guests, so when we are sure that the player is gone delete the map if(player->isGuest()) playerIo->deleteMapFilesForPlayer(player); ServerLevel *level = player->getLevel(); -if (player->riding != NULL) +if (player->riding != nullptr) { level->removeEntityImmediately(player->riding); app.DebugPrintf("removing player mount"); @@ -505,10 +505,10 @@ if (player->riding != NULL) removePlayerFromReceiving(player); player->connection = nullptr; // Must remove reference to connection, or else there is a circular dependency delete player->gameMode; // Gamemode also needs deleted as it references back to this player - player->gameMode = NULL; + player->gameMode = nullptr; // 4J Stu - Save all the players currently in the game, which will also free up unused map id slots if required, and remove old players - saveAll(NULL,false); + saveAll(nullptr,false); } shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid) @@ -531,7 +531,7 @@ shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendin // Use packet-supplied identity from LoginPacket. // Do not recompute from name here: mixed-version clients must stay compatible. INetworkPlayer* np = pendingConnection->connection->getSocket()->getPlayer(); - if (np != NULL) + if (np != nullptr) { player->setOnlineXuid(np->GetUID()); @@ -547,14 +547,14 @@ shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendin #endif // Work out the base server player settings INetworkPlayer *networkPlayer = pendingConnection->connection->getSocket()->getPlayer(); - if(networkPlayer != NULL && !networkPlayer->IsHost()) + if(networkPlayer != nullptr && !networkPlayer->IsHost()) { player->enableAllPlayerPrivileges( app.GetGameHostOption(eGameHostOption_TrustPlayers)>0 ); } // 4J Added LevelRuleset *serverRuleDefs = app.getGameRuleDefinitions(); - if(serverRuleDefs != NULL) + if(serverRuleDefs != nullptr) { player->gameMode->setGameRules( GameRuleDefinition::generateNewGameRulesInstance(GameRulesInstance::eGameRulesInstanceType_ServerPlayer, serverRuleDefs, pendingConnection->connection) ); } @@ -581,7 +581,7 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay if( ep->dimension != oldDimension ) continue; INetworkPlayer * otherPlayer = ep->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { // There's another player here in the same dimension - we're not the last one out isEmptying = false; @@ -674,7 +674,7 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay { // If the player is still alive and respawning to the same dimension, they are just being added back from someone else viewing the Win screen player->moveTo(serverPlayer->x, serverPlayer->y, serverPlayer->z, serverPlayer->yRot, serverPlayer->xRot); - if(bedPosition != NULL) + if(bedPosition != nullptr) { player->setRespawnPosition(bedPosition, spawnForced); delete bedPosition; @@ -682,10 +682,10 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay // Fix for #81759 - TU9: Content: Gameplay: Entering The End Exit Portal replaces the Player's currently held item with the first one from the Quickbar player->inventory->selected = serverPlayer->inventory->selected; } - else if (bedPosition != NULL) + else if (bedPosition != nullptr) { Pos *respawnPosition = Player::checkBedValidRespawnPosition(server->getLevel(serverPlayer->dimension), bedPosition, spawnForced); - if (respawnPosition != NULL) + if (respawnPosition != nullptr) { player->moveTo(respawnPosition->x + 0.5f, respawnPosition->y + 0.1f, respawnPosition->z + 0.5f, 0, 0); player->setRespawnPosition(bedPosition, spawnForced); @@ -765,7 +765,7 @@ void PlayerList::toggleDimension(shared_ptr player, int targetDime if( ep->dimension != lastDimension ) continue; INetworkPlayer * otherPlayer = ep->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { // There's another player here in the same dimension - we're not the last one out isEmptying = false; @@ -966,15 +966,15 @@ void PlayerList::tick() for(unsigned int i = 0; i < players.size(); i++) { shared_ptr p = players.at(i); - // 4J Stu - May be being a bit overprotective with all the NULL checks, but adding late in TU7 so want to be safe - if (p != NULL && p->connection != NULL && p->connection->connection != NULL && p->connection->connection->getSocket() != NULL && p->connection->connection->getSocket()->getSmallId() == smallId ) + // 4J Stu - May be being a bit overprotective with all the nullptr checks, but adding late in TU7 so want to be safe + if (p != nullptr && p->connection != nullptr && p->connection->connection != nullptr && p->connection->connection->getSocket() != nullptr && p->connection->connection->getSocket()->getSmallId() == smallId ) { player = p; break; } } - if (player != NULL) + if (player != nullptr) { player->connection->disconnect( DisconnectPacket::eDisconnect_Closed ); } @@ -987,7 +987,7 @@ void PlayerList::tick() BYTE smallId = m_smallIdsToKick.front(); m_smallIdsToKick.pop_front(); INetworkPlayer *selectedPlayer = g_NetworkManager.GetPlayerBySmallId(smallId); - if( selectedPlayer != NULL ) + if( selectedPlayer != nullptr ) { if( selectedPlayer->IsLocal() != TRUE ) { @@ -1000,14 +1000,14 @@ void PlayerList::tick() { shared_ptr p = players.at(i); PlayerUID playersXuid = p->getOnlineXuid(); - if (p != NULL && ProfileManager.AreXUIDSEqual(playersXuid, xuid ) ) + if (p != nullptr && ProfileManager.AreXUIDSEqual(playersXuid, xuid ) ) { player = p; break; } } - if (player != NULL) + if (player != nullptr) { m_bannedXuids.push_back( player->getOnlineXuid() ); // 4J Stu - If we have kicked a player, make sure that they have no privileges if they later try to join the world when trust players is off @@ -1030,7 +1030,7 @@ void PlayerList::tick() if(currentPlayer->removed) { shared_ptr newPlayer = findAlivePlayerOnSystem(currentPlayer); - if(newPlayer != NULL) + if(newPlayer != nullptr) { receiveAllPlayers[dim][i] = newPlayer; app.DebugPrintf("Replacing primary player %ls with %ls in dimension %d\n", currentPlayer->name.c_str(), newPlayer->name.c_str(), dim); @@ -1097,7 +1097,7 @@ bool PlayerList::isOp(shared_ptr player) cheatsEnabled = cheatsEnabled || app.GetUseDPadForDebug(); #endif INetworkPlayer *networkPlayer = player->connection->getNetworkPlayer(); - bool isOp = cheatsEnabled && (player->isModerator() || (networkPlayer != NULL && networkPlayer->IsHost())); + bool isOp = cheatsEnabled && (player->isModerator() || (networkPlayer != nullptr && networkPlayer->IsHost())); return isOp; } @@ -1131,7 +1131,7 @@ shared_ptr PlayerList::getPlayer(PlayerUID uid) shared_ptr PlayerList::getNearestPlayer(Pos *position, int range) { if (players.empty()) return nullptr; - if (position == NULL) return players.at(0); + if (position == nullptr) return players.at(0); shared_ptr current = nullptr; double dist = -1; int rangeSqr = range * range; @@ -1154,9 +1154,9 @@ shared_ptr PlayerList::getNearestPlayer(Pos *position, int range) vector *PlayerList::getPlayers(Pos *position, int rangeMin, int rangeMax, int count, int mode, int levelMin, int levelMax, unordered_map *scoreRequirements, const wstring &playerName, const wstring &teamName, Level *level) { app.DebugPrintf("getPlayers NOT IMPLEMENTED!"); - return NULL; + return nullptr; - /*if (players.empty()) return NULL; + /*if (players.empty()) return nullptr; vector > result = new vector >(); bool reverse = count < 0; bool playerNameNot = !playerName.empty() && playerName.startsWith("!"); @@ -1238,7 +1238,7 @@ bool PlayerList::meetsScoreRequirements(shared_ptr player, unordered_map void PlayerList::sendMessage(const wstring& name, const wstring& message) { shared_ptr player = getPlayer(name); - if (player != NULL) + if (player != nullptr) { player->connection->send( shared_ptr( new ChatPacket(message) ) ); } @@ -1254,7 +1254,7 @@ void PlayerList::broadcast(shared_ptr except, double x, double y, double // 4J - altered so that we don't send to the same machine more than once. Add the source player to the machines we have "sent" to as it doesn't need to go to that // machine either vector< shared_ptr > sentTo; - if( except != NULL ) + if( except != nullptr ) { sentTo.push_back(dynamic_pointer_cast(except)); } @@ -1270,7 +1270,7 @@ void PlayerList::broadcast(shared_ptr except, double x, double y, double if( sentTo.size() ) { INetworkPlayer *thisPlayer = p->connection->getNetworkPlayer(); - if( thisPlayer == NULL ) + if( thisPlayer == nullptr ) { dontSend = true; } @@ -1280,7 +1280,7 @@ void PlayerList::broadcast(shared_ptr except, double x, double y, double { shared_ptr player2 = sentTo[j]; INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { dontSend = true; } @@ -1318,8 +1318,8 @@ void PlayerList::broadcast(shared_ptr except, double x, double y, double void PlayerList::saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps /*= false*/) { - if(progressListener != NULL) progressListener->progressStart(IDS_PROGRESS_SAVING_PLAYERS); - // 4J - playerIo can be NULL if we have have to exit a game really early on due to network failure + if(progressListener != nullptr) progressListener->progressStart(IDS_PROGRESS_SAVING_PLAYERS); + // 4J - playerIo can be nullptr if we have have to exit a game really early on due to network failure if(playerIo) { playerIo->saveAllCachedData(); @@ -1330,7 +1330,7 @@ void PlayerList::saveAll(ProgressListener *progressListener, bool bDeleteGuestMa //4J Stu - We don't want to save the map data for guests, so when we are sure that the player is gone delete the map if(bDeleteGuestMaps && players[i]->isGuest()) playerIo->deleteMapFilesForPlayer(players[i]); - if(progressListener != NULL) progressListener->progressStagePercentage((i * 100)/ static_cast(players.size())); + if(progressListener != nullptr) progressListener->progressStagePercentage((i * 100)/ static_cast(players.size())); } playerIo->clearOldPlayerFiles(); playerIo->saveMapIdLookup(); @@ -1419,11 +1419,11 @@ void PlayerList::updatePlayerGameMode(shared_ptr newPlayer, shared // reset the player's game mode (first pick from old, then copy level if // necessary) - if (oldPlayer != NULL) + if (oldPlayer != nullptr) { newPlayer->gameMode->setGameModeForPlayer(oldPlayer->gameMode->getGameModeForPlayer()); } - else if (overrideGameMode != NULL) + else if (overrideGameMode != nullptr) { newPlayer->gameMode->setGameModeForPlayer(overrideGameMode); } @@ -1507,10 +1507,10 @@ void PlayerList::removePlayerFromReceiving(shared_ptr player, bool } } } - else if( thisPlayer == NULL ) + else if( thisPlayer == nullptr ) { #ifndef _CONTENT_PACKAGE - app.DebugPrintf("Remove: Qnet player for %ls was NULL so re-checking all players\n", player->name.c_str() ); + app.DebugPrintf("Remove: Qnet player for %ls was nullptr so re-checking all players\n", player->name.c_str() ); #endif // 4J Stu - Something went wrong, or possibly the QNet player left before we got here. // Re-check all active players and make sure they have someone on their system to receive all packets @@ -1527,7 +1527,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr player, bool for(auto& primaryPlayer : receiveAllPlayers[newPlayerDim]) { INetworkPlayer *primPlayer = primaryPlayer->connection->getNetworkPlayer(); - if(primPlayer != NULL && checkingPlayer->IsSameSystem( primPlayer ) ) + if(primPlayer != nullptr && checkingPlayer->IsSameSystem( primPlayer ) ) { foundPrimary = true; break; @@ -1559,10 +1559,10 @@ void PlayerList::addPlayerToReceiving(shared_ptr player) INetworkPlayer *thisPlayer = player->connection->getNetworkPlayer(); - if( thisPlayer == NULL ) + if( thisPlayer == nullptr ) { #ifndef _CONTENT_PACKAGE - app.DebugPrintf("Add: Qnet player for player %ls is NULL so not adding them\n", player->name.c_str() ); + app.DebugPrintf("Add: Qnet player for player %ls is nullptr so not adding them\n", player->name.c_str() ); #endif shouldAddPlayer = false; } @@ -1571,7 +1571,7 @@ void PlayerList::addPlayerToReceiving(shared_ptr player) for(auto& oldPlayer : receiveAllPlayers[playerDim]) { INetworkPlayer *checkingPlayer = oldPlayer->connection->getNetworkPlayer(); - if(checkingPlayer != NULL && checkingPlayer->IsSameSystem( thisPlayer ) ) + if(checkingPlayer != nullptr && checkingPlayer->IsSameSystem( thisPlayer ) ) { shouldAddPlayer = false; break; diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index 09d754183..f4803eaee 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -60,7 +60,7 @@ int PlayerRenderer::prepareArmor(shared_ptr _player, int layer, fl } shared_ptr itemInstance = player->inventory->getArmor(3 - layer); - if (itemInstance != NULL) + if (itemInstance != nullptr) { Item *item = itemInstance->getItem(); if (dynamic_cast(item)) @@ -79,9 +79,9 @@ int PlayerRenderer::prepareArmor(shared_ptr _player, int layer, fl armor->leg1->visible = layer == 2 || layer == 3; setArmor(armor); - if (armor != NULL) armor->attackTime = model->attackTime; - if (armor != NULL) armor->riding = model->riding; - if (armor != NULL) armor->young = model->young; + if (armor != nullptr) armor->attackTime = model->attackTime; + if (armor != nullptr) armor->riding = model->riding; + if (armor != nullptr) armor->young = model->young; float brightness = SharedConstants::TEXTURE_LIGHTING ? 1 : player->getBrightness(a); if (armorItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH) @@ -114,7 +114,7 @@ void PlayerRenderer::prepareSecondPassArmor(shared_ptr _player, in // 4J - dynamic cast required because we aren't using templates/generics in our version shared_ptr player = dynamic_pointer_cast(_player); shared_ptr itemInstance = player->inventory->getArmor(3 - layer); - if (itemInstance != NULL) + if (itemInstance != nullptr) { Item *item = itemInstance->getItem(); if (dynamic_cast(item)) @@ -136,8 +136,8 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double if(mob->hasInvisiblePrivilege()) return; shared_ptr item = mob->inventory->getSelected(); - armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = item != NULL ? 1 : 0; - if (item != NULL) + armorParts1->holdingRightHand = armorParts2->holdingRightHand = humanoidModel->holdingRightHand = item != nullptr ? 1 : 0; + if (item != nullptr) { if (mob->getUseItemDuration() > 0) { @@ -153,7 +153,7 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double } } // 4J added, for 3rd person view of eating - if( item != NULL && mob->getUseItemDuration() > 0 && item->getUseAnimation() == UseAnim_eat ) + if( item != nullptr && mob->getUseItemDuration() > 0 && item->getUseAnimation() == UseAnim_eat ) { // These factors are largely lifted from ItemInHandRenderer to try and keep the 3rd person eating animation as similar as possible float t = (mob->getUseItemDuration() - a + 1); @@ -237,7 +237,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) shared_ptr mob = dynamic_pointer_cast(_mob); shared_ptr headGear = mob->inventory->getArmor(3); - if (headGear != NULL) + if (headGear != nullptr) { // don't render the pumpkin for the skins unsigned int uiAnimOverrideBitmask = mob->getSkinAnimOverrideBitmask( mob->getCustomSkin()); @@ -277,7 +277,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) } // need to add a custom texture for deadmau5 - if (mob != NULL && app.isXuidDeadmau5( mob->getXuid() ) && bindTexture(mob->customTextureUrl, L"" )) + if (mob != nullptr && app.isXuidDeadmau5( mob->getXuid() ) && bindTexture(mob->customTextureUrl, L"" )) { for (int i = 0; i < 2; i++) { @@ -345,13 +345,13 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) shared_ptr item = mob->inventory->getSelected(); - if (item != NULL) + if (item != nullptr) { glPushMatrix(); humanoidModel->arm0->translateTo(1 / 16.0f); glTranslatef(-1 / 16.0f, 7 / 16.0f, 1 / 16.0f); - if (mob->fishing != NULL) + if (mob->fishing != nullptr) { item = shared_ptr( new ItemInstance(Item::stick) ); } @@ -449,7 +449,7 @@ void PlayerRenderer::renderNameTags(shared_ptr player, double x, d Scoreboard *scoreboard = player->getScoreboard(); Objective *objective = scoreboard->getDisplayObjective(Scoreboard::DISPLAY_SLOT_BELOW_NAME); - if (objective != NULL) + if (objective != nullptr) { Score *score = scoreboard->getPlayerScore(player->getAName(), objective); @@ -535,7 +535,7 @@ void PlayerRenderer::renderShadow(shared_ptr e, double x, double y, doub if(app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) > 0) { shared_ptr player = dynamic_pointer_cast(e); - if(player != NULL && player->hasInvisiblePrivilege()) return; + if(player != nullptr && player->hasInvisiblePrivilege()) return; } EntityRenderer::renderShadow(e,x,y,z,pow,a); } diff --git a/Minecraft.Client/PreStitchedTextureMap.cpp b/Minecraft.Client/PreStitchedTextureMap.cpp index 5a98b3462..33e0b59ec 100644 --- a/Minecraft.Client/PreStitchedTextureMap.cpp +++ b/Minecraft.Client/PreStitchedTextureMap.cpp @@ -26,8 +26,8 @@ PreStitchedTextureMap::PreStitchedTextureMap(int type, const wstring &name, cons this->missingTexture = missingTexture; // 4J Initialisers - missingPosition = NULL; - stitchResult = NULL; + missingPosition = nullptr; + stitchResult = nullptr; m_mipMap = mipmap; missingPosition = static_cast(new SimpleIcon(NAME_MISSING_TEXTURE, NAME_MISSING_TEXTURE, 0, 0, 1, 1)); @@ -48,7 +48,7 @@ void PreStitchedTextureMap::stitch() //for (Tile tile : Tile.tiles) for(unsigned int i = 0; i < Tile::TILE_NUM_COUNT; ++i) { - if (Tile::tiles[i] != NULL) + if (Tile::tiles[i] != nullptr) { Tile::tiles[i]->registerIcons(this); } @@ -62,7 +62,7 @@ void PreStitchedTextureMap::stitch() for(unsigned int i = 0; i < Item::ITEM_NUM_COUNT; ++i) { Item *item = Item::items[i]; - if (item != NULL && item->getIconType() == iconType) + if (item != nullptr && item->getIconType() == iconType) { item->registerIcons(this); } @@ -121,7 +121,7 @@ void PreStitchedTextureMap::stitch() int height = image->getHeight(); int width = image->getWidth(); - if(stitchResult != NULL) + if(stitchResult != nullptr) { TextureManager::getInstance()->unregisterTexture(name, stitchResult); delete stitchResult; @@ -216,7 +216,7 @@ void PreStitchedTextureMap::makeTextureAnimated(TexturePack *texturePack, Stitch // TODO: [EB] Put the frames into a proper object, not this inside out hack vector *frames = TextureManager::getInstance()->createTextures(filename, m_mipMap); - if (frames == NULL || frames->empty()) + if (frames == nullptr || frames->empty()) { return; // Couldn't load a texture, skip it } @@ -248,10 +248,10 @@ StitchedTexture *PreStitchedTextureMap::getTexture(const wstring &name) app.DebugPrintf("Not implemented!\n"); __debugbreak(); #endif - return NULL; + return nullptr; #if 0 StitchedTexture *result = texturesByName.find(name)->second; - if (result == NULL) result = missingPosition; + if (result == nullptr) result = missingPosition; return result; #endif } @@ -272,10 +272,10 @@ Texture *PreStitchedTextureMap::getStitchedTexture() // 4J Stu - register is a reserved keyword in C++ Icon *PreStitchedTextureMap::registerIcon(const wstring &name) { - Icon *result = NULL; + Icon *result = nullptr; if (name.empty()) { - app.DebugPrintf("Don't register NULL\n"); + app.DebugPrintf("Don't register nullptr\n"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif diff --git a/Minecraft.Client/ReceivingLevelScreen.cpp b/Minecraft.Client/ReceivingLevelScreen.cpp index 0e9fe3ec0..fda24773e 100644 --- a/Minecraft.Client/ReceivingLevelScreen.cpp +++ b/Minecraft.Client/ReceivingLevelScreen.cpp @@ -25,7 +25,7 @@ void ReceivingLevelScreen::tick() { connection->send( shared_ptr( new KeepAlivePacket() ) ); } - if (connection != NULL) + if (connection != nullptr) { connection->tick(); } diff --git a/Minecraft.Client/RemotePlayer.cpp b/Minecraft.Client/RemotePlayer.cpp index ea946db02..dcfd69926 100644 --- a/Minecraft.Client/RemotePlayer.cpp +++ b/Minecraft.Client/RemotePlayer.cpp @@ -58,7 +58,7 @@ void RemotePlayer::tick() walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f; walkAnimPos += walkAnimSpeed; - if (!hasStartedUsingItem && isUsingItemFlag() && inventory->items[inventory->selected] != NULL) + if (!hasStartedUsingItem && isUsingItemFlag() && inventory->items[inventory->selected] != nullptr) { shared_ptr item = inventory->items[inventory->selected]; startUsingItem(inventory->items[inventory->selected], Item::items[item->id]->getUseDuration(item)); diff --git a/Minecraft.Client/RenameWorldScreen.cpp b/Minecraft.Client/RenameWorldScreen.cpp index ea05039af..4255201ca 100644 --- a/Minecraft.Client/RenameWorldScreen.cpp +++ b/Minecraft.Client/RenameWorldScreen.cpp @@ -8,7 +8,7 @@ RenameWorldScreen::RenameWorldScreen(Screen *lastScreen, const wstring& levelId) { - nameEdit = NULL; + nameEdit = nullptr; this->lastScreen = lastScreen; this->levelId = levelId; } diff --git a/Minecraft.Client/Screen.cpp b/Minecraft.Client/Screen.cpp index 3e632f0b6..59ec2c0a8 100644 --- a/Minecraft.Client/Screen.cpp +++ b/Minecraft.Client/Screen.cpp @@ -13,13 +13,13 @@ Screen::Screen() // 4J added { - minecraft = NULL; + minecraft = nullptr; width = 0; height = 0; passEvents = false; - font = NULL; - particles = NULL; - clickedButton = NULL; + font = nullptr; + particles = nullptr; + clickedButton = nullptr; } void Screen::render(int xm, int ym, float a) @@ -35,7 +35,7 @@ void Screen::keyPressed(wchar_t eventCharacter, int eventKey) { if (eventKey == Keyboard::KEY_ESCAPE) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J - removed } } @@ -43,7 +43,7 @@ void Screen::keyPressed(wchar_t eventCharacter, int eventKey) wstring Screen::getClipboard() { // 4J - removed - return NULL; + return nullptr; } void Screen::setClipboard(const wstring& str) @@ -69,10 +69,10 @@ void Screen::mouseClicked(int x, int y, int buttonNum) void Screen::mouseReleased(int x, int y, int buttonNum) { - if (clickedButton!=NULL && buttonNum==0) + if (clickedButton!=nullptr && buttonNum==0) { clickedButton->released(x, y); - clickedButton = NULL; + clickedButton = nullptr; } } @@ -210,7 +210,7 @@ void Screen::renderBackground() void Screen::renderBackground(int vo) { - if (minecraft->level != NULL) + if (minecraft->level != nullptr) { fillGradient(0, 0, width, height, 0xc0101010, 0xd0101010); } diff --git a/Minecraft.Client/SelectWorldScreen.cpp b/Minecraft.Client/SelectWorldScreen.cpp index 75ccc268c..cc2090785 100644 --- a/Minecraft.Client/SelectWorldScreen.cpp +++ b/Minecraft.Client/SelectWorldScreen.cpp @@ -16,11 +16,11 @@ SelectWorldScreen::SelectWorldScreen(Screen *lastScreen) title = L"Select world"; done = false; selectedWorld = 0; - worldSelectionList = NULL; + worldSelectionList = nullptr; isDeleting = false; - deleteButton = NULL; - selectButton = NULL; - renameButton = NULL; + deleteButton = nullptr; + selectButton = nullptr; + renameButton = nullptr; this->lastScreen = lastScreen; } @@ -115,14 +115,14 @@ void SelectWorldScreen::buttonClicked(Button *button) else { // create demo world - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); if (done) return; done = true; // 4J Stu - Not used, so commenting to stop the build failing #if 0 minecraft->gameMode = new DemoMode(minecraft); minecraft->selectLevel(CreateWorldScreen::findAvailableFolderName(minecraft->getLevelSource(), L"Demo"), L"Demo World", 0L); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); #endif } } @@ -142,20 +142,20 @@ void SelectWorldScreen::buttonClicked(Button *button) void SelectWorldScreen::worldSelected(int id) { - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); if (done) return; done = true; - minecraft->gameMode = NULL; //new SurvivalMode(minecraft); + minecraft->gameMode = nullptr; //new SurvivalMode(minecraft); wstring worldFolderName = getWorldId(id); - if (worldFolderName == L"") // 4J - was NULL comparison + if (worldFolderName == L"") // 4J - was nullptr comparison { worldFolderName = L"World" + std::to_wstring(id); } // 4J Stu - Not used, so commenting to stop the build failing #if 0 minecraft->selectLevel(worldFolderName, getWorldName(id), 0); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); #endif } diff --git a/Minecraft.Client/ServerChunkCache.cpp b/Minecraft.Client/ServerChunkCache.cpp index 2f79c6caa..f4440200e 100644 --- a/Minecraft.Client/ServerChunkCache.cpp +++ b/Minecraft.Client/ServerChunkCache.cpp @@ -71,7 +71,7 @@ bool ServerChunkCache::hasChunk(int x, int z) if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return true; int idx = ix * XZSIZE + iz; LevelChunk *lc = cache[idx]; - if( lc == NULL ) return false; + if( lc == nullptr ) return false; return true; } @@ -148,13 +148,13 @@ LevelChunk *ServerChunkCache::create(int x, int z, bool asyncPostProcess) // 4J LevelChunk *chunk = cache[idx]; LevelChunk *lastChunk = chunk; - if( ( chunk == NULL ) || ( chunk->x != x ) || ( chunk->z != z ) ) + if( ( chunk == nullptr ) || ( chunk->x != x ) || ( chunk->z != z ) ) { EnterCriticalSection(&m_csLoadCreate); chunk = load(x, z); - if (chunk == NULL) + if (chunk == nullptr) { - if (source == NULL) + if (source == nullptr) { chunk = emptyChunk; } @@ -163,7 +163,7 @@ LevelChunk *ServerChunkCache::create(int x, int z, bool asyncPostProcess) // 4J chunk = source->getChunk(x, z); } } - if (chunk != NULL) + if (chunk != nullptr) { chunk->load(); } @@ -320,7 +320,7 @@ void ServerChunkCache::overwriteLevelChunkFromSource(int x, int z) if( ( iz < 0 ) || ( iz >= XZSIZE ) ) assert(0); int idx = ix * XZSIZE + iz; - LevelChunk *chunk = NULL; + LevelChunk *chunk = nullptr; chunk = source->getChunk(x, z); assert(chunk); if(chunk) @@ -389,22 +389,22 @@ void ServerChunkCache::dontDrop(int x, int z) LevelChunk *ServerChunkCache::load(int x, int z) { - if (storage == NULL) return NULL; + if (storage == nullptr) return nullptr; - LevelChunk *levelChunk = NULL; + LevelChunk *levelChunk = nullptr; #ifdef _LARGE_WORLDS int ix = x + XZOFFSET; int iz = z + XZOFFSET; int idx = ix * XZSIZE + iz; levelChunk = m_unloadedCache[idx]; - m_unloadedCache[idx] = NULL; - if(levelChunk == NULL) + m_unloadedCache[idx] = nullptr; + if(levelChunk == nullptr) #endif { levelChunk = storage->load(level, x, z); } - if (levelChunk != NULL) + if (levelChunk != nullptr) { levelChunk->lastSaveTime = level->getGameTime(); } @@ -413,14 +413,14 @@ LevelChunk *ServerChunkCache::load(int x, int z) void ServerChunkCache::saveEntities(LevelChunk *levelChunk) { - if (storage == NULL) return; + if (storage == nullptr) return; storage->saveEntities(level, levelChunk); } void ServerChunkCache::save(LevelChunk *levelChunk) { - if (storage == NULL) return; + if (storage == nullptr) return; levelChunk->lastSaveTime = level->getGameTime(); storage->save(level, levelChunk); @@ -542,7 +542,7 @@ void ServerChunkCache::postProcess(ChunkSource *parent, int x, int z ) LevelChunk *chunk = getChunk(x, z); if ( (chunk->terrainPopulated & LevelChunk::sTerrainPopulatedFromHere) == 0 ) { - if (source != NULL) + if (source != nullptr) { PIXBeginNamedEvent(0,"Main post processing"); source->postProcess(parent, x, z); @@ -659,7 +659,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) } // 4J - added this to support progressListener - if (progressListener != NULL) + if (progressListener != nullptr) { if (++cc % 10 == 0) { @@ -712,7 +712,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) } // 4J - added this to support progressListener - if (progressListener != NULL) + if (progressListener != nullptr) { if (++cc % 10 == 0) { @@ -741,21 +741,21 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) for(unsigned int i = 0; i < 3; ++i) { - saveThreads[i] = NULL; + saveThreads[i] = nullptr; threadData[i].cache = this; - wakeEvent[i] = new C4JThread::Event(); //CreateEvent(NULL,FALSE,FALSE,NULL); + wakeEvent[i] = new C4JThread::Event(); //CreateEvent(nullptr,FALSE,FALSE,nullptr); threadData[i].wakeEvent = wakeEvent[i]; - notificationEvent[i] = new C4JThread::Event(); //CreateEvent(NULL,FALSE,FALSE,NULL); + notificationEvent[i] = new C4JThread::Event(); //CreateEvent(nullptr,FALSE,FALSE,nullptr); threadData[i].notificationEvent = notificationEvent[i]; if(i==0) threadData[i].useSharedThreadStorage = true; else threadData[i].useSharedThreadStorage = false; } - LevelChunk *chunk = NULL; + LevelChunk *chunk = nullptr; byte workingThreads; bool chunkSet = false; @@ -804,13 +804,13 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) //app.DebugPrintf("Chunk to save set for thread %d\n", j); - if(saveThreads[j] == NULL) + if(saveThreads[j] == nullptr) { char threadName[256]; sprintf(threadName,"Save thread %d\n",j); SetThreadName(threadId[j], threadName); - //saveThreads[j] = CreateThread(NULL,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]); + //saveThreads[j] = CreateThread(nullptr,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]); saveThreads[j] = new C4JThread(runSaveThreadProc,(void *)&threadData[j],threadName); @@ -836,7 +836,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) } // 4J - added this to support progressListener - if (progressListener != NULL) + if (progressListener != nullptr) { if (count > 0 && ++cc % 10 == 0) { @@ -850,7 +850,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) if( !chunkSet ) { - threadData[j].chunkToSave = NULL; + threadData[j].chunkToSave = nullptr; //app.DebugPrintf("No chunk to save set for thread %d\n",j); } } @@ -882,13 +882,13 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) unsigned char validThreads = 0; for(unsigned int i = 0; i < 3; ++i) { - //app.DebugPrintf("Settings chunk to NULL for save thread %d\n", i); - threadData[i].chunkToSave = NULL; + //app.DebugPrintf("Settings chunk to nullptr for save thread %d\n", i); + threadData[i].chunkToSave = nullptr; //app.DebugPrintf("Setting wake event for save thread %d\n",i); threadData[i].wakeEvent->Set(); //SetEvent(threadData[i].wakeEvent); - if(saveThreads[i] != NULL) ++validThreads; + if(saveThreads[i] != nullptr) ++validThreads; } //WaitForMultipleObjects(validThreads,saveThreads,TRUE,INFINITE); @@ -910,7 +910,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) if (force) { - if (storage == NULL) + if (storage == nullptr) { LeaveCriticalSection(&m_csLoadCreate); return true; @@ -955,14 +955,14 @@ bool ServerChunkCache::tick() int iz = chunk->z + XZOFFSET; int idx = ix * XZSIZE + iz; m_unloadedCache[idx] = chunk; - cache[idx] = NULL; + cache[idx] = nullptr; } } m_toDrop.pop_front(); } } #endif - if (storage != NULL) storage->tick(); + if (storage != nullptr) storage->tick(); } return source->tick(); @@ -1013,7 +1013,7 @@ int ServerChunkCache::runSaveThreadProc(LPVOID lpParam) //app.DebugPrintf("Save thread has started\n"); - while(params->chunkToSave != NULL) + while(params->chunkToSave != nullptr) { PIXBeginNamedEvent(0,"Saving entities"); //app.DebugPrintf("Save thread has started processing a chunk\n"); diff --git a/Minecraft.Client/ServerConnection.cpp b/Minecraft.Client/ServerConnection.cpp index 07616aa47..cca4c619f 100644 --- a/Minecraft.Client/ServerConnection.cpp +++ b/Minecraft.Client/ServerConnection.cpp @@ -78,7 +78,7 @@ void ServerConnection::tick() // uc.disconnect("Internal server error"); // logger.log(Level.WARNING, "Failed to handle packet: " + e, e); // } - if(uc->connection != NULL) uc->connection->flush(); + if(uc->connection != nullptr) uc->connection->flush(); } } @@ -167,7 +167,7 @@ void ServerConnection::handleServerSettingsChanged(shared_ptrlevels.length; ++i) { - if( pMinecraft->levels[i] != NULL ) + if( pMinecraft->levels[i] != nullptr ) { app.DebugPrintf("ClientConnection::handleServerSettingsChanged - Difficulty = %d",packet->data); pMinecraft->levels[i]->difficulty = packet->data; diff --git a/Minecraft.Client/ServerLevel.cpp b/Minecraft.Client/ServerLevel.cpp index 265a1428c..89fe12a4b 100644 --- a/Minecraft.Client/ServerLevel.cpp +++ b/Minecraft.Client/ServerLevel.cpp @@ -42,7 +42,7 @@ WeighedTreasureArray ServerLevel::RANDOM_BONUS_ITEMS; -C4JThread* ServerLevel::m_updateThread = NULL; +C4JThread* ServerLevel::m_updateThread = nullptr; C4JThread::EventArray* ServerLevel::m_updateTrigger; CRITICAL_SECTION ServerLevel::m_updateCS[3]; @@ -63,7 +63,7 @@ void ServerLevel::staticCtor() InitializeCriticalSection(&m_updateCS[1]); InitializeCriticalSection(&m_updateCS[2]); - m_updateThread = new C4JThread(runUpdate, NULL, "Tile update"); + m_updateThread = new C4JThread(runUpdate, nullptr, "Tile update"); m_updateThread->SetProcessor(CPU_CORE_TILE_UPDATE); #ifdef __ORBIS__ m_updateThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); // On Orbis, this core is also used for Matching 2, and that priority of that seems to be always at default no matter what we set it to. Prioritise this below Matching 2. @@ -123,7 +123,7 @@ ServerLevel::ServerLevel(MinecraftServer *server, shared_ptrlevelS scoreboard = new ServerScoreboard(server); //shared_ptr scoreboardSaveData = dynamic_pointer_cast( savedDataStorage->get(typeid(ScoreboardSaveData), ScoreboardSaveData::FILE_ID) ); - //if (scoreboardSaveData == NULL) + //if (scoreboardSaveData == nullptr) //{ // scoreboardSaveData = shared_ptr( new ScoreboardSaveData() ); // savedDataStorage->set(ScoreboardSaveData::FILE_ID, scoreboardSaveData); @@ -258,7 +258,7 @@ void ServerLevel::tick() { //app.DebugPrintf("Incremental save\n"); PIXBeginNamedEvent(0,"Incremental save"); - save(false, NULL); + save(false, nullptr); PIXEndNamedEvent(); } @@ -313,7 +313,7 @@ void ServerLevel::tick() Biome::MobSpawnerData *ServerLevel::getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z) { vector *mobList = getChunkSource()->getMobsAt(mobCategory, x, y, z); - if (mobList == NULL || mobList->empty()) return NULL; + if (mobList == nullptr || mobList->empty()) return nullptr; return static_cast(WeighedRandom::getRandomItem(random, (vector *)mobList)); } @@ -433,7 +433,7 @@ void ServerLevel::tickTiles() if( hasChunkAt(x,y,z) ) { int id = getTile(x,y,z); - if (Tile::tiles[id] != NULL && Tile::tiles[id]->isTicking()) + if (Tile::tiles[id] != nullptr && Tile::tiles[id]->isTicking()) { /*if(id == 2) ++grassTicks; else if(id == 11) ++lavaTicks; @@ -776,7 +776,7 @@ void ServerLevel::tick(shared_ptr e, bool actual) { e->remove(); } - if (!server->isNpcsEnabled() && (dynamic_pointer_cast(e) != NULL)) + if (!server->isNpcsEnabled() && (dynamic_pointer_cast(e) != nullptr)) { e->remove(); } @@ -860,7 +860,7 @@ void ServerLevel::setInitialSpawn(LevelSettings *levelSettings) int minXZ = - (dimension->getXZSize() * 16 ) / 2; int maxXZ = (dimension->getXZSize() * 16 ) / 2 - 1; - if (findBiome != NULL) + if (findBiome != nullptr) { xSpawn = findBiome->x; zSpawn = findBiome->z; @@ -914,7 +914,7 @@ void ServerLevel::generateBonusItemsNearSpawn() if( getTile( x, y, z ) == Tile::chest_Id ) { shared_ptr chest = dynamic_pointer_cast(getTileEntity(x, y, z)); - if (chest != NULL) + if (chest != nullptr) { if( chest->isBonusChest ) { @@ -960,7 +960,7 @@ void ServerLevel::save(bool force, ProgressListener *progressListener, bool bAut if(StorageManager.GetSaveDisabled()) return; - if (progressListener != NULL) + if (progressListener != nullptr) { if(bAutosave) { @@ -976,7 +976,7 @@ void ServerLevel::save(bool force, ProgressListener *progressListener, bool bAut saveLevelData(); PIXEndNamedEvent(); - if (progressListener != NULL) progressListener->progressStage(IDS_PROGRESS_SAVING_CHUNKS); + if (progressListener != nullptr) progressListener->progressStage(IDS_PROGRESS_SAVING_CHUNKS); #if defined(_XBOX_ONE) || defined(__ORBIS__) // Our autosave is a minimal save. All the chunks are saves by the constant save process @@ -1009,7 +1009,7 @@ void ServerLevel::save(bool force, ProgressListener *progressListener, bool bAut //if( force && !isClientSide ) //{ - // if (progressListener != NULL) progressListener->progressStage(IDS_PROGRESS_SAVING_TO_DISC); + // if (progressListener != nullptr) progressListener->progressStage(IDS_PROGRESS_SAVING_TO_DISC); // levelStorage->flushSaveFile(); //} } @@ -1034,7 +1034,7 @@ void ServerLevel::saveToDisc(ProgressListener *progressListener, bool autosave) } } - if (progressListener != NULL) progressListener->progressStage(IDS_PROGRESS_SAVING_TO_DISC); + if (progressListener != nullptr) progressListener->progressStage(IDS_PROGRESS_SAVING_TO_DISC); levelStorage->flushSaveFile(autosave); } @@ -1122,7 +1122,7 @@ shared_ptr ServerLevel::explode(shared_ptr source, double x, if( sentTo.size() ) { INetworkPlayer *thisPlayer = player->connection->getNetworkPlayer(); - if( thisPlayer == NULL ) + if( thisPlayer == nullptr ) { continue; } @@ -1131,7 +1131,7 @@ shared_ptr ServerLevel::explode(shared_ptr source, double x, for(auto& player2 : sentTo) { INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { knockbackOnly = true; } @@ -1578,7 +1578,7 @@ int ServerLevel::runUpdate(void* lpParam) if( (id == Tile::grass_Id && grassTicks >= MAX_GRASS_TICKS) || (id == Tile::calmLava_Id && lavaTicks >= MAX_LAVA_TICKS) ) continue; // 4J Stu - Added shouldTileTick as some tiles won't even do anything if they are set to tick and use up one of our updates - if (Tile::tiles[id] != NULL && Tile::tiles[id]->isTicking() && Tile::tiles[id]->shouldTileTick(m_level[iLev],x + (cx * 16), y, z + (cz * 16) ) ) + if (Tile::tiles[id] != nullptr && Tile::tiles[id]->isTicking() && Tile::tiles[id]->shouldTileTick(m_level[iLev],x + (cx * 16), y, z + (cz * 16) ) ) { if(id == Tile::grass_Id) ++grassTicks; else if(id == Tile::calmLava_Id) ++lavaTicks; diff --git a/Minecraft.Client/ServerPlayer.cpp b/Minecraft.Client/ServerPlayer.cpp index 898e4a66f..dc4628ab1 100644 --- a/Minecraft.Client/ServerPlayer.cpp +++ b/Minecraft.Client/ServerPlayer.cpp @@ -101,7 +101,7 @@ ServerPlayer::ServerPlayer(MinecraftServer *server, Level *level, const wstring& waterDepth++; } attemptCount++; - playerNear = ( level->getNearestPlayer(xx + 0.5, yy, zz + 0.5,3) != NULL ); + playerNear = ( level->getNearestPlayer(xx + 0.5, yy, zz + 0.5,3) != nullptr ); } while ( ( waterDepth > 1 ) && (!playerNear) && ( attemptCount < 20 ) ); xx = xx2; yy = yy2; @@ -180,7 +180,7 @@ void ServerPlayer::readAdditionalSaveData(CompoundTag *entityTag) } GameRulesInstance *grs = gameMode->getGameRules(); - if (entityTag->contains(L"GameRules") && grs != NULL) + if (entityTag->contains(L"GameRules") && grs != nullptr) { byteArray ba = entityTag->getByteArray(L"GameRules"); ByteArrayInputStream bais(ba); @@ -197,13 +197,13 @@ void ServerPlayer::addAdditonalSaveData(CompoundTag *entityTag) Player::addAdditonalSaveData(entityTag); GameRulesInstance *grs = gameMode->getGameRules(); - if (grs != NULL) + if (grs != nullptr) { ByteArrayOutputStream baos; DataOutputStream dos(&baos); grs->write(&dos); entityTag->putByteArray(L"GameRules", baos.buf); - baos.buf.data = NULL; + baos.buf.data = nullptr; dos.close(); baos.close(); } @@ -308,14 +308,14 @@ void ServerPlayer::doTickA() for (unsigned int i = 0; i < inventory->getContainerSize(); i++) { shared_ptr ie = inventory->getItem(i); - if (ie != NULL) + if (ie != nullptr) { // 4J - removed condition. These were getting lower priority than tile update packets etc. on the slow outbound queue, and so were extremely slow to send sometimes, // particularly at the start of a game. They don't typically seem to be massive and shouldn't be send when there isn't actually any updating to do. if (Item::items[ie->id]->isComplex() ) // && connection->countDelayedPackets() <= 2) { shared_ptr packet = (dynamic_cast(Item::items[ie->id])->getUpdatePacket(ie, level, dynamic_pointer_cast( shared_from_this() ) ) ); - if (packet != NULL) + if (packet != nullptr) { connection->send(packet); } @@ -352,7 +352,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) } } - // if (nearest != NULL) // 4J - removed as we don't have references here + // if (nearest != nullptr) // 4J - removed as we don't have references here if( nearestValid ) { bool okToSend = false; @@ -372,7 +372,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) // app.DebugPrintf("%d: canSendToPlayer %d, countDelayedPackets %d GetSendQueueSizeBytes %d done: %d\n", // connection->getNetworkPlayer()->GetSmallId(), // canSendToPlayer, connection->countDelayedPackets(), -// g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( NULL, true ), +// g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( nullptr, true ), // connection->done); // } @@ -381,12 +381,12 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) #ifdef _XBOX_ONE // The network manager on xbox one doesn't currently split data into slow & fast queues - since we can only measure // both together then bytes provides a better metric than count of data items to determine if we should avoid queueing too much up - (g_NetworkManager.GetHostPlayer()->GetSendQueueSizeBytes( NULL, true ) < 8192 )&& + (g_NetworkManager.GetHostPlayer()->GetSendQueueSizeBytes( nullptr, true ) < 8192 )&& #elif defined _XBOX - (g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( NULL, true ) < 4 )&& + (g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( nullptr, true ) < 4 )&& #else (connection->countDelayedPackets() < 4 )&& - (g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( NULL, true ) < 4 )&& + (g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( nullptr, true ) < 4 )&& #endif //(tickCount - lastBrupSendTickCount) > (connection->getNetworkPlayer()->GetCurrentRtt()>>4) && !connection->done) ) @@ -584,7 +584,7 @@ void ServerPlayer::die(DamageSource *source) } shared_ptr killer = getKillCredit(); - if (killer != NULL) killer->awardKillScore(shared_from_this(), deathScore); + if (killer != nullptr) killer->awardKillScore(shared_from_this(), deathScore); //awardStat(Stats::deaths, 1); } @@ -597,10 +597,10 @@ bool ServerPlayer::hurt(DamageSource *dmgSource, float dmg) //bool allowFallDamage = server->isPvpAllowed() && server->isDedicatedServer() && server->isPvpAllowed() && (dmgSource->msgId.compare(L"fall") == 0); if (!server->isPvpAllowed() && invulnerableTime > 0 && dmgSource != DamageSource::outOfWorld) return false; - if (dynamic_cast(dmgSource) != NULL) + if (dynamic_cast(dmgSource) != nullptr) { // 4J Stu - Fix for #46422 - TU5: Crash: Gameplay: Crash when being hit by a trap using a dispenser - // getEntity returns the owner of projectiles, and this would never be the arrow. The owner is sometimes NULL. + // getEntity returns the owner of projectiles, and this would never be the arrow. The owner is sometimes nullptr. shared_ptr source = dmgSource->getDirectEntity(); if (source->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast(source)->canHarmPlayer(dynamic_pointer_cast(shared_from_this()))) @@ -608,10 +608,10 @@ bool ServerPlayer::hurt(DamageSource *dmgSource, float dmg) return false; } - if ( (source != NULL) && source->instanceof(eTYPE_ARROW) ) + if ( (source != nullptr) && source->instanceof(eTYPE_ARROW) ) { shared_ptr arrow = dynamic_pointer_cast(source); - if ( (arrow->owner != NULL) && arrow->owner->instanceof(eTYPE_PLAYER) && !canHarmPlayer(dynamic_pointer_cast(arrow->owner)) ) + if ( (arrow->owner != nullptr) && arrow->owner->instanceof(eTYPE_PLAYER) && !canHarmPlayer(dynamic_pointer_cast(arrow->owner)) ) { return false; } @@ -634,7 +634,7 @@ bool ServerPlayer::hurt(DamageSource *dmgSource, float dmg) else { shared_ptr source = dmgSource->getEntity(); - if( source != NULL ) + if( source != nullptr ) { switch(source->GetType()) { @@ -670,10 +670,10 @@ bool ServerPlayer::hurt(DamageSource *dmgSource, float dmg) m_lastDamageSource = eTelemetryPlayerDeathSource_Explosion_Tnt; break; case eTYPE_ARROW: - if ((dynamic_pointer_cast(source))->owner != NULL) + if ((dynamic_pointer_cast(source))->owner != nullptr) { shared_ptr attacker = (dynamic_pointer_cast(source))->owner; - if (attacker != NULL) + if (attacker != nullptr) { switch(attacker->GetType()) { @@ -712,7 +712,7 @@ bool ServerPlayer::canHarmPlayer(wstring targetName) bool canHarm = true; shared_ptr owner = server->getPlayers()->getPlayer(targetName); - if (owner != NULL) + if (owner != nullptr) { if ((shared_from_this() != owner) && canHarmPlayer(owner)) canHarm = false; } @@ -749,7 +749,7 @@ void ServerPlayer::changeDimension(int i) for(auto& servPlayer : MinecraftServer::getInstance()->getPlayers()->players) { INetworkPlayer *checkPlayer = servPlayer->connection->getNetworkPlayer(); - if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && !servPlayer->wonGame ) + if(thisPlayer != checkPlayer && checkPlayer != nullptr && thisPlayer->IsSameSystem( checkPlayer ) && !servPlayer->wonGame ) { servPlayer->wonGame = true; servPlayer->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex() ) ) ); @@ -766,7 +766,7 @@ void ServerPlayer::changeDimension(int i) awardStat(GenericStats::theEnd(), GenericStats::param_theEnd()); Pos *pos = server->getLevel(i)->getDimensionSpecificSpawn(); - if (pos != NULL) + if (pos != nullptr) { connection->teleport(pos->x, pos->y, pos->z, 0, 0); delete pos; @@ -789,10 +789,10 @@ void ServerPlayer::changeDimension(int i) // 4J Added delay param void ServerPlayer::broadcast(shared_ptr te, bool delay /*= false*/) { - if (te != NULL) + if (te != nullptr) { shared_ptr p = te->getUpdatePacket(); - if (p != NULL) + if (p != nullptr) { p->shouldDelay = delay; if(delay) connection->queueSend(p); @@ -827,7 +827,7 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, boo getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::WAKE_UP) ) ); } Player::stopSleepInBed(forcefulWakeUp, updateLevelList, saveRespawnPoint); - if (connection != NULL) connection->teleport(x, y, z, yRot, xRot); + if (connection != nullptr) connection->teleport(x, y, z, yRot, xRot); } void ServerPlayer::ride(shared_ptr e) @@ -853,7 +853,7 @@ void ServerPlayer::doCheckFallDamage(double ya, bool onGround) void ServerPlayer::openTextEdit(shared_ptr sign) { shared_ptr signTE = dynamic_pointer_cast(sign); - if (signTE != NULL) + if (signTE != nullptr) { signTE->setAllowedPlayerEditor(dynamic_pointer_cast(shared_from_this())); connection->send( shared_ptr( new TileEditorOpenPacket(TileEditorOpenPacket::SIGN, sign->x, sign->y, sign->z)) ); @@ -893,7 +893,7 @@ bool ServerPlayer::openFireworks(int x, int y, int z) containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } - else if(dynamic_cast(containerMenu) != NULL) + else if(dynamic_cast(containerMenu) != nullptr) { closeContainer(); @@ -1092,7 +1092,7 @@ bool ServerPlayer::openTrading(shared_ptr traderTarget, const wstring connection->send(shared_ptr(new ContainerOpenPacket(containerCounter, ContainerOpenPacket::TRADER_NPC, name.empty()?L"":name, container->getContainerSize(), !name.empty()))); MerchantRecipeList *offers = traderTarget->getOffers(dynamic_pointer_cast(shared_from_this())); - if (offers != NULL) + if (offers != nullptr) { ByteArrayOutputStream rawOutput; DataOutputStream output(&rawOutput); @@ -1203,7 +1203,7 @@ void ServerPlayer::doCloseContainer() void ServerPlayer::setPlayerInput(float xxa, float yya, bool jumping, bool sneaking) { - if(riding != NULL) + if(riding != nullptr) { if (xxa >= -1 && xxa <= 1) this->xxa = xxa; if (yya >= -1 && yya <= 1) this->yya = yya; @@ -1214,7 +1214,7 @@ void ServerPlayer::setPlayerInput(float xxa, float yya, bool jumping, bool sneak void ServerPlayer::awardStat(Stat *stat, byteArray param) { - if (stat == NULL) + if (stat == nullptr) { delete [] param.data; return; @@ -1237,7 +1237,7 @@ void ServerPlayer::awardStat(Stat *stat, byteArray param) void ServerPlayer::disconnect() { - if (rider.lock() != NULL) rider.lock()->ride(shared_from_this() ); + if (rider.lock() != nullptr) rider.lock()->ride(shared_from_this() ); if (m_isSleeping) { stopSleepInBed(true, false, false); @@ -1501,7 +1501,7 @@ void ServerPlayer::startUsingItem(shared_ptr instance, int duratio { Player::startUsingItem(instance, duration); - if (instance != NULL && instance->getItem() != NULL && instance->getItem()->getUseAnimation(instance) == UseAnim_eat) + if (instance != nullptr && instance->getItem() != nullptr && instance->getItem()->getUseAnimation(instance) == UseAnim_eat) { getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::EAT) ) ); } @@ -1553,7 +1553,7 @@ void ServerPlayer::magicCrit(shared_ptr entity) void ServerPlayer::onUpdateAbilities() { - if (connection == NULL) return; + if (connection == nullptr) return; connection->send(shared_ptr(new PlayerAbilitiesPacket(&abilities))); } @@ -1651,7 +1651,7 @@ int ServerPlayer::getPlayerViewDistanceModifier() { INetworkPlayer *player = connection->getNetworkPlayer(); - if( player != NULL ) + if( player != nullptr ) { DWORD rtt = player->GetCurrentRtt(); @@ -1666,7 +1666,7 @@ int ServerPlayer::getPlayerViewDistanceModifier() void ServerPlayer::handleCollectItem(shared_ptr item) { - if(gameMode->getGameRules() != NULL) gameMode->getGameRules()->onCollectItem(item); + if(gameMode->getGameRules() != nullptr) gameMode->getGameRules()->onCollectItem(item); } #ifndef _CONTENT_PACKAGE diff --git a/Minecraft.Client/ServerPlayerGameMode.cpp b/Minecraft.Client/ServerPlayerGameMode.cpp index 4495c4da8..daafc2ca6 100644 --- a/Minecraft.Client/ServerPlayerGameMode.cpp +++ b/Minecraft.Client/ServerPlayerGameMode.cpp @@ -29,12 +29,12 @@ ServerPlayerGameMode::ServerPlayerGameMode(Level *level) this->level = level; // 4J Added - m_gameRules = NULL; + m_gameRules = nullptr; } ServerPlayerGameMode::~ServerPlayerGameMode() { - if(m_gameRules!=NULL) delete m_gameRules; + if(m_gameRules!=nullptr) delete m_gameRules; } void ServerPlayerGameMode::setGameModeForPlayer(GameType *gameModeForPlayer) @@ -105,7 +105,7 @@ void ServerPlayerGameMode::tick() int t = level->getTile(xDestroyBlock, yDestroyBlock, zDestroyBlock); Tile *tile = Tile::tiles[t]; - if (tile == NULL) + if (tile == nullptr) { level->destroyTileProgress(player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1); lastSentState = -1; @@ -216,13 +216,13 @@ bool ServerPlayerGameMode::superDestroyBlock(int x, int y, int z) Tile *oldTile = Tile::tiles[level->getTile(x, y, z)]; int data = level->getData(x, y, z); - if (oldTile != NULL) + if (oldTile != nullptr) { oldTile->playerWillDestroy(level, x, y, z, data, player); } bool changed = level->removeTile(x, y, z); - if (oldTile != NULL && changed) + if (oldTile != nullptr && changed) { oldTile->destroy(level, x, y, z, data); } @@ -241,7 +241,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) if (gameModeForPlayer->isCreative()) { - if (player->getCarriedItem() != NULL && dynamic_cast(player->getCarriedItem()->getItem()) != NULL) + if (player->getCarriedItem() != nullptr && dynamic_cast(player->getCarriedItem()->getItem()) != nullptr) { return false; } @@ -298,7 +298,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) { shared_ptr item = player->getSelectedItem(); bool canDestroy = player->canDestroy(Tile::tiles[t]); - if (item != NULL) + if (item != nullptr) { item->mineBlock(level, t, x, y, z, player); if (item->count == 0) @@ -322,7 +322,7 @@ bool ServerPlayerGameMode::useItem(shared_ptr player, Level *level, shar int oldCount = item->count; int oldAux = item->getAuxValue(); shared_ptr itemInstance = item->use(level, player); - if (itemInstance != item || (itemInstance != NULL && (itemInstance->count != oldCount || itemInstance->getUseDuration() > 0 || itemInstance->getAuxValue() != oldAux))) + if (itemInstance != item || (itemInstance != nullptr && (itemInstance->count != oldCount || itemInstance->getUseDuration() > 0 || itemInstance->getAuxValue() != oldAux))) { player->inventory->items[player->inventory->selected] = itemInstance; if (isCreative()) @@ -348,7 +348,7 @@ bool ServerPlayerGameMode::useItemOn(shared_ptr player, Level *level, sh { // 4J-PB - Adding a test only version to allow tooltips to be displayed int t = level->getTile(x, y, z); - if (!player->isSneaking() || player->getCarriedItem() == NULL) + if (!player->isSneaking() || player->getCarriedItem() == nullptr) { if (t > 0 && player->isAllowedToUse(Tile::tiles[t])) { @@ -360,14 +360,14 @@ bool ServerPlayerGameMode::useItemOn(shared_ptr player, Level *level, sh { if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX, clickY, clickZ)) { - if(m_gameRules != NULL) m_gameRules->onUseTile(t,x,y,z); + if(m_gameRules != nullptr) m_gameRules->onUseTile(t,x,y,z); return true; } } } } - if (item == NULL || !player->isAllowedToUse(item)) return false; + if (item == nullptr || !player->isAllowedToUse(item)) return false; if (isCreative()) { int aux = item->getAuxValue(); @@ -391,6 +391,6 @@ void ServerPlayerGameMode::setLevel(ServerLevel *newLevel) // 4J Added void ServerPlayerGameMode::setGameRules(GameRulesInstance *rules) { - if(m_gameRules != NULL) delete m_gameRules; + if(m_gameRules != nullptr) delete m_gameRules; m_gameRules = rules; } \ No newline at end of file diff --git a/Minecraft.Client/ServerPlayerGameMode.h b/Minecraft.Client/ServerPlayerGameMode.h index 89b9e9b44..509e16763 100644 --- a/Minecraft.Client/ServerPlayerGameMode.h +++ b/Minecraft.Client/ServerPlayerGameMode.h @@ -54,7 +54,7 @@ class ServerPlayerGameMode public: bool destroyBlock(int x, int y, int z); bool useItem(shared_ptr player, Level *level, shared_ptr item, bool bTestUseOnly=false); - bool useItemOn(shared_ptr player, Level *level, shared_ptr item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL); + bool useItemOn(shared_ptr player, Level *level, shared_ptr item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false, bool *pbUsedItem=nullptr); void setLevel(ServerLevel *newLevel); }; \ No newline at end of file diff --git a/Minecraft.Client/ServerScoreboard.cpp b/Minecraft.Client/ServerScoreboard.cpp index 738a29c92..9a0443245 100644 --- a/Minecraft.Client/ServerScoreboard.cpp +++ b/Minecraft.Client/ServerScoreboard.cpp @@ -37,7 +37,7 @@ void ServerScoreboard::setDisplayObjective(int slot, Objective *objective) //Scoreboard::setDisplayObjective(slot, objective); - //if (old != objective && old != NULL) + //if (old != objective && old != nullptr) //{ // if (getObjectiveDisplaySlotCount(old) > 0) // { @@ -49,7 +49,7 @@ void ServerScoreboard::setDisplayObjective(int slot, Objective *objective) // } //} - //if (objective != NULL) + //if (objective != nullptr) //{ // if (trackedObjectives.contains(objective)) // { @@ -146,7 +146,7 @@ void ServerScoreboard::setSaveData(ScoreboardSaveData *data) void ServerScoreboard::setDirty() { - //if (saveData != NULL) + //if (saveData != nullptr) //{ // saveData->setDirty(); //} @@ -154,7 +154,7 @@ void ServerScoreboard::setDirty() vector > *ServerScoreboard::getStartTrackingPackets(Objective *objective) { - return NULL; + return nullptr; //vector > *packets = new vector >(); //packets.push_back( shared_ptr( new SetObjectivePacket(objective, SetObjectivePacket::METHOD_ADD))); @@ -189,7 +189,7 @@ void ServerScoreboard::startTrackingObjective(Objective *objective) vector > *ServerScoreboard::getStopTrackingPackets(Objective *objective) { - return NULL; + return nullptr; //vector > *packets = new ArrayList(); //packets->push_back( shared_ptrgetPath(); } diff --git a/Minecraft.Client/SkullTileRenderer.cpp b/Minecraft.Client/SkullTileRenderer.cpp index e7b610bf1..7862043b2 100644 --- a/Minecraft.Client/SkullTileRenderer.cpp +++ b/Minecraft.Client/SkullTileRenderer.cpp @@ -6,7 +6,7 @@ #include "..\Minecraft.World\net.minecraft.h" #include "..\Minecraft.World\net.minecraft.world.level.tile.h" -SkullTileRenderer *SkullTileRenderer::instance = NULL; +SkullTileRenderer *SkullTileRenderer::instance = nullptr; ResourceLocation SkullTileRenderer::SKELETON_LOCATION = ResourceLocation(TN_MOB_SKELETON); ResourceLocation SkullTileRenderer::WITHER_SKELETON_LOCATION = ResourceLocation(TN_MOB_WITHER_SKELETON); diff --git a/Minecraft.Client/SlimeModel.cpp b/Minecraft.Client/SlimeModel.cpp index 834847f80..7d30ce663 100644 --- a/Minecraft.Client/SlimeModel.cpp +++ b/Minecraft.Client/SlimeModel.cpp @@ -27,9 +27,9 @@ SlimeModel::SlimeModel(int vOffs) } else { - eye0 = NULL; - eye1 = NULL; - mouth = NULL; + eye0 = nullptr; + eye1 = nullptr; + mouth = nullptr; } cube->compile(1.0f/16.0f); } @@ -39,7 +39,7 @@ void SlimeModel::render(shared_ptr entity, float time, float r, float bo setupAnim(time, r, bob, yRot, xRot, scale, entity); cube->render(scale,usecompiled); - if (eye0!=NULL) + if (eye0!=nullptr) { eye0->render(scale,usecompiled); eye1->render(scale,usecompiled); diff --git a/Minecraft.Client/SmallButton.cpp b/Minecraft.Client/SmallButton.cpp index 6bb3cd1fb..731f5f141 100644 --- a/Minecraft.Client/SmallButton.cpp +++ b/Minecraft.Client/SmallButton.cpp @@ -3,12 +3,12 @@ SmallButton::SmallButton(int id, int x, int y, const wstring& msg) : Button(id, x, y, 150, 20, msg) { - this->option = NULL; + this->option = nullptr; } SmallButton::SmallButton(int id, int x, int y, int width, int height, const wstring& msg) : Button(id, x, y, width, height, msg) { - this->option = NULL; + this->option = nullptr; } SmallButton::SmallButton(int id, int x, int y, const Options::Option *item, const wstring& msg) : Button(id, x, y, 150, 20, msg) diff --git a/Minecraft.Client/SnowManRenderer.cpp b/Minecraft.Client/SnowManRenderer.cpp index 11855fe37..853127bb7 100644 --- a/Minecraft.Client/SnowManRenderer.cpp +++ b/Minecraft.Client/SnowManRenderer.cpp @@ -23,7 +23,7 @@ void SnowManRenderer::additionalRendering(shared_ptr _mob, float a MobRenderer::additionalRendering(mob, a); shared_ptr headGear = shared_ptr( new ItemInstance(Tile::pumpkin, 1) ); - if (headGear != NULL && headGear->getItem()->id < 256) + if (headGear != nullptr && headGear->getItem()->id < 256) { glPushMatrix(); model->head->translateTo(1 / 16.0f); diff --git a/Minecraft.Client/StatsCounter.cpp b/Minecraft.Client/StatsCounter.cpp index 8f930fcf9..e92c43c0c 100644 --- a/Minecraft.Client/StatsCounter.cpp +++ b/Minecraft.Client/StatsCounter.cpp @@ -1314,30 +1314,30 @@ void StatsCounter::WipeLeaderboards() #if defined DEBUG_ENABLE_CLEAR_LEADERBOARDS && defined _XBOX - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_EASY, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_NORMAL, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_HARD, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_PEACEFUL, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_EASY, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_NORMAL, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_HARD, NULL); -// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_PEACEFUL, NULL); -// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_EASY, NULL); -// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_NORMAL, NULL); -// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_HARD, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_PEACEFUL, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_EASY, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_NORMAL, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_HARD, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_PEACEFUL, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_EASY, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_NORMAL, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_HARD, NULL); -// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_PEACEFUL, NULL); -// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_EASY, NULL); -// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_NORMAL, NULL); -// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_HARD, NULL); - if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_TOTAL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_TOTAL, NULL); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_EASY, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_NORMAL, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_HARD, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_PEACEFUL, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_EASY, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_NORMAL, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_HARD, nullptr); +// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_PEACEFUL, nullptr); +// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_EASY, nullptr); +// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_NORMAL, nullptr); +// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_HARD, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_PEACEFUL, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_EASY, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_NORMAL, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_HARD, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_PEACEFUL, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_EASY, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_NORMAL, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_HARD, nullptr); +// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_PEACEFUL ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_PEACEFUL, nullptr); +// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_EASY ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_EASY, nullptr); +// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_NORMAL ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_NORMAL, nullptr); +// if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_HARD ) XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_HARD, nullptr); + if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_TOTAL ) XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_TOTAL, nullptr); if( LeaderboardManager::Instance()->OpenSession() ) { writeStats(); diff --git a/Minecraft.Client/StatsScreen.cpp b/Minecraft.Client/StatsScreen.cpp index 6c42532db..c618a30f2 100644 --- a/Minecraft.Client/StatsScreen.cpp +++ b/Minecraft.Client/StatsScreen.cpp @@ -10,15 +10,15 @@ #include "..\Minecraft.World\net.minecraft.world.item.h" const float StatsScreen::SLOT_TEX_SIZE = 128.0f; -ItemRenderer *StatsScreen::itemRenderer = NULL; +ItemRenderer *StatsScreen::itemRenderer = nullptr; StatsScreen::StatsScreen(Screen *lastScreen, StatsCounter *stats) { // 4J - added initialisers itemRenderer = new ItemRenderer(); - statsList = NULL; - itemStatsList = NULL; - blockStatsList = NULL; + statsList = nullptr; + itemStatsList = nullptr; + blockStatsList = nullptr; this->lastScreen = lastScreen; this->stats = stats; } @@ -303,7 +303,7 @@ ItemStat *StatsScreen::StatisticsList::getSlotStat(int slot) void StatsScreen::StatisticsList::renderStat(ItemStat *stat, int x, int y, bool shaded) { - if (stat != NULL) + if (stat != nullptr) { wstring msg = stat->format(parent->stats->getTotalValue(stat)); parent->drawString(parent->font, msg, x - parent->font->width(msg), y + SLOT_TEXT_OFFSET, shaded ? 0xffffff : 0x909090); @@ -373,7 +373,7 @@ void StatsScreen::StatisticsList::renderMousehoverTooltip(ItemStat *stat, int x, { // 4J Stu - Unused #if 0 - if (stat == NULL) + if (stat == nullptr) { return; } @@ -429,11 +429,11 @@ StatsScreen::ItemStatisticsList::ItemStatisticsList(StatsScreen *ss) : StatsScre { addToList = true; } - else if (Stats::itemBroke[id] != NULL && parent->stats->getTotalValue(Stats::itemBroke[id]) > 0) + else if (Stats::itemBroke[id] != nullptr && parent->stats->getTotalValue(Stats::itemBroke[id]) > 0) { addToList = true; } - else if (Stats::itemCrafted[id] != NULL && parent->stats->getTotalValue(Stats::itemCrafted[id]) > 0) + else if (Stats::itemCrafted[id] != nullptr && parent->stats->getTotalValue(Stats::itemCrafted[id]) > 0) { addToList = true; } @@ -556,11 +556,11 @@ StatsScreen::BlockStatisticsList::BlockStatisticsList(StatsScreen *ss) : Statist { addToList = true; } - else if (Stats::itemUsed[id] != NULL && parent->stats->getTotalValue(Stats::itemUsed[id]) > 0) + else if (Stats::itemUsed[id] != nullptr && parent->stats->getTotalValue(Stats::itemUsed[id]) > 0) { addToList = true; } - else if (Stats::itemCrafted[id] != NULL && parent->stats->getTotalValue(Stats::itemCrafted[id]) > 0) + else if (Stats::itemCrafted[id] != nullptr && parent->stats->getTotalValue(Stats::itemCrafted[id]) > 0) { addToList = true; } diff --git a/Minecraft.Client/StitchSlot.cpp b/Minecraft.Client/StitchSlot.cpp index cdce61281..8de443ed4 100644 --- a/Minecraft.Client/StitchSlot.cpp +++ b/Minecraft.Client/StitchSlot.cpp @@ -5,8 +5,8 @@ StitchSlot::StitchSlot(int originX, int originY, int width, int height) : originX(originX), originY(originY), width(width), height(height) { - subSlots = NULL; - textureHolder = NULL; + subSlots = nullptr; + textureHolder = nullptr; } TextureHolder *StitchSlot::getHolder() @@ -27,7 +27,7 @@ int StitchSlot::getY() bool StitchSlot::add(TextureHolder *textureHolder) { // Already holding a texture -- doesn't account for subslots. - if (this->textureHolder != NULL) + if (this->textureHolder != nullptr) { return false; } @@ -42,7 +42,7 @@ bool StitchSlot::add(TextureHolder *textureHolder) } // Exact fit! best-case-solution - if (textureWidth == width && textureHeight == height && subSlots == NULL) + if (textureWidth == width && textureHeight == height && subSlots == nullptr) { // Store somehow this->textureHolder = textureHolder; @@ -50,7 +50,7 @@ bool StitchSlot::add(TextureHolder *textureHolder) } // See if we're already divided before, if not, setup subSlots - if (subSlots == NULL) + if (subSlots == nullptr) { subSlots = new vector(); diff --git a/Minecraft.Client/StitchedTexture.cpp b/Minecraft.Client/StitchedTexture.cpp index 29e3e4bd7..b9693f3da 100644 --- a/Minecraft.Client/StitchedTexture.cpp +++ b/Minecraft.Client/StitchedTexture.cpp @@ -26,7 +26,7 @@ StitchedTexture *StitchedTexture::create(const wstring &name) StitchedTexture::StitchedTexture(const wstring &name, const wstring &filename) : name(name) { // 4J Initialisers - source = NULL; + source = nullptr; rotated = false; x = 0; y = 0; @@ -40,9 +40,9 @@ StitchedTexture::StitchedTexture(const wstring &name, const wstring &filename) : heightTranslation = 0.0f; frame = 0; subFrame = 0; - frameOverride = NULL; + frameOverride = nullptr; flags = 0; - frames = NULL; + frames = nullptr; m_fileName = filename; } @@ -192,7 +192,7 @@ int StitchedTexture::getSourceHeight() const void StitchedTexture::cycleFrames() { - if (frameOverride != NULL) + if (frameOverride != nullptr) { pair current = frameOverride->at(frame); subFrame++; @@ -250,10 +250,10 @@ int StitchedTexture::getFrames() */ void StitchedTexture::loadAnimationFrames(BufferedReader *bufferedReader) { - if(frameOverride != NULL) + if(frameOverride != nullptr) { delete frameOverride; - frameOverride = NULL; + frameOverride = nullptr; } frame = 0; subFrame = 0; @@ -303,10 +303,10 @@ void StitchedTexture::loadAnimationFrames(BufferedReader *bufferedReader) void StitchedTexture::loadAnimationFrames(const wstring &string) { - if(frameOverride != NULL) + if(frameOverride != nullptr) { delete frameOverride; - frameOverride = NULL; + frameOverride = nullptr; } frame = 0; subFrame = 0; diff --git a/Minecraft.Client/Stitcher.cpp b/Minecraft.Client/Stitcher.cpp index d52954c44..fa206a75c 100644 --- a/Minecraft.Client/Stitcher.cpp +++ b/Minecraft.Client/Stitcher.cpp @@ -17,7 +17,7 @@ void Stitcher::_init(const wstring &name, int maxWidth, int maxHeight, bool forc // 4J init storageX = 0; storageY = 0; - stitchedTexture = NULL; + stitchedTexture = nullptr; } Stitcher::Stitcher(const wstring &name, int maxWidth, int maxHeight, bool forcePowerOfTwo) @@ -78,7 +78,7 @@ void Stitcher::stitch() //TextureHolder[] textureHolders = texturesToBeStitched.toArray(new TextureHolder[texturesToBeStitched.size()]); //Arrays.sort(textureHolders); - stitchedTexture = NULL; + stitchedTexture = nullptr; //for (int i = 0; i < textureHolders.length; i++) for( TextureHolder *textureHolder : texturesToBeStitched ) diff --git a/Minecraft.Client/TeleportCommand.cpp b/Minecraft.Client/TeleportCommand.cpp index 2132cfd4b..0ee269cd6 100644 --- a/Minecraft.Client/TeleportCommand.cpp +++ b/Minecraft.Client/TeleportCommand.cpp @@ -29,7 +29,7 @@ void TeleportCommand::execute(shared_ptr source, byteArray comman shared_ptr subject = players->getPlayer(subjectID); shared_ptr destination = players->getPlayer(destinationID); - if(subject != NULL && destination != NULL && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() ) + if(subject != nullptr && destination != nullptr && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() ) { subject->ride(nullptr); subject->connection->teleport(destination->x, destination->y, destination->z, destination->yRot, destination->xRot); diff --git a/Minecraft.Client/TerrainParticle.cpp b/Minecraft.Client/TerrainParticle.cpp index cec8df8fb..fb29118b8 100644 --- a/Minecraft.Client/TerrainParticle.cpp +++ b/Minecraft.Client/TerrainParticle.cpp @@ -47,7 +47,7 @@ void TerrainParticle::render(Tesselator *t, float a, float xa, float ya, float z float v1 = v0 + 0.999f / 16.0f / 4; float r = 0.1f * size; - if (tex != NULL) + if (tex != nullptr) { u0 = tex->getU((uo / 4.0f) * SharedConstants::WORLD_RESOLUTION); u1 = tex->getU(((uo + 1) / 4.0f) * SharedConstants::WORLD_RESOLUTION); diff --git a/Minecraft.Client/TextEditScreen.cpp b/Minecraft.Client/TextEditScreen.cpp index 6b14ce5d1..d9804b92a 100644 --- a/Minecraft.Client/TextEditScreen.cpp +++ b/Minecraft.Client/TextEditScreen.cpp @@ -52,7 +52,7 @@ void TextEditScreen::buttonClicked(Button *button) if (button->id == 0) { sign->setChanged(); - minecraft->setScreen(NULL); + minecraft->setScreen(nullptr); } } diff --git a/Minecraft.Client/Texture.cpp b/Minecraft.Client/Texture.cpp index dd1804d7a..b7e58d5fa 100644 --- a/Minecraft.Client/Texture.cpp +++ b/Minecraft.Client/Texture.cpp @@ -24,7 +24,7 @@ Texture::Texture(const wstring &name, int mode, int width, int height, int depth void Texture::_init(const wstring &name, int mode, int width, int height, int depth, int wrapMode, int format, int minFilter, int magFilter, bool mipMap) { #ifdef __PS3__ - if(g_texBlitJobQueuePort == NULL) + if(g_texBlitJobQueuePort == nullptr) g_texBlitJobQueuePort = new C4JSpursJobQueue::Port("C4JSpursJob_Texture_blit"); #endif this->name = name; @@ -40,7 +40,7 @@ void Texture::_init(const wstring &name, int mode, int width, int height, int de m_bInitialised = false; for( int i = 0 ; i < 10; i++ ) { - data[i] = NULL; + data[i] = nullptr; } rect = new Rect2i(0, 0, width, height); @@ -105,7 +105,7 @@ void Texture::_init(const wstring &name, int mode, int width, int height, int de void Texture::_init(const wstring &name, int mode, int width, int height, int depth, int wrapMode, int format, int minFilter, int magFilter, BufferedImage *image, bool mipMap) { _init(name, mode, width, height, depth, wrapMode, format, minFilter, magFilter, mipMap); - if (image == NULL) + if (image == nullptr) { if (width == -1 || height == -1) { @@ -195,7 +195,7 @@ Texture::~Texture() for(int i = 0; i < 10; i++ ) { - if(data[i] != NULL) delete data[i]; + if(data[i] != nullptr) delete data[i]; } if(glId >= 0) @@ -258,7 +258,7 @@ void Texture::writeAsBMP(const wstring &name) outFile.delete(); } - DataOutputStream *outStream = NULL; + DataOutputStream *outStream = nullptr; //try { outStream = new DataOutputStream(new FileOutputStream(outFile)); //} catch (IOException e) { @@ -384,7 +384,7 @@ void Texture::blit(int x, int y, Texture *source, bool rotated) { ByteBuffer *srcBuffer = source->getData(level); - if(srcBuffer == NULL) break; + if(srcBuffer == nullptr) break; int yy = y >> level; int xx = x >> level; @@ -598,10 +598,10 @@ void Texture::transferFromImage(BufferedImage *image) for(int i = 0; i < 10; i++ ) { - if(data[i] != NULL) + if(data[i] != nullptr) { delete data[i]; - data[i] = NULL; + data[i] = nullptr; } } @@ -618,7 +618,7 @@ void Texture::transferFromImage(BufferedImage *image) delete [] tempBytes.data; - if(mipmapped || image->getData(1) != NULL) + if(mipmapped || image->getData(1) != nullptr) { mipmapped = true; for(unsigned int level = 1; level < MAX_MIP_LEVELS; ++level) @@ -807,7 +807,7 @@ void Texture::updateOnGPU() { for (int level = 1; level < m_iMipLevels; level++) { - if(data[level] == NULL) break; + if(data[level] == nullptr) break; data[level]->flip(); } diff --git a/Minecraft.Client/Texture.h b/Minecraft.Client/Texture.h index 09b7495e9..5dcf2b481 100644 --- a/Minecraft.Client/Texture.h +++ b/Minecraft.Client/Texture.h @@ -59,7 +59,7 @@ class Texture #ifdef __PS3__ ByteBuffer_IO *data[10]; #else - ByteBuffer *data[10]; // Arrays for mipmaps - NULL if not used + ByteBuffer *data[10]; // Arrays for mipmaps - nullptr if not used #endif public: diff --git a/Minecraft.Client/TextureManager.cpp b/Minecraft.Client/TextureManager.cpp index 542b94998..d6cbe2c33 100644 --- a/Minecraft.Client/TextureManager.cpp +++ b/Minecraft.Client/TextureManager.cpp @@ -7,7 +7,7 @@ #include "TextureManager.h" #include "..\Minecraft.World\StringHelpers.h" -TextureManager *TextureManager::instance = NULL; +TextureManager *TextureManager::instance = nullptr; void TextureManager::createInstance() { @@ -36,7 +36,7 @@ Texture *TextureManager::getTexture(const wstring &name) return idToTextureMap.find(stringToIDMap.find(name)->second)->second; } - return NULL; + return nullptr; } void TextureManager::registerName(const wstring &name, Texture *texture) @@ -136,7 +136,7 @@ vector *TextureManager::createTextures(const wstring &filename, bool for (int i = 0; i < frameCount; i++) { BufferedImage *subImage = image->getSubimage(0, frameHeight * i, frameWidth, frameHeight); - Texture *texture = createTexture(texName, mode, frameWidth, frameHeight, clamp, format, minFilter, magFilter, mipmap || image->getData(1) != NULL, subImage); + Texture *texture = createTexture(texName, mode, frameWidth, frameHeight, clamp, format, minFilter, magFilter, mipmap || image->getData(1) != nullptr, subImage); delete subImage; result->push_back(texture); } @@ -146,7 +146,7 @@ vector *TextureManager::createTextures(const wstring &filename, bool // TODO: Remove this hack -- fix proper rotation support (needed for 'off-aspect textures') if (width == height) { - result->push_back(createTexture(texName, mode, width, height, clamp, format, minFilter, magFilter, mipmap || image->getData(1) != NULL, image)); + result->push_back(createTexture(texName, mode, width, height, clamp, format, minFilter, magFilter, mipmap || image->getData(1) != nullptr, image)); } else { @@ -191,6 +191,6 @@ Texture *TextureManager::createTexture(const wstring &name, int mode, int width, Texture *TextureManager::createTexture(const wstring &name, int mode, int width, int height, int format, bool mipmap) { // 4J Stu - Don't clamp as it causes issues with how we signal non-mipmmapped textures to the pixel shader - //return createTexture(name, mode, width, height, Texture::WM_CLAMP, format, Texture::TFLT_NEAREST, Texture::TFLT_NEAREST, mipmap, NULL); - return createTexture(name, mode, width, height, Texture::WM_WRAP, format, Texture::TFLT_NEAREST, Texture::TFLT_NEAREST, mipmap, NULL); + //return createTexture(name, mode, width, height, Texture::WM_CLAMP, format, Texture::TFLT_NEAREST, Texture::TFLT_NEAREST, mipmap, nullptr); + return createTexture(name, mode, width, height, Texture::WM_WRAP, format, Texture::TFLT_NEAREST, Texture::TFLT_NEAREST, mipmap, nullptr); } \ No newline at end of file diff --git a/Minecraft.Client/TextureMap.cpp b/Minecraft.Client/TextureMap.cpp index 9aefbb637..902dc9d66 100644 --- a/Minecraft.Client/TextureMap.cpp +++ b/Minecraft.Client/TextureMap.cpp @@ -22,8 +22,8 @@ TextureMap::TextureMap(int type, const wstring &name, const wstring &path, Buffe this->missingTexture = missingTexture; // 4J Initialisers - missingPosition = NULL; - stitchResult = NULL; + missingPosition = nullptr; + stitchResult = nullptr; m_mipMap = mipmap; } @@ -37,7 +37,7 @@ void TextureMap::stitch() //for (Tile tile : Tile.tiles) for(unsigned int i = 0; i < Tile::TILE_NUM_COUNT; ++i) { - if (Tile::tiles[i] != NULL) + if (Tile::tiles[i] != nullptr) { Tile::tiles[i]->registerIcons(this); } @@ -51,7 +51,7 @@ void TextureMap::stitch() for(unsigned int i = 0; i < Item::ITEM_NUM_COUNT; ++i) { Item *item = Item::items[i]; - if (item != NULL && item->getIconType() == iconType) + if (item != nullptr && item->getIconType() == iconType) { item->registerIcons(this); } @@ -89,7 +89,7 @@ void TextureMap::stitch() // TODO: [EB] Put the frames into a proper object, not this inside out hack vector *frames = TextureManager::getInstance()->createTextures(filename, m_mipMap); - if (frames == NULL || frames->empty()) + if (frames == nullptr || frames->empty()) { continue; // Couldn't load a texture, skip it } @@ -124,7 +124,7 @@ void TextureMap::stitch() vector *frames = textures.find(textureHolder)->second; - StitchedTexture *stored = NULL; + StitchedTexture *stored = nullptr; auto itTex = texturesToRegister.find(textureName); if(itTex != texturesToRegister.end() ) stored = itTex->second; @@ -188,7 +188,7 @@ void TextureMap::stitch() StitchedTexture *TextureMap::getTexture(const wstring &name) { StitchedTexture *result = texturesByName.find(name)->second; - if (result == NULL) result = missingPosition; + if (result == nullptr) result = missingPosition; return result; } @@ -212,7 +212,7 @@ Icon *TextureMap::registerIcon(const wstring &name) { if (name.empty()) { - app.DebugPrintf("Don't register NULL\n"); + app.DebugPrintf("Don't register nullptr\n"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif @@ -220,11 +220,11 @@ Icon *TextureMap::registerIcon(const wstring &name) } // TODO: [EB]: Why do we allow multiple registrations? - StitchedTexture *result = NULL; + StitchedTexture *result = nullptr; auto it = texturesToRegister.find(name); if(it != texturesToRegister.end()) result = it->second; - if (result == NULL) + if (result == nullptr) { result = StitchedTexture::create(name); texturesToRegister.insert( stringStitchedTextureMap::value_type(name, result) ); diff --git a/Minecraft.Client/TexturePack.cpp b/Minecraft.Client/TexturePack.cpp index 7ed208ae3..bacb29516 100644 --- a/Minecraft.Client/TexturePack.cpp +++ b/Minecraft.Client/TexturePack.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "TexturePack.h" -wstring TexturePack::getPath(bool bTitleUpdateTexture /*= false*/,const char *pchBDPatchFileName /*= NULL*/) +wstring TexturePack::getPath(bool bTitleUpdateTexture /*= false*/,const char *pchBDPatchFileName /*= nullptr*/) { wstring wDrive; #ifdef _XBOX @@ -24,8 +24,8 @@ wstring TexturePack::getPath(bool bTitleUpdateTexture /*= false*/,const char *pc #ifdef __PS3__ // 4J-PB - we need to check for a BD patch - this is going to be an issue for full DLC texture packs (Halloween) - char *pchUsrDir=NULL; - if(app.GetBootedFromDiscPatch() && pchBDPatchFileName!=NULL) + char *pchUsrDir=nullptr; + if(app.GetBootedFromDiscPatch() && pchBDPatchFileName!=nullptr) { pchUsrDir = app.GetBDUsrDirPath(pchBDPatchFileName); wstring wstr (pchUsrDir, pchUsrDir+strlen(pchUsrDir)); diff --git a/Minecraft.Client/TexturePack.h b/Minecraft.Client/TexturePack.h index 23cb4f62e..8e6134233 100644 --- a/Minecraft.Client/TexturePack.h +++ b/Minecraft.Client/TexturePack.h @@ -35,11 +35,11 @@ class TexturePack */ return name; } - virtual DLCPack * getDLCPack() { return NULL;} + virtual DLCPack * getDLCPack() { return nullptr;} // 4J Added - virtual wstring getPath(bool bTitleUpdateTexture = false, const char *pchBDPatchFilename=NULL); + virtual wstring getPath(bool bTitleUpdateTexture = false, const char *pchBDPatchFilename=nullptr); virtual wstring getAnimationString(const wstring &textureName, const wstring &path, bool allowFallback) = 0; virtual BufferedImage *getImageResource(const wstring& File, bool filenameHasExtension = false, bool bTitleUpdateTexture=false, const wstring &drive =L"") = 0; virtual void loadColourTable() = 0; diff --git a/Minecraft.Client/TexturePackRepository.cpp b/Minecraft.Client/TexturePackRepository.cpp index 6bb3ccccb..92032aae0 100644 --- a/Minecraft.Client/TexturePackRepository.cpp +++ b/Minecraft.Client/TexturePackRepository.cpp @@ -9,7 +9,7 @@ #include "..\Minecraft.World\StringHelpers.h" #include "Minimap.h" -TexturePack *TexturePackRepository::DEFAULT_TEXTURE_PACK = NULL; +TexturePack *TexturePackRepository::DEFAULT_TEXTURE_PACK = nullptr; TexturePackRepository::TexturePackRepository(File workingDirectory, Minecraft *minecraft) { @@ -17,7 +17,7 @@ TexturePackRepository::TexturePackRepository(File workingDirectory, Minecraft *m // 4J - added usingWeb = false; - selected = NULL; + selected = nullptr; texturePacks = new vector; this->minecraft = minecraft; @@ -28,9 +28,9 @@ TexturePackRepository::TexturePackRepository(File workingDirectory, Minecraft *m DEFAULT_TEXTURE_PACK->loadColourTable(); - m_dummyTexturePack = NULL; - m_dummyDLCTexturePack = NULL; - lastSelected = NULL; + m_dummyTexturePack = nullptr; + m_dummyDLCTexturePack = nullptr; + lastSelected = nullptr; updateList(); } @@ -49,13 +49,13 @@ void TexturePackRepository::addDebugPacks() { DLCPack *pack = app.m_dlcManager.getPack(L"DLCTestPack"); - if( pack != NULL && pack->IsCorrupt() ) + if( pack != nullptr && pack->IsCorrupt() ) { app.m_dlcManager.removePack(pack); - pack = NULL; + pack = nullptr; } - if(pack == NULL) + if(pack == nullptr) { wprintf(L"Pack \"%ls\" is not installed, so adding it\n", L"DLCTestPack"); pack = new DLCPack(L"DLCTestPack",0xffffffff); @@ -164,7 +164,7 @@ void TexturePackRepository::updateList() currentPacks->push_back(m_dummyTexturePack); cacheById[m_dummyTexturePack->getId()] = m_dummyTexturePack; - if(m_dummyDLCTexturePack != NULL) + if(m_dummyDLCTexturePack != nullptr) { currentPacks->push_back(m_dummyDLCTexturePack); cacheById[m_dummyDLCTexturePack->getId()] = m_dummyDLCTexturePack; @@ -227,7 +227,7 @@ wstring TexturePackRepository::getIdOrNull(File file) return file.getName() + ":folder:" + file.lastModified(); } - return NULL; + return nullptr; #endif return L""; } @@ -357,17 +357,17 @@ TexturePack *TexturePackRepository::getTexturePackById(DWORD id) return it->second; } - return NULL; + return nullptr; } TexturePack *TexturePackRepository::addTexturePackFromDLC(DLCPack *dlcPack, DWORD id) { - TexturePack *newPack = NULL; + TexturePack *newPack = nullptr; // 4J-PB - The City texture pack went out with a child id for the texture pack of 1 instead of zero // we need to mask off the child id here to deal with this DWORD dwParentID=id&0xFFFFFF; // child id is <<24 and Or'd with parent - if(dlcPack != NULL) + if(dlcPack != nullptr) { newPack = new DLCTexturePack(dwParentID, dlcPack, DEFAULT_TEXTURE_PACK); texturePacks->push_back(newPack); @@ -408,7 +408,7 @@ void TexturePackRepository::removeTexturePackById(DWORD id) texturePacks->erase(it2); if(lastSelected == oldPack) { - lastSelected = NULL; + lastSelected = nullptr; } } m_texturePacksToDelete.push_back(oldPack); @@ -417,19 +417,19 @@ void TexturePackRepository::removeTexturePackById(DWORD id) void TexturePackRepository::updateUI() { - if(lastSelected != NULL && lastSelected != selected) + if(lastSelected != nullptr && lastSelected != selected) { lastSelected->unloadUI(); selected->loadUI(); Minimap::reloadColours(); ui.StartReloadSkinThread(); - lastSelected = NULL; + lastSelected = nullptr; } } bool TexturePackRepository::needsUIUpdate() { - return lastSelected != NULL && lastSelected != selected; + return lastSelected != nullptr && lastSelected != selected; } unsigned int TexturePackRepository::getTexturePackCount() @@ -439,7 +439,7 @@ unsigned int TexturePackRepository::getTexturePackCount() TexturePack *TexturePackRepository::getTexturePackByIndex(unsigned int index) { - TexturePack *pack = NULL; + TexturePack *pack = nullptr; if(index < texturePacks->size()) { pack = texturePacks->at(index); diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index e864a2f49..c724bd130 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -299,15 +299,15 @@ intArray Textures::loadTexturePixels(TEXTURE_NAME texId, const wstring& resource { intArray id = pixelsMap[resourceName]; // 4J - if resourceName isn't in the map, it should add an element and as that will use the default constructor, its - // internal data pointer will be NULL - if (id.data != NULL) return id; + // internal data pointer will be nullptr + if (id.data != nullptr) return id; } // 4J - removed try/catch // try { intArray res; //wstring in = skin->getResource(resourceName); - if (false)// 4J - removed - was ( in == NULL) + if (false)// 4J - removed - was ( in == nullptr) { res = loadTexturePixels(missingNo); } @@ -458,7 +458,7 @@ void Textures::bindTextureLayers(ResourceLocation *resource) wstring resourceName = wstring(preLoaded[textureName]) + L".png"; BufferedImage *image = readImage(textureName, resourceName); - if( image == NULL ) + if( image == nullptr ) { continue; } @@ -618,7 +618,7 @@ int Textures::loadTexture(TEXTURE_NAME texId, const wstring& resourceName) if (clamp) pathName = resourceName.substr(7); //wstring in = skins->getSelected()->getResource(pathName); - if (false ) // 4J - removed was ( in == NULL) + if (false ) // 4J - removed was ( in == nullptr) { loadTexture(missingNo, id, blur, clamp); } @@ -711,7 +711,7 @@ void Textures::loadTexture(BufferedImage *img, int id, bool blur, bool clamp) intArray rawPixels(w*h); img->getRGB(0, 0, w, h, rawPixels, 0, w); - if (options != NULL && options->anaglyph3d) + if (options != nullptr && options->anaglyph3d) { rawPixels = anaglyph(rawPixels); } @@ -877,7 +877,7 @@ void Textures::replaceTexture(intArray rawPixels, int w, int h, int id) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - if (options != NULL && options->anaglyph3d) + if (options != nullptr && options->anaglyph3d) { rawPixels = anaglyph(rawPixels); } @@ -890,7 +890,7 @@ void Textures::replaceTexture(intArray rawPixels, int w, int h, int id) int g = (rawPixels[i] >> 8) & 0xff; int b = (rawPixels[i]) & 0xff; - if (options != NULL && options->anaglyph3d) + if (options != nullptr && options->anaglyph3d) { int rr = (r * 30 + g * 59 + b * 11) / 100; int gg = (r * 30 + g * 70) / (100); @@ -1004,9 +1004,9 @@ void Textures::releaseTexture(int id) int Textures::loadHttpTexture(const wstring& url, const wstring& backup) { HttpTexture *texture = httpTextures[url]; - if (texture != NULL) + if (texture != nullptr) { - if (texture->loadedImage != NULL && !texture->isLoaded) + if (texture->loadedImage != nullptr && !texture->isLoaded) { if (texture->id < 0) { @@ -1019,7 +1019,7 @@ int Textures::loadHttpTexture(const wstring& url, const wstring& backup) texture->isLoaded = true; } } - if (texture == NULL || texture->id < 0) + if (texture == nullptr || texture->id < 0) { if (backup.empty() ) return -1; return loadTexture(TN_COUNT, backup); @@ -1030,9 +1030,9 @@ int Textures::loadHttpTexture(const wstring& url, const wstring& backup) int Textures::loadHttpTexture(const wstring& url, int backup) { HttpTexture *texture = httpTextures[url]; - if (texture != NULL) + if (texture != nullptr) { - if (texture->loadedImage != NULL && !texture->isLoaded) + if (texture->loadedImage != nullptr && !texture->isLoaded) { if (texture->id < 0) { @@ -1045,7 +1045,7 @@ int Textures::loadHttpTexture(const wstring& url, int backup) texture->isLoaded = true; } } - if (texture == NULL || texture->id < 0) + if (texture == nullptr || texture->id < 0) { return loadTexture(backup); } @@ -1060,7 +1060,7 @@ bool Textures::hasHttpTexture(const wstring &url) HttpTexture *Textures::addHttpTexture(const wstring& url, HttpTextureProcessor *processor) { HttpTexture *texture = httpTextures[url]; - if (texture == NULL) + if (texture == nullptr) { httpTextures[url] = new HttpTexture(url, processor); } @@ -1074,7 +1074,7 @@ HttpTexture *Textures::addHttpTexture(const wstring& url, HttpTextureProcessor * void Textures::removeHttpTexture(const wstring& url) { HttpTexture *texture = httpTextures[url]; - if (texture != NULL) + if (texture != nullptr) { texture->count--; if (texture->count == 0) @@ -1088,20 +1088,20 @@ void Textures::removeHttpTexture(const wstring& url) // 4J-PB - adding for texture in memory (from global title storage) int Textures::loadMemTexture(const wstring& url, const wstring& backup) { - MemTexture *texture = NULL; + MemTexture *texture = nullptr; auto it = memTextures.find(url); if (it != memTextures.end()) { texture = (*it).second; } - if(texture == NULL && app.IsFileInMemoryTextures(url)) + if(texture == nullptr && app.IsFileInMemoryTextures(url)) { // If we haven't loaded it yet, but we have the data for it then add it texture = addMemTexture(url, new MobSkinMemTextureProcessor() ); } - if(texture != NULL) + if(texture != nullptr) { - if (texture->loadedImage != NULL && !texture->isLoaded) + if (texture->loadedImage != nullptr && !texture->isLoaded) { // 4J - Disable mipmapping in general for skins & capes. Have seen problems with edge-on polys for some eg mumbo jumbo if( ( url.substr(0,7) == L"dlcskin" ) || @@ -1122,7 +1122,7 @@ int Textures::loadMemTexture(const wstring& url, const wstring& backup) MIPMAP = true; } } - if (texture == NULL || texture->id < 0) + if (texture == nullptr || texture->id < 0) { if (backup.empty() ) return -1; return loadTexture(TN_COUNT,backup); @@ -1132,21 +1132,21 @@ int Textures::loadMemTexture(const wstring& url, const wstring& backup) int Textures::loadMemTexture(const wstring& url, int backup) { - MemTexture *texture = NULL; + MemTexture *texture = nullptr; auto it = memTextures.find(url); if (it != memTextures.end()) { texture = (*it).second; } - if(texture == NULL && app.IsFileInMemoryTextures(url)) + if(texture == nullptr && app.IsFileInMemoryTextures(url)) { // If we haven't loaded it yet, but we have the data for it then add it texture = addMemTexture(url, new MobSkinMemTextureProcessor() ); } - if(texture != NULL) + if(texture != nullptr) { texture->ticksSinceLastUse = 0; - if (texture->loadedImage != NULL && !texture->isLoaded) + if (texture->loadedImage != nullptr && !texture->isLoaded) { // 4J - Disable mipmapping in general for skins & capes. Have seen problems with edge-on polys for some eg mumbo jumbo if( ( url.substr(0,7) == L"dlcskin" ) || @@ -1166,7 +1166,7 @@ int Textures::loadMemTexture(const wstring& url, int backup) MIPMAP = true; } } - if (texture == NULL || texture->id < 0) + if (texture == nullptr || texture->id < 0) { return loadTexture(backup); } @@ -1175,16 +1175,16 @@ int Textures::loadMemTexture(const wstring& url, int backup) MemTexture *Textures::addMemTexture(const wstring& name,MemTextureProcessor *processor) { - MemTexture *texture = NULL; + MemTexture *texture = nullptr; auto it = memTextures.find(name); if (it != memTextures.end()) { texture = (*it).second; } - if(texture == NULL) + if(texture == nullptr) { // can we find it in the app mem files? - PBYTE pbData=NULL; + PBYTE pbData=nullptr; DWORD dwBytes=0; app.GetMemFileDetails(name,&pbData,&dwBytes); @@ -1196,7 +1196,7 @@ MemTexture *Textures::addMemTexture(const wstring& name,MemTextureProcessor *pro else { // 4J Stu - Make an entry for this anyway and we can populate it later - memTextures[name] = NULL; + memTextures[name] = nullptr; } } else @@ -1212,7 +1212,7 @@ MemTexture *Textures::addMemTexture(const wstring& name,MemTextureProcessor *pro // MemTexture *Textures::getMemTexture(const wstring& url, MemTextureProcessor *processor) // { // MemTexture *texture = memTextures[url]; -// if (texture != NULL) +// if (texture != nullptr) // { // texture->count++; // } @@ -1221,16 +1221,16 @@ MemTexture *Textures::addMemTexture(const wstring& name,MemTextureProcessor *pro void Textures::removeMemTexture(const wstring& url) { - MemTexture *texture = NULL; + MemTexture *texture = nullptr; auto it = memTextures.find(url); if (it != memTextures.end()) { texture = (*it).second; - // If it's NULL then we should just remove the entry - if( texture == NULL ) memTextures.erase(url); + // If it's nullptr then we should just remove the entry + if( texture == nullptr ) memTextures.erase(url); } - if(texture != NULL) + if(texture != nullptr) { texture->count--; if (texture->count == 0) @@ -1380,7 +1380,7 @@ Icon *Textures::getMissingIcon(int type) BufferedImage *Textures::readImage(TEXTURE_NAME texId, const wstring& name) // 4J was InputStream *in { - BufferedImage *img=NULL; + BufferedImage *img=nullptr; MemSect(32); // is this image one of the Title Update ones? bool isTu = IsTUImage(texId, name); @@ -1534,7 +1534,7 @@ wchar_t *TUImagePaths[] = // - NULL + nullptr }; bool Textures::IsTUImage(TEXTURE_NAME texId, const wstring& name) @@ -1583,7 +1583,7 @@ wchar_t *OriginalImagesPaths[] = { L"misc/watercolor.png", - NULL + nullptr }; bool Textures::IsOriginalImage(TEXTURE_NAME texId, const wstring& name) diff --git a/Minecraft.Client/TileEntityRenderDispatcher.cpp b/Minecraft.Client/TileEntityRenderDispatcher.cpp index 887663fe1..5a1519c7f 100644 --- a/Minecraft.Client/TileEntityRenderDispatcher.cpp +++ b/Minecraft.Client/TileEntityRenderDispatcher.cpp @@ -15,7 +15,7 @@ #include "EnderChestRenderer.h" #include "BeaconRenderer.h" -TileEntityRenderDispatcher *TileEntityRenderDispatcher::instance = NULL; +TileEntityRenderDispatcher *TileEntityRenderDispatcher::instance = nullptr; double TileEntityRenderDispatcher::xOff = 0; double TileEntityRenderDispatcher::yOff = 0; double TileEntityRenderDispatcher::zOff = 0; @@ -28,9 +28,9 @@ void TileEntityRenderDispatcher::staticCtor() TileEntityRenderDispatcher::TileEntityRenderDispatcher() { // 4J -a dded - font = NULL; - textures = NULL; - level = NULL; + font = nullptr; + textures = nullptr; + level = nullptr; cameraEntity = nullptr; playerRotY = 0.0f; playerRotX = 0.0f;; @@ -45,7 +45,7 @@ TileEntityRenderDispatcher::TileEntityRenderDispatcher() renderers[eTYPE_ENCHANTMENTTABLEENTITY] = new EnchantTableRenderer(); renderers[eTYPE_THEENDPORTALTILEENTITY] = new TheEndPortalRenderer(); renderers[eTYPE_SKULLTILEENTITY] = new SkullTileRenderer(); - renderers[eTYPE_FURNACETILEENTITY] = NULL; + renderers[eTYPE_FURNACETILEENTITY] = nullptr; renderers[eTYPE_BEACONTILEENTITY] = new BeaconRenderer(); glDisable(GL_LIGHTING); @@ -57,13 +57,13 @@ TileEntityRenderDispatcher::TileEntityRenderDispatcher() TileEntityRenderer *TileEntityRenderDispatcher::getRenderer(eINSTANCEOF e) { - TileEntityRenderer *r = NULL; + TileEntityRenderer *r = nullptr; //TileEntityRenderer *r = renderers[e]; auto it = renderers.find(e); // 4J Stu - The .at and [] accessors insert elements if they don't exist if( it == renderers.end() ) { - return NULL; + return nullptr; } /* 4J - not doing this hierarchical search anymore. We need to explicitly add renderers for any eINSTANCEOF type that we want to be able to render @@ -83,12 +83,12 @@ TileEntityRenderer *TileEntityRenderDispatcher::getRenderer(eINSTANCEOF e) bool TileEntityRenderDispatcher::hasRenderer(shared_ptr e) { - return getRenderer(e) != NULL; + return getRenderer(e) != nullptr; } TileEntityRenderer *TileEntityRenderDispatcher::getRenderer(shared_ptr e) { - if (e == NULL) return NULL; + if (e == nullptr) return nullptr; return getRenderer(e->GetType()); } @@ -135,7 +135,7 @@ void TileEntityRenderDispatcher::render(shared_ptr e, float a, bool void TileEntityRenderDispatcher::render(shared_ptr entity, double x, double y, double z, float a, bool setColor/*=true*/, float alpha, bool useCompiled) { TileEntityRenderer *renderer = getRenderer(entity); - if (renderer != NULL) + if (renderer != nullptr) { renderer->render(entity, x, y, z, a, setColor, alpha, useCompiled); } diff --git a/Minecraft.Client/TileEntityRenderer.cpp b/Minecraft.Client/TileEntityRenderer.cpp index 94bdd39ce..86bfee7b2 100644 --- a/Minecraft.Client/TileEntityRenderer.cpp +++ b/Minecraft.Client/TileEntityRenderer.cpp @@ -5,13 +5,13 @@ void TileEntityRenderer::bindTexture(ResourceLocation *location) { Textures *t = tileEntityRenderDispatcher->textures; - if(t != NULL) t->bind(t->loadTexture(location->getTexture())); + if(t != nullptr) t->bind(t->loadTexture(location->getTexture())); } void TileEntityRenderer::bindTexture(const wstring& urlTexture, ResourceLocation *location) { Textures *t = tileEntityRenderDispatcher->textures; - if(t != NULL) t->bind(t->loadHttpTexture(urlTexture, location->getTexture())); + if(t != nullptr) t->bind(t->loadHttpTexture(urlTexture, location->getTexture())); } Level *TileEntityRenderer::getLevel() diff --git a/Minecraft.Client/TileRenderer.cpp b/Minecraft.Client/TileRenderer.cpp index acf6a57b6..cbc99554e 100644 --- a/Minecraft.Client/TileRenderer.cpp +++ b/Minecraft.Client/TileRenderer.cpp @@ -19,7 +19,7 @@ const float smallUV = ( 1.0f / 16.0f ); void TileRenderer::_init() { - fixedTexture = NULL; + fixedTexture = nullptr; xFlipTexture = false; noCulling = false; applyAmbienceOcclusion = false; @@ -44,7 +44,7 @@ void TileRenderer::_init() xMin = 0; yMin = 0; zMin = 0; - cache = NULL; + cache = nullptr; } bool TileRenderer::isTranslucentAt(LevelSource *level, int x, int y, int z) @@ -170,7 +170,7 @@ TileRenderer::TileRenderer( LevelSource* level ) TileRenderer::TileRenderer() { - this->level = NULL; + this->level = nullptr; _init(); } @@ -181,7 +181,7 @@ void TileRenderer::setFixedTexture( Icon *fixedTexture ) void TileRenderer::clearFixedTexture() { - this->fixedTexture = NULL; + this->fixedTexture = nullptr; } bool TileRenderer::hasFixedTexture() @@ -195,7 +195,7 @@ bool TileRenderer::hasFixedTexture() } #endif - return fixedTexture != NULL; + return fixedTexture != nullptr; } void TileRenderer::setShape(float x0, float y0, float z0, float x1, float y1, float z1) @@ -907,7 +907,7 @@ bool TileRenderer::tesselateFlowerPotInWorld(FlowerPotTile *tt, int x, int y, in float xOff = 0; float yOff = 4; float zOff = 0; - Tile *plant = NULL; + Tile *plant = nullptr; switch (type) { @@ -927,7 +927,7 @@ bool TileRenderer::tesselateFlowerPotInWorld(FlowerPotTile *tt, int x, int y, in t->addOffset(xOff / 16.0f, yOff / 16.0f, zOff / 16.0f); - if (plant != NULL) + if (plant != nullptr) { tesselateInWorld(plant, x, y, z); } @@ -1902,7 +1902,7 @@ bool TileRenderer::tesselateLeverInWorld( Tile* tt, int x, int y, int z ) } } - Vec3* c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL; + Vec3* c0 = nullptr, *c1 = nullptr, *c2 = nullptr, *c3 = nullptr; for ( int i = 0; i < 6; i++ ) { if ( i == 0 ) @@ -2073,7 +2073,7 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile *tt, int x, int y, int z) corners[i]->z += z + 0.5; } - Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL; + Vec3 *c0 = nullptr, *c1 = nullptr, *c2 = nullptr, *c3 = nullptr; int stickX0 = 7; int stickX1 = 9; int stickY0 = 9; @@ -3241,7 +3241,7 @@ bool TileRenderer::tesselateThinPaneInWorld(Tile *tt, int x, int y, int z) Icon *tex; Icon *edgeTex; - bool stained = dynamic_cast(tt) != NULL; + bool stained = dynamic_cast(tt) != nullptr; if (hasFixedTexture()) { tex = fixedTexture; @@ -5207,7 +5207,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tile* // but they also happen to draw a lot of faces, and the code for determining which texture to use is more complex than in most // cases. Optimisation here then to store a uniform texture where appropriate (could be extended beyond leaves) that will stop // any other faces being evaluated. - Icon *uniformTex = NULL; + Icon *uniformTex = nullptr; int id = tt->id; if( id == Tile::leaves_Id ) { @@ -5257,7 +5257,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tile* Tesselator* t = Tesselator::getInstance(); t->tex2( 0xf000f ); - if( uniformTex == NULL ) + if( uniformTex == nullptr ) { if ( getTexture(tt)->getFlags() == Icon::IS_GRASS_TOP ) tintSides = false; } @@ -8550,7 +8550,7 @@ Icon *TileRenderer::getTexture(Tile *tile) Icon *TileRenderer::getTextureOrMissing(Icon *icon) { - if (icon == NULL) return minecraft->textures->getMissingIcon(Icon::TYPE_TERRAIN); + if (icon == nullptr) return minecraft->textures->getMissingIcon(Icon::TYPE_TERRAIN); #ifdef __PSVITA__ // AP - alpha cut out is expensive on vita. Pass on the Alpha Cut out flag to the tesselator diff --git a/Minecraft.Client/TitleScreen.cpp b/Minecraft.Client/TitleScreen.cpp index 1c7d5125b..d522963ca 100644 --- a/Minecraft.Client/TitleScreen.cpp +++ b/Minecraft.Client/TitleScreen.cpp @@ -18,7 +18,7 @@ TitleScreen::TitleScreen() { // 4J - added initialisers vo = 0; - multiplayerButton = NULL; + multiplayerButton = nullptr; splash = L"missingno"; // try { // 4J - removed try/catch @@ -93,7 +93,7 @@ void TitleScreen::init() buttons.push_back(new Button(4, width / 2 + 2, topPos + spacing * 3 + 12, 98, 20, language->getElement(L"menu.quit"))); } - if (minecraft->user == NULL) + if (minecraft->user == nullptr) { multiplayerButton->active = false; } diff --git a/Minecraft.Client/TrackedEntity.cpp b/Minecraft.Client/TrackedEntity.cpp index 74cfbca32..386339543 100644 --- a/Minecraft.Client/TrackedEntity.cpp +++ b/Minecraft.Client/TrackedEntity.cpp @@ -63,7 +63,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl updatePlayers(tracker, players); } - if (lastRidingEntity != e->riding || (e->riding != NULL && tickCount % (SharedConstants::TICKS_PER_SECOND * 3) == 0)) + if (lastRidingEntity != e->riding || (e->riding != nullptr && tickCount % (SharedConstants::TICKS_PER_SECOND * 3) == 0)) { lastRidingEntity = e->riding; broadcast(shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, e, e->riding))); @@ -75,7 +75,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl shared_ptr frame = dynamic_pointer_cast (e); shared_ptr item = frame->getItem(); - if (item != NULL && item->getItem()->id == Item::map_Id && !e->removed) + if (item != nullptr && item->getItem()->id == Item::map_Id && !e->removed) { shared_ptr data = Item::map->getSavedData(item, e->level); for (auto& it : *players) @@ -86,7 +86,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (!player->removed && player->connection && player->connection->countDelayedPackets() <= 5) { shared_ptr packet = Item::map->getUpdatePacket(item, e->level, player); - if (packet != NULL) player->connection->send(packet); + if (packet != nullptr) player->connection->send(packet); } } } @@ -107,7 +107,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl int yRota = yRotn - yRotp; int xRota = xRotn - xRotp; - if(e->riding == NULL) + if(e->riding == nullptr) { teleportDelay++; @@ -264,7 +264,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl } - if (packet != NULL) + if (packet != nullptr) { broadcast(packet); } @@ -368,7 +368,7 @@ void TrackedEntity::broadcast(shared_ptr packet) if( sentTo.size() ) { INetworkPlayer *thisPlayer =player->connection->getNetworkPlayer(); - if( thisPlayer == NULL ) + if( thisPlayer == nullptr ) { dontSend = true; } @@ -377,7 +377,7 @@ void TrackedEntity::broadcast(shared_ptr packet) for(auto& player2 : sentTo) { INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { dontSend = true; } @@ -410,7 +410,7 @@ void TrackedEntity::broadcastAndSend(shared_ptr packet) vector< shared_ptr > sentTo; broadcast(packet); shared_ptr sp = e->instanceof(eTYPE_SERVERPLAYER) ? dynamic_pointer_cast(e) : nullptr; - if (sp != NULL && sp->connection) + if (sp != nullptr && sp->connection) { sp->connection->send(packet); } @@ -477,7 +477,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar if( ep->dimension != sp->dimension ) continue; INetworkPlayer * otherPlayer = ep->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { // 4J Stu - We call update players when the entity has moved more than a certain amount at the start of it's tick // Before this call we set xpu, ypu and zpu to the entities new position, but xp,yp and zp are the old position until later in the tick. @@ -499,7 +499,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar // 4J-JEV: ADDED! An entities mount has to be visible before the entity visible, // this is to ensure that the mount is already in the client's game when the rider is added. - if (canBeSeenBy && bVisible && e->riding != NULL) + if (canBeSeenBy && bVisible && e->riding != nullptr) { return tracker->getTracker(e->riding)->isVisible(tracker, sp, true); } @@ -530,11 +530,11 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr plr = dynamic_pointer_cast(e); app.DebugPrintf( "TrackedEntity:: Player '%ls' is now visible to player '%ls', %s.\n", plr->name.c_str(), sp->name.c_str(), - (e->riding==NULL?"not riding minecart":"in minecart") + (e->riding==nullptr?"not riding minecart":"in minecart") ); } - bool isAddMobPacket = dynamic_pointer_cast(packet) != NULL; + bool isAddMobPacket = dynamic_pointer_cast(packet) != nullptr; // 4J Stu brought forward to fix when Item Frames if (!e->getEntityData()->isEmpty() && !isAddMobPacket) @@ -560,11 +560,11 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptrconnection->send( shared_ptr( new SetEntityMotionPacket(e->entityId, e->xd, e->yd, e->zd) ) ); } - if (e->riding != NULL) + if (e->riding != nullptr) { sp->connection->send(shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, e, e->riding))); } - if ( e->instanceof(eTYPE_MOB) && dynamic_pointer_cast(e)->getLeashHolder() != NULL) + if ( e->instanceof(eTYPE_MOB) && dynamic_pointer_cast(e)->getLeashHolder() != nullptr) { sp->connection->send( shared_ptr( new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, e, dynamic_pointer_cast(e)->getLeashHolder())) ); } @@ -574,7 +574,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr item = dynamic_pointer_cast(e)->getCarried(i); - if(item != NULL) sp->connection->send( shared_ptr( new SetEquippedItemPacket(e->entityId, i, item) ) ); + if(item != nullptr) sp->connection->send( shared_ptr( new SetEquippedItemPacket(e->entityId, i, item) ) ); } } @@ -636,7 +636,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() } // 4J-PB - replacing with a switch, rather than tons of ifs - if (dynamic_pointer_cast(e) != NULL) + if (dynamic_pointer_cast(e) != nullptr) { yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); return shared_ptr( new AddMobPacket(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp) ); @@ -653,7 +653,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() PlayerUID xuid = INVALID_XUID; PlayerUID OnlineXuid = INVALID_XUID; - if( player != NULL ) + if( player != nullptr ) { xuid = player->getXuid(); OnlineXuid = player->getOnlineXuid(); @@ -678,12 +678,12 @@ shared_ptr TrackedEntity::getAddEntityPacket() else if (e->instanceof(eTYPE_FISHINGHOOK)) { shared_ptr owner = dynamic_pointer_cast(e)->owner; - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); + return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); } else if (e->instanceof(eTYPE_ARROW)) { shared_ptr owner = (dynamic_pointer_cast(e))->owner; - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); + return shared_ptr( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); } else if (e->instanceof(eTYPE_SNOWBALL)) { @@ -728,7 +728,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() shared_ptr fb = dynamic_pointer_cast(e); shared_ptr aep = nullptr; - if (fb->owner != NULL) + if (fb->owner != nullptr) { aep = shared_ptr( new AddEntityPacket(e, type, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); } diff --git a/Minecraft.Client/VideoSettingsScreen.cpp b/Minecraft.Client/VideoSettingsScreen.cpp index 2fefe9298..cc13eab29 100644 --- a/Minecraft.Client/VideoSettingsScreen.cpp +++ b/Minecraft.Client/VideoSettingsScreen.cpp @@ -46,7 +46,7 @@ void VideoSettingsScreen::init() void VideoSettingsScreen::buttonClicked(Button *button) { if (!button->active) return; - if (button->id < 100 && (dynamic_cast(button) != NULL)) + if (button->id < 100 && (dynamic_cast(button) != nullptr)) { options->toggle(static_cast(button)->getOption(), 1); button->msg = options->getMessage(Options::Option::getItem(button->id)); diff --git a/Minecraft.Client/Windows64/4JLibs/inc/4J_Input.h b/Minecraft.Client/Windows64/4JLibs/inc/4J_Input.h index 9ac5c55d1..26e88e067 100644 --- a/Minecraft.Client/Windows64/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Windows64/4JLibs/inc/4J_Input.h @@ -107,8 +107,8 @@ class C_4JInput void SetMenuDisplayed(int iPad, bool bVal); -// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); -// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); +// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); +// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=nullptr); EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); void GetText(uint16_t *UTF16String); diff --git a/Minecraft.Client/Windows64/4JLibs/inc/4J_Profile.h b/Minecraft.Client/Windows64/4JLibs/inc/4J_Profile.h index f1bd85bbe..6b9cc2890 100644 --- a/Minecraft.Client/Windows64/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/Windows64/4JLibs/inc/4J_Profile.h @@ -100,7 +100,7 @@ class C_4JProfile // ACHIEVEMENTS & AWARDS void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false, - CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L); + CXuiStringTable*pStringTable=nullptr, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=nullptr, unsigned int uiThemeSize=0L); int GetAwardId(int iAwardNumber); eAwardType GetAwardType(int iAwardNumber); bool CanBeAwarded(int iQuadrant, int iAwardNumber); diff --git a/Minecraft.Client/Windows64/4JLibs/inc/4J_Render.h b/Minecraft.Client/Windows64/4JLibs/inc/4J_Render.h index 737caa98b..fb16ccb32 100644 --- a/Minecraft.Client/Windows64/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/Windows64/4JLibs/inc/4J_Render.h @@ -16,8 +16,8 @@ class ImageFileBuffer int GetType() { return m_type; } void *GetBufferPointer() { return m_pBuffer; } int GetBufferSize() { return m_bufferSize; } - void Release() { free(m_pBuffer); m_pBuffer = NULL; } - bool Allocated() { return m_pBuffer != NULL; } + void Release() { free(m_pBuffer); m_pBuffer = nullptr; } + bool Allocated() { return m_pBuffer != nullptr; } }; typedef struct @@ -60,7 +60,7 @@ class C4JRender void StartFrame(); void DoScreenGrabOnNextPresent(); void Present(); - void Clear(int flags, D3D11_RECT *pRect = NULL); + void Clear(int flags, D3D11_RECT *pRect = nullptr); void SetClearColour(const float colourRGBA[4]); bool IsWidescreen(); bool IsHiDef(); diff --git a/Minecraft.Client/Windows64/4JLibs/inc/4J_Storage.h b/Minecraft.Client/Windows64/4JLibs/inc/4J_Storage.h index 896f730a7..07fa8fc7e 100644 --- a/Minecraft.Client/Windows64/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/Windows64/4JLibs/inc/4J_Storage.h @@ -239,7 +239,7 @@ class C4JStorage // Messages C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, - int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, C4JStringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0); + int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=nullptr,LPVOID lpParam=nullptr, C4JStringTable *pStringTable=nullptr, WCHAR *pwchFormatString=nullptr,DWORD dwFocusButton=0); C4JStorage::EMessageResult GetMessageBoxResult(); @@ -296,17 +296,17 @@ class C4JStorage C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); XCONTENT_DATA& GetDLC(DWORD dw); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive=NULL); - DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive=nullptr); + DWORD UnmountInstalledDLC(LPCSTR szMountDrive = nullptr); void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); std::string GetMountedPath(std::string szMount); // Global title storage C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType, - WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(LPVOID, WCHAR *,int, bool, int)=NULL,LPVOID lpParam=NULL, int iAction=0); + WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(LPVOID, WCHAR *,int, bool, int)=nullptr,LPVOID lpParam=nullptr, int iAction=0); bool WriteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename,BYTE *pBuffer,DWORD dwBufferSize); bool DeleteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename); - void StoreTMSPathName(WCHAR *pwchName=NULL); + void StoreTMSPathName(WCHAR *pwchName=nullptr); // TMS++ #ifdef _XBOX @@ -314,11 +314,11 @@ class C4JStorage HRESULT GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam); #endif - // C4JStorage::ETMSStatus TMSPP_WriteFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID lpParam=NULL, int iUserData=0); + // C4JStorage::ETMSStatus TMSPP_WriteFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); // C4JStorage::ETMSStatus TMSPP_GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam, int iUserData=0); - C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)=NULL,LPVOID lpParam=NULL, int iUserData=0); - // C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int iUserData=0); - // C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int iUserData=0); + C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); + // C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); + // C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=nullptr, int iUserData=0); // bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const wstring &Filename); // unsigned int CRC(unsigned char *buf, int len); diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d10_shaders.inl b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d10_shaders.inl index d4d2bb229..6ea0d142f 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d10_shaders.inl +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d10_shaders.inl @@ -1364,7 +1364,7 @@ static DWORD pshader_exceptional_blend_12[276] = { }; static ProgramWithCachedVariableLocations pshader_exceptional_blend_arr[13] = { - { NULL, 0, }, + { nullptr, 0, }, { pshader_exceptional_blend_1, 1340, }, { pshader_exceptional_blend_2, 1444, }, { pshader_exceptional_blend_3, 1424, }, @@ -2672,10 +2672,10 @@ static ProgramWithCachedVariableLocations pshader_filter_arr[32] = { { pshader_filter_9, 708, }, { pshader_filter_10, 1644, }, { pshader_filter_11, 1372, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, { pshader_filter_16, 1740, }, { pshader_filter_17, 1732, }, { pshader_filter_18, 1820, }, @@ -2688,10 +2688,10 @@ static ProgramWithCachedVariableLocations pshader_filter_arr[32] = { { pshader_filter_25, 1468, }, { pshader_filter_26, 1820, }, { pshader_filter_27, 1548, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, }; static DWORD pshader_blur_2[320] = { @@ -3193,8 +3193,8 @@ static DWORD pshader_blur_9[621] = { }; static ProgramWithCachedVariableLocations pshader_blur_arr[10] = { - { NULL, 0, }, - { NULL, 0, }, + { nullptr, 0, }, + { nullptr, 0, }, { pshader_blur_2, 1280, }, { pshader_blur_3, 1452, }, { pshader_blur_4, 1624, }, diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d11.cpp b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d11.cpp index dea9e3155..b2fb31e16 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d11.cpp +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d11.cpp @@ -64,7 +64,7 @@ static void *map_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf, bool discard) HRESULT hr = ctx->Map(buf, 0, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE, 0, &msr); if (FAILED(hr)) { report_d3d_error(hr, "Map", "of buffer"); - return NULL; + return nullptr; } else return msr.pData; } @@ -76,12 +76,12 @@ static void unmap_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf) static RADINLINE void set_pixel_shader(ID3D11DeviceContext *ctx, ID3D11PixelShader *shader) { - ctx->PSSetShader(shader, NULL, 0); + ctx->PSSetShader(shader, nullptr, 0); } static RADINLINE void set_vertex_shader(ID3D11DeviceContext *ctx, ID3D11VertexShader *shader) { - ctx->VSSetShader(shader, NULL, 0); + ctx->VSSetShader(shader, nullptr, 0); } static ID3D11BlendState *create_blend_state(ID3D11Device *dev, BOOL blend, D3D11_BLEND src, D3D11_BLEND dst) @@ -100,7 +100,7 @@ static ID3D11BlendState *create_blend_state(ID3D11Device *dev, BOOL blend, D3D11 HRESULT hr = dev->CreateBlendState(&desc, &res); if (FAILED(hr)) { report_d3d_error(hr, "CreateBlendState", ""); - res = NULL; + res = nullptr; } return res; @@ -113,10 +113,10 @@ static void create_pixel_shader(ProgramWithCachedVariableLocations *p, ProgramWi { *p = *src; if(p->bytecode) { - HRESULT hr = gdraw->d3d_device->CreatePixelShader(p->bytecode, p->size, NULL, &p->pshader); + HRESULT hr = gdraw->d3d_device->CreatePixelShader(p->bytecode, p->size, nullptr, &p->pshader); if (FAILED(hr)) { report_d3d_error(hr, "CreatePixelShader", ""); - p->pshader = NULL; + p->pshader = nullptr; return; } } @@ -126,10 +126,10 @@ static void create_vertex_shader(ProgramWithCachedVariableLocations *p, ProgramW { *p = *src; if(p->bytecode) { - HRESULT hr = gdraw->d3d_device->CreateVertexShader(p->bytecode, p->size, NULL, &p->vshader); + HRESULT hr = gdraw->d3d_device->CreateVertexShader(p->bytecode, p->size, nullptr, &p->vshader); if (FAILED(hr)) { report_d3d_error(hr, "CreateVertexShader", ""); - p->vshader = NULL; + p->vshader = nullptr; return; } } diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d11.h b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d11.h index 7fd7012fe..47fe3c29b 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d11.h +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d11.h @@ -42,7 +42,7 @@ IDOC extern GDrawFunctions * gdraw_D3D11_CreateContext(ID3D11Device *dev, ID3D11 There can only be one D3D GDraw context active at any one time. If initialization fails for some reason (the main reason would be an out of memory condition), - NULL is returned. Otherwise, you can pass the return value to IggySetGDraw. */ + nullptr is returned. Otherwise, you can pass the return value to IggySetGDraw. */ IDOC extern void gdraw_D3D11_DestroyContext(void); /* Destroys the current GDraw context, if any. */ @@ -70,7 +70,7 @@ IDOC extern void gdraw_D3D11_SetTileOrigin(ID3D11RenderTargetView *main_rt, ID3D If your rendertarget uses multisampling, you also need to specify a shader resource view for a non-MSAA rendertarget texture (identically sized to main_rt) in non_msaa_rt. This is only used if the Flash content includes non-standard - blend modes which have to use a special blend shader, so you can leave it NULL + blend modes which have to use a special blend shader, so you can leave it nullptr if you forbid such content. You need to call this before Iggy calls any rendering functions. */ diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d1x_shared.inl b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d1x_shared.inl index 6e14791c4..856e708ca 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d1x_shared.inl +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_d3d1x_shared.inl @@ -196,16 +196,16 @@ static void safe_release(T *&p) { if (p) { p->Release(); - p = NULL; + p = nullptr; } } static void report_d3d_error(HRESULT hr, char *call, char *context) { if (hr == E_OUTOFMEMORY) - IggyGDrawSendWarning(NULL, "GDraw D3D out of memory in %s%s", call, context); + IggyGDrawSendWarning(nullptr, "GDraw D3D out of memory in %s%s", call, context); else - IggyGDrawSendWarning(NULL, "GDraw D3D error in %s%s: 0x%08x", call, context, hr); + IggyGDrawSendWarning(nullptr, "GDraw D3D error in %s%s: 0x%08x", call, context, hr); } static void unbind_resources(void) @@ -215,12 +215,12 @@ static void unbind_resources(void) // unset active textures and vertex/index buffers, // to make sure there are no dangling refs static ID3D1X(ShaderResourceView) *no_views[3] = { 0 }; - ID3D1X(Buffer) *no_vb = NULL; + ID3D1X(Buffer) *no_vb = nullptr; UINT no_offs = 0; d3d->PSSetShaderResources(0, 3, no_views); d3d->IASetVertexBuffers(0, 1, &no_vb, &no_offs, &no_offs); - d3d->IASetIndexBuffer(NULL, DXGI_FORMAT_UNKNOWN, 0); + d3d->IASetIndexBuffer(nullptr, DXGI_FORMAT_UNKNOWN, 0); } static void api_free_resource(GDrawHandle *r) @@ -251,11 +251,11 @@ static void RADLINK gdraw_UnlockHandles(GDrawStats * /*stats*/) static void *start_write_dyn(DynBuffer *buf, U32 size) { - U8 *ptr = NULL; + U8 *ptr = nullptr; if (size > buf->size) { - IggyGDrawSendWarning(NULL, "GDraw dynamic vertex buffer usage of %d bytes in one call larger than buffer size %d", size, buf->size); - return NULL; + IggyGDrawSendWarning(nullptr, "GDraw dynamic vertex buffer usage of %d bytes in one call larger than buffer size %d", size, buf->size); + return nullptr; } // update statistics @@ -373,19 +373,19 @@ extern GDrawTexture *gdraw_D3D1X_(WrappedTextureCreate)(ID3D1X(ShaderResourceVie { GDrawStats stats={0}; GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats); // it may need to free one item to give us a handle - p->handle.tex.d3d = NULL; + p->handle.tex.d3d = nullptr; p->handle.tex.d3d_view = tex_view; - p->handle.tex.d3d_rtview = NULL; + p->handle.tex.d3d_rtview = nullptr; p->handle.tex.w = 1; p->handle.tex.h = 1; - gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned); + gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned); return (GDrawTexture *) p; } extern void gdraw_D3D1X_(WrappedTextureChange)(GDrawTexture *tex, ID3D1X(ShaderResourceView) *tex_view) { GDrawHandle *p = (GDrawHandle *) tex; - p->handle.tex.d3d = NULL; + p->handle.tex.d3d = nullptr; p->handle.tex.d3d_view = tex_view; } @@ -407,12 +407,12 @@ static void RADLINK gdraw_SetTextureUniqueID(GDrawTexture *tex, void *old_id, vo static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format format, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats) { - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; DXGI_FORMAT dxgi_fmt; S32 bpp, size = 0, nmips = 0; if (width >= 16384 || height >= 16384) { - IggyGDrawSendWarning(NULL, "GDraw texture size too large (%d x %d), dimension limit is 16384", width, height); + IggyGDrawSendWarning(nullptr, "GDraw texture size too large (%d x %d), dimension limit is 16384", width, height); return false; } @@ -433,7 +433,7 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, // try to allocate memory for the client to write to p->texture_data = (U8 *) IggyGDrawMalloc(size); if (!p->texture_data) { - IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); + IggyGDrawSendWarning(nullptr, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); return false; } @@ -446,9 +446,9 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, t->handle.tex.w = width; t->handle.tex.h = height; - t->handle.tex.d3d = NULL; - t->handle.tex.d3d_view = NULL; - t->handle.tex.d3d_rtview = NULL; + t->handle.tex.d3d = nullptr; + t->handle.tex.d3d_view = nullptr; + t->handle.tex.d3d_rtview = nullptr; p->texture_type = GDRAW_TEXTURE_TYPE_rgba; p->p0 = t; @@ -512,7 +512,7 @@ static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingI // and create a corresponding shader resource view failed_call = "CreateShaderResourceView"; - hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_view); + hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_view); done: if (!FAILED(hr)) { @@ -525,7 +525,7 @@ done: safe_release(t->handle.tex.d3d_view); gdraw_HandleCacheAllocateFail(t); - t = NULL; + t = nullptr; report_d3d_error(hr, failed_call, " while creating texture"); } @@ -554,8 +554,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void * /*unique_id*/ static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats) { GDrawHandle *t = (GDrawHandle *) tt; - assert(t != NULL); // @GDRAW_ASSERT - if (t->owner == unique_id || unique_id == NULL) { + assert(t != nullptr); // @GDRAW_ASSERT + if (t->owner == unique_id || unique_id == nullptr) { if (t->cache == &gdraw->rendertargets) { gdraw_HandleCacheUnlock(t); // cache it by simply not freeing it @@ -595,7 +595,7 @@ static void RADLINK gdraw_SetAntialiasTexture(S32 width, U8 *rgba) return; } - hr = gdraw->d3d_device->CreateShaderResourceView(gdraw->aa_tex, NULL, &gdraw->aa_tex_view); + hr = gdraw->d3d_device->CreateShaderResourceView(gdraw->aa_tex, nullptr, &gdraw->aa_tex_view); if (FAILED(hr)) { report_d3d_error(hr, "CreateShaderResourceView", " while creating texture"); safe_release(gdraw->aa_tex); @@ -616,8 +616,8 @@ static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat if (p->vertex_data && p->index_data) { GDrawHandle *vb = gdraw_res_alloc_begin(gdraw->vbufcache, vbuf_size + ibuf_size, stats); if (vb) { - vb->handle.vbuf.verts = NULL; - vb->handle.vbuf.inds = NULL; + vb->handle.vbuf.verts = nullptr; + vb->handle.vbuf.inds = nullptr; p->vertex_data_length = vbuf_size; p->index_data_length = ibuf_size; @@ -661,7 +661,7 @@ static GDrawVertexBuffer * RADLINK gdraw_MakeVertexBufferEnd(GDraw_MakeVertexBuf safe_release(vb->handle.vbuf.inds); gdraw_HandleCacheAllocateFail(vb); - vb = NULL; + vb = nullptr; report_d3d_error(hr, "CreateBuffer", " creating vertex buffer"); } else { @@ -682,7 +682,7 @@ static rrbool RADLINK gdraw_TryLockVertexBuffer(GDrawVertexBuffer *vb, void *uni static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) { GDrawHandle *h = (GDrawHandle *) vb; - assert(h != NULL); // @GDRAW_ASSERT + assert(h != nullptr); // @GDRAW_ASSERT if (h->owner == unique_id) gdraw_res_free(h, stats); } @@ -712,31 +712,31 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats) // ran out of RTs, allocate a new one S32 size = gdraw->frametex_width * gdraw->frametex_height * 4; if (gdraw->rendertargets.bytes_free < size) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit size limit of %d bytes", gdraw->rendertargets.total_bytes); - return NULL; + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit size limit of %d bytes", gdraw->rendertargets.total_bytes); + return nullptr; } t = gdraw_HandleCacheAllocateBegin(&gdraw->rendertargets); if (!t) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit handle limit"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit handle limit"); return t; } D3D1X_(TEXTURE2D_DESC) desc = { static_cast(gdraw->frametex_width), static_cast(gdraw->frametex_height), 1U, 1U, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_SHADER_RESOURCE) | D3D1X_(BIND_RENDER_TARGET), 0U, 0U }; - t->handle.tex.d3d = NULL; - t->handle.tex.d3d_view = NULL; - t->handle.tex.d3d_rtview = NULL; + t->handle.tex.d3d = nullptr; + t->handle.tex.d3d_view = nullptr; + t->handle.tex.d3d_rtview = nullptr; - HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &t->handle.tex.d3d); + HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, nullptr, &t->handle.tex.d3d); failed_call = "CreateTexture2D"; if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_view); + hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_view); failed_call = "CreateTexture2D"; } if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateRenderTargetView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_rtview); + hr = gdraw->d3d_device->CreateRenderTargetView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_rtview); failed_call = "CreateRenderTargetView"; } @@ -748,7 +748,7 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats) report_d3d_error(hr, failed_call, " creating rendertarget"); - return NULL; + return nullptr; } gdraw_HandleCacheAllocateEnd(t, size, (void *) 1, GDRAW_HANDLE_STATE_locked); @@ -768,10 +768,10 @@ static ID3D1X(DepthStencilView) *get_rendertarget_depthbuffer(GDrawStats *stats) D3D1X_(TEXTURE2D_DESC) desc = { static_cast(gdraw->frametex_width), static_cast(gdraw->frametex_height), 1U, 1U, DXGI_FORMAT_D24_UNORM_S8_UINT, { 1, 0 }, D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_DEPTH_STENCIL), 0U, 0U }; - HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &gdraw->rt_depth_buffer); + HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, nullptr, &gdraw->rt_depth_buffer); failed_call = "CreateTexture2D"; if (!FAILED(hr)) { - hr = gdraw->d3d_device->CreateDepthStencilView(gdraw->rt_depth_buffer, NULL, &gdraw->depth_buffer[1]); + hr = gdraw->d3d_device->CreateDepthStencilView(gdraw->rt_depth_buffer, nullptr, &gdraw->depth_buffer[1]); failed_call = "CreateDepthStencilView while creating rendertarget"; } @@ -1113,7 +1113,7 @@ static void set_render_target(GDrawStats *stats) gdraw->d3d_context->OMSetRenderTargets(1, &target, gdraw->depth_buffer[0]); gdraw->d3d_context->RSSetState(gdraw->raster_state[gdraw->main_msaa]); } else { - ID3D1X(DepthStencilView) *depth = NULL; + ID3D1X(DepthStencilView) *depth = nullptr; if (gdraw->cur->flags & (GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_id | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_stencil)) depth = get_rendertarget_depthbuffer(stats); @@ -1128,15 +1128,15 @@ static void set_render_target(GDrawStats *stats) static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_texture_format /*format*/, U32 flags, void *owner, GDrawStats *stats) { GDrawFramebufferState *n = gdraw->cur+1; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (gdraw->tw == 0 || gdraw->th == 0) { - IggyGDrawSendWarning(NULL, "GDraw warning: w=0,h=0 rendertarget"); + IggyGDrawSendWarning(nullptr, "GDraw warning: w=0,h=0 rendertarget"); return false; } if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) { assert(0); - IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH"); return false; } @@ -1150,10 +1150,10 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex n->flags = flags; n->color_buffer = t; - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT ++gdraw->cur; - gdraw->cur->cached = owner != NULL; + gdraw->cur->cached = owner != nullptr; if (owner) { gdraw->cur->base_x = region->x0; gdraw->cur->base_y = region->y0; @@ -1232,9 +1232,9 @@ static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats) assert(m >= gdraw->frame); // bug in Iggy -- unbalanced if (m != gdraw->frame) { - assert(m->color_buffer != NULL); // @GDRAW_ASSERT + assert(m->color_buffer != nullptr); // @GDRAW_ASSERT } - assert(n->color_buffer != NULL); // @GDRAW_ASSERT + assert(n->color_buffer != nullptr); // @GDRAW_ASSERT // switch back to old render target set_render_target(stats); @@ -1291,8 +1291,8 @@ static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap { ID3D1XContext *d3d = gdraw->d3d_context; - if (tex == NULL) { - ID3D1X(ShaderResourceView) *notex = NULL; + if (tex == nullptr) { + ID3D1X(ShaderResourceView) *notex = nullptr; d3d->PSSetShaderResources(texunit, 1, ¬ex); } else { GDrawHandle *h = (GDrawHandle *) tex; @@ -1303,7 +1303,7 @@ static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap static void RADLINK gdraw_Set3DTransform(F32 *mat) { - if (mat == NULL) + if (mat == nullptr) gdraw->use_3d = 0; else { gdraw->use_3d = 1; @@ -1366,9 +1366,9 @@ static int set_renderstate_full(S32 vertex_format, GDrawRenderState *r, GDrawSta // in stencil set mode, prefer not doing any shading at all // but if alpha test is on, we need to make an exception -#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do NULL PS it seems +#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do nullptr PS it seems if (which != GDRAW_TEXTURE_alpha_test) - program = NULL; + program = nullptr; else #endif { @@ -1478,7 +1478,7 @@ static int vertsize[GDRAW_vformat__basic_count] = { // Draw triangles with a given renderstate // -static void tag_resources(void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL) +static void tag_resources(void *r1, void *r2=nullptr, void *r3=nullptr, void *r4=nullptr) { U64 now = gdraw->frame_counter; if (r1) static_cast(r1)->fence.value = now; @@ -1690,7 +1690,7 @@ static void set_clamp_constant(F32 *constant, GDrawTexture *tex) static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbevel, GDrawStats *stats) { - if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, stats)) + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, nullptr, stats)) return; set_texture(0, r->tex[0], false, GDRAW_WRAP_clamp); @@ -1778,7 +1778,7 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 assert(0); } } else { - GDrawHandle *blend_tex = NULL; + GDrawHandle *blend_tex = nullptr; // for crazy blend modes, we need to read back from the framebuffer // and do the blending in the pixel shader. we do this with copies @@ -1862,18 +1862,18 @@ static void destroy_shader(ProgramWithCachedVariableLocations *p) { if (p->pshader) { p->pshader->Release(); - p->pshader = NULL; + p->pshader = nullptr; } } static ID3D1X(Buffer) *create_dynamic_buffer(U32 size, U32 bind) { D3D1X_(BUFFER_DESC) desc = { size, D3D1X_(USAGE_DYNAMIC), bind, D3D1X_(CPU_ACCESS_WRITE), 0 }; - ID3D1X(Buffer) *buf = NULL; - HRESULT hr = gdraw->d3d_device->CreateBuffer(&desc, NULL, &buf); + ID3D1X(Buffer) *buf = nullptr; + HRESULT hr = gdraw->d3d_device->CreateBuffer(&desc, nullptr, &buf); if (FAILED(hr)) { report_d3d_error(hr, "CreateBuffer", " creating dynamic vertex buffer"); - buf = NULL; + buf = nullptr; } return buf; } @@ -1910,7 +1910,7 @@ static void create_all_shaders_and_state(void) HRESULT hr = d3d->CreateInputLayout(vformats[i].desc, vformats[i].nelem, vsh->bytecode, vsh->size, &gdraw->inlayout[i]); if (FAILED(hr)) { report_d3d_error(hr, "CreateInputLayout", ""); - gdraw->inlayout[i] = NULL; + gdraw->inlayout[i] = nullptr; } } @@ -2029,11 +2029,11 @@ static void create_all_shaders_and_state(void) hr = gdraw->d3d_device->CreateBuffer(&bufdesc, &data, &gdraw->quad_ib); if (FAILED(hr)) { report_d3d_error(hr, "CreateBuffer", " for constants"); - gdraw->quad_ib = NULL; + gdraw->quad_ib = nullptr; } IggyGDrawFree(inds); } else - gdraw->quad_ib = NULL; + gdraw->quad_ib = nullptr; } static void destroy_all_shaders_and_state() @@ -2106,7 +2106,7 @@ static void free_gdraw() if (gdraw->texturecache) IggyGDrawFree(gdraw->texturecache); if (gdraw->vbufcache) IggyGDrawFree(gdraw->vbufcache); IggyGDrawFree(gdraw); - gdraw = NULL; + gdraw = nullptr; } static bool alloc_dynbuffer(U32 size) @@ -2142,7 +2142,7 @@ static bool alloc_dynbuffer(U32 size) gdraw->max_quad_vert_count = RR_MIN(size / sizeof(gswf_vertex_xyst), QUAD_IB_COUNT * 4); gdraw->max_quad_vert_count &= ~3; // must be multiple of four - return gdraw->dyn_vb.buffer != NULL && gdraw->dyn_ib.buffer != NULL; + return gdraw->dyn_vb.buffer != nullptr && gdraw->dyn_ib.buffer != nullptr; } int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S32 num_bytes) @@ -2181,7 +2181,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 IggyGDrawFree(gdraw->texturecache); } gdraw->texturecache = make_handle_cache(GDRAW_D3D1X_(RESOURCE_texture)); - return gdraw->texturecache != NULL; + return gdraw->texturecache != nullptr; case GDRAW_D3D1X_(RESOURCE_vertexbuffer): if (gdraw->vbufcache) { @@ -2189,7 +2189,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 IggyGDrawFree(gdraw->vbufcache); } gdraw->vbufcache = make_handle_cache(GDRAW_D3D1X_(RESOURCE_vertexbuffer)); - return gdraw->vbufcache != NULL; + return gdraw->vbufcache != nullptr; case GDRAW_D3D1X_(RESOURCE_dynbuffer): unbind_resources(); @@ -2205,7 +2205,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3 static GDrawFunctions *create_context(ID3D1XDevice *dev, ID3D1XContext *ctx, S32 w, S32 h) { gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw)); - if (!gdraw) return NULL; + if (!gdraw) return nullptr; memset(gdraw, 0, sizeof(*gdraw)); @@ -2220,7 +2220,7 @@ static GDrawFunctions *create_context(ID3D1XDevice *dev, ID3D1XContext *ctx, S32 if (!gdraw->texturecache || !gdraw->vbufcache || !alloc_dynbuffer(gdraw_limits[GDRAW_D3D1X_(RESOURCE_dynbuffer)].num_bytes)) { free_gdraw(); - return NULL; + return nullptr; } create_all_shaders_and_state(); @@ -2291,7 +2291,7 @@ void gdraw_D3D1X_(DestroyContext)(void) if (gdraw->texturecache) gdraw_res_flush(gdraw->texturecache, &stats); if (gdraw->vbufcache) gdraw_res_flush(gdraw->vbufcache, &stats); - gdraw->d3d_device = NULL; + gdraw->d3d_device = nullptr; } free_gdraw(); @@ -2354,7 +2354,7 @@ void RADLINK gdraw_D3D1X_(GetResourceUsageStats)(gdraw_resourcetype type, S32 *h case GDRAW_D3D1X_(RESOURCE_texture): cache = gdraw->texturecache; break; case GDRAW_D3D1X_(RESOURCE_vertexbuffer): cache = gdraw->vbufcache; break; case GDRAW_D3D1X_(RESOURCE_dynbuffer): *handles_used = 0; *bytes_used = gdraw->last_dyn_maxalloc; return; - default: cache = NULL; break; + default: cache = nullptr; break; } *handles_used = *bytes_used = 0; @@ -2411,7 +2411,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, case IFT_FORMAT_DXT3 : size=16; d3dfmt = DXGI_FORMAT_BC2_UNORM; blk = 4; break; case IFT_FORMAT_DXT5 : size=16; d3dfmt = DXGI_FORMAT_BC3_UNORM; blk = 4; break; default: { - IggyGDrawSendWarning(NULL, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format); + IggyGDrawSendWarning(nullptr, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format); goto done; } } @@ -2427,7 +2427,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, free_data = (U8 *) IggyGDrawMalloc(total_size); if (!free_data) { - IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); + IggyGDrawSendWarning(nullptr, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); goto done; } @@ -2460,7 +2460,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, if (FAILED(hr)) goto done; failed_call = "CreateShaderResourceView for texture creation"; - hr = gdraw->d3d_device->CreateShaderResourceView(tex, NULL, &view); + hr = gdraw->d3d_device->CreateShaderResourceView(tex, nullptr, &view); if (FAILED(hr)) goto done; t = gdraw_D3D1X_(WrappedTextureCreate)(view); diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_gl_shaders.inl b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_gl_shaders.inl index dc8a0484d..74a292212 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_gl_shaders.inl +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_gl_shaders.inl @@ -181,7 +181,7 @@ static char *pshader_basic_vars[] = { "color_mul", "color_add", "focal", - NULL + nullptr }; static char pshader_general2_frag0[] = @@ -293,7 +293,7 @@ static char **pshader_general2(void) static char *pshader_general2_vars[] = { "tex0", - NULL + nullptr }; static char pshader_exceptional_blend_frag0[] = @@ -414,7 +414,7 @@ static char pshader_exceptional_blend_frag13[] = #define NUMFRAGMENTS_pshader_exceptional_blend 3 static char *pshader_exceptional_blend_arr[13][NUMFRAGMENTS_pshader_exceptional_blend] = { - { NULL, NULL, NULL, }, + { nullptr, nullptr, nullptr, }, { pshader_exceptional_blend_frag0, pshader_exceptional_blend_frag1, pshader_exceptional_blend_frag2, }, { pshader_exceptional_blend_frag0, pshader_exceptional_blend_frag3, pshader_exceptional_blend_frag2, }, { pshader_exceptional_blend_frag0, pshader_exceptional_blend_frag4, pshader_exceptional_blend_frag2, }, @@ -439,7 +439,7 @@ static char *pshader_exceptional_blend_vars[] = { "tex1", "color_mul", "color_add", - NULL + nullptr }; static char pshader_filter_frag0[] = @@ -593,10 +593,10 @@ static char *pshader_filter_arr[32][NUMFRAGMENTS_pshader_filter] = { { pshader_filter_frag0, pshader_filter_frag1, pshader_filter_frag6, pshader_filter_frag1, pshader_filter_frag1, pshader_filter_frag3, pshader_filter_frag2, }, { pshader_filter_frag0, pshader_filter_frag1, pshader_filter_frag6, pshader_filter_frag1, pshader_filter_frag4, pshader_filter_frag1, pshader_filter_frag2, }, { pshader_filter_frag0, pshader_filter_frag1, pshader_filter_frag6, pshader_filter_frag1, pshader_filter_frag4, pshader_filter_frag3, pshader_filter_frag2, }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, + { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, }, + { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, }, + { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, }, + { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, }, { pshader_filter_frag0, pshader_filter_frag7, pshader_filter_frag1, pshader_filter_frag1, pshader_filter_frag1, pshader_filter_frag1, pshader_filter_frag2, }, { pshader_filter_frag0, pshader_filter_frag7, pshader_filter_frag1, pshader_filter_frag1, pshader_filter_frag1, pshader_filter_frag3, pshader_filter_frag2, }, { pshader_filter_frag0, pshader_filter_frag7, pshader_filter_frag1, pshader_filter_frag1, pshader_filter_frag4, pshader_filter_frag1, pshader_filter_frag2, }, @@ -609,10 +609,10 @@ static char *pshader_filter_arr[32][NUMFRAGMENTS_pshader_filter] = { { pshader_filter_frag0, pshader_filter_frag7, pshader_filter_frag6, pshader_filter_frag1, pshader_filter_frag1, pshader_filter_frag3, pshader_filter_frag2, }, { pshader_filter_frag0, pshader_filter_frag7, pshader_filter_frag6, pshader_filter_frag1, pshader_filter_frag4, pshader_filter_frag1, pshader_filter_frag2, }, { pshader_filter_frag0, pshader_filter_frag7, pshader_filter_frag6, pshader_filter_frag1, pshader_filter_frag4, pshader_filter_frag3, pshader_filter_frag2, }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, + { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, }, + { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, }, + { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, }, + { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, }, }; static char **pshader_filter(int bevel, int ontop, int inner, int gradient, int knockout) @@ -629,7 +629,7 @@ static char *pshader_filter_vars[] = { "clamp0", "clamp1", "color2", - NULL + nullptr }; static char pshader_blur_frag0[] = @@ -701,8 +701,8 @@ static char pshader_blur_frag9[] = #define NUMFRAGMENTS_pshader_blur 3 static char *pshader_blur_arr[10][NUMFRAGMENTS_pshader_blur] = { - { NULL, NULL, NULL, }, - { NULL, NULL, NULL, }, + { nullptr, nullptr, nullptr, }, + { nullptr, nullptr, nullptr, }, { pshader_blur_frag0, pshader_blur_frag1, pshader_blur_frag2, }, { pshader_blur_frag0, pshader_blur_frag3, pshader_blur_frag2, }, { pshader_blur_frag0, pshader_blur_frag4, pshader_blur_frag2, }, @@ -722,7 +722,7 @@ static char *pshader_blur_vars[] = { "tex0", "tap", "clampv", - NULL + nullptr }; static char pshader_color_matrix_frag0[] = @@ -804,7 +804,7 @@ static char **pshader_color_matrix(void) static char *pshader_color_matrix_vars[] = { "tex0", "data", - NULL + nullptr }; static char pshader_manual_clear_frag0[] = @@ -855,7 +855,7 @@ static char **pshader_manual_clear(void) static char *pshader_manual_clear_vars[] = { "color_mul", - NULL + nullptr }; static char vshader_vsgl_frag0[] = @@ -966,7 +966,7 @@ static char *vshader_vsgl_vars[] = { "texgen_s", "texgen_t", "viewproj", - NULL + nullptr }; static char vshader_vsglihud_frag0[] = @@ -1079,6 +1079,6 @@ static char *vshader_vsglihud_vars[] = { "worldview", "material", "textmode", - NULL + nullptr }; diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_gl_shared.inl b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_gl_shared.inl index 9916096ad..f134b7407 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_gl_shared.inl +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_gl_shared.inl @@ -60,7 +60,7 @@ static RADINLINE void break_on_err(GLint e) static void report_err(GLint e) { break_on_err(e); - IggyGDrawSendWarning(NULL, "OpenGL glGetError error"); + IggyGDrawSendWarning(nullptr, "OpenGL glGetError error"); } static void compilation_err(const char *msg) @@ -256,7 +256,7 @@ static void make_texture(GLuint tex) static void make_rendertarget(GDrawHandle *t, GLuint tex, GLenum int_type, GLenum ext_type, GLenum data_type, S32 w, S32 h, S32 size) { glBindTexture(GL_TEXTURE_2D, tex); - glTexImage2D(GL_TEXTURE_2D, 0, int_type, w, h, 0, ext_type, data_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, int_type, w, h, 0, ext_type, data_type, nullptr); make_texture(tex); glBindTexture(GL_TEXTURE_2D, 0); } @@ -309,7 +309,7 @@ extern GDrawTexture *gdraw_GLx_(WrappedTextureCreate)(S32 gl_texture_handle, S32 p->handle.tex.w = width; p->handle.tex.h = height; p->handle.tex.nonpow2 = !(is_pow2(width) && is_pow2(height)); - gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned); + gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned); return (GDrawTexture *) p; } @@ -350,7 +350,7 @@ static void RADLINK gdraw_SetTextureUniqueID(GDrawTexture *tex, void *old_id, vo static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format format, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *gstats) { S32 size=0, asize, stride; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; opengl_check(); stride = width; @@ -369,7 +369,7 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, p->texture_data = IggyGDrawMalloc(size); if (!p->texture_data) { gdraw_HandleCacheAllocateFail(t); - IggyGDrawSendWarning(NULL, "GDraw malloc for texture data failed"); + IggyGDrawSendWarning(nullptr, "GDraw malloc for texture data failed"); return false; } @@ -419,9 +419,9 @@ static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingI if (e != 0) { gdraw_HandleCacheAllocateFail(t); - IggyGDrawSendWarning(NULL, "GDraw OpenGL error creating texture"); + IggyGDrawSendWarning(nullptr, "GDraw OpenGL error creating texture"); eat_gl_err(); - return NULL; + return nullptr; } else { gdraw_HandleCacheAllocateEnd(t, p->i4, p->p1, (flags & GDRAW_MAKETEXTURE_FLAGS_never_flush) ? GDRAW_HANDLE_STATE_pinned : GDRAW_HANDLE_STATE_locked); stats->nonzero_flags |= GDRAW_STATS_alloc_tex; @@ -467,8 +467,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *tex, void *unique_id, G static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *gstats) { GDrawHandle *t = (GDrawHandle *) tt; - assert(t != NULL); - if (t->owner == unique_id || unique_id == NULL) { + assert(t != nullptr); + if (t->owner == unique_id || unique_id == nullptr) { if (t->cache == &gdraw->rendertargets) { gdraw_HandleCacheUnlock(t); // cache it by simply not freeing it @@ -516,7 +516,7 @@ static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat opengl_check(); vb = gdraw_res_alloc_begin(gdraw->vbufcache, vbuf_size + ibuf_size, gstats); if (!vb) { - IggyGDrawSendWarning(NULL, "GDraw out of vertex buffer memory"); + IggyGDrawSendWarning(nullptr, "GDraw out of vertex buffer memory"); return false; } @@ -526,9 +526,9 @@ static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat glGenBuffers(1, &vb->handle.vbuf.base); glGenBuffers(1, &vb->handle.vbuf.indices); glBindBuffer(GL_ARRAY_BUFFER, vb->handle.vbuf.base); - glBufferData(GL_ARRAY_BUFFER, vbuf_size, NULL, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, vbuf_size, nullptr, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vb->handle.vbuf.indices); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, ibuf_size, NULL, GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, ibuf_size, nullptr, GL_STATIC_DRAW); if (!e) e = glGetError(); if (e != GL_NO_ERROR) { glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -537,7 +537,7 @@ static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat glDeleteBuffers(1, &vb->handle.vbuf.indices); gdraw_HandleCacheAllocateFail(vb); eat_gl_err(); - IggyGDrawSendWarning(NULL, "GDraw OpenGL vertex buffer creation failed"); + IggyGDrawSendWarning(nullptr, "GDraw OpenGL vertex buffer creation failed"); return false; } @@ -556,7 +556,7 @@ static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat if (!p->vertex_data || !p->index_data) { if (p->vertex_data) IggyGDrawFree(p->vertex_data); if (p->index_data) IggyGDrawFree(p->index_data); - IggyGDrawSendWarning(NULL, "GDraw malloc for vertex buffer temporary memory failed"); + IggyGDrawSendWarning(nullptr, "GDraw malloc for vertex buffer temporary memory failed"); return false; } } else { @@ -602,7 +602,7 @@ static GDrawVertexBuffer * RADLINK gdraw_MakeVertexBufferEnd(GDraw_MakeVertexBuf glDeleteBuffers(1, &vb->handle.vbuf.indices); gdraw_HandleCacheAllocateFail(vb); eat_gl_err(); - return NULL; + return nullptr; } else gdraw_HandleCacheAllocateEnd(vb, p->i0 + p->i1, p->p1, GDRAW_HANDLE_STATE_locked); @@ -619,7 +619,7 @@ static rrbool RADLINK gdraw_TryToLockVertexBuffer(GDrawVertexBuffer *vb, void *u static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats) { GDrawHandle *h = (GDrawHandle *) vb; - assert(h != NULL); + assert(h != nullptr); if (h->owner == unique_id) gdraw_res_free(h, stats); } @@ -678,13 +678,13 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *gstats) // ran out of RTs, allocate a new one size = gdraw->frametex_width * gdraw->frametex_height * 4; if (gdraw->rendertargets.bytes_free < size) { - IggyGDrawSendWarning(NULL, "GDraw exceeded available rendertarget memory"); - return NULL; + IggyGDrawSendWarning(nullptr, "GDraw exceeded available rendertarget memory"); + return nullptr; } t = gdraw_HandleCacheAllocateBegin(&gdraw->rendertargets); if (!t) { - IggyGDrawSendWarning(NULL, "GDraw exceeded available rendertarget handles"); + IggyGDrawSendWarning(nullptr, "GDraw exceeded available rendertarget handles"); return t; } @@ -873,7 +873,7 @@ static void RADLINK gdraw_SetViewSizeAndWorldScale(S32 w, S32 h, F32 scalex, F32 static void RADLINK gdraw_Set3DTransform(F32 *mat) { - if (mat == NULL) + if (mat == nullptr) gdraw->use_3d = 0; else { gdraw->use_3d = 1; @@ -992,30 +992,30 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex GDrawHandle *t; int k; if (gdraw->tw == 0 || gdraw->th == 0) { - IggyGDrawSendWarning(NULL, "GDraw got a request for an empty rendertarget"); + IggyGDrawSendWarning(nullptr, "GDraw got a request for an empty rendertarget"); return false; } if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) { - IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeded MAX_RENDER_STACK_DEPTH"); + IggyGDrawSendWarning(nullptr, "GDraw rendertarget nesting exceeded MAX_RENDER_STACK_DEPTH"); return false; } if (owner) { t = get_rendertarget_texture(region->x1 - region->x0, region->y1 - region->y0, owner, gstats); if (!t) { - IggyGDrawSendWarning(NULL, "GDraw ran out of rendertargets for cacheAsBItmap"); + IggyGDrawSendWarning(nullptr, "GDraw ran out of rendertargets for cacheAsBItmap"); return false; } } else { t = get_color_rendertarget(gstats); if (!t) { - IggyGDrawSendWarning(NULL, "GDraw ran out of rendertargets"); + IggyGDrawSendWarning(nullptr, "GDraw ran out of rendertargets"); return false; } } n->color_buffer = t; - assert(n->color_buffer != NULL); + assert(n->color_buffer != nullptr); if (n == gdraw->frame+1) n->stencil_depth = get_depthstencil_renderbuffer(gstats); @@ -1023,7 +1023,7 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex n->stencil_depth = (n-1)->stencil_depth; ++gdraw->cur; - gdraw->cur->cached = owner != NULL; + gdraw->cur->cached = owner != nullptr; if (owner) { gdraw->cur->base_x = region->x0; gdraw->cur->base_y = region->y0; @@ -1161,8 +1161,8 @@ static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *gstats) assert(m >= gdraw->frame); // bug in Iggy -- unbalanced if (m != gdraw->frame) - assert(m->color_buffer != NULL); - assert(n->color_buffer != NULL); + assert(m->color_buffer != nullptr); + assert(n->color_buffer != nullptr); // remove color and stencil buffers glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 , GL_RENDERBUFFER, 0); @@ -1274,7 +1274,7 @@ static float depth_from_id(S32 id) static void set_texture(U32 texunit, GDrawTexture *tex) { glActiveTexture(GL_TEXTURE0 + texunit); - if (tex == NULL) + if (tex == nullptr) glBindTexture(GL_TEXTURE_2D, 0); else glBindTexture(GL_TEXTURE_2D, ((GDrawHandle *) tex)->handle.tex.gl); @@ -1575,7 +1575,7 @@ static void RADLINK gdraw_DrawIndexedTriangles(GDrawRenderState *r, GDrawPrimiti glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } - if (!set_render_state(r,p->vertex_format, NULL, p, gstats)) return; + if (!set_render_state(r,p->vertex_format, nullptr, p, gstats)) return; gstats->nonzero_flags |= GDRAW_STATS_batches; gstats->num_batches += 1; gstats->drawn_indices += p->num_indices; @@ -1593,7 +1593,7 @@ static void RADLINK gdraw_DrawIndexedTriangles(GDrawRenderState *r, GDrawPrimiti while (pos < p->num_vertices) { S32 vert_count = RR_MIN(p->num_vertices - pos, QUAD_IB_COUNT * 4); set_vertex_format(p->vertex_format, p->vertices + pos*stride); - glDrawElements(GL_TRIANGLES, (vert_count >> 2) * 6, GL_UNSIGNED_SHORT, NULL); + glDrawElements(GL_TRIANGLES, (vert_count >> 2) * 6, GL_UNSIGNED_SHORT, nullptr); pos += vert_count; } @@ -1719,7 +1719,7 @@ static void gdraw_DriverBlurPass(GDrawRenderState *r, int taps, F32 *data, gswf_ static void gdraw_Colormatrix(GDrawRenderState *r, gswf_recti *s, float *tc, GDrawStats *gstats) { ProgramWithCachedVariableLocations *prg = &gdraw->colormatrix; - if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, gstats)) + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, nullptr, gstats)) return; use_lazy_shader(prg); set_texture(0, r->tex[0]); @@ -1752,7 +1752,7 @@ static void set_clamp_constant(GLint constant, GDrawTexture *tex) static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbevel, GDrawStats *gstats) { ProgramWithCachedVariableLocations *prg = &gdraw->filter_prog[isbevel][r->filter_mode]; - if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, gstats)) + if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, nullptr, gstats)) return; use_lazy_shader(prg); set_texture(0, r->tex[0]); @@ -1845,7 +1845,7 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 assert(0); } } else { - GDrawTexture *blend_tex = NULL; + GDrawTexture *blend_tex = nullptr; const int *vvars; // for crazy blend modes, we need to read back from the framebuffer @@ -1864,7 +1864,7 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1 set_texture(1, blend_tex); } - if (!set_render_state(r, GDRAW_vformat_v2tc2, &vvars, NULL, gstats)) + if (!set_render_state(r, GDRAW_vformat_v2tc2, &vvars, nullptr, gstats)) return; do_screen_quad(&s, tc, vvars, gstats, 0); tag_resources(r->tex[0],r->tex[1],0); @@ -1932,7 +1932,7 @@ static void make_fragment_program(ProgramWithCachedVariableLocations *p, int num } shad = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(shad, num_strings, (const GLchar **)strings, NULL); + glShaderSource(shad, num_strings, (const GLchar **)strings, nullptr); glCompileShader(shad); glGetShaderiv(shad, GL_COMPILE_STATUS, &res); if (!res) { @@ -1994,7 +1994,7 @@ static void make_vertex_program(GLuint *vprog, int num_strings, char **strings) if(strings[0]) { shad = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(shad, num_strings, (const GLchar **)strings, NULL); + glShaderSource(shad, num_strings, (const GLchar **)strings, nullptr); glCompileShader(shad); glGetShaderiv(shad, GL_COMPILE_STATUS, &res); if (!res) { @@ -2154,7 +2154,7 @@ static void free_gdraw() if (gdraw->texturecache) IggyGDrawFree(gdraw->texturecache); if (gdraw->vbufcache) IggyGDrawFree(gdraw->vbufcache); IggyGDrawFree(gdraw); - gdraw = NULL; + gdraw = nullptr; } int gdraw_GLx_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S32 num_bytes) @@ -2193,7 +2193,7 @@ int gdraw_GLx_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S32 IggyGDrawFree(gdraw->texturecache); } gdraw->texturecache = make_handle_cache(GDRAW_GLx_(RESOURCE_texture)); - return gdraw->texturecache != NULL; + return gdraw->texturecache != nullptr; case GDRAW_GLx_(RESOURCE_vertexbuffer): if (gdraw->vbufcache) { @@ -2201,7 +2201,7 @@ int gdraw_GLx_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S32 IggyGDrawFree(gdraw->vbufcache); } gdraw->vbufcache = make_handle_cache(GDRAW_GLx_(RESOURCE_vertexbuffer)); - return gdraw->vbufcache != NULL; + return gdraw->vbufcache != nullptr; default: return 0; @@ -2220,12 +2220,12 @@ GDrawTexture * RADLINK gdraw_GLx_(MakeTextureFromResource)(U8 *resource_file, S3 while (fmt->iggyfmt != texture->format && fmt->blkbytes) fmt++; if (!fmt->blkbytes) // end of list - i.e. format not supported - return NULL; + return nullptr; // prepare texture glGenTextures(1, &gl_texture_handle); if (gl_texture_handle == 0) - return NULL; + return nullptr; opengl_check(); make_texture(gl_texture_handle); @@ -2283,7 +2283,7 @@ GDrawTexture * RADLINK gdraw_GLx_(MakeTextureFromResource)(U8 *resource_file, S3 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mips-1); tex = gdraw_GLx_(WrappedTextureCreate)(gl_texture_handle, texture->w, texture->h, mips > 1); - if (tex == NULL) + if (tex == nullptr) glDeleteTextures(1, &gl_texture_handle); opengl_check(); return tex; @@ -2301,7 +2301,7 @@ static rrbool hasext(const char *exts, const char *which) size_t len; #ifdef GDRAW_USE_glGetStringi - if (exts == NULL) { + if (exts == nullptr) { GLint i, num_exts; glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts); for (i=0; i < num_exts; ++i) @@ -2316,7 +2316,7 @@ static rrbool hasext(const char *exts, const char *which) for(;;) { where = strstr(where, which); - if (where == NULL) + if (where == nullptr) return false; if ( (where == exts || *(where - 1) == ' ') // starts with terminator @@ -2329,7 +2329,7 @@ static rrbool hasext(const char *exts, const char *which) static GDrawFunctions *create_context(S32 w, S32 h) { gdraw = IggyGDrawMalloc(sizeof(*gdraw)); - if (!gdraw) return NULL; + if (!gdraw) return nullptr; memset(gdraw, 0, sizeof(*gdraw)); @@ -2339,7 +2339,7 @@ static GDrawFunctions *create_context(S32 w, S32 h) if (!gdraw->texturecache || !gdraw->vbufcache || !make_quad_indices()) { free_gdraw(); - return NULL; + return nullptr; } opengl_check(); @@ -2380,7 +2380,7 @@ static GDrawFunctions *create_context(S32 w, S32 h) gdraw_funcs.ClearID = gdraw_ClearID; gdraw_funcs.MakeTextureBegin = gdraw_MakeTextureBegin; - gdraw_funcs.MakeTextureMore = NULL; + gdraw_funcs.MakeTextureMore = nullptr; gdraw_funcs.MakeTextureEnd = gdraw_MakeTextureEnd; gdraw_funcs.UpdateTextureRect = gdraw_UpdateTextureRect; diff --git a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_shared.inl b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_shared.inl index 11a197e67..1790de77e 100644 --- a/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_shared.inl +++ b/Minecraft.Client/Windows64/Iggy/gdraw/gdraw_shared.inl @@ -226,7 +226,7 @@ static void debug_check_raw_values(GDrawHandleCache *c) s = s->next; } s = c->active; - while (s != NULL) { + while (s != nullptr) { assert(s->raw_ptr != t->raw_ptr); s = s->next; } @@ -433,7 +433,7 @@ static rrbool gdraw_HandleCacheLockStats(GDrawHandle *t, void *owner, GDrawStats static rrbool gdraw_HandleCacheLock(GDrawHandle *t, void *owner) { - return gdraw_HandleCacheLockStats(t, owner, NULL); + return gdraw_HandleCacheLockStats(t, owner, nullptr); } static void gdraw_HandleCacheUnlock(GDrawHandle *t) @@ -461,11 +461,11 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->is_thrashing = false; c->did_defragment = false; for (i=0; i < GDRAW_HANDLE_STATE__count; i++) { - c->state[i].owner = NULL; - c->state[i].cache = NULL; // should never follow cache link from sentinels! + c->state[i].owner = nullptr; + c->state[i].cache = nullptr; // should never follow cache link from sentinels! c->state[i].next = c->state[i].prev = &c->state[i]; #ifdef GDRAW_MANAGE_MEM - c->state[i].raw_ptr = NULL; + c->state[i].raw_ptr = nullptr; #endif c->state[i].fence.value = 0; c->state[i].bytes = 0; @@ -478,7 +478,7 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->handle[i].bytes = 0; c->handle[i].state = GDRAW_HANDLE_STATE_free; #ifdef GDRAW_MANAGE_MEM - c->handle[i].raw_ptr = NULL; + c->handle[i].raw_ptr = nullptr; #endif } c->state[GDRAW_HANDLE_STATE_free].next = &c->handle[0]; @@ -486,10 +486,10 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte c->prev_frame_start.value = 0; c->prev_frame_end.value = 0; #ifdef GDRAW_MANAGE_MEM - c->alloc = NULL; + c->alloc = nullptr; #endif #ifdef GDRAW_MANAGE_MEM_TWOPOOL - c->alloc_other = NULL; + c->alloc_other = nullptr; #endif check_lists(c); } @@ -497,14 +497,14 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte static GDrawHandle *gdraw_HandleCacheAllocateBegin(GDrawHandleCache *c) { GDrawHandle *free_list = &c->state[GDRAW_HANDLE_STATE_free]; - GDrawHandle *t = NULL; + GDrawHandle *t = nullptr; if (free_list->next != free_list) { t = free_list->next; gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_alloc); t->bytes = 0; t->owner = 0; #ifdef GDRAW_MANAGE_MEM - t->raw_ptr = NULL; + t->raw_ptr = nullptr; #endif #ifdef GDRAW_CORRUPTION_CHECK t->has_check_value = false; @@ -558,7 +558,7 @@ static GDrawHandle *gdraw_HandleCacheGetLRU(GDrawHandleCache *c) // at the front of the LRU list are the oldest ones, since in-use resources // will get appended on every transition from "locked" to "live". GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_live]; - return (sentinel->next != sentinel) ? sentinel->next : NULL; + return (sentinel->next != sentinel) ? sentinel->next : nullptr; } static void gdraw_HandleCacheTick(GDrawHandleCache *c, GDrawFence now) @@ -1090,7 +1090,7 @@ static void make_pool_aligned(void **start, S32 *num_bytes, U32 alignment) if (addr_aligned != addr_orig) { S32 diff = (S32) (addr_aligned - addr_orig); if (*num_bytes < diff) { - *start = NULL; + *start = nullptr; *num_bytes = 0; return; } else { @@ -1127,7 +1127,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) UINTa remaining = arena->end - arena->current; UINTa total_size = (ptr - arena->current) + size; if (remaining < total_size) // doesn't fit - return NULL; + return nullptr; arena->current = ptr + size; return ptr; @@ -1152,7 +1152,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // (i.e. block->next->prev == block->prev->next == block) // - All allocated blocks are also kept in a hash table, indexed by their // pointer (to allow free to locate the corresponding block_info quickly). -// There's a single-linked, NULL-terminated list of elements in each hash +// There's a single-linked, nullptr-terminated list of elements in each hash // bucket. // - The physical block list is ordered. It always contains all currently // active blocks and spans the whole managed memory range. There are no @@ -1161,7 +1161,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align) // they are coalesced immediately. // - The maximum number of blocks that could ever be necessary is allocated // on initialization. All block_infos not currently in use are kept in a -// single-linked, NULL-terminated list of unused blocks. Every block is either +// single-linked, nullptr-terminated list of unused blocks. Every block is either // in the physical block list or the unused list, and the total number of // blocks is constant. // These invariants always hold before and after an allocation/free. @@ -1379,7 +1379,7 @@ static void gfxalloc_check2(gfx_allocator *alloc) static gfx_block_info *gfxalloc_pop_unused(gfx_allocator *alloc) { - GFXALLOC_ASSERT(alloc->unused_list != NULL); + GFXALLOC_ASSERT(alloc->unused_list != nullptr); GFXALLOC_ASSERT(alloc->unused_list->is_unused); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_unused);) @@ -1452,7 +1452,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma U32 i, max_blocks, size; if (!align || (align & (align - 1)) != 0) // align must be >0 and a power of 2 - return NULL; + return nullptr; // for <= max_allocs live allocs, there's <= 2*max_allocs+1 blocks. worst case: // [free][used][free] .... [free][used][free] @@ -1460,7 +1460,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma size = sizeof(gfx_allocator) + max_blocks * sizeof(gfx_block_info); a = (gfx_allocator *) IggyGDrawMalloc(size); if (!a) - return NULL; + return nullptr; memset(a, 0, size); @@ -1501,16 +1501,16 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma a->blocks[i].is_unused = 1; gfxalloc_check(a); - debug_complete_check(a, NULL, 0,0); + debug_complete_check(a, nullptr, 0,0); return a; } static void *gfxalloc_alloc(gfx_allocator *alloc, U32 size_in_bytes) { - gfx_block_info *cur, *best = NULL; + gfx_block_info *cur, *best = nullptr; U32 i, best_wasted = ~0u; U32 size = size_in_bytes; -debug_complete_check(alloc, NULL, 0,0); +debug_complete_check(alloc, nullptr, 0,0); gfxalloc_check(alloc); GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);) GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);) @@ -1560,7 +1560,7 @@ gfxalloc_check(alloc); debug_check_overlap(alloc->cache, best->ptr, best->size); return best->ptr; } else - return NULL; // not enough space! + return nullptr; // not enough space! } static void gfxalloc_free(gfx_allocator *alloc, void *ptr) @@ -1730,7 +1730,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta // (unused for allocated blocks, we'll use it to store a back-pointer to the corresponding handle) for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys) if (!b->is_free) - b->prev = NULL; + b->prev = nullptr; // go through all handles and store a pointer to the handle in the corresponding memory block for (i=0; i < c->max_handles; i++) @@ -1743,7 +1743,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta break; } - GFXALLOC_ASSERT(b != NULL); // didn't find this block anywhere! + GFXALLOC_ASSERT(b != nullptr); // didn't find this block anywhere! } // clear alloc hash table (we rebuild it during defrag) @@ -1905,7 +1905,7 @@ static rrbool gdraw_CanDefragment(GDrawHandleCache *c) static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats) { GDrawHandleCache *c = t->cache; - void *ptr = NULL; + void *ptr = nullptr; assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned); // anything we migrate should be in the "other" (old) pool @@ -2295,7 +2295,7 @@ static void gdraw_bufring_init(gdraw_bufring * RADRESTRICT ring, void *ptr, U32 static void gdraw_bufring_shutdown(gdraw_bufring * RADRESTRICT ring) { - ring->cur = NULL; + ring->cur = nullptr; ring->seg_size = 0; } @@ -2305,7 +2305,7 @@ static void *gdraw_bufring_alloc(gdraw_bufring * RADRESTRICT ring, U32 size, U32 gdraw_bufring_seg *seg; if (size > ring->seg_size) - return NULL; // nope, won't fit + return nullptr; // nope, won't fit assert(align <= ring->align); @@ -2410,7 +2410,7 @@ static rrbool gdraw_res_free_lru(GDrawHandleCache *c, GDrawStats *stats) // was it referenced since end of previous frame (=in this frame)? // if some, we're thrashing; report it to the user, but only once per frame. if (c->prev_frame_end.value < r->fence.value && !c->is_thrashing) { - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory"); c->is_thrashing = true; } @@ -2430,8 +2430,8 @@ static GDrawHandle *gdraw_res_alloc_outofmem(GDrawHandleCache *c, GDrawHandle *t { if (t) gdraw_HandleCacheAllocateFail(t); - IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); - return NULL; + IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type); + return nullptr; } #ifndef GDRAW_MANAGE_MEM @@ -2440,7 +2440,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt { GDrawHandle *t; if (size > c->total_bytes) - gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); else { // given how much data we're going to allocate, throw out // data until there's "room" (this basically lets us use @@ -2448,7 +2448,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // packing it and being exact) while (c->bytes_free < size) { if (!gdraw_res_free_lru(c, stats)) { - gdraw_res_alloc_outofmem(c, NULL, "memory"); + gdraw_res_alloc_outofmem(c, nullptr, "memory"); break; } } @@ -2463,8 +2463,8 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt // we'd trade off cost of regenerating) if (gdraw_res_free_lru(c, stats)) { t = gdraw_HandleCacheAllocateBegin(c); - if (t == NULL) { - gdraw_res_alloc_outofmem(c, NULL, "handles"); + if (t == nullptr) { + gdraw_res_alloc_outofmem(c, nullptr, "handles"); } } } @@ -2508,7 +2508,7 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) { GDRAW_FENCE_FLUSH(); // dead list is sorted by fence index - make sure all fence values are current. - r->owner = NULL; + r->owner = nullptr; gdraw_HandleCacheInsertDead(r); gdraw_res_reap(r->cache, stats); } @@ -2516,11 +2516,11 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats) static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats) { GDrawHandle *t; - void *ptr = NULL; + void *ptr = nullptr; gdraw_res_reap(c, stats); // NB this also does GDRAW_FENCE_FLUSH(); if (size > c->total_bytes) - return gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)"); + return gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)"); // now try to allocate a handle t = gdraw_HandleCacheAllocateBegin(c); @@ -2532,7 +2532,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt gdraw_res_free_lru(c, stats); t = gdraw_HandleCacheAllocateBegin(c); if (!t) - return gdraw_res_alloc_outofmem(c, NULL, "handles"); + return gdraw_res_alloc_outofmem(c, nullptr, "handles"); } // try to allocate first diff --git a/Minecraft.Client/Windows64/Iggy/include/gdraw.h b/Minecraft.Client/Windows64/Iggy/include/gdraw.h index 404a2642b..7cc4ddd0e 100644 --- a/Minecraft.Client/Windows64/Iggy/include/gdraw.h +++ b/Minecraft.Client/Windows64/Iggy/include/gdraw.h @@ -356,13 +356,13 @@ IDOC typedef struct GDrawPrimitive IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats); /* Draws a collection of indexed triangles, ignoring special filters or blend modes. - If buf is NULL, then the pointers in 'prim' are machine pointers, and + If buf is nullptr, then the pointers in 'prim' are machine pointers, and you need to make a copy of the data (note currently all triangles implementing strokes (wide lines) go this path). - If buf is non-NULL, then use the appropriate vertex buffer, and the + If buf is non-nullptr, then use the appropriate vertex buffer, and the pointers in prim are actually offsets from the beginning of the - vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL; + vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) nullptr; (note there are separate spaces for vertices and indices; e.g. the first mesh in a given vertex buffer will normally have a 0 offset for the vertices and a 0 offset for the indices) @@ -455,7 +455,7 @@ IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_Pro /* Ends specification of a new texture. $:info The same handle initially passed to $gdraw_make_texture_begin - $:return Handle for the newly created texture, or NULL if an error occured + $:return Handle for the newly created texture, or nullptr if an error occured */ IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats); diff --git a/Minecraft.Client/Windows64/Iggy/include/iggyexpruntime.h b/Minecraft.Client/Windows64/Iggy/include/iggyexpruntime.h index 1f1a90a1c..a42ccbfff 100644 --- a/Minecraft.Client/Windows64/Iggy/include/iggyexpruntime.h +++ b/Minecraft.Client/Windows64/Iggy/include/iggyexpruntime.h @@ -25,8 +25,8 @@ IDOC RADEXPFUNC HIGGYEXP RADEXPLINK IggyExpCreate(char *ip_address, S32 port, vo $:storage A small block of storage that needed to store the $HIGGYEXP, must be at least $IGGYEXP_MIN_STORAGE $:storage_size_in_bytes The size of the block pointer to by storage -Returns a NULL HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer -can be contacted at the specified address/port. Otherwise returns a non-NULL $HIGGYEXP +Returns a nullptr HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer +can be contacted at the specified address/port. Otherwise returns a non-nullptr $HIGGYEXP which you can pass to $IggyUseExplorer. */ IDOC RADEXPFUNC void RADEXPLINK IggyExpDestroy(HIGGYEXP p); diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp index d3e408065..cc4710abe 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp @@ -288,7 +288,7 @@ void KeyboardMouseInput::SetMouseGrabbed(bool grabbed) else if (!grabbed && !m_cursorHiddenForUI && g_hWnd) { while (ShowCursor(TRUE) < 0) {} - ClipCursor(NULL); + ClipCursor(nullptr); } } @@ -317,7 +317,7 @@ void KeyboardMouseInput::SetCursorHiddenForUI(bool hidden) else if (!hidden && !m_mouseGrabbed && g_hWnd) { while (ShowCursor(TRUE) < 0) {} - ClipCursor(NULL); + ClipCursor(nullptr); } } @@ -347,13 +347,13 @@ void KeyboardMouseInput::SetWindowFocused(bool focused) else { while (ShowCursor(TRUE) < 0) {} - ClipCursor(NULL); + ClipCursor(nullptr); } } else { while (ShowCursor(TRUE) < 0) {} - ClipCursor(NULL); + ClipCursor(nullptr); } } diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp index fde78e308..b1f15565b 100644 --- a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp +++ b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp @@ -11,8 +11,8 @@ SOCKET WinsockNetLayer::s_listenSocket = INVALID_SOCKET; SOCKET WinsockNetLayer::s_hostConnectionSocket = INVALID_SOCKET; -HANDLE WinsockNetLayer::s_acceptThread = NULL; -HANDLE WinsockNetLayer::s_clientRecvThread = NULL; +HANDLE WinsockNetLayer::s_acceptThread = nullptr; +HANDLE WinsockNetLayer::s_clientRecvThread = nullptr; bool WinsockNetLayer::s_isHost = false; bool WinsockNetLayer::s_connected = false; @@ -29,14 +29,14 @@ CRITICAL_SECTION WinsockNetLayer::s_connectionsLock; std::vector WinsockNetLayer::s_connections; SOCKET WinsockNetLayer::s_advertiseSock = INVALID_SOCKET; -HANDLE WinsockNetLayer::s_advertiseThread = NULL; +HANDLE WinsockNetLayer::s_advertiseThread = nullptr; volatile bool WinsockNetLayer::s_advertising = false; Win64LANBroadcast WinsockNetLayer::s_advertiseData = {}; CRITICAL_SECTION WinsockNetLayer::s_advertiseLock; int WinsockNetLayer::s_hostGamePort = WIN64_NET_DEFAULT_PORT; SOCKET WinsockNetLayer::s_discoverySock = INVALID_SOCKET; -HANDLE WinsockNetLayer::s_discoveryThread = NULL; +HANDLE WinsockNetLayer::s_discoveryThread = nullptr; volatile bool WinsockNetLayer::s_discovering = false; CRITICAL_SECTION WinsockNetLayer::s_discoveryLock; std::vector WinsockNetLayer::s_discoveredSessions; @@ -113,18 +113,18 @@ void WinsockNetLayer::Shutdown() s_connections.clear(); LeaveCriticalSection(&s_connectionsLock); - if (s_acceptThread != NULL) + if (s_acceptThread != nullptr) { WaitForSingleObject(s_acceptThread, 2000); CloseHandle(s_acceptThread); - s_acceptThread = NULL; + s_acceptThread = nullptr; } - if (s_clientRecvThread != NULL) + if (s_clientRecvThread != nullptr) { WaitForSingleObject(s_clientRecvThread, 2000); CloseHandle(s_clientRecvThread); - s_clientRecvThread = NULL; + s_clientRecvThread = nullptr; } if (s_initialized) @@ -157,22 +157,22 @@ bool WinsockNetLayer::HostGame(int port, const char* bindIp) LeaveCriticalSection(&s_freeSmallIdLock); struct addrinfo hints = {}; - struct addrinfo* result = NULL; + struct addrinfo* result = nullptr; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; - hints.ai_flags = (bindIp == NULL || bindIp[0] == 0) ? AI_PASSIVE : 0; + hints.ai_flags = (bindIp == nullptr || bindIp[0] == 0) ? AI_PASSIVE : 0; char portStr[16]; sprintf_s(portStr, "%d", port); - const char* resolvedBindIp = (bindIp != NULL && bindIp[0] != 0) ? bindIp : NULL; + const char* resolvedBindIp = (bindIp != nullptr && bindIp[0] != 0) ? bindIp : nullptr; int iResult = getaddrinfo(resolvedBindIp, portStr, &hints, &result); if (iResult != 0) { app.DebugPrintf("getaddrinfo failed for %s:%d - %d\n", - resolvedBindIp != NULL ? resolvedBindIp : "*", + resolvedBindIp != nullptr ? resolvedBindIp : "*", port, iResult); return false; @@ -211,10 +211,10 @@ bool WinsockNetLayer::HostGame(int port, const char* bindIp) s_active = true; s_connected = true; - s_acceptThread = CreateThread(NULL, 0, AcceptThreadProc, NULL, 0, NULL); + s_acceptThread = CreateThread(nullptr, 0, AcceptThreadProc, nullptr, 0, nullptr); app.DebugPrintf("Win64 LAN: Hosting on %s:%d\n", - resolvedBindIp != NULL ? resolvedBindIp : "*", + resolvedBindIp != nullptr ? resolvedBindIp : "*", port); return true; } @@ -235,7 +235,7 @@ bool WinsockNetLayer::JoinGame(const char* ip, int port) } struct addrinfo hints = {}; - struct addrinfo* result = NULL; + struct addrinfo* result = nullptr; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; @@ -306,7 +306,7 @@ bool WinsockNetLayer::JoinGame(const char* ip, int port) s_active = true; s_connected = true; - s_clientRecvThread = CreateThread(NULL, 0, ClientRecvThreadProc, NULL, 0, NULL); + s_clientRecvThread = CreateThread(nullptr, 0, ClientRecvThreadProc, nullptr, 0, nullptr); return true; } @@ -401,18 +401,18 @@ void WinsockNetLayer::HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, unsig INetworkPlayer* pPlayerFrom = g_NetworkManager.GetPlayerBySmallId(fromSmallId); INetworkPlayer* pPlayerTo = g_NetworkManager.GetPlayerBySmallId(toSmallId); - if (pPlayerFrom == NULL || pPlayerTo == NULL) return; + if (pPlayerFrom == nullptr || pPlayerTo == nullptr) return; if (s_isHost) { ::Socket* pSocket = pPlayerFrom->GetSocket(); - if (pSocket != NULL) + if (pSocket != nullptr) pSocket->pushDataToQueue(data, dataSize, false); } else { ::Socket* pSocket = pPlayerTo->GetSocket(); - if (pSocket != NULL) + if (pSocket != nullptr) pSocket->pushDataToQueue(data, dataSize, true); } } @@ -421,7 +421,7 @@ DWORD WINAPI WinsockNetLayer::AcceptThreadProc(LPVOID param) { while (s_active) { - SOCKET clientSocket = accept(s_listenSocket, NULL, NULL); + SOCKET clientSocket = accept(s_listenSocket, nullptr, nullptr); if (clientSocket == INVALID_SOCKET) { if (s_active) @@ -473,7 +473,7 @@ DWORD WINAPI WinsockNetLayer::AcceptThreadProc(LPVOID param) conn.tcpSocket = clientSocket; conn.smallId = assignedSmallId; conn.active = true; - conn.recvThread = NULL; + conn.recvThread = nullptr; EnterCriticalSection(&s_connectionsLock); s_connections.push_back(conn); @@ -492,7 +492,7 @@ DWORD WINAPI WinsockNetLayer::AcceptThreadProc(LPVOID param) DWORD* threadParam = new DWORD; *threadParam = connIdx; - HANDLE hThread = CreateThread(NULL, 0, RecvThreadProc, threadParam, 0, NULL); + HANDLE hThread = CreateThread(nullptr, 0, RecvThreadProc, threadParam, 0, nullptr); EnterCriticalSection(&s_connectionsLock); if (connIdx < static_cast(s_connections.size())) @@ -693,7 +693,7 @@ bool WinsockNetLayer::StartAdvertising(int gamePort, const wchar_t* hostName, un setsockopt(s_advertiseSock, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); s_advertising = true; - s_advertiseThread = CreateThread(NULL, 0, AdvertiseThreadProc, NULL, 0, NULL); + s_advertiseThread = CreateThread(nullptr, 0, AdvertiseThreadProc, nullptr, 0, nullptr); app.DebugPrintf("Win64 LAN: Started advertising on UDP port %d\n", WIN64_LAN_DISCOVERY_PORT); return true; @@ -709,11 +709,11 @@ void WinsockNetLayer::StopAdvertising() s_advertiseSock = INVALID_SOCKET; } - if (s_advertiseThread != NULL) + if (s_advertiseThread != nullptr) { WaitForSingleObject(s_advertiseThread, 2000); CloseHandle(s_advertiseThread); - s_advertiseThread = NULL; + s_advertiseThread = nullptr; } } @@ -792,7 +792,7 @@ bool WinsockNetLayer::StartDiscovery() setsockopt(s_discoverySock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof(timeout)); s_discovering = true; - s_discoveryThread = CreateThread(NULL, 0, DiscoveryThreadProc, NULL, 0, NULL); + s_discoveryThread = CreateThread(nullptr, 0, DiscoveryThreadProc, nullptr, 0, nullptr); app.DebugPrintf("Win64 LAN: Listening for LAN games on UDP port %d\n", WIN64_LAN_DISCOVERY_PORT); return true; @@ -808,11 +808,11 @@ void WinsockNetLayer::StopDiscovery() s_discoverySock = INVALID_SOCKET; } - if (s_discoveryThread != NULL) + if (s_discoveryThread != nullptr) { WaitForSingleObject(s_discoveryThread, 2000); CloseHandle(s_discoveryThread); - s_discoveryThread = NULL; + s_discoveryThread = nullptr; } EnterCriticalSection(&s_discoveryLock); diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.h b/Minecraft.Client/Windows64/Network/WinsockNetLayer.h index fd1280f7d..226eab2da 100644 --- a/Minecraft.Client/Windows64/Network/WinsockNetLayer.h +++ b/Minecraft.Client/Windows64/Network/WinsockNetLayer.h @@ -65,7 +65,7 @@ class WinsockNetLayer static bool Initialize(); static void Shutdown(); - static bool HostGame(int port, const char* bindIp = NULL); + static bool HostGame(int port, const char* bindIp = nullptr); static bool JoinGame(const char* ip, int port); static bool SendToSmallId(BYTE targetSmallId, const void* data, int dataSize); diff --git a/Minecraft.Client/Windows64/Windows64_App.cpp b/Minecraft.Client/Windows64/Windows64_App.cpp index 70e61f035..7c4a17313 100644 --- a/Minecraft.Client/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Windows64/Windows64_App.cpp @@ -52,8 +52,8 @@ void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize) } else { - // No capture happened (e.g. first save on world creation) leave thumbnail as NULL - if (pbData) *pbData = NULL; + // No capture happened (e.g. first save on world creation) leave thumbnail as nullptr + if (pbData) *pbData = nullptr; if (pdwSize) *pdwSize = 0; } } @@ -69,7 +69,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - app.setLevelGenerationOptions(NULL); + app.setLevelGenerationOptions(nullptr); // From CScene_Main::RunPlayGame Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -99,7 +99,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() NetworkGameInitData *param = new NetworkGameInitData(); param->seed = seedValue; - param->saveData = NULL; + param->saveData = nullptr; app.SetGameHostOption(eGameHostOption_Difficulty,0); app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); diff --git a/Minecraft.Client/Windows64/Windows64_App.h b/Minecraft.Client/Windows64/Windows64_App.h index af3192e2f..639cec739 100644 --- a/Minecraft.Client/Windows64/Windows64_App.h +++ b/Minecraft.Client/Windows64/Windows64_App.h @@ -27,7 +27,7 @@ class CConsoleMinecraftApp : public CMinecraftApp // BANNED LEVEL LIST virtual void ReadBannedList(int iPad, eTMSAction action=static_cast(0), bool bCallback=false) {} - C4JStringTable *GetStringTable() { return NULL;} + C4JStringTable *GetStringTable() { return nullptr;} // original code virtual void TemporaryCreateGameStart(); diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 7f372c6b0..343dbd129 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -120,17 +120,17 @@ static void CopyWideArgToAnsi(LPCWSTR source, char* dest, size_t destSize) return; dest[0] = 0; - if (source == NULL) + if (source == nullptr) return; - WideCharToMultiByte(CP_ACP, 0, source, -1, dest, static_cast(destSize), NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, source, -1, dest, static_cast(destSize), nullptr, nullptr); dest[destSize - 1] = 0; } // ---------- Persistent options (options.txt next to exe) ---------- static void GetOptionsFilePath(char *out, size_t outSize) { - GetModuleFileNameA(NULL, out, static_cast(outSize)); + GetModuleFileNameA(nullptr, out, static_cast(outSize)); char *p = strrchr(out, '\\'); if (p) *(p + 1) = '\0'; strncat_s(out, outSize, "options.txt", _TRUNCATE); @@ -206,7 +206,7 @@ static Win64LaunchOptions ParseLaunchOptions() int argc = 0; LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); - if (argv == NULL) + if (argv == nullptr) return options; if (argc > 1 && lstrlenW(argv[1]) == 1) @@ -248,7 +248,7 @@ static Win64LaunchOptions ParseLaunchOptions() } else if (_wcsicmp(argv[i], L"-port") == 0 && (i + 1) < argc) { - wchar_t* endPtr = NULL; + wchar_t* endPtr = nullptr; long port = wcstol(argv[++i], &endPtr, 10); if (endPtr != argv[i] && *endPtr == 0 && port > 0 && port <= 65535) { @@ -286,7 +286,7 @@ static void SetupHeadlessServerConsole() { if (AllocConsole()) { - FILE* stream = NULL; + FILE* stream = nullptr; freopen_s(&stream, "CONIN$", "r", stdin); freopen_s(&stream, "CONOUT$", "w", stdout); freopen_s(&stream, "CONOUT$", "w", stderr); @@ -487,7 +487,7 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, return pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, - NULL, + nullptr, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, pd3dPP, ppDevice ); @@ -505,16 +505,16 @@ void MemSect(int sect) } #endif -HINSTANCE g_hInst = NULL; -HWND g_hWnd = NULL; +HINSTANCE g_hInst = nullptr; +HWND g_hWnd = nullptr; D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; -ID3D11Device* g_pd3dDevice = NULL; -ID3D11DeviceContext* g_pImmediateContext = NULL; -IDXGISwapChain* g_pSwapChain = NULL; -ID3D11RenderTargetView* g_pRenderTargetView = NULL; -ID3D11DepthStencilView* g_pDepthStencilView = NULL; -ID3D11Texture2D* g_pDepthStencilBuffer = NULL; +ID3D11Device* g_pd3dDevice = nullptr; +ID3D11DeviceContext* g_pImmediateContext = nullptr; +IDXGISwapChain* g_pSwapChain = nullptr; +ID3D11RenderTargetView* g_pRenderTargetView = nullptr; +ID3D11DepthStencilView* g_pDepthStencilView = nullptr; +ID3D11Texture2D* g_pDepthStencilBuffer = nullptr; // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) @@ -633,7 +633,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_INPUT: { UINT dwSize = 0; - GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)); + GetRawInputData((HRAWINPUT)lParam, RID_INPUT, nullptr, &dwSize, sizeof(RAWINPUTHEADER)); if (dwSize > 0 && dwSize <= 256) { BYTE rawBuffer[256]; @@ -676,7 +676,7 @@ ATOM MyRegisterClass(HINSTANCE hInstance) wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, "Minecraft"); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = "Minecraft"; wcex.lpszClassName = "MinecraftClass"; @@ -709,10 +709,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) 0, wr.right - wr.left, // width of the window wr.bottom - wr.top, // height of the window - NULL, - NULL, + nullptr, + nullptr, hInstance, - NULL); + nullptr); if (!g_hWnd) { @@ -827,7 +827,7 @@ HRESULT InitDevice() for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) { g_driverType = driverTypes[driverTypeIndex]; - hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, + hr = D3D11CreateDeviceAndSwapChain( nullptr, g_driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext ); if( HRESULT_SUCCEEDED( hr ) ) break; @@ -836,7 +836,7 @@ HRESULT InitDevice() return hr; // Create a render target view - ID3D11Texture2D* pBackBuffer = NULL; + ID3D11Texture2D* pBackBuffer = nullptr; hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer ); if( FAILED( hr ) ) return hr; @@ -856,7 +856,7 @@ HRESULT InitDevice() descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; descDepth.CPUAccessFlags = 0; descDepth.MiscFlags = 0; - hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); + hr = g_pd3dDevice->CreateTexture2D(&descDepth, nullptr, &g_pDepthStencilBuffer); D3D11_DEPTH_STENCIL_VIEW_DESC descDSView; ZeroMemory(&descDSView, sizeof(descDSView)); @@ -866,7 +866,7 @@ HRESULT InitDevice() hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); - hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView ); + hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, nullptr, &g_pRenderTargetView ); pBackBuffer->Release(); if( FAILED( hr ) ) return hr; @@ -926,7 +926,7 @@ void ToggleFullscreen() { SetWindowLong(g_hWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW); SetWindowPlacement(g_hWnd, &g_wpPrev); - SetWindowPos(g_hWnd, NULL, 0, 0, 0, 0, + SetWindowPos(g_hWnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); } g_isFullscreen = !g_isFullscreen; @@ -1001,8 +1001,8 @@ static Minecraft* InitialiseMinecraftRuntime() Minecraft::main(); Minecraft* pMinecraft = Minecraft::GetInstance(); - if (pMinecraft == NULL) - return NULL; + if (pMinecraft == nullptr) + return nullptr; app.InitGameSettings(); app.InitialiseTips(); @@ -1034,7 +1034,7 @@ static int HeadlessServerConsoleThreadProc(void* lpParameter) continue; MinecraftServer* server = MinecraftServer::getInstance(); - if (server != NULL) + if (server != nullptr) { server->handleConsoleInput(command, server); } @@ -1066,7 +1066,7 @@ static int RunHeadlessServer() fflush(stdout); Minecraft* pMinecraft = InitialiseMinecraftRuntime(); - if (pMinecraft == NULL) + if (pMinecraft == nullptr) { fprintf(stderr, "Failed to initialise the Minecraft runtime.\n"); return 1; @@ -1132,13 +1132,13 @@ static int RunHeadlessServer() printf("Type 'help' for server commands.\n"); fflush(stdout); - C4JThread* consoleThread = new C4JThread(&HeadlessServerConsoleThreadProc, NULL, "Server console", 128 * 1024); + C4JThread* consoleThread = new C4JThread(&HeadlessServerConsoleThreadProc, nullptr, "Server console", 128 * 1024); consoleThread->Run(); MSG msg = { 0 }; while (WM_QUIT != msg.message && !app.m_bShutdown && !MinecraftServer::serverHalted()) { - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); @@ -1176,7 +1176,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // 4J-Win64: set CWD to exe dir so asset paths resolve correctly { char szExeDir[MAX_PATH] = {}; - GetModuleFileNameA(NULL, szExeDir, MAX_PATH); + GetModuleFileNameA(nullptr, szExeDir, MAX_PATH); char *pSlash = strrchr(szExeDir, '\\'); if (pSlash) { *(pSlash + 1) = '\0'; SetCurrentDirectoryA(szExeDir); } } @@ -1188,7 +1188,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // Load username from username.txt char exePath[MAX_PATH] = {}; - GetModuleFileNameA(NULL, exePath, MAX_PATH); + GetModuleFileNameA(nullptr, exePath, MAX_PATH); char *lastSlash = strrchr(exePath, '\\'); if (lastSlash) { @@ -1272,7 +1272,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, MSG msg = {0}; while( WM_QUIT != msg.message ) { - if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) + if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); @@ -1320,7 +1320,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, #endif Minecraft *pMinecraft = InitialiseMinecraftRuntime(); - if (pMinecraft == NULL) + if (pMinecraft == nullptr) { CleanupDevice(); return 1; @@ -1356,7 +1356,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, { g_KBMInput.Tick(); - while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) + while( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); @@ -1451,7 +1451,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true,false); IntCache::Reset(); @@ -1545,7 +1545,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // Update mouse grab: grab when in-game and no menu is open { static bool altToggleSuppressCapture = false; - bool shouldCapture = app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL; + bool shouldCapture = app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == nullptr; // Left Alt key toggles capture on/off for debugging if (g_KBMInput.IsKeyPressed(VK_LMENU) || g_KBMInput.IsKeyPressed(VK_RMENU)) { diff --git a/Minecraft.Client/Windows64/Windows64_UIController.cpp b/Minecraft.Client/Windows64/Windows64_UIController.cpp index b76b724a2..e251793ba 100644 --- a/Minecraft.Client/Windows64/Windows64_UIController.cpp +++ b/Minecraft.Client/Windows64/Windows64_UIController.cpp @@ -82,7 +82,7 @@ void ConsoleUIController::render() example, no resolve targets are required. */ gdraw_D3D11_SetTileOrigin( m_pRenderTargetView, m_pDepthStencilView, - NULL, + nullptr, 0, 0 ); @@ -147,7 +147,7 @@ void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) { gdraw_D3D11_SetTileOrigin( m_pRenderTargetView, m_pDepthStencilView, - NULL, + nullptr, xPos, yPos ); } diff --git a/Minecraft.Client/Windows64/XML/ATGXmlParser.h b/Minecraft.Client/Windows64/XML/ATGXmlParser.h index 75142e3e3..12f597372 100644 --- a/Minecraft.Client/Windows64/XML/ATGXmlParser.h +++ b/Minecraft.Client/Windows64/XML/ATGXmlParser.h @@ -138,7 +138,7 @@ class XMLParser DWORD m_dwCharsTotal; DWORD m_dwCharsConsumed; - BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing NULL + BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing nullptr WCHAR m_pWriteBuf[ XML_WRITE_BUFFER_SIZE ]; BYTE* m_pReadPtr; diff --git a/Minecraft.Client/WitchRenderer.cpp b/Minecraft.Client/WitchRenderer.cpp index 5e0f2b103..ec2b8a76f 100644 --- a/Minecraft.Client/WitchRenderer.cpp +++ b/Minecraft.Client/WitchRenderer.cpp @@ -18,7 +18,7 @@ void WitchRenderer::render(shared_ptr entity, double x, double y, double shared_ptr item = mob->getCarriedItem(); - witchModel->holdingItem = item != NULL; + witchModel->holdingItem = item != nullptr; MobRenderer::render(mob, x, y, z, rot, a); } @@ -38,7 +38,7 @@ void WitchRenderer::additionalRendering(shared_ptr entity, float a shared_ptr item = mob->getCarriedItem(); - if (item != NULL) + if (item != nullptr) { glPushMatrix(); diff --git a/Minecraft.Client/Xbox/4JLibs/inc/4J_Input.h b/Minecraft.Client/Xbox/4JLibs/inc/4J_Input.h index 120e9c7b5..6d504b63e 100644 --- a/Minecraft.Client/Xbox/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Xbox/4JLibs/inc/4J_Input.h @@ -98,8 +98,8 @@ class C_4JInput void SetMenuDisplayed(int iPad, bool bVal); - EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,CXuiStringTable *pStringTable=NULL); - EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,CXuiStringTable *pStringTable=NULL); + EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,CXuiStringTable *pStringTable=nullptr); + EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,CXuiStringTable *pStringTable=nullptr); // Online check strings against offensive list - TCR 92 // TCR # 092 CMTV Player Text String Verification diff --git a/Minecraft.Client/Xbox/4JLibs/inc/4J_Profile.h b/Minecraft.Client/Xbox/4JLibs/inc/4J_Profile.h index 28e717e8d..524d94173 100644 --- a/Minecraft.Client/Xbox/4JLibs/inc/4J_Profile.h +++ b/Minecraft.Client/Xbox/4JLibs/inc/4J_Profile.h @@ -96,7 +96,7 @@ class C_4JProfile // ACHIEVEMENTS & AWARDS void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false, - CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L); + CXuiStringTable*pStringTable=nullptr, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=nullptr, unsigned int uiThemeSize=0L); int GetAwardId(int iAwardNumber); eAwardType GetAwardType(int iAwardNumber); bool CanBeAwarded(int iQuadrant, int iAwardNumber); diff --git a/Minecraft.Client/Xbox/4JLibs/inc/4J_Render.h b/Minecraft.Client/Xbox/4JLibs/inc/4J_Render.h index 5f113d5d7..613486f0c 100644 --- a/Minecraft.Client/Xbox/4JLibs/inc/4J_Render.h +++ b/Minecraft.Client/Xbox/4JLibs/inc/4J_Render.h @@ -116,7 +116,7 @@ class C4JRender void Initialise(IDirect3DDevice9 *pDevice); void InitialiseContext(); void Present(); - void Clear(int flags, D3DRECT *pRect = NULL); + void Clear(int flags, D3DRECT *pRect = nullptr); void SetClearColour(D3DCOLOR colour); bool IsWidescreen(); bool IsHiDef(); diff --git a/Minecraft.Client/Xbox/4JLibs/inc/4J_Storage.h b/Minecraft.Client/Xbox/4JLibs/inc/4J_Storage.h index 2988dc2c1..2a50e8dbe 100644 --- a/Minecraft.Client/Xbox/4JLibs/inc/4J_Storage.h +++ b/Minecraft.Client/Xbox/4JLibs/inc/4J_Storage.h @@ -217,7 +217,7 @@ class C4JStorage // Messages C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, - int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, CXuiStringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0); + int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=nullptr,LPVOID lpParam=nullptr, CXuiStringTable *pStringTable=nullptr, WCHAR *pwchFormatString=nullptr,DWORD dwFocusButton=0); void CancelMessageBoxRequest(); C4JStorage::EMessageResult GetMessageBoxResult(); @@ -239,7 +239,7 @@ class C4JStorage unsigned int GetSaveSize(); void GetSaveData(void *pvData,unsigned int *puiBytes); PVOID AllocateSaveData(unsigned int uiBytes); - void SaveSaveData(unsigned int uiBytes,PBYTE pbThumbnail=NULL,DWORD cbThumbnail=0,PBYTE pbTextData=NULL, DWORD dwTextLen=0); + void SaveSaveData(unsigned int uiBytes,PBYTE pbThumbnail=nullptr,DWORD cbThumbnail=0,PBYTE pbTextData=nullptr, DWORD dwTextLen=0); void CopySaveDataToNewSave(PBYTE pbThumbnail,DWORD cbThumbnail,WCHAR *wchNewName,int ( *Func)(LPVOID lpParam, bool), LPVOID lpParam); void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected); bool GetSaveDeviceSelected(unsigned int iPad); @@ -271,27 +271,27 @@ class C4JStorage C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); XCONTENT_DATA& GetDLC(DWORD dw); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive=NULL); - DWORD UnmountInstalledDLC(LPCSTR szMountDrive=NULL); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive=nullptr); + DWORD UnmountInstalledDLC(LPCSTR szMountDrive=nullptr); // Global title storage C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType, - WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(LPVOID, WCHAR *,int, bool, int)=NULL,LPVOID lpParam=NULL, int iAction=0); + WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(LPVOID, WCHAR *,int, bool, int)=nullptr,LPVOID lpParam=nullptr, int iAction=0); bool WriteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename,BYTE *pBuffer,DWORD dwBufferSize); bool DeleteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename); - void StoreTMSPathName(WCHAR *pwchName=NULL); + void StoreTMSPathName(WCHAR *pwchName=nullptr); // TMS++ - C4JStorage::ETMSStatus TMSPP_WriteFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID lpParam=NULL, int iUserData=0); + C4JStorage::ETMSStatus TMSPP_WriteFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); C4JStorage::ETMSStatus TMSPP_GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam, int iUserData=0); - C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)=NULL,LPVOID lpParam=NULL, int iUserData=0); - C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int iUserData=0); - C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int iUserData=0); + C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); + C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=nullptr,LPVOID lpParam=nullptr, int iUserData=0); + C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=nullptr, int iUserData=0); bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const wstring &Filename); unsigned int CRC(unsigned char *buf, int len); - C4JStorage::ETMSStatus TMSPP_WriteFileWithProgress(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID lpParam=NULL, int iUserData=0, - int( *CompletionFunc)(LPVOID,float fComplete)=NULL,LPVOID lpCompletionParam=NULL); + C4JStorage::ETMSStatus TMSPP_WriteFileWithProgress(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=nullptr,LPVOID lpParam=nullptr, int iUserData=0, + int( *CompletionFunc)(LPVOID,float fComplete)=nullptr,LPVOID lpCompletionParam=nullptr); void TMSPP_CancelWriteFileWithProgress(int iPad); HRESULT TMSPP_SetTitleGroupID(LPCSTR szGroupID); diff --git a/Minecraft.Client/Xbox/Audio/SoundEngine.cpp b/Minecraft.Client/Xbox/Audio/SoundEngine.cpp index 97eb0658e..9ba0e4dd8 100644 --- a/Minecraft.Client/Xbox/Audio/SoundEngine.cpp +++ b/Minecraft.Client/Xbox/Audio/SoundEngine.cpp @@ -12,16 +12,16 @@ #include "..\..\DLCTexturePack.h" -IXAudio2* g_pXAudio2 = NULL; // pointer to XAudio2 instance used by QNet and XACT -IXAudio2MasteringVoice* g_pXAudio2MasteringVoice = NULL; // pointer to XAudio2 mastering voice - -IXACT3Engine *SoundEngine::m_pXACT3Engine = NULL; -IXACT3WaveBank *SoundEngine::m_pWaveBank = NULL; -IXACT3WaveBank *SoundEngine::m_pWaveBank2 = NULL; -IXACT3WaveBank *SoundEngine::m_pStreamedWaveBank = NULL; -IXACT3WaveBank *SoundEngine::m_pStreamedWaveBankAdditional = NULL; -IXACT3SoundBank *SoundEngine::m_pSoundBank = NULL; -IXACT3SoundBank *SoundEngine::m_pSoundBank2 = NULL; +IXAudio2* g_pXAudio2 = nullptr; // pointer to XAudio2 instance used by QNet and XACT +IXAudio2MasteringVoice* g_pXAudio2MasteringVoice = nullptr; // pointer to XAudio2 mastering voice + +IXACT3Engine *SoundEngine::m_pXACT3Engine = nullptr; +IXACT3WaveBank *SoundEngine::m_pWaveBank = nullptr; +IXACT3WaveBank *SoundEngine::m_pWaveBank2 = nullptr; +IXACT3WaveBank *SoundEngine::m_pStreamedWaveBank = nullptr; +IXACT3WaveBank *SoundEngine::m_pStreamedWaveBankAdditional = nullptr; +IXACT3SoundBank *SoundEngine::m_pSoundBank = nullptr; +IXACT3SoundBank *SoundEngine::m_pSoundBank2 = nullptr; CRITICAL_SECTION SoundEngine::m_CS; X3DAUDIO_HANDLE SoundEngine::m_xact3dInstance; @@ -97,9 +97,9 @@ void SoundEngine::init(Options *pOptions) // 4J-PB - move this to the title update, since we've corrected it to allow sounds to be pitch varied when they weren't before HANDLE file; #ifdef _TU_BUILD - file = CreateFile("UPDATE:\\res\\audio\\Minecraft.xgs", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("UPDATE:\\res\\audio\\Minecraft.xgs", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #else - file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\Minecraft.xgs", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\Minecraft.xgs", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -107,11 +107,11 @@ void SoundEngine::init(Options *pOptions) assert(false); return; } - DWORD dwFileSize = GetFileSize(file,NULL); + DWORD dwFileSize = GetFileSize(file,nullptr); DWORD bytesRead = 0; DWORD memFlags = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_PHYSICAL); void *pvGlobalSettings = XMemAlloc(dwFileSize, memFlags); - ReadFile(file,pvGlobalSettings,dwFileSize,&bytesRead,NULL); + ReadFile(file,pvGlobalSettings,dwFileSize,&bytesRead,nullptr); CloseHandle(file); XACT_RUNTIME_PARAMETERS EngineParameters = {0}; @@ -161,7 +161,7 @@ void SoundEngine::init(Options *pOptions) // Create resident wave bank - leave memory for this managed by xact so it can free it - file = CreateFile("GAME:\\res\\audio\\resident.xwb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("GAME:\\res\\audio\\resident.xwb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { app.FatalLoadError(); @@ -169,9 +169,9 @@ void SoundEngine::init(Options *pOptions) return; } - dwFileSize = GetFileSize(file,NULL); + dwFileSize = GetFileSize(file,nullptr); void *pvWaveBank = XMemAlloc(dwFileSize, memFlags); - ReadFile(file,pvWaveBank,dwFileSize,&bytesRead,NULL); + ReadFile(file,pvWaveBank,dwFileSize,&bytesRead,nullptr); CloseHandle(file); if ( FAILED( hr = m_pXACT3Engine->CreateInMemoryWaveBank( pvWaveBank, dwFileSize, XACT_FLAG_ENGINE_CREATE_MANAGEDATA, memFlags, &m_pWaveBank ) ) ) @@ -183,9 +183,9 @@ void SoundEngine::init(Options *pOptions) // 4J-PB - add new sounds wavebank #ifdef _TU_BUILD - file = CreateFile("UPDATE:\\res\\audio\\additional.xwb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("UPDATE:\\res\\audio\\additional.xwb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #else - file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\additional.xwb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\additional.xwb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -194,9 +194,9 @@ void SoundEngine::init(Options *pOptions) return; } - dwFileSize = GetFileSize(file,NULL); + dwFileSize = GetFileSize(file,nullptr); void *pvWaveBank2 = XMemAlloc(dwFileSize, memFlags); - ReadFile(file,pvWaveBank2,dwFileSize,&bytesRead,NULL); + ReadFile(file,pvWaveBank2,dwFileSize,&bytesRead,nullptr); CloseHandle(file); if ( FAILED( hr = m_pXACT3Engine->CreateInMemoryWaveBank( pvWaveBank2, dwFileSize, XACT_FLAG_ENGINE_CREATE_MANAGEDATA, memFlags, &m_pWaveBank2 ) ) ) @@ -208,7 +208,7 @@ void SoundEngine::init(Options *pOptions) // Create streamed sound bank - file = CreateFile("GAME:\\res\\audio\\streamed.xwb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); + file = CreateFile("GAME:\\res\\audio\\streamed.xwb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, nullptr); if( file == INVALID_HANDLE_VALUE ) { @@ -232,11 +232,11 @@ void SoundEngine::init(Options *pOptions) // Create streamed sound bank - //file = CreateFile("GAME:\\res\\audio\\AdditionalMusic.xwb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); + //file = CreateFile("GAME:\\res\\audio\\AdditionalMusic.xwb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, nullptr); #ifdef _TU_BUILD - file = CreateFile("UPDATE:\\res\\audio\\AdditionalMusic.xwb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("UPDATE:\\res\\audio\\AdditionalMusic.xwb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #else - file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\AdditionalMusic.xwb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\AdditionalMusic.xwb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -259,11 +259,11 @@ void SoundEngine::init(Options *pOptions) // Create sound bank - leave memory for this managed by xact so it can free it // 4J-PB - updated for the TU - //file = CreateFile("GAME:\\res\\audio\\minecraft.xsb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + //file = CreateFile("GAME:\\res\\audio\\minecraft.xsb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #ifdef _TU_BUILD - file = CreateFile("UPDATE:\\res\\audio\\minecraft.xsb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("UPDATE:\\res\\audio\\minecraft.xsb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #else - file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\minecraft.xsb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\minecraft.xsb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -271,9 +271,9 @@ void SoundEngine::init(Options *pOptions) assert(false); return; } - dwFileSize = GetFileSize(file,NULL); + dwFileSize = GetFileSize(file,nullptr); void *pvSoundBank = XMemAlloc(dwFileSize, memFlags); - ReadFile(file,pvSoundBank,dwFileSize,&bytesRead,NULL); + ReadFile(file,pvSoundBank,dwFileSize,&bytesRead,nullptr); CloseHandle(file); if ( FAILED( hr = m_pXACT3Engine->CreateSoundBank( pvSoundBank, dwFileSize, XACT_FLAG_ENGINE_CREATE_MANAGEDATA, memFlags, &m_pSoundBank ) ) ) @@ -286,9 +286,9 @@ void SoundEngine::init(Options *pOptions) // Create sound bank2 - leave memory for this managed by xact so it can free it #ifdef _TU_BUILD - file = CreateFile("UPDATE:\\res\\audio\\additional.xsb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("UPDATE:\\res\\audio\\additional.xsb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #else - file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\additional.xsb", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile("GAME:\\res\\TitleUpdate\\audio\\additional.xsb", GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -296,9 +296,9 @@ void SoundEngine::init(Options *pOptions) assert(false); return; } - dwFileSize = GetFileSize(file,NULL); + dwFileSize = GetFileSize(file,nullptr); void *pvSoundBank2 = XMemAlloc(dwFileSize, memFlags); - ReadFile(file,pvSoundBank2,dwFileSize,&bytesRead,NULL); + ReadFile(file,pvSoundBank2,dwFileSize,&bytesRead,nullptr); CloseHandle(file); if ( FAILED( hr = m_pXACT3Engine->CreateSoundBank( pvSoundBank2, dwFileSize, XACT_FLAG_ENGINE_CREATE_MANAGEDATA, memFlags, &m_pSoundBank2 ) ) ) @@ -324,7 +324,7 @@ void SoundEngine::CreateStreamingWavebank(const char *pchName, IXACT3WaveBank ** // Create streamed sound bank HRESULT hr; - HANDLE file = CreateFile(pchName, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); + HANDLE file = CreateFile(pchName, GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, nullptr); if( file == INVALID_HANDLE_VALUE ) { @@ -350,7 +350,7 @@ void SoundEngine::CreateStreamingWavebank(const char *pchName, IXACT3WaveBank ** void SoundEngine::CreateSoundbank(const char *pchName, IXACT3SoundBank **ppSoundBank) { HRESULT hr; - HANDLE file = CreateFile(pchName, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(pchName, GENERIC_READ, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { @@ -358,11 +358,11 @@ void SoundEngine::CreateSoundbank(const char *pchName, IXACT3SoundBank **ppSound assert(false); return; } - DWORD dwFileSize = GetFileSize(file,NULL); + DWORD dwFileSize = GetFileSize(file,nullptr); DWORD bytesRead = 0; DWORD memFlags = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_PHYSICAL); void *pvSoundBank = XMemAlloc(dwFileSize, memFlags); - ReadFile(file,pvSoundBank,dwFileSize,&bytesRead,NULL); + ReadFile(file,pvSoundBank,dwFileSize,&bytesRead,nullptr); CloseHandle(file); if ( FAILED( hr = m_pXACT3Engine->CreateSoundBank( pvSoundBank, dwFileSize, XACT_FLAG_ENGINE_CREATE_MANAGEDATA, memFlags, ppSoundBank ) ) ) @@ -416,7 +416,7 @@ bool SoundEngine::isStreamingWavebankReady(IXACT3WaveBank *pWaveBank) void SoundEngine::XACTNotificationCallback( const XACT_NOTIFICATION* pNotification ) { - if(pNotification->pvContext!= NULL) + if(pNotification->pvContext!= nullptr) { if(pNotification->type==XACTNOTIFICATIONTYPE_WAVEBANKPREPARED) { @@ -462,7 +462,7 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume, floa bool bSoundbank1=(iSound<=eSoundType_STEP_SAND); - if( (m_pSoundBank == NULL ) || (m_pSoundBank2 == NULL))return; + if( (m_pSoundBank == nullptr ) || (m_pSoundBank2 == nullptr))return; if( currentSounds.size() > MAX_POLYPHONY ) { @@ -570,7 +570,7 @@ void SoundEngine::playUI(int iSound, float, float) { bool bSoundBank1=(iSound<=eSoundType_STEP_SAND); - if( (m_pSoundBank == NULL ) || (m_pSoundBank2 == NULL)) return; + if( (m_pSoundBank == nullptr ) || (m_pSoundBank2 == nullptr)) return; if( currentSounds.size() > MAX_POLYPHONY ) { @@ -637,15 +637,15 @@ void SoundEngine::playUI(int iSound, float, float) void SoundEngine::playStreaming(const wstring& name, float x, float y, float z, float vol, float pitch, bool bMusicDelay) { - IXACT3SoundBank *pSoundBank=NULL; + IXACT3SoundBank *pSoundBank=nullptr; bool bSoundBank2=false; MemSect(34); - if(m_MusicInfo.pCue!=NULL) + if(m_MusicInfo.pCue!=nullptr) { m_MusicInfo.pCue->Stop(0); m_MusicInfo.pCue->Destroy(); - m_MusicInfo.pCue = NULL; + m_MusicInfo.pCue = nullptr; } m_MusicInfo.volume = 1.0f;//m_fMusicVolume; @@ -673,7 +673,7 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z, for(unsigned int i=0;ilocalplayers[i]!=NULL) + if(pMinecraft->localplayers[i]!=nullptr) { if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_END) { @@ -743,7 +743,7 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z, { // printf("Sound prep failed\n"); m_musicIDX = XACTINDEX_INVALID; // don't do anything in the tick - m_MusicInfo.pCue=NULL; + m_MusicInfo.pCue=nullptr; MemSect(0); return; } @@ -774,7 +774,7 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z, } void SoundEngine::playMusicTick() { - if( (m_pSoundBank == NULL ) || (m_pSoundBank2 == NULL)) return; + if( (m_pSoundBank == nullptr ) || (m_pSoundBank2 == nullptr)) return; if( m_musicIDX == XACTINDEX_INVALID ) { @@ -785,7 +785,7 @@ void SoundEngine::playMusicTick() // check to see if the sound has stopped playing DWORD state; HRESULT hr; - if(m_MusicInfo.pCue!=NULL) + if(m_MusicInfo.pCue!=nullptr) { if( FAILED( hr = m_MusicInfo.pCue->GetState(&state) ) ) { @@ -804,14 +804,14 @@ void SoundEngine::playMusicTick() if(GetIsPlayingStreamingGameMusic()) { - if(m_MusicInfo.pCue!=NULL) + if(m_MusicInfo.pCue!=nullptr) { bool playerInEnd = false; bool playerInNether=false; Minecraft *pMinecraft = Minecraft::GetInstance(); for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if(pMinecraft->localplayers[i]!=NULL) + if(pMinecraft->localplayers[i]!=nullptr) { if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_END) { @@ -852,7 +852,7 @@ void SoundEngine::playMusicTick() return; } - if(m_MusicInfo.pCue!=NULL) + if(m_MusicInfo.pCue!=nullptr) { update3DPosition(&m_MusicInfo, true); SetIsPlayingStreamingGameMusic(true); @@ -986,7 +986,7 @@ void SoundEngine::update3DPosition(SoundEngine::soundInfo *pInfo, bool bPlaceEmi void SoundEngine::tick(shared_ptr *players, float a) { - if( m_pXACT3Engine == NULL ) return; + if( m_pXACT3Engine == nullptr ) return; // Creater listener array from the local players int listenerCount = 0; @@ -995,7 +995,7 @@ void SoundEngine::tick(shared_ptr *players, float a) { for( int i = 0; i < 4; i++ ) { - if( players[i] != NULL ) + if( players[i] != nullptr ) { float yRot = players[i]->yRotO + (players[i]->yRot - players[i]->yRotO) * a; diff --git a/Minecraft.Client/Xbox/Font/XUI_Font.cpp b/Minecraft.Client/Xbox/Font/XUI_Font.cpp index f4ae9d069..2262f3459 100644 --- a/Minecraft.Client/Xbox/Font/XUI_Font.cpp +++ b/Minecraft.Client/Xbox/Font/XUI_Font.cpp @@ -53,8 +53,8 @@ XUI_Font::~XUI_Font() VOID XUI_Font::GetTextExtent( const WCHAR* strText, FLOAT* pWidth, FLOAT* pHeight, BOOL bFirstLineOnly ) const { - assert( pWidth != NULL ); - assert( pHeight != NULL ); + assert( pWidth != nullptr ); + assert( pHeight != nullptr ); // Set default text extent in output parameters int iWidth = 0; @@ -146,8 +146,8 @@ VOID XUI_Font::Begin() //m_pFontTexture->GetLevelDesc( 0, &TextureDesc ); // Get the description // Set render state - assert(m_fontData->m_pFontTexture != NULL || m_fontData->m_iFontTexture > 0); - if(m_fontData->m_pFontTexture != NULL) + assert(m_fontData->m_pFontTexture != nullptr || m_fontData->m_iFontTexture > 0); + if(m_fontData->m_pFontTexture != nullptr) { pD3dDevice->SetTexture( 0, m_fontData->m_pFontTexture ); } @@ -236,7 +236,7 @@ VOID XUI_Font::DrawShadowText( FLOAT fOriginX, FLOAT fOriginY, DWORD dwColor, DW VOID XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, DWORD dwColor, const WCHAR* strText, DWORD dwFlags, FLOAT fMaxPixelWidth, bool darken /*= false*/ ) { - if( NULL == strText ) return; + if( nullptr == strText ) return; if( L'\0' == strText[0] ) return; // 4J-PB - if we're in 480 widescreen mode, we need to ensure that the font characters are aligned on an even boundary if they are a 2x multiple diff --git a/Minecraft.Client/Xbox/Font/XUI_FontData.cpp b/Minecraft.Client/Xbox/Font/XUI_FontData.cpp index d8d87547c..88d77d090 100644 --- a/Minecraft.Client/Xbox/Font/XUI_FontData.cpp +++ b/Minecraft.Client/Xbox/Font/XUI_FontData.cpp @@ -157,11 +157,11 @@ XUI_FontData::SChar XUI_FontData::getChar(const wchar_t strChar) //-------------------------------------------------------------------------------------- XUI_FontData::XUI_FontData() { - m_pFontTexture = NULL; + m_pFontTexture = nullptr; m_iFontTexture = -1; m_dwNumGlyphs = 0L; - m_Glyphs = NULL; + m_Glyphs = nullptr; m_cMaxGlyph = 0; @@ -201,12 +201,12 @@ HRESULT XUI_FontData::Create( SFontData &sfontdata ) m_fontData = new CFontData( sfontdata, rawPixels.data ); - if (rawPixels.data != NULL) delete [] rawPixels.data; + if (rawPixels.data != nullptr) delete [] rawPixels.data; #if 0 { // 4J-JEV: Load in FontData (ABC) file, and initialize member variables from it. - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); //wsprintfW(szResourceLocator,L"section://%X,%s#%s",c_ModuleHandle,L"media", L"media/font/Mojangles_10.abc"); wsprintfW(szResourceLocator,L"section://%X,%s#%s%s%s",c_ModuleHandle,L"media", L"media/font/",strFontFileName.c_str(),L".abc"); @@ -349,7 +349,7 @@ HRESULT XUI_FontData::Create( int iFontTexture, const VOID* pFontData ) //-------------------------------------------------------------------------------------- VOID XUI_FontData::Destroy() { - if(m_pFontTexture!=NULL) + if(m_pFontTexture!=nullptr) { m_pFontTexture->Release(); delete m_pFontTexture; @@ -357,7 +357,7 @@ VOID XUI_FontData::Destroy() m_fontData->release(); - m_pFontTexture = NULL; + m_pFontTexture = nullptr; m_dwNumGlyphs = 0L; m_cMaxGlyph = 0; diff --git a/Minecraft.Client/Xbox/Font/XUI_FontRenderer.cpp b/Minecraft.Client/Xbox/Font/XUI_FontRenderer.cpp index 5fff04db6..f6619fd5f 100644 --- a/Minecraft.Client/Xbox/Font/XUI_FontRenderer.cpp +++ b/Minecraft.Client/Xbox/Font/XUI_FontRenderer.cpp @@ -36,7 +36,7 @@ VOID XUI_FontRenderer::Term() HRESULT XUI_FontRenderer::GetCaps( DWORD * pdwCaps ) { - if( pdwCaps != NULL ) + if( pdwCaps != nullptr ) { // setting this means XUI calls the DrawCharsToDevice method *pdwCaps = XUI_FONT_RENDERER_CAP_INTERNAL_GLYPH_CACHE | XUI_FONT_RENDERER_CAP_POINT_SIZE_RESPECTED | XUI_FONT_RENDERER_STYLE_DROPSHADOW; @@ -60,8 +60,8 @@ HRESULT XUI_FontRenderer::CreateFont( const TypefaceDescriptor * pTypefaceDescri //app.DebugPrintf("point size is: %f, xuiSize is: %d\n", fPointSize, xuiSize); - XUI_Font *font = NULL; - XUI_FontData *fontData = NULL; + XUI_Font *font = nullptr; + XUI_FontData *fontData = nullptr; FLOAT scale = 1; eFontData efontdata; @@ -77,17 +77,17 @@ HRESULT XUI_FontRenderer::CreateFont( const TypefaceDescriptor * pTypefaceDescri } font = m_loadedFonts[efontdata][scale]; - if (font == NULL) + if (font == nullptr) { fontData = m_loadedFontData[efontdata]; - if (fontData == NULL) + if (fontData == nullptr) { SFontData *sfontdata; switch (efontdata) { case eFontData_Mojangles_7: sfontdata = &SFontData::Mojangles_7; break; case eFontData_Mojangles_11: sfontdata = &SFontData::Mojangles_11; break; - default: sfontdata = NULL; break; + default: sfontdata = nullptr; break; } fontData = new XUI_FontData(); @@ -108,7 +108,7 @@ HRESULT XUI_FontRenderer::CreateFont( const TypefaceDescriptor * pTypefaceDescri VOID XUI_FontRenderer::ReleaseFont( HFONTOBJ hFont ) { XUI_Font *xuiFont = static_cast(hFont); - if (xuiFont != NULL) + if (xuiFont != nullptr) { xuiFont->DecRefCount(); if (xuiFont->refCount <= 0) @@ -156,7 +156,7 @@ HRESULT XUI_FontRenderer::GetCharMetrics( HFONTOBJ hFont, WCHAR wch, XUICharMetr HRESULT XUI_FontRenderer::DrawCharToTexture( HFONTOBJ hFont, WCHAR wch, HXUIDC hDC, IXuiTexture * pTexture, UINT x, UINT y, UINT width, UINT height, UINT insetX, UINT insetY ) { - if( hFont==0 || pTexture==NULL ) return E_INVALIDARG; + if( hFont==0 || pTexture==nullptr ) return E_INVALIDARG; return( S_OK ); } diff --git a/Minecraft.Client/Xbox/Leaderboards/XboxLeaderboardManager.cpp b/Minecraft.Client/Xbox/Leaderboards/XboxLeaderboardManager.cpp index 76fca0e48..55967327e 100644 --- a/Minecraft.Client/Xbox/Leaderboards/XboxLeaderboardManager.cpp +++ b/Minecraft.Client/Xbox/Leaderboards/XboxLeaderboardManager.cpp @@ -10,25 +10,25 @@ LeaderboardManager *LeaderboardManager::m_instance = new XboxLeaderboardManager( const XboxLeaderboardManager::LeaderboardDescriptor XboxLeaderboardManager::LEADERBOARD_DESCRIPTORS[XboxLeaderboardManager::NUM_LEADERBOARDS][4] = { { - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_PEACEFUL, 4, STATS_COLUMN_TRAVELLING_PEACEFUL_WALKED, STATS_COLUMN_TRAVELLING_PEACEFUL_FALLEN, STATS_COLUMN_TRAVELLING_PEACEFUL_MINECART, STATS_COLUMN_TRAVELLING_PEACEFUL_BOAT, NULL, NULL, NULL,NULL), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_EASY, 4, STATS_COLUMN_TRAVELLING_EASY_WALKED, STATS_COLUMN_TRAVELLING_EASY_FALLEN, STATS_COLUMN_TRAVELLING_EASY_MINECART, STATS_COLUMN_TRAVELLING_EASY_BOAT, NULL, NULL, NULL,NULL), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_NORMAL, 4, STATS_COLUMN_TRAVELLING_NORMAL_WALKED, STATS_COLUMN_TRAVELLING_NORMAL_FALLEN, STATS_COLUMN_TRAVELLING_NORMAL_MINECART, STATS_COLUMN_TRAVELLING_NORMAL_BOAT, NULL, NULL, NULL,NULL), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_HARD, 4, STATS_COLUMN_TRAVELLING_HARD_WALKED, STATS_COLUMN_TRAVELLING_HARD_FALLEN, STATS_COLUMN_TRAVELLING_HARD_MINECART, STATS_COLUMN_TRAVELLING_HARD_BOAT, NULL, NULL, NULL,NULL), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_PEACEFUL, 4, STATS_COLUMN_TRAVELLING_PEACEFUL_WALKED, STATS_COLUMN_TRAVELLING_PEACEFUL_FALLEN, STATS_COLUMN_TRAVELLING_PEACEFUL_MINECART, STATS_COLUMN_TRAVELLING_PEACEFUL_BOAT, nullptr, nullptr, nullptr,nullptr), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_EASY, 4, STATS_COLUMN_TRAVELLING_EASY_WALKED, STATS_COLUMN_TRAVELLING_EASY_FALLEN, STATS_COLUMN_TRAVELLING_EASY_MINECART, STATS_COLUMN_TRAVELLING_EASY_BOAT, nullptr, nullptr, nullptr,nullptr), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_NORMAL, 4, STATS_COLUMN_TRAVELLING_NORMAL_WALKED, STATS_COLUMN_TRAVELLING_NORMAL_FALLEN, STATS_COLUMN_TRAVELLING_NORMAL_MINECART, STATS_COLUMN_TRAVELLING_NORMAL_BOAT, nullptr, nullptr, nullptr,nullptr), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_TRAVELLING_HARD, 4, STATS_COLUMN_TRAVELLING_HARD_WALKED, STATS_COLUMN_TRAVELLING_HARD_FALLEN, STATS_COLUMN_TRAVELLING_HARD_MINECART, STATS_COLUMN_TRAVELLING_HARD_BOAT, nullptr, nullptr, nullptr,nullptr), }, { - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_PEACEFUL, 7, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_DIRT, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_STONE, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_SAND, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_GRAVEL, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_CLAY, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_OBSIDIAN, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_EASY, 7, STATS_COLUMN_MINING_BLOCKS_EASY_DIRT, STATS_COLUMN_MINING_BLOCKS_EASY_STONE, STATS_COLUMN_MINING_BLOCKS_EASY_SAND, STATS_COLUMN_MINING_BLOCKS_EASY_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_EASY_GRAVEL, STATS_COLUMN_MINING_BLOCKS_EASY_CLAY, STATS_COLUMN_MINING_BLOCKS_EASY_OBSIDIAN, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_NORMAL, 7, STATS_COLUMN_MINING_BLOCKS_NORMAL_DIRT, STATS_COLUMN_MINING_BLOCKS_NORMAL_STONE, STATS_COLUMN_MINING_BLOCKS_NORMAL_SAND, STATS_COLUMN_MINING_BLOCKS_NORMAL_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_NORMAL_GRAVEL, STATS_COLUMN_MINING_BLOCKS_NORMAL_CLAY, STATS_COLUMN_MINING_BLOCKS_NORMAL_OBSIDIAN, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_HARD, 7, STATS_COLUMN_MINING_BLOCKS_HARD_DIRT, STATS_COLUMN_MINING_BLOCKS_HARD_STONE, STATS_COLUMN_MINING_BLOCKS_HARD_SAND, STATS_COLUMN_MINING_BLOCKS_HARD_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_HARD_GRAVEL, STATS_COLUMN_MINING_BLOCKS_HARD_CLAY, STATS_COLUMN_MINING_BLOCKS_HARD_OBSIDIAN, NULL ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_PEACEFUL, 7, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_DIRT, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_STONE, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_SAND, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_GRAVEL, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_CLAY, STATS_COLUMN_MINING_BLOCKS_PEACEFUL_OBSIDIAN, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_EASY, 7, STATS_COLUMN_MINING_BLOCKS_EASY_DIRT, STATS_COLUMN_MINING_BLOCKS_EASY_STONE, STATS_COLUMN_MINING_BLOCKS_EASY_SAND, STATS_COLUMN_MINING_BLOCKS_EASY_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_EASY_GRAVEL, STATS_COLUMN_MINING_BLOCKS_EASY_CLAY, STATS_COLUMN_MINING_BLOCKS_EASY_OBSIDIAN, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_NORMAL, 7, STATS_COLUMN_MINING_BLOCKS_NORMAL_DIRT, STATS_COLUMN_MINING_BLOCKS_NORMAL_STONE, STATS_COLUMN_MINING_BLOCKS_NORMAL_SAND, STATS_COLUMN_MINING_BLOCKS_NORMAL_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_NORMAL_GRAVEL, STATS_COLUMN_MINING_BLOCKS_NORMAL_CLAY, STATS_COLUMN_MINING_BLOCKS_NORMAL_OBSIDIAN, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_MINING_BLOCKS_HARD, 7, STATS_COLUMN_MINING_BLOCKS_HARD_DIRT, STATS_COLUMN_MINING_BLOCKS_HARD_STONE, STATS_COLUMN_MINING_BLOCKS_HARD_SAND, STATS_COLUMN_MINING_BLOCKS_HARD_COBBLESTONE, STATS_COLUMN_MINING_BLOCKS_HARD_GRAVEL, STATS_COLUMN_MINING_BLOCKS_HARD_CLAY, STATS_COLUMN_MINING_BLOCKS_HARD_OBSIDIAN, nullptr ), }, { - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_FARMING_PEACEFUL, 6, STATS_COLUMN_FARMING_PEACEFUL_EGGS, STATS_COLUMN_FARMING_PEACEFUL_WHEAT, STATS_COLUMN_FARMING_PEACEFUL_MUSHROOMS,STATS_COLUMN_FARMING_PEACEFUL_SUGARCANE,STATS_COLUMN_FARMING_PEACEFUL_MILK, STATS_COLUMN_FARMING_PEACEFUL_PUMPKINS, NULL, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_FARMING_EASY, 6, STATS_COLUMN_FARMING_EASY_EGGS, STATS_COLUMN_FARMING_PEACEFUL_WHEAT, STATS_COLUMN_FARMING_EASY_MUSHROOMS, STATS_COLUMN_FARMING_EASY_SUGARCANE, STATS_COLUMN_FARMING_EASY_MILK, STATS_COLUMN_FARMING_EASY_PUMPKINS, NULL, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_FARMING_NORMAL, 6, STATS_COLUMN_FARMING_NORMAL_EGGS, STATS_COLUMN_FARMING_NORMAL_WHEAT, STATS_COLUMN_FARMING_NORMAL_MUSHROOMS, STATS_COLUMN_FARMING_NORMAL_SUGARCANE, STATS_COLUMN_FARMING_NORMAL_MILK, STATS_COLUMN_FARMING_NORMAL_PUMPKINS, NULL, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_FARMING_HARD, 6, STATS_COLUMN_FARMING_HARD_EGGS, STATS_COLUMN_FARMING_HARD_WHEAT, STATS_COLUMN_FARMING_HARD_MUSHROOMS, STATS_COLUMN_FARMING_HARD_SUGARCANE, STATS_COLUMN_FARMING_HARD_MILK, STATS_COLUMN_FARMING_HARD_PUMPKINS, NULL, NULL ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_FARMING_PEACEFUL, 6, STATS_COLUMN_FARMING_PEACEFUL_EGGS, STATS_COLUMN_FARMING_PEACEFUL_WHEAT, STATS_COLUMN_FARMING_PEACEFUL_MUSHROOMS,STATS_COLUMN_FARMING_PEACEFUL_SUGARCANE,STATS_COLUMN_FARMING_PEACEFUL_MILK, STATS_COLUMN_FARMING_PEACEFUL_PUMPKINS, nullptr, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_FARMING_EASY, 6, STATS_COLUMN_FARMING_EASY_EGGS, STATS_COLUMN_FARMING_PEACEFUL_WHEAT, STATS_COLUMN_FARMING_EASY_MUSHROOMS, STATS_COLUMN_FARMING_EASY_SUGARCANE, STATS_COLUMN_FARMING_EASY_MILK, STATS_COLUMN_FARMING_EASY_PUMPKINS, nullptr, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_FARMING_NORMAL, 6, STATS_COLUMN_FARMING_NORMAL_EGGS, STATS_COLUMN_FARMING_NORMAL_WHEAT, STATS_COLUMN_FARMING_NORMAL_MUSHROOMS, STATS_COLUMN_FARMING_NORMAL_SUGARCANE, STATS_COLUMN_FARMING_NORMAL_MILK, STATS_COLUMN_FARMING_NORMAL_PUMPKINS, nullptr, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_FARMING_HARD, 6, STATS_COLUMN_FARMING_HARD_EGGS, STATS_COLUMN_FARMING_HARD_WHEAT, STATS_COLUMN_FARMING_HARD_MUSHROOMS, STATS_COLUMN_FARMING_HARD_SUGARCANE, STATS_COLUMN_FARMING_HARD_MILK, STATS_COLUMN_FARMING_HARD_PUMPKINS, nullptr, nullptr ), }, { - XboxLeaderboardManager::LeaderboardDescriptor( NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_KILLS_EASY, 7, STATS_COLUMN_KILLS_EASY_ZOMBIES, STATS_COLUMN_KILLS_EASY_SKELETONS, STATS_COLUMN_KILLS_EASY_CREEPERS, STATS_COLUMN_KILLS_EASY_SPIDERS, STATS_COLUMN_KILLS_EASY_SPIDERJOCKEYS, STATS_COLUMN_KILLS_EASY_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_EASY_SLIME, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_KILLS_NORMAL, 7, STATS_COLUMN_KILLS_NORMAL_ZOMBIES, STATS_COLUMN_KILLS_NORMAL_SKELETONS, STATS_COLUMN_KILLS_NORMAL_CREEPERS, STATS_COLUMN_KILLS_NORMAL_SPIDERS, STATS_COLUMN_KILLS_NORMAL_SPIDERJOCKEYS, STATS_COLUMN_KILLS_NORMAL_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_NORMAL_SLIME, NULL ), - XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_KILLS_HARD, 7, STATS_COLUMN_KILLS_HARD_ZOMBIES, STATS_COLUMN_KILLS_HARD_SKELETONS, STATS_COLUMN_KILLS_HARD_CREEPERS, STATS_COLUMN_KILLS_HARD_SPIDERS, STATS_COLUMN_KILLS_HARD_SPIDERJOCKEYS, STATS_COLUMN_KILLS_HARD_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_HARD_SLIME, NULL ), + XboxLeaderboardManager::LeaderboardDescriptor( nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_KILLS_EASY, 7, STATS_COLUMN_KILLS_EASY_ZOMBIES, STATS_COLUMN_KILLS_EASY_SKELETONS, STATS_COLUMN_KILLS_EASY_CREEPERS, STATS_COLUMN_KILLS_EASY_SPIDERS, STATS_COLUMN_KILLS_EASY_SPIDERJOCKEYS, STATS_COLUMN_KILLS_EASY_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_EASY_SLIME, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_KILLS_NORMAL, 7, STATS_COLUMN_KILLS_NORMAL_ZOMBIES, STATS_COLUMN_KILLS_NORMAL_SKELETONS, STATS_COLUMN_KILLS_NORMAL_CREEPERS, STATS_COLUMN_KILLS_NORMAL_SPIDERS, STATS_COLUMN_KILLS_NORMAL_SPIDERJOCKEYS, STATS_COLUMN_KILLS_NORMAL_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_NORMAL_SLIME, nullptr ), + XboxLeaderboardManager::LeaderboardDescriptor( STATS_VIEW_KILLS_HARD, 7, STATS_COLUMN_KILLS_HARD_ZOMBIES, STATS_COLUMN_KILLS_HARD_SKELETONS, STATS_COLUMN_KILLS_HARD_CREEPERS, STATS_COLUMN_KILLS_HARD_SPIDERS, STATS_COLUMN_KILLS_HARD_SPIDERJOCKEYS, STATS_COLUMN_KILLS_HARD_ZOMBIEPIGMEN, STATS_COLUMN_KILLS_HARD_SLIME, nullptr ), }, }; @@ -37,9 +37,9 @@ XboxLeaderboardManager::XboxLeaderboardManager() m_eStatsState = eStatsState_Idle; m_statsRead = false; - m_hSession = NULL; - m_spec = NULL; - m_stats = NULL; + m_hSession = nullptr; + m_spec = nullptr; + m_stats = nullptr; m_isQNetSession = false; m_endingSession = false; @@ -53,11 +53,11 @@ void XboxLeaderboardManager::Tick() { /*if( IsStatsReadComplete() ) - if( m_readCompleteCallback != NULL ) + if( m_readCompleteCallback != nullptr ) m_readCompleteCallback(m_readCompleteUserdata);*/ if ( IsStatsReadComplete() ) - if (m_readListener != NULL) + if (m_readListener != nullptr) { // 4J Stu - If the state is other than ready, then we don't have any stats to sort if(m_eFilterMode == LeaderboardManager::eFM_Friends && m_eStatsState == eStatsState_Ready) SortFriendStats(); @@ -83,12 +83,12 @@ bool XboxLeaderboardManager::OpenSession() if (m_endingSession) return false; //We've already got an open session - if (m_hSession != NULL) return true; + if (m_hSession != nullptr) return true; int lockedProfile = ProfileManager.GetLockedProfile(); if( lockedProfile == -1 ) { - m_hSession = NULL; + m_hSession = nullptr; return false; } @@ -112,26 +112,26 @@ bool XboxLeaderboardManager::OpenSession() XSESSION_INFO sessionInfo; ULONGLONG sessionNonce; - DWORD ret = XSessionCreate(XSESSION_CREATE_USES_STATS | XSESSION_CREATE_HOST, lockedProfile, 8, 8, &sessionNonce, &sessionInfo, NULL, &m_hSession); + DWORD ret = XSessionCreate(XSESSION_CREATE_USES_STATS | XSESSION_CREATE_HOST, lockedProfile, 8, 8, &sessionNonce, &sessionInfo, nullptr, &m_hSession); if( ret != ERROR_SUCCESS ) { - m_hSession = NULL; + m_hSession = nullptr; return false; } DWORD userIndices[1] = { lockedProfile }; BOOL privateSlots[1] = { FALSE }; - ret = XSessionJoinLocal(m_hSession, 1, userIndices, privateSlots, NULL); + ret = XSessionJoinLocal(m_hSession, 1, userIndices, privateSlots, nullptr); if( ret != ERROR_SUCCESS ) { - m_hSession = NULL; + m_hSession = nullptr; return false; } - ret = XSessionStart(m_hSession, 0, NULL); + ret = XSessionStart(m_hSession, 0, nullptr); if( ret != ERROR_SUCCESS ) { - m_hSession = NULL; + m_hSession = nullptr; return false; } @@ -151,7 +151,7 @@ void XboxLeaderboardManager::CloseSession() return; } - if (m_hSession == NULL) return; + if (m_hSession == nullptr) return; memset(&m_endSessionOverlapped, 0, sizeof(m_endSessionOverlapped)); @@ -166,15 +166,15 @@ void XboxLeaderboardManager::CloseSession() if (ret != ERROR_SUCCESS) DeleteSession(); } - m_readListener = NULL; + m_readListener = nullptr; } } void XboxLeaderboardManager::DeleteSession() { - XSessionDelete(m_hSession, NULL); + XSessionDelete(m_hSession, nullptr); CloseHandle(m_hSession); - m_hSession = NULL; + m_hSession = nullptr; } bool XboxLeaderboardManager::WriteStats(unsigned int viewCount, ViewIn views) @@ -190,7 +190,7 @@ bool XboxLeaderboardManager::WriteStats(unsigned int viewCount, ViewIn views) if(m_isQNetSession == true) { INetworkPlayer *player = g_NetworkManager.GetPlayerByXuid(m_myXUID); - if(player != NULL) + if(player != nullptr) { ret = static_cast(player)->GetQNetPlayer()->WriteStats(viewCount,views); //printf("Wrote stats to QNet player\n"); @@ -204,7 +204,7 @@ bool XboxLeaderboardManager::WriteStats(unsigned int viewCount, ViewIn views) } else { - ret = XSessionWriteStats(m_hSession, m_myXUID, viewCount, views, NULL); + ret = XSessionWriteStats(m_hSession, m_myXUID, viewCount, views, nullptr); } if (ret != ERROR_SUCCESS) return false; return true; @@ -213,7 +213,7 @@ bool XboxLeaderboardManager::WriteStats(unsigned int viewCount, ViewIn views) void XboxLeaderboardManager::CancelOperation() { //Need to have a session open - if( m_hSession == NULL ) + if( m_hSession == nullptr ) if( !OpenSession() ) return; @@ -249,7 +249,7 @@ bool XboxLeaderboardManager::ReadStats_MyScore(LeaderboardReadListener *callback //Allocate a buffer for the stats m_stats = (PXUSER_STATS_READ_RESULTS) new BYTE[m_numStats]; - if (m_stats == NULL) return false; + if (m_stats == nullptr) return false; memset(m_stats, 0, m_numStats); memset(&m_overlapped, 0, sizeof(m_overlapped)); @@ -258,7 +258,7 @@ bool XboxLeaderboardManager::ReadStats_MyScore(LeaderboardReadListener *callback hEnumerator, // Enumeration handle m_stats, // Buffer m_numStats, // Size of buffer - NULL, // Number of rows returned; not used for async + nullptr, // Number of rows returned; not used for async &m_overlapped ); // Overlapped structure; not used for sync if ( (ret!=ERROR_SUCCESS) && (ret!=ERROR_IO_PENDING) ) return false; @@ -280,12 +280,12 @@ bool XboxLeaderboardManager::ReadStats_Friends(LeaderboardReadListener *callback getFriends(friendCount, &friends); - if(friendCount == 0 || friends == NULL) + if(friendCount == 0 || friends == nullptr) { app.DebugPrintf("XboxLeaderboardManager::ReadStats_Friends - No friends found. Possibly you are offline?\n"); return false; } - assert(friendCount > 0 && friends != NULL); + assert(friendCount > 0 && friends != nullptr); m_numStats = 0; ret = XUserReadStats( @@ -295,8 +295,8 @@ bool XboxLeaderboardManager::ReadStats_Friends(LeaderboardReadListener *callback 1, //specCount, m_spec, &m_numStats, - NULL, - NULL + nullptr, + nullptr ); //Annoyingly, this returns ERROR_INSUFFICIENT_BUFFER when it is being asked to calculate the size of the buffer by passing zero resultsSize @@ -304,7 +304,7 @@ bool XboxLeaderboardManager::ReadStats_Friends(LeaderboardReadListener *callback //Allocate a buffer for the stats m_stats = (PXUSER_STATS_READ_RESULTS) new BYTE[m_numStats]; - if (m_stats == NULL) return false; + if (m_stats == nullptr) return false; memset(m_stats, 0, m_numStats); memset(&m_overlapped, 0, sizeof(m_overlapped)); @@ -346,7 +346,7 @@ bool XboxLeaderboardManager::ReadStats_TopRank(LeaderboardReadListener *callback //Allocate a buffer for the stats m_stats = (PXUSER_STATS_READ_RESULTS) new BYTE[m_numStats]; - if (m_stats == NULL) return false; + if (m_stats == nullptr) return false; memset(m_stats, 0, m_numStats); memset(&m_overlapped, 0, sizeof(m_overlapped)); @@ -355,7 +355,7 @@ bool XboxLeaderboardManager::ReadStats_TopRank(LeaderboardReadListener *callback hEnumerator, // Enumeration handle m_stats, // Buffer m_numStats, // Size of buffer - NULL, // Number of rows returned; not used for async + nullptr, // Number of rows returned; not used for async &m_overlapped ); // Overlapped structure; not used for sync if( (ret!=ERROR_SUCCESS) && (ret!=ERROR_IO_PENDING) ) return false; @@ -367,7 +367,7 @@ bool XboxLeaderboardManager::ReadStats_TopRank(LeaderboardReadListener *callback bool XboxLeaderboardManager::readStats(int difficulty, EStatsType type) { //Need to have a session open - if (m_hSession==NULL) if(!OpenSession()) return false; + if (m_hSession==nullptr) if(!OpenSession()) return false; m_eStatsState = eStatsState_Failed; m_statsRead = false; @@ -386,7 +386,7 @@ bool XboxLeaderboardManager::readStats(int difficulty, EStatsType type) void XboxLeaderboardManager::FlushStats() { - if( m_hSession == NULL || m_isQNetSession ) return; + if( m_hSession == nullptr || m_isQNetSession ) return; memset(&m_flushStatsOverlapped, 0, sizeof(m_flushStatsOverlapped)); XSessionFlushStats(m_hSession, &m_flushStatsOverlapped); } @@ -403,7 +403,7 @@ bool XboxLeaderboardManager::IsStatsReadComplete() if( m_stats ) { delete [] m_stats; - m_stats = NULL; + m_stats = nullptr; } } else @@ -415,7 +415,7 @@ bool XboxLeaderboardManager::IsStatsReadComplete() if( m_stats ) { delete [] m_stats; - m_stats = NULL; + m_stats = nullptr; } } else @@ -465,10 +465,10 @@ void XboxLeaderboardManager::SortFriendStats() #if 0 void XboxLeaderboardManager::SetStatsRetrieved(bool success) { - if( m_stats != NULL ) + if( m_stats != nullptr ) { delete [] m_stats; - m_stats = NULL; + m_stats = nullptr; } m_statsRead = success; @@ -496,7 +496,7 @@ bool XboxLeaderboardManager::getFriends(unsigned int &friendsCount, PlayerUID** xonlineFriends, resultsSize, &numFriends, - NULL + nullptr ); if (ret!=ERROR_SUCCESS) friendsCount = 0; diff --git a/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp b/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp index ea9ef39ea..9dc2d8c3c 100644 --- a/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp +++ b/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp @@ -4,7 +4,7 @@ NetworkPlayerXbox::NetworkPlayerXbox(IQNetPlayer *qnetPlayer) { m_qnetPlayer = qnetPlayer; - m_pSocket = NULL; + m_pSocket = nullptr; } unsigned char NetworkPlayerXbox::GetSmallId() @@ -34,14 +34,14 @@ int NetworkPlayerXbox::GetSendQueueSizeBytes( INetworkPlayer *player, bool lowPr { DWORD flags = QNET_GETSENDQUEUESIZE_BYTES; if( lowPriority ) flags |= QNET_GETSENDQUEUESIZE_SECONDARY_TYPE; - return m_qnetPlayer->GetSendQueueSize(player ? static_cast(player)->m_qnetPlayer : NULL , flags); + return m_qnetPlayer->GetSendQueueSize(player ? static_cast(player)->m_qnetPlayer : nullptr , flags); } int NetworkPlayerXbox::GetSendQueueSizeMessages( INetworkPlayer *player, bool lowPriority ) { DWORD flags = QNET_GETSENDQUEUESIZE_MESSAGES; if( lowPriority ) flags |= QNET_GETSENDQUEUESIZE_SECONDARY_TYPE; - return m_qnetPlayer->GetSendQueueSize(player ? static_cast(player)->m_qnetPlayer : NULL , flags); + return m_qnetPlayer->GetSendQueueSize(player ? static_cast(player)->m_qnetPlayer : nullptr , flags); } int NetworkPlayerXbox::GetCurrentRtt() diff --git a/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.cpp b/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.cpp index 882137eb8..f586f4470 100644 --- a/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.cpp +++ b/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.cpp @@ -187,7 +187,7 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerJoined( for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, false ); } @@ -196,7 +196,7 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerJoined( int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pIQNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pIQNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -221,7 +221,7 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerLeaving( // Get our wrapper object associated with this player. Socket *socket = networkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { // If we are in game then remove this player from the game as well. // We may get here either from the player requesting to exit the game, @@ -237,14 +237,14 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerLeaving( // We need this as long as the game server still needs to communicate with the player //delete socket; - networkPlayer->SetSocket( NULL ); + networkPlayer->SetSocket( nullptr ); } if( m_pIQNet->IsHost() && !m_bHostChanged ) { if( isSystemPrimaryPlayer(pQNetPlayer) ) { - IQNetPlayer *pNewQNetPrimaryPlayer = NULL; + IQNetPlayer *pNewQNetPrimaryPlayer = nullptr; for(unsigned int i = 0; i < m_pIQNet->GetPlayerCount(); ++i ) { IQNetPlayer *pQNetPlayer2 = m_pIQNet->GetPlayerByIndex( i ); @@ -261,7 +261,7 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerLeaving( m_machineQNetPrimaryPlayers.erase( it ); } - if( pNewQNetPrimaryPlayer != NULL ) + if( pNewQNetPrimaryPlayer != nullptr ) m_machineQNetPrimaryPlayers.push_back( pNewQNetPrimaryPlayer ); } @@ -274,7 +274,7 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerLeaving( for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if(playerChangedCallback[idx] != NULL) + if(playerChangedCallback[idx] != nullptr) playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, true ); } @@ -283,7 +283,7 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerLeaving( int localPlayerCount = 0; for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if( m_pIQNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount; + if( m_pIQNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount; } float appTime = app.getAppTime(); @@ -349,7 +349,7 @@ VOID CPlatformNetworkManagerXbox::NotifyDataReceived( INetworkPlayer *pPlayerFrom = getNetworkPlayer(pQNetPlayerFrom); Socket *socket = pPlayerFrom->GetSocket(); - if(socket != NULL) + if(socket != nullptr) socket->pushDataToQueue(pbData, dwDataSize, false); } else @@ -358,7 +358,7 @@ VOID CPlatformNetworkManagerXbox::NotifyDataReceived( INetworkPlayer *pPlayerTo = getNetworkPlayer(apQNetPlayersTo[dwPlayer]); Socket *socket = pPlayerTo->GetSocket(); //app.DebugPrintf( "Pushing data into read queue for user \"%ls\"\n", apPlayersTo[dwPlayer]->GetGamertag()); - if(socket != NULL) + if(socket != nullptr) socket->pushDataToQueue(pbData, dwDataSize); } } @@ -432,7 +432,7 @@ bool CPlatformNetworkManagerXbox::Initialise(CGameNetworkManager *pGameNetworkMa g_pPlatformNetworkManager = this; for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { - playerChangedCallback[ i ] = NULL; + playerChangedCallback[ i ] = nullptr; } HRESULT hr; @@ -440,7 +440,7 @@ bool CPlatformNetworkManagerXbox::Initialise(CGameNetworkManager *pGameNetworkMa DWORD dwResult; // Start up XNet with default settings. - iResult = XNetStartup( NULL ); + iResult = XNetStartup( nullptr ); if( iResult != 0 ) { app.DebugPrintf( "Starting up XNet failed (err = %i)!\n", iResult ); @@ -457,7 +457,7 @@ bool CPlatformNetworkManagerXbox::Initialise(CGameNetworkManager *pGameNetworkMa } // Create the QNet object. - hr = QNetCreateUsingXAudio2( QNET_SESSIONTYPE_LIVE_STANDARD, this, NULL, g_pXAudio2, &m_pIQNet ); + hr = QNetCreateUsingXAudio2( QNET_SESSIONTYPE_LIVE_STANDARD, this, nullptr, g_pXAudio2, &m_pIQNet ); if( FAILED( hr ) ) { app.DebugPrintf( "Creating QNet object failed (err = 0x%08x)!\n", hr ); @@ -489,8 +489,8 @@ bool CPlatformNetworkManagerXbox::Initialise(CGameNetworkManager *pGameNetworkMa m_bSearchPending = false; m_bIsOfflineGame = false; - m_pSearchParam = NULL; - m_SessionsUpdatedCallback = NULL; + m_pSearchParam = nullptr; + m_SessionsUpdatedCallback = nullptr; for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { @@ -498,10 +498,10 @@ bool CPlatformNetworkManagerXbox::Initialise(CGameNetworkManager *pGameNetworkMa m_lastSearchStartTime[i] = 0; // The results that will be filled in with the current search - m_pSearchResults[i] = NULL; - m_pQoSResult[i] = NULL; - m_pCurrentSearchResults[i] = NULL; - m_pCurrentQoSResult[i] = NULL; + m_pSearchResults[i] = nullptr; + m_pQoSResult[i] = nullptr; + m_pCurrentSearchResults[i] = nullptr; + m_pCurrentQoSResult[i] = nullptr; m_currentSearchResultsCount[i] = 0; } @@ -629,11 +629,11 @@ bool CPlatformNetworkManagerXbox::RemoveLocalPlayerByUserIndex( int userIndex ) IQNetPlayer *pQNetPlayer = m_pIQNet->GetLocalPlayerByUserIndex(userIndex); INetworkPlayer *pNetworkPlayer = getNetworkPlayer(pQNetPlayer); - if(pNetworkPlayer != NULL) + if(pNetworkPlayer != nullptr) { Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { // We can't remove the player from qnet until we have stopped using it to communicate C4JThread* thread = new C4JThread(&CPlatformNetworkManagerXbox::RemovePlayerOnSocketClosedThreadProc, pNetworkPlayer, "RemovePlayerOnSocketClosed"); @@ -701,11 +701,11 @@ bool CPlatformNetworkManagerXbox::LeaveGame(bool bMigrateHost) IQNetPlayer *pQNetPlayer = m_pIQNet->GetLocalPlayerByUserIndex(g_NetworkManager.GetPrimaryPad()); INetworkPlayer *pNetworkPlayer = getNetworkPlayer(pQNetPlayer); - if(pNetworkPlayer != NULL) + if(pNetworkPlayer != nullptr) { Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { //printf("Waiting for socket closed event\n"); DWORD result = socket->m_socketClosedEvent->WaitForSignal(INFINITE); @@ -717,13 +717,13 @@ bool CPlatformNetworkManagerXbox::LeaveGame(bool bMigrateHost) // 4J Stu - Clear our reference to this socket pQNetPlayer = m_pIQNet->GetLocalPlayerByUserIndex(g_NetworkManager.GetPrimaryPad()); pNetworkPlayer = getNetworkPlayer(pQNetPlayer); - if(pNetworkPlayer) pNetworkPlayer->SetSocket( NULL ); + if(pNetworkPlayer) pNetworkPlayer->SetSocket( nullptr ); } delete socket; } else { - //printf("Socket is already NULL\n"); + //printf("Socket is already nullptr\n"); } } @@ -795,7 +795,7 @@ void CPlatformNetworkManagerXbox::_HostGame(int usersMask, unsigned char publicS publicSlots, // dwPublicSlots privateSlots, // dwPrivateSlots 0, // cProperties - NULL, // pProperties + nullptr, // pProperties ARRAYSIZE( aXUserContexts ), // cContexts aXUserContexts ); // pContexts @@ -899,8 +899,8 @@ void CPlatformNetworkManagerXbox::UnRegisterPlayerChangedCallback(int iPad, void { if(playerChangedCallbackParam[iPad] == callbackParam) { - playerChangedCallback[iPad] = NULL; - playerChangedCallbackParam[iPad] = NULL; + playerChangedCallback[iPad] = nullptr; + playerChangedCallbackParam[iPad] = nullptr; } } @@ -927,14 +927,14 @@ bool CPlatformNetworkManagerXbox::_RunNetworkGame() return true; } -void CPlatformNetworkManagerXbox::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/) +void CPlatformNetworkManagerXbox::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= nullptr*/) { DWORD playerCount = m_pIQNet->GetPlayerCount(); if( this->m_bLeavingGame ) return; - if( GetHostPlayer() == NULL ) + if( GetHostPlayer() == nullptr ) return; for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) @@ -954,13 +954,13 @@ void CPlatformNetworkManagerXbox::UpdateAndSetGameSessionData(INetworkPlayer *pN } else { - m_hostGameSessionData.players[i] = NULL; + m_hostGameSessionData.players[i] = nullptr; memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE); } } else { - m_hostGameSessionData.players[i] = NULL; + m_hostGameSessionData.players[i] = nullptr; memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE); } } @@ -982,14 +982,14 @@ int CPlatformNetworkManagerXbox::RemovePlayerOnSocketClosedThreadProc( void* lpP Socket *socket = pNetworkPlayer->GetSocket(); - if( socket != NULL ) + if( socket != nullptr ) { //printf("Waiting for socket closed event\n"); socket->m_socketClosedEvent->WaitForSignal(INFINITE); //printf("Socket closed event has fired\n"); // 4J Stu - Clear our reference to this socket - pNetworkPlayer->SetSocket( NULL ); + pNetworkPlayer->SetSocket( nullptr ); delete socket; } @@ -1066,7 +1066,7 @@ void CPlatformNetworkManagerXbox::SystemFlagReset() void CPlatformNetworkManagerXbox::SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return; - if( pNetworkPlayer == NULL ) return; + if( pNetworkPlayer == nullptr ) return; for( unsigned int i = 0; i < m_playerFlags.size(); i++ ) { @@ -1082,7 +1082,7 @@ void CPlatformNetworkManagerXbox::SystemFlagSet(INetworkPlayer *pNetworkPlayer, bool CPlatformNetworkManagerXbox::SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index) { if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return false; - if( pNetworkPlayer == NULL ) + if( pNetworkPlayer == nullptr ) { return false; } @@ -1099,8 +1099,8 @@ bool CPlatformNetworkManagerXbox::SystemFlagGet(INetworkPlayer *pNetworkPlayer, wstring CPlatformNetworkManagerXbox::GatherStats() { - return L"Queue messages: " + std::to_wstring(static_cast(GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_MESSAGES ) ) - + L" Queue bytes: " + std::to_wstring( static_cast(GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES ) ); + return L"Queue messages: " + std::to_wstring(static_cast(GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( nullptr, QNET_GETSENDQUEUESIZE_MESSAGES ) ) + + L" Queue bytes: " + std::to_wstring( static_cast(GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( nullptr, QNET_GETSENDQUEUESIZE_BYTES ) ); } wstring CPlatformNetworkManagerXbox::GatherRTTStats() @@ -1132,23 +1132,23 @@ void CPlatformNetworkManagerXbox::TickSearch() m_currentSearchResultsCount[m_lastSearchPad] = m_searchResultsCount[m_lastSearchPad]; // Store the current search results so that we don't delete them too early - if( m_pCurrentSearchResults[m_lastSearchPad] != NULL ) + if( m_pCurrentSearchResults[m_lastSearchPad] != nullptr ) { delete m_pCurrentSearchResults[m_lastSearchPad]; - m_pCurrentSearchResults[m_lastSearchPad] = NULL; + m_pCurrentSearchResults[m_lastSearchPad] = nullptr; } m_pCurrentSearchResults[m_lastSearchPad] = m_pSearchResults[m_lastSearchPad]; - m_pSearchResults[m_lastSearchPad] = NULL; + m_pSearchResults[m_lastSearchPad] = nullptr; - if( m_pCurrentQoSResult[m_lastSearchPad] != NULL ) + if( m_pCurrentQoSResult[m_lastSearchPad] != nullptr ) { XNetQosRelease(m_pCurrentQoSResult[m_lastSearchPad]); - m_pCurrentQoSResult[m_lastSearchPad] = NULL; + m_pCurrentQoSResult[m_lastSearchPad] = nullptr; } m_pCurrentQoSResult[m_lastSearchPad] = m_pQoSResult[m_lastSearchPad]; - m_pQoSResult[m_lastSearchPad] = NULL; + m_pQoSResult[m_lastSearchPad] = nullptr; - if( m_SessionsUpdatedCallback != NULL ) m_SessionsUpdatedCallback(m_pSearchParam); + if( m_SessionsUpdatedCallback != nullptr ) m_SessionsUpdatedCallback(m_pSearchParam); m_bSearchResultsReady = false; m_bSearchPending = false; } @@ -1156,7 +1156,7 @@ void CPlatformNetworkManagerXbox::TickSearch() else { // Don't start searches unless we have registered a callback - if( m_SessionsUpdatedCallback != NULL && (m_lastSearchStartTime[g_NetworkManager.GetPrimaryPad()] + MINECRAFT_XSESSION_SEARCH_DELAY_MILLISECONDS) < GetTickCount() ) + if( m_SessionsUpdatedCallback != nullptr && (m_lastSearchStartTime[g_NetworkManager.GetPrimaryPad()] + MINECRAFT_XSESSION_SEARCH_DELAY_MILLISECONDS) < GetTickCount() ) { SearchForGames(); } @@ -1180,15 +1180,15 @@ void CPlatformNetworkManagerXbox::SearchForGames() } friendsSessions[m_lastSearchPad].clear(); - if( m_pSearchResults[m_lastSearchPad] != NULL ) + if( m_pSearchResults[m_lastSearchPad] != nullptr ) { delete m_pSearchResults[m_lastSearchPad]; - m_pSearchResults[m_lastSearchPad] = NULL; + m_pSearchResults[m_lastSearchPad] = nullptr; } - if( m_pQoSResult[m_lastSearchPad] != NULL ) + if( m_pQoSResult[m_lastSearchPad] != nullptr ) { XNetQosRelease(m_pQoSResult[m_lastSearchPad]); - m_pQoSResult[m_lastSearchPad] = NULL; + m_pQoSResult[m_lastSearchPad] = nullptr; } bool bMultiplayerAllowed = g_NetworkManager.IsSignedInLive( g_NetworkManager.GetPrimaryPad() ) && g_NetworkManager.AllowedToPlayMultiplayer( g_NetworkManager.GetPrimaryPad() ); @@ -1250,7 +1250,7 @@ void CPlatformNetworkManagerXbox::SearchForGames() buffer, bufferSize, &itemsReturned, - NULL + nullptr ); DWORD flagPlayingOnline = XONLINE_FRIENDSTATE_FLAG_ONLINE; // | XONLINE_FRIENDSTATE_FLAG_PLAYING; @@ -1317,8 +1317,8 @@ void CPlatformNetworkManagerXbox::SearchForGames() sessionIDList, g_NetworkManager.GetPrimaryPad(), &cbResults, // Pass in the address of the size variable - NULL, - NULL // This example uses the synchronous model + nullptr, + nullptr // This example uses the synchronous model ); XOVERLAPPED *pOverlapped = new XOVERLAPPED(); @@ -1423,7 +1423,7 @@ int CPlatformNetworkManagerXbox::SearchForGamesThreadProc( void* lpParameter ) } // Create an event object that is autoreset with an initial state of "not signaled". // Pass this event handle to the QoSLookup to receive notification of each QoS lookup. - HANDLE QoSLookupHandle = CreateEvent(NULL, false, false, NULL); + HANDLE QoSLookupHandle = CreateEvent(nullptr, false, false, nullptr); *threadData->ppQos = new XNQOS(); @@ -1433,8 +1433,8 @@ int CPlatformNetworkManagerXbox::SearchForGamesThreadProc( void* lpParameter ) QoSxnkid, // Array of pointers to XNKID structures that contain session IDs for the remote Xbox 360 consoles QoSxnkey, // Array of pointers to XNKEY structures that contain key-exchange keys for the remote Xbox 360 consoles 0, // Number of security gateways to probe - NULL, // Pointer to an array of IN_ADDR structures that contain the IP addresses of the security gateways - NULL, // Pointer to an array of service IDs for the security gateway + nullptr, // Pointer to an array of IN_ADDR structures that contain the IP addresses of the security gateways + nullptr, // Pointer to an array of service IDs for the security gateway 8, // Number of desired probe replies to receive 0, // Maximum upstream bandwidth that the outgoing QoS probe packets can consume 0, // Flags @@ -1489,11 +1489,11 @@ vector *CPlatformNetworkManagerXbox::GetSessionList(int iPa pSearchResult = &m_pCurrentSearchResults[iPad]->pResults[dwResult]; // No room for us, so ignore it - // 4J Stu - pSearchResult should never be NULL, but just in case... - if(pSearchResult == NULL || pSearchResult->dwOpenPublicSlots < localPlayers) continue; + // 4J Stu - pSearchResult should never be nullptr, but just in case... + if(pSearchResult == nullptr || pSearchResult->dwOpenPublicSlots < localPlayers) continue; bool foundSession = false; - FriendSessionInfo *sessionInfo = NULL; + FriendSessionInfo *sessionInfo = nullptr; auto itFriendSession = friendsSessions[iPad].begin(); for(itFriendSession = friendsSessions[iPad].begin(); itFriendSession < friendsSessions[iPad].end(); ++itFriendSession) { @@ -1595,7 +1595,7 @@ bool CPlatformNetworkManagerXbox::GetGameSessionInfo(int iPad, SessionID session if(memcmp( &pSearchResult->info.sessionID, &sessionId, sizeof(SessionID) ) != 0) continue; bool foundSession = false; - FriendSessionInfo *sessionInfo = NULL; + FriendSessionInfo *sessionInfo = nullptr; auto = itFriendSession, friendsSessions[iPad].begin(); for(itFriendSession = friendsSessions[iPad].begin(); itFriendSession < friendsSessions[iPad].end(); ++itFriendSession) { @@ -1637,7 +1637,7 @@ bool CPlatformNetworkManagerXbox::GetGameSessionInfo(int iPad, SessionID session sessionInfo->data.isJoinable) { foundSessionInfo->data = sessionInfo->data; - if(foundSessionInfo->displayLabel != NULL) delete [] foundSessionInfo->displayLabel; + if(foundSessionInfo->displayLabel != nullptr) delete [] foundSessionInfo->displayLabel; foundSessionInfo->displayLabel = new wchar_t[100]; memcpy(foundSessionInfo->displayLabel, sessionInfo->displayLabel, 100 * sizeof(wchar_t) ); foundSessionInfo->displayLabelLength = sessionInfo->displayLabelLength; @@ -1672,7 +1672,7 @@ void CPlatformNetworkManagerXbox::ForceFriendsSessionRefresh() m_searchResultsCount[i] = 0; m_lastSearchStartTime[i] = 0; delete m_pSearchResults[i]; - m_pSearchResults[i] = NULL; + m_pSearchResults[i] = nullptr; } } @@ -1699,7 +1699,7 @@ void CPlatformNetworkManagerXbox::removeNetworkPlayer(IQNetPlayer *pQNetPlayer) INetworkPlayer *CPlatformNetworkManagerXbox::getNetworkPlayer(IQNetPlayer *pQNetPlayer) { - return pQNetPlayer ? (INetworkPlayer *)(pQNetPlayer->GetCustomDataValue()) : NULL; + return pQNetPlayer ? (INetworkPlayer *)(pQNetPlayer->GetCustomDataValue()) : nullptr; } diff --git a/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.h b/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.h index 7c6112b4e..2784726c7 100644 --- a/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.h +++ b/Minecraft.Client/Xbox/Network/PlatformNetworkManagerXbox.h @@ -88,7 +88,7 @@ class CPlatformNetworkManagerXbox : public CPlatformNetworkManager, public IQNet GameSessionData m_hostGameSessionData; CGameNetworkManager *m_pGameNetworkManager; public: - virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL); + virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr); private: // TODO 4J Stu - Do we need to be able to have more than one of these? diff --git a/Minecraft.Client/Xbox/Sentient/DynamicConfigurations.cpp b/Minecraft.Client/Xbox/Sentient/DynamicConfigurations.cpp index 327e094c9..086b141ef 100644 --- a/Minecraft.Client/Xbox/Sentient/DynamicConfigurations.cpp +++ b/Minecraft.Client/Xbox/Sentient/DynamicConfigurations.cpp @@ -11,7 +11,7 @@ bool MinecraftDynamicConfigurations::s_bUpdatedConfigs[MinecraftDynamicConfigura MinecraftDynamicConfigurations::EDynamic_Configs MinecraftDynamicConfigurations::s_eCurrentConfig = MinecraftDynamicConfigurations::eDynamic_Config_Max; size_t MinecraftDynamicConfigurations::s_currentConfigSize = 0; size_t MinecraftDynamicConfigurations::s_dataWrittenSize = 0; -byte *MinecraftDynamicConfigurations::s_dataWritten = NULL; +byte *MinecraftDynamicConfigurations::s_dataWritten = nullptr; void MinecraftDynamicConfigurations::Tick() { @@ -57,7 +57,7 @@ void MinecraftDynamicConfigurations::UpdateConfiguration(EDynamic_Configs id) { app.DebugPrintf("DynamicConfig: Attempting to update dynamic configuration %d\n", id); - HRESULT hr = Sentient::SenDynamicConfigGetSize( id, &s_currentConfigSize, &MinecraftDynamicConfigurations::GetSizeCompletedCallback, NULL); + HRESULT hr = Sentient::SenDynamicConfigGetSize( id, &s_currentConfigSize, &MinecraftDynamicConfigurations::GetSizeCompletedCallback, nullptr); switch(hr) { @@ -76,7 +76,7 @@ void MinecraftDynamicConfigurations::UpdateConfiguration(EDynamic_Configs id) break; case E_POINTER: app.DebugPrintf("DynamicConfig: Failed to get size for config as pointer is invalid\n"); - //The out_size pointer is NULL. + //The out_size pointer is nullptr. break; } if(FAILED(hr) ) @@ -97,7 +97,7 @@ void MinecraftDynamicConfigurations::GetSizeCompletedCallback(HRESULT taskResult &s_dataWrittenSize, s_dataWritten, &MinecraftDynamicConfigurations::GetDataCompletedCallback, - NULL + nullptr ); switch(hr) @@ -115,8 +115,8 @@ void MinecraftDynamicConfigurations::GetSizeCompletedCallback(HRESULT taskResult //Sentient is not initialized. You must call SentientInitialize before you call this function. break; case E_POINTER: - app.DebugPrintf("DynamicConfig: Failed to get bytes for config as pointer is NULL\n"); - //The out_size pointer is NULL. + app.DebugPrintf("DynamicConfig: Failed to get bytes for config as pointer is nullptr\n"); + //The out_size pointer is nullptr. break; } if(FAILED(hr) ) @@ -160,7 +160,7 @@ void MinecraftDynamicConfigurations::GetDataCompletedCallback(HRESULT taskResu } delete [] s_dataWritten; - s_dataWritten = NULL; + s_dataWritten = nullptr; s_bUpdatedConfigs[s_eCurrentConfig] = true; UpdateNextConfiguration(); diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientAvatar.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientAvatar.h index dfccfd3b7..524c1bdc0 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientAvatar.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientAvatar.h @@ -108,7 +108,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_avatarInfoList is NULL. + /// E_POINTER: out_avatarInfoList is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -149,7 +149,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_avatarInfo is NULL. + /// E_POINTER: out_avatarInfo is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -192,7 +192,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: avatarInfo.resourceID or avatarInfo.[fe]male.metadata is invalid. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -235,7 +235,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: avatarInfo.resourceID or avatarInfo.[fe]male.assets is invalid. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -278,7 +278,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: avatarInfo.resourceID or avatarInfo.[fe]male.icon is invalid. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -316,7 +316,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: avatarInfo.resourceID or avatarInfo.xml is invalid. - /// E_POINTER: out_avatarExtraInfo is NULL. + /// E_POINTER: out_avatarExtraInfo is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -352,14 +352,14 @@ namespace Sentient // First method, filling a fixed-size buffer: // // wchar_t buffer[1234]; - // SenAvatarXMLGetTitle( xml, loc, _countof(buffer), NULL, buffer ); + // SenAvatarXMLGetTitle( xml, loc, _countof(buffer), nullptr, buffer ); // // Second method, filling a dynamically-allocated buffer: // // size_t bufferLength; - // SenAvatarXMLGetTitle( xml, loc, 0, &bufferLength, NULL ); + // SenAvatarXMLGetTitle( xml, loc, 0, &bufferLength, nullptr ); // wchar_t buffer = new wchar_t[bufferLength]; - // SenAvatarXMLGetTitle( xml, loc, bufferLength, NULL, buffer ); + // SenAvatarXMLGetTitle( xml, loc, bufferLength, nullptr, buffer ); // // Note that bufferLength is in wchars, and includes the terminating nul. // The actual length of the _string_ is (*out_bufferLength - 1). diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientBoxArt.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientBoxArt.h index 096622433..95a8c1881 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientBoxArt.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientBoxArt.h @@ -116,7 +116,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_boxArtInfoList is NULL. + /// E_POINTER: out_boxArtInfoList is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -160,7 +160,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: boxArtInfo.resourceID or boxArtInfo.image is invalid. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -198,7 +198,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: boxArtInfo.resourceID or boxArtInfo.xml is invalid. - /// E_POINTER: out_boxArtExtraInfo is NULL. + /// E_POINTER: out_boxArtExtraInfo is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -236,7 +236,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: boxArtInfo.resourceID or boxArtInfo.xml is invalid. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -263,7 +263,7 @@ namespace Sentient /// /// @param[in] culture /// This is the result of a call to SenCultureFind() or SenCultureGet*(). - /// You may also pass NULL to use the culture set with SenCultureSetCurrent(). + /// You may also pass nullptr to use the culture set with SenCultureSetCurrent(). /// /// @param[in] bufferLength /// Note that bufferLength is in wchars, and needs to _include_ space for the terminating nul. @@ -271,16 +271,16 @@ namespace Sentient /// @param[out] out_bufferLength /// Used to return the actual number of wchars written to the buffer, including the terminating nul. /// The actual length of the _string_ is (*out_bufferLength - 1). - /// Pass @a out_bufferLength = NULL if you don't care about the actual size. + /// Pass @a out_bufferLength = nullptr if you don't care about the actual size. /// /// @param[out] out_buffer /// The buffer to fill in with the string. /// It is assumed that this is preallocated to at least @a bufferLength wchars. - /// Pass @a out_buffer = NULL if you are only interested in finding out the necessary buffer size. + /// Pass @a out_buffer = nullptr if you are only interested in finding out the necessary buffer size. /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_UNEXPECTED: passed a NULL culture without a default culture being set first. + /// E_UNEXPECTED: passed a nullptr culture without a default culture being set first. /// E_INVALIDARG: senXML does not contain parsed XML data. /// E_FAIL: Failed to locate text. /// S_OK: Server call spawned successfully. @@ -291,14 +291,14 @@ namespace Sentient /// First method, filling a fixed-size buffer: /// /// wchar_t buffer[1234]; - /// SenBoxArtXMLGetTitle( xml, culture, _countof(buffer), NULL, buffer ); + /// SenBoxArtXMLGetTitle( xml, culture, _countof(buffer), nullptr, buffer ); /// /// Second method, filling a dynamically-allocated buffer: /// /// size_t bufferLength; - /// SenBoxArtXMLGetTitle( xml, culture, 0, &bufferLength, NULL ); + /// SenBoxArtXMLGetTitle( xml, culture, 0, &bufferLength, nullptr ); /// wchar_t buffer = new wchar_t[bufferLength]; - /// SenBoxArtXMLGetTitle( xml, culture, bufferLength, NULL, buffer ); + /// SenBoxArtXMLGetTitle( xml, culture, bufferLength, nullptr, buffer ); /// /// @related SenBoxArtDownloadXML() /// @related SenXMLParse() @@ -319,7 +319,7 @@ namespace Sentient /// /// @param[in] culture /// This is the result of a call to SenCultureFind() or SenCultureGet*(). - /// You may also pass NULL to use the culture set with SenCultureSetCurrent(). + /// You may also pass nullptr to use the culture set with SenCultureSetCurrent(). /// /// @param[in] bufferLength /// Note that bufferLength is in wchars, and needs to _include_ space for the terminating nul. @@ -327,16 +327,16 @@ namespace Sentient /// @param[out] out_bufferLength /// Used to return the actual number of wchars written to the buffer, including the terminating nul. /// The actual length of the _string_ is (*out_bufferLength - 1). - /// Pass @a out_bufferLength = NULL if you don't care about the actual size. + /// Pass @a out_bufferLength = nullptr if you don't care about the actual size. /// /// @param[out] out_buffer /// The buffer to fill in with the string. /// It is assumed that this is preallocated to at least @a bufferLength wchars. - /// Pass @a out_buffer = NULL if you are only interested in finding out the necessary buffer size. + /// Pass @a out_buffer = nullptr if you are only interested in finding out the necessary buffer size. /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_UNEXPECTED: passed a NULL culture without a default culture being set first. + /// E_UNEXPECTED: passed a nullptr culture without a default culture being set first. /// E_INVALIDARG: senXML does not contain parsed XML data. /// E_FAIL: Failed to locate text. /// S_OK: Server call spawned successfully. @@ -347,14 +347,14 @@ namespace Sentient /// First method, filling a fixed-size buffer: /// /// wchar_t buffer[1234]; - /// SenBoxArtXMLGetDescription( xml, culture, _countof(buffer), NULL, buffer ); + /// SenBoxArtXMLGetDescription( xml, culture, _countof(buffer), nullptr, buffer ); /// /// Second method, filling a dynamically-allocated buffer: /// /// size_t bufferLength; - /// SenBoxArtXMLGetDescription( xml, culture, 0, &bufferLength, NULL ); + /// SenBoxArtXMLGetDescription( xml, culture, 0, &bufferLength, nullptr ); /// wchar_t buffer = new wchar_t[bufferLength]; - /// SenBoxArtXMLGetDescription( xml, culture, bufferLength, NULL, buffer ); + /// SenBoxArtXMLGetDescription( xml, culture, bufferLength, nullptr, buffer ); /// /// @related SenBoxArtDownloadXML() /// @related SenXMLParse() @@ -390,7 +390,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: boxArtInfo.resourceID or boxArtInfo.image is invalid. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientConfig.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientConfig.h index 81c2f3cc6..0aca08ef3 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientConfig.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientConfig.h @@ -55,7 +55,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: out_configInfo is NULL. + /// E_POINTER: out_configInfo is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -95,7 +95,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// E_INVALIDARG: configInfo.resourceID or configInfo.config is invalid. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientCore.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientCore.h index f86eb92ae..4d3815d2a 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientCore.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientCore.h @@ -42,7 +42,7 @@ 3. Many functions are designed for asynchronous use, and will internally create a task that will only finish after feedback from the server. - a. These functions can be either blocking or asynchronous. If the callback pointer is NULL + a. These functions can be either blocking or asynchronous. If the callback pointer is nullptr then it is a blocking call. b. If the call is asynchronous, then it will always return instantly, and will return S_OK if a task has been created. diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientCultureBackCompat_SenClientUGC.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientCultureBackCompat_SenClientUGC.h index b36fd6e5e..02e255e86 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientCultureBackCompat_SenClientUGC.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientCultureBackCompat_SenClientUGC.h @@ -25,8 +25,8 @@ namespace Sentient /// /// @param[in] culture /// This is the result of a call to SenCultureFind() or SenCultureGet*(). - /// You may also pass NULL to use the culture set with SenCultureSetCurrent(). - /// May be NULL for default culture. + /// You may also pass nullptr to use the culture set with SenCultureSetCurrent(). + /// May be nullptr for default culture. /// /// @param[in] maxResults /// Used to indicate the number of items to be returned by @a out_feedInfo. diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientDynamicConfig.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientDynamicConfig.h index d6c5cb648..7b652aaef 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientDynamicConfig.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientDynamicConfig.h @@ -34,7 +34,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: size is NULL. + /// E_POINTER: size is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -66,7 +66,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: size is NULL. + /// E_POINTER: size is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -109,7 +109,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -149,7 +149,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: out_data is NULL. + /// E_POINTER: out_data is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientFame.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientFame.h index 1e823075f..8f07b1cef 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientFame.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientFame.h @@ -215,7 +215,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_userFameVIPArray is NULL. + /// E_POINTER: out_userFameVIPArray is nullptr. /// SENTIENT_E_TOO_MANY_CALLS: This call has been rejected to avoid excessive server load. Try again later. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. @@ -243,7 +243,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_fameVIPData is NULL. + /// E_POINTER: out_fameVIPData is nullptr. /// SENTIENT_S_OPERATION_IN_PROGRESS: The call could not be completed immediately and out_fameVIPData has not been filled in. /// S_OK: The operation completed successfully. /// @@ -304,8 +304,8 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_entryArray or out_leaderboardResults is NULL. - /// E_INVALIDARG: userCallback is NULL and out_senHandle is non-NULL. Task handles are not supported for synchronous requests. + /// E_POINTER: out_entryArray or out_leaderboardResults is nullptr. + /// E_INVALIDARG: userCallback is nullptr and out_senHandle is non-nullptr. Task handles are not supported for synchronous requests. /// SENTIENT_E_TOO_MANY_CALLS: This call has been rejected to avoid excessive server load. Try again later. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. @@ -331,7 +331,7 @@ namespace Sentient /// /// @return SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_awardData is NULL. + /// E_POINTER: out_awardData is nullptr. /// SENTIENT_S_OPERATION_IN_PROGRESS: The call could not be completed immediately and out_awardData has not been filled in. /// S_FALSE: The operation completed successfully but there were no awards to report. out_awardData has not been filled in. /// S_OK: The operation completed successfully and there was a valid award to report. out_awardData contains information about the award. @@ -351,7 +351,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: out_timeRemaining is NULL. + /// E_POINTER: out_timeRemaining is nullptr. /// SENTIENT_S_OPERATION_IN_PROGRESS: The call could not be completed immediately and out_timeRemaining has not been filled in. /// E_FAIL: Internal failure. Check log for output. /// S_OK: Call completed successfully and out_timeRemaining has been filled in. @@ -373,7 +373,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_timeRemaining is NULL. + /// E_POINTER: out_timeRemaining is nullptr. /// SENTIENT_S_OPERATION_IN_PROGRESS: The call could not be completed immediately and out_timeRemaining has not been filled in. /// S_FALSE: The VIP level of the supplied user does not expire. out_timeRemaining has not been filled in. /// E_FAIL: Internal failure. Check log for output. @@ -400,7 +400,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: out_name is NULL. + /// E_POINTER: out_name is nullptr. /// E_INVALIDARG: vipLevel is outside the range of known VIP levels. /// SENTIENT_S_OPERATION_IN_PROGRESS: The call could not be completed immediately and out_name has not been filled in. /// S_OK: The operation completed successfully. @@ -423,7 +423,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_count is NULL. + /// E_POINTER: out_count is nullptr. /// SENTIENT_S_OPERATION_IN_PROGRESS: The call could not be completed immediately and out_count has not been filled in. /// E_FAIL: Internal failure. Check log for output. /// S_OK: The operation completed successfully. @@ -456,7 +456,7 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_POINTER: out_dataCount or out_displayData is NULL. + /// E_POINTER: out_dataCount or out_displayData is nullptr. /// E_INVALIDARG: startIndex is greater than the total number of items available. /// SENTIENT_S_OPERATION_IN_PROGRESS: The call could not be completed immediately and output parameters have not been filled in. /// E_FAIL: Internal failure. Check log for output. @@ -553,8 +553,8 @@ namespace Sentient /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. /// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call. - /// E_INVALIDARG: Either userCallback is NULL and out_senHandle is non-NULL, or participantCount is less than 2. - /// E_POINTER: participants is NULL. + /// E_INVALIDARG: Either userCallback is nullptr and out_senHandle is non-nullptr, or participantCount is less than 2. + /// E_POINTER: participants is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientUGC.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientUGC.h index da1b1f65d..b40245710 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientUGC.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientUGC.h @@ -97,7 +97,7 @@ namespace Sentient // metadata for a lot of UGCs at once. // Note: if a level has been uploaded with main data before, and the creator // wants to just modify the metadata, they can upload the metadata with the - // maindatablobs being NULL. + // maindatablobs being nullptr. // NOTE: for large items, use the SenUGCUploadMainData method with the SenUGCProgressInfo // signature so you can get the running progress and a cancellation token // to abort the upload (allowing UI for the user, etc) @@ -159,7 +159,7 @@ namespace Sentient // be used to abort the upload. This is useful for large uploads where // you may want to allow the user to cancel. // NOTE: This call is asynchronous ONLY and will error for synchronous - // attempts with a NULL param for userCallback. + // attempts with a nullptr param for userCallback. // There are multiple data blobs supported (the exact number is defined in // SenUGCMainData_NrBlobs) on subsequent calls. Slot zero is to be used by a // game to store a preview thumbnail, which can then be downloaded without @@ -172,7 +172,7 @@ namespace Sentient // metadata for a lot of UGCs at once. // NOTE: if a level has been uploaded with main data before, and the creator // wants to just modify the metadata, they can upload the metadata with the - // main data blob being NULL. + // main data blob being nullptr. // NOTE: If a creator uploads a data blob again, it will overwrite the previous // stored blob with the new one. //************************************ @@ -848,8 +848,8 @@ namespace Sentient /// /// @param[in] culture /// This is the result of a call to SenCultureFind() or SenCultureGet*(). - /// You may also pass NULL to use the culture set with SenCultureSetCurrent(). - /// May be NULL for default culture. + /// You may also pass nullptr to use the culture set with SenCultureSetCurrent(). + /// May be nullptr for default culture. /// /// @param[in] maxResults /// Used to indicate the number of items to be returned by @a out_feedInfo. diff --git a/Minecraft.Client/Xbox/Sentient/Include/SenClientUser.h b/Minecraft.Client/Xbox/Sentient/Include/SenClientUser.h index cf3ef0b3e..4c48ee501 100644 --- a/Minecraft.Client/Xbox/Sentient/Include/SenClientUser.h +++ b/Minecraft.Client/Xbox/Sentient/Include/SenClientUser.h @@ -61,7 +61,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: out_isInRole is NULL. + /// E_POINTER: out_isInRole is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// @@ -91,7 +91,7 @@ namespace Sentient /// /// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include: /// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first. - /// E_POINTER: out_isInRole is NULL. + /// E_POINTER: out_isInRole is nullptr. /// E_FAIL: Failed to spawn server call. /// S_OK: Server call spawned successfully. /// diff --git a/Minecraft.Client/Xbox/Sentient/SentientManager.cpp b/Minecraft.Client/Xbox/Sentient/SentientManager.cpp index bf48c400a..49b0c26af 100644 --- a/Minecraft.Client/Xbox/Sentient/SentientManager.cpp +++ b/Minecraft.Client/Xbox/Sentient/SentientManager.cpp @@ -52,7 +52,7 @@ HRESULT CSentientManager::Tick() m_lastHeartbeat = currentTime; for(DWORD i = 0; i < XUSER_MAX_COUNT; ++i) { - if(Minecraft::GetInstance()->localplayers[i] != NULL) + if(Minecraft::GetInstance()->localplayers[i] != nullptr) { SenStatHeartBeat(i, m_lastHeartbeat - m_initialiseTime); } @@ -63,7 +63,7 @@ HRESULT CSentientManager::Tick() { for(DWORD i = 0; i < XUSER_MAX_COUNT; ++i) { - if(Minecraft::GetInstance()->localplayers[i] != NULL && m_fLevelStartTime[i] - currentTime > 60) + if(Minecraft::GetInstance()->localplayers[i] != nullptr && m_fLevelStartTime[i] - currentTime > 60) { Flush(); } @@ -257,7 +257,7 @@ INT CSentientManager::GetMode(DWORD dwUserId) Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->localplayers[dwUserId] != NULL && pMinecraft->localplayers[dwUserId]->level != NULL && pMinecraft->localplayers[dwUserId]->level->getLevelData() != NULL ) + if( pMinecraft->localplayers[dwUserId] != nullptr && pMinecraft->localplayers[dwUserId]->level != nullptr && pMinecraft->localplayers[dwUserId]->level->getLevelData() != nullptr ) { GameType *gameType = pMinecraft->localplayers[dwUserId]->level->getLevelData()->getGameType(); @@ -329,7 +329,7 @@ INT CSentientManager::GetSubLevelId(DWORD dwUserId) Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft->localplayers[dwUserId] != NULL) + if(pMinecraft->localplayers[dwUserId] != nullptr) { switch(pMinecraft->localplayers[dwUserId]->dimension) { diff --git a/Minecraft.Client/Xbox/Sentient/SentientStats.cpp b/Minecraft.Client/Xbox/Sentient/SentientStats.cpp index 361d18eed..ffa9392d8 100644 --- a/Minecraft.Client/Xbox/Sentient/SentientStats.cpp +++ b/Minecraft.Client/Xbox/Sentient/SentientStats.cpp @@ -37,8 +37,8 @@ BOOL SenStatPlayerSessionStart ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 10; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -67,8 +67,8 @@ BOOL SenStatPlayerSessionExit ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 5; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -93,8 +93,8 @@ BOOL SenStatHeartBeat ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 1; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -136,8 +136,8 @@ BOOL SenStatLevelStart ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 18; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -172,8 +172,8 @@ BOOL SenStatLevelExit ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 11; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -209,8 +209,8 @@ BOOL SenStatLevelSaveOrCheckpoint ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 12; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -253,8 +253,8 @@ BOOL SenStatLevelResume ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 19; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -285,8 +285,8 @@ BOOL SenStatPauseOrInactive ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 7; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -317,8 +317,8 @@ BOOL SenStatUnpauseOrActive ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 7; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -351,8 +351,8 @@ BOOL SenStatMenuShown ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 9; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -385,8 +385,8 @@ BOOL SenStatAchievementUnlocked ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 9; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -419,8 +419,8 @@ BOOL SenStatMediaShareUpload ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 9; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -453,8 +453,8 @@ BOOL SenStatUpsellPresented ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 9; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -488,8 +488,8 @@ BOOL SenStatUpsellResponded ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 10; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -607,8 +607,8 @@ BOOL SenStatSkinChanged ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 8; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -639,8 +639,8 @@ BOOL SenStatBanLevel ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 7; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -671,8 +671,8 @@ BOOL SenStatUnBanLevel ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 7; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing @@ -705,8 +705,8 @@ BOOL SenStatTexturePackChanged ( DWORD dwUserID, INT SecondsSinceI st.dwNumProperties = 9; st.arrProperties = (CHAR*)&LocalStruct; st.dwNumValues = 0; - st.arrValues = NULL; - st.arrValueFlags = NULL; + st.arrValues = nullptr; + st.arrValueFlags = nullptr; #ifdef SEN_LOGTELEMETRY // if we're in debug build with logging then log the stat to a file for testing diff --git a/Minecraft.Client/Xbox/Social/SocialManager.cpp b/Minecraft.Client/Xbox/Social/SocialManager.cpp index b7a108bc7..b89fda709 100644 --- a/Minecraft.Client/Xbox/Social/SocialManager.cpp +++ b/Minecraft.Client/Xbox/Social/SocialManager.cpp @@ -67,14 +67,14 @@ CSocialManager::CSocialManager() // WESTY : Not sure if we even need to get social access key! /* - m_pAccessKeyText = NULL; + m_pAccessKeyText = nullptr; m_dwAccessKeyTextSize = 0; */ - m_pMainImageBuffer = NULL; + m_pMainImageBuffer = nullptr; m_dwMainImageBufferSize = 0; - m_PostPreviewImage.pBytes = NULL; + m_PostPreviewImage.pBytes = nullptr; m_dwCurrRequestUser = -1; ZeroMemory(m_wchTitleA,sizeof(WCHAR)*MAX_SOCIALPOST_CAPTION); @@ -304,14 +304,14 @@ bool CSocialManager::AreAllUsersAllowedToPostImages() void CSocialManager::DestroyMainPostImage() { delete [] m_PostImageParams.pFullImage; - m_PostImageParams.pFullImage=NULL; + m_PostImageParams.pFullImage=nullptr; m_dwMainImageBufferSize=0; } void CSocialManager::DestroyPreviewPostImage() { XPhysicalFree( (void *)m_PostPreviewImage.pBytes ); - m_PostPreviewImage.pBytes = NULL; + m_PostPreviewImage.pBytes = nullptr; } void CSocialManager::SetSocialPostText(LPCWSTR pwchTitle, LPCWSTR pwchCaption, LPCWSTR pwchDesc) @@ -459,7 +459,7 @@ bool CSocialManager::PostImageToSocialNetwork( ESocialNetwork eSocialNetwork, DW bool bResult = false; - PBYTE pbData=NULL; + PBYTE pbData=nullptr; DWORD dwDataSize; app.GetScreenshot(dwUserIndex,&pbData,&dwDataSize); @@ -536,10 +536,10 @@ bool CSocialManager::GetSocialNetworkAccessKey( ESocialNetwork eSocialNetwork, D DWORD dwResult; // Ensure that we free any previously used access key buffer. - if ( m_pAccessKeyText != NULL ) + if ( m_pAccessKeyText != nullptr ) { delete [] m_pAccessKeyText; - m_pAccessKeyText = NULL; + m_pAccessKeyText = nullptr; } // Get social network ID and permissions. @@ -554,39 +554,39 @@ bool CSocialManager::GetSocialNetworkAccessKey( ESocialNetwork eSocialNetwork, D { if ( bUsingKinect ) { - dwResult = XShowNuiSocialGetUserToken( dwUserTrackingIndex, dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), NULL ); + dwResult = XShowNuiSocialGetUserToken( dwUserTrackingIndex, dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), nullptr ); // If buffer for key text was not large enough, reallocate buffer that is large enough and try again. if ( dwResult == ERROR_INSUFFICIENT_BUFFER ) { delete [] m_pAccessKeyText; m_pAccessKeyText = new wchar_t[ m_dwAccessKeyTextSize ]; - dwResult = XShowNuiSocialGetUserToken( dwUserTrackingIndex, dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), NULL ); + dwResult = XShowNuiSocialGetUserToken( dwUserTrackingIndex, dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), nullptr ); } } else // using standard controller interface. { - dwResult = XShowSocialGetUserToken( dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), NULL ); + dwResult = XShowSocialGetUserToken( dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), nullptr ); // If buffer for key text was not large enough, reallocate buffer that is large enough and try again. if ( dwResult == ERROR_INSUFFICIENT_BUFFER ) { delete [] m_pAccessKeyText; m_pAccessKeyText = new wchar_t[ m_dwAccessKeyTextSize ]; - dwResult = XShowSocialGetUserToken( dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), NULL ); + dwResult = XShowSocialGetUserToken( dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), nullptr ); } } } else // we are trying to obtain cached user access key. { - dwResult = XSocialGetUserToken( dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), NULL ); + dwResult = XSocialGetUserToken( dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), nullptr ); // If buffer for key text was not large enough, reallocate buffer that is large enough and try again. if ( dwResult == ERROR_INSUFFICIENT_BUFFER ) { delete [] m_pAccessKeyText; m_pAccessKeyText = new wchar_t[ m_dwAccessKeyTextSize ]; - dwResult = XSocialGetUserToken( dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), NULL ); + dwResult = XSocialGetUserToken( dwUserIndex, dwSocialNetworkID, pRequiredPermissions, m_pAccessKeyText, &( m_dwAccessKeyTextSize ), nullptr ); } } diff --git a/Minecraft.Client/Xbox/XML/ATGXmlParser.cpp b/Minecraft.Client/Xbox/XML/ATGXmlParser.cpp index 96b6bfc83..badade553 100644 --- a/Minecraft.Client/Xbox/XML/ATGXmlParser.cpp +++ b/Minecraft.Client/Xbox/XML/ATGXmlParser.cpp @@ -27,7 +27,7 @@ XMLParser::XMLParser() { m_pWritePtr = m_pWriteBuf; m_pReadPtr = m_pReadBuf; - m_pISAXCallback = NULL; + m_pISAXCallback = nullptr; m_hFile = INVALID_HANDLE_VALUE; } @@ -49,7 +49,7 @@ VOID XMLParser::FillBuffer() m_pReadPtr = m_pReadBuf; - if( m_hFile == NULL ) + if( m_hFile == nullptr ) { if( m_uInXMLBufferCharsLeft > XML_READ_BUFFER_SIZE ) NChars = XML_READ_BUFFER_SIZE; @@ -62,7 +62,7 @@ VOID XMLParser::FillBuffer() } else { - if( !ReadFile( m_hFile, m_pReadBuf, XML_READ_BUFFER_SIZE, &NChars, NULL )) + if( !ReadFile( m_hFile, m_pReadBuf, XML_READ_BUFFER_SIZE, &NChars, nullptr )) { return; } @@ -359,7 +359,7 @@ HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail ) // Read more from the file FillBuffer(); - // We are at EOF if it is still NULL + // We are at EOF if it is still nullptr if ( ( m_pReadPtr[0] == '\0' ) && ( m_pReadPtr[1] == '\0' ) ) { if( !bOkToFail ) @@ -861,7 +861,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) { HRESULT hr; - if( m_pISAXCallback == NULL ) + if( m_pISAXCallback == nullptr ) return E_NOINTERFACE; m_pISAXCallback->m_LineNum = 1; @@ -874,9 +874,9 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) m_pReadBuf[ 0 ] = '\0'; m_pReadBuf[ 1 ] = '\0'; - m_pInXMLBuffer = NULL; + m_pInXMLBuffer = nullptr; m_uInXMLBufferCharsLeft = 0; - m_hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL ); + m_hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr ); if( m_hFile == INVALID_HANDLE_VALUE ) { @@ -899,7 +899,7 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename ) m_hFile = INVALID_HANDLE_VALUE; // we no longer own strFilename, so un-set it - m_pISAXCallback->m_strFilename = NULL; + m_pISAXCallback->m_strFilename = nullptr; return hr; } @@ -912,7 +912,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) { HRESULT hr; - if( m_pISAXCallback == NULL ) + if( m_pISAXCallback == nullptr ) return E_NOINTERFACE; m_pISAXCallback->m_LineNum = 1; @@ -925,7 +925,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) m_pReadBuf[ 0 ] = '\0'; m_pReadBuf[ 1 ] = '\0'; - m_hFile = NULL; + m_hFile = nullptr; m_pInXMLBuffer = strBuffer; m_uInXMLBufferCharsLeft = uBufferSize; m_dwCharsTotal = uBufferSize; @@ -934,7 +934,7 @@ HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize ) hr = MainParseLoop(); // we no longer own strFilename, so un-set it - m_pISAXCallback->m_strFilename = NULL; + m_pISAXCallback->m_strFilename = nullptr; return hr; } diff --git a/Minecraft.Client/Xbox/XML/ATGXmlParser.h b/Minecraft.Client/Xbox/XML/ATGXmlParser.h index 75142e3e3..12f597372 100644 --- a/Minecraft.Client/Xbox/XML/ATGXmlParser.h +++ b/Minecraft.Client/Xbox/XML/ATGXmlParser.h @@ -138,7 +138,7 @@ class XMLParser DWORD m_dwCharsTotal; DWORD m_dwCharsConsumed; - BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing NULL + BYTE m_pReadBuf[ XML_READ_BUFFER_SIZE + 2 ]; // room for a trailing nullptr WCHAR m_pWriteBuf[ XML_WRITE_BUFFER_SIZE ]; BYTE* m_pReadPtr; diff --git a/Minecraft.Client/Xbox/XML/xmlFilesCallback.h b/Minecraft.Client/Xbox/XML/xmlFilesCallback.h index 2ea670dfb..7571706e3 100644 --- a/Minecraft.Client/Xbox/XML/xmlFilesCallback.h +++ b/Minecraft.Client/Xbox/XML/xmlFilesCallback.h @@ -47,7 +47,7 @@ class xmlMojangCallback : public ATG::ISAXCallback { ZeroMemory(wTemp,sizeof(WCHAR)*35); wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); - xuid=_wcstoui64(wTemp,NULL,10); + xuid=_wcstoui64(wTemp,nullptr,10); } } else if (_wcsicmp(wAttName,L"cape")==0) @@ -138,7 +138,7 @@ class xmlConfigCallback : public ATG::ISAXCallback #ifdef _XBOX iValue=_wtoi(wValue); #else - iValue=wcstol(wValue, NULL, 10); + iValue=wcstol(wValue, nullptr, 10); #endif } } @@ -220,7 +220,7 @@ class xmlDLCInfoCallback : public ATG::ISAXCallback { ZeroMemory(wTemp,sizeof(WCHAR)*35); wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); - uiSortIndex=wcstoul(wTemp,NULL,16); + uiSortIndex=wcstoul(wTemp,nullptr,16); } } else if (_wcsicmp(wAttName,L"Banner")==0) @@ -236,7 +236,7 @@ class xmlDLCInfoCallback : public ATG::ISAXCallback { ZeroMemory(wTemp,sizeof(WCHAR)*35); wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); - ullFull=_wcstoui64(wTemp,NULL,16); + ullFull=_wcstoui64(wTemp,nullptr,16); } } else if (_wcsicmp(wAttName,L"Trial")==0) @@ -245,7 +245,7 @@ class xmlDLCInfoCallback : public ATG::ISAXCallback { ZeroMemory(wTemp,sizeof(WCHAR)*35); wcsncpy_s( wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); - ullTrial=_wcstoui64(wTemp,NULL,16); + ullTrial=_wcstoui64(wTemp,nullptr,16); } } else if (_wcsicmp(wAttName,L"FirstSkin")==0) @@ -286,7 +286,7 @@ class xmlDLCInfoCallback : public ATG::ISAXCallback #ifdef _XBOX iConfig=_wtoi(wConfig); #else - iConfig=wcstol(wConfig, NULL, 10); + iConfig=wcstol(wConfig, nullptr, 10); #endif } } diff --git a/Minecraft.Client/Xbox/Xbox_App.cpp b/Minecraft.Client/Xbox/Xbox_App.cpp index eebeb827f..a717540bc 100644 --- a/Minecraft.Client/Xbox/Xbox_App.cpp +++ b/Minecraft.Client/Xbox/Xbox_App.cpp @@ -284,10 +284,10 @@ CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() m_bRead_TMS_XUIDS_XML=false; m_bRead_TMS_Config_XML=false; m_bRead_TMS_DLCINFO_XML=false; - m_pXuidsFileBuffer=NULL; + m_pXuidsFileBuffer=nullptr; m_dwXuidsFileSize=0; ZeroMemory(m_ScreenshotBuffer,sizeof(LPD3DXBUFFER)*XUSER_MAX_COUNT); - m_ThumbnailBuffer=NULL; + m_ThumbnailBuffer=nullptr; #ifdef _DEBUG_MENUS_ENABLED debugOverlayCreated = false; #endif @@ -301,12 +301,12 @@ CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() m_bContainerMenuDisplayed[i]=false; m_bIgnoreAutosaveMenuDisplayed[i]=false; m_bIgnorePlayerJoinMenuDisplayed[i]=false; - m_hCurrentScene[i]=NULL; - m_hFirstScene[i]=NULL; + m_hCurrentScene[i]=nullptr; + m_hFirstScene[i]=nullptr; } m_titleDeploymentType = XTITLE_DEPLOYMENT_DOWNLOAD; - DWORD dwResult = XTitleGetDeploymentType(&m_titleDeploymentType, NULL); + DWORD dwResult = XTitleGetDeploymentType(&m_titleDeploymentType, nullptr); if( dwResult == ERROR_SUCCESS ) { switch( m_titleDeploymentType ) @@ -658,7 +658,7 @@ void CConsoleMinecraftApp::GetPreviewImage(int iPad,XSOCIAL_PREVIEWIMAGE *previe preview->pBytes = (BYTE *)XPhysicalAlloc(sizeBytes, MAXULONG_PTR, 0, PAGE_READWRITE | PAGE_WRITECOMBINE ); memcpy( (void *)preview->pBytes, (void *)m_PreviewBuffer[iPad].pBytes, sizeBytes ); XPhysicalFree((LPVOID)m_PreviewBuffer[iPad].pBytes); - m_PreviewBuffer[iPad].pBytes = NULL; + m_PreviewBuffer[iPad].pBytes = nullptr; } void CConsoleMinecraftApp::CaptureScreenshot(int iPad) @@ -678,7 +678,7 @@ HRESULT CConsoleMinecraftApp::LoadXuiResources() HRESULT hr; // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); //#ifdef _CONTENT_PACKAGE @@ -894,7 +894,7 @@ HRESULT CConsoleMinecraftApp::LoadXuiResources() // int iStringC=0; // LPCWSTR lpTempString; // - // while((lpTempString=StringTable.Lookup(iStringC))!=NULL) + // while((lpTempString=StringTable.Lookup(iStringC))!=nullptr) // { // DebugPrintf("STRING %d = ",iStringC); // OutputDebugStringW(lpTempString); @@ -914,17 +914,17 @@ HRESULT CConsoleMinecraftApp::LoadXuiResources() wsprintfW(szResourceLocator,L"section://%X,%s#%s",c_ModuleHandle,L"media", L"media/"); if(RenderManager.IsHiDef()) { - hr=LoadFirstScene( szResourceLocator, L"xuiscene_base.xur", NULL, &mainBaseScene ); + hr=LoadFirstScene( szResourceLocator, L"xuiscene_base.xur", nullptr, &mainBaseScene ); } else { if(RenderManager.IsWidescreen()) { - hr=LoadFirstScene( szResourceLocator, L"xuiscene_base.xur", NULL, &mainBaseScene ); + hr=LoadFirstScene( szResourceLocator, L"xuiscene_base.xur", nullptr, &mainBaseScene ); } else { - hr=LoadFirstScene( szResourceLocator, L"xuiscene_base_480.xur", NULL, &mainBaseScene ); + hr=LoadFirstScene( szResourceLocator, L"xuiscene_base_480.xur", nullptr, &mainBaseScene ); } } if( FAILED(hr) ) app.FatalLoadError(); @@ -989,7 +989,7 @@ HRESULT CConsoleMinecraftApp::RegisterFont(eFont eFontLanguage,eFont eFontFallba HRESULT hr=S_OK; const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); wsprintfW(szResourceLocator,L"section://%X,%s#%s",c_ModuleHandle,L"media", wchTypefaceLocatorA[eFontLanguage]); // 4J Stu - Check that the font file actually exists @@ -1003,7 +1003,7 @@ HRESULT CConsoleMinecraftApp::RegisterFont(eFont eFontLanguage,eFont eFontFallba { if(eFontFallback!=eFont_None) { - hr = RegisterDefaultTypeface( wchTypefaceA[eFontLanguage],szResourceLocator,NULL,0.0f,wchTypefaceA[eFontFallback]); + hr = RegisterDefaultTypeface( wchTypefaceA[eFontLanguage],szResourceLocator,nullptr,0.0f,wchTypefaceA[eFontFallback]); } else { @@ -1410,7 +1410,7 @@ void CConsoleMinecraftApp::OverrideFontRenderer(bool set, bool immediate) } else { - XuiFontSetRenderer( NULL ); + XuiFontSetRenderer( nullptr ); } m_bFontRendererOverridden = set; @@ -1451,7 +1451,7 @@ void CConsoleMinecraftApp::CaptureSaveThumbnail() void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize) { // on a save caused by a create world, the thumbnail capture won't have happened - if(m_ThumbnailBuffer!=NULL) + if(m_ThumbnailBuffer!=nullptr) { if( pbData ) { @@ -1460,28 +1460,28 @@ void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize) memcpy(*pbData,m_ThumbnailBuffer->GetBufferPointer(),*pdwSize); } m_ThumbnailBuffer->Release(); - m_ThumbnailBuffer=NULL; + m_ThumbnailBuffer=nullptr; } } void CConsoleMinecraftApp::ReleaseSaveThumbnail() { - if(m_ThumbnailBuffer!=NULL) + if(m_ThumbnailBuffer!=nullptr) { m_ThumbnailBuffer->Release(); - m_ThumbnailBuffer=NULL; + m_ThumbnailBuffer=nullptr; } } void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) { // on a save caused by a create world, the thumbnail capture won't have happened - if(m_ScreenshotBuffer[iPad]!=NULL) + if(m_ScreenshotBuffer[iPad]!=nullptr) { *pbData= new BYTE [m_ScreenshotBuffer[iPad]->GetBufferSize()]; *pdwSize=m_ScreenshotBuffer[iPad]->GetBufferSize(); memcpy(*pbData,m_ScreenshotBuffer[iPad]->GetBufferPointer(),*pdwSize); m_ScreenshotBuffer[iPad]->Release(); - m_ScreenshotBuffer[iPad]=NULL; + m_ScreenshotBuffer[iPad]=nullptr; } } @@ -1492,13 +1492,13 @@ void CConsoleMinecraftApp::EnableDebugOverlay(bool enable,int iPad) if(enable && !debugOverlayCreated) { - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; wsprintfW(szResourceLocator,L"section://%X,%s#%s",c_ModuleHandle,L"media", L"media/"); - hr = XuiSceneCreate(szResourceLocator, L"xuiscene_debugoverlay.xur", NULL, &m_hDebugOverlay); + hr = XuiSceneCreate(szResourceLocator, L"xuiscene_debugoverlay.xur", nullptr, &m_hDebugOverlay); debugContainerScene.AddChild(m_hDebugOverlay); debugContainerScene.SetShow(false); @@ -1644,7 +1644,7 @@ WCHAR *CConsoleMinecraftApp::GetSceneName(EUIScene eScene,bool bAppendToName,boo return m_SceneName; } -HRESULT CConsoleMinecraftApp::NavigateToScene(int iPad,EUIScene eScene, void *initData /* = NULL */, bool forceUsePad /*= false*/, BOOL bStayVisible /* = FALSE */, HXUIOBJ *phResultingScene /*= NULL*/ ) +HRESULT CConsoleMinecraftApp::NavigateToScene(int iPad,EUIScene eScene, void *initData /* = nullptr */, bool forceUsePad /*= false*/, BOOL bStayVisible /* = FALSE */, HXUIOBJ *phResultingScene /*= nullptr*/ ) { ASSERT(m_bDefaultTypefaceRegistered); ASSERT(m_bSkinLoaded); @@ -1690,7 +1690,7 @@ HRESULT CConsoleMinecraftApp::NavigateToScene(int iPad,EUIScene eScene, void *in } // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); + const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr); HXUIOBJ hScene; HRESULT hr; @@ -1701,7 +1701,7 @@ HRESULT CConsoleMinecraftApp::NavigateToScene(int iPad,EUIScene eScene, void *in // If the init data is null, put the player pad in there - if(initData==NULL) + if(initData==nullptr) { initData = &iPad; } @@ -1843,7 +1843,7 @@ HRESULT CConsoleMinecraftApp::NavigateToScene(int iPad,EUIScene eScene, void *in m_bPauseMenuDisplayed[iPad] = true; Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad]; @@ -1883,7 +1883,7 @@ HRESULT CConsoleMinecraftApp::NavigateToScene(int iPad,EUIScene eScene, void *in break; } - if(phResultingScene!=NULL) + if(phResultingScene!=nullptr) { *phResultingScene=hScene; } @@ -1997,7 +1997,7 @@ HRESULT CConsoleMinecraftApp::CloseXuiScenes(int iPad, bool forceUsePad /*= fals } Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft != NULL && pMinecraft->localgameModes[iPad] != NULL ) + if(pMinecraft != nullptr && pMinecraft->localgameModes[iPad] != nullptr ) { TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[iPad]; @@ -2132,7 +2132,7 @@ HRESULT CConsoleMinecraftApp::RemoveBackScene(int iPad) } } - XuiSceneSetBackScene(hBack, NULL); + XuiSceneSetBackScene(hBack, nullptr); XuiDestroyObject( hBack ); } } @@ -2163,7 +2163,7 @@ HRESULT CConsoleMinecraftApp::NavigateToHomeMenu() // unload any texture pack audio // if there is audio in use, clear out the audio, and unmount the pack TexturePack *pTexPack=Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=NULL; + DLCTexturePack *pDLCTexPack=nullptr; if(pTexPack->hasAudio()) { @@ -2179,11 +2179,11 @@ HRESULT CConsoleMinecraftApp::NavigateToHomeMenu() // need to stop the streaming audio - by playing streaming audio from the default texture pack now pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0); - if(pDLCTexPack->m_pStreamedWaveBank!=NULL) + if(pDLCTexPack->m_pStreamedWaveBank!=nullptr) { pDLCTexPack->m_pStreamedWaveBank->Destroy(); } - if(pDLCTexPack->m_pSoundBank!=NULL) + if(pDLCTexPack->m_pSoundBank!=nullptr) { pDLCTexPack->m_pSoundBank->Destroy(); } @@ -2193,7 +2193,7 @@ HRESULT CConsoleMinecraftApp::NavigateToHomeMenu() g_NetworkManager.ForceFriendsSessionRefresh(); - hr = NavigateToScene(XUSER_INDEX_ANY,eUIScene_MainMenu,NULL); + hr = NavigateToScene(XUSER_INDEX_ANY,eUIScene_MainMenu,nullptr); return hr; } @@ -2217,7 +2217,7 @@ void CConsoleMinecraftApp::SetChatTextDisplayed(int iPad, bool bVal) void CConsoleMinecraftApp::ReloadChatScene(int iPad, bool bJoining /*= false*/, bool bForce /*= false*/) { - if(m_hFirstChatScene[iPad] == NULL || m_hCurrentChatScene[iPad] == NULL) return; + if(m_hFirstChatScene[iPad] == nullptr || m_hCurrentChatScene[iPad] == nullptr) return; // Re-create the chat scene so it is the correct size. It starts without any visible lines. BOOL chatSceneVisible = FALSE; @@ -2236,7 +2236,7 @@ void CConsoleMinecraftApp::ReloadChatScene(int iPad, bool bJoining /*= false*/, { if( m_hFirstChatScene[iPad] != m_hCurrentChatScene[iPad] ) XuiSceneNavigateBack(m_hCurrentChatScene[iPad], m_hFirstChatScene[iPad],iPad); m_hCurrentChatScene[iPad] = m_hFirstChatScene[iPad]; - app.NavigateToScene(iPad,eUIComponent_Chat,NULL,true); + app.NavigateToScene(iPad,eUIComponent_Chat,nullptr,true); XuiElementSetShow( m_hCurrentChatScene[iPad], chatSceneVisible); } @@ -2298,7 +2298,7 @@ void CConsoleMinecraftApp::ReloadChatScene(int iPad, bool bJoining /*= false*/, void CConsoleMinecraftApp::ReloadHudScene(int iPad, bool bJoining /*= false*/, bool bForce /*= false*/) { - if(m_hFirstHudScene[iPad] == NULL || m_hCurrentHudScene[iPad] == NULL) return; + if(m_hFirstHudScene[iPad] == nullptr || m_hCurrentHudScene[iPad] == nullptr) return; // Re-create the hud scene so it is the correct size. It starts without any visible lines. BOOL hudSceneVisible = FALSE; @@ -2317,7 +2317,7 @@ void CConsoleMinecraftApp::ReloadHudScene(int iPad, bool bJoining /*= false*/, b { if( m_hFirstHudScene[iPad] != m_hCurrentHudScene[iPad] ) XuiSceneNavigateBack(m_hCurrentHudScene[iPad], m_hFirstHudScene[iPad],iPad); m_hCurrentHudScene[iPad] = m_hFirstHudScene[iPad]; - app.NavigateToScene(iPad,eUIScene_HUD,NULL,true); + app.NavigateToScene(iPad,eUIScene_HUD,nullptr,true); XuiElementSetShow( m_hCurrentHudScene[iPad], hudSceneVisible); } @@ -2333,7 +2333,7 @@ void CConsoleMinecraftApp::AdjustSplitscreenScene(HXUIOBJ hScene,D3DXVECTOR3 *pv XuiElementGetPosition(hScene,pvOriginalPosition); vec=*pvOriginalPosition; - if( pMinecraft->localplayers[iPad] != NULL ) + if( pMinecraft->localplayers[iPad] != nullptr ) { switch( pMinecraft->localplayers[iPad]->m_iScreenSection) { @@ -2382,7 +2382,7 @@ void CConsoleMinecraftApp::AdjustSplitscreenScene(HXUIOBJ hScene,D3DXVECTOR3 *pv vec=*pvOriginalPosition; - if( pMinecraft->localplayers[iPad] != NULL ) + if( pMinecraft->localplayers[iPad] != nullptr ) { switch( pMinecraft->localplayers[iPad]->m_iScreenSection) { @@ -2449,7 +2449,7 @@ HRESULT CConsoleMinecraftApp::AdjustSplitscreenScene_PlayerChanged(HXUIOBJ hScen // 4J Stu - Return S_FALSE to inidicate that the scene has been closed return S_FALSE; } - else if ( pMinecraft->localplayers[iPad] != NULL ) + else if ( pMinecraft->localplayers[iPad] != nullptr ) { // we need to reposition the scenes since the players will have moved around @@ -2510,7 +2510,7 @@ HRESULT CConsoleMinecraftApp::AdjustSplitscreenScene_PlayerChanged(HXUIOBJ hScen // 4J Stu - Return S_FALSE to inidicate that the scene has been closed return S_FALSE; } - else if ( pMinecraft->localplayers[iPad] != NULL ) + else if ( pMinecraft->localplayers[iPad] != nullptr ) { // we need to reposition the scenes since the players will have moved around @@ -2560,7 +2560,7 @@ HRESULT CConsoleMinecraftApp::AdjustSplitscreenScene_PlayerChanged(HXUIOBJ hScen void CConsoleMinecraftApp::StoreLaunchData() { - LD_DEMO* pDemoData = NULL; + LD_DEMO* pDemoData = nullptr; DWORD dwStatus = XGetLaunchDataSize( &m_dwLaunchDataSize ); @@ -2578,7 +2578,7 @@ void CConsoleMinecraftApp::StoreLaunchData() void CConsoleMinecraftApp::ExitGame() { - if(m_pLaunchData!=NULL) + if(m_pLaunchData!=nullptr) { LD_DEMO* pDemoData = (LD_DEMO*)( m_pLaunchData ); XSetLaunchData( pDemoData, m_dwLaunchDataSize ); @@ -2605,7 +2605,7 @@ void CConsoleMinecraftApp::FatalLoadError(void) memset(&MessageBoxOverlap, 0, sizeof(MessageBoxOverlap)); - //HANDLE messageBoxThread = CreateThread(NULL, 0, &CMinecraftApp::ShowFatalLoadMessageBoxThreadProc, &MessageBoxOverlap, 0, NULL); + //HANDLE messageBoxThread = CreateThread(nullptr, 0, &CMinecraftApp::ShowFatalLoadMessageBoxThreadProc, &MessageBoxOverlap, 0, nullptr); // //WaitForSingleObjectEx(messageBoxThread, // handle to object // 20000, // time-out interval @@ -2775,7 +2775,7 @@ int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile) if(iTMSFileIndex!=-1) { // can we find the tms file in our xzp? - if(TMSFileA[iTMSFileIndex].pbData==NULL) // if we haven't already loaded it + if(TMSFileA[iTMSFileIndex].pbData==nullptr) // if we haven't already loaded it { swprintf(szResourceLocator, LOCATOR_SIZE, L"%ls#TMSFiles/%ls",m_wchTMSXZP, wchTMSFile); @@ -2793,10 +2793,10 @@ void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType) { if((eType==eTMSFileType_All) ||(eType==TMSFileA[i].eTMSType)) { - if(TMSFileA[i].pbData!=NULL) + if(TMSFileA[i].pbData!=nullptr) { XuiFree(TMSFileA[i].pbData); - TMSFileA[i].pbData=NULL; + TMSFileA[i].pbData=nullptr; TMSFileA[i].uiSize=0; } } @@ -2807,148 +2807,148 @@ void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType) TMS_FILE CConsoleMinecraftApp::TMSFileA[TMS_COUNT] = { // skin packs - { L"SP1", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SP2", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SP3", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SP4", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SP5", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SP6", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SPF", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SPB", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SPC", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SPZ", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SPM", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SPI", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"SPG", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, + { L"SP1", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SP2", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SP3", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SP4", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SP5", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SP6", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SPF", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SPB", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SPC", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SPZ", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SPM", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SPI", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"SPG", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, //themes - { L"ThSt", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"ThIr", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"ThGo", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"ThDi", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, - { L"ThAw", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0}, + { L"ThSt", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"ThIr", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"ThGo", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"ThDi", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, + { L"ThAw", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0}, //gamerpics - { L"GPAn", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPCo", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPEn", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPFo", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPTo", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPBA", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPFa", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPME", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPMF", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPMM", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPSE", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - - { L"GPOr", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPMi", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPMB", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPBr", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, NULL, 0, 0}, - - { L"GPM1", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPM2", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0}, - { L"GPM3", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0}, + { L"GPAn", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPCo", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPEn", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPFo", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPTo", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPBA", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPFa", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPME", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPMF", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPMM", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPSE", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + + { L"GPOr", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPMi", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPMB", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPBr", eFileExtensionType_PNG , eTMSFileType_MinecraftStore, nullptr, 0, 0}, + + { L"GPM1", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPM2", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0}, + { L"GPM3", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0}, //avatar items - { L"AH_0001", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0002", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0003", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0004", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0005", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0006", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0007", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0008", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0009", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0010", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0011", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0012", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AH_0013", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - - { L"AT_0001", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0002", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0003", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0004", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0005", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0006", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0007", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0008", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0009", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0010", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0011", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0012", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0013", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0014", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0015", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0016", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0017", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0018", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0019", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0020", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0021", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0022", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0023", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0024", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0025", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AT_0026", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - - { L"AP_0001", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0002", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0003", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0004", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0005", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0006", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0007", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0009", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0010", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0011", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0012", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0013", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0014", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0015", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0016", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0017", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0018", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - - { L"AP_0019", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0020", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0021", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0022", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0023", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0024", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0025", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0026", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0027", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0028", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0029", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0030", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0031", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0032", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"AP_0033", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - - { L"AA_0001", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0 , 0 }, + { L"AH_0001", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0002", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0003", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0004", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0005", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0006", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0007", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0008", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0009", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0010", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0011", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0012", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AH_0013", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + + { L"AT_0001", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0002", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0003", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0004", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0005", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0006", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0007", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0008", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0009", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0010", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0011", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0012", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0013", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0014", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0015", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0016", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0017", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0018", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0019", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0020", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0021", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0022", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0023", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0024", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0025", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AT_0026", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + + { L"AP_0001", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0002", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0003", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0004", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0005", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0006", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0007", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0009", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0010", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0011", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0012", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0013", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0014", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0015", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0016", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0017", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0018", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + + { L"AP_0019", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0020", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0021", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0022", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0023", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0024", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0025", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0026", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0027", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0028", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0029", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0030", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0031", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0032", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"AP_0033", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + + { L"AA_0001", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0 , 0 }, // Mash-up Packs - { L"MPMA", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"MPMA", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 1024 }, - { L"MPSR", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"MPSR", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 1025 }, - { L"MPHA", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"MPHA", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 1026 }, + { L"MPMA", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"MPMA", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 1024 }, + { L"MPSR", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"MPSR", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 1025 }, + { L"MPHA", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"MPHA", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 1026 }, // Texture Packs - { L"TP01", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"TP01", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 2049 }, - { L"TP02", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"TP02", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 2053 }, - { L"TP04", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"TP04", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 2051 }, - { L"TP05", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"TP05", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 2054 }, - { L"TP06", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"TP06", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 2050 }, - { L"TP07", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, NULL, 0, 0 }, - { L"TP07", eFileExtensionType_DAT, eTMSFileType_TexturePack, NULL, 0, 2055 }, + { L"TP01", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"TP01", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 2049 }, + { L"TP02", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"TP02", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 2053 }, + { L"TP04", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"TP04", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 2051 }, + { L"TP05", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"TP05", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 2054 }, + { L"TP06", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"TP06", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 2050 }, + { L"TP07", eFileExtensionType_PNG, eTMSFileType_MinecraftStore, nullptr, 0, 0 }, + { L"TP07", eFileExtensionType_DAT, eTMSFileType_TexturePack, nullptr, 0, 2055 }, }; diff --git a/Minecraft.Client/Xbox/Xbox_App.h b/Minecraft.Client/Xbox/Xbox_App.h index 79ee28f97..86dbc2874 100644 --- a/Minecraft.Client/Xbox/Xbox_App.h +++ b/Minecraft.Client/Xbox/Xbox_App.h @@ -133,12 +133,12 @@ class CConsoleMinecraftApp : public CMinecraftApp WCHAR *GetSceneName(EUIScene eScene, bool bAppendToName,bool bSplitscreenScene); - virtual HRESULT NavigateToScene(int iPad,EUIScene eScene, void *initData = NULL, bool forceUsePad = false, BOOL bStayVisible=FALSE, HXUIOBJ *phResultingScene=NULL); + virtual HRESULT NavigateToScene(int iPad,EUIScene eScene, void *initData = nullptr, bool forceUsePad = false, BOOL bStayVisible=FALSE, HXUIOBJ *phResultingScene=nullptr); virtual HRESULT NavigateBack(int iPad, bool forceUsePad = false,EUIScene eScene = eUIScene_COUNT); virtual HRESULT TutorialSceneNavigateBack(int iPad, bool forceUsePad = false); virtual HRESULT CloseXuiScenes(int iPad, bool forceUsePad = false); virtual HRESULT CloseAllPlayersXuiScenes(); - virtual HRESULT CloseXuiScenesAndNavigateToScene(int iPad,EUIScene eScene, void *initData=NULL, bool forceUsePad = false); + virtual HRESULT CloseXuiScenesAndNavigateToScene(int iPad,EUIScene eScene, void *initData=nullptr, bool forceUsePad = false); virtual HRESULT RemoveBackScene(int iPad); virtual HRESULT NavigateToHomeMenu(); D3DXVECTOR3 GetElementScreenPosition(HXUIOBJ hObj); diff --git a/Minecraft.Client/Xbox/Xbox_Minecraft.cpp b/Minecraft.Client/Xbox/Xbox_Minecraft.cpp index 04e4a8d5a..6606dacf0 100644 --- a/Minecraft.Client/Xbox/Xbox_Minecraft.cpp +++ b/Minecraft.Client/Xbox/Xbox_Minecraft.cpp @@ -285,7 +285,7 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, return pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, - NULL, + nullptr, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, pd3dPP, ppDevice ); @@ -399,7 +399,7 @@ int __cdecl main() } // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers) - hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); + hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, nullptr); if ( FAILED( hr ) ) { app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr ); @@ -671,7 +671,7 @@ int __cdecl main() else { MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->tick(nullptr, 0.0f); MemSect(0); pMinecraft->textures->tick(true,false); IntCache::Reset(); diff --git a/Minecraft.Client/Xbox/Xbox_UIController.cpp b/Minecraft.Client/Xbox/Xbox_UIController.cpp index 51d91ca49..669b037ad 100644 --- a/Minecraft.Client/Xbox/Xbox_UIController.cpp +++ b/Minecraft.Client/Xbox/Xbox_UIController.cpp @@ -170,7 +170,7 @@ void ConsoleUIController::HandleDLCInstalled(int iPad) CustomMessage_DLCInstalled( &xuiMsg ); // The DLC message should only happen in the main menus, so it should go to the default xui scenes - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { @@ -188,7 +188,7 @@ void ConsoleUIController::HandleTMSDLCFileRetrieved(int iPad) XUIMessage xuiMsg; CustomMessage_TMS_DLCFileRetrieved( &xuiMsg ); - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { @@ -204,7 +204,7 @@ void ConsoleUIController::HandleTMSBanFileRetrieved(int iPad) { XUIMessage xuiMsg; CustomMessage_TMS_BanFileRetrieved( &xuiMsg ); - bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bNotInGame=(Minecraft::GetInstance()->level==nullptr); if(bNotInGame) { @@ -319,7 +319,7 @@ C4JStorage::EMessageResult ConsoleUIController::RequestMessageBox(UINT uiTitle, return StorageManager.RequestMessageBox(uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, lpParam, pStringTable, pwchFormatString, dwFocusButton); } -C4JStorage::EMessageResult ConsoleUIController::RequestUGCMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = NULL*/, LPVOID lpParam/* = NULL*/) +C4JStorage::EMessageResult ConsoleUIController::RequestUGCMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = nullptr*/, LPVOID lpParam/* = nullptr*/) { // Default title / messages if (title == -1) @@ -337,5 +337,5 @@ C4JStorage::EMessageResult ConsoleUIController::RequestUGCMessageBox(UINT title/ UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; - return ui.RequestMessageBox(title, message, uiIDA, 1, iPad, Func, lpParam, app.GetStringTable(), NULL, 0, false); + return ui.RequestMessageBox(title, message, uiIDA, 1, iPad, Func, lpParam, app.GetStringTable(), nullptr, 0, false); } \ No newline at end of file diff --git a/Minecraft.Client/Xbox/Xbox_UIController.h b/Minecraft.Client/Xbox/Xbox_UIController.h index 2b273ee52..cd4605965 100644 --- a/Minecraft.Client/Xbox/Xbox_UIController.h +++ b/Minecraft.Client/Xbox/Xbox_UIController.h @@ -11,7 +11,7 @@ class ConsoleUIController : public IUIController virtual void StartReloadSkinThread(); virtual bool IsReloadingSkin(); virtual void CleanUpSkinReload(); - virtual bool NavigateToScene(int iPad, EUIScene scene, void *initData = NULL, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD); + virtual bool NavigateToScene(int iPad, EUIScene scene, void *initData = nullptr, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD); virtual bool NavigateBack(int iPad, bool forceUsePad = false, EUIScene eScene = eUIScene_COUNT, EUILayer eLayer = eUILayer_COUNT); virtual void NavigateToHomeMenu(); virtual void CloseUIScenes(int iPad, bool forceIPad = false); @@ -71,9 +71,9 @@ class ConsoleUIController : public IUIController virtual void SetWinUserIndex(unsigned int iPad); virtual C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, - int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, CXuiStringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0, bool bIsError = true); + int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=nullptr,LPVOID lpParam=nullptr, CXuiStringTable *pStringTable=nullptr, WCHAR *pwchFormatString=nullptr,DWORD dwFocusButton=0, bool bIsError = true); - C4JStorage::EMessageResult RequestUGCMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = NULL, LPVOID lpParam = NULL); + C4JStorage::EMessageResult RequestUGCMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = nullptr, LPVOID lpParam = nullptr); }; extern ConsoleUIController ui; \ No newline at end of file diff --git a/Minecraft.Client/ZombieRenderer.cpp b/Minecraft.Client/ZombieRenderer.cpp index 9db758075..10d13b269 100644 --- a/Minecraft.Client/ZombieRenderer.cpp +++ b/Minecraft.Client/ZombieRenderer.cpp @@ -14,11 +14,11 @@ ZombieRenderer::ZombieRenderer() : HumanoidMobRenderer(new ZombieModel(), .5f, 1 defaultModel = humanoidModel; villagerModel = new VillagerZombieModel(); - defaultArmorParts1 = NULL; - defaultArmorParts2 = NULL; + defaultArmorParts1 = nullptr; + defaultArmorParts2 = nullptr; - villagerArmorParts1 = NULL; - villagerArmorParts2 = NULL; + villagerArmorParts1 = nullptr; + villagerArmorParts2 = nullptr; createArmorParts(); } diff --git a/Minecraft.Client/stubs.h b/Minecraft.Client/stubs.h index f4ae056f2..10ba2d053 100644 --- a/Minecraft.Client/stubs.h +++ b/Minecraft.Client/stubs.h @@ -170,15 +170,15 @@ class ZipFile { public: ZipFile(File *file) {} - InputStream *getInputStream(ZipEntry *entry) { return NULL; } - ZipEntry *getEntry(const wstring& name) {return NULL;} + InputStream *getInputStream(ZipEntry *entry) { return nullptr; } + ZipEntry *getEntry(const wstring& name) {return nullptr;} void close() {} }; class ImageIO { public: - static BufferedImage *read(InputStream *in) { return NULL; } + static BufferedImage *read(InputStream *in) { return nullptr; } }; class Keyboard diff --git a/Minecraft.World/AABB.cpp b/Minecraft.World/AABB.cpp index 6610bc27e..af0501b49 100644 --- a/Minecraft.World/AABB.cpp +++ b/Minecraft.World/AABB.cpp @@ -8,7 +8,7 @@ #include "HitResult.h" DWORD AABB::tlsIdx = 0; -AABB::ThreadStorage *AABB::tlsDefault = NULL; +AABB::ThreadStorage *AABB::tlsDefault = nullptr; AABB::ThreadStorage::ThreadStorage() { @@ -25,7 +25,7 @@ AABB::ThreadStorage::~ThreadStorage() void AABB::CreateNewThreadStorage() { ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == NULL ) + if(tlsDefault == nullptr ) { tlsIdx = TlsAlloc(); tlsDefault = tls; @@ -286,23 +286,23 @@ HitResult *AABB::clip(Vec3 *a, Vec3 *b) Vec3 *zh0 = a->clipZ(b, z0); Vec3 *zh1 = a->clipZ(b, z1); - if (!containsX(xh0)) xh0 = NULL; - if (!containsX(xh1)) xh1 = NULL; - if (!containsY(yh0)) yh0 = NULL; - if (!containsY(yh1)) yh1 = NULL; - if (!containsZ(zh0)) zh0 = NULL; - if (!containsZ(zh1)) zh1 = NULL; + if (!containsX(xh0)) xh0 = nullptr; + if (!containsX(xh1)) xh1 = nullptr; + if (!containsY(yh0)) yh0 = nullptr; + if (!containsY(yh1)) yh1 = nullptr; + if (!containsZ(zh0)) zh0 = nullptr; + if (!containsZ(zh1)) zh1 = nullptr; - Vec3 *closest = NULL; + Vec3 *closest = nullptr; - if (xh0 != NULL && (closest == NULL || a->distanceToSqr(xh0) < a->distanceToSqr(closest))) closest = xh0; - if (xh1 != NULL && (closest == NULL || a->distanceToSqr(xh1) < a->distanceToSqr(closest))) closest = xh1; - if (yh0 != NULL && (closest == NULL || a->distanceToSqr(yh0) < a->distanceToSqr(closest))) closest = yh0; - if (yh1 != NULL && (closest == NULL || a->distanceToSqr(yh1) < a->distanceToSqr(closest))) closest = yh1; - if (zh0 != NULL && (closest == NULL || a->distanceToSqr(zh0) < a->distanceToSqr(closest))) closest = zh0; - if (zh1 != NULL && (closest == NULL || a->distanceToSqr(zh1) < a->distanceToSqr(closest))) closest = zh1; + if (xh0 != nullptr && (closest == nullptr || a->distanceToSqr(xh0) < a->distanceToSqr(closest))) closest = xh0; + if (xh1 != nullptr && (closest == nullptr || a->distanceToSqr(xh1) < a->distanceToSqr(closest))) closest = xh1; + if (yh0 != nullptr && (closest == nullptr || a->distanceToSqr(yh0) < a->distanceToSqr(closest))) closest = yh0; + if (yh1 != nullptr && (closest == nullptr || a->distanceToSqr(yh1) < a->distanceToSqr(closest))) closest = yh1; + if (zh0 != nullptr && (closest == nullptr || a->distanceToSqr(zh0) < a->distanceToSqr(closest))) closest = zh0; + if (zh1 != nullptr && (closest == nullptr || a->distanceToSqr(zh1) < a->distanceToSqr(closest))) closest = zh1; - if (closest == NULL) return NULL; + if (closest == nullptr) return nullptr; int face = -1; @@ -319,19 +319,19 @@ HitResult *AABB::clip(Vec3 *a, Vec3 *b) bool AABB::containsX(Vec3 *v) { - if (v == NULL) return false; + if (v == nullptr) return false; return v->y >= y0 && v->y <= y1 && v->z >= z0 && v->z <= z1; } bool AABB::containsY(Vec3 *v) { - if (v == NULL) return false; + if (v == nullptr) return false; return v->x >= x0 && v->x <= x1 && v->z >= z0 && v->z <= z1; } bool AABB::containsZ(Vec3 *v) { - if (v == NULL) return false; + if (v == nullptr) return false; return v->x >= x0 && v->x <= x1 && v->y >= y0 && v->y <= y1; } diff --git a/Minecraft.World/AbstractContainerMenu.cpp b/Minecraft.World/AbstractContainerMenu.cpp index 2cbea246d..637d05a68 100644 --- a/Minecraft.World/AbstractContainerMenu.cpp +++ b/Minecraft.World/AbstractContainerMenu.cpp @@ -80,7 +80,7 @@ void AbstractContainerMenu::broadcastChanges() { // 4J Stu - Added 0 count check. There is a bug in the Java with anvils that means this broadcast // happens while we are in the middle of quickmoving, and before the slot properly gets set to null - expected = (current == NULL || current->count == 0) ? nullptr : current->copy(); + expected = (current == nullptr || current->count == 0) ? nullptr : current->copy(); lastSlots[i] = expected; m_bNeedsRendered = true; @@ -103,7 +103,7 @@ bool AbstractContainerMenu::needsRendered() shared_ptr expected = lastSlots.at(i); if (!ItemInstance::matches(expected, current)) { - expected = current == NULL ? nullptr : current->copy(); + expected = current == nullptr ? nullptr : current->copy(); lastSlots[i] = expected; needsRendered = true; } @@ -126,7 +126,7 @@ Slot *AbstractContainerMenu::getSlotFor(shared_ptr c, int index) return slot; } } - return NULL; + return nullptr; } Slot *AbstractContainerMenu::getSlot(int index) @@ -137,7 +137,7 @@ Slot *AbstractContainerMenu::getSlot(int index) shared_ptr AbstractContainerMenu::quickMoveStack(shared_ptr player, int slotIndex) { Slot *slot = slots.at(slotIndex); - if (slot != NULL) + if (slot != nullptr) { return slot->getItem(); } @@ -158,7 +158,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto { resetQuickCraft(); } - else if (inventory->getCarried() == NULL) + else if (inventory->getCarried() == nullptr) { resetQuickCraft(); } @@ -180,7 +180,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto { Slot *slot = slots.at(slotIndex); - if (slot != NULL && canItemQuickReplace(slot, inventory->getCarried(), true) && slot->mayPlace(inventory->getCarried()) && inventory->getCarried()->count > quickcraftSlots.size() && canDragTo(slot)) + if (slot != nullptr && canItemQuickReplace(slot, inventory->getCarried(), true) && slot->mayPlace(inventory->getCarried()) && inventory->getCarried()->count > quickcraftSlots.size() && canDragTo(slot)) { quickcraftSlots.insert(slot); } @@ -231,7 +231,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto { if (slotIndex == SLOT_CLICKED_OUTSIDE) { - if (inventory->getCarried() != NULL) + if (inventory->getCarried() != nullptr) { if (slotIndex == SLOT_CLICKED_OUTSIDE) { @@ -253,10 +253,10 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto { if (slotIndex < 0) return nullptr; Slot *slot = slots.at(slotIndex); - if(slot != NULL && slot->mayPickup(player)) + if(slot != nullptr && slot->mayPickup(player)) { shared_ptr piiClicked = quickMoveStack(player, slotIndex); - if (piiClicked != NULL) + if (piiClicked != nullptr) { int oldType = piiClicked->id; @@ -269,9 +269,9 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto // 4J Stu - Remove the reference to this before we start a recursive loop piiClicked = nullptr; - if (slot != NULL) + if (slot != nullptr) { - if (slot->getItem() != NULL && slot->getItem()->id == oldType) + if (slot->getItem() != nullptr && slot->getItem()->id == oldType) { if(looped) { @@ -293,19 +293,19 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto if (slotIndex < 0) return nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL) + if (slot != nullptr) { shared_ptr clicked = slot->getItem(); shared_ptr carried = inventory->getCarried(); - if (clicked != NULL) + if (clicked != nullptr) { clickedEntity = clicked->copy(); } - if (clicked == NULL) + if (clicked == nullptr) { - if (carried != NULL && slot->mayPlace(carried)) + if (carried != nullptr && slot->mayPlace(carried)) { int c = buttonNum == 0 ? carried->count : 1; if (c > slot->getMaxStackSize()) @@ -326,7 +326,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto else if (buttonNum == 1 && mayCombine(slot, carried)) { shared_ptr combined = slot->combine(carried); - if(combined != NULL) + if(combined != nullptr) { slot->set(combined); if(!player->abilities.instabuild) carried->remove(1); @@ -338,7 +338,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto } else if (slot->mayPickup(player)) { - if (carried == NULL) + if (carried == nullptr) { // pick up to empty hand int c = buttonNum == 0 ? clicked->count : (clicked->count + 1) / 2; @@ -412,7 +412,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto if (slot->mayPickup(player)) { shared_ptr current = inventory->getItem(buttonNum); - bool canMove = current == NULL || (slot->container == inventory && slot->mayPlace(current)); + bool canMove = current == nullptr || (slot->container == inventory && slot->mayPlace(current)); int freeSlot = -1; if (!canMove) @@ -426,7 +426,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto shared_ptr taking = slot->getItem(); inventory->setItem(buttonNum, taking); - if ((slot->container == inventory && slot->mayPlace(current)) || current == NULL) + if ((slot->container == inventory && slot->mayPlace(current)) || current == nullptr) { slot->remove(taking->count); slot->set(current); @@ -440,27 +440,27 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto slot->onTake(player, taking); } } - else if (!slot->hasItem() && current != NULL && slot->mayPlace(current)) + else if (!slot->hasItem() && current != nullptr && slot->mayPlace(current)) { inventory->setItem(buttonNum, nullptr); slot->set(current); } } } - else if (clickType == CLICK_CLONE && player->abilities.instabuild && inventory->getCarried() == NULL && slotIndex >= 0) + else if (clickType == CLICK_CLONE && player->abilities.instabuild && inventory->getCarried() == nullptr && slotIndex >= 0) { Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr copy = slot->getItem()->copy(); copy->count = copy->getMaxStackSize(); inventory->setCarried(copy); } } - else if (clickType == CLICK_THROW && inventory->getCarried() == NULL && slotIndex >= 0) + else if (clickType == CLICK_THROW && inventory->getCarried() == nullptr && slotIndex >= 0) { Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem() && slot->mayPickup(player)) + if (slot != nullptr && slot->hasItem() && slot->mayPickup(player)) { shared_ptr item = slot->remove(buttonNum == 0 ? 1 : slot->getItem()->count); slot->onTake(player, item); @@ -472,7 +472,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto Slot *slot = slots.at(slotIndex); shared_ptr carried = inventory->getCarried(); - if (carried != NULL && (slot == NULL || !slot->hasItem() || !slot->mayPickup(player))) + if (carried != nullptr && (slot == nullptr || !slot->hasItem() || !slot->mayPickup(player))) { int start = buttonNum == 0 ? 0 : slots.size() - 1; int step = buttonNum == 0 ? 1 : -1; @@ -514,7 +514,7 @@ bool AbstractContainerMenu::canTakeItemForPickAll(shared_ptr carri // 4J Stu - Brought forward from 1.2 to fix infinite recursion bug in creative void AbstractContainerMenu::loopClick(int slotIndex, int buttonNum, bool quickKeyHeld, shared_ptr player) { - while( clicked(slotIndex, buttonNum, CLICK_QUICK_MOVE, player, true) != NULL) + while( clicked(slotIndex, buttonNum, CLICK_QUICK_MOVE, player, true) != nullptr) { } } @@ -527,7 +527,7 @@ bool AbstractContainerMenu::mayCombine(Slot *slot, shared_ptr item void AbstractContainerMenu::removed(shared_ptr player) { shared_ptr inventory = player->inventory; - if (inventory->getCarried() != NULL) + if (inventory->getCarried() != nullptr) { player->drop(inventory->getCarried()); inventory->setCarried(nullptr); @@ -605,7 +605,7 @@ bool AbstractContainerMenu::moveItemStackTo(shared_ptr itemStack, Slot *slot = slots.at(destSlot); shared_ptr target = slot->getItem(); - if (target != NULL && target->id == itemStack->id && (!itemStack->isStackedByData() || itemStack->getAuxValue() == target->getAuxValue()) + if (target != nullptr && target->id == itemStack->id && (!itemStack->isStackedByData() || itemStack->getAuxValue() == target->getAuxValue()) && ItemInstance::tagMatches(itemStack, target) ) { int totalStack = target->count + itemStack->count; @@ -652,7 +652,7 @@ bool AbstractContainerMenu::moveItemStackTo(shared_ptr itemStack, Slot *slot = slots.at(destSlot); shared_ptr target = slot->getItem(); - if (target == NULL) + if (target == nullptr) { slot->set(itemStack->copy()); slot->setChanged(); @@ -707,9 +707,9 @@ void AbstractContainerMenu::resetQuickCraft() bool AbstractContainerMenu::canItemQuickReplace(Slot *slot, shared_ptr item, bool ignoreSize) { - bool canReplace = slot == NULL || !slot->hasItem(); + bool canReplace = slot == nullptr || !slot->hasItem(); - if (slot != NULL && slot->hasItem() && item != NULL && item->sameItem(slot->getItem()) && ItemInstance::tagMatches(slot->getItem(), item)) + if (slot != nullptr && slot->hasItem() && item != nullptr && item->sameItem(slot->getItem()) && ItemInstance::tagMatches(slot->getItem(), item)) { canReplace |= slot->getItem()->count + (ignoreSize ? 0 : item->count) <= item->getMaxStackSize(); } @@ -739,7 +739,7 @@ bool AbstractContainerMenu::canDragTo(Slot *slot) int AbstractContainerMenu::getRedstoneSignalFromContainer(shared_ptr container) { - if (container == NULL) return 0; + if (container == nullptr) return 0; int count = 0; float totalPct = 0; @@ -747,7 +747,7 @@ int AbstractContainerMenu::getRedstoneSignalFromContainer(shared_ptr { shared_ptr item = container->getItem(i); - if (item != NULL) + if (item != nullptr) { totalPct += item->count / static_cast(min(container->getMaxStackSize(), item->getMaxStackSize())); count++; diff --git a/Minecraft.World/Achievement.cpp b/Minecraft.World/Achievement.cpp index a0dfd5332..cd5a68df7 100644 --- a/Minecraft.World/Achievement.cpp +++ b/Minecraft.World/Achievement.cpp @@ -58,7 +58,7 @@ bool Achievement::isAchievement() wstring Achievement::getDescription() { - if (descFormatter != NULL) + if (descFormatter != nullptr) { return descFormatter->format(desc); } diff --git a/Minecraft.World/Achievements.cpp b/Minecraft.World/Achievements.cpp index a3d33cbd8..1b00acc00 100644 --- a/Minecraft.World/Achievements.cpp +++ b/Minecraft.World/Achievements.cpp @@ -17,79 +17,79 @@ int Achievements::yMax = 0; vector *Achievements::achievements = new vector; -Achievement *Achievements::openInventory = NULL; -Achievement *Achievements::mineWood = NULL; -Achievement *Achievements::buildWorkbench = NULL; -Achievement *Achievements::buildPickaxe = NULL; -Achievement *Achievements::buildFurnace = NULL; -Achievement *Achievements::acquireIron = NULL; -Achievement *Achievements::buildHoe = NULL; -Achievement *Achievements::makeBread = NULL; -Achievement *Achievements::bakeCake = NULL; -Achievement *Achievements::buildBetterPickaxe = NULL; -Achievement *Achievements::cookFish = NULL; -Achievement *Achievements::onARail = NULL; -Achievement *Achievements::buildSword = NULL; -Achievement *Achievements::killEnemy = NULL; -Achievement *Achievements::killCow = NULL; -Achievement *Achievements::flyPig = NULL; - -Achievement *Achievements::snipeSkeleton = NULL; -Achievement *Achievements::diamonds = NULL; -//Achievement *Achievements::portal = NULL; -Achievement *Achievements::ghast = NULL; -Achievement *Achievements::blazeRod = NULL; -Achievement *Achievements::potion = NULL; -Achievement *Achievements::theEnd = NULL; -Achievement *Achievements::winGame = NULL; -Achievement *Achievements::enchantments = NULL; -//Achievement *Achievements::overkill = NULL; -//Achievement *Achievements::bookcase = NULL; +Achievement *Achievements::openInventory = nullptr; +Achievement *Achievements::mineWood = nullptr; +Achievement *Achievements::buildWorkbench = nullptr; +Achievement *Achievements::buildPickaxe = nullptr; +Achievement *Achievements::buildFurnace = nullptr; +Achievement *Achievements::acquireIron = nullptr; +Achievement *Achievements::buildHoe = nullptr; +Achievement *Achievements::makeBread = nullptr; +Achievement *Achievements::bakeCake = nullptr; +Achievement *Achievements::buildBetterPickaxe = nullptr; +Achievement *Achievements::cookFish = nullptr; +Achievement *Achievements::onARail = nullptr; +Achievement *Achievements::buildSword = nullptr; +Achievement *Achievements::killEnemy = nullptr; +Achievement *Achievements::killCow = nullptr; +Achievement *Achievements::flyPig = nullptr; + +Achievement *Achievements::snipeSkeleton = nullptr; +Achievement *Achievements::diamonds = nullptr; +//Achievement *Achievements::portal = nullptr; +Achievement *Achievements::ghast = nullptr; +Achievement *Achievements::blazeRod = nullptr; +Achievement *Achievements::potion = nullptr; +Achievement *Achievements::theEnd = nullptr; +Achievement *Achievements::winGame = nullptr; +Achievement *Achievements::enchantments = nullptr; +//Achievement *Achievements::overkill = nullptr; +//Achievement *Achievements::bookcase = nullptr; // 4J : WESTY : Added new acheivements. -Achievement *Achievements::leaderOfThePack = NULL; -Achievement *Achievements::MOARTools = NULL; -Achievement *Achievements::dispenseWithThis = NULL; -Achievement *Achievements::InToTheNether = NULL; +Achievement *Achievements::leaderOfThePack = nullptr; +Achievement *Achievements::MOARTools = nullptr; +Achievement *Achievements::dispenseWithThis = nullptr; +Achievement *Achievements::InToTheNether = nullptr; // 4J : WESTY : Added other awards. -Achievement *Achievements::socialPost = NULL; -Achievement *Achievements::eatPorkChop = NULL; -Achievement *Achievements::play100Days = NULL; -Achievement *Achievements::arrowKillCreeper = NULL; -Achievement *Achievements::mine100Blocks = NULL; -Achievement *Achievements::kill10Creepers = NULL; +Achievement *Achievements::socialPost = nullptr; +Achievement *Achievements::eatPorkChop = nullptr; +Achievement *Achievements::play100Days = nullptr; +Achievement *Achievements::arrowKillCreeper = nullptr; +Achievement *Achievements::mine100Blocks = nullptr; +Achievement *Achievements::kill10Creepers = nullptr; #ifdef _EXTENDED_ACHIEVEMENTS -Achievement *Achievements::overkill = NULL; // Restored old achivements. -Achievement *Achievements::bookcase = NULL; // Restored old achivements. +Achievement *Achievements::overkill = nullptr; // Restored old achivements. +Achievement *Achievements::bookcase = nullptr; // Restored old achivements. // 4J-JEV: New Achievements for Orbis. -Achievement *Achievements::adventuringTime = NULL; -Achievement *Achievements::repopulation = NULL; -//Achievement *Achievements::porkChop = NULL; -Achievement *Achievements::diamondsToYou = NULL; -//Achievement *Achievements::passingTheTime = NULL; -//Achievement *Achievements::archer = NULL; -Achievement *Achievements::theHaggler = NULL; -Achievement *Achievements::potPlanter = NULL; -Achievement *Achievements::itsASign = NULL; -Achievement *Achievements::ironBelly = NULL; -Achievement *Achievements::haveAShearfulDay = NULL; -Achievement *Achievements::rainbowCollection = NULL; -Achievement *Achievements::stayinFrosty = NULL; -Achievement *Achievements::chestfulOfCobblestone = NULL; -Achievement *Achievements::renewableEnergy = NULL; -Achievement *Achievements::musicToMyEars = NULL; -Achievement *Achievements::bodyGuard = NULL; -Achievement *Achievements::ironMan = NULL; -Achievement *Achievements::zombieDoctor = NULL; -Achievement *Achievements::lionTamer = NULL; +Achievement *Achievements::adventuringTime = nullptr; +Achievement *Achievements::repopulation = nullptr; +//Achievement *Achievements::porkChop = nullptr; +Achievement *Achievements::diamondsToYou = nullptr; +//Achievement *Achievements::passingTheTime = nullptr; +//Achievement *Achievements::archer = nullptr; +Achievement *Achievements::theHaggler = nullptr; +Achievement *Achievements::potPlanter = nullptr; +Achievement *Achievements::itsASign = nullptr; +Achievement *Achievements::ironBelly = nullptr; +Achievement *Achievements::haveAShearfulDay = nullptr; +Achievement *Achievements::rainbowCollection = nullptr; +Achievement *Achievements::stayinFrosty = nullptr; +Achievement *Achievements::chestfulOfCobblestone = nullptr; +Achievement *Achievements::renewableEnergy = nullptr; +Achievement *Achievements::musicToMyEars = nullptr; +Achievement *Achievements::bodyGuard = nullptr; +Achievement *Achievements::ironMan = nullptr; +Achievement *Achievements::zombieDoctor = nullptr; +Achievement *Achievements::lionTamer = nullptr; #endif void Achievements::staticCtor() { - Achievements::openInventory = (new Achievement(eAward_TakingInventory, L"openInventory", 0, 0, Item::book, NULL))->setAwardLocallyOnly()->postConstruct(); + Achievements::openInventory = (new Achievement(eAward_TakingInventory, L"openInventory", 0, 0, Item::book, nullptr))->setAwardLocallyOnly()->postConstruct(); Achievements::mineWood = (new Achievement(eAward_GettingWood, L"mineWood", 2, 1, Tile::treeTrunk, (Achievement *) openInventory))->postConstruct(); Achievements::buildWorkbench = (new Achievement(eAward_Benchmarking, L"buildWorkBench", 4, -1, Tile::workBench, (Achievement *) mineWood))->postConstruct(); Achievements::buildPickaxe = (new Achievement(eAward_TimeToMine, L"buildPickaxe", 4, 2, Item::pickAxe_wood, (Achievement *) buildWorkbench))->postConstruct(); @@ -152,26 +152,26 @@ void Achievements::staticCtor() Achievements::overkill = (new Achievement(eAward_overkill, L"overkill", -4,1, Item::sword_diamond, (Achievement *)enchantments) )->setGolden()->postConstruct(); Achievements::bookcase = (new Achievement(eAward_bookcase, L"bookcase", -3,6, Tile::bookshelf, (Achievement *)enchantments) )->postConstruct(); - Achievements::adventuringTime = (new Achievement(eAward_adventuringTime, L"adventuringTime", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct(); - Achievements::repopulation = (new Achievement(eAward_repopulation, L"repopulation", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); + Achievements::adventuringTime = (new Achievement(eAward_adventuringTime, L"adventuringTime", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct(); + Achievements::repopulation = (new Achievement(eAward_repopulation, L"repopulation", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); //Achievements::porkChoop // // // // // // - Achievements::diamondsToYou = (new Achievement(eAward_diamondsToYou, L"diamondsToYou", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - //Achievements::passingTheTime = (new Achievement(eAward_play100Days, L"passingTheTime", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - //Achievements::archer = (new Achievement(eAward_arrowKillCreeper, L"archer", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::theHaggler = (new Achievement(eAward_theHaggler, L"theHaggler", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct(); - Achievements::potPlanter = (new Achievement(eAward_potPlanter, L"potPlanter", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct(); - Achievements::itsASign = (new Achievement(eAward_itsASign, L"itsASign", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct(); - Achievements::ironBelly = (new Achievement(eAward_ironBelly, L"ironBelly", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::haveAShearfulDay = (new Achievement(eAward_haveAShearfulDay, L"haveAShearfulDay", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::rainbowCollection = (new Achievement(eAward_rainbowCollection, L"rainbowCollection", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct(); - Achievements::stayinFrosty = (new Achievement(eAward_stayinFrosty, L"stayingFrosty", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::chestfulOfCobblestone = (new Achievement(eAward_chestfulOfCobblestone, L"chestfulOfCobblestone", 0,0, Tile::bookshelf, (Achievement*) NULL) )->setAwardLocallyOnly()->postConstruct(); - Achievements::renewableEnergy = (new Achievement(eAward_renewableEnergy, L"renewableEnergy", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::musicToMyEars = (new Achievement(eAward_musicToMyEars, L"musicToMyEars", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::bodyGuard = (new Achievement(eAward_bodyGuard, L"bodyGuard", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::ironMan = (new Achievement(eAward_ironMan, L"ironMan", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::zombieDoctor = (new Achievement(eAward_zombieDoctor, L"zombieDoctor", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); - Achievements::lionTamer = (new Achievement(eAward_lionTamer, L"lionTamer", 0,0, Tile::bookshelf, (Achievement*) NULL) )->postConstruct(); + Achievements::diamondsToYou = (new Achievement(eAward_diamondsToYou, L"diamondsToYou", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + //Achievements::passingTheTime = (new Achievement(eAward_play100Days, L"passingTheTime", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + //Achievements::archer = (new Achievement(eAward_arrowKillCreeper, L"archer", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::theHaggler = (new Achievement(eAward_theHaggler, L"theHaggler", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct(); + Achievements::potPlanter = (new Achievement(eAward_potPlanter, L"potPlanter", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct(); + Achievements::itsASign = (new Achievement(eAward_itsASign, L"itsASign", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct(); + Achievements::ironBelly = (new Achievement(eAward_ironBelly, L"ironBelly", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::haveAShearfulDay = (new Achievement(eAward_haveAShearfulDay, L"haveAShearfulDay", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::rainbowCollection = (new Achievement(eAward_rainbowCollection, L"rainbowCollection", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct(); + Achievements::stayinFrosty = (new Achievement(eAward_stayinFrosty, L"stayingFrosty", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::chestfulOfCobblestone = (new Achievement(eAward_chestfulOfCobblestone, L"chestfulOfCobblestone", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->setAwardLocallyOnly()->postConstruct(); + Achievements::renewableEnergy = (new Achievement(eAward_renewableEnergy, L"renewableEnergy", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::musicToMyEars = (new Achievement(eAward_musicToMyEars, L"musicToMyEars", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::bodyGuard = (new Achievement(eAward_bodyGuard, L"bodyGuard", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::ironMan = (new Achievement(eAward_ironMan, L"ironMan", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::zombieDoctor = (new Achievement(eAward_zombieDoctor, L"zombieDoctor", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); + Achievements::lionTamer = (new Achievement(eAward_lionTamer, L"lionTamer", 0,0, Tile::bookshelf, (Achievement*) nullptr) )->postConstruct(); #endif } diff --git a/Minecraft.World/AddMobPacket.cpp b/Minecraft.World/AddMobPacket.cpp index d224b2931..d5ccfe084 100644 --- a/Minecraft.World/AddMobPacket.cpp +++ b/Minecraft.World/AddMobPacket.cpp @@ -17,7 +17,7 @@ AddMobPacket::AddMobPacket() yRot = 0; xRot = 0; entityData = nullptr; - unpack = NULL; + unpack = nullptr; } AddMobPacket::~AddMobPacket() @@ -61,7 +61,7 @@ AddMobPacket::AddMobPacket(shared_ptr mob, int yRotp, int xRotp, i // printf("%d: New add mob rot %d\n",id,yRot); entityData = mob->getEntityData(); - unpack = NULL; + unpack = nullptr; } void AddMobPacket::read(DataInputStream *dis) //throws IOException @@ -118,11 +118,11 @@ void AddMobPacket::handle(PacketListener *listener) int AddMobPacket::getEstimatedSize() { int size = 11; - if( entityData != NULL ) + if( entityData != nullptr ) { size += entityData->getSizeInBytes(); } - else if( unpack != NULL ) + else if( unpack != nullptr ) { // 4J Stu - This is an incoming value which we aren't currently analysing //size += unpack->get @@ -132,7 +132,7 @@ int AddMobPacket::getEstimatedSize() vector > *AddMobPacket::getUnpackedData() { - if (unpack == NULL) + if (unpack == nullptr) { unpack = entityData->getAll(); } diff --git a/Minecraft.World/AddPlayerPacket.cpp b/Minecraft.World/AddPlayerPacket.cpp index 6b3e26365..fbee1fc52 100644 --- a/Minecraft.World/AddPlayerPacket.cpp +++ b/Minecraft.World/AddPlayerPacket.cpp @@ -24,12 +24,12 @@ AddPlayerPacket::AddPlayerPacket() m_capeId = 0; m_uiGamePrivileges = 0; entityData = nullptr; - unpack = NULL; + unpack = nullptr; } AddPlayerPacket::~AddPlayerPacket() { - if(unpack != NULL) delete unpack; + if(unpack != nullptr) delete unpack; } AddPlayerPacket::AddPlayerPacket(shared_ptr player, PlayerUID xuid, PlayerUID OnlineXuid,int xp, int yp, int zp, int yRotp, int xRotp, int yHeadRotp) @@ -51,7 +51,7 @@ AddPlayerPacket::AddPlayerPacket(shared_ptr player, PlayerUID xuid, Play //printf("%d: New add player (%f,%f,%f) : (%d,%d,%d) : xRot %d, yRot %d\n",id,player->x,player->y,player->z,x,y,z,xRot,yRot); shared_ptr itemInstance = player->inventory->getSelected(); - carriedItem = itemInstance == NULL ? 0 : itemInstance->id; + carriedItem = itemInstance == nullptr ? 0 : itemInstance->id; this->xuid = xuid; this->OnlineXuid = OnlineXuid; @@ -61,7 +61,7 @@ AddPlayerPacket::AddPlayerPacket(shared_ptr player, PlayerUID xuid, Play m_uiGamePrivileges = player->getAllPlayerGamePrivileges(); entityData = player->getEntityData(); - unpack = NULL; + unpack = nullptr; } void AddPlayerPacket::read(DataInputStream *dis) //throws IOException @@ -119,11 +119,11 @@ int AddPlayerPacket::getEstimatedSize() { int iSize= sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(BYTE) + sizeof(BYTE) +sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + sizeof(int) + sizeof(BYTE) + sizeof(unsigned int) + sizeof(byte); - if( entityData != NULL ) + if( entityData != nullptr ) { iSize += entityData->getSizeInBytes(); } - else if( unpack != NULL ) + else if( unpack != nullptr ) { // 4J Stu - This is an incoming value which we aren't currently analysing //iSize += unpack->get @@ -134,7 +134,7 @@ int AddPlayerPacket::getEstimatedSize() vector > *AddPlayerPacket::getUnpackedData() { - if (unpack == NULL) + if (unpack == nullptr) { unpack = entityData->getAll(); } diff --git a/Minecraft.World/AgableMob.cpp b/Minecraft.World/AgableMob.cpp index 307aa767f..892a14e56 100644 --- a/Minecraft.World/AgableMob.cpp +++ b/Minecraft.World/AgableMob.cpp @@ -17,7 +17,7 @@ bool AgableMob::mobInteract(shared_ptr player) { shared_ptr item = player->inventory->getSelected(); - if (item != NULL && item->id == Item::spawnEgg_Id) + if (item != nullptr && item->id == Item::spawnEgg_Id) { if (!level->isClientSide) { @@ -27,10 +27,10 @@ bool AgableMob::mobInteract(shared_ptr player) int error; shared_ptr result = SpawnEggItem::canSpawn(item->getAuxValue(), level, &error); - if (result != NULL) + if (result != nullptr) { shared_ptr offspring = getBreedOffspring(dynamic_pointer_cast(shared_from_this())); - if (offspring != NULL) + if (offspring != nullptr) { offspring->setAge(BABY_START_AGE); offspring->moveTo(x, y, z, 0, 0); diff --git a/Minecraft.World/Animal.cpp b/Minecraft.World/Animal.cpp index 77048d06d..bd9bc3fad 100644 --- a/Minecraft.World/Animal.cpp +++ b/Minecraft.World/Animal.cpp @@ -78,7 +78,7 @@ void Animal::checkHurtTarget(shared_ptr target, float d) } shared_ptr p = dynamic_pointer_cast(target); - if (p->getSelectedItem() == NULL || !isFood(p->getSelectedItem())) + if (p->getSelectedItem() == nullptr || !isFood(p->getSelectedItem())) { attackTarget = nullptr; } @@ -97,7 +97,7 @@ void Animal::checkHurtTarget(shared_ptr target, float d) } else if (getInLoveValue() > 0 && a->getInLoveValue() > 0) { - if (a->attackTarget == NULL) a->attackTarget = shared_from_this(); + if (a->attackTarget == nullptr) a->attackTarget = shared_from_this(); if (a->attackTarget == shared_from_this() && d < 3.5) { @@ -134,9 +134,9 @@ void Animal::breedWith(shared_ptr target) target->loveTime = 0; target->setInLoveValue(0); - // 4J - we have offspring of NULL returned when we have hit our limits of spawning any particular type of animal. In these cases try and do everything we can apart from actually + // 4J - we have offspring of nullptr returned when we have hit our limits of spawning any particular type of animal. In these cases try and do everything we can apart from actually // spawning the entity. - if (offspring != NULL) + if (offspring != nullptr) { // Only want to set the age to this +ve value if something is actually spawned, as during this period the animal will attempt to follow offspring and ignore players. setAge(5 * 60 * 20); @@ -169,7 +169,7 @@ float Animal::getWalkTargetValue(int x, int y, int z) bool Animal::hurt(DamageSource *dmgSource, float dmg) { if (isInvulnerable()) return false; - if (dynamic_cast(dmgSource) != NULL) + if (dynamic_cast(dmgSource) != nullptr) { shared_ptr source = dmgSource->getDirectEntity(); @@ -179,12 +179,12 @@ bool Animal::hurt(DamageSource *dmgSource, float dmg) return false; } - if ( (source != NULL) && source->instanceof(eTYPE_ARROW) ) + if ( (source != nullptr) && source->instanceof(eTYPE_ARROW) ) { shared_ptr arrow = 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) && !dynamic_pointer_cast(arrow->owner)->isAllowedToAttackAnimals() ) + if (arrow->owner != nullptr && arrow->owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast(arrow->owner)->isAllowedToAttackAnimals() ) { return false; } @@ -196,7 +196,7 @@ bool Animal::hurt(DamageSource *dmgSource, float dmg) if (!useNewAi()) { AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); - if (speed->getModifier(eModifierId_MOB_FLEEING) == NULL) + if (speed->getModifier(eModifierId_MOB_FLEEING) == nullptr) { speed->addModifier(new AttributeModifier(*Animal::SPEED_MODIFIER_FLEEING)); } @@ -255,7 +255,7 @@ shared_ptr Animal::findAttackTarget() setDespawnProtected(); shared_ptr p = dynamic_pointer_cast(it); - if (p->getSelectedItem() != NULL && this->isFood(p->getSelectedItem())) + if (p->getSelectedItem() != nullptr && this->isFood(p->getSelectedItem())) { delete players; return p; @@ -317,7 +317,7 @@ bool Animal::isFood(shared_ptr itemInstance) bool Animal::mobInteract(shared_ptr player) { shared_ptr item = player->inventory->getSelected(); - if (item != NULL && isFood(item) && getAge() == 0 && getInLoveValue() <= 0) + if (item != nullptr && isFood(item) && getAge() == 0 && getInLoveValue() <= 0) { if (!player->abilities.instabuild) { diff --git a/Minecraft.World/AnvilMenu.cpp b/Minecraft.World/AnvilMenu.cpp index 83d381425..de3315544 100644 --- a/Minecraft.World/AnvilMenu.cpp +++ b/Minecraft.World/AnvilMenu.cpp @@ -55,7 +55,7 @@ void AnvilMenu::createResult() if (DEBUG_COST) app.DebugPrintf("----"); - if (input == NULL) + if (input == nullptr) { resultSlots->setItem(0, nullptr); cost = 0; @@ -68,15 +68,15 @@ void AnvilMenu::createResult() unordered_map *enchantments = EnchantmentHelper::getEnchantments(result); bool usingBook = false; - tax += input->getBaseRepairCost() + (addition == NULL ? 0 : addition->getBaseRepairCost()); + tax += input->getBaseRepairCost() + (addition == nullptr ? 0 : addition->getBaseRepairCost()); if (DEBUG_COST) { - app.DebugPrintf("Starting with base repair tax of %d (%d + %d)\n", tax, input->getBaseRepairCost(), (addition == NULL ? 0 : addition->getBaseRepairCost())); + app.DebugPrintf("Starting with base repair tax of %d (%d + %d)\n", tax, input->getBaseRepairCost(), (addition == nullptr ? 0 : addition->getBaseRepairCost())); } repairItemCountCost = 0; - if (addition != NULL) + if (addition != nullptr) { usingBook = addition->id == Item::enchantedBook_Id && Item::enchantedBook->getEnchantments(addition)->size() > 0; @@ -290,10 +290,10 @@ void AnvilMenu::createResult() result = nullptr; } - if (result != NULL) + if (result != nullptr) { int baseCost = result->getBaseRepairCost(); - if (addition != NULL && baseCost < addition->getBaseRepairCost()) baseCost = addition->getBaseRepairCost(); + if (addition != nullptr && baseCost < addition->getBaseRepairCost()) baseCost = addition->getBaseRepairCost(); if (result->hasCustomHoverName()) baseCost -= 9; if (baseCost < 0) baseCost = 0; baseCost += 2; @@ -344,7 +344,7 @@ void AnvilMenu::removed(shared_ptr player) for (int i = 0; i < repairSlots->getContainerSize(); i++) { shared_ptr item = repairSlots->removeItemNoUpdate(i); - if (item != NULL) + if (item != nullptr) { player->drop(item); } @@ -362,7 +362,7 @@ shared_ptr AnvilMenu::quickMoveStack(shared_ptr player, in { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/AnvilTile.cpp b/Minecraft.World/AnvilTile.cpp index 8789cb7c4..5d186c285 100644 --- a/Minecraft.World/AnvilTile.cpp +++ b/Minecraft.World/AnvilTile.cpp @@ -21,7 +21,7 @@ AnvilTile::AnvilTile(int id) : HeavyTile(id, Material::heavyMetal, isSolidRender { part = PART_BASE; setLightBlock(0); - icons = NULL; + icons = nullptr; } bool AnvilTile::isCubeShaped() diff --git a/Minecraft.World/ArmorDyeRecipe.cpp b/Minecraft.World/ArmorDyeRecipe.cpp index c55cbc592..d3abcc1cc 100644 --- a/Minecraft.World/ArmorDyeRecipe.cpp +++ b/Minecraft.World/ArmorDyeRecipe.cpp @@ -13,12 +13,12 @@ bool ArmorDyeRecipe::matches(shared_ptr craftSlots, Level *le for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; ArmorItem *armor = dynamic_cast(item->getItem()); if (armor) { - if (armor->getMaterial() == ArmorItem::ArmorMaterial::CLOTH && target == NULL) + if (armor->getMaterial() == ArmorItem::ArmorMaterial::CLOTH && target == nullptr) { target = item; } @@ -37,7 +37,7 @@ bool ArmorDyeRecipe::matches(shared_ptr craftSlots, Level *le } } - return target != NULL && !dyes.empty(); + return target != nullptr && !dyes.empty(); } shared_ptr ArmorDyeRecipe::assembleDyedArmor(shared_ptr craftSlots) @@ -46,19 +46,19 @@ shared_ptr ArmorDyeRecipe::assembleDyedArmor(shared_ptrgetContainerSize(); slot++) { shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; armor = dynamic_cast(item->getItem()); if (armor) { - if (armor->getMaterial() == ArmorItem::ArmorMaterial::CLOTH && target == NULL) + if (armor->getMaterial() == ArmorItem::ArmorMaterial::CLOTH && target == nullptr) { target = item->copy(); target->count = 1; @@ -104,7 +104,7 @@ shared_ptr ArmorDyeRecipe::assembleDyedArmor(shared_ptrgetAuxValue(); TempIngReq.uiGridA[iCount++]=expected->id | iAuxVal<<24; diff --git a/Minecraft.World/ArmorItem.cpp b/Minecraft.World/ArmorItem.cpp index 114b200b9..93d58cdd7 100644 --- a/Minecraft.World/ArmorItem.cpp +++ b/Minecraft.World/ArmorItem.cpp @@ -170,9 +170,9 @@ int ArmorItem::getColor(shared_ptr item) if (armorType != ArmorMaterial::CLOTH) return -1; CompoundTag *tag = item->getTag(); - if (tag == NULL) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR ); + if (tag == nullptr) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR ); CompoundTag *display = tag->getCompound(L"display"); - if (display == NULL) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR ); + if (display == nullptr) return Minecraft::GetInstance()->getColourTable()->getColor( DEFAULT_LEATHER_COLOR ); if (display->contains(L"color")) { @@ -197,7 +197,7 @@ void ArmorItem::clearColor(shared_ptr item) { if (armorType != ArmorMaterial::CLOTH) return; CompoundTag *tag = item->getTag(); - if (tag == NULL) return; + if (tag == nullptr) return; CompoundTag *display = tag->getCompound(L"display"); if (display->contains(L"color")) display->remove(L"color"); } @@ -215,7 +215,7 @@ void ArmorItem::setColor(shared_ptr item, int color) CompoundTag *tag = item->getTag(); - if (tag == NULL) + if (tag == nullptr) { tag = new CompoundTag(); item->setTag(tag); @@ -262,5 +262,5 @@ Icon *ArmorItem::getEmptyIcon(int slot) return Item::boots_diamond->iconEmpty; } - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.World/ArmorSlot.cpp b/Minecraft.World/ArmorSlot.cpp index 7707635a5..2e85fed31 100644 --- a/Minecraft.World/ArmorSlot.cpp +++ b/Minecraft.World/ArmorSlot.cpp @@ -19,11 +19,11 @@ int ArmorSlot::getMaxStackSize() const bool ArmorSlot::mayPlace(shared_ptr item) { - if (item == NULL) + if (item == nullptr) { return false; } - if ( dynamic_cast( item->getItem() ) != NULL) + if ( dynamic_cast( item->getItem() ) != nullptr) { return dynamic_cast( item->getItem() )->slot == slotNum; } @@ -43,7 +43,7 @@ Icon *ArmorSlot::getNoItemIcon() //bool ArmorSlot::mayCombine(shared_ptr item) //{ // shared_ptr thisItemI = getItem(); -// if(thisItemI == NULL || item == NULL) return false; +// if(thisItemI == nullptr || item == nullptr) return false; // // ArmorItem *thisItem = (ArmorItem *)thisItemI->getItem(); // bool thisIsDyableArmor = thisItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH; @@ -53,7 +53,7 @@ Icon *ArmorSlot::getNoItemIcon() // //shared_ptr ArmorSlot::combine(shared_ptr item) //{ -// shared_ptr craftSlots = shared_ptr( new CraftingContainer(NULL, 2, 2) ); +// shared_ptr craftSlots = shared_ptr( new CraftingContainer(nullptr, 2, 2) ); // craftSlots->setItem(0, item); // craftSlots->setItem(1, getItem()); // Armour item needs to go second // shared_ptr result = ArmorDyeRecipe::assembleDyedArmor(craftSlots); diff --git a/Minecraft.World/ArrayWithLength.h b/Minecraft.World/ArrayWithLength.h index e22724c6a..ab491aa80 100644 --- a/Minecraft.World/ArrayWithLength.h +++ b/Minecraft.World/ArrayWithLength.h @@ -10,7 +10,7 @@ template class arrayWithLength public: T *data; unsigned int length; - arrayWithLength() { data = NULL; length = 0; } + arrayWithLength() { data = nullptr; length = 0; } arrayWithLength(unsigned int elements, bool bClearArray=true) { assert(elements!=0); data = new T[elements]; if(bClearArray){ memset( data,0,sizeof(T)*elements); } this->length = elements; } // 4J Stu Added this ctor so I static init arrays in the Item derivation tree @@ -24,7 +24,7 @@ template class arrayWithLength T *temp = new T[elements]; memset( temp,0,sizeof(T)*elements); - if( data != NULL ) + if( data != nullptr ) { std::copy( data, data+length, temp ); @@ -45,7 +45,7 @@ template class array2DWithLength public: _parrayWithLength *data; unsigned int length; - array2DWithLength() { data = NULL; length = 0; } + array2DWithLength() { data = nullptr; length = 0; } array2DWithLength(unsigned int dimA, unsigned int dimB) { data = new _parrayWithLength[dimA]; diff --git a/Minecraft.World/Arrow.cpp b/Minecraft.World/Arrow.cpp index e6ee4b9cc..4c5d9ae3b 100644 --- a/Minecraft.World/Arrow.cpp +++ b/Minecraft.World/Arrow.cpp @@ -197,7 +197,7 @@ void Arrow::tick() { Tile::tiles[t]->updateShape(level, xTile, yTile, zTile); AABB *aabb = Tile::tiles[t]->getAABB(level, xTile, yTile, zTile); - if (aabb != NULL && aabb->contains(Vec3::newTemp(x, y, z))) + if (aabb != nullptr && aabb->contains(Vec3::newTemp(x, y, z))) { inGround = true; } @@ -242,7 +242,7 @@ void Arrow::tick() from = Vec3::newTemp(x, y, z); to = Vec3::newTemp(x + xd, y + yd, z + zd); - if (res != NULL) + if (res != nullptr) { to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z); } @@ -256,7 +256,7 @@ void Arrow::tick() float rr = 0.3f; AABB *bb = e->bb->grow(rr, rr, rr); HitResult *p = bb->clip(from, to); - if (p != NULL) + if (p != nullptr) { double dd = from->distanceTo(p->pos); if (dd < nearest || nearest == 0) @@ -268,33 +268,33 @@ void Arrow::tick() } } - if (hitEntity != NULL) + if (hitEntity != nullptr) { delete res; res = new HitResult(hitEntity); } - if ( (res != NULL) && (res->entity != NULL) && res->entity->instanceof(eTYPE_PLAYER)) + if ( (res != nullptr) && (res->entity != nullptr) && res->entity->instanceof(eTYPE_PLAYER)) { shared_ptr player = dynamic_pointer_cast(res->entity); // 4J: Check for owner being null - if ( player->abilities.invulnerable || ((owner != NULL) && (owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast(owner)->canHarmPlayer(player)))) + if ( player->abilities.invulnerable || ((owner != nullptr) && (owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast(owner)->canHarmPlayer(player)))) { - res = NULL; + res = nullptr; } } - if (res != NULL) + if (res != nullptr) { - if (res->entity != NULL) + if (res->entity != nullptr) { float pow = Mth::sqrt(xd * xd + yd * yd + zd * zd); int dmg = (int) Mth::ceil(static_cast(pow * baseDamage)); if(isCritArrow()) dmg += random->nextInt(dmg / 2 + 2); - DamageSource *damageSource = NULL; - if (owner == NULL) + DamageSource *damageSource = nullptr; + if (owner == nullptr) { damageSource = DamageSource::arrow(dynamic_pointer_cast(shared_from_this()), shared_from_this()); } @@ -331,19 +331,19 @@ void Arrow::tick() } } - if (owner != NULL) + if (owner != nullptr) { ThornsEnchantment::doThornsAfterAttack(owner, mob, random); } - if (owner != NULL && res->entity != owner && owner->GetType() == eTYPE_SERVERPLAYER) + if (owner != nullptr && res->entity != owner && owner->GetType() == eTYPE_SERVERPLAYER) { dynamic_pointer_cast(owner)->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::SUCCESSFUL_BOW_HIT, 0)) ); } } // 4J : WESTY : For award, need to track if creeper was killed by arrow from the player. - if (owner != NULL && owner->instanceof(eTYPE_PLAYER) // arrow owner is a player + if (owner != nullptr && owner->instanceof(eTYPE_PLAYER) // arrow owner is a player && !res->entity->isAlive() // target is now dead && (res->entity->GetType() == eTYPE_CREEPER)) // target is a creeper diff --git a/Minecraft.World/AttributeModifier.cpp b/Minecraft.World/AttributeModifier.cpp index 6c45c4ac6..170902893 100644 --- a/Minecraft.World/AttributeModifier.cpp +++ b/Minecraft.World/AttributeModifier.cpp @@ -61,7 +61,7 @@ AttributeModifier *AttributeModifier::setSerialize(bool serialize) bool AttributeModifier::equals(AttributeModifier *modifier) { if (this == modifier) return true; - if (modifier == NULL) return false; //|| getClass() != o.getClass()) return false; + if (modifier == nullptr) return false; //|| getClass() != o.getClass()) return false; if (id != modifier->id) return false; diff --git a/Minecraft.World/AvoidPlayerGoal.cpp b/Minecraft.World/AvoidPlayerGoal.cpp index 53aebe89f..f9c6641a9 100644 --- a/Minecraft.World/AvoidPlayerGoal.cpp +++ b/Minecraft.World/AvoidPlayerGoal.cpp @@ -33,12 +33,12 @@ AvoidPlayerGoal::AvoidPlayerGoal(PathfinderMob *mob, const type_info& avoidType, entitySelector = new AvoidPlayerGoalEntitySelector(this); toAvoid = weak_ptr(); - path = NULL; + path = nullptr; } AvoidPlayerGoal::~AvoidPlayerGoal() { - if(path != NULL) delete path; + if(path != nullptr) delete path; delete entitySelector; } @@ -47,9 +47,9 @@ bool AvoidPlayerGoal::canUse() if (avoidType == typeid(Player)) { shared_ptr tamableAnimal = dynamic_pointer_cast(mob->shared_from_this()); - if (tamableAnimal != NULL && tamableAnimal->isTame()) return false; + if (tamableAnimal != nullptr && tamableAnimal->isTame()) return false; toAvoid = weak_ptr(mob->level->getNearestPlayer(mob->shared_from_this(), maxDist)); - if (toAvoid.lock() == NULL) return false; + if (toAvoid.lock() == nullptr) return false; } else { @@ -64,24 +64,24 @@ bool AvoidPlayerGoal::canUse() } Vec3 *pos = RandomPos::getPosAvoid(dynamic_pointer_cast(mob->shared_from_this()), 16, 7, Vec3::newTemp(toAvoid.lock()->x, toAvoid.lock()->y, toAvoid.lock()->z)); - if (pos == NULL) return false; + if (pos == nullptr) return false; if (toAvoid.lock()->distanceToSqr(pos->x, pos->y, pos->z) < toAvoid.lock()->distanceToSqr(mob->shared_from_this())) return false; delete path; path = pathNav->createPath(pos->x, pos->y, pos->z); - if (path == NULL) return false; + if (path == nullptr) return false; if (!path->endsInXZ(pos)) return false; return true; } bool AvoidPlayerGoal::canContinueToUse() { - return toAvoid.lock() != NULL && !pathNav->isDone(); + return toAvoid.lock() != nullptr && !pathNav->isDone(); } void AvoidPlayerGoal::start() { pathNav->moveTo(path, walkSpeedModifier); - path = NULL; + path = nullptr; } void AvoidPlayerGoal::stop() diff --git a/Minecraft.World/AwardStatPacket.cpp b/Minecraft.World/AwardStatPacket.cpp index 43328794c..07888541f 100644 --- a/Minecraft.World/AwardStatPacket.cpp +++ b/Minecraft.World/AwardStatPacket.cpp @@ -8,7 +8,7 @@ AwardStatPacket::AwardStatPacket() { - this->m_paramData.data = NULL; + this->m_paramData.data = nullptr; this->m_paramData.length = 0; } @@ -28,17 +28,17 @@ AwardStatPacket::AwardStatPacket(int statId, byteArray paramData) AwardStatPacket::~AwardStatPacket() { - if (m_paramData.data != NULL) + if (m_paramData.data != nullptr) { delete [] m_paramData.data; - m_paramData.data = NULL; + m_paramData.data = nullptr; } } void AwardStatPacket::handle(PacketListener *listener) { listener->handleAwardStat(shared_from_this()); - m_paramData.data = NULL; + m_paramData.data = nullptr; } void AwardStatPacket::read(DataInputStream *dis) //throws IOException diff --git a/Minecraft.World/BaseAttributeMap.cpp b/Minecraft.World/BaseAttributeMap.cpp index 8fb1b1f16..151448b52 100644 --- a/Minecraft.World/BaseAttributeMap.cpp +++ b/Minecraft.World/BaseAttributeMap.cpp @@ -24,7 +24,7 @@ AttributeInstance *BaseAttributeMap::getInstance(eATTRIBUTE_ID id) } else { - return NULL; + return nullptr; } } @@ -50,7 +50,7 @@ void BaseAttributeMap::removeItemModifiers(shared_ptr item) AttributeInstance* attribute = getInstance(it.first); AttributeModifier* modifier = it.second; - if (attribute != NULL) + if (attribute != nullptr) { attribute->removeModifier(modifier); } @@ -72,7 +72,7 @@ void BaseAttributeMap::addItemModifiers(shared_ptr item) AttributeInstance* attribute = getInstance(it.first); AttributeModifier* modifier = it.second; - if (attribute != NULL) + if (attribute != nullptr) { attribute->removeModifier(modifier); attribute->addModifier(new AttributeModifier(*modifier)); diff --git a/Minecraft.World/BaseEntityTile.cpp b/Minecraft.World/BaseEntityTile.cpp index 2edfbf92d..7dc06f771 100644 --- a/Minecraft.World/BaseEntityTile.cpp +++ b/Minecraft.World/BaseEntityTile.cpp @@ -25,7 +25,7 @@ bool BaseEntityTile::triggerEvent(Level *level, int x, int y, int z, int b0, int { Tile::triggerEvent(level, x, y, z, b0, b1); shared_ptr te = level->getTileEntity(x, y, z); - if (te != NULL) + if (te != nullptr) { return te->triggerEvent(b0, b1); } diff --git a/Minecraft.World/BaseMobSpawner.cpp b/Minecraft.World/BaseMobSpawner.cpp index 743427dae..b01aeb09c 100644 --- a/Minecraft.World/BaseMobSpawner.cpp +++ b/Minecraft.World/BaseMobSpawner.cpp @@ -8,10 +8,10 @@ BaseMobSpawner::BaseMobSpawner() { - spawnPotentials = NULL; + spawnPotentials = nullptr; spawnDelay = 20; entityId = L"Pig"; - nextSpawnData = NULL; + nextSpawnData = nullptr; spin = oSpin = 0.0; minSpawnDelay = SharedConstants::TICKS_PER_SECOND * 10; @@ -37,7 +37,7 @@ BaseMobSpawner::~BaseMobSpawner() wstring BaseMobSpawner::getEntityId() { - if (getNextSpawnData() == NULL) + if (getNextSpawnData() == nullptr) { if (entityId.compare(L"Minecart") == 0) { @@ -58,7 +58,7 @@ void BaseMobSpawner::setEntityId(const wstring &entityId) bool BaseMobSpawner::isNearPlayer() { - return getLevel()->getNearestPlayer(getX() + 0.5, getY() + 0.5, getZ() + 0.5, requiredPlayerRange) != NULL; + return getLevel()->getNearestPlayer(getX() + 0.5, getY() + 0.5, getZ() + 0.5, requiredPlayerRange) != nullptr; } void BaseMobSpawner::tick() @@ -95,7 +95,7 @@ void BaseMobSpawner::tick() for (int c = 0; c < spawnCount; c++) { shared_ptr entity = EntityIO::newEntity(getEntityId(), getLevel()); - if (entity == NULL) return; + if (entity == nullptr) return; int nearBy = getLevel()->getEntitiesOfClass( typeid(entity.get()), AABB::newTemp(getX(), getY(), getZ(), getX() + 1, getY() + 1, getZ() + 1)->grow(spawnRange * 2, 4, spawnRange * 2))->size(); if (nearBy >= maxNearbyEntities) @@ -111,12 +111,12 @@ void BaseMobSpawner::tick() entity->moveTo(xp, yp, zp, getLevel()->random->nextFloat() * 360, 0); - if (mob == NULL || mob->canSpawn()) + if (mob == nullptr || mob->canSpawn()) { loadDataAndAddEntity(entity); getLevel()->levelEvent(LevelEvent::PARTICLES_MOBTILE_SPAWN, getX(), getY(), getZ(), 0); - if (mob != NULL) + if (mob != nullptr) { mob->spawnAnim(); } @@ -131,7 +131,7 @@ void BaseMobSpawner::tick() shared_ptr BaseMobSpawner::loadDataAndAddEntity(shared_ptr entity) { - if (getNextSpawnData() != NULL) + if (getNextSpawnData() != nullptr) { CompoundTag *data = new CompoundTag(); entity->save(data); @@ -147,7 +147,7 @@ shared_ptr BaseMobSpawner::loadDataAndAddEntity(shared_ptr entit } entity->load(data); - if (entity->level != NULL) entity->level->addEntity(entity); + if (entity->level != nullptr) entity->level->addEntity(entity); // add mounts shared_ptr rider = entity; @@ -155,7 +155,7 @@ shared_ptr BaseMobSpawner::loadDataAndAddEntity(shared_ptr entit { CompoundTag *ridingTag = data->getCompound(Entity::RIDING_TAG); shared_ptr mount = EntityIO::newEntity(ridingTag->getString(L"id"), entity->level); - if (mount != NULL) + if (mount != nullptr) { CompoundTag *mountData = new CompoundTag(); mount->save(mountData); @@ -172,7 +172,7 @@ shared_ptr BaseMobSpawner::loadDataAndAddEntity(shared_ptr entit mount->load(mountData); mount->moveTo(rider->x, rider->y, rider->z, rider->yRot, rider->xRot); - if (entity->level != NULL) entity->level->addEntity(mount); + if (entity->level != nullptr) entity->level->addEntity(mount); rider->ride(mount); } rider = mount; @@ -180,9 +180,9 @@ shared_ptr BaseMobSpawner::loadDataAndAddEntity(shared_ptr entit } } - else if (entity->instanceof(eTYPE_LIVINGENTITY) && entity->level != NULL) + else if (entity->instanceof(eTYPE_LIVINGENTITY) && entity->level != nullptr) { - dynamic_pointer_cast( entity )->finalizeMobSpawn(NULL); + dynamic_pointer_cast( entity )->finalizeMobSpawn(nullptr); getLevel()->addEntity(entity); } @@ -200,7 +200,7 @@ void BaseMobSpawner::delay() spawnDelay = minSpawnDelay + getLevel()->random->nextInt(maxSpawnDelay - minSpawnDelay); } - if ( (spawnPotentials != NULL) && (spawnPotentials->size() > 0) ) + if ( (spawnPotentials != nullptr) && (spawnPotentials->size() > 0) ) { setNextSpawnData( static_cast(WeighedRandom::getRandomItem((Random *)getLevel()->random, (vector *)spawnPotentials)) ); } @@ -225,7 +225,7 @@ void BaseMobSpawner::load(CompoundTag *tag) } else { - spawnPotentials = NULL; + spawnPotentials = nullptr; } if (tag->contains(L"SpawnData")) @@ -234,7 +234,7 @@ void BaseMobSpawner::load(CompoundTag *tag) } else { - setNextSpawnData(NULL); + setNextSpawnData(nullptr); } if (tag->contains(L"MinSpawnDelay")) @@ -252,7 +252,7 @@ void BaseMobSpawner::load(CompoundTag *tag) if (tag->contains(L"SpawnRange")) spawnRange = tag->getShort(L"SpawnRange"); - if (getLevel() != NULL && getLevel()->isClientSide) + if (getLevel() != nullptr && getLevel()->isClientSide) { displayEntity = nullptr; } @@ -269,12 +269,12 @@ void BaseMobSpawner::save(CompoundTag *tag) tag->putShort(L"RequiredPlayerRange", static_cast(requiredPlayerRange)); tag->putShort(L"SpawnRange", static_cast(spawnRange)); - if (getNextSpawnData() != NULL) + if (getNextSpawnData() != nullptr) { tag->putCompound(L"SpawnData", static_cast(getNextSpawnData()->tag->copy())); } - if (getNextSpawnData() != NULL || (spawnPotentials != NULL && spawnPotentials->size() > 0)) + if (getNextSpawnData() != nullptr || (spawnPotentials != nullptr && spawnPotentials->size() > 0)) { ListTag *list = new ListTag(); @@ -296,9 +296,9 @@ void BaseMobSpawner::save(CompoundTag *tag) shared_ptr BaseMobSpawner::getDisplayEntity() { - if (displayEntity == NULL) + if (displayEntity == nullptr) { - shared_ptr e = EntityIO::newEntity(getEntityId(), NULL); + shared_ptr e = EntityIO::newEntity(getEntityId(), nullptr); e = loadDataAndAddEntity(e); displayEntity = e; } @@ -333,7 +333,7 @@ BaseMobSpawner::SpawnData::SpawnData(CompoundTag *base) : WeighedRandomItem(base if (_type.compare(L"Minecart") == 0) { - if (tag != NULL) + if (tag != nullptr) { switch (tag->getInt(L"Type")) { @@ -362,7 +362,7 @@ BaseMobSpawner::SpawnData::SpawnData(CompoundTag *tag, wstring _type) : WeighedR { if (_type.compare(L"Minecart") == 0) { - if (tag != NULL) + if (tag != nullptr) { switch (tag->getInt(L"Type")) { diff --git a/Minecraft.World/BasePressurePlateTile.cpp b/Minecraft.World/BasePressurePlateTile.cpp index 128a4216a..cd4c821c4 100644 --- a/Minecraft.World/BasePressurePlateTile.cpp +++ b/Minecraft.World/BasePressurePlateTile.cpp @@ -43,7 +43,7 @@ int BasePressurePlateTile::getTickDelay(Level *level) AABB *BasePressurePlateTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool BasePressurePlateTile::isSolidRender(bool isServerLevel) diff --git a/Minecraft.World/BaseRailTile.cpp b/Minecraft.World/BaseRailTile.cpp index c08c2860e..be14a2643 100644 --- a/Minecraft.World/BaseRailTile.cpp +++ b/Minecraft.World/BaseRailTile.cpp @@ -102,7 +102,7 @@ void BaseRailTile::Rail::removeSoftConnections() for (unsigned int i = 0; i < connections.size(); i++) { Rail *rail = getRail(connections[i]); - if (rail == NULL || !rail->connectsTo(this)) + if (rail == nullptr || !rail->connectsTo(this)) { delete connections[i]; connections.erase(connections.begin()+i); @@ -130,11 +130,11 @@ bool BaseRailTile::Rail::hasRail(int x, int y, int z) BaseRailTile::Rail *BaseRailTile::Rail::getRail(TilePos *p) { - if(!m_bValidRail) return NULL; + if(!m_bValidRail) return nullptr; if (isRail(level, p->x, p->y, p->z)) return new Rail(level, p->x, p->y, p->z); if (isRail(level, p->x, p->y + 1, p->z)) return new Rail(level, p->x, p->y + 1, p->z); if (isRail(level, p->x, p->y - 1, p->z)) return new Rail(level, p->x, p->y - 1, p->z); - return NULL; + return nullptr; } @@ -253,7 +253,7 @@ bool BaseRailTile::Rail::hasNeighborRail(int x, int y, int z) if(!m_bValidRail) return false; TilePos tp(x,y,z); Rail *neighbor = getRail( &tp ); - if (neighbor == NULL) return false; + if (neighbor == nullptr) return false; neighbor->removeSoftConnections(); bool retval = neighbor->canConnectTo(this); delete neighbor; @@ -331,7 +331,7 @@ void BaseRailTile::Rail::place(bool hasSignal, bool first) for ( auto& it : connections ) { Rail *neighbor = getRail(it); - if (neighbor == NULL) continue; + if (neighbor == nullptr) continue; neighbor->removeSoftConnections(); if (neighbor->canConnectTo(this)) @@ -359,7 +359,7 @@ BaseRailTile::BaseRailTile(int id, bool usesDataBit) : Tile(id, Material::decora this->usesDataBit = usesDataBit; setShape(0, 0, 0, 1, 2 / 16.0f, 1); - iconTurn = NULL; + iconTurn = nullptr; } bool BaseRailTile::isUsesDataBit() @@ -369,7 +369,7 @@ bool BaseRailTile::isUsesDataBit() AABB *BaseRailTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool BaseRailTile::blocksLight() diff --git a/Minecraft.World/BasicTree.cpp b/Minecraft.World/BasicTree.cpp index f98b4dcb0..4bf8ade4e 100644 --- a/Minecraft.World/BasicTree.cpp +++ b/Minecraft.World/BasicTree.cpp @@ -34,7 +34,7 @@ BasicTree::BasicTree(bool doUpdate) : Feature(doUpdate) trunkWidth = 1; heightVariance = 12; foliageHeight = 4; - foliageCoords = NULL; + foliageCoords = nullptr; foliageCoordsLength = 0; } @@ -126,7 +126,7 @@ void BasicTree::prepare() for( int i = clusterCount; i < clustersPerY * height; i++ ) { delete [] tempFoliageCoords[i]; - tempFoliageCoords[i] = NULL; + tempFoliageCoords[i] = nullptr; } // 4J - original code for above is the following, it isn't obvious to me why it is doing a copy of the array, so let's not for now // foliageCoords = new int[clusterCount][4]; @@ -460,7 +460,7 @@ bool BasicTree::checkLocation() int endPosition[] = { origin[0], origin[1] + height - 1, origin[2] }; // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(startPosition[0], startPosition[1], startPosition[2], endPosition[0], endPosition[1], endPosition[2]); diff --git a/Minecraft.World/BasicTypeContainers.cpp b/Minecraft.World/BasicTypeContainers.cpp index 9ecc865c6..ba2359d88 100644 --- a/Minecraft.World/BasicTypeContainers.cpp +++ b/Minecraft.World/BasicTypeContainers.cpp @@ -18,5 +18,5 @@ const double Double::MIN_NORMAL = DBL_MIN; int Integer::parseInt(wstring &str, int radix /* = 10*/) { - return wcstol( str.c_str(), NULL, radix ); + return wcstol( str.c_str(), nullptr, radix ); } \ No newline at end of file diff --git a/Minecraft.World/Bat.cpp b/Minecraft.World/Bat.cpp index dbb003026..462fef57d 100644 --- a/Minecraft.World/Bat.cpp +++ b/Minecraft.World/Bat.cpp @@ -15,7 +15,7 @@ Bat::Bat(Level *level) : AmbientCreature(level) registerAttributes(); setHealth(getMaxHealth()); - targetPosition = NULL; + targetPosition = nullptr; setSize(.5f, .9f); setResting(true); @@ -141,7 +141,7 @@ void Bat::newServerAiStep() yHeadRot = random->nextInt(360); } - if (level->getNearestPlayer(shared_from_this(), 4.0f) != NULL) + if (level->getNearestPlayer(shared_from_this(), 4.0f) != nullptr) { setResting(false); level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, static_cast(x), static_cast(y), static_cast(z), 0); @@ -151,12 +151,12 @@ void Bat::newServerAiStep() else { - if (targetPosition != NULL && (!level->isEmptyTile(targetPosition->x, targetPosition->y, targetPosition->z) || targetPosition->y < 1)) + if (targetPosition != nullptr && (!level->isEmptyTile(targetPosition->x, targetPosition->y, targetPosition->z) || targetPosition->y < 1)) { delete targetPosition; - targetPosition = NULL; + targetPosition = nullptr; } - if (targetPosition == NULL || random->nextInt(30) == 0 || targetPosition->distSqr(static_cast(x), static_cast(y), static_cast(z)) < 4) + if (targetPosition == nullptr || random->nextInt(30) == 0 || targetPosition->distSqr(static_cast(x), static_cast(y), static_cast(z)) < 4) { delete targetPosition; targetPosition = new Pos(static_cast(x) + random->nextInt(7) - random->nextInt(7), static_cast(y) + random->nextInt(6) - 2, static_cast(z) + random->nextInt(7) - random->nextInt(7)); diff --git a/Minecraft.World/BeaconMenu.cpp b/Minecraft.World/BeaconMenu.cpp index 62908b4f4..0d7e54b46 100644 --- a/Minecraft.World/BeaconMenu.cpp +++ b/Minecraft.World/BeaconMenu.cpp @@ -60,7 +60,7 @@ shared_ptr BeaconMenu::quickMoveStack(shared_ptr player, i { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -127,7 +127,7 @@ BeaconMenu::PaymentSlot::PaymentSlot(shared_ptr container, int slot, bool BeaconMenu::PaymentSlot::mayPlace(shared_ptr item) { - if (item != NULL) + if (item != nullptr) { return (item->id == Item::emerald_Id || item->id == Item::diamond_Id || item->id == Item::goldIngot_Id || item->id == Item::ironIngot_Id); } diff --git a/Minecraft.World/BeaconTile.cpp b/Minecraft.World/BeaconTile.cpp index f002cbe29..998f15e85 100644 --- a/Minecraft.World/BeaconTile.cpp +++ b/Minecraft.World/BeaconTile.cpp @@ -19,7 +19,7 @@ bool BeaconTile::use(Level *level, int x, int y, int z, shared_ptr playe if (level->isClientSide) return true; shared_ptr beacon = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (beacon != NULL) player->openBeacon(beacon); + if (beacon != nullptr) player->openBeacon(beacon); return true; } diff --git a/Minecraft.World/BeaconTileEntity.cpp b/Minecraft.World/BeaconTileEntity.cpp index 17f64723f..10e74eee1 100644 --- a/Minecraft.World/BeaconTileEntity.cpp +++ b/Minecraft.World/BeaconTileEntity.cpp @@ -28,7 +28,7 @@ void BeaconTileEntity::staticCtor() { for(unsigned int effect = 0; effect < BEACON_EFFECTS_EFFECTS; ++effect) { - BEACON_EFFECTS[tier][effect] = NULL; + BEACON_EFFECTS[tier][effect] = nullptr; } } BEACON_EFFECTS[0][0] = MobEffect::movementSpeed; @@ -213,7 +213,7 @@ void BeaconTileEntity::setPrimaryPower(int primaryPower) for(unsigned int e = 0; e < BEACON_EFFECTS_EFFECTS; ++e) { MobEffect *effect = BEACON_EFFECTS[tier][e]; - if(effect == NULL) break; + if(effect == nullptr) break; if (effect->id == primaryPower) { @@ -236,7 +236,7 @@ void BeaconTileEntity::setSecondaryPower(int secondaryPower) for(unsigned int e = 0; e < BEACON_EFFECTS_EFFECTS; ++e) { MobEffect *effect = BEACON_EFFECTS[tier][e]; - if(effect == NULL) break; + if(effect == nullptr) break; if (effect->id == secondaryPower) { @@ -295,7 +295,7 @@ shared_ptr BeaconTileEntity::getItem(unsigned int slot) shared_ptr BeaconTileEntity::removeItem(unsigned int slot, int count) { - if (slot == 0 && paymentItem != NULL) + if (slot == 0 && paymentItem != nullptr) { if (count >= paymentItem->count) { @@ -314,7 +314,7 @@ shared_ptr BeaconTileEntity::removeItem(unsigned int slot, int cou shared_ptr BeaconTileEntity::removeItemNoUpdate(int slot) { - if (slot == 0 && paymentItem != NULL) + if (slot == 0 && paymentItem != nullptr) { shared_ptr returnItem = paymentItem; paymentItem = nullptr; diff --git a/Minecraft.World/BedTile.cpp b/Minecraft.World/BedTile.cpp index 039943bdc..5597f7409 100644 --- a/Minecraft.World/BedTile.cpp +++ b/Minecraft.World/BedTile.cpp @@ -16,9 +16,9 @@ BedTile::BedTile(int id) : DirectionalTile(id, Material::cloth, isSolidRender()) { setShape(); - iconEnd = NULL; - iconSide = NULL; - iconTop = NULL; + iconEnd = nullptr; + iconSide = nullptr; + iconTop = nullptr; } // 4J Added override @@ -120,7 +120,7 @@ bool BedTile::use(Level *level, int x, int y, int z, shared_ptr player, } } - if (sleepingPlayer == NULL) + if (sleepingPlayer == nullptr) { setOccupied(level, x, y, z, false); } @@ -309,7 +309,7 @@ Pos *BedTile::findStandUpPosition(Level *level, int x, int y, int z, int skipCou } } - return NULL; + return nullptr; } void BedTile::spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonus) diff --git a/Minecraft.World/BegGoal.cpp b/Minecraft.World/BegGoal.cpp index 975539282..3f059b66e 100644 --- a/Minecraft.World/BegGoal.cpp +++ b/Minecraft.World/BegGoal.cpp @@ -20,14 +20,14 @@ BegGoal::BegGoal(Wolf *wolf, float lookDistance) bool BegGoal::canUse() { player = weak_ptr(level->getNearestPlayer(wolf->shared_from_this(), lookDistance)); - if (player.lock() == NULL) return false; + if (player.lock() == nullptr) return false; wolf->setDespawnProtected(); return playerHoldingInteresting(player.lock()); } bool BegGoal::canContinueToUse() { - if (player.lock() == NULL || !player.lock()->isAlive()) return false; + if (player.lock() == nullptr || !player.lock()->isAlive()) return false; if (wolf->distanceToSqr(player.lock()) > lookDistance * lookDistance) return false; wolf->setDespawnProtected(); return lookTime > 0 && playerHoldingInteresting(player.lock()); @@ -54,7 +54,7 @@ void BegGoal::tick() bool BegGoal::playerHoldingInteresting(shared_ptr player) { shared_ptr item = player->inventory->getSelected(); - if (item == NULL) return false; + if (item == nullptr) return false; if (!wolf->isTame() && item->id == Item::bone_Id) return true; return wolf->isFood(item); } \ No newline at end of file diff --git a/Minecraft.World/BinaryHeap.cpp b/Minecraft.World/BinaryHeap.cpp index 3a3d1c1e6..4fc5ce455 100644 --- a/Minecraft.World/BinaryHeap.cpp +++ b/Minecraft.World/BinaryHeap.cpp @@ -58,7 +58,7 @@ Node *BinaryHeap::pop() { Node *popped = heap[0]; heap[0] = heap[--sizeVar]; - heap[sizeVar] = NULL; + heap[sizeVar] = nullptr; if (sizeVar > 0) downHeap(0); popped->heapIdx=-1; return popped; @@ -68,7 +68,7 @@ void BinaryHeap::remove(Node *node) { // This is what node.heapIdx is for. heap[node->heapIdx] = heap[--sizeVar]; - heap[sizeVar] = NULL; + heap[sizeVar] = nullptr; if (sizeVar > node->heapIdx) { if (heap[node->heapIdx]->f < node->f) @@ -145,7 +145,7 @@ void BinaryHeap::downHeap(int idx) if (rightIdx >= sizeVar) { // Only need to compare with left. - rightNode = NULL; + rightNode = nullptr; rightCost = Float::POSITIVE_INFINITY; } else diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index f8ac2107d..66265765e 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -13,34 +13,34 @@ //public static final Biome[] biomes = new Biome[256]; Biome *Biome::biomes[256]; -Biome *Biome::ocean = NULL; -Biome *Biome::plains = NULL; -Biome *Biome::desert = NULL; +Biome *Biome::ocean = nullptr; +Biome *Biome::plains = nullptr; +Biome *Biome::desert = nullptr; -Biome *Biome::extremeHills = NULL; -Biome *Biome::forest = NULL; -Biome *Biome::taiga = NULL; +Biome *Biome::extremeHills = nullptr; +Biome *Biome::forest = nullptr; +Biome *Biome::taiga = nullptr; -Biome *Biome::swampland = NULL; -Biome *Biome::river = NULL; +Biome *Biome::swampland = nullptr; +Biome *Biome::river = nullptr; -Biome *Biome::hell = NULL; -Biome *Biome::sky = NULL; +Biome *Biome::hell = nullptr; +Biome *Biome::sky = nullptr; -Biome *Biome::frozenOcean = NULL; -Biome *Biome::frozenRiver = NULL; -Biome *Biome::iceFlats = NULL; -Biome *Biome::iceMountains = NULL; -Biome *Biome::mushroomIsland = NULL; -Biome *Biome::mushroomIslandShore = NULL; -Biome *Biome::beaches = NULL; -Biome *Biome::desertHills = NULL; -Biome *Biome::forestHills = NULL; -Biome *Biome::taigaHills = NULL; -Biome *Biome::smallerExtremeHills = NULL; +Biome *Biome::frozenOcean = nullptr; +Biome *Biome::frozenRiver = nullptr; +Biome *Biome::iceFlats = nullptr; +Biome *Biome::iceMountains = nullptr; +Biome *Biome::mushroomIsland = nullptr; +Biome *Biome::mushroomIslandShore = nullptr; +Biome *Biome::beaches = nullptr; +Biome *Biome::desertHills = nullptr; +Biome *Biome::forestHills = nullptr; +Biome *Biome::taigaHills = nullptr; +Biome *Biome::smallerExtremeHills = nullptr; -Biome *Biome::jungle = NULL; -Biome *Biome::jungleHills = NULL; +Biome *Biome::jungle = nullptr; +Biome *Biome::jungleHills = nullptr; void Biome::staticCtor() @@ -95,7 +95,7 @@ Biome::Biome(int id) : id(id) temperature = 0.5f; downfall = 0.5f; //waterColor = 0xffffff; // 4J Stu - Not used - decorator = NULL; + decorator = nullptr; m_grassColor = eMinecraftColour_NOT_SET; m_foliageColor = eMinecraftColour_NOT_SET; @@ -132,7 +132,7 @@ Biome::Biome(int id) : id(id) Biome::~Biome() { - if(decorator != NULL) delete decorator; + if(decorator != nullptr) delete decorator; } BiomeDecorator *Biome::createDecorator() @@ -228,7 +228,7 @@ vector *Biome::getMobs(MobCategory *category) if (category == MobCategory::creature_wolf) return &friendlies_wolf; if (category == MobCategory::creature_mushroomcow) return &friendlies_mushroomcow; if (category == MobCategory::ambient) return &ambientFriendlies; - return NULL; + return nullptr; } bool Biome::hasSnow() diff --git a/Minecraft.World/BiomeCache.cpp b/Minecraft.World/BiomeCache.cpp index f5469c595..78384c371 100644 --- a/Minecraft.World/BiomeCache.cpp +++ b/Minecraft.World/BiomeCache.cpp @@ -10,7 +10,7 @@ BiomeCache::Block::Block(int x, int z, BiomeCache *parent) // temps = floatArray(ZONE_SIZE * ZONE_SIZE, false); // MGH - added "no clear" flag to arrayWithLength // downfall = floatArray(ZONE_SIZE * ZONE_SIZE, false); // biomes = BiomeArray(ZONE_SIZE * ZONE_SIZE, false); - biomeIndices = byteArray(ZONE_SIZE * ZONE_SIZE, false); + biomeIndices = byteArray(static_cast(ZONE_SIZE * ZONE_SIZE), false); lastUse = 0; this->x = x; @@ -87,7 +87,7 @@ BiomeCache::Block *BiomeCache::getBlockAt(int x, int z) z >>= ZONE_SIZE_BITS; __int64 slot = (static_cast<__int64>(x) & 0xffffffffl) | ((static_cast<__int64>(z) & 0xffffffffl) << 32l); auto it = cached.find(slot); - Block *block = NULL; + Block *block = nullptr; if (it == cached.end()) { MemSect(48); diff --git a/Minecraft.World/BiomeDecorator.cpp b/Minecraft.World/BiomeDecorator.cpp index a3cbf546c..add156e88 100644 --- a/Minecraft.World/BiomeDecorator.cpp +++ b/Minecraft.World/BiomeDecorator.cpp @@ -9,8 +9,8 @@ BiomeDecorator::BiomeDecorator(Biome *biome) _init(); // 4J inits - level = NULL; - random = NULL; + level = nullptr; + random = nullptr; xo = 0; zo = 0; @@ -19,7 +19,7 @@ BiomeDecorator::BiomeDecorator(Biome *biome) void BiomeDecorator::decorate(Level *level, Random *random, int xo, int zo) { - if (this->level != NULL) + if (this->level != nullptr) { app.DebugPrintf("BiomeDecorator::decorate - Already decorating!!\n"); #ifndef _CONTENT_PACKAGE @@ -34,8 +34,8 @@ void BiomeDecorator::decorate(Level *level, Random *random, int xo, int zo) decorate(); - this->level = NULL; - this->random = NULL; + this->level = nullptr; + this->random = nullptr; } @@ -164,7 +164,7 @@ void BiomeDecorator::decorate() // 4J Stu - For some reason this was created each time round in the loop // I assume there is a case where deadBushCount could be 0 - DeadBushFeature *deadBushFeature = NULL; + DeadBushFeature *deadBushFeature = nullptr; if(deadBushCount > 0) deadBushFeature = new DeadBushFeature(Tile::deadBush_Id); for (int i = 0; i < deadBushCount; i++) { @@ -174,7 +174,7 @@ void BiomeDecorator::decorate() //new DeadBushFeature(Tile::deadBush_Id)->place(level, random, x, y, z); deadBushFeature->place(level, random, x, y, z); } - if(deadBushFeature != NULL)delete deadBushFeature; + if(deadBushFeature != nullptr)delete deadBushFeature; for (int i = 0; i < waterlilyCount; i++) { diff --git a/Minecraft.World/BiomeOverrideLayer.cpp b/Minecraft.World/BiomeOverrideLayer.cpp index a44295dc2..846057408 100644 --- a/Minecraft.World/BiomeOverrideLayer.cpp +++ b/Minecraft.World/BiomeOverrideLayer.cpp @@ -11,14 +11,14 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) #ifdef _UNICODE wstring path = L"GAME:\\GameRules\\biomemap.bin"; - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #else #ifdef _WINDOWS64 string path = "GameRules\\biomemap.bin"; #else string path = "GAME:\\GameRules\\biomemap.bin"; #endif - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if( file == INVALID_HANDLE_VALUE ) { @@ -35,14 +35,14 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) __debugbreak(); // TODO DWORD bytesRead,dwFileSize = 0; #else - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr); #endif if(dwFileSize > m_biomeOverride.length) { app.DebugPrintf("Biomemap binary is too large!!\n"); __debugbreak(); } - BOOL bSuccess = ReadFile(file,m_biomeOverride.data,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(file,m_biomeOverride.data,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { diff --git a/Minecraft.World/BiomeSource.cpp b/Minecraft.World/BiomeSource.cpp index d2454f4a6..885ea6320 100644 --- a/Minecraft.World/BiomeSource.cpp +++ b/Minecraft.World/BiomeSource.cpp @@ -87,10 +87,10 @@ floatArray BiomeSource::getDownfallBlock(int x, int z, int w, int h) const void BiomeSource::getDownfallBlock(floatArray &downfalls, int x, int z, int w, int h) const { IntCache::releaseAll(); - //if (downfalls == NULL || downfalls->length < w * h) - if (downfalls.data == NULL || downfalls.length < w * h) + //if (downfalls == nullptr || downfalls->length < w * h) + if (downfalls.data == nullptr || downfalls.length < w * h) { - if(downfalls.data != NULL) delete [] downfalls.data; + if(downfalls.data != nullptr) delete [] downfalls.data; downfalls = floatArray(w * h); } @@ -132,9 +132,9 @@ void BiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z, in { IntCache::releaseAll(); //if (temperatures == null || temperatures.length < w * h) { - if (temperatures.data == NULL || temperatures.length < w * h) + if (temperatures.data == nullptr || temperatures.length < w * h) { - if( temperatures.data != NULL ) delete [] temperatures.data; + if( temperatures.data != nullptr ) delete [] temperatures.data; temperatures = floatArray(w * h); } @@ -170,9 +170,9 @@ void BiomeSource::getRawBiomeBlock(BiomeArray &biomes, int x, int z, int w, int { IntCache::releaseAll(); //if (biomes == null || biomes.length < w * h) - if (biomes.data == NULL || biomes.length < w * h) + if (biomes.data == nullptr || biomes.length < w * h) { - if(biomes.data != NULL) delete [] biomes.data; + if(biomes.data != nullptr) delete [] biomes.data; biomes = BiomeArray(w * h); } @@ -181,7 +181,7 @@ void BiomeSource::getRawBiomeBlock(BiomeArray &biomes, int x, int z, int w, int { biomes[i] = Biome::biomes[result[i]]; #ifndef _CONTENT_PACKAGE - if(biomes[i] == NULL) + if(biomes[i] == nullptr) { app.DebugPrintf("Tried to assign null biome %d\n", result[i]); __debugbreak(); @@ -208,9 +208,9 @@ void BiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h, { IntCache::releaseAll(); //if (biomes == null || biomes.length < w * h) - if (biomes.data == NULL || biomes.length < w * h) + if (biomes.data == nullptr || biomes.length < w * h) { - if(biomes.data != NULL) delete [] biomes.data; + if(biomes.data != nullptr) delete [] biomes.data; biomes = BiomeArray(w * h); } @@ -248,9 +248,9 @@ void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, int { IntCache::releaseAll(); //if (biomes == null || biomes.length < w * h) - if (biomeIndices.data == NULL || biomeIndices.length < w * h) + if (biomeIndices.data == nullptr || biomeIndices.length < w * h) { - if(biomeIndices.data != NULL) delete [] biomeIndices.data; + if(biomeIndices.data != nullptr) delete [] biomeIndices.data; biomeIndices = byteArray(w * h); } @@ -341,7 +341,7 @@ TilePos *BiomeSource::findBiome(int x, int z, int r, Biome *toFind, Random *rand int w = x1 - x0 + 1; int h = z1 - z0 + 1; intArray biomes = layer->getArea(x0, z0, w, h); - TilePos *res = NULL; + TilePos *res = nullptr; int found = 0; int biomesCount = w*h; for (unsigned int i = 0; i < biomesCount; i++) @@ -351,7 +351,7 @@ TilePos *BiomeSource::findBiome(int x, int z, int r, Biome *toFind, Random *rand Biome *b = Biome::biomes[biomes[i]]; if (b == toFind) { - if (res == NULL || random->nextInt(found + 1) == 0) + if (res == nullptr || random->nextInt(found + 1) == 0) { res = new TilePos(xx, 0, zz); found++; @@ -380,7 +380,7 @@ TilePos *BiomeSource::findBiome(int x, int z, int r, vector allowed, Ra int h = z1 - z0 + 1; MemSect(50); intArray biomes = layer->getArea(x0, z0, w, h); - TilePos *res = NULL; + TilePos *res = nullptr; int found = 0; for (unsigned int i = 0; i < w * h; i++) { @@ -389,7 +389,7 @@ TilePos *BiomeSource::findBiome(int x, int z, int r, vector allowed, Ra Biome *b = Biome::biomes[biomes[i]]; if (find(allowed.begin(), allowed.end(), b) != allowed.end()) { - if (res == NULL || random->nextInt(found + 1) == 0) + if (res == nullptr || random->nextInt(found + 1) == 0) { delete res; res = new TilePos(xx, 0, zz); diff --git a/Minecraft.World/BirchFeature.cpp b/Minecraft.World/BirchFeature.cpp index d7a57514d..3c423564a 100644 --- a/Minecraft.World/BirchFeature.cpp +++ b/Minecraft.World/BirchFeature.cpp @@ -42,7 +42,7 @@ bool BirchFeature::place(Level *level, Random *random, int x, int y, int z) if ((belowTile != Tile::grass_Id && belowTile != Tile::dirt_Id) || y >= Level::maxBuildHeight - treeHeight - 1) return false; // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); int radius = 3; diff --git a/Minecraft.World/Blaze.cpp b/Minecraft.World/Blaze.cpp index 652aa673b..de74fc758 100644 --- a/Minecraft.World/Blaze.cpp +++ b/Minecraft.World/Blaze.cpp @@ -87,7 +87,7 @@ void Blaze::aiStep() allowedHeightOffset = .5f + static_cast(random->nextGaussian()) * 3; } - if (getAttackTarget() != NULL && (getAttackTarget()->y + getAttackTarget()->getHeadHeight()) > (y + getHeadHeight() + allowedHeightOffset)) + if (getAttackTarget() != nullptr && (getAttackTarget()->y + getAttackTarget()->getHeadHeight()) > (y + getHeadHeight() + allowedHeightOffset)) { yd = yd + (.3f - yd) * .3f; } diff --git a/Minecraft.World/BlockReplacements.cpp b/Minecraft.World/BlockReplacements.cpp index ac31b3d2e..f60d9e2af 100644 --- a/Minecraft.World/BlockReplacements.cpp +++ b/Minecraft.World/BlockReplacements.cpp @@ -9,7 +9,7 @@ void BlockReplacements::staticCtor() for (int i = 0; i < 256; i++) { byte b = static_cast(i); - if (b != 0 && Tile::tiles[b & 0xff] == NULL) + if (b != 0 && Tile::tiles[b & 0xff] == nullptr) { b = 0; } diff --git a/Minecraft.World/Boat.cpp b/Minecraft.World/Boat.cpp index 1811c2094..a470936ab 100644 --- a/Minecraft.World/Boat.cpp +++ b/Minecraft.World/Boat.cpp @@ -97,7 +97,7 @@ bool Boat::hurt(DamageSource *source, float hurtDamage) // 4J-JEV: Fix for #88212, // Untrusted players shouldn't be able to damage minecarts or boats. - if (dynamic_cast(source) != NULL) + if (dynamic_cast(source) != nullptr) { shared_ptr attacker = source->getDirectEntity(); @@ -113,18 +113,18 @@ bool Boat::hurt(DamageSource *source, float hurtDamage) // 4J Stu - If someone is riding in this, then it can tick multiple times which causes the damage to // decrease too quickly. So just make the damage a bit higher to start with for similar behaviour // to an unridden one. Only do this change if the riding player is attacking it. - if( rider.lock() != NULL && rider.lock() == source->getEntity() ) hurtDamage += 1; + if( rider.lock() != nullptr && rider.lock() == source->getEntity() ) hurtDamage += 1; setDamage(getDamage() + hurtDamage * 10); markHurt(); // 4J Stu - Brought froward from 12w36 to fix #46611 - TU5: Gameplay: Minecarts and boat requires more hits than one to be destroyed in creative mode // 4J-PB - Fix for XB1 #175735 - [CRASH] [Multi-Plat]: Code: Gameplay: Placing a boat on harmful surfaces causes the game to crash - bool creativePlayer = (source->getEntity() != NULL) && source->getEntity()->instanceof(eTYPE_PLAYER) && dynamic_pointer_cast(source->getEntity())->abilities.instabuild; + bool creativePlayer = (source->getEntity() != nullptr) && source->getEntity()->instanceof(eTYPE_PLAYER) && dynamic_pointer_cast(source->getEntity())->abilities.instabuild; if (creativePlayer || getDamage() > 20 * 2) { - if (rider.lock() != NULL) rider.lock()->ride( shared_from_this() ); + if (rider.lock() != nullptr) rider.lock()->ride( shared_from_this() ); if (!creativePlayer) spawnAtLocation(Item::boat_Id, 1, 0); remove(); } @@ -318,7 +318,7 @@ void Boat::tick() } - if ( rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY) ) + if ( rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_LIVINGENTITY) ) { shared_ptr livingRider = dynamic_pointer_cast(rider.lock()); double forward = livingRider->yya; @@ -438,7 +438,7 @@ void Boat::tick() } - if (rider.lock() != NULL) + if (rider.lock() != nullptr) { if (rider.lock()->removed) rider = weak_ptr(); } @@ -446,7 +446,7 @@ void Boat::tick() void Boat::positionRider() { - if (rider.lock() == NULL) return; + if (rider.lock() == nullptr) return; double xa = cos(yRot * PI / 180) * 0.4; double za = sin(yRot * PI / 180) * 0.4; @@ -475,7 +475,7 @@ wstring Boat::getName() bool Boat::interact(shared_ptr player) { - if ( (rider.lock() != NULL) && rider.lock()->instanceof(eTYPE_PLAYER) && (rider.lock() != player) ) return true; + if ( (rider.lock() != nullptr) && rider.lock()->instanceof(eTYPE_PLAYER) && (rider.lock() != player) ) return true; if (!level->isClientSide) { // 4J HEG - Fixed issue with player not being able to dismount boat (issue #4446) diff --git a/Minecraft.World/BoatItem.cpp b/Minecraft.World/BoatItem.cpp index d2bb75b5b..379e5e448 100644 --- a/Minecraft.World/BoatItem.cpp +++ b/Minecraft.World/BoatItem.cpp @@ -39,7 +39,7 @@ bool BoatItem::TestUse(shared_ptr itemInstance, Level *level, shar double range = 5; Vec3 *to = from->add(xa * range, ya * range, za * range); HitResult *hr = level->clip(from, to, true); - if (hr == NULL) return false; + if (hr == nullptr) return false; if (hr->type == HitResult::TILE) { @@ -74,7 +74,7 @@ shared_ptr BoatItem::use(shared_ptr itemInstance, Le double range = 5; Vec3 *to = from->add(xa * range, ya * range, za * range); HitResult *hr = level->clip(from, to, true); - if (hr == NULL) return itemInstance; + if (hr == nullptr) return itemInstance; // check entity collision Vec3 *b = player->getViewVector(a); diff --git a/Minecraft.World/BonusChestFeature.cpp b/Minecraft.World/BonusChestFeature.cpp index 6d083f547..cd33e60ae 100644 --- a/Minecraft.World/BonusChestFeature.cpp +++ b/Minecraft.World/BonusChestFeature.cpp @@ -59,7 +59,7 @@ bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z, { level->setTileAndData(x2, y2, z2, Tile::chest_Id, 0, Tile::UPDATE_CLIENTS); shared_ptr chest = dynamic_pointer_cast(level->getTileEntity(x2, y2, z2)); - if (chest != NULL) + if (chest != nullptr) { WeighedTreasure::addChestItems(random, treasureList, chest, numRolls); chest->isBonusChest = true; // 4J added diff --git a/Minecraft.World/BottleItem.cpp b/Minecraft.World/BottleItem.cpp index 7a666752d..57fb95cdf 100644 --- a/Minecraft.World/BottleItem.cpp +++ b/Minecraft.World/BottleItem.cpp @@ -18,7 +18,7 @@ Icon *BottleItem::getIcon(int auxValue) shared_ptr BottleItem::use(shared_ptr itemInstance, Level *level, shared_ptr player) { HitResult *hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) return itemInstance; + if (hr == nullptr) return itemInstance; if (hr->type == HitResult::TILE) { @@ -63,7 +63,7 @@ shared_ptr BottleItem::use(shared_ptr itemInstance, bool BottleItem::TestUse(shared_ptr itemInstance, Level *level, shared_ptr player) { HitResult *hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) return false; + if (hr == nullptr) return false; if (hr->type == HitResult::TILE) { diff --git a/Minecraft.World/BoundingBox.cpp b/Minecraft.World/BoundingBox.cpp index 74dba470f..e93158f2d 100644 --- a/Minecraft.World/BoundingBox.cpp +++ b/Minecraft.World/BoundingBox.cpp @@ -115,7 +115,7 @@ BoundingBox *BoundingBox::getIntersection(BoundingBox *other) { if (!intersects(other)) { - return NULL; + return nullptr; } BoundingBox *result = new BoundingBox(); result->x0 = Math::_max(x0, other->x0); diff --git a/Minecraft.World/BowItem.cpp b/Minecraft.World/BowItem.cpp index ef55a8a5c..b2ef08c9e 100644 --- a/Minecraft.World/BowItem.cpp +++ b/Minecraft.World/BowItem.cpp @@ -15,7 +15,7 @@ BowItem::BowItem(int id) : Item( id ) maxStackSize = 1; setMaxDamage(384); - icons = NULL; + icons = nullptr; } void BowItem::releaseUsing(shared_ptr itemInstance, Level *level, shared_ptr player, int durationLeft) diff --git a/Minecraft.World/BreedGoal.cpp b/Minecraft.World/BreedGoal.cpp index 1c46fd90f..11840388c 100644 --- a/Minecraft.World/BreedGoal.cpp +++ b/Minecraft.World/BreedGoal.cpp @@ -25,12 +25,12 @@ bool BreedGoal::canUse() { if (!animal->isInLove()) return false; partner = weak_ptr(getFreePartner()); - return partner.lock() != NULL; + return partner.lock() != nullptr; } bool BreedGoal::canContinueToUse() { - return partner.lock() != NULL && partner.lock()->isAlive() && partner.lock()->isInLove() && loveTime < 20 * 3; + return partner.lock() != nullptr && partner.lock()->isAlive() && partner.lock()->isInLove() && loveTime < 20 * 3; } void BreedGoal::stop() @@ -74,21 +74,21 @@ void BreedGoal::breed() shared_ptr offspring = animal->getBreedOffspring(partner.lock()); animal->setDespawnProtected(); partner.lock()->setDespawnProtected(); - if (offspring == NULL) + if (offspring == nullptr) { - // This will be NULL if we've hit our limits for spawning any particular type of animal... reset things as normally as we can, without actually producing any offspring + // This will be nullptr if we've hit our limits for spawning any particular type of animal... reset things as normally as we can, without actually producing any offspring animal->resetLove(); partner.lock()->resetLove(); return; } shared_ptr loveCause = animal->getLoveCause(); - if (loveCause == NULL && partner.lock()->getLoveCause() != NULL) + if (loveCause == nullptr && partner.lock()->getLoveCause() != nullptr) { loveCause = partner.lock()->getLoveCause(); } - if (loveCause != NULL) + if (loveCause != nullptr) { // Record mob bred stat. loveCause->awardStat(GenericStats::breedEntity(offspring->GetType()),GenericStats::param_breedEntity(offspring->GetType())); diff --git a/Minecraft.World/BrewingStandMenu.cpp b/Minecraft.World/BrewingStandMenu.cpp index 4f9e2ac34..2200f47c3 100644 --- a/Minecraft.World/BrewingStandMenu.cpp +++ b/Minecraft.World/BrewingStandMenu.cpp @@ -69,7 +69,7 @@ shared_ptr BrewingStandMenu::quickMoveStack(shared_ptr pla Slot *PotionSlot2 = slots.at(BOTTLE_SLOT_START+1); Slot *PotionSlot3 = slots.at(BOTTLE_SLOT_START+2); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -199,7 +199,7 @@ bool BrewingStandMenu::PotionSlot::mayCombine(shared_ptr second) bool BrewingStandMenu::PotionSlot::mayPlaceItem(shared_ptr item) { - return item != NULL && (item->id == Item::potion_Id || item->id == Item::glassBottle_Id); + return item != nullptr && (item->id == Item::potion_Id || item->id == Item::glassBottle_Id); } @@ -210,7 +210,7 @@ BrewingStandMenu::IngredientsSlot::IngredientsSlot(shared_ptr contain bool BrewingStandMenu::IngredientsSlot::mayPlace(shared_ptr item) { - if (item != NULL) + if (item != nullptr) { if (PotionBrewing::SIMPLIFIED_BREWING) { diff --git a/Minecraft.World/BrewingStandTile.cpp b/Minecraft.World/BrewingStandTile.cpp index afb324ce0..afdf839aa 100644 --- a/Minecraft.World/BrewingStandTile.cpp +++ b/Minecraft.World/BrewingStandTile.cpp @@ -10,7 +10,7 @@ BrewingStandTile::BrewingStandTile(int id) : BaseEntityTile(id, Material::metal, isSolidRender()) { random = new Random(); - iconBase = NULL; + iconBase = nullptr; } BrewingStandTile::~BrewingStandTile() @@ -60,7 +60,7 @@ bool BrewingStandTile::use(Level *level, int x, int y, int z, shared_ptr return true; } shared_ptr brewingStand = dynamic_pointer_cast(level->getTileEntity(x, y, z)); - if (brewingStand != NULL) player->openBrewingStand(brewingStand); + if (brewingStand != nullptr) player->openBrewingStand(brewingStand); return true; } @@ -86,13 +86,13 @@ void BrewingStandTile::animateTick(Level *level, int xt, int yt, int zt, Random void BrewingStandTile::onRemove(Level *level, int x, int y, int z, int id, int data) { shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && ( dynamic_pointer_cast(tileEntity) != NULL) ) + if (tileEntity != nullptr && ( dynamic_pointer_cast(tileEntity) != nullptr) ) { shared_ptr container = dynamic_pointer_cast(tileEntity); for (int i = 0; i < container->getContainerSize(); i++) { shared_ptr item = container->getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; diff --git a/Minecraft.World/BrewingStandTileEntity.cpp b/Minecraft.World/BrewingStandTileEntity.cpp index 2c535a0e7..825149816 100644 --- a/Minecraft.World/BrewingStandTileEntity.cpp +++ b/Minecraft.World/BrewingStandTileEntity.cpp @@ -96,7 +96,7 @@ int BrewingStandTileEntity::getBrewTime() bool BrewingStandTileEntity::isBrewable() { - if (items[INGREDIENT_SLOT] == NULL || items[INGREDIENT_SLOT]->count <= 0) + if (items[INGREDIENT_SLOT] == nullptr || items[INGREDIENT_SLOT]->count <= 0) { return false; } @@ -111,7 +111,7 @@ bool BrewingStandTileEntity::isBrewable() bool oneResult = false; for (int dest = 0; dest < 3; dest++) { - if (items[dest] != NULL && items[dest]->id == Item::potion_Id) + if (items[dest] != nullptr && items[dest]->id == Item::potion_Id) { int currentBrew = items[dest]->getAuxValue(); int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) ); @@ -129,7 +129,7 @@ bool BrewingStandTileEntity::isBrewable() // TODO - find out whether actually checking pointers to MobEffectInstance classes for equality // is of any use bool equals = false; - if( ( currentEffects != NULL ) && ( newEffects != NULL ) ) + if( ( currentEffects != nullptr ) && ( newEffects != nullptr ) ) { if( currentEffects->size() == newEffects->size() ) { @@ -141,7 +141,7 @@ bool BrewingStandTileEntity::isBrewable() } if ((currentBrew > 0 && currentEffects == newEffects) || - (currentEffects != NULL && (equals || newEffects == NULL))) + (currentEffects != nullptr && (equals || newEffects == nullptr))) { } else if (currentBrew != newBrew) @@ -166,7 +166,7 @@ bool BrewingStandTileEntity::isBrewable() bool oneResult = false; for (int dest = 0; dest < 3; dest++) { - if (items[dest] != NULL && items[dest]->id == Item::potion_Id) + if (items[dest] != nullptr && items[dest]->id == Item::potion_Id) { int currentBrew = items[dest]->getAuxValue(); int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) ); @@ -176,7 +176,7 @@ bool BrewingStandTileEntity::isBrewable() break; } } - else if (isWater && items[dest] != NULL && items[dest]->id == Item::glassBottle_Id) + else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id) { oneResult = true; break; @@ -199,7 +199,7 @@ void BrewingStandTileEntity::doBrew() { for (int dest = 0; dest < 3; dest++) { - if (items[dest] != NULL && items[dest]->id == Item::potion_Id) + if (items[dest] != nullptr && items[dest]->id == Item::potion_Id) { int currentBrew = items[dest]->getAuxValue(); int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) ); @@ -211,7 +211,7 @@ void BrewingStandTileEntity::doBrew() // TODO - find out whether actually checking pointers to MobEffectInstance classes for equality // is of any use bool equals = false; - if( ( currentEffects != NULL ) && ( newEffects != NULL ) ) + if( ( currentEffects != nullptr ) && ( newEffects != nullptr ) ) { if( currentEffects->size() == newEffects->size() ) { @@ -223,7 +223,7 @@ void BrewingStandTileEntity::doBrew() } if ((currentBrew > 0 && currentEffects == newEffects) || - (currentEffects != NULL && (equals || newEffects == NULL))) + (currentEffects != nullptr && (equals || newEffects == nullptr))) { if (!PotionItem::isThrowable(currentBrew) && PotionItem::isThrowable(newBrew)) { @@ -246,13 +246,13 @@ void BrewingStandTileEntity::doBrew() for (int dest = 0; dest < 3; dest++) { - if (items[dest] != NULL && items[dest]->id == Item::potion_Id) + if (items[dest] != nullptr && items[dest]->id == Item::potion_Id) { int currentBrew = items[dest]->getAuxValue(); int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) ); items[dest]->setAuxValue(newBrew); } - else if (isWater && items[dest] != NULL && items[dest]->id == Item::glassBottle_Id) + else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id) { items[dest] = shared_ptr(new ItemInstance(Item::potion)); } @@ -275,7 +275,7 @@ void BrewingStandTileEntity::doBrew() int BrewingStandTileEntity::applyIngredient(int currentBrew, shared_ptr ingredient) { - if (ingredient == NULL) + if (ingredient == nullptr) { return currentBrew; } @@ -327,7 +327,7 @@ void BrewingStandTileEntity::save(CompoundTag *base) for (int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i)); @@ -354,7 +354,7 @@ shared_ptr BrewingStandTileEntity::removeItem(unsigned int slot, i // option on the ingredients slot // Fix for #65373 - TU8: Content: UI: Command "Take Half" in the Brewing Stand interface doesn't work as intended. - if (slot >= 0 && slot < items.length && items[slot] != NULL) + if (slot >= 0 && slot < items.length && items[slot] != nullptr) { if (items[slot]->count <= count) { @@ -445,7 +445,7 @@ int BrewingStandTileEntity::getPotionBits() int newCount = 0; for (int potion = 0; potion < 3; potion++) { - if (items[potion] != NULL) + if (items[potion] != nullptr) { newCount |= (1 << potion); } @@ -485,7 +485,7 @@ shared_ptr BrewingStandTileEntity::clone() for (unsigned int i = 0; i < items.length; i++) { - if (items.data[i] != NULL) + if (items.data[i] != nullptr) { result->items.data[i] = ItemInstance::clone(items.data[i]); } diff --git a/Minecraft.World/BucketItem.cpp b/Minecraft.World/BucketItem.cpp index a3bd7bee1..b7553c26b 100644 --- a/Minecraft.World/BucketItem.cpp +++ b/Minecraft.World/BucketItem.cpp @@ -28,7 +28,7 @@ bool BucketItem::TestUse(shared_ptr itemInstance, Level *level, sh { bool pickLiquid = content == 0; HitResult *hr = getPlayerPOVHitResult(level, player, pickLiquid); - if (hr == NULL) return false; + if (hr == nullptr) return false; if (hr->type == HitResult::TILE) { @@ -105,7 +105,7 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, bool pickLiquid = content == 0; HitResult *hr = getPlayerPOVHitResult(level, player, pickLiquid); - if (hr == NULL) return itemInstance; + if (hr == nullptr) return itemInstance; if (hr->type == HitResult::TILE) { @@ -117,7 +117,7 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, { app.DebugPrintf("!!!!!!!!!!! Can't place that here\n"); shared_ptr servPlayer = dynamic_pointer_cast(player); - if( servPlayer != NULL ) + if( servPlayer != nullptr ) { app.DebugPrintf("Sending ChatPacket::e_ChatCannotPlaceLava to player\n"); servPlayer->connection->send( shared_ptr( new ChatPacket(L"", ChatPacket::e_ChatCannotPlaceLava ) ) ); diff --git a/Minecraft.World/Bush.cpp b/Minecraft.World/Bush.cpp index 6f8e8d913..5575c837f 100644 --- a/Minecraft.World/Bush.cpp +++ b/Minecraft.World/Bush.cpp @@ -63,7 +63,7 @@ bool Bush::canSurvive(Level *level, int x, int y, int z) AABB *Bush::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool Bush::blocksLight() diff --git a/Minecraft.World/ButtonTile.cpp b/Minecraft.World/ButtonTile.cpp index f3387e20b..b05d597d1 100644 --- a/Minecraft.World/ButtonTile.cpp +++ b/Minecraft.World/ButtonTile.cpp @@ -21,7 +21,7 @@ Icon *ButtonTile::getTexture(int face, int data) AABB *ButtonTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } int ButtonTile::getTickDelay(Level *level) diff --git a/Minecraft.World/ByteArrayInputStream.cpp b/Minecraft.World/ByteArrayInputStream.cpp index 394bda14a..9a40b29a7 100644 --- a/Minecraft.World/ByteArrayInputStream.cpp +++ b/Minecraft.World/ByteArrayInputStream.cpp @@ -114,5 +114,5 @@ __int64 ByteArrayInputStream::skip(__int64 n) ByteArrayInputStream::~ByteArrayInputStream() { - if(buf.data != NULL) delete [] buf.data; + if(buf.data != nullptr) delete [] buf.data; } \ No newline at end of file diff --git a/Minecraft.World/ByteArrayOutputStream.cpp b/Minecraft.World/ByteArrayOutputStream.cpp index afb8c719a..a9f36e04a 100644 --- a/Minecraft.World/ByteArrayOutputStream.cpp +++ b/Minecraft.World/ByteArrayOutputStream.cpp @@ -20,7 +20,7 @@ ByteArrayOutputStream::ByteArrayOutputStream(unsigned int size) ByteArrayOutputStream::~ByteArrayOutputStream() { - if (buf.data != NULL) + if (buf.data != nullptr) delete[] buf.data; } diff --git a/Minecraft.World/ByteArrayTag.h b/Minecraft.World/ByteArrayTag.h index ce701fdbf..1d3e38755 100644 --- a/Minecraft.World/ByteArrayTag.h +++ b/Minecraft.World/ByteArrayTag.h @@ -41,7 +41,7 @@ class ByteArrayTag : public Tag if (Tag::equals(obj)) { ByteArrayTag *o = static_cast(obj); - return ((data.data == NULL && o->data.data == NULL) || (data.data != NULL && data.length == o->data.length && memcmp(data.data, o->data.data, data.length) == 0) ); + return ((data.data == nullptr && o->data.data == nullptr) || (data.data != nullptr && data.length == o->data.length && memcmp(data.data, o->data.data, data.length) == 0) ); } return false; } diff --git a/Minecraft.World/C4JThread.cpp b/Minecraft.World/C4JThread.cpp index 0582abb8f..81aa010be 100644 --- a/Minecraft.World/C4JThread.cpp +++ b/Minecraft.World/C4JThread.cpp @@ -21,7 +21,7 @@ CRITICAL_SECTION C4JThread::ms_threadListCS; #ifdef _XBOX_ONE // 4J Stu - On XboxOne the main thread is not the one that does all the static init, so we have to set this up later -C4JThread *C4JThread::m_mainThread = NULL; +C4JThread *C4JThread::m_mainThread = nullptr; void C4JThread::StaticInit() { @@ -109,12 +109,12 @@ C4JThread::C4JThread( C4JThreadStartFunc* startFunc, void* param, const char* th CPU = SCE_KERNEL_CPU_MASK_USER_1; } - m_threadID = sceKernelCreateThread(m_threadName, entryPoint, g_DefaultPriority, m_stackSize, 0, CPU, NULL); + m_threadID = sceKernelCreateThread(m_threadName, entryPoint, g_DefaultPriority, m_stackSize, 0, CPU, nullptr); app.DebugPrintf("***************************** start thread %s **************************\n", m_threadName); #else m_threadID = 0; m_threadHandle = 0; - m_threadHandle = CreateThread(NULL, m_stackSize, entryPoint, this, CREATE_SUSPENDED, &m_threadID); + m_threadHandle = CreateThread(nullptr, m_stackSize, entryPoint, this, CREATE_SUSPENDED, &m_threadID); #endif EnterCriticalSection(&ms_threadListCS); ms_threadList.push_back(this); @@ -128,8 +128,8 @@ C4JThread::C4JThread( const char* mainThreadName) user_registerthread(); #endif - m_startFunc = NULL; - m_threadParam = NULL; + m_startFunc = nullptr; + m_threadParam = nullptr; m_stackSize = 0; #ifdef __PS3__ @@ -178,7 +178,7 @@ C4JThread::~C4JThread() #endif #if defined __ORBIS__ - scePthreadJoin(m_threadID, NULL); + scePthreadJoin(m_threadID, nullptr); #endif EnterCriticalSection(&ms_threadListCS); @@ -212,7 +212,7 @@ void * C4JThread::entryPoint(void *param) pThread->m_exitCode = (*pThread->m_startFunc)(pThread->m_threadParam); pThread->m_completionFlag->Set(); pThread->m_isRunning = false; - scePthreadExit(NULL); + scePthreadExit(nullptr); } #elif defined __PSVITA__ struct StrArg { @@ -233,7 +233,7 @@ SceInt32 C4JThread::entryPoint(SceSize argSize, void *pArgBlock) PSVitaTLSStorage::RemoveThread(pThread->m_threadID); user_removethread(); - sceKernelExitDeleteThread(NULL); + sceKernelExitDeleteThread(nullptr); return pThread->m_exitCode; } @@ -270,7 +270,7 @@ void C4JThread::Run() scePthreadAttrDestroy(&m_threadAttr); #elif defined __PSVITA__ StrArg strArg = {this}; -// m_threadID = sceKernelCreateThread(m_threadName, entryPoint, m_priority, m_stackSize, 0, m_CPUMask, NULL); +// m_threadID = sceKernelCreateThread(m_threadName, entryPoint, m_priority, m_stackSize, 0, m_CPUMask, nullptr); sceKernelStartThread( m_threadID, sizeof(strArg), &strArg); #else ResumeThread(m_threadHandle); @@ -450,7 +450,7 @@ C4JThread* C4JThread::getCurrentThread() LeaveCriticalSection(&ms_threadListCS); - return NULL; + return nullptr; } bool C4JThread::isMainThread() @@ -480,12 +480,12 @@ C4JThread::Event::Event(EMode mode/* = e_modeAutoClear*/) #elif defined __ORBIS__ char name[1] = {0}; - sceKernelCreateEventFlag( &m_event, name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, NULL); + sceKernelCreateEventFlag( &m_event, name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, nullptr); #elif defined __PSVITA__ char name[1] = {0}; - m_event = sceKernelCreateEventFlag( name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, NULL); + m_event = sceKernelCreateEventFlag( name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, nullptr); #else - m_event = CreateEvent( NULL, (m_mode == e_modeManualClear), FALSE, NULL ); + m_event = CreateEvent( nullptr, (m_mode == e_modeManualClear), FALSE, nullptr ); #endif //__PS3__ } @@ -554,7 +554,7 @@ DWORD C4JThread::Event::WaitForSignal( int timeoutMs ) SceKernelUseconds *pTimeoutMicrosecs; if( timeoutMs == INFINITE ) { - pTimeoutMicrosecs = NULL; + pTimeoutMicrosecs = nullptr; } else { @@ -566,7 +566,7 @@ DWORD C4JThread::Event::WaitForSignal( int timeoutMs ) { waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_PAT; } - int err = sceKernelWaitEventFlag(m_event, 1, waitMode, NULL, pTimeoutMicrosecs); + int err = sceKernelWaitEventFlag(m_event, 1, waitMode, nullptr, pTimeoutMicrosecs); switch(err) { case SCE_OK: return WAIT_OBJECT_0; @@ -579,7 +579,7 @@ DWORD C4JThread::Event::WaitForSignal( int timeoutMs ) SceUInt32 *pTimeoutMicrosecs; if( timeoutMs == INFINITE ) { - pTimeoutMicrosecs = NULL; + pTimeoutMicrosecs = nullptr; } else { @@ -591,7 +591,7 @@ DWORD C4JThread::Event::WaitForSignal( int timeoutMs ) { waitMode |= SCE_KERNEL_EVF_WAITMODE_CLEAR_ALL; } - int err = sceKernelWaitEventFlag(m_event, 1, waitMode, NULL, pTimeoutMicrosecs); + int err = sceKernelWaitEventFlag(m_event, 1, waitMode, nullptr, pTimeoutMicrosecs); switch(err) { case SCE_OK: return WAIT_OBJECT_0; @@ -623,15 +623,15 @@ C4JThread::EventArray::EventArray( int size, EMode mode/* = e_modeAutoClear*/) assert(err == CELL_OK); #elif defined __ORBIS__ char name[1] = {0}; - sceKernelCreateEventFlag( &m_events, name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, NULL); + sceKernelCreateEventFlag( &m_events, name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, nullptr); #elif defined __PSVITA__ char name[1] = {0}; - m_events = sceKernelCreateEventFlag( name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, NULL); + m_events = sceKernelCreateEventFlag( name, SCE_KERNEL_EVF_ATTR_TH_FIFO | SCE_KERNEL_EVF_ATTR_MULTI, 0, nullptr); #else m_events = new HANDLE[size]; for(int i=0;i forceEntity) // 4J added forceData, forceEntity param diff --git a/Minecraft.World/CauldronTile.cpp b/Minecraft.World/CauldronTile.cpp index f7a8d0445..599a9353e 100644 --- a/Minecraft.World/CauldronTile.cpp +++ b/Minecraft.World/CauldronTile.cpp @@ -13,9 +13,9 @@ const wstring CauldronTile::TEXTURE_BOTTOM = L"cauldron_bottom"; CauldronTile::CauldronTile(int id) : Tile(id, Material::metal, isSolidRender()) { - iconInner = NULL; - iconTop = NULL; - iconBottom = NULL; + iconInner = nullptr; + iconTop = nullptr; + iconBottom = nullptr; } Icon *CauldronTile::getTexture(int face, int data) @@ -43,7 +43,7 @@ Icon *CauldronTile::getTexture(const wstring &name) { if (name.compare(TEXTURE_INSIDE) == 0) return Tile::cauldron->iconInner; if (name.compare(TEXTURE_BOTTOM) == 0) return Tile::cauldron->iconBottom; - return NULL; + return nullptr; } void CauldronTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr source) @@ -93,7 +93,7 @@ bool CauldronTile::use(Level *level, int x, int y, int z, shared_ptr pla } shared_ptr item = player->inventory->getSelected(); - if (item == NULL) + if (item == nullptr) { return true; } diff --git a/Minecraft.World/CaveFeature.cpp b/Minecraft.World/CaveFeature.cpp index c460d8634..cf83e8a3f 100644 --- a/Minecraft.World/CaveFeature.cpp +++ b/Minecraft.World/CaveFeature.cpp @@ -35,7 +35,7 @@ bool CaveFeature::place(Level *level, Random *random, int x, int y, int z) double hr = (Mth::sin(d / 16.0f * PI) * radius + 1) * ss + 1; // 4J Stu Added to stop cave features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects((xx - r / 2), (yy - hr / 2), (zz - r / 2), (xx + r / 2), (yy + hr / 2), (zz + r / 2)); diff --git a/Minecraft.World/ChestTile.cpp b/Minecraft.World/ChestTile.cpp index 06e57d7d2..a81497215 100644 --- a/Minecraft.World/ChestTile.cpp +++ b/Minecraft.World/ChestTile.cpp @@ -208,18 +208,18 @@ void ChestTile::neighborChanged(Level *level, int x, int y, int z, int type) { BaseEntityTile::neighborChanged(level, x, y, z, type); shared_ptr(cte) = dynamic_pointer_cast(level->getTileEntity(x, y, z)); - if (cte != NULL) cte->clearCache(); + if (cte != nullptr) cte->clearCache(); } void ChestTile::onRemove(Level *level, int x, int y, int z, int id, int data) { shared_ptr container = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (container != NULL ) + if (container != nullptr ) { for (unsigned int i = 0; i < container->getContainerSize(); i++) { shared_ptr item = container->getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; @@ -272,7 +272,7 @@ bool ChestTile::use(Level *level, int x, int y, int z, shared_ptr player } shared_ptr container = getContainer(level, x, y, z); - if (container != NULL) + if (container != nullptr) { player->openContainer(container); } @@ -283,7 +283,7 @@ bool ChestTile::use(Level *level, int x, int y, int z, shared_ptr player shared_ptr ChestTile::getContainer(Level *level, int x, int y, int z) { shared_ptr container = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (container == NULL) return nullptr; + if (container == nullptr) return nullptr; if (level->isSolidBlockingTile(x, y + 1, z)) return nullptr; if (isCatSittingOnChest(level,x, y, z)) return nullptr; diff --git a/Minecraft.World/ChestTileEntity.cpp b/Minecraft.World/ChestTileEntity.cpp index bdffb05cc..966eb5bb5 100644 --- a/Minecraft.World/ChestTileEntity.cpp +++ b/Minecraft.World/ChestTileEntity.cpp @@ -65,7 +65,7 @@ shared_ptr ChestTileEntity::getItem(unsigned int slot) shared_ptr ChestTileEntity::removeItem(unsigned int slot, int count) { - if (items->data[slot] != NULL) + if (items->data[slot] != nullptr) { if (items->data[slot]->count <= count) { @@ -91,7 +91,7 @@ shared_ptr ChestTileEntity::removeItem(unsigned int slot, int coun shared_ptr ChestTileEntity::removeItemNoUpdate(int slot) { - if (items->data[slot] != NULL) + if (items->data[slot] != nullptr) { shared_ptr item = items->data[slot]; items->data[slot] = nullptr; @@ -103,7 +103,7 @@ shared_ptr ChestTileEntity::removeItemNoUpdate(int slot) void ChestTileEntity::setItem(unsigned int slot, shared_ptr item) { items->data[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); this->setChanged(); } @@ -154,7 +154,7 @@ void ChestTileEntity::save(CompoundTag *base) for (unsigned int i = 0; i < items->length; i++) { - if (items->data[i] != NULL) + if (items->data[i] != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i)); @@ -244,16 +244,16 @@ void ChestTileEntity::checkNeighbors() } shared_ptr cteThis = dynamic_pointer_cast(shared_from_this()); - if (n.lock() != NULL) n.lock()->heyImYourNeighbor(cteThis, Direction::SOUTH); - if (s.lock() != NULL) s.lock()->heyImYourNeighbor(cteThis, Direction::NORTH); - if (e.lock() != NULL) e.lock()->heyImYourNeighbor(cteThis, Direction::WEST); - if (w.lock() != NULL) w.lock()->heyImYourNeighbor(cteThis, Direction::EAST); + if (n.lock() != nullptr) n.lock()->heyImYourNeighbor(cteThis, Direction::SOUTH); + if (s.lock() != nullptr) s.lock()->heyImYourNeighbor(cteThis, Direction::NORTH); + if (e.lock() != nullptr) e.lock()->heyImYourNeighbor(cteThis, Direction::WEST); + if (w.lock() != nullptr) w.lock()->heyImYourNeighbor(cteThis, Direction::EAST); } bool ChestTileEntity::isSameChest(int x, int y, int z) { Tile *tile = Tile::tiles[level->getTile(x, y, z)]; - if (tile == NULL || !(dynamic_cast(tile) != NULL)) return false; + if (tile == nullptr || !(dynamic_cast(tile) != nullptr)) return false; return static_cast(tile)->type == getType(); } @@ -283,7 +283,7 @@ void ChestTileEntity::tick() shared_ptr container = containerMenu->getContainer(); shared_ptr thisContainer = dynamic_pointer_cast(shared_from_this()); shared_ptr compoundContainer = dynamic_pointer_cast(container); - if ((container == thisContainer) || (compoundContainer != NULL && compoundContainer->contains(thisContainer))) + if ((container == thisContainer) || (compoundContainer != nullptr && compoundContainer->contains(thisContainer))) { openCount++; } @@ -298,12 +298,12 @@ void ChestTileEntity::tick() float speed = 0.10f; if (openCount > 0 && openness == 0) { - if (n.lock() == NULL && w.lock() == NULL) + if (n.lock() == nullptr && w.lock() == nullptr) { double xc = x + 0.5; double zc = z + 0.5; - if (s.lock() != NULL) zc += 0.5; - if (e.lock() != NULL) xc += 0.5; + if (s.lock() != nullptr) zc += 0.5; + if (e.lock() != nullptr) xc += 0.5; // 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_OPEN, 0.2f, level->random->nextFloat() * 0.1f + 0.9f); @@ -323,12 +323,12 @@ void ChestTileEntity::tick() { // Fix for #64546 - Customer Encountered: TU7: Chests placed by the Player are closing too fast. //openness = 0; - if (n.lock() == NULL && w.lock() == NULL) + if (n.lock() == nullptr && w.lock() == nullptr) { double xc = x + 0.5; double zc = z + 0.5; - if (s.lock() != NULL) zc += 0.5; - if (e.lock() != NULL) xc += 0.5; + if (s.lock() != nullptr) zc += 0.5; + if (e.lock() != nullptr) xc += 0.5; // 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_CLOSE, 0.2f, level->random->nextFloat() * 0.1f + 0.9f); @@ -366,7 +366,7 @@ void ChestTileEntity::startOpen() void ChestTileEntity::stopOpen() { - if (getTile() == NULL || !( dynamic_cast( getTile() ) != NULL)) return; + if (getTile() == nullptr || !( dynamic_cast( getTile() ) != nullptr)) return; openCount--; level->tileEvent(x, y, z, getTile()->id, ChestTile::EVENT_SET_OPEN_COUNT, openCount); level->updateNeighborsAt(x, y, z, getTile()->id); @@ -389,7 +389,7 @@ int ChestTileEntity::getType() { if (type == -1) { - if (level != NULL && dynamic_cast( getTile() ) != NULL) + if (level != nullptr && dynamic_cast( getTile() ) != nullptr) { type = static_cast(getTile())->type; } @@ -410,7 +410,7 @@ shared_ptr ChestTileEntity::clone() for (unsigned int i = 0; i < items->length; i++) { - if (items->data[i] != NULL) + if (items->data[i] != nullptr) { result->items->data[i] = ItemInstance::clone(items->data[i]); } diff --git a/Minecraft.World/ChunkSource.h b/Minecraft.World/ChunkSource.h index c537651c0..37b0ecc33 100644 --- a/Minecraft.World/ChunkSource.h +++ b/Minecraft.World/ChunkSource.h @@ -73,7 +73,7 @@ class ChunkSource virtual bool tick() = 0; virtual bool shouldSave() = 0; - virtual LevelChunk **getCache() { return NULL; } // 4J added + virtual LevelChunk **getCache() { return nullptr; } // 4J added virtual void dataReceived(int x, int z) {} // 4J added /** diff --git a/Minecraft.World/ClientSideMerchant.cpp b/Minecraft.World/ClientSideMerchant.cpp index ba1793007..1b54580b8 100644 --- a/Minecraft.World/ClientSideMerchant.cpp +++ b/Minecraft.World/ClientSideMerchant.cpp @@ -7,8 +7,8 @@ ClientSideMerchant::ClientSideMerchant(shared_ptr source, const wstring { this->source = source; // 4J Stu - Need to do this after creating as a shared_ptr - container = NULL; //new MerchantContainer(source, this); - currentOffers = NULL; + container = nullptr; //new MerchantContainer(source, this); + currentOffers = nullptr; m_name = name; } diff --git a/Minecraft.World/ClockItem.cpp b/Minecraft.World/ClockItem.cpp index afe0544d2..83b8e7a4d 100644 --- a/Minecraft.World/ClockItem.cpp +++ b/Minecraft.World/ClockItem.cpp @@ -12,7 +12,7 @@ const wstring ClockItem::TEXTURE_PLAYER_ICON[XUSER_MAX_COUNT] = {L"clockP0",L"cl ClockItem::ClockItem(int id) : Item(id) { - icons = NULL; + icons = nullptr; } // 4J Added so that we can override the icon id used to calculate the texture UV's for each player @@ -21,7 +21,7 @@ Icon *ClockItem::getIcon(int auxValue) Icon *icon = Item::getIcon(auxValue); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->player != NULL && auxValue == 0 ) + if( pMinecraft->player != nullptr && auxValue == 0 ) { icon = icons[pMinecraft->player->GetXboxPad()]; } diff --git a/Minecraft.World/ColoredTileItem.cpp b/Minecraft.World/ColoredTileItem.cpp index 37ea4c63b..f659d7a5f 100644 --- a/Minecraft.World/ColoredTileItem.cpp +++ b/Minecraft.World/ColoredTileItem.cpp @@ -15,7 +15,7 @@ ColoredTileItem::ColoredTileItem(int id, bool stackedByData) : TileItem(id) ColoredTileItem::~ColoredTileItem() { - if(descriptionPostfixes.data != NULL) delete [] descriptionPostfixes.data; + if(descriptionPostfixes.data != nullptr) delete [] descriptionPostfixes.data; } int ColoredTileItem::getColor(shared_ptr item, int spriteLayer) @@ -35,7 +35,7 @@ int ColoredTileItem::getLevelDataForAuxValue(int auxValue) ColoredTileItem *ColoredTileItem::setDescriptionPostfixes(intArray descriptionPostfixes) { - if(this->descriptionPostfixes.data != NULL) delete this->descriptionPostfixes.data; + if(this->descriptionPostfixes.data != nullptr) delete this->descriptionPostfixes.data; this->descriptionPostfixes = intArray(descriptionPostfixes.length); for(unsigned int i = 0; i < descriptionPostfixes.length; ++i ) { @@ -47,7 +47,7 @@ ColoredTileItem *ColoredTileItem::setDescriptionPostfixes(intArray descriptionPo unsigned int ColoredTileItem::getDescriptionId(shared_ptr instance) { - if (descriptionPostfixes.data == NULL) + if (descriptionPostfixes.data == nullptr) { return TileItem::getDescriptionId(instance); } diff --git a/Minecraft.World/CombatEntry.cpp b/Minecraft.World/CombatEntry.cpp index 903d95bbe..5fe2e6d32 100644 --- a/Minecraft.World/CombatEntry.cpp +++ b/Minecraft.World/CombatEntry.cpp @@ -6,8 +6,8 @@ CombatEntry::CombatEntry(DamageSource *source, int time, float health, float damage, CombatTracker::eLOCATION location, float fallDistance) { - this->source = NULL; - if(source != NULL) + this->source = nullptr; + if(source != nullptr) { // 4J: this might actually be a derived damage source so use copy func this->source = source->copy(); @@ -61,7 +61,7 @@ CombatTracker::eLOCATION CombatEntry::getLocation() wstring CombatEntry::getAttackerName() { - return getSource()->getEntity() == NULL ? L"" : getSource()->getEntity()->getNetworkName(); + return getSource()->getEntity() == nullptr ? L"" : getSource()->getEntity()->getNetworkName(); } float CombatEntry::getFallDistance() diff --git a/Minecraft.World/CombatTracker.cpp b/Minecraft.World/CombatTracker.cpp index 2d35913c3..7fe8316fb 100644 --- a/Minecraft.World/CombatTracker.cpp +++ b/Minecraft.World/CombatTracker.cpp @@ -67,7 +67,7 @@ shared_ptr CombatTracker::getDeathMessagePacket() shared_ptr killingEntity = killingBlow->getSource()->getEntity(); - if (knockOffEntry != NULL && killingBlow->getSource()->equals(DamageSource::fall)) + if (knockOffEntry != nullptr && killingBlow->getSource()->equals(DamageSource::fall)) { shared_ptr attackerEntity = knockOffEntry->getSource()->getEntity(); @@ -93,11 +93,11 @@ shared_ptr CombatTracker::getDeathMessagePacket() result = shared_ptr(new ChatPacket(mob->getNetworkName(), message)); } - else if (attackerEntity != NULL && (killingEntity == NULL || attackerEntity != killingEntity)) + else if (attackerEntity != nullptr && (killingEntity == nullptr || attackerEntity != killingEntity)) { shared_ptr attackerItem = attackerEntity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast(attackerEntity)->getCarriedItem() : nullptr; - if (attackerItem != NULL && attackerItem->hasCustomHoverName()) + if (attackerItem != nullptr && attackerItem->hasCustomHoverName()) { result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssistItem, attackerEntity->GetType(), attackerEntity->getNetworkName(), attackerItem->getHoverName())); } @@ -106,10 +106,10 @@ shared_ptr CombatTracker::getDeathMessagePacket() result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssist, attackerEntity->GetType(), attackerEntity->getNetworkName())); } } - else if (killingEntity != NULL) + else if (killingEntity != nullptr) { shared_ptr killerItem = killingEntity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast(killingEntity)->getCarriedItem() : nullptr; - if (killerItem != NULL && killerItem->hasCustomHoverName()) + if (killerItem != nullptr && killerItem->hasCustomHoverName()) { result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinishItem, killingEntity->GetType(), killingEntity->getNetworkName(), killerItem->getHoverName())); } @@ -140,20 +140,20 @@ shared_ptr CombatTracker::getKiller() for ( CombatEntry *entry : entries ) { - if ( entry->getSource() != NULL && entry->getSource()->getEntity() != NULL && entry->getSource()->getEntity()->instanceof(eTYPE_PLAYER) && (bestPlayer == NULL || entry->getDamage() > bestPlayerDamage)) + if ( entry->getSource() != nullptr && entry->getSource()->getEntity() != nullptr && entry->getSource()->getEntity()->instanceof(eTYPE_PLAYER) && (bestPlayer == nullptr || entry->getDamage() > bestPlayerDamage)) { bestPlayerDamage = entry->getDamage(); bestPlayer = 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)) + if ( entry->getSource() != nullptr && entry->getSource()->getEntity() != nullptr && entry->getSource()->getEntity()->instanceof(eTYPE_LIVINGENTITY) && (bestMob == nullptr || entry->getDamage() > bestMobDamage)) { bestMobDamage = entry->getDamage(); bestMob = dynamic_pointer_cast(entry->getSource()->getEntity()); } } - if (bestPlayer != NULL && bestPlayerDamage >= bestMobDamage / 3) + if (bestPlayer != nullptr && bestPlayerDamage >= bestMobDamage / 3) { return bestPlayer; } @@ -165,20 +165,20 @@ shared_ptr CombatTracker::getKiller() CombatEntry *CombatTracker::getMostSignificantFall() { - CombatEntry *result = NULL; - CombatEntry *alternative = NULL; + CombatEntry *result = nullptr; + CombatEntry *alternative = nullptr; int altDamage = 0; float bestFall = 0; for (int i = 0; i < entries.size(); i++) { CombatEntry *entry = entries.at(i); - CombatEntry *previous = i > 0 ? entries.at(i - 1) : NULL; + CombatEntry *previous = i > 0 ? entries.at(i - 1) : nullptr; bool isFall = entry->getSource()->equals(DamageSource::fall); bool isOutOfWorld = entry->getSource()->equals(DamageSource::outOfWorld); - if ((isFall || isOutOfWorld) && (entry->getFallDistance() > 0) && (result == NULL || entry->getFallDistance() > bestFall)) + if ((isFall || isOutOfWorld) && (entry->getFallDistance() > 0) && (result == nullptr || entry->getFallDistance() > bestFall)) { if (i > 0) { @@ -191,23 +191,23 @@ CombatEntry *CombatTracker::getMostSignificantFall() bestFall = entry->getFallDistance(); } - if (entry->getLocation() != eLocation_GENERIC && (alternative == NULL || entry->getDamage() > altDamage)) + if (entry->getLocation() != eLocation_GENERIC && (alternative == nullptr || entry->getDamage() > altDamage)) { alternative = entry; } } - if (bestFall > 5 && result != NULL) + if (bestFall > 5 && result != nullptr) { return result; } - else if (altDamage > 5 && alternative != NULL) + else if (altDamage > 5 && alternative != nullptr) { return alternative; } else { - return NULL; + return nullptr; } } diff --git a/Minecraft.World/Command.cpp b/Minecraft.World/Command.cpp index bf546f6ea..2ec6853ca 100644 --- a/Minecraft.World/Command.cpp +++ b/Minecraft.World/Command.cpp @@ -24,7 +24,7 @@ void Command::logAdminAction(shared_ptr source, ChatPacket::EChat void Command::logAdminAction(shared_ptr source, int type, ChatPacket::EChatPacketMessage messageType, const wstring& message, int customData, const wstring& additionalMessage) { - if (logger != NULL) + if (logger != nullptr) { logger->logAdminCommand(source, type, messageType, message, customData, additionalMessage); } @@ -39,7 +39,7 @@ shared_ptr Command::getPlayer(PlayerUID playerId) { shared_ptr player = MinecraftServer::getInstance()->getPlayers()->getPlayer(playerId); - if (player == NULL) + if (player == nullptr) { return nullptr; } diff --git a/Minecraft.World/CommandBlock.cpp b/Minecraft.World/CommandBlock.cpp index e1b6b8dd3..1810ef132 100644 --- a/Minecraft.World/CommandBlock.cpp +++ b/Minecraft.World/CommandBlock.cpp @@ -38,7 +38,7 @@ void CommandBlock::tick(Level *level, int x, int y, int z, Random *random) { shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && dynamic_pointer_cast( tileEntity ) != NULL) + if (tileEntity != nullptr && dynamic_pointer_cast( tileEntity ) != nullptr) { shared_ptr commandBlock = dynamic_pointer_cast( tileEntity ); commandBlock->setSuccessCount(commandBlock->performCommand(level)); @@ -55,7 +55,7 @@ bool CommandBlock::use(Level *level, int x, int y, int z, shared_ptr pla { shared_ptr amce = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (amce != NULL) + if (amce != nullptr) { player->openTextEdit(amce); } @@ -72,7 +72,7 @@ int CommandBlock::getAnalogOutputSignal(Level *level, int x, int y, int z, int d { shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && dynamic_pointer_cast( tileEntity ) != NULL) + if (tileEntity != nullptr && dynamic_pointer_cast( tileEntity ) != nullptr) { return dynamic_pointer_cast( tileEntity )->getSuccessCount(); } diff --git a/Minecraft.World/CommandBlockEntity.cpp b/Minecraft.World/CommandBlockEntity.cpp index 1c518f4fd..b81f8e46b 100644 --- a/Minecraft.World/CommandBlockEntity.cpp +++ b/Minecraft.World/CommandBlockEntity.cpp @@ -32,7 +32,7 @@ int CommandBlockEntity::performCommand(Level *level) } MinecraftServer *instance = MinecraftServer::getInstance(); - if (instance != NULL && instance->isCommandBlockEnabled()) + if (instance != nullptr && instance->isCommandBlockEnabled()) { CommandDispatcher *commandDispatcher = instance->getCommandDispatcher(); return commandDispatcher->performCommand(dynamic_pointer_cast(shared_from_this()), command, byteArray() ); diff --git a/Minecraft.World/CommonStats.cpp b/Minecraft.World/CommonStats.cpp index abef92aa5..5ad0e35b1 100644 --- a/Minecraft.World/CommonStats.cpp +++ b/Minecraft.World/CommonStats.cpp @@ -50,26 +50,26 @@ Stat* CommonStats::get_killsNetherZombiePigman() { return Stats::killsNetherZomb Stat *CommonStats::get_breedEntity(eINSTANCEOF mobType) { if (mobType == eTYPE_COW) return GenericStats::repopulation(); - else return NULL; + else return nullptr; } Stat *CommonStats::get_tamedEntity(eINSTANCEOF mobType) { if (mobType == eTYPE_OCELOT) return GenericStats::lionTamer(); else if (mobType == eTYPE_WOLF) return Stats::befriendsWolf; - else return NULL; + else return nullptr; } Stat *CommonStats::get_craftedEntity(eINSTANCEOF mobType) { if (mobType == eTYPE_VILLAGERGOLEM) return GenericStats::bodyGuard(); - else return NULL; + else return nullptr; } Stat *CommonStats::get_shearedEntity(eINSTANCEOF mobType) { if (mobType == eTYPE_SHEEP) return GenericStats::haveAShearfulDay(); - else return NULL; + else return nullptr; } Stat *CommonStats::get_totalBlocksMined() { return Stats::totalBlocksMined; } @@ -81,7 +81,7 @@ Stat* CommonStats::get_blocksPlaced(int blockId) #if (defined _EXTENDED_ACHIEVEMENTS) && (!defined _XBOX_ONE) return Stats::blocksPlaced[blockId]; #else - return NULL; + return nullptr; #endif } @@ -97,7 +97,7 @@ Stat *CommonStats::get_itemsCollected(int itemId, int itemAux) #endif if (itemId != Item::emerald_Id) return Stats::itemsCollected[itemId]; - else return NULL; + else return nullptr; } Stat *CommonStats::get_itemsCrafted(int itemId) { return Stats::itemsCrafted[itemId]; } @@ -111,7 +111,7 @@ Stat *CommonStats::get_itemsUsed(int itemId) if (itemId == Item::porkChop_cooked_Id) return Stats::blocksPlaced[itemId]; #endif - return NULL; + return nullptr; } Stat *CommonStats::get_itemsBought(int itemId) @@ -121,7 +121,7 @@ Stat *CommonStats::get_itemsBought(int itemId) // StatArray for Items Bought. if (itemId == Item::emerald_Id) return Stats::itemsCollected[itemId]; - else return NULL; + else return nullptr; } Stat *CommonStats::get_killsEnderdragon() { return Stats::killsEnderdragon; } @@ -133,7 +133,7 @@ Stat *CommonStats::get_enteredBiome(int biomeId) #if (defined _EXTENDED_ACHIEVEMENTS) && (!defined _XBOX_ONE) return Stats::biomesVisisted[biomeId]; #else - return NULL; + return nullptr; #endif } @@ -171,7 +171,7 @@ Stat *CommonStats::get_achievement(eAward achievementId) #ifndef _XBOX case eAward_snipeSkeleton: return (Stat *) Achievements::snipeSkeleton; case eAward_diamonds: return (Stat *) Achievements::diamonds; - case eAward_portal: return (Stat *) NULL; // TODO + case eAward_portal: return (Stat *) nullptr; // TODO case eAward_ghast: return (Stat *) Achievements::ghast; case eAward_blazeRod: return (Stat *) Achievements::blazeRod; case eAward_potion: return (Stat *) Achievements::potion; @@ -205,7 +205,7 @@ Stat *CommonStats::get_achievement(eAward achievementId) case eAward_lionTamer: return (Stat *) Achievements::lionTamer; #endif - default: return (Stat *) NULL; + default: return (Stat *) nullptr; } } @@ -286,7 +286,7 @@ byteArray CommonStats::getParam_noArgs() byteArray CommonStats::makeParam(int count) { - byteArray out( sizeof(int) ); + byteArray out( static_cast(sizeof(int)) ); memcpy(out.data,&count,sizeof(int)); return out; } diff --git a/Minecraft.World/ComparatorTile.cpp b/Minecraft.World/ComparatorTile.cpp index f611424d2..197a936cc 100644 --- a/Minecraft.World/ComparatorTile.cpp +++ b/Minecraft.World/ComparatorTile.cpp @@ -235,7 +235,7 @@ bool ComparatorTile::triggerEvent(Level *level, int x, int y, int z, int b0, int { DiodeTile::triggerEvent(level, x, y, z, b0, b1); shared_ptr te = level->getTileEntity(x, y, z); - if (te != NULL) + if (te != nullptr) { return te->triggerEvent(b0, b1); } diff --git a/Minecraft.World/CompassItem.cpp b/Minecraft.World/CompassItem.cpp index 57ad65d04..99d18ed08 100644 --- a/Minecraft.World/CompassItem.cpp +++ b/Minecraft.World/CompassItem.cpp @@ -12,7 +12,7 @@ const wstring CompassItem::TEXTURE_PLAYER_ICON[XUSER_MAX_COUNT] = {L"compassP0", CompassItem::CompassItem(int id) : Item(id) { - icons = NULL; + icons = nullptr; } // 4J Added so that we can override the icon id used to calculate the texture UV's for each player @@ -22,7 +22,7 @@ Icon *CompassItem::getIcon(int auxValue) Icon *icon = Item::getIcon(auxValue); Minecraft *pMinecraft = Minecraft::GetInstance(); - if( pMinecraft->player != NULL && auxValue == 0 ) + if( pMinecraft->player != nullptr && auxValue == 0 ) { icon = icons[pMinecraft->player->GetXboxPad()]; } diff --git a/Minecraft.World/CompoundContainer.cpp b/Minecraft.World/CompoundContainer.cpp index 39da0e58f..50bfcc34d 100644 --- a/Minecraft.World/CompoundContainer.cpp +++ b/Minecraft.World/CompoundContainer.cpp @@ -6,8 +6,8 @@ CompoundContainer::CompoundContainer(int name, shared_ptr c1, shared_ptr c2) { this->name = name; - if (c1 == NULL) c1 = c2; - if (c2 == NULL) c2 = c1; + if (c1 == nullptr) c1 = c2; + if (c2 == nullptr) c2 = c1; this->c1 = c1; this->c2 = c2; } diff --git a/Minecraft.World/CompoundTag.h b/Minecraft.World/CompoundTag.h index e08706449..1822224e7 100644 --- a/Minecraft.World/CompoundTag.h +++ b/Minecraft.World/CompoundTag.h @@ -130,7 +130,7 @@ class CompoundTag : public Tag { auto it = tags.find(name); if(it != tags.end()) return it->second; - return NULL; + return nullptr; } bool contains(const wstring &name) diff --git a/Minecraft.World/CompressedTileStorage.cpp b/Minecraft.World/CompressedTileStorage.cpp index 8a999a0a6..c2c9037ee 100644 --- a/Minecraft.World/CompressedTileStorage.cpp +++ b/Minecraft.World/CompressedTileStorage.cpp @@ -23,11 +23,11 @@ CRITICAL_SECTION CompressedTileStorage::cs_write; #ifdef PSVITA_PRECOMPUTED_TABLE // AP - this will create a precomputed table to speed up getData -static int *CompressedTile_StorageIndexTable = NULL; +static int *CompressedTile_StorageIndexTable = nullptr; void CompressedTileStorage_InitTable() { - if( CompressedTile_StorageIndexTable == NULL ) + if( CompressedTile_StorageIndexTable == nullptr ) { CompressedTile_StorageIndexTable = (int*) malloc(sizeof(int) * 64); for(int j = 0;j < 64;j += 1 ) @@ -41,7 +41,7 @@ void CompressedTileStorage_InitTable() CompressedTileStorage::CompressedTileStorage() { - indicesAndData = NULL; + indicesAndData = nullptr; allocatedSize = 0; #ifdef PSVITA_PRECOMPUTED_TABLE @@ -60,7 +60,7 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage *copyFrom) } else { - indicesAndData = NULL; + indicesAndData = nullptr; } LeaveCriticalSection(&cs_write); @@ -71,7 +71,7 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage *copyFrom) CompressedTileStorage::CompressedTileStorage(byteArray initFrom, unsigned int initOffset) { - indicesAndData = NULL; + indicesAndData = nullptr; allocatedSize = 0; // We need 32768 bytes for a fully uncompressed chunk, plus 1024 for the index. Rounding up to nearest 4096 bytes for allocation @@ -117,7 +117,7 @@ bool CompressedTileStorage::isCompressed() CompressedTileStorage::CompressedTileStorage(bool isEmpty) { - indicesAndData = NULL; + indicesAndData = nullptr; allocatedSize = 0; // Empty and already compressed, so we only need 1K. Rounding up to nearest 4096 bytes for allocation @@ -423,7 +423,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset) ucMappings[j] = 255; } - unsigned char *repacked = NULL; + unsigned char *repacked = nullptr; int bitspertile = 1 << indexTypeNew; // will be 1, 2 or 4 (from index values of 0, 1, 2) int tiletypecount = 1 << bitspertile; // will be 2, 4 or 16 (from index values of 0, 1, 2) @@ -806,7 +806,7 @@ void CompressedTileStorage::tick() int freeIndex = ( deleteQueueIndex + 1 ) % 3; // printf("Free queue: %d, %d\n",deleteQueue[freeIndex].GetEntryCount(),deleteQueue[freeIndex].GetAllocated()); - unsigned char *toFree = NULL; + unsigned char *toFree = nullptr; do { toFree = deleteQueue[freeIndex].Pop(); @@ -887,7 +887,7 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) { unsigned short indexType = blockIndices[i] & INDEX_TYPE_MASK; - unsigned char *unpacked_data = NULL; + unsigned char *unpacked_data = nullptr; unsigned char *packed_data; // First task is to find out what type of storage each block needs. Need to unpack each where required. @@ -1050,7 +1050,7 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) { memToAlloc += 1024; // For the indices unsigned char *newIndicesAndData = static_cast(XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc( memToAlloc ); - if( newIndicesAndData == NULL ) + if( newIndicesAndData == nullptr ) { DWORD lastError = GetLastError(); #ifndef _DURANGO @@ -1111,9 +1111,9 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) // If we're not done, then we actually need to recompress this block. First of all decompress from its current format. if( !done ) { - unsigned char *unpacked_data = NULL; - unsigned char *tile_types = NULL; - unsigned char *packed_data = NULL; + unsigned char *unpacked_data = nullptr; + unsigned char *tile_types = nullptr; + unsigned char *packed_data = nullptr; if( indexTypeOld == INDEX_TYPE_0_OR_8_BIT ) { if( blockIndices[i] & INDEX_TYPE_0_BIT_FLAG ) @@ -1159,7 +1159,7 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) } #endif - unsigned char *repacked = NULL; + unsigned char *repacked = nullptr; if( indexTypeNew == INDEX_TYPE_0_OR_8_BIT ) { diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp index 807ef1d98..962624b87 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -61,17 +61,17 @@ Connection::~Connection() // These should all have been destroyed in close() but no harm in checking again delete byteArrayDos; - byteArrayDos = NULL; + byteArrayDos = nullptr; delete baos; - baos = NULL; + baos = nullptr; if( bufferedDos ) { bufferedDos->deleteChildStream(); delete bufferedDos; - bufferedDos = NULL; + bufferedDos = nullptr; } delete dis; - dis = NULL; + dis = nullptr; } Connection::Connection(Socket *socket, const wstring& id, PacketListener *packetListener) // throws IOException @@ -185,7 +185,7 @@ bool Connection::writeTick() bool didSomething = false; // 4J Stu - If the connection is closed and the output stream has been deleted - if(bufferedDos==NULL || byteArrayDos==NULL) + if(bufferedDos==nullptr || byteArrayDos==nullptr) return didSomething; // try { @@ -318,14 +318,14 @@ bool Connection::readTick() bool didSomething = false; // 4J Stu - If the connection has closed and the input stream has been deleted - if(dis==NULL) + if(dis==nullptr) return didSomething; //try { shared_ptr packet = Packet::readPacket(dis, packetListener->isServerPacketListener()); - if (packet != NULL) + if (packet != nullptr) { readSizes[packet->getId()] += packet->getEstimatedSize() + 1; EnterCriticalSection(&incoming_cs); @@ -377,8 +377,8 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...) disconnectReason = reason;//va_arg( input, const wstring ); vector objs = vector(); - void *i = NULL; - while (i != NULL) + void *i = nullptr; + while (i != nullptr) { i = va_arg( input, void* ); objs.push_back(i); @@ -390,7 +390,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...) } else { - disconnectReasonObjects = NULL; + disconnectReasonObjects = nullptr; } // int count = 0, sum = 0, i = first; @@ -407,7 +407,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...) // return( sum ? (sum / count) : 0 ); -// CreateThread(NULL, 0, runClose, this, 0, &closeThreadID); +// CreateThread(nullptr, 0, runClose, this, 0, &closeThreadID); running = false; @@ -419,24 +419,24 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...) writeThread->WaitForCompletion(INFINITE); delete dis; - dis = NULL; + dis = nullptr; if( bufferedDos ) { bufferedDos->close(); bufferedDos->deleteChildStream(); delete bufferedDos; - bufferedDos = NULL; + bufferedDos = nullptr; } if( byteArrayDos ) { byteArrayDos->close(); delete byteArrayDos; - byteArrayDos = NULL; + byteArrayDos = nullptr; } if( socket ) { socket->close(packetListener->isServerPacketListener()); - socket = NULL; + socket = nullptr; } } @@ -552,7 +552,7 @@ void Connection::sendAndQuit() close(DisconnectPacket::eDisconnect_Closed); } #else - CreateThread(NULL, 0, runSendAndQuit, this, 0, &saqThreadID); + CreateThread(nullptr, 0, runSendAndQuit, this, 0, &saqThreadID); #endif } @@ -567,7 +567,7 @@ int Connection::runRead(void* lpParam) ShutdownManager::HasStarted(ShutdownManager::eConnectionReadThreads); Connection *con = static_cast(lpParam); - if (con == NULL) + if (con == nullptr) { #ifdef __PS3__ ShutdownManager::HasFinished(ShutdownManager::eConnectionReadThreads); @@ -617,7 +617,7 @@ int Connection::runWrite(void* lpParam) ShutdownManager::HasStarted(ShutdownManager::eConnectionWriteThreads); Connection *con = dynamic_cast(static_cast(lpParam)); - if (con == NULL) + if (con == nullptr) { ShutdownManager::HasFinished(ShutdownManager::eConnectionWriteThreads); return 0; @@ -644,8 +644,8 @@ int Connection::runWrite(void* lpParam) // TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well waitResult = con->m_hWakeWriteThread->WaitForSignal(100L); - if (con->bufferedDos != NULL) con->bufferedDos->flush(); - //if (con->byteArrayDos != NULL) con->byteArrayDos->flush(); + if (con->bufferedDos != nullptr) con->bufferedDos->flush(); + //if (con->byteArrayDos != nullptr) con->byteArrayDos->flush(); } @@ -662,7 +662,7 @@ int Connection::runClose(void* lpParam) { Connection *con = dynamic_cast(static_cast(lpParam)); - if (con == NULL) return 0; + if (con == nullptr) return 0; //try { @@ -686,7 +686,7 @@ int Connection::runSendAndQuit(void* lpParam) Connection *con = dynamic_cast(static_cast(lpParam)); // printf("Con:0x%x runSendAndQuit\n",con); - if (con == NULL) return 0; + if (con == nullptr) return 0; //try { diff --git a/Minecraft.World/ConsoleSaveFile.h b/Minecraft.World/ConsoleSaveFile.h index 39c1ec89c..0f7c451ee 100644 --- a/Minecraft.World/ConsoleSaveFile.h +++ b/Minecraft.World/ConsoleSaveFile.h @@ -23,7 +23,7 @@ class ConsoleSaveFile virtual void Flush(bool autosave, bool updateThumbnail = true) = 0; #ifndef _CONTENT_PACKAGE - virtual void DebugFlushToFile(void *compressedData = NULL, unsigned int compressedDataSize = 0) = 0; + virtual void DebugFlushToFile(void *compressedData = nullptr, unsigned int compressedDataSize = 0) = 0; #endif virtual unsigned int getSizeOnDisk() = 0; virtual wstring getFilename() = 0; @@ -53,5 +53,5 @@ class ConsoleSaveFile virtual void ConvertRegionFile(File sourceFile) = 0; virtual void ConvertToLocalPlatform() = 0; - virtual void *getWritePointer(FileEntry *file) { return NULL; } + virtual void *getWritePointer(FileEntry *file) { return nullptr; } }; diff --git a/Minecraft.World/ConsoleSaveFileConverter.cpp b/Minecraft.World/ConsoleSaveFileConverter.cpp index 21de3cbea..f7d8d0ee1 100644 --- a/Minecraft.World/ConsoleSaveFileConverter.cpp +++ b/Minecraft.World/ConsoleSaveFileConverter.cpp @@ -84,7 +84,7 @@ void ConsoleSaveFileConverter::ConvertSave(ConsoleSaveFile *sourceSave, ConsoleS vector *playerFiles = sourceSave->getFilesWithPrefix( DirectoryLevelStorage::getPlayerDir() ); #endif - if(playerFiles != NULL) + if(playerFiles != nullptr) { for(int fileIdx = 0; fileIdx < playerFiles->size();fileIdx++) { diff --git a/Minecraft.World/ConsoleSaveFileInputStream.cpp b/Minecraft.World/ConsoleSaveFileInputStream.cpp index 93d49956f..db9979189 100644 --- a/Minecraft.World/ConsoleSaveFileInputStream.cpp +++ b/Minecraft.World/ConsoleSaveFileInputStream.cpp @@ -9,7 +9,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile m_saveFile = saveFile; m_file = m_saveFile->createFile( file ); - m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( m_file, 0, nullptr, FILE_BEGIN ); } ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile, FileEntry *file) @@ -17,7 +17,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile m_saveFile = saveFile; m_file = file; - m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( m_file, 0, nullptr, FILE_BEGIN ); } //Reads a byte of data from this input stream. This method blocks if no input is yet available. @@ -119,7 +119,7 @@ int ConsoleSaveFileInputStream::read(byteArray b, unsigned int offset, unsigned //If this stream has an associated channel then the channel is closed as well. void ConsoleSaveFileInputStream::close() { - if( m_saveFile != NULL ) + if( m_saveFile != nullptr ) { BOOL result = m_saveFile->closeHandle( m_file ); @@ -129,6 +129,6 @@ void ConsoleSaveFileInputStream::close() } // Stop the dtor from trying to close it again - m_saveFile = NULL; + m_saveFile = nullptr; } } diff --git a/Minecraft.World/ConsoleSaveFileOriginal.cpp b/Minecraft.World/ConsoleSaveFileOriginal.cpp index f2bd522fb..182f85908 100644 --- a/Minecraft.World/ConsoleSaveFileOriginal.cpp +++ b/Minecraft.World/ConsoleSaveFileOriginal.cpp @@ -22,14 +22,14 @@ #endif unsigned int ConsoleSaveFileOriginal::pagesCommitted = 0; -void *ConsoleSaveFileOriginal::pvHeap = NULL; +void *ConsoleSaveFileOriginal::pvHeap = nullptr; -ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData /*= NULL*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) +ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData /*= nullptr*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) { InitializeCriticalSectionAndSpinCount(&m_lock,5120); // One time initialise of static stuff required for our storage - if( pvHeap == NULL ) + if( pvHeap == nullptr ) { // Reserve a chunk of 64MB of virtual address space for our saves, using 64KB pages. // We'll only be committing these as required to grow the storage we need, which will @@ -38,7 +38,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID // AP - The Vita doesn't have virtual memory so a pretend system has been implemented in PSVitaStubs.cpp. // All access to the memory must be done via the access function as the pointer returned from VirtualAlloc // can't be used directly. - pvHeap = VirtualAlloc(NULL, MAX_PAGE_COUNT * CSF_PAGE_SIZE, RESERVE_ALLOCATION, PAGE_READWRITE ); + pvHeap = VirtualAlloc(nullptr, MAX_PAGE_COUNT * CSF_PAGE_SIZE, RESERVE_ALLOCATION, PAGE_READWRITE ); } pvSaveMem = pvHeap; @@ -49,13 +49,13 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID // Load a save from the game rules bool bLevelGenBaseSave = false; LevelGenerationOptions *levelGen = app.getLevelGenerationOptions(); - if( pvSaveData == NULL && levelGen != NULL && levelGen->requiresBaseSave()) + if( pvSaveData == nullptr && levelGen != nullptr && levelGen->requiresBaseSave()) { pvSaveData = levelGen->getBaseSaveData(fileSize); if(pvSaveData && fileSize != 0) bLevelGenBaseSave = true; } - if( pvSaveData == NULL || fileSize == 0) + if( pvSaveData == nullptr || fileSize == 0) fileSize = StorageManager.GetSaveSize(); if( forceCleanSave ) @@ -75,7 +75,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID unsigned int pagesRequired = ( heapSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE; void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); - if( pvRet == NULL ) + if( pvRet == nullptr ) { #ifndef _CONTENT_PACKAGE // Out of physical memory @@ -87,7 +87,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID if( fileSize > 0) { bool AllocData = false; - if(pvSaveData != NULL) + if(pvSaveData != nullptr) { #ifdef __PSVITA__ // AP - use this to access the virtual memory @@ -181,7 +181,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID { unsigned int pagesRequired = ( desiredSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE; void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); - if( pvRet == NULL ) + if( pvRet == nullptr ) { // Out of physical memory __debugbreak(); @@ -214,9 +214,9 @@ ConsoleSaveFileOriginal::~ConsoleSaveFileOriginal() pagesCommitted = 0; // Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway #if defined _XBOX - app.GetSaveThumbnail(NULL,NULL); + app.GetSaveThumbnail(nullptr,nullptr); #elif defined __PS3__ - app.GetSaveThumbnail(NULL,NULL, NULL,NULL); + app.GetSaveThumbnail(nullptr,nullptr, nullptr,nullptr); #endif DeleteCriticalSection(&m_lock); @@ -235,7 +235,7 @@ FileEntry *ConsoleSaveFileOriginal::createFile( const ConsoleSavePath &fileName void ConsoleSaveFileOriginal::deleteFile( FileEntry *file ) { - if( file == NULL ) return; + if( file == nullptr ) return; LockSaveAccess(); @@ -339,8 +339,8 @@ void ConsoleSaveFileOriginal::PrepareForWrite( FileEntry *file, DWORD nNumberOfB BOOL ConsoleSaveFileOriginal::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten) { - assert( pvSaveMem != NULL ); - if( pvSaveMem == NULL ) + assert( pvSaveMem != nullptr ); + if( pvSaveMem == nullptr ) { return 0; } @@ -376,8 +376,8 @@ BOOL ConsoleSaveFileOriginal::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD BOOL ConsoleSaveFileOriginal::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten) { - assert( pvSaveMem != NULL ); - if( pvSaveMem == NULL ) + assert( pvSaveMem != nullptr ); + if( pvSaveMem == nullptr ) { return 0; } @@ -414,8 +414,8 @@ BOOL ConsoleSaveFileOriginal::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWr BOOL ConsoleSaveFileOriginal::readFile( FileEntry *file, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead) { DWORD actualBytesToRead; - assert( pvSaveMem != NULL ); - if( pvSaveMem == NULL ) + assert( pvSaveMem != nullptr ); + if( pvSaveMem == nullptr ) { return 0; } @@ -489,7 +489,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt { unsigned int pagesRequired = ( desiredSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE; void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); - if( pvRet == NULL ) + if( pvRet == nullptr ) { // Out of physical memory __debugbreak(); @@ -676,12 +676,12 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) #ifdef __PSVITA__ // AP - make sure we always allocate just what is needed so it will only SAVE what is needed. // If we don't do this the StorageManager will save a file of uncompressed size unnecessarily. - compData = NULL; + compData = nullptr; #endif - // If we failed to allocate then compData will be NULL + // If we failed to allocate then compData will be nullptr // Pre-calculate the compressed data size so that we can attempt to allocate a smaller buffer - if(compData == NULL) + if(compData == nullptr) { // Length should be 0 here so that the compression call knows that we want to know the length back compLength = 0; @@ -692,9 +692,9 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) QueryPerformanceCounter( &qwTime ); #ifdef __PSVITA__ // AP - get the compressed size via the access function. This uses a special RLE format - VirtualCompress(NULL,&compLength,pvSaveMem,fileSize); + VirtualCompress(nullptr,&compLength,pvSaveMem,fileSize); #else - Compression::getCompression()->Compress(NULL,&compLength,pvSaveMem,fileSize); + Compression::getCompression()->Compress(nullptr,&compLength,pvSaveMem,fileSize); #endif QueryPerformanceCounter( &qwNewTime ); @@ -713,7 +713,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) } #endif - if(compData != NULL) + if(compData != nullptr) { // No compression on PS3 - see comment above #ifndef __PS3__ @@ -743,10 +743,10 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) app.DebugPrintf("Save data compressed from %d to %d\n", fileSize, compLength); #endif - PBYTE pbThumbnailData=NULL; + PBYTE pbThumbnailData=nullptr; DWORD dwThumbnailDataSize=0; - PBYTE pbDataSaveImage=NULL; + PBYTE pbDataSaveImage=nullptr; DWORD dwDataSizeSaveImage=0; #if ( defined _XBOX || defined _DURANGO || defined _WINDOWS64 ) @@ -760,7 +760,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) __int64 seed = 0; bool hasSeed = false; - if(MinecraftServer::getInstance()!= NULL && MinecraftServer::getInstance()->levels[0]!=NULL) + if(MinecraftServer::getInstance()!= nullptr && MinecraftServer::getInstance()->levels[0]!=nullptr) { seed = MinecraftServer::getInstance()->levels[0]->getLevelData()->getSeed(); hasSeed = true; @@ -827,7 +827,7 @@ int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes) #endif #ifndef _CONTENT_PACKAGE -void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, unsigned int compressedDataSize /*= 0*/) +void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= nullptr*/, unsigned int compressedDataSize /*= 0*/) { LockSaveAccess(); @@ -867,16 +867,16 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, LPCSTR lpFileName = wstringtofilename( targetFileDir.getPath() + wstring(fileName) ); #endif #ifndef __PSVITA__ - HANDLE hSaveFile = CreateFile( lpFileName, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); + HANDLE hSaveFile = CreateFile( lpFileName, GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, nullptr); #endif - if(compressedData != NULL && compressedDataSize > 0) + if(compressedData != nullptr && compressedDataSize > 0) { #ifdef __PSVITA__ // AP - Use the access function to save - VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL); + VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, nullptr); #else - WriteFile( hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,NULL); + WriteFile( hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,nullptr); #endif assert(numberOfBytesWritten == compressedDataSize); } @@ -884,9 +884,9 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, { #ifdef __PSVITA__ // AP - Use the access function to save - VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL); + VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, nullptr); #else - WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,NULL); + WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,nullptr); #endif assert(numberOfBytesWritten == fileSize); } @@ -917,7 +917,7 @@ vector *ConsoleSaveFileOriginal::getFilesWithPrefix(const wstring & vector *ConsoleSaveFileOriginal::getRegionFilesByDimension(unsigned int dimensionIndex) { - return NULL; + return nullptr; } #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) diff --git a/Minecraft.World/ConsoleSaveFileOriginal.h b/Minecraft.World/ConsoleSaveFileOriginal.h index fd35aa1da..9c91fafcf 100644 --- a/Minecraft.World/ConsoleSaveFileOriginal.h +++ b/Minecraft.World/ConsoleSaveFileOriginal.h @@ -35,7 +35,7 @@ class ConsoleSaveFileOriginal : public ConsoleSaveFile #if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WINDOWS64) static int SaveSaveDataCallback(LPVOID lpParam,bool bRes); #endif - ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData = NULL, DWORD fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); + ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData = nullptr, DWORD fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); virtual ~ConsoleSaveFileOriginal(); // 4J Stu - Initial implementation is intended to have a similar interface to the standard Xbox file access functions @@ -56,7 +56,7 @@ class ConsoleSaveFileOriginal : public ConsoleSaveFile virtual void Flush(bool autosave, bool updateThumbnail = true); #ifndef _CONTENT_PACKAGE - virtual void DebugFlushToFile(void *compressedData = NULL, unsigned int compressedDataSize = 0); + virtual void DebugFlushToFile(void *compressedData = nullptr, unsigned int compressedDataSize = 0); #endif virtual unsigned int getSizeOnDisk(); diff --git a/Minecraft.World/ConsoleSaveFileOutputStream.cpp b/Minecraft.World/ConsoleSaveFileOutputStream.cpp index 27b46df08..c4812a734 100644 --- a/Minecraft.World/ConsoleSaveFileOutputStream.cpp +++ b/Minecraft.World/ConsoleSaveFileOutputStream.cpp @@ -19,7 +19,7 @@ ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFi m_file = m_saveFile->createFile(file); - m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( m_file, 0, nullptr, FILE_BEGIN ); } ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFile, FileEntry *file) @@ -28,7 +28,7 @@ ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFi m_file = file; - m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( m_file, 0, nullptr, FILE_BEGIN ); } //Writes the specified byte to this file output stream. Implements the write method of OutputStream. @@ -115,7 +115,7 @@ void ConsoleSaveFileOutputStream::write(byteArray b, unsigned int offset, unsign //If this stream has an associated channel then the channel is closed as well. void ConsoleSaveFileOutputStream::close() { - if( m_saveFile != NULL ) + if( m_saveFile != nullptr ) { BOOL result = m_saveFile->closeHandle( m_file ); @@ -125,6 +125,6 @@ void ConsoleSaveFileOutputStream::close() } // Stop the dtor from trying to close it again - m_saveFile = NULL; + m_saveFile = nullptr; } } diff --git a/Minecraft.World/ContainerMenu.cpp b/Minecraft.World/ContainerMenu.cpp index 83c2db2ec..3dcae136e 100644 --- a/Minecraft.World/ContainerMenu.cpp +++ b/Minecraft.World/ContainerMenu.cpp @@ -46,7 +46,7 @@ shared_ptr ContainerMenu::quickMoveStack(shared_ptr player { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -97,7 +97,7 @@ shared_ptr ContainerMenu::clicked(int slotIndex, int buttonNum, in #ifdef _EXTENDED_ACHIEVEMENTS shared_ptr localPlayer = dynamic_pointer_cast(player); - if (localPlayer != NULL) // 4J-JEV: For "Chestful o'Cobblestone" achievement. + if (localPlayer != nullptr) // 4J-JEV: For "Chestful o'Cobblestone" achievement. { int cobblecount = 0; for (int i = 0; i < container->getContainerSize(); i++) diff --git a/Minecraft.World/ContainerSetContentPacket.cpp b/Minecraft.World/ContainerSetContentPacket.cpp index 079ed59e2..ae76e0f05 100644 --- a/Minecraft.World/ContainerSetContentPacket.cpp +++ b/Minecraft.World/ContainerSetContentPacket.cpp @@ -24,7 +24,7 @@ ContainerSetContentPacket::ContainerSetContentPacket(int containerId, vector item = newItems->at(i); - items[i] = item == NULL ? nullptr : item->copy(); + items[i] = item == nullptr ? nullptr : item->copy(); } } diff --git a/Minecraft.World/ContainerSetSlotPacket.cpp b/Minecraft.World/ContainerSetSlotPacket.cpp index 42892f3cc..6a0382442 100644 --- a/Minecraft.World/ContainerSetSlotPacket.cpp +++ b/Minecraft.World/ContainerSetSlotPacket.cpp @@ -22,7 +22,7 @@ ContainerSetSlotPacket::ContainerSetSlotPacket(int containerId, int slot, shared { this->containerId = containerId; this->slot = slot; - this->item = item == NULL ? item : item->copy(); + this->item = item == nullptr ? item : item->copy(); } void ContainerSetSlotPacket::handle(PacketListener *listener) diff --git a/Minecraft.World/ControlledByPlayerGoal.cpp b/Minecraft.World/ControlledByPlayerGoal.cpp index ecda01b35..3069293d6 100644 --- a/Minecraft.World/ControlledByPlayerGoal.cpp +++ b/Minecraft.World/ControlledByPlayerGoal.cpp @@ -36,7 +36,7 @@ void ControlledByPlayerGoal::stop() bool ControlledByPlayerGoal::canUse() { - return mob->isAlive() && mob->rider.lock() != NULL && mob->rider.lock()->instanceof(eTYPE_PLAYER) && (boosting || mob->canBeControlledByRider()); + return mob->isAlive() && mob->rider.lock() != nullptr && mob->rider.lock()->instanceof(eTYPE_PLAYER) && (boosting || mob->canBeControlledByRider()); } void ControlledByPlayerGoal::tick() @@ -117,7 +117,7 @@ void ControlledByPlayerGoal::tick() { shared_ptr carriedItem = player->getCarriedItem(); - if (carriedItem != NULL && carriedItem->id == Item::carrotOnAStick_Id) + if (carriedItem != nullptr && carriedItem->id == Item::carrotOnAStick_Id) { carriedItem->hurtAndBreak(1, player); @@ -135,7 +135,7 @@ void ControlledByPlayerGoal::tick() bool ControlledByPlayerGoal::isNoJumpTile(int tile) { - return Tile::tiles[tile] != NULL && (Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_STAIRS || (dynamic_cast(Tile::tiles[tile]) != NULL) ); + return Tile::tiles[tile] != nullptr && (Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_STAIRS || (dynamic_cast(Tile::tiles[tile]) != nullptr) ); } bool ControlledByPlayerGoal::isBoosting() diff --git a/Minecraft.World/Cow.cpp b/Minecraft.World/Cow.cpp index 05e701027..d80c16a2e 100644 --- a/Minecraft.World/Cow.cpp +++ b/Minecraft.World/Cow.cpp @@ -106,7 +106,7 @@ void Cow::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) bool Cow::mobInteract(shared_ptr player) { shared_ptr item = player->inventory->getSelected(); - if (item != NULL && item->id == Item::bucket_empty->id && !player->abilities.instabuild) + if (item != nullptr && item->id == Item::bucket_empty->id && !player->abilities.instabuild) { player->awardStat(GenericStats::cowsMilked(),GenericStats::param_cowsMilked()); diff --git a/Minecraft.World/CraftingContainer.cpp b/Minecraft.World/CraftingContainer.cpp index 47a11eb49..3ec1b0394 100644 --- a/Minecraft.World/CraftingContainer.cpp +++ b/Minecraft.World/CraftingContainer.cpp @@ -58,7 +58,7 @@ bool CraftingContainer::hasCustomName() shared_ptr CraftingContainer::removeItemNoUpdate(int slot) { - if ((*items)[slot] != NULL) + if ((*items)[slot] != nullptr) { shared_ptr item = (*items)[slot]; (*items)[slot] = nullptr; @@ -69,7 +69,7 @@ shared_ptr CraftingContainer::removeItemNoUpdate(int slot) shared_ptr CraftingContainer::removeItem(unsigned int slot, int count) { - if ((*items)[slot] != NULL) + if ((*items)[slot] != nullptr) { if ((*items)[slot]->count <= count) { diff --git a/Minecraft.World/CraftingMenu.cpp b/Minecraft.World/CraftingMenu.cpp index c104bbec8..a510e8691 100644 --- a/Minecraft.World/CraftingMenu.cpp +++ b/Minecraft.World/CraftingMenu.cpp @@ -64,7 +64,7 @@ void CraftingMenu::removed(shared_ptr player) for (int i = 0; i < 9; i++) { shared_ptr item = craftSlots->removeItemNoUpdate(i); - if (item != NULL) + if (item != nullptr) { player->drop(item); } @@ -82,7 +82,7 @@ shared_ptr CraftingMenu::quickMoveStack(shared_ptr player, { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/Creeper.cpp b/Minecraft.World/Creeper.cpp index 15d84f409..0cd6b5344 100644 --- a/Minecraft.World/Creeper.cpp +++ b/Minecraft.World/Creeper.cpp @@ -64,7 +64,7 @@ bool Creeper::useNewAi() int Creeper::getMaxFallDistance() { - if (getTarget() == NULL) return 3; + if (getTarget() == nullptr) return 3; // As long as they survive the fall they should try. return 3 + static_cast(getHealth() - 1); } @@ -142,13 +142,13 @@ void Creeper::die(DamageSource *source) { Monster::die(source); - if ( source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_SKELETON) ) + if ( source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_SKELETON) ) { int recordId = Item::record_01_Id + random->nextInt(Item::record_12_Id - Item::record_01_Id + 1); spawnAtLocation(recordId, 1); } - if ( source->getDirectEntity() != NULL && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) ) + if ( source->getDirectEntity() != nullptr && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) ) { shared_ptr player = dynamic_pointer_cast(source->getEntity()); player->awardStat(GenericStats::archer(), GenericStats::param_archer()); diff --git a/Minecraft.World/CropTile.cpp b/Minecraft.World/CropTile.cpp index a339d3e3c..39753caea 100644 --- a/Minecraft.World/CropTile.cpp +++ b/Minecraft.World/CropTile.cpp @@ -9,7 +9,7 @@ CropTile::CropTile(int id) : Bush(id) { setTicking(true); updateDefaultShape(); - icons = NULL; + icons = nullptr; setDestroyTime(0.0f); setSoundType(SOUND_GRASS); diff --git a/Minecraft.World/CustomLevelSource.cpp b/Minecraft.World/CustomLevelSource.cpp index df3877441..35a5de99d 100644 --- a/Minecraft.World/CustomLevelSource.cpp +++ b/Minecraft.World/CustomLevelSource.cpp @@ -30,7 +30,7 @@ CustomLevelSource::CustomLevelSource(Level *level, __int64 seed, bool generateSt string path = "GAME:\\GameRules\\heightmap.bin"; #endif #endif - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { app.FatalLoadError(); @@ -44,14 +44,14 @@ CustomLevelSource::CustomLevelSource(Level *level, __int64 seed, bool generateSt __debugbreak(); // TODO DWORD bytesRead,dwFileSize = 0; #else - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr); #endif if(dwFileSize > m_heightmapOverride.length) { app.DebugPrintf("Heightmap binary is too large!!\n"); __debugbreak(); } - BOOL bSuccess = ReadFile(file,m_heightmapOverride.data,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(file,m_heightmapOverride.data,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { @@ -72,7 +72,7 @@ CustomLevelSource::CustomLevelSource(Level *level, __int64 seed, bool generateSt string waterHeightPath = "GAME:\\GameRules\\waterheight.bin"; #endif #endif - file = CreateFile(waterHeightPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile(waterHeightPath.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if( file == INVALID_HANDLE_VALUE ) { DWORD error = GetLastError(); @@ -86,14 +86,14 @@ CustomLevelSource::CustomLevelSource(Level *level, __int64 seed, bool generateSt __debugbreak(); // TODO DWORD bytesRead,dwFileSize = 0; #else - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); + DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr); #endif if(dwFileSize > m_waterheightOverride.length) { app.DebugPrintf("waterheight binary is too large!!\n"); __debugbreak(); } - BOOL bSuccess = ReadFile(file,m_waterheightOverride.data,dwFileSize,&bytesRead,NULL); + BOOL bSuccess = ReadFile(file,m_waterheightOverride.data,dwFileSize,&bytesRead,nullptr); if(bSuccess==FALSE) { @@ -270,7 +270,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi byte material = b->material; LevelGenerationOptions *lgo = app.getLevelGenerationOptions(); - if(lgo != NULL) + if(lgo != nullptr) { lgo->getBiomeOverride(b->id,material,top); } @@ -313,7 +313,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi { top = b->topMaterial; material = b->material; - if(lgo != NULL) + if(lgo != nullptr) { lgo->getBiomeOverride(b->id,material,top); } @@ -357,7 +357,7 @@ LevelChunk *CustomLevelSource::create(int x, int z) #ifdef _OVERRIDE_HEIGHTMAP return getChunk(x,z); #else - return NULL; + return nullptr; #endif } @@ -411,7 +411,7 @@ LevelChunk *CustomLevelSource::getChunk(int xOffs, int zOffs) return levelChunk; #else - return NULL; + return nullptr; #endif } @@ -622,9 +622,9 @@ vector *CustomLevelSource::getMobsAt(MobCategory *mobCa { #ifdef _OVERRIDE_HEIGHTMAP Biome *biome = level->getBiome(x, z); - if (biome == NULL) + if (biome == nullptr) { - return NULL; + return nullptr; } if (mobCategory == MobCategory::monster && scatteredFeature->isSwamphut(x, y, z)) { @@ -632,19 +632,19 @@ vector *CustomLevelSource::getMobsAt(MobCategory *mobCa } return biome->getMobs(mobCategory); #else - return NULL; + return nullptr; #endif } TilePos *CustomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) { #ifdef _OVERRIDE_HEIGHTMAP - if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != NULL) + if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != nullptr) { return strongholdFeature->getNearestGeneratedFeature(level, x, y, z); } #endif - return NULL; + return nullptr; } void CustomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) @@ -652,10 +652,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/CustomPayloadPacket.cpp b/Minecraft.World/CustomPayloadPacket.cpp index 81ec45766..46fde5aaf 100644 --- a/Minecraft.World/CustomPayloadPacket.cpp +++ b/Minecraft.World/CustomPayloadPacket.cpp @@ -23,7 +23,7 @@ CustomPayloadPacket::CustomPayloadPacket(const wstring &identifier, byteArray da this->identifier = identifier; this->data = data; - if (data.data != NULL) + if (data.data != nullptr) { length = data.length; @@ -45,7 +45,7 @@ void CustomPayloadPacket::read(DataInputStream *dis) if (length > 0 && length < Short::MAX_VALUE) { - if(data.data != NULL) + if(data.data != nullptr) { delete [] data.data; } @@ -58,7 +58,7 @@ void CustomPayloadPacket::write(DataOutputStream *dos) { writeUtf(identifier, dos); dos->writeShort(static_cast(length)); - if (data.data != NULL) + if (data.data != nullptr) { dos->write(data); } diff --git a/Minecraft.World/DamageEnchantment.cpp b/Minecraft.World/DamageEnchantment.cpp index ce5a7c1f9..4ca8c9a6b 100644 --- a/Minecraft.World/DamageEnchantment.cpp +++ b/Minecraft.World/DamageEnchantment.cpp @@ -51,7 +51,7 @@ int DamageEnchantment::getDescriptionId() bool DamageEnchantment::isCompatibleWith(Enchantment *other) const { - return dynamic_cast(other) == NULL; + return dynamic_cast(other) == nullptr; } bool DamageEnchantment::canEnchant(shared_ptr item) diff --git a/Minecraft.World/DamageSource.cpp b/Minecraft.World/DamageSource.cpp index 1ed1c65fe..43e236bf4 100644 --- a/Minecraft.World/DamageSource.cpp +++ b/Minecraft.World/DamageSource.cpp @@ -40,7 +40,7 @@ DamageSource *DamageSource::arrow(shared_ptr arrow, shared_ptr ow DamageSource *DamageSource::fireball(shared_ptr fireball, shared_ptr owner) { - if (owner == NULL) + if (owner == nullptr) { return (new IndirectEntityDamageSource(ChatPacket::e_ChatDeathOnFire, ChatPacket::e_ChatDeathOnFire, fireball, fireball))->setIsFire()->setProjectile(); } @@ -64,7 +64,7 @@ DamageSource *DamageSource::thorns(shared_ptr source) DamageSource *DamageSource::explosion(Explosion *explosion) { - if ( (explosion != NULL) && (explosion->getSourceMob() != NULL) ) + if ( (explosion != nullptr) && (explosion->getSourceMob() != nullptr) ) { return (new EntityDamageSource(ChatPacket::e_ChatDeathExplosionPlayer, ChatPacket::e_ChatDeathExplosionPlayer, explosion->getSourceMob()))->setScalesWithDifficulty()->setExplosion(); } @@ -191,7 +191,7 @@ DamageSource *DamageSource::setMagic() shared_ptr DamageSource::getDeathMessagePacket(shared_ptr player) { shared_ptr source = player->getKillCredit(); - if(source != NULL) + if(source != nullptr) { return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId != ChatPacket::e_ChatCustom ? m_msgWithItemId : m_msgId, source->GetType(), source->getNetworkName() ) ); } diff --git a/Minecraft.World/DataLayer.cpp b/Minecraft.World/DataLayer.cpp index 81e9ddc2e..f3916320a 100644 --- a/Minecraft.World/DataLayer.cpp +++ b/Minecraft.World/DataLayer.cpp @@ -49,7 +49,7 @@ void DataLayer::set(int x, int y, int z, int val) bool DataLayer::isValid() { - return data.data != NULL; + return data.data != nullptr; } void DataLayer::setAll(int br) diff --git a/Minecraft.World/DaylightDetectorTileEntity.cpp b/Minecraft.World/DaylightDetectorTileEntity.cpp index 8f57b0040..2b72f3c9e 100644 --- a/Minecraft.World/DaylightDetectorTileEntity.cpp +++ b/Minecraft.World/DaylightDetectorTileEntity.cpp @@ -9,10 +9,10 @@ DaylightDetectorTileEntity::DaylightDetectorTileEntity() void DaylightDetectorTileEntity::tick() { - if (level != NULL && !level->isClientSide && (level->getGameTime() % SharedConstants::TICKS_PER_SECOND) == 0) + if (level != nullptr && !level->isClientSide && (level->getGameTime() % SharedConstants::TICKS_PER_SECOND) == 0) { tile = getTile(); - if (tile != NULL && dynamic_cast(tile) != NULL) + if (tile != nullptr && dynamic_cast(tile) != nullptr) { static_cast(tile)->updateSignalStrength(level, x, y, z); } diff --git a/Minecraft.World/DeadBushTile.cpp b/Minecraft.World/DeadBushTile.cpp index 33fdfe6c0..06bd41ee0 100644 --- a/Minecraft.World/DeadBushTile.cpp +++ b/Minecraft.World/DeadBushTile.cpp @@ -29,7 +29,7 @@ int DeadBushTile::getResource(int data, Random *random, int playerBonusLevel) void DeadBushTile::playerDestroy(Level *level, shared_ptr player, int x, int y, int z, int data) { - if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears_Id) + if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears_Id) { player->awardStat( GenericStats::blocksMined(id), diff --git a/Minecraft.World/DefendVillageTargetGoal.cpp b/Minecraft.World/DefendVillageTargetGoal.cpp index 6ed6af53d..201738a38 100644 --- a/Minecraft.World/DefendVillageTargetGoal.cpp +++ b/Minecraft.World/DefendVillageTargetGoal.cpp @@ -12,7 +12,7 @@ DefendVillageTargetGoal::DefendVillageTargetGoal(VillagerGolem *golem) : TargetG bool DefendVillageTargetGoal::canUse() { shared_ptr village = golem->getVillage(); - if (village == NULL) return false; + if (village == nullptr) return false; potentialTarget = weak_ptr(village->getClosestAggressor(dynamic_pointer_cast(golem->shared_from_this()))); shared_ptr potTarget = potentialTarget.lock(); if (!canAttack(potTarget, false)) diff --git a/Minecraft.World/DetectorRailTile.cpp b/Minecraft.World/DetectorRailTile.cpp index 16265ceb8..ce35a5926 100644 --- a/Minecraft.World/DetectorRailTile.cpp +++ b/Minecraft.World/DetectorRailTile.cpp @@ -12,7 +12,7 @@ DetectorRailTile::DetectorRailTile(int id) : BaseRailTile(id, true) { setTicking(true); - icons = NULL; + icons = nullptr; } int DetectorRailTile::getTickDelay(Level *level) diff --git a/Minecraft.World/Dimension.cpp b/Minecraft.World/Dimension.cpp index 75e225b3c..57f1dbb32 100644 --- a/Minecraft.World/Dimension.cpp +++ b/Minecraft.World/Dimension.cpp @@ -70,7 +70,7 @@ Dimension::~Dimension() { delete[] brightnessRamp; - if(biomeSource != NULL) + if(biomeSource != nullptr) delete biomeSource; } @@ -161,7 +161,7 @@ float *Dimension::getSunriseColor(float td, float a) return sunriseCol; } - return NULL; + return nullptr; } Vec3 *Dimension::getFogColor(float td, float a) const @@ -192,7 +192,7 @@ Dimension *Dimension::getNew(int id) if (id == 0) return new NormalDimension(); if (id == 1) return new TheEndDimension(); - return NULL; + return nullptr; } float Dimension::getCloudHeight() @@ -207,7 +207,7 @@ bool Dimension::hasGround() Pos *Dimension::getSpawnPos() { - return NULL; + return nullptr; } int Dimension::getSpawnYPosition() diff --git a/Minecraft.World/DiodeTile.cpp b/Minecraft.World/DiodeTile.cpp index e5bbfede1..b40a5af53 100644 --- a/Minecraft.World/DiodeTile.cpp +++ b/Minecraft.World/DiodeTile.cpp @@ -299,7 +299,7 @@ bool DiodeTile::isSolidRender(bool isServerLevel) bool DiodeTile::isAlternateInput(int tile) { Tile *tt = Tile::tiles[tile]; - return tt != NULL && tt->isSignalSource(); + return tt != nullptr && tt->isSignalSource(); } int DiodeTile::getOutputSignal(LevelSource *level, int x, int y, int z, int data) diff --git a/Minecraft.World/DirectoryLevelStorage.cpp b/Minecraft.World/DirectoryLevelStorage.cpp index 73c841e0f..f6231530c 100644 --- a/Minecraft.World/DirectoryLevelStorage.cpp +++ b/Minecraft.World/DirectoryLevelStorage.cpp @@ -217,13 +217,13 @@ ChunkStorage *DirectoryLevelStorage::createChunkStorage(Dimension *dimension) { // 4J Jev, removed try/catch. - if (dynamic_cast(dimension) != NULL) + if (dynamic_cast(dimension) != nullptr) { File dir2 = File(dir, LevelStorage::NETHER_FOLDER); //dir2.mkdirs(); // 4J Removed return new OldChunkStorage(dir2, true); } - if (dynamic_cast(dimension) != NULL) + if (dynamic_cast(dimension) != nullptr) { File dir2 = File(dir, LevelStorage::ENDER_FOLDER); //dir2.mkdirs(); // 4J Removed @@ -270,7 +270,7 @@ LevelData *DirectoryLevelStorage::prepareLevel() else #endif { - getSaveFile()->setFilePointer(fileEntry,0,NULL, FILE_BEGIN); + getSaveFile()->setFilePointer(fileEntry,0,nullptr, FILE_BEGIN); #ifdef _LARGE_WORLDS byteArray data(fileEntry->getFileSize()); @@ -344,7 +344,7 @@ LevelData *DirectoryLevelStorage::prepareLevel() return ret; } - return NULL; + return nullptr; } void DirectoryLevelStorage::saveLevelData(LevelData *levelData, vector > *players) @@ -432,7 +432,7 @@ void DirectoryLevelStorage::save(shared_ptr player) CompoundTag *DirectoryLevelStorage::load(shared_ptr player) { CompoundTag *tag = loadPlayerDataTag( player->getXuid() ); - if (tag != NULL) + if (tag != nullptr) { player->load(tag); } @@ -464,7 +464,7 @@ CompoundTag *DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid) ConsoleSaveFileInputStream fis = ConsoleSaveFileInputStream(m_saveFile, realFile); return NbtIo::readCompressed(&fis); } - return NULL; + return nullptr; } // 4J Added function @@ -478,7 +478,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles() vector *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() ); #endif - if( playerFiles != NULL ) + if( playerFiles != nullptr ) { #ifndef _FINAL_BUILD if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<createFile(file); - m_saveFile->setFilePointer(fileEntry,0,NULL, FILE_BEGIN); + m_saveFile->setFilePointer(fileEntry,0,nullptr, FILE_BEGIN); #ifdef _LARGE_WORLDS ByteArrayOutputStream baos; diff --git a/Minecraft.World/DirectoryLevelStorageSource.cpp b/Minecraft.World/DirectoryLevelStorageSource.cpp index e229232b1..232d4d443 100644 --- a/Minecraft.World/DirectoryLevelStorageSource.cpp +++ b/Minecraft.World/DirectoryLevelStorageSource.cpp @@ -32,7 +32,7 @@ vector *DirectoryLevelStorageSource::getLevelList() wstring levelId = wstring(L"World").append( std::to_wstring( (i+1) ) ); LevelData *levelData = getDataTagFor(saveFile, levelId); - if (levelData != NULL) + if (levelData != nullptr) { levels->push_back(new LevelSummary(levelId, L"", levelData->getLastPlayed(), levelData->getSizeOnDisk(), levelData.getGameType(), false, levelData->isHardcore())); } @@ -59,7 +59,7 @@ LevelData *DirectoryLevelStorageSource::getDataTagFor(ConsoleSaveFile *saveFile, return ret; } - return NULL; + return nullptr; } void DirectoryLevelStorageSource::renameLevel(const wstring& levelId, const wstring& newLevelName) diff --git a/Minecraft.World/DispenserTile.cpp b/Minecraft.World/DispenserTile.cpp index 2e141948b..abbb67d41 100644 --- a/Minecraft.World/DispenserTile.cpp +++ b/Minecraft.World/DispenserTile.cpp @@ -18,9 +18,9 @@ DispenserTile::DispenserTile(int id) : BaseEntityTile(id, Material::stone) { random = new Random(); - iconTop = NULL; - iconFront = NULL; - iconFrontVertical = NULL; + iconTop = nullptr; + iconFront = nullptr; + iconFrontVertical = nullptr; } int DispenserTile::getTickDelay(Level *level) @@ -115,7 +115,7 @@ void DispenserTile::dispenseFrom(Level *level, int x, int y, int z) { BlockSourceImpl source(level, x, y, z); shared_ptr trap = dynamic_pointer_cast( source.getEntity() ); - if (trap == NULL) return; + if (trap == nullptr) return; int slot = trap->getRandomSlot(); if (slot < 0) @@ -186,12 +186,12 @@ void DispenserTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr
  • container = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (container != NULL ) + if (container != nullptr ) { for (unsigned int i = 0; i < container->getContainerSize(); i++) { shared_ptr item = container->getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; diff --git a/Minecraft.World/DispenserTileEntity.cpp b/Minecraft.World/DispenserTileEntity.cpp index 2a00f4cd5..9129ea5cd 100644 --- a/Minecraft.World/DispenserTileEntity.cpp +++ b/Minecraft.World/DispenserTileEntity.cpp @@ -35,7 +35,7 @@ shared_ptr DispenserTileEntity::getItem(unsigned int slot) shared_ptr DispenserTileEntity::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { if (items[slot]->count <= count) { @@ -61,7 +61,7 @@ shared_ptr DispenserTileEntity::removeItem(unsigned int slot, int shared_ptr DispenserTileEntity::removeItemNoUpdate(int slot) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -73,7 +73,7 @@ shared_ptr DispenserTileEntity::removeItemNoUpdate(int slot) // 4J-PB added for spawn eggs not being useable due to limits, so add them in again void DispenserTileEntity::AddItemBack(shared_ptritem, unsigned int slot) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { // just increment the count of the items if(item->id==items[slot]->id) @@ -85,7 +85,7 @@ void DispenserTileEntity::AddItemBack(shared_ptritem, unsigned int else { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); setChanged(); } } @@ -99,10 +99,10 @@ bool DispenserTileEntity::removeProjectile(int itemId) { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->id == itemId) + if (items[i] != nullptr && items[i]->id == itemId) { shared_ptr removedItem = removeItem(i, 1); - return removedItem != NULL; + return removedItem != nullptr; } } return false; @@ -114,7 +114,7 @@ int DispenserTileEntity::getRandomSlot() int replaceOdds = 1; for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && random->nextInt(replaceOdds++) == 0) + if (items[i] != nullptr && random->nextInt(replaceOdds++) == 0) { replaceSlot = i; } @@ -126,7 +126,7 @@ int DispenserTileEntity::getRandomSlot() void DispenserTileEntity::setItem(unsigned int slot, shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); setChanged(); } @@ -134,7 +134,7 @@ int DispenserTileEntity::addItem(shared_ptr item) { for (int i = 0; i < items.length; i++) { - if (items[i] == NULL || items[i]->id == 0) + if (items[i] == nullptr || items[i]->id == 0) { setItem(i, item); return i; @@ -186,7 +186,7 @@ void DispenserTileEntity::save(CompoundTag *base) for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i)); @@ -236,7 +236,7 @@ shared_ptr DispenserTileEntity::clone() for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { result->items[i] = ItemInstance::clone(items[i]); } diff --git a/Minecraft.World/DoorInteractGoal.cpp b/Minecraft.World/DoorInteractGoal.cpp index fc4a9a68e..458057448 100644 --- a/Minecraft.World/DoorInteractGoal.cpp +++ b/Minecraft.World/DoorInteractGoal.cpp @@ -9,7 +9,7 @@ DoorInteractGoal::DoorInteractGoal(Mob *mob) { doorX = doorY = doorZ = 0; - doorTile = NULL; + doorTile = nullptr; passed = false; doorOpenDirX = doorOpenDirZ = 0.0f; @@ -21,7 +21,7 @@ bool DoorInteractGoal::canUse() if (!mob->horizontalCollision) return false; PathNavigation *pathNav = mob->getNavigation(); Path *path = pathNav->getPath(); - if (path == NULL || path->isDone() || !pathNav->canOpenDoors()) return false; + if (path == nullptr || path->isDone() || !pathNav->canOpenDoors()) return false; for (int i = 0; i < min(path->getIndex() + 2, path->getSize()); ++i) { @@ -31,7 +31,7 @@ bool DoorInteractGoal::canUse() doorZ = n->z; if (mob->distanceToSqr(doorX, mob->y, doorZ) > 1.5 * 1.5) continue; doorTile = getDoorTile(doorX, doorY, doorZ); - if (doorTile == NULL) continue; + if (doorTile == nullptr) continue; return true; } @@ -39,7 +39,7 @@ bool DoorInteractGoal::canUse() doorY = Mth::floor(mob->y + 1); doorZ = Mth::floor(mob->z); doorTile = getDoorTile(doorX, doorY, doorZ); - return doorTile != NULL; + return doorTile != nullptr; } bool DoorInteractGoal::canContinueToUse() @@ -68,6 +68,6 @@ void DoorInteractGoal::tick() DoorTile *DoorInteractGoal::getDoorTile(int x, int y, int z) { int tileId = mob->level->getTile(x, y, z); - if (tileId != Tile::door_wood_Id) return NULL; + if (tileId != Tile::door_wood_Id) return nullptr; return static_cast(Tile::tiles[tileId]); } \ No newline at end of file diff --git a/Minecraft.World/DropperTile.cpp b/Minecraft.World/DropperTile.cpp index a28228c98..098b6338a 100644 --- a/Minecraft.World/DropperTile.cpp +++ b/Minecraft.World/DropperTile.cpp @@ -34,7 +34,7 @@ void DropperTile::dispenseFrom(Level *level, int x, int y, int z) { BlockSourceImpl source(level, x, y, z); shared_ptr trap = dynamic_pointer_cast( source.getEntity() ); - if (trap == NULL) return; + if (trap == nullptr) return; int slot = trap->getRandomSlot(); if (slot < 0) @@ -48,11 +48,11 @@ void DropperTile::dispenseFrom(Level *level, int x, int y, int z) shared_ptr into = HopperTileEntity::getContainerAt(level, x + Facing::STEP_X[face], y + Facing::STEP_Y[face], z + Facing::STEP_Z[face]); shared_ptr remaining = nullptr; - if (into != NULL) + if (into != nullptr) { remaining = HopperTileEntity::addItem(into.get(), item->copy()->remove(1), Facing::OPPOSITE_FACING[face]); - if (remaining == NULL) + if (remaining == nullptr) { remaining = item->copy(); if (--remaining->count == 0) remaining = nullptr; @@ -66,7 +66,7 @@ void DropperTile::dispenseFrom(Level *level, int x, int y, int z) else { remaining = DISPENSE_BEHAVIOUR->dispense(&source, item); - if (remaining != NULL && remaining->count == 0) remaining = nullptr; + if (remaining != nullptr && remaining->count == 0) remaining = nullptr; } trap->setItem(slot, remaining); diff --git a/Minecraft.World/DurangoStats.cpp b/Minecraft.World/DurangoStats.cpp index 7ec808bc6..7302d9edc 100644 --- a/Minecraft.World/DurangoStats.cpp +++ b/Minecraft.World/DurangoStats.cpp @@ -267,11 +267,11 @@ byteArray DsMobKilled::createParamBlob(shared_ptr player, shared_ptrGetType(); - if ( (mobEType == eTYPE_SPIDER) && (mob->rider.lock() != NULL) && (mob->rider.lock()->GetType() == eTYPE_SKELETON) && mob->rider.lock()->isAlive() ) + if ( (mobEType == eTYPE_SPIDER) && (mob->rider.lock() != nullptr) && (mob->rider.lock()->GetType() == eTYPE_SKELETON) && mob->rider.lock()->isAlive() ) { mob_networking_id = SPIDER_JOCKEY_ID; // Spider jockey only a concept for leaderboards. } - else if ( (mobEType == eTYPE_SKELETON) && (mob->riding != NULL) && (mob->riding->GetType() == eTYPE_SPIDER) && mob->riding->isAlive() ) + else if ( (mobEType == eTYPE_SKELETON) && (mob->riding != nullptr) && (mob->riding->GetType() == eTYPE_SPIDER) && mob->riding->isAlive() ) { mob_networking_id = SPIDER_JOCKEY_ID; // Spider jockey only a concept for leaderboards. } @@ -303,7 +303,7 @@ byteArray DsMobKilled::createParamBlob(shared_ptr player, shared_ptrgetItem()->id : 0), + (item != nullptr ? item->getItem()->id : 0), mob->distanceTo(player->x, player->y, player->z), 0/*not needed*/ }; @@ -729,7 +729,7 @@ Stat *DurangoStats::get_stat(int i) default: assert(false); break; } - return NULL; + return nullptr; } Stat* DurangoStats::get_walkOneM() @@ -833,7 +833,7 @@ Stat* DurangoStats::get_itemsCrafted(int itemId) case Item::diamond_Id: case Item::redStone_Id: case Item::emerald_Id: - return NULL; + return nullptr; case Item::dye_powder_Id: default: @@ -890,7 +890,7 @@ Stat* DurangoStats::get_achievement(eAward achievementId) } // Other achievements awarded through more detailed generic events. - return NULL; + return nullptr; } byteArray DurangoStats::getParam_walkOneM(int distance) @@ -1130,7 +1130,7 @@ LPCWSTR DurangoStats::getUserId(int iPad) void DurangoStats::playerSessionStart(PlayerUID uid, shared_ptr plr) { - if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL) + if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr) { //wprintf(uid.toString().c_str()); @@ -1164,7 +1164,7 @@ void DurangoStats::playerSessionStart(int iPad) void DurangoStats::playerSessionPause(int iPad) { shared_ptr plr = Minecraft::GetInstance()->localplayers[iPad]; - if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL) + if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr) { PlayerUID puid; ProfileManager.GetXUID(iPad, &puid, true); @@ -1187,7 +1187,7 @@ void DurangoStats::playerSessionPause(int iPad) void DurangoStats::playerSessionResume(int iPad) { shared_ptr plr = Minecraft::GetInstance()->localplayers[iPad]; - if (plr != NULL && plr->level != NULL && plr->level->getLevelData() != NULL) + if (plr != nullptr && plr->level != nullptr && plr->level->getLevelData() != nullptr) { PlayerUID puid; ProfileManager.GetXUID(iPad, &puid, true); @@ -1214,7 +1214,7 @@ void DurangoStats::playerSessionResume(int iPad) void DurangoStats::playerSessionEnd(int iPad) { shared_ptr plr = Minecraft::GetInstance()->localplayers[iPad]; - if (plr != NULL) + if (plr != nullptr) { DurangoStats::getInstance()->travel->flush(plr); } diff --git a/Minecraft.World/DyePowderItem.cpp b/Minecraft.World/DyePowderItem.cpp index 81faf63fc..3392da982 100644 --- a/Minecraft.World/DyePowderItem.cpp +++ b/Minecraft.World/DyePowderItem.cpp @@ -18,7 +18,7 @@ DyePowderItem::DyePowderItem(int id) : Item( id ) { setStackedByData(true); setMaxDamage(0); - icons = NULL; + icons = nullptr; } const unsigned int DyePowderItem::COLOR_DESCS[] = @@ -306,9 +306,9 @@ void DyePowderItem::addGrowthParticles(Level *level, int x, int y, int z, int co { int id = level->getTile(x, y, z); if (count == 0) count = 15; - Tile *tile = id > 0 && id < Tile::TILE_NUM_COUNT ? Tile::tiles[id] : NULL; + Tile *tile = id > 0 && id < Tile::TILE_NUM_COUNT ? Tile::tiles[id] : nullptr; - if (tile == NULL) return; + if (tile == nullptr) return; tile->updateShape(level, x, y, z); for (int i = 0; i < count; i++) @@ -322,7 +322,7 @@ void DyePowderItem::addGrowthParticles(Level *level, int x, int y, int z, int co bool DyePowderItem::interactEnemy(shared_ptr itemInstance, shared_ptr player, shared_ptr mob) { - if (dynamic_pointer_cast( mob ) != NULL) + if (dynamic_pointer_cast( mob ) != nullptr) { shared_ptr sheep = dynamic_pointer_cast(mob); // convert to tile-based color value (0 is white instead of black) diff --git a/Minecraft.World/EnchantItemCommand.cpp b/Minecraft.World/EnchantItemCommand.cpp index 7ec57563c..dec0bf8e4 100644 --- a/Minecraft.World/EnchantItemCommand.cpp +++ b/Minecraft.World/EnchantItemCommand.cpp @@ -28,15 +28,15 @@ void EnchantItemCommand::execute(shared_ptr source, byteArray com shared_ptr player = getPlayer(uid); - if(player == NULL) return; + if(player == nullptr) return; shared_ptr selectedItem = player->getSelectedItem(); - if(selectedItem == NULL) return; + if(selectedItem == nullptr) return; Enchantment *e = Enchantment::enchantments[enchantmentId]; - if(e == NULL) return; + if(e == nullptr) return; if(!e->canEnchant(selectedItem)) return; if(enchantmentLevel < e->getMinLevel()) enchantmentLevel = e->getMinLevel(); @@ -45,13 +45,13 @@ void EnchantItemCommand::execute(shared_ptr source, byteArray com if (selectedItem->hasTag()) { ListTag *enchantmentTags = selectedItem->getEnchantmentTags(); - if (enchantmentTags != NULL) + if (enchantmentTags != nullptr) { for (int i = 0; i < enchantmentTags->size(); i++) { int type = enchantmentTags->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_ID); - if (Enchantment::enchantments[type] != NULL) + if (Enchantment::enchantments[type] != nullptr) { Enchantment *other = Enchantment::enchantments[type]; if (!other->isCompatibleWith(e)) @@ -72,7 +72,7 @@ void EnchantItemCommand::execute(shared_ptr source, byteArray com shared_ptr EnchantItemCommand::preparePacket(shared_ptr player, int enchantmentId, int enchantmentLevel) { - if(player == NULL) return nullptr; + if(player == nullptr) return nullptr; ByteArrayOutputStream baos; DataOutputStream dos(&baos); diff --git a/Minecraft.World/EnchantedBookItem.cpp b/Minecraft.World/EnchantedBookItem.cpp index 590c8bda6..65153c00b 100644 --- a/Minecraft.World/EnchantedBookItem.cpp +++ b/Minecraft.World/EnchantedBookItem.cpp @@ -35,7 +35,7 @@ const Rarity *EnchantedBookItem::getRarity(shared_ptr itemInstance ListTag *EnchantedBookItem::getEnchantments(shared_ptr item) { - if (item->tag == NULL || !item->tag->contains((wchar_t *)TAG_STORED_ENCHANTMENTS.c_str())) + if (item->tag == nullptr || !item->tag->contains((wchar_t *)TAG_STORED_ENCHANTMENTS.c_str())) { return new ListTag(); } @@ -49,7 +49,7 @@ void EnchantedBookItem::appendHoverText(shared_ptr itemInstance, s ListTag *list = getEnchantments(itemInstance); - if (list != NULL) + if (list != nullptr) { wstring unformatted = L""; for (int i = 0; i < list->size(); i++) @@ -57,7 +57,7 @@ void EnchantedBookItem::appendHoverText(shared_ptr itemInstance, s int type = list->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_ID); int level = list->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL); - if (Enchantment::enchantments[type] != NULL) + if (Enchantment::enchantments[type] != nullptr) { lines->push_back(Enchantment::enchantments[type]->getFullname(level)); } diff --git a/Minecraft.World/Enchantment.cpp b/Minecraft.World/Enchantment.cpp index ae638b27e..c2f981a61 100644 --- a/Minecraft.World/Enchantment.cpp +++ b/Minecraft.World/Enchantment.cpp @@ -7,34 +7,34 @@ EnchantmentArray Enchantment::enchantments = EnchantmentArray( 256 ); vector Enchantment::validEnchantments; -Enchantment *Enchantment::allDamageProtection = NULL; -Enchantment *Enchantment::fireProtection = NULL; -Enchantment *Enchantment::fallProtection = NULL; -Enchantment *Enchantment::explosionProtection = NULL; -Enchantment *Enchantment::projectileProtection = NULL; -Enchantment *Enchantment::drownProtection = NULL; -Enchantment *Enchantment::waterWorker = NULL; -Enchantment *Enchantment::thorns = NULL; +Enchantment *Enchantment::allDamageProtection = nullptr; +Enchantment *Enchantment::fireProtection = nullptr; +Enchantment *Enchantment::fallProtection = nullptr; +Enchantment *Enchantment::explosionProtection = nullptr; +Enchantment *Enchantment::projectileProtection = nullptr; +Enchantment *Enchantment::drownProtection = nullptr; +Enchantment *Enchantment::waterWorker = nullptr; +Enchantment *Enchantment::thorns = nullptr; // weapon -Enchantment *Enchantment::damageBonus = NULL; -Enchantment *Enchantment::damageBonusUndead = NULL; -Enchantment *Enchantment::damageBonusArthropods = NULL; -Enchantment *Enchantment::knockback = NULL; -Enchantment *Enchantment::fireAspect = NULL; -Enchantment *Enchantment::lootBonus = NULL; +Enchantment *Enchantment::damageBonus = nullptr; +Enchantment *Enchantment::damageBonusUndead = nullptr; +Enchantment *Enchantment::damageBonusArthropods = nullptr; +Enchantment *Enchantment::knockback = nullptr; +Enchantment *Enchantment::fireAspect = nullptr; +Enchantment *Enchantment::lootBonus = nullptr; // digger -Enchantment *Enchantment::diggingBonus = NULL; -Enchantment *Enchantment::untouching = NULL; -Enchantment *Enchantment::digDurability = NULL; -Enchantment *Enchantment::resourceBonus = NULL; +Enchantment *Enchantment::diggingBonus = nullptr; +Enchantment *Enchantment::untouching = nullptr; +Enchantment *Enchantment::digDurability = nullptr; +Enchantment *Enchantment::resourceBonus = nullptr; // bows -Enchantment *Enchantment::arrowBonus = NULL; -Enchantment *Enchantment::arrowKnockback = NULL; -Enchantment *Enchantment::arrowFire = NULL; -Enchantment *Enchantment::arrowInfinite = NULL; +Enchantment *Enchantment::arrowBonus = nullptr; +Enchantment *Enchantment::arrowKnockback = nullptr; +Enchantment *Enchantment::arrowFire = nullptr; +Enchantment *Enchantment::arrowInfinite = nullptr; void Enchantment::staticCtor() { @@ -70,7 +70,7 @@ void Enchantment::staticCtor() for(unsigned int i = 0; i < 256; ++i) { Enchantment *enchantment = enchantments[i]; - if (enchantment != NULL) + if (enchantment != nullptr) { validEnchantments.push_back(enchantment); } @@ -79,7 +79,7 @@ void Enchantment::staticCtor() void Enchantment::_init(int id) { - if (enchantments[id] != NULL) + if (enchantments[id] != nullptr) { app.DebugPrintf("Duplicate enchantment id!"); #ifndef _CONTENT_PACKAGE diff --git a/Minecraft.World/EnchantmentCategory.cpp b/Minecraft.World/EnchantmentCategory.cpp index b7460f58e..b1c951eee 100644 --- a/Minecraft.World/EnchantmentCategory.cpp +++ b/Minecraft.World/EnchantmentCategory.cpp @@ -16,7 +16,7 @@ bool EnchantmentCategory::canEnchant(Item *item) const { if (this == all) return true; - if (dynamic_cast( item ) != NULL) + if (dynamic_cast( item ) != nullptr) { if (this == armor) return true; ArmorItem *ai = static_cast(item); @@ -26,15 +26,15 @@ bool EnchantmentCategory::canEnchant(Item *item) const if (ai->slot == ArmorItem::SLOT_FEET) return this == armor_feet; return false; } - else if (dynamic_cast(item) != NULL) + else if (dynamic_cast(item) != nullptr) { return this == weapon; } - else if (dynamic_cast(item) != NULL) + else if (dynamic_cast(item) != nullptr) { return this == digger; } - else if (dynamic_cast(item) != NULL) + else if (dynamic_cast(item) != nullptr) { return this == bow; } diff --git a/Minecraft.World/EnchantmentHelper.cpp b/Minecraft.World/EnchantmentHelper.cpp index 8f4f4ed19..995670c83 100644 --- a/Minecraft.World/EnchantmentHelper.cpp +++ b/Minecraft.World/EnchantmentHelper.cpp @@ -11,12 +11,12 @@ Random EnchantmentHelper::random; int EnchantmentHelper::getEnchantmentLevel(int enchantmentId, shared_ptr piece) { - if (piece == NULL) + if (piece == nullptr) { return 0; } ListTag *enchantmentTags = piece->getEnchantmentTags(); - if (enchantmentTags == NULL) + if (enchantmentTags == nullptr) { return 0; } @@ -38,7 +38,7 @@ unordered_map *EnchantmentHelper::getEnchantments(shared_ptr *result = new unordered_map(); ListTag *list = item->id == Item::enchantedBook_Id ? Item::enchantedBook->getEnchantments(item) : item->getEnchantmentTags(); - if (list != NULL) + if (list != nullptr) { for (int i = 0; i < list->size(); i++) { @@ -88,7 +88,7 @@ void EnchantmentHelper::setEnchantments(unordered_map *enchantments, s int EnchantmentHelper::getEnchantmentLevel(int enchantmentId, ItemInstanceArray inventory) { - if (inventory.data == NULL) return 0; + if (inventory.data == nullptr) return 0; int bestLevel = 0; //for (ItemInstance piece : inventory) for(unsigned int i = 0; i < inventory.length; ++i) @@ -104,12 +104,12 @@ int EnchantmentHelper::getEnchantmentLevel(int enchantmentId, ItemInstanceArray void EnchantmentHelper::runIterationOnItem(EnchantmentIterationMethod &method, shared_ptr piece) { - if (piece == NULL) + if (piece == nullptr) { return; } ListTag *enchantmentTags = piece->getEnchantmentTags(); - if (enchantmentTags == NULL) + if (enchantmentTags == nullptr) { return; } @@ -118,7 +118,7 @@ void EnchantmentHelper::runIterationOnItem(EnchantmentIterationMethod &method, s int type = enchantmentTags->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_ID); int level = enchantmentTags->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL); - if (Enchantment::enchantments[type] != NULL) + if (Enchantment::enchantments[type] != nullptr) { method.doEnchantment(Enchantment::enchantments[type], level); } @@ -245,7 +245,7 @@ shared_ptr EnchantmentHelper::getRandomItemWith(Enchantment *encha for(unsigned int i = 0; i < items.length; ++i) { shared_ptr item = items[i]; - if (item != NULL && getEnchantmentLevel(enchantment->id, item) > 0) + if (item != nullptr && getEnchantmentLevel(enchantment->id, item) > 0) { return item; } @@ -338,7 +338,7 @@ vector *EnchantmentHelper::selectEnchantment(Random *rand if (itemBonus <= 0) { - return NULL; + return nullptr; } // 4J Stu - Update function to 1.3 version for TU7 itemBonus /= 2; @@ -354,7 +354,7 @@ vector *EnchantmentHelper::selectEnchantment(Random *rand realValue = 1; } - vector *results = NULL; + vector *results = nullptr; unordered_map *availableEnchantments = getAvailableEnchantmentResults(realValue, itemInstance); if (availableEnchantments && !availableEnchantments->empty()) @@ -433,7 +433,7 @@ vector *EnchantmentHelper::selectEnchantment(Random *rand unordered_map *EnchantmentHelper::getAvailableEnchantmentResults(int value, shared_ptr itemInstance) { Item *item = itemInstance->getItem(); - unordered_map *results = NULL; + unordered_map *results = nullptr; bool isBook = itemInstance->id == Item::book_Id; @@ -441,7 +441,7 @@ unordered_map *EnchantmentHelper::getAvailableEnchan for(unsigned int i = 0; i < Enchantment::enchantments.length; ++i) { Enchantment *e = Enchantment::enchantments[i]; - if (e == NULL) + if (e == nullptr) { continue; } @@ -456,7 +456,7 @@ unordered_map *EnchantmentHelper::getAvailableEnchan { if (value >= e->getMinCost(level) && value <= e->getMaxCost(level)) { - if (results == NULL) + if (results == nullptr) { results = new unordered_map(); } diff --git a/Minecraft.World/EnchantmentMenu.cpp b/Minecraft.World/EnchantmentMenu.cpp index fa769bf9c..08c51c3d0 100644 --- a/Minecraft.World/EnchantmentMenu.cpp +++ b/Minecraft.World/EnchantmentMenu.cpp @@ -81,7 +81,7 @@ void EnchantmentMenu::slotsChanged() // 4J used to take a shared_ptr { shared_ptr item = enchantSlots->getItem(0); - if (item == NULL || !item->isEnchantable()) + if (item == nullptr || !item->isEnchantable()) { for (int i = 0; i < 3; i++) { @@ -153,14 +153,14 @@ void EnchantmentMenu::slotsChanged() // 4J used to take a shared_ptr bool EnchantmentMenu::clickMenuButton(shared_ptr player, int i) { shared_ptr item = enchantSlots->getItem(0); - if (costs[i] > 0 && item != NULL && (player->experienceLevel >= costs[i] || player->abilities.instabuild) ) + if (costs[i] > 0 && item != nullptr && (player->experienceLevel >= costs[i] || player->abilities.instabuild) ) { if (!level->isClientSide) { bool isBook = item->id == Item::book_Id; vector *newEnchantment = EnchantmentHelper::selectEnchantment(&random, item, costs[i]); - if (newEnchantment != NULL) + if (newEnchantment != nullptr) { player->giveExperienceLevels(-costs[i]); if (isBook) item->id = Item::enchantedBook_Id; @@ -200,7 +200,7 @@ void EnchantmentMenu::removed(shared_ptr player) if (level->isClientSide) return; shared_ptr item = enchantSlots->removeItemNoUpdate(0); - if (item != NULL) + if (item != nullptr) { player->drop(item); } @@ -219,7 +219,7 @@ shared_ptr EnchantmentMenu::quickMoveStack(shared_ptr play Slot *slot = slots.at(slotIndex); Slot *IngredientSlot = slots.at(INGREDIENT_SLOT); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/EnchantmentTableEntity.cpp b/Minecraft.World/EnchantmentTableEntity.cpp index 0b722680b..3e5924d22 100644 --- a/Minecraft.World/EnchantmentTableEntity.cpp +++ b/Minecraft.World/EnchantmentTableEntity.cpp @@ -46,7 +46,7 @@ void EnchantmentTableEntity::tick() oRot = rot; shared_ptr player = level->getNearestPlayer(x + 0.5f, y + 0.5f, z + 0.5f, 3); - if (player != NULL) + if (player != nullptr) { double xd = player->x - (x + 0.5f); double zd = player->z - (z + 0.5f); diff --git a/Minecraft.World/EnchantmentTableTile.cpp b/Minecraft.World/EnchantmentTableTile.cpp index d50fe5f5e..8e777ea11 100644 --- a/Minecraft.World/EnchantmentTableTile.cpp +++ b/Minecraft.World/EnchantmentTableTile.cpp @@ -14,8 +14,8 @@ EnchantmentTableTile::EnchantmentTableTile(int id) : BaseEntityTile(id, Material updateDefaultShape(); setLightBlock(0); - iconTop = NULL; - iconBottom = NULL; + iconTop = nullptr; + iconBottom = nullptr; } // 4J Added override diff --git a/Minecraft.World/EnderChestTile.cpp b/Minecraft.World/EnderChestTile.cpp index ef3c2046d..464c04823 100644 --- a/Minecraft.World/EnderChestTile.cpp +++ b/Minecraft.World/EnderChestTile.cpp @@ -65,7 +65,7 @@ bool EnderChestTile::use(Level *level, int x, int y, int z, shared_ptr p { shared_ptr container = player->getEnderChestInventory(); shared_ptr enderChest = dynamic_pointer_cast(level->getTileEntity(x, y, z)); - if (container == NULL || enderChest == NULL) return true; + if (container == nullptr || enderChest == nullptr) return true; if (level->isSolidBlockingTile(x, y + 1, z)) return true; diff --git a/Minecraft.World/EnderCrystal.cpp b/Minecraft.World/EnderCrystal.cpp index 5e7a9edbd..40a82c3b4 100644 --- a/Minecraft.World/EnderCrystal.cpp +++ b/Minecraft.World/EnderCrystal.cpp @@ -93,7 +93,7 @@ bool EnderCrystal::hurt(DamageSource *source, float damage) if (isInvulnerable()) return false; // 4J-PB - if the owner of the source is the enderdragon, then ignore it (where the dragon's fireball hits an endercrystal) - if ( source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_ENDERDRAGON) ) + if ( source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_ENDERDRAGON) ) { return false; } diff --git a/Minecraft.World/EnderDragon.cpp b/Minecraft.World/EnderDragon.cpp index 608f0cd59..9a97b765a 100644 --- a/Minecraft.World/EnderDragon.cpp +++ b/Minecraft.World/EnderDragon.cpp @@ -78,7 +78,7 @@ void EnderDragon::_init() m_nodes = new NodeArray(24); openSet = new BinaryHeap(); - m_currentPath = NULL; + m_currentPath = nullptr; } EnderDragon::EnderDragon(Level *level) : Mob(level) @@ -121,16 +121,16 @@ void EnderDragon::AddParts() EnderDragon::~EnderDragon() { - if(m_nodes->data != NULL) + if(m_nodes->data != nullptr) { for(unsigned int i = 0; i < m_nodes->length; ++i) { - if(m_nodes->data[i]!=NULL) delete m_nodes->data[i]; + if(m_nodes->data[i]!=nullptr) delete m_nodes->data[i]; } delete [] m_nodes->data; } delete openSet; - if( m_currentPath != NULL ) delete m_currentPath; + if( m_currentPath != nullptr ) delete m_currentPath; } void EnderDragon::registerAttributes() @@ -383,7 +383,7 @@ void EnderDragon::aiStep() attackTarget = level->getNearestPlayer( shared_from_this(), SITTING_ATTACK_VIEW_RANGE, SITTING_ATTACK_Y_VIEW_RANGE ); ++m_actionTicks; - if( attackTarget != NULL ) + if( attackTarget != nullptr ) { if(m_actionTicks > SITTING_SCANNING_IDLE_TICKS/4) { @@ -464,7 +464,7 @@ void EnderDragon::aiStep() } else if( getSynchedAction() == e_EnderdragonAction_Sitting_Scanning ) { - if( attackTarget != NULL) + if( attackTarget != nullptr) { Vec3 *aim = Vec3::newTemp((attackTarget->x - x), 0, (attackTarget->z - z))->normalize(); Vec3 *dir = Vec3::newTemp(sin(yRot * PI / 180), 0, -cos(yRot * PI / 180))->normalize(); @@ -519,7 +519,7 @@ void EnderDragon::aiStep() // double xTargetO = xTarget; // double yTargetO = yTarget; // double zTargetO = zTarget; - if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && attackTarget != NULL && m_currentPath != NULL && m_currentPath->isDone()) + if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && attackTarget != nullptr && m_currentPath != nullptr && m_currentPath->isDone()) { xTarget = attackTarget->x; zTarget = attackTarget->z; @@ -715,7 +715,7 @@ void EnderDragon::aiStep() if (!level->isClientSide) { double maxDist = 64.0f; - if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && attackTarget != NULL && attackTarget->distanceToSqr(shared_from_this()) < maxDist * maxDist) + if (getSynchedAction() == e_EnderdragonAction_StrafePlayer && attackTarget != nullptr && attackTarget->distanceToSqr(shared_from_this()) < maxDist * maxDist) { if (this->canSee(attackTarget)) { @@ -747,7 +747,7 @@ void EnderDragon::aiStep() m_fireballCharge = 0; app.DebugPrintf("Finding new target due to having fired a fireball\n"); - if( m_currentPath != NULL ) + if( m_currentPath != nullptr ) { while(!m_currentPath->isDone()) { @@ -778,13 +778,13 @@ void EnderDragon::aiStep() void EnderDragon::checkCrystals() { - if (nearestCrystal != NULL) + if (nearestCrystal != nullptr) { if (nearestCrystal->removed) { if (!level->isClientSide) { - hurt(head, DamageSource::explosion(NULL), 10); + hurt(head, DamageSource::explosion(nullptr), 10); } nearestCrystal = nullptr; @@ -888,13 +888,13 @@ void EnderDragon::findNewTarget() case e_EnderdragonAction_Takeoff: case e_EnderdragonAction_HoldingPattern: { - if(!newTarget && m_currentPath != NULL && m_currentPath->isDone()) + if(!newTarget && m_currentPath != nullptr && m_currentPath->isDone()) { // Distance is 64, which is the radius of the circle int eggHeight = max(level->seaLevel + 5, level->getTopSolidBlock(PODIUM_X_POS,PODIUM_Z_POS)); //level->getHeightmap(4,4); playerNearestToEgg = level->getNearestPlayer(PODIUM_X_POS, eggHeight, PODIUM_Z_POS, 64.0); double dist = 64.0f; - if(playerNearestToEgg != NULL) + if(playerNearestToEgg != nullptr) { dist = playerNearestToEgg->distanceToSqr(PODIUM_X_POS, eggHeight, PODIUM_Z_POS); dist /= (8*8*8); @@ -909,7 +909,7 @@ void EnderDragon::findNewTarget() #endif } // More likely to strafe a player if they are close to the egg, or there are not many crystals remaining - else if( playerNearestToEgg != NULL && (random->nextInt( abs(dist) + 2 ) == 0 || random->nextInt( m_remainingCrystalsCount + 2 ) == 0) ) + else if( playerNearestToEgg != nullptr && (random->nextInt( abs(dist) + 2 ) == 0 || random->nextInt( m_remainingCrystalsCount + 2 ) == 0) ) { setSynchedAction(e_EnderdragonAction_StrafePlayer); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES @@ -921,7 +921,7 @@ void EnderDragon::findNewTarget() break; case e_EnderdragonAction_StrafePlayer: // Always return to the holding pattern after strafing - if(m_currentPath == NULL || (m_currentPath->isDone() && newTarget) ) + if(m_currentPath == nullptr || (m_currentPath->isDone() && newTarget) ) { setSynchedAction(e_EnderdragonAction_HoldingPattern); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES @@ -949,7 +949,7 @@ void EnderDragon::findNewTarget() newTarget = false; //if (random->nextInt(2) == 0 && level->players.size() > 0) - if(getSynchedAction() == e_EnderdragonAction_StrafePlayer && playerNearestToEgg != NULL) + if(getSynchedAction() == e_EnderdragonAction_StrafePlayer && playerNearestToEgg != nullptr) { attackTarget = playerNearestToEgg; strafeAttackTarget(); @@ -957,7 +957,7 @@ void EnderDragon::findNewTarget() else if(getSynchedAction() == e_EnderdragonAction_LandingApproach) { // Generate a new path if we don't currently have one - if( m_currentPath == NULL || m_currentPath->isDone() ) + if( m_currentPath == nullptr || m_currentPath->isDone() ) { int currentNodeIndex = findClosestNode(); @@ -966,7 +966,7 @@ void EnderDragon::findNewTarget() playerNearestToEgg = level->getNearestPlayer(PODIUM_X_POS, eggHeight, PODIUM_Z_POS, 128.0); int targetNodeIndex = 0 ; - if(playerNearestToEgg != NULL) + if(playerNearestToEgg != nullptr) { Vec3 *aim = Vec3::newTemp(playerNearestToEgg->x, 0, playerNearestToEgg->z)->normalize(); //app.DebugPrintf("Final marker node near (%f,%d,%f)\n", -aim->x*40,105,-aim->z*40 ); @@ -978,18 +978,18 @@ void EnderDragon::findNewTarget() } Node finalNode(PODIUM_X_POS, eggHeight, PODIUM_Z_POS); - if(m_currentPath != NULL) delete m_currentPath; + if(m_currentPath != nullptr) delete m_currentPath; m_currentPath = findPath(currentNodeIndex,targetNodeIndex, &finalNode); // Always skip the first node (as that's where we are already) - if(m_currentPath != NULL) m_currentPath->next(); + if(m_currentPath != nullptr) m_currentPath->next(); } m_actionTicks = 0; navigateToNextPathNode(); - if(m_currentPath != NULL && m_currentPath->isDone()) + if(m_currentPath != nullptr && m_currentPath->isDone()) { setSynchedAction(e_EnderdragonAction_Landing); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES @@ -1007,7 +1007,7 @@ void EnderDragon::findNewTarget() { // Default is e_EnderdragonAction_HoldingPattern // Generate a new path if we don't currently have one - if(m_currentPath == NULL || m_currentPath->isDone() ) + if(m_currentPath == nullptr || m_currentPath->isDone() ) { int currentNodeIndex = findClosestNode(); int targetNodeIndex = currentNodeIndex; @@ -1044,11 +1044,11 @@ void EnderDragon::findNewTarget() if(targetNodeIndex < 0) targetNodeIndex += 12; } - if(m_currentPath != NULL) delete m_currentPath; + if(m_currentPath != nullptr) delete m_currentPath; m_currentPath = findPath(currentNodeIndex,targetNodeIndex); // Always skip the first node (as that's where we are already) - if(m_currentPath != NULL) m_currentPath->next(); + if(m_currentPath != nullptr) m_currentPath->next(); } navigateToNextPathNode(); @@ -1125,9 +1125,9 @@ bool EnderDragon::hurt(shared_ptr MultiEntityMobPart, Damage //xTarget = x + ss1 * 5 + (random->nextFloat() - 0.5f) * 2; //yTarget = y + random->nextFloat() * 3 + 1; //zTarget = z - cc1 * 5 + (random->nextFloat() - 0.5f) * 2; - //attackTarget = NULL; + //attackTarget = nullptr; - if ( source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) || source->isExplosion() ) + if ( source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) || source->isExplosion() ) { int healthBefore = getHealth(); reallyHurt(source, damage); @@ -1142,7 +1142,7 @@ bool EnderDragon::hurt(shared_ptr MultiEntityMobPart, Damage if( setSynchedAction(e_EnderdragonAction_LandingApproach) ) { - if( m_currentPath != NULL ) + if( m_currentPath != nullptr ) { while(!m_currentPath->isDone()) { @@ -1227,7 +1227,7 @@ void EnderDragon::tickDeath() if (dragonDeathTime == 200 && !level->isClientSide) { - //level->levelEvent(NULL, LevelEvent::ENDERDRAGON_KILLED, (int) x, (int) y, (int) z, 0); + //level->levelEvent(nullptr, LevelEvent::ENDERDRAGON_KILLED, (int) x, (int) y, (int) z, 0); int xpCount = 2000; while (xpCount > 0) @@ -1477,7 +1477,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource *source) { if(setSynchedAction(e_EnderdragonAction_LandingApproach)) { - if( m_currentPath != NULL ) + if( m_currentPath != nullptr ) { while(!m_currentPath->isDone()) { @@ -1490,7 +1490,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource *source) #endif } } - else if(source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER)) + else if(source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER)) { if(setSynchedAction(e_EnderdragonAction_StrafePlayer)) { @@ -1521,10 +1521,10 @@ void EnderDragon::strafeAttackTarget() Node finalNode(finalXTarget, finalYTarget, finalZTarget); - if(m_currentPath != NULL) delete m_currentPath; + if(m_currentPath != nullptr) delete m_currentPath; m_currentPath = findPath(currentNodeIndex,targetNodeIndex, &finalNode); - if(m_currentPath != NULL) + if(m_currentPath != nullptr) { // Always skip the first node (as that's where we are already) m_currentPath->next(); @@ -1535,7 +1535,7 @@ void EnderDragon::strafeAttackTarget() void EnderDragon::navigateToNextPathNode() { - if(m_currentPath != NULL && !m_currentPath->isDone()) + if(m_currentPath != nullptr && !m_currentPath->isDone()) { Vec3 *curr = m_currentPath->currentPos(); @@ -1563,7 +1563,7 @@ void EnderDragon::navigateToNextPathNode() int EnderDragon::findClosestNode() { // Setup all the nodes on the first time this is called - if(m_nodes->data[0] == NULL) + if(m_nodes->data[0] == nullptr) { // Path nodes for navigation // 0 - 11 are the outer ring at 60 blocks from centre @@ -1650,7 +1650,7 @@ int EnderDragon::findClosestNode(double tX, double tY, double tZ) } for(unsigned int i = startIndex; i < 24; ++i) { - if( m_nodes->data[i] != NULL ) + if( m_nodes->data[i] != nullptr ) { float dist = m_nodes->data[i]->distanceTo(currentPos); if(dist < closestDist) @@ -1665,7 +1665,7 @@ int EnderDragon::findClosestNode(double tX, double tY, double tZ) } // 4J Stu - A* taken from PathFinder and modified -Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = NULL */) +Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = nullptr */) { for(unsigned int i = 0; i < 24; ++i) { @@ -1674,7 +1674,7 @@ Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = N n->f = 0; n->g = 0; n->h = 0; - n->cameFrom = NULL; + n->cameFrom = nullptr; n->heapIdx = -1; } @@ -1704,7 +1704,7 @@ Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = N if (x->equals(to)) { app.DebugPrintf("Found path from %d to %d\n", startIndex, endIndex); - if(finalNode != NULL) + if(finalNode != nullptr) { finalNode->cameFrom = to; to = finalNode; @@ -1756,9 +1756,9 @@ Path *EnderDragon::findPath(int startIndex, int endIndex, Node *finalNode /* = N } } - if (closest == from) return NULL; + if (closest == from) return nullptr; app.DebugPrintf("Failed to find path from %d to %d\n", startIndex, endIndex); - if(finalNode != NULL) + if(finalNode != nullptr) { finalNode->cameFrom = closest; closest = finalNode; @@ -1771,7 +1771,7 @@ Path *EnderDragon::reconstruct_path(Node *from, Node *to) { int count = 1; Node *n = to; - while (n->cameFrom != NULL) + while (n->cameFrom != nullptr) { count++; n = n->cameFrom; @@ -1780,7 +1780,7 @@ Path *EnderDragon::reconstruct_path(Node *from, Node *to) NodeArray nodes = NodeArray(count); n = to; nodes.data[--count] = n; - while (n->cameFrom != NULL) + while (n->cameFrom != nullptr) { n = n->cameFrom; nodes.data[--count] = n; @@ -1923,7 +1923,7 @@ double EnderDragon::getHeadPartYRotDiff(int partIndex, doubleArray bodyPos, doub Vec3 *EnderDragon::getHeadLookVector(float a) { - Vec3 *result = NULL; + Vec3 *result = nullptr; if( getSynchedAction() == e_EnderdragonAction_Landing || getSynchedAction() == e_EnderdragonAction_Takeoff ) { diff --git a/Minecraft.World/EnderDragon.h b/Minecraft.World/EnderDragon.h index a13ecaa26..9f39767eb 100644 --- a/Minecraft.World/EnderDragon.h +++ b/Minecraft.World/EnderDragon.h @@ -163,7 +163,7 @@ class EnderDragon : public Mob, public BossMob, public MultiEntityMob, public En EEnderdragonAction getSynchedAction(); int findClosestNode(double tX, double tY, double tZ); int findClosestNode(); - Path *findPath(int startIndex, int endIndex, Node *finalNode = NULL); + Path *findPath(int startIndex, int endIndex, Node *finalNode = nullptr); Path *reconstruct_path(Node *from, Node *to); void strafeAttackTarget(); diff --git a/Minecraft.World/EnderEyeItem.cpp b/Minecraft.World/EnderEyeItem.cpp index a0c3dad37..80e5fe984 100644 --- a/Minecraft.World/EnderEyeItem.cpp +++ b/Minecraft.World/EnderEyeItem.cpp @@ -136,7 +136,7 @@ bool EnderEyeItem::useOn(shared_ptr instance, shared_ptr p bool EnderEyeItem::TestUse(shared_ptr itemInstance, Level *level, shared_ptr player) { HitResult *hr = getPlayerPOVHitResult(level, player, false); - if (hr != NULL && hr->type == HitResult::TILE) + if (hr != nullptr && hr->type == HitResult::TILE) { int tile = level->getTile(hr->x, hr->y, hr->z); delete hr; @@ -145,7 +145,7 @@ bool EnderEyeItem::TestUse(shared_ptr itemInstance, Level *level, return false; } } - else if( hr != NULL ) + else if( hr != nullptr ) { delete hr; } @@ -177,7 +177,7 @@ bool EnderEyeItem::TestUse(shared_ptr itemInstance, Level *level, } // TilePos *nearestMapFeature = level->findNearestMapFeature(LargeFeature::STRONGHOLD, (int) player->x, (int) player->y, (int) player->z); -// if (nearestMapFeature != NULL) +// if (nearestMapFeature != nullptr) // { // delete nearestMapFeature; // return true; @@ -189,7 +189,7 @@ bool EnderEyeItem::TestUse(shared_ptr itemInstance, Level *level, shared_ptr EnderEyeItem::use(shared_ptr instance, Level *level, shared_ptr player) { HitResult *hr = getPlayerPOVHitResult(level, player, false); - if (hr != NULL && hr->type == HitResult::TILE) + if (hr != nullptr && hr->type == HitResult::TILE) { int tile = level->getTile(hr->x, hr->y, hr->z); delete hr; @@ -198,7 +198,7 @@ shared_ptr EnderEyeItem::use(shared_ptr instance, Le return instance; } } - else if( hr != NULL ) + else if( hr != nullptr ) { delete hr; } diff --git a/Minecraft.World/EnderMan.cpp b/Minecraft.World/EnderMan.cpp index d21f62d76..e12318187 100644 --- a/Minecraft.World/EnderMan.cpp +++ b/Minecraft.World/EnderMan.cpp @@ -96,7 +96,7 @@ shared_ptr EnderMan::findAttackTarget() #endif shared_ptr player = level->getNearestAttackablePlayer(shared_from_this(), 64); - if (player != NULL) + if (player != nullptr) { if (isLookingAtMe(player)) { @@ -120,7 +120,7 @@ shared_ptr EnderMan::findAttackTarget() bool EnderMan::isLookingAtMe(shared_ptr player) { shared_ptr helmet = player->inventory->armor[3]; - if (helmet != NULL && helmet->id == Tile::pumpkin_Id) return false; + if (helmet != nullptr && helmet->id == Tile::pumpkin_Id) return false; Vec3 *look = player->getViewVector(1)->normalize(); Vec3 *dir = Vec3::newTemp(x - player->x, (bb->y0 + bbHeight / 2) - (player->y + player->getHeadHeight()), z - player->z); @@ -143,7 +143,7 @@ void EnderMan::aiStep() AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); speed->removeModifier(SPEED_MODIFIER_ATTACKING); - if (attackTarget != NULL) + if (attackTarget != nullptr) { speed->addModifier(new AttributeModifier(*SPEED_MODIFIER_ATTACKING)); } @@ -226,14 +226,14 @@ void EnderMan::aiStep() } jumping = false; - if (attackTarget != NULL) + if (attackTarget != nullptr) { lookAt(attackTarget, 100, 100); } if (!level->isClientSide && isAlive()) { - if (attackTarget != NULL) + if (attackTarget != nullptr) { if ( attackTarget->instanceof(eTYPE_PLAYER) && isLookingAtMe(dynamic_pointer_cast(attackTarget))) { @@ -408,12 +408,12 @@ bool EnderMan::hurt(DamageSource *source, float damage) if (isInvulnerable()) return false; setCreepy(true); - if ( dynamic_cast(source) != NULL && source->getEntity()->instanceof(eTYPE_PLAYER)) + if ( dynamic_cast(source) != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER)) { aggroedByPlayer = true; } - if (dynamic_cast(source) != NULL) + if (dynamic_cast(source) != nullptr) { aggroedByPlayer = false; for (int i = 0; i < 64; i++) diff --git a/Minecraft.World/EnderpearlItem.cpp b/Minecraft.World/EnderpearlItem.cpp index e1ed693b2..4bf641f71 100644 --- a/Minecraft.World/EnderpearlItem.cpp +++ b/Minecraft.World/EnderpearlItem.cpp @@ -19,7 +19,7 @@ shared_ptr EnderpearlItem::use(shared_ptr instance, { // 4J-PB - Not sure why this was disabled for creative mode, so commenting out //if (player->abilities.instabuild) return instance; - if (player->riding != NULL) return instance; + if (player->riding != nullptr) return instance; if (!player->abilities.instabuild) { instance->count--; diff --git a/Minecraft.World/Enemy.cpp b/Minecraft.World/Enemy.cpp index b9aa3e20a..5dd548466 100644 --- a/Minecraft.World/Enemy.cpp +++ b/Minecraft.World/Enemy.cpp @@ -5,5 +5,5 @@ EntitySelector *Enemy::ENEMY_SELECTOR = new Enemy::EnemyEntitySelector(); bool Enemy::EnemyEntitySelector::matches(shared_ptr entity) const { - return (entity != NULL) && entity->instanceof(eTYPE_ENEMY); + return (entity != nullptr) && entity->instanceof(eTYPE_ENEMY); } \ No newline at end of file diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index 6a8107302..acb439b20 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -41,7 +41,7 @@ int Entity::extraWanderCount = 0; int Entity::getSmallId() { unsigned int *puiUsedFlags = entityIdUsedFlags; - unsigned int *puiRemovedFlags = NULL; + unsigned int *puiRemovedFlags = nullptr; // If we are the server (we should be, if we are allocating small Ids), then check with the server if there are any small Ids which are // still in the ServerPlayer's vectors of entities to be removed - these are used to gather up a set of entities into one network packet @@ -260,7 +260,7 @@ void Entity::_init(bool useSmallId, Level *level) riding = nullptr; forcedLoading = false; - //level = NULL; // Level is assigned to in the original c_tor code + //level = nullptr; // Level is assigned to in the original c_tor code xo = yo = zo = 0.0; x = y = z = 0.0; xd = yd = zd = 0.0; @@ -355,7 +355,7 @@ Entity::Entity(Level *level, bool useSmallId) // 4J - added useSmallId parameter // resetPos(); setPos(0, 0, 0); - if (level != NULL) + if (level != nullptr) { dimension = level->dimension->id; } @@ -398,7 +398,7 @@ return entityId; void Entity::resetPos() { - if (level == NULL) return; + if (level == nullptr) return; shared_ptr sharedThis = shared_from_this(); while (true && y > 0) @@ -510,7 +510,7 @@ void Entity::baseTick() // 4J Stu - Not needed //util.Timer.push("entityBaseTick"); - if (riding != NULL && riding->removed) + if (riding != nullptr && riding->removed) { riding = nullptr; } @@ -533,7 +533,7 @@ void Entity::baseTick() { if (server->isNetherEnabled()) { - if (riding == NULL) + if (riding == nullptr) { if (portalTime++ >= waitTime) { @@ -883,7 +883,7 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J - double zm = z - zo; - if (makeStepSound() && !isPlayerSneaking && riding == NULL) + if (makeStepSound() && !isPlayerSneaking && riding == nullptr) { int xt = Mth::floor(x); int yt = Mth::floor(y - 0.2f - heightOffset); @@ -1029,7 +1029,7 @@ void Entity::checkFallDamage(double ya, bool onGround) AABB *Entity::getCollideBox() { - return NULL; + return nullptr; } void Entity::burn(int dmg) @@ -1047,7 +1047,7 @@ bool Entity::isFireImmune() void Entity::causeFallDamage(float distance) { - if (rider.lock() != NULL) rider.lock()->causeFallDamage(distance); + if (rider.lock() != nullptr) rider.lock()->causeFallDamage(distance); } @@ -1348,7 +1348,7 @@ bool Entity::saveAsMount(CompoundTag *entityTag) bool Entity::save(CompoundTag *entityTag) { wstring id = getEncodeId(); - if (removed || id.empty() || (rider.lock() != NULL) ) + if (removed || id.empty() || (rider.lock() != nullptr) ) { return false; } @@ -1376,7 +1376,7 @@ void Entity::saveWithoutId(CompoundTag *entityTag) addAdditonalSaveData(entityTag); - if (riding != NULL) + if (riding != nullptr) { CompoundTag *ridingTag = new CompoundTag(RIDING_TAG); if (riding->saveAsMount(ridingTag)) @@ -1556,7 +1556,7 @@ bool Entity::interact(shared_ptr player) AABB *Entity::getCollideAgainstBox(shared_ptr entity) { - return NULL; + return nullptr; } void Entity::rideTick() @@ -1569,7 +1569,7 @@ void Entity::rideTick() xd = yd = zd = 0; tick(); - if (riding == NULL) return; + if (riding == nullptr) return; // Sets riders old&new position to it's mount's old&new position (plus the ride y-seperatation). riding->positionRider(); @@ -1605,7 +1605,7 @@ void Entity::rideTick() void Entity::positionRider() { shared_ptr lockedRider = rider.lock(); - if( lockedRider == NULL) + if( lockedRider == nullptr) { return; } @@ -1627,9 +1627,9 @@ void Entity::ride(shared_ptr e) xRideRotA = 0; yRideRotA = 0; - if (e == NULL) + if (e == nullptr) { - if (riding != NULL) + if (riding != nullptr) { // 4J Stu - Position should already be updated before the SetEntityLinkPacket comes in if(!level->isClientSide) moveTo(riding->x, riding->bb->y0 + riding->bbHeight, riding->z, yRot, xRot); @@ -1638,7 +1638,7 @@ void Entity::ride(shared_ptr e) riding = nullptr; return; } - if (riding != NULL) + if (riding != nullptr) { riding->rider = weak_ptr(); } @@ -1677,7 +1677,7 @@ float Entity::getPickRadius() Vec3 *Entity::getLookAngle() { - return NULL; + return nullptr; } void Entity::handleInsidePortal() @@ -1721,7 +1721,7 @@ void Entity::animateHurt() ItemInstanceArray Entity::getEquipmentSlots() // ItemInstance[] { - return ItemInstanceArray(); // Default ctor creates NULL internal array + return ItemInstanceArray(); // Default ctor creates nullptr internal array } // 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game @@ -1736,7 +1736,7 @@ bool Entity::isOnFire() bool Entity::isRiding() { - return riding != NULL; + return riding != nullptr; } bool Entity::isSneaking() @@ -1937,7 +1937,7 @@ wstring Entity::getAName() vector > *Entity::getSubEntities() { - return NULL; + return nullptr; } bool Entity::is(shared_ptr other) @@ -2023,7 +2023,7 @@ void Entity::changeDimension(int i) server->getPlayers()->repositionAcrossDimension(shared_from_this(), lastDimension, oldLevel, newLevel); shared_ptr newEntity = EntityIO::newEntity(EntityIO::getEncodeId(shared_from_this()), newLevel); - if (newEntity != NULL) + if (newEntity != nullptr) { newEntity->restoreFrom(shared_from_this(), true); diff --git a/Minecraft.World/EntityDamageSource.cpp b/Minecraft.World/EntityDamageSource.cpp index 22237bf18..8ff9e328a 100644 --- a/Minecraft.World/EntityDamageSource.cpp +++ b/Minecraft.World/EntityDamageSource.cpp @@ -23,7 +23,7 @@ shared_ptr EntityDamageSource::getEntity() shared_ptr EntityDamageSource::getDeathMessagePacket(shared_ptr player) { - shared_ptr held = (entity != NULL) && entity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast(entity)->getCarriedItem() : nullptr; + shared_ptr held = (entity != nullptr) && entity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast(entity)->getCarriedItem() : nullptr; wstring additional = L""; if (entity->instanceof(eTYPE_SERVERPLAYER)) @@ -39,7 +39,7 @@ shared_ptr EntityDamageSource::getDeathMessagePacket(shared_ptrhasCustomHoverName()) + if ( (held != nullptr) && held->hasCustomHoverName()) { return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId, entity->GetType(), additional, held->getHoverName() ) ); } @@ -51,7 +51,7 @@ shared_ptr EntityDamageSource::getDeathMessagePacket(shared_ptrinstanceof(eTYPE_LIVINGENTITY) && !entity->instanceof(eTYPE_PLAYER); + return (entity != nullptr) && entity->instanceof(eTYPE_LIVINGENTITY) && !entity->instanceof(eTYPE_PLAYER); } // 4J: Copy function diff --git a/Minecraft.World/EntityHorse.cpp b/Minecraft.World/EntityHorse.cpp index 9636c9892..03a70f92b 100644 --- a/Minecraft.World/EntityHorse.cpp +++ b/Minecraft.World/EntityHorse.cpp @@ -259,7 +259,7 @@ int EntityHorse::getArmorType() int EntityHorse::getArmorTypeForItem(shared_ptr armorItem) { - if (armorItem == NULL) + if (armorItem == nullptr) { return ARMOR_NONE; } @@ -350,7 +350,7 @@ bool EntityHorse::hurt(DamageSource *damagesource, float dmg) if (isTamed()) { shared_ptr entity = damagesource->getDirectEntity(); - if (entity != NULL && entity->instanceof(eTYPE_PLAYER)) + if (entity != nullptr && entity->instanceof(eTYPE_PLAYER)) { shared_ptr attacker = dynamic_pointer_cast(entity); attacker->canHarmPlayer(getOwnerName()); @@ -358,7 +358,7 @@ bool EntityHorse::hurt(DamageSource *damagesource, float dmg) } shared_ptr attacker = damagesource->getEntity(); - if (rider.lock() != NULL && (rider.lock() == (attacker) )) + if (rider.lock() != nullptr && (rider.lock() == (attacker) )) { return false; } @@ -375,7 +375,7 @@ int EntityHorse::getArmorValue() bool EntityHorse::isPushable() { - return rider.lock() == NULL; + return rider.lock() == nullptr; } // TODO: [EB]: Explain why this is being done - what side effect does getBiome have? @@ -424,7 +424,7 @@ void EntityHorse::causeFallDamage(float fallDistance) hurt(DamageSource::fall, dmg); - if (rider.lock() != NULL) + if (rider.lock() != nullptr) { rider.lock()->hurt(DamageSource::fall, dmg); } @@ -458,7 +458,7 @@ void EntityHorse::createInventory() shared_ptr old = inventory; inventory = shared_ptr( new AnimalChest(L"HorseChest", getInventorySize()) ); inventory->setCustomName(getAName()); - if (old != NULL) + if (old != nullptr) { old->removeListener(this); @@ -466,7 +466,7 @@ void EntityHorse::createInventory() for (int slot = 0; slot < max; slot++) { shared_ptr item = old->getItem(slot); - if (item != NULL) + if (item != nullptr) { inventory->setItem(slot, item->copy()); } @@ -481,7 +481,7 @@ void EntityHorse::updateEquipment() { if (level && !level->isClientSide) { - setSaddled(inventory->getItem(INV_SLOT_SADDLE) != NULL); + setSaddled(inventory->getItem(INV_SLOT_SADDLE) != nullptr); if (canWearArmor()) { setArmorType(getArmorTypeForItem(inventory->getItem(INV_SLOT_ARMOR))); @@ -666,7 +666,7 @@ void EntityHorse::playStepSound(int xt, int yt, int zt, int t) if (!Tile::tiles[t]->material->isLiquid()) { int type = getType(); - if (rider.lock() != NULL && type != TYPE_DONKEY && type != TYPE_MULE) + if (rider.lock() != nullptr && type != TYPE_DONKEY && type != TYPE_MULE) { gallopSoundCounter++; if (gallopSoundCounter > 5 && gallopSoundCounter % 3 == 0) @@ -795,7 +795,7 @@ intArray EntityHorse::getLayeredTextureLayers() void EntityHorse::openInventory(shared_ptr player) { - if (!level->isClientSide && (rider.lock() == NULL || rider.lock() == player) && isTamed()) + if (!level->isClientSide && (rider.lock() == nullptr || rider.lock() == player) && isTamed()) { inventory->setCustomName(getAName()); player->openHorseInventory(dynamic_pointer_cast(shared_from_this()), inventory); @@ -806,7 +806,7 @@ bool EntityHorse::mobInteract(shared_ptr player) { shared_ptr itemstack = player->inventory->getSelected(); - if (itemstack != NULL && itemstack->id == Item::spawnEgg_Id) + if (itemstack != nullptr && itemstack->id == Item::spawnEgg_Id) { return Animal::mobInteract(player); } @@ -825,13 +825,13 @@ bool EntityHorse::mobInteract(shared_ptr player) return true; } - if (isRidable() && rider.lock() != NULL) + if (isRidable() && rider.lock() != nullptr) { return Animal::mobInteract(player); } // consumables - if (itemstack != NULL) + if (itemstack != nullptr) { bool itemUsed = false; @@ -944,7 +944,7 @@ bool EntityHorse::mobInteract(shared_ptr player) if (!isTamed() && !itemUsed) { - if (itemstack != NULL && itemstack->interactEnemy(player, dynamic_pointer_cast(shared_from_this()))) + if (itemstack != nullptr && itemstack->interactEnemy(player, dynamic_pointer_cast(shared_from_this()))) { return true; } @@ -985,11 +985,11 @@ bool EntityHorse::mobInteract(shared_ptr player) } } - if (isRidable() && rider.lock() == NULL) + if (isRidable() && rider.lock() == nullptr) { // for name tag items and such, we must call the item's interaction // method before riding - if (itemstack != NULL && itemstack->interactEnemy(player, dynamic_pointer_cast(shared_from_this()))) + if (itemstack != nullptr && itemstack->interactEnemy(player, dynamic_pointer_cast(shared_from_this()))) { return true; } @@ -1046,7 +1046,7 @@ bool EntityHorse::canWearBags() bool EntityHorse::isImmobile() { - if (rider.lock() != NULL && isSaddled()) + if (rider.lock() != nullptr && isSaddled()) { return true; } @@ -1127,7 +1127,7 @@ void EntityHorse::aiStep() heal(1); } - if (!isEating() && rider.lock() == NULL && random->nextInt(300) == 0) + if (!isEating() && rider.lock() == nullptr && random->nextInt(300) == 0) { if (level->getTile(Mth::floor(x), Mth::floor(y) - 1, Mth::floor(z)) == Tile::grass_Id) { @@ -1144,7 +1144,7 @@ void EntityHorse::aiStep() if (isBred() && !isAdult() && !isEating()) { shared_ptr mommy = getClosestMommy(shared_from_this(), 16); - if (mommy != NULL && distanceToSqr(mommy) > 4.0) + if (mommy != nullptr && distanceToSqr(mommy) > 4.0) { Path *pathentity = level->findPath(shared_from_this(), mommy, 16.0f, true, false, false, true); setPath(pathentity); @@ -1263,12 +1263,12 @@ void EntityHorse::openMouth() bool EntityHorse::isReadyForParenting() { - return rider.lock() == NULL && riding == NULL && isTamed() && isAdult() && !isSterile() && getHealth() >= getMaxHealth(); + return rider.lock() == nullptr && riding == nullptr && isTamed() && isAdult() && !isSterile() && getHealth() >= getMaxHealth(); } bool EntityHorse::renderName() { - return hasCustomName() && rider.lock() == NULL; + return hasCustomName() && rider.lock() == nullptr; } bool EntityHorse::rideableEntity() @@ -1320,12 +1320,12 @@ void EntityHorse::dropMyStuff() void EntityHorse::dropInventory(shared_ptr entity, shared_ptr animalchest) { - if (animalchest == NULL || level->isClientSide) return; + if (animalchest == nullptr || level->isClientSide) return; for (int i = 0; i < animalchest->getContainerSize(); i++) { shared_ptr itemstack = animalchest->getItem(i); - if (itemstack == NULL) + if (itemstack == nullptr) { continue; } @@ -1349,7 +1349,7 @@ void EntityHorse::travel(float xa, float ya) { // If the entity is not ridden by Player, then execute the normal // Entityliving code - if (rider.lock() == NULL || !isSaddled()) + if (rider.lock() == nullptr || !isSaddled()) { footSize = .5f; flyingSpeed = .02f; @@ -1455,7 +1455,7 @@ void EntityHorse::addAdditonalSaveData(CompoundTag *tag) { shared_ptr stack = inventory->getItem(i); - if (stack != NULL) + if (stack != nullptr) { CompoundTag *compoundTag = new CompoundTag(); @@ -1468,11 +1468,11 @@ void EntityHorse::addAdditonalSaveData(CompoundTag *tag) tag->put(L"Items", listTag); } - if (inventory->getItem(INV_SLOT_ARMOR) != NULL) + if (inventory->getItem(INV_SLOT_ARMOR) != nullptr) { tag->put(L"ArmorItem", inventory->getItem(INV_SLOT_ARMOR)->save(new CompoundTag(L"ArmorItem"))); } - if (inventory->getItem(INV_SLOT_SADDLE) != NULL) + if (inventory->getItem(INV_SLOT_SADDLE) != nullptr) { tag->put(L"SaddleItem", inventory->getItem(INV_SLOT_SADDLE)->save(new CompoundTag(L"SaddleItem"))); } @@ -1498,7 +1498,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag *tag) // 4J: This is for handling old save data, not needed on console /*AttributeInstance *oldSpeedAttribute = getAttributes()->getInstance(SharedMonsterAttributes::MOVEMENT_SPEED); - if (oldSpeedAttribute != NULL) + if (oldSpeedAttribute != nullptr) { getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(oldSpeedAttribute->getBaseValue() * 0.25f); }*/ @@ -1523,7 +1523,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag *tag) if (tag->contains(L"ArmorItem")) { shared_ptr armor = ItemInstance::fromTag(tag->getCompound(L"ArmorItem")); - if (armor != NULL && isHorseArmor(armor->id)) + if (armor != nullptr && isHorseArmor(armor->id)) { inventory->setItem(INV_SLOT_ARMOR, armor); } @@ -1532,7 +1532,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag *tag) if (tag->contains(L"SaddleItem")) { shared_ptr saddleItem = ItemInstance::fromTag(tag->getCompound(L"SaddleItem")); - if (saddleItem != NULL && saddleItem->id == Item::saddle_Id) + if (saddleItem != nullptr && saddleItem->id == Item::saddle_Id) { inventory->setItem(INV_SLOT_SADDLE, saddleItem); } @@ -1637,7 +1637,7 @@ MobGroupData *EntityHorse::finalizeMobSpawn(MobGroupData *groupData, int extraDa int type = 0; int variant = 0; - if ( dynamic_cast(groupData) != NULL ) + if ( dynamic_cast(groupData) != nullptr ) { type = static_cast(groupData)->horseType; variant = static_cast(groupData)->horseVariant & 0xff | (random->nextInt(MARKINGS) << 8); diff --git a/Minecraft.World/EntityIO.cpp b/Minecraft.World/EntityIO.cpp index 086015dc7..9c7c64d40 100644 --- a/Minecraft.World/EntityIO.cpp +++ b/Minecraft.World/EntityIO.cpp @@ -135,8 +135,8 @@ shared_ptr EntityIO::newEntity(const wstring& id, Level *level) if(it != idCreateMap->end() ) { entityCreateFn create = it->second; - if (create != NULL) entity = shared_ptr(create(level)); - if( ( entity != NULL ) && entity->GetType() == eTYPE_ENDERDRAGON ) + if (create != nullptr) entity = shared_ptr(create(level)); + if( ( entity != nullptr ) && entity->GetType() == eTYPE_ENDERDRAGON ) { dynamic_pointer_cast(entity)->AddParts(); // 4J added to finalise creation } @@ -173,14 +173,14 @@ shared_ptr EntityIO::loadStatic(CompoundTag *tag, Level *level) if(it != idCreateMap->end() ) { entityCreateFn create = it->second; - if (create != NULL) entity = shared_ptr(create(level)); - if( ( entity != NULL ) && entity->GetType() == eTYPE_ENDERDRAGON ) + if (create != nullptr) entity = shared_ptr(create(level)); + if( ( entity != nullptr ) && entity->GetType() == eTYPE_ENDERDRAGON ) { dynamic_pointer_cast(entity)->AddParts(); // 4J added to finalise creation } } - if (entity != NULL) + if (entity != nullptr) { entity->load(tag); } @@ -201,14 +201,14 @@ shared_ptr EntityIO::newById(int id, Level *level) if(it != numCreateMap->end() ) { entityCreateFn create = it->second; - if (create != NULL) entity = shared_ptr(create(level)); - if( ( entity != NULL ) && entity->GetType() == eTYPE_ENDERDRAGON ) + if (create != nullptr) entity = shared_ptr(create(level)); + if( ( entity != nullptr ) && entity->GetType() == eTYPE_ENDERDRAGON ) { dynamic_pointer_cast(entity)->AddParts(); // 4J added to finalise creation } } - if (entity != NULL) + if (entity != nullptr) { } else @@ -229,8 +229,8 @@ shared_ptr EntityIO::newByEnumType(eINSTANCEOF eType, Level *level) if(it2 != numCreateMap->end() ) { entityCreateFn create = it2->second; - if (create != NULL) entity = shared_ptr(create(level)); - if( ( entity != NULL ) && entity->GetType() == eTYPE_ENDERDRAGON ) + if (create != nullptr) entity = shared_ptr(create(level)); + if( ( entity != nullptr ) && entity->GetType() == eTYPE_ENDERDRAGON ) { dynamic_pointer_cast(entity)->AddParts(); // 4J added to finalise creation } diff --git a/Minecraft.World/EntityPos.cpp b/Minecraft.World/EntityPos.cpp index 38b505734..02f716edf 100644 --- a/Minecraft.World/EntityPos.cpp +++ b/Minecraft.World/EntityPos.cpp @@ -58,5 +58,5 @@ EntityPos *EntityPos::lerp(shared_ptr e, float f) { return new EntityPos(yrd, xrd); } - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.World/EntitySelector.cpp b/Minecraft.World/EntitySelector.cpp index 36c7bf88b..0f575c73b 100644 --- a/Minecraft.World/EntitySelector.cpp +++ b/Minecraft.World/EntitySelector.cpp @@ -12,7 +12,7 @@ bool AliveEntitySelector::matches(shared_ptr entity) const bool ContainerEntitySelector::matches(shared_ptr entity) const { - return (dynamic_pointer_cast(entity) != NULL) && entity->isAlive(); + return (dynamic_pointer_cast(entity) != nullptr) && entity->isAlive(); } MobCanWearArmourEntitySelector::MobCanWearArmourEntitySelector(shared_ptr item) @@ -27,7 +27,7 @@ bool MobCanWearArmourEntitySelector::matches(shared_ptr entity) const shared_ptr mob = dynamic_pointer_cast(entity); - if (mob->getCarried(Mob::getEquipmentSlotForItem(item)) != NULL) return false; + if (mob->getCarried(Mob::getEquipmentSlotForItem(item)) != nullptr) return false; if ( mob->instanceof(eTYPE_MOB) ) { diff --git a/Minecraft.World/ExperienceOrb.cpp b/Minecraft.World/ExperienceOrb.cpp index 9aad00086..cc4b12bc6 100644 --- a/Minecraft.World/ExperienceOrb.cpp +++ b/Minecraft.World/ExperienceOrb.cpp @@ -99,13 +99,13 @@ void ExperienceOrb::tick() // Usually exp orbs will get created at the same time so smoothen the lagspikes if (followingTime < tickCount - SharedConstants::TICKS_PER_SECOND + (entityId % 100)) { - if (followingPlayer == NULL || followingPlayer->distanceToSqr(shared_from_this()) > maxDist * maxDist) + if (followingPlayer == nullptr || followingPlayer->distanceToSqr(shared_from_this()) > maxDist * maxDist) { followingPlayer = level->getNearestPlayer(shared_from_this(), maxDist); } followingTime = tickCount; } - if (followingPlayer != NULL) + if (followingPlayer != nullptr) { double xdd = (followingPlayer->x - x) / maxDist; double ydd = (followingPlayer->y + followingPlayer->getHeadHeight() - y) / maxDist; diff --git a/Minecraft.World/Explosion.cpp b/Minecraft.World/Explosion.cpp index 3fc085bec..65e719e40 100644 --- a/Minecraft.World/Explosion.cpp +++ b/Minecraft.World/Explosion.cpp @@ -72,10 +72,10 @@ void Explosion::explode() if (t > 0) { Tile *tile = Tile::tiles[t]; - float resistance = source != NULL ? source->getTileExplosionResistance(this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source); + float resistance = source != nullptr ? source->getTileExplosionResistance(this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source); remainingPower -= (resistance + 0.3f) * stepSize; } - if (remainingPower > 0&& (source == NULL || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower))) + if (remainingPower > 0&& (source == nullptr || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower))) { toBlow.insert(TilePos(xt, yt, zt)); } @@ -163,7 +163,7 @@ void Explosion::explode() } -void Explosion::finalizeExplosion(bool generateParticles, vector *toBlowDirect/*=NULL*/) // 4J - added toBlowDirect parameter +void Explosion::finalizeExplosion(bool generateParticles, vector *toBlowDirect/*=nullptr*/) // 4J - added toBlowDirect parameter { level->playSound(x, y, z, eSoundType_RANDOM_EXPLODE, 4, (1 + (level->random->nextFloat() - level->random->nextFloat()) * 0.2f) * 0.7f); if (r < 2 || !destroyBlocks) @@ -262,7 +262,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector *toBlo } PIXEndNamedEvent(); - if( toBlowDirect == NULL ) delete toBlowArray; + if( toBlowDirect == nullptr ) delete toBlowArray; } Explosion::playerVec3Map *Explosion::getHitPlayers() @@ -281,7 +281,7 @@ Vec3 *Explosion::getHitPlayerKnockback( shared_ptr player ) shared_ptr Explosion::getSourceMob() { - if (source == NULL) return nullptr; + if (source == nullptr) return nullptr; if (source->instanceof(eTYPE_PRIMEDTNT)) return dynamic_pointer_cast(source)->getOwner(); if (source->instanceof(eTYPE_LIVINGENTITY)) return dynamic_pointer_cast(source); return nullptr; diff --git a/Minecraft.World/Explosion.h b/Minecraft.World/Explosion.h index 1fe1e57bb..7cefb44b4 100644 --- a/Minecraft.World/Explosion.h +++ b/Minecraft.World/Explosion.h @@ -36,7 +36,7 @@ class Explosion void explode(); public: - void finalizeExplosion(bool generateParticles, vector *toBlowDirect = NULL); // 4J - added toBlow parameter + void finalizeExplosion(bool generateParticles, vector *toBlowDirect = nullptr); // 4J - added toBlow parameter playerVec3Map *getHitPlayers(); Vec3 *getHitPlayerKnockback( shared_ptr player ); shared_ptr getSourceMob(); diff --git a/Minecraft.World/FallingTile.cpp b/Minecraft.World/FallingTile.cpp index aec50d9be..cd951681d 100644 --- a/Minecraft.World/FallingTile.cpp +++ b/Minecraft.World/FallingTile.cpp @@ -24,7 +24,7 @@ void FallingTile::_init() hurtEntities = false; fallDamageMax = 40; fallDamageAmount = 2; - tileData = NULL; + tileData = nullptr; // 4J Added so that client-side falling tiles can fall through blocks // This fixes a bug on the host where the tile update from the server comes in before the client-side falling tile @@ -136,11 +136,11 @@ void FallingTile::tick() { hv->onLand(level, xt, yt, zt, data); } - if (tileData != NULL && Tile::tiles[tile]->isEntityTile()) + if (tileData != nullptr && Tile::tiles[tile]->isEntityTile()) { shared_ptr tileEntity = level->getTileEntity(xt, yt, zt); - if (tileEntity != NULL) + if (tileEntity != nullptr) { CompoundTag *swap = new CompoundTag(); tileEntity->save(swap); @@ -220,7 +220,7 @@ void FallingTile::addAdditonalSaveData(CompoundTag *tag) tag->putBoolean(L"HurtEntities", hurtEntities); tag->putFloat(L"FallHurtAmount", fallDamageAmount); tag->putInt(L"FallHurtMax", fallDamageMax); - if (tileData != NULL) tag->putCompound(L"TileEntityData", tileData); + if (tileData != nullptr) tag->putCompound(L"TileEntityData", tileData); } void FallingTile::readAdditionalSaveData(CompoundTag *tag) diff --git a/Minecraft.World/FarmTile.cpp b/Minecraft.World/FarmTile.cpp index 6cbe40acd..39bf685f5 100644 --- a/Minecraft.World/FarmTile.cpp +++ b/Minecraft.World/FarmTile.cpp @@ -8,8 +8,8 @@ FarmTile::FarmTile(int id) : Tile(id, Material::dirt,isSolidRender()) { - iconWet = NULL; - iconDry = NULL; + iconWet = nullptr; + iconDry = nullptr; setTicking(true); updateDefaultShape(); diff --git a/Minecraft.World/FastNoise.cpp b/Minecraft.World/FastNoise.cpp index 65f8d7ecc..399c427fe 100644 --- a/Minecraft.World/FastNoise.cpp +++ b/Minecraft.World/FastNoise.cpp @@ -34,7 +34,7 @@ FastNoise::~FastNoise() doubleArray FastNoise::getRegion(doubleArray buffer, double x, double y, double z, int xSize, int ySize, int zSize, double xScale, double yScale, double zScale) { - if (buffer.data == NULL) buffer = doubleArray(xSize * ySize * zSize); + if (buffer.data == nullptr) buffer = doubleArray(xSize * ySize * zSize); else for (unsigned int i = 0; i < buffer.length; i++) buffer[i] = 0; diff --git a/Minecraft.World/FenceGateTile.cpp b/Minecraft.World/FenceGateTile.cpp index a8de450e1..bd1326a95 100644 --- a/Minecraft.World/FenceGateTile.cpp +++ b/Minecraft.World/FenceGateTile.cpp @@ -25,7 +25,7 @@ AABB *FenceGateTile::getAABB(Level *level, int x, int y, int z) int data = level->getData(x, y, z); if (isOpen(data)) { - return NULL; + return nullptr; } // 4J Brought forward change from 1.2.3 to fix hit box rotation if (data == Direction::NORTH || data == Direction::SOUTH) @@ -86,7 +86,7 @@ bool FenceGateTile::use(Level *level, int x, int y, int z, shared_ptr pl if (soundOnly) { // 4J - added - just do enough to play the sound - level->levelEvent(player, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0); // 4J - changed event to pass player rather than NULL as the source of the event so we can filter the broadcast properly + level->levelEvent(player, LevelEvent::SOUND_OPEN_DOOR, x, y, z, 0); // 4J - changed event to pass player rather than nullptr as the source of the event so we can filter the broadcast properly return false; } diff --git a/Minecraft.World/FenceTile.cpp b/Minecraft.World/FenceTile.cpp index 39f4aac1c..83c311676 100644 --- a/Minecraft.World/FenceTile.cpp +++ b/Minecraft.World/FenceTile.cpp @@ -122,7 +122,7 @@ bool FenceTile::connectsTo(LevelSource *level, int x, int y, int z) return true; } Tile *tileInstance = Tile::tiles[tile]; - if (tileInstance != NULL) + if (tileInstance != nullptr) { if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped()) { diff --git a/Minecraft.World/File.cpp b/Minecraft.World/File.cpp index ca13f228f..4b36169f5 100644 --- a/Minecraft.World/File.cpp +++ b/Minecraft.World/File.cpp @@ -24,7 +24,7 @@ File::File( const File &parent, const std::wstring& child ) } //Creates a new File instance by converting the given pathname string into an abstract pathname. -File::File( const wstring& pathname ) //: parent( NULL ) +File::File( const wstring& pathname ) //: parent( nullptr ) { // #ifndef _CONTENT_PACKAGE // char buf[256]; @@ -62,7 +62,7 @@ File::File( const wstring& pathname ) //: parent( NULL ) if( path.back().compare( pathRoot ) != 0 ) this->parent = new File( &path ); else - this->parent = NULL; + this->parent = nullptr; } */ } @@ -75,7 +75,7 @@ File::File( const std::wstring& parent, const std::wstring& child ) //: m_abstr //Creates a new File instance by converting the given path vector into an abstract pathname. /* -File::File( vector *path ) : parent( NULL ) +File::File( vector *path ) : parent( nullptr ) { m_abstractPathName = path->back(); path->pop_back(); @@ -86,7 +86,7 @@ if( path->size() > 0 ) if( path->back().compare( pathRoot ) != 0 ) this->parent = new File( path ); else -this->parent = NULL; +this->parent = nullptr; } } */ @@ -120,10 +120,10 @@ bool File::_delete() bool File::mkdir() const { #ifdef _UNICODE - return CreateDirectory( getPath().c_str(), NULL) != 0; + return CreateDirectory( getPath().c_str(), nullptr) != 0; #else - return CreateDirectory( wstringtofilename(getPath()), NULL) != 0; + return CreateDirectory( wstringtofilename(getPath()), nullptr) != 0; #endif } @@ -167,7 +167,7 @@ bool File::mkdirs() const #ifdef _UNICODE if( GetFileAttributes( pathToHere.c_str() ) == -1 ) { - DWORD result = CreateDirectory( pathToHere.c_str(), NULL); + DWORD result = CreateDirectory( pathToHere.c_str(), nullptr); if( result == 0 ) { // Failed to create @@ -177,7 +177,7 @@ bool File::mkdirs() const #else if( GetFileAttributes( wstringtofilename(pathToHere) ) == -1 ) { - DWORD result = CreateDirectory( wstringtofilename(pathToHere), NULL); + DWORD result = CreateDirectory( wstringtofilename(pathToHere), nullptr); if( result == 0 ) { // Failed to create @@ -321,7 +321,7 @@ std::vector *File::listFiles() const else sprintf(filePath,"%s/%s",getUsrDirPath(), lpFileName ); - bool exists = sceFiosDirectoryExistsSync( NULL, filePath ); + bool exists = sceFiosDirectoryExistsSync( nullptr, filePath ); if( !exists ) { app.DebugPrintf("\nsceFiosDirectoryExistsSync - Directory doesn't exist\n"); @@ -334,7 +334,7 @@ std::vector *File::listFiles() const SceFiosDH dh = SCE_FIOS_DH_INVALID; SceFiosBuffer buf; buf.length = 0; - SceFiosOp op = sceFiosDHOpen(NULL, &dh, filePath, buf); + SceFiosOp op = sceFiosDHOpen(nullptr, &dh, filePath, buf); int err = sceFiosOpWait(op); if( err != SCE_FIOS_OK ) @@ -346,24 +346,24 @@ std::vector *File::listFiles() const buf.set(pBuf, (size_t)size); sceFiosOpDelete( op ); - sceFiosDHClose(NULL, dh); + sceFiosDHClose(nullptr, dh); - err = sceFiosDHOpenSync(NULL, &dh, filePath, buf); + err = sceFiosDHOpenSync(nullptr, &dh, filePath, buf); if( err != SCE_FIOS_OK ) { app.DebugPrintf("\nsceFiosDHOpenSync = 0x%x\n",err); } SceFiosDirEntry entry; ZeroMemory(&entry, sizeof(SceFiosDirEntry)); - err = sceFiosDHReadSync(NULL, dh, &entry); + err = sceFiosDHReadSync(nullptr, dh, &entry); while( err == SCE_FIOS_OK) { vOutput->push_back( new File( *this, filenametowstring( entry.fullPath + entry.offsetToName ) ) ); ZeroMemory(&entry, sizeof(SceFiosDirEntry)); - err = sceFiosDHReadSync(NULL, dh, &entry); + err = sceFiosDHReadSync(nullptr, dh, &entry); }; - sceFiosDHClose(NULL, dh); + sceFiosDHClose(nullptr, dh); delete pBuf; #else @@ -418,7 +418,7 @@ std::vector *File::listFiles(FileFilter *filter) const { // TODO 4J Stu - Also need to check for I/O errors? if( !isDirectory() ) - return NULL; + return nullptr; std::vector *vOutput = new std::vector(); @@ -576,7 +576,7 @@ int64_t File::length() // check if the file exists first SceFiosStat statData; - if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK) + if(sceFiosStatSync(nullptr, filePath, &statData) != SCE_FIOS_OK) { return 0; } @@ -660,7 +660,7 @@ const std::wstring File::getPath() const { /* wstring path; - if ( parent != NULL) + if ( parent != nullptr) path = parent->getPath(); else path = wstring(pathRoot); @@ -687,7 +687,7 @@ int File::hash_fnct(const File &k) { int hashCode = 0; - //if (k->parent != NULL) + //if (k->parent != nullptr) // hashCode = hash_fnct(k->getParent()); wchar_t *ref = (wchar_t *) k.m_abstractPathName.c_str(); diff --git a/Minecraft.World/FileHeader.cpp b/Minecraft.World/FileHeader.cpp index 01687628f..a7bdbc904 100644 --- a/Minecraft.World/FileHeader.cpp +++ b/Minecraft.World/FileHeader.cpp @@ -5,7 +5,7 @@ FileHeader::FileHeader() { - lastFile = NULL; + lastFile = nullptr; m_saveVersion = 0; // New saves should have an original version set to the latest version. This will be overridden when we load a save @@ -49,7 +49,7 @@ FileEntry *FileHeader::AddFile( const wstring &name, unsigned int length /* = 0 void FileHeader::RemoveFile( FileEntry *file ) { - if( file == NULL ) return; + if( file == nullptr ) return; AdjustStartOffsets(file, file->getFileSize(), true); @@ -364,13 +364,13 @@ bool FileHeader::fileExists( const wstring &name ) vector *FileHeader::getFilesWithPrefix(const wstring &prefix) { - vector *files = NULL; + vector *files = nullptr; for( unsigned int i = 0; i < fileTable.size(); ++i ) { if( wcsncmp( fileTable[i]->data.filename, prefix.c_str(), prefix.size() ) == 0 ) { - if( files == NULL ) + if( files == nullptr ) { files = new vector(); } @@ -479,7 +479,7 @@ wstring FileHeader::getPlayerDataFilenameForSave(const PlayerUID& pUID) vector *FileHeader::getValidPlayerDatFiles() { - vector *files = NULL; + vector *files = nullptr; // find filenames that match this pattern // P_5e7ff8372ea9_00000004_Mark_4J @@ -509,7 +509,7 @@ vector *FileHeader::getValidPlayerDatFiles() continue; // if we get here, it must be a valid filename - if( files == NULL ) + if( files == nullptr ) { files = new vector(); } @@ -524,21 +524,21 @@ vector *FileHeader::getValidPlayerDatFiles() vector *FileHeader::getDatFilesWithOnlineID(const PlayerUID& pUID) { if(pUID.isSignedIntoPSN() == false) - return NULL; + return nullptr; vector* datFiles = getValidPlayerDatFiles(); - if(datFiles == NULL) - return NULL; + if(datFiles == nullptr) + return nullptr; // we're looking for the online name from the pUID in these types of filenames - // P_5e7ff8372ea9_00000004_Mark_4J wchar_t onlineIDW[64]; mbstowcs(onlineIDW, pUID.getOnlineID(), 64); - vector *files = NULL; + vector *files = nullptr; int onlineIDSize = wcslen(onlineIDW); if(onlineIDSize == 0) - return NULL; + return nullptr; wcscat(onlineIDW, L".dat"); @@ -564,7 +564,7 @@ vector *FileHeader::getDatFilesWithOnlineID(const PlayerUID& pUID) { if(wcsncmp(&filenameOnly[onlineIDStart], onlineIDW, onlineIDSize) == 0) { - if( files == NULL ) + if( files == nullptr ) { files = new vector(); } @@ -582,8 +582,8 @@ vector *FileHeader::getDatFilesWithMacAndUserID(const PlayerUID& pU { vector* datFiles = getValidPlayerDatFiles(); - if(datFiles == NULL) - return NULL; + if(datFiles == nullptr) + return nullptr; // we're looking for the mac address and userIDfrom the pUID in these types of filenames - // P_5e7ff8372ea9_00000004_Mark_4J @@ -592,7 +592,7 @@ vector *FileHeader::getDatFilesWithMacAndUserID(const PlayerUID& pU const wchar_t* pMacStr = macStr.c_str(); const wchar_t* pUserStr = userStr.c_str(); - vector *files = NULL; + vector *files = nullptr; static const int macAddrStart = 2; // 2 characters into the filename static const int userIDStart = 15; // 15 characters into the filename @@ -609,7 +609,7 @@ vector *FileHeader::getDatFilesWithMacAndUserID(const PlayerUID& pU // check the userID matches if(wcsncmp(&filenameOnly[userIDStart], pUserStr, userStr.size()) == 0) { - if( files == NULL ) + if( files == nullptr ) { files = new vector(); } @@ -627,12 +627,12 @@ vector *FileHeader::getDatFilesWithPrimaryUser() { vector* datFiles = getValidPlayerDatFiles(); - if(datFiles == NULL) - return NULL; + if(datFiles == nullptr) + return nullptr; // we're just looking for filenames starting with "P_" in these types of filenames - // P_5e7ff8372ea9_00000004_Mark_4J - vector *files = NULL; + vector *files = nullptr; char tempStr[128]; for( unsigned int i = 0; i < datFiles->size(); ++i ) @@ -644,7 +644,7 @@ vector *FileHeader::getDatFilesWithPrimaryUser() // check for "P_" prefix if(wcsncmp(&filenameOnly[0], L"P_", 2) == 0) { - if( files == NULL ) + if( files == nullptr ) { files = new vector(); } diff --git a/Minecraft.World/FileInputStream.cpp b/Minecraft.World/FileInputStream.cpp index 7c0e844f0..a7714ae26 100644 --- a/Minecraft.World/FileInputStream.cpp +++ b/Minecraft.World/FileInputStream.cpp @@ -24,20 +24,20 @@ FileInputStream::FileInputStream(const File &file) file.getPath().c_str(), // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #else m_fileHandle = CreateFile( pchFilename, // file name GENERIC_READ, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported + nullptr // Unsupported ); #endif @@ -68,7 +68,7 @@ int FileInputStream::read() &byteRead, // data buffer 1, // number of bytes to read &numberOfBytesRead, // number of bytes read - NULL // overlapped buffer + nullptr // overlapped buffer ); if( bSuccess==FALSE ) @@ -100,7 +100,7 @@ int FileInputStream::read(byteArray b) b.data, // data buffer b.length, // number of bytes to read &numberOfBytesRead, // number of bytes read - NULL // overlapped buffer + nullptr // overlapped buffer ); if( bSuccess==FALSE ) @@ -138,7 +138,7 @@ int FileInputStream::read(byteArray b, unsigned int offset, unsigned int length) &b[offset], // data buffer length, // number of bytes to read &numberOfBytesRead, // number of bytes read - NULL // overlapped buffer + nullptr // overlapped buffer ); if( bSuccess==FALSE ) diff --git a/Minecraft.World/FileOutputStream.cpp b/Minecraft.World/FileOutputStream.cpp index e554ccf59..58a0ecd96 100644 --- a/Minecraft.World/FileOutputStream.cpp +++ b/Minecraft.World/FileOutputStream.cpp @@ -24,20 +24,20 @@ FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( INVALID_HAN file.getPath().c_str() , // file name GENERIC_WRITE, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_ALWAYS , // how to create FILE_ATTRIBUTE_NORMAL , // file attributes - NULL // Unsupported + nullptr // Unsupported ); #else m_fileHandle = CreateFile( wstringtofilename(file.getPath()) , // file name GENERIC_WRITE, // access mode 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused + nullptr, // Unused OPEN_ALWAYS , // how to create FILE_ATTRIBUTE_NORMAL , // file attributes - NULL // Unsupported + nullptr // Unsupported ); #endif @@ -68,7 +68,7 @@ void FileOutputStream::write(unsigned int b) &value, // data buffer 1, // number of bytes to write &numberOfBytesWritten, // number of bytes written - NULL // overlapped buffer + nullptr // overlapped buffer ); if( result == 0 ) @@ -93,7 +93,7 @@ void FileOutputStream::write(byteArray b) &b.data, // data buffer b.length, // number of bytes to write &numberOfBytesWritten, // number of bytes written - NULL // overlapped buffer + nullptr // overlapped buffer ); if( result == 0 ) @@ -123,7 +123,7 @@ void FileOutputStream::write(byteArray b, unsigned int offset, unsigned int leng &b[offset], // data buffer length, // number of bytes to write &numberOfBytesWritten, // number of bytes written - NULL // overlapped buffer + nullptr // overlapped buffer ); if( result == 0 ) diff --git a/Minecraft.World/FireChargeItem.cpp b/Minecraft.World/FireChargeItem.cpp index 7a865ff5e..d3499cdc6 100644 --- a/Minecraft.World/FireChargeItem.cpp +++ b/Minecraft.World/FireChargeItem.cpp @@ -10,7 +10,7 @@ FireChargeItem::FireChargeItem(int id) : Item(id) { - m_dragonFireballIcon = NULL; + m_dragonFireballIcon = nullptr; } bool FireChargeItem::useOn(shared_ptr instance, shared_ptr player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) diff --git a/Minecraft.World/FireTile.cpp b/Minecraft.World/FireTile.cpp index dfb4b961c..49f859b51 100644 --- a/Minecraft.World/FireTile.cpp +++ b/Minecraft.World/FireTile.cpp @@ -24,7 +24,7 @@ FireTile::FireTile(int id) : Tile(id, Material::fire,isSolidRender()) burnOdds = new int[256]; memset( burnOdds,0,sizeof(int)*256); - icons = NULL; + icons = nullptr; setTicking(true); } @@ -64,7 +64,7 @@ void FireTile::setFlammable(int id, int flame, int burn) AABB *FireTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool FireTile::blocksLight() diff --git a/Minecraft.World/Fireball.cpp b/Minecraft.World/Fireball.cpp index 2bd740ad3..b520f436e 100644 --- a/Minecraft.World/Fireball.cpp +++ b/Minecraft.World/Fireball.cpp @@ -127,10 +127,10 @@ Fireball::Fireball(Level *level, shared_ptr mob, double xa, double void Fireball::tick() { // 4J-PB - Moved forward from 1.2.3 - //if (!level->isClientSide && (owner == NULL || owner->removed)) + //if (!level->isClientSide && (owner == nullptr || owner->removed)) if (!level->isClientSide) { - if((owner != NULL && owner->removed) || !level->hasChunkAt(static_cast(x), static_cast(y), static_cast(z))) + if((owner != nullptr && owner->removed) || !level->hasChunkAt(static_cast(x), static_cast(y), static_cast(z))) { app.DebugPrintf("Fireball removed - owner is null or removed is true for owner\n"); remove(); @@ -193,7 +193,7 @@ void Fireball::tick() from = Vec3::newTemp(x, y, z); to = Vec3::newTemp(x + xd, y + yd, z + zd); - if (res != NULL) + if (res != nullptr) { to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z); } @@ -207,7 +207,7 @@ void Fireball::tick() float rr = 0.3f; AABB *bb = e->bb->grow(rr, rr, rr); HitResult *p = bb->clip(from, to); - if (p != NULL) + if (p != nullptr) { double dd = from->distanceTo(p->pos); if (dd < nearest || nearest == 0) @@ -220,14 +220,14 @@ void Fireball::tick() } - if (hitEntity != NULL) + if (hitEntity != nullptr) { delete res; res = new HitResult(hitEntity); } MemSect(0); - if (res != NULL) + if (res != nullptr) { onHit(res); } @@ -343,10 +343,10 @@ bool Fireball::hurt(DamageSource *source, float damage) if (isInvulnerable()) return false; markHurt(); - if (source->getEntity() != NULL) + if (source->getEntity() != nullptr) { Vec3 *lookAngle = source->getEntity()->getLookAngle(); - if (lookAngle != NULL) + if (lookAngle != nullptr) { xd = lookAngle->x; yd = lookAngle->y; diff --git a/Minecraft.World/FireworksChargeItem.cpp b/Minecraft.World/FireworksChargeItem.cpp index d027c5542..8b12c98c4 100644 --- a/Minecraft.World/FireworksChargeItem.cpp +++ b/Minecraft.World/FireworksChargeItem.cpp @@ -21,7 +21,7 @@ int FireworksChargeItem::getColor(shared_ptr item, int spriteLayer if (spriteLayer == 1) { Tag *colorTag = getExplosionTagField(item, FireworksItem::TAG_E_COLORS); - if (colorTag != NULL) + if (colorTag != nullptr) { IntArrayTag *colors = static_cast(colorTag); if (colors->data.length == 1) @@ -58,12 +58,12 @@ Tag *FireworksChargeItem::getExplosionTagField(shared_ptr instance if (instance->hasTag()) { CompoundTag *explosion = instance->getTag()->getCompound(FireworksItem::TAG_EXPLOSION); - if (explosion != NULL) + if (explosion != nullptr) { return explosion->get(field); } } - return NULL; + return nullptr; } void FireworksChargeItem::appendHoverText(shared_ptr itemInstance, shared_ptr player, vector *lines, bool advanced) @@ -71,7 +71,7 @@ void FireworksChargeItem::appendHoverText(shared_ptr itemInstance, if (itemInstance->hasTag()) { CompoundTag *explosion = itemInstance->getTag()->getCompound(FireworksItem::TAG_EXPLOSION); - if (explosion != NULL) + if (explosion != nullptr) { appendHoverText(explosion, lines); } diff --git a/Minecraft.World/FireworksItem.cpp b/Minecraft.World/FireworksItem.cpp index f81b45889..c872bc407 100644 --- a/Minecraft.World/FireworksItem.cpp +++ b/Minecraft.World/FireworksItem.cpp @@ -46,7 +46,7 @@ void FireworksItem::appendHoverText(shared_ptr itemInstance, share return; } CompoundTag *fireTag = itemInstance->getTag()->getCompound(TAG_FIREWORKS); - if (fireTag == NULL) + if (fireTag == nullptr) { return; } @@ -56,7 +56,7 @@ void FireworksItem::appendHoverText(shared_ptr itemInstance, share } ListTag *explosions = (ListTag *) fireTag->getList(TAG_EXPLOSIONS); - if (explosions != NULL && explosions->size() > 0) + if (explosions != nullptr && explosions->size() > 0) { for (int i = 0; i < explosions->size(); i++) diff --git a/Minecraft.World/FireworksMenu.cpp b/Minecraft.World/FireworksMenu.cpp index 68c9e0f2b..92474e2de 100644 --- a/Minecraft.World/FireworksMenu.cpp +++ b/Minecraft.World/FireworksMenu.cpp @@ -61,7 +61,7 @@ void FireworksMenu::removed(shared_ptr player) for (int i = 0; i < 9; i++) { shared_ptr item = craftSlots->removeItemNoUpdate(i); - if (item != NULL) + if (item != nullptr) { player->drop(item); } @@ -77,7 +77,7 @@ shared_ptr FireworksMenu::quickMoveStack(shared_ptr player { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -145,6 +145,6 @@ bool FireworksMenu::canTakeItemForPickAll(shared_ptr carried, Slot bool FireworksMenu::isValidIngredient(shared_ptr item, int slotId) { - if(item == NULL || slotId == RESULT_SLOT) return true; + if(item == nullptr || slotId == RESULT_SLOT) return true; return FireworksRecipe::isValidIngredient(item, m_canMakeFireworks, m_canMakeCharge, m_canMakeFade); } \ No newline at end of file diff --git a/Minecraft.World/FireworksRecipe.cpp b/Minecraft.World/FireworksRecipe.cpp index 7bf631049..6c6d3d259 100644 --- a/Minecraft.World/FireworksRecipe.cpp +++ b/Minecraft.World/FireworksRecipe.cpp @@ -3,7 +3,7 @@ #include "FireworksRecipe.h" DWORD FireworksRecipe::tlsIdx = 0; -FireworksRecipe::ThreadStorage *FireworksRecipe::tlsDefault = NULL; +FireworksRecipe::ThreadStorage *FireworksRecipe::tlsDefault = nullptr; FireworksRecipe::ThreadStorage::ThreadStorage() { @@ -13,7 +13,7 @@ FireworksRecipe::ThreadStorage::ThreadStorage() void FireworksRecipe::CreateNewThreadStorage() { ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == NULL ) + if(tlsDefault == nullptr ) { tlsIdx = TlsAlloc(); tlsDefault = tls; @@ -59,7 +59,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; if (item->id == Item::gunpowder_Id) { @@ -134,7 +134,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { shared_ptr item = craftSlots->getItem(slot); - if (item == NULL || item->id != Item::fireworksCharge_Id) continue; + if (item == nullptr || item->id != Item::fireworksCharge_Id) continue; if (item->hasTag() && item->getTag()->contains(FireworksItem::TAG_EXPLOSION)) { @@ -165,7 +165,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; if (item->id == Item::dye_powder_Id) { @@ -195,10 +195,10 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l } else if (item->id == Item::skull_Id) { - type = FireworksItem::TYPE_CREEPER; + type = FireworksItem::TYPE_CREEPER; } } - intArray colorArray(colors.size()); + intArray colorArray(static_cast(colors.size())); for (int i = 0; i < colorArray.length; i++) { colorArray[i] = colors.at(i); @@ -221,7 +221,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; if (item->id == Item::dye_powder_Id) { @@ -230,18 +230,18 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l else if (item->id == Item::fireworksCharge_Id) { resultItem = item->copy(); - resultItem->count = 1; + resultItem->count = 1; } } - intArray colorArray(colors.size()); + intArray colorArray(static_cast(colors.size())); for (int i = 0; i < colorArray.length; i++) { colorArray[i] = colors.at(i); } - if (resultItem != NULL && resultItem->hasTag()) + if (resultItem != nullptr && resultItem->hasTag()) { CompoundTag *compound = resultItem->getTag()->getCompound(FireworksItem::TAG_EXPLOSION); - if (compound == NULL) + if (compound == nullptr) { delete colorArray.data; @@ -301,7 +301,7 @@ void FireworksRecipe::updatePossibleRecipes(shared_ptr craftS for (int slot = 0; slot < craftSlots->getContainerSize(); slot++) { shared_ptr item = craftSlots->getItem(slot); - if (item == NULL) continue; + if (item == nullptr) continue; if (item->id == Item::gunpowder_Id) { diff --git a/Minecraft.World/FireworksRocketEntity.cpp b/Minecraft.World/FireworksRocketEntity.cpp index bd7410b29..d3897e4f0 100644 --- a/Minecraft.World/FireworksRocketEntity.cpp +++ b/Minecraft.World/FireworksRocketEntity.cpp @@ -15,7 +15,7 @@ FireworksRocketEntity::FireworksRocketEntity(Level *level) : Entity(level) void FireworksRocketEntity::defineSynchedData() { - entityData->defineNULL(DATA_ID_FIREWORKS_ITEM, NULL); + entityData->defineNULL(DATA_ID_FIREWORKS_ITEM, nullptr); } bool FireworksRocketEntity::shouldRenderAtSqrDistance(double distance) @@ -35,13 +35,13 @@ FireworksRocketEntity::FireworksRocketEntity(Level *level, double x, double y, d heightOffset = 0; int flightCount = 1; - if (sourceItem != NULL && sourceItem->hasTag()) + if (sourceItem != nullptr && sourceItem->hasTag()) { entityData->set(DATA_ID_FIREWORKS_ITEM, sourceItem); CompoundTag *tag = sourceItem->getTag(); CompoundTag *compound = tag->getCompound(FireworksItem::TAG_FIREWORKS); - if (compound != NULL) + if (compound != nullptr) { flightCount += compound->getByte(FireworksItem::TAG_FLIGHT); } @@ -120,8 +120,8 @@ void FireworksRocketEntity::handleEntityEvent(byte eventId) if (eventId == EntityEvent::FIREWORKS_EXPLODE && level->isClientSide) { shared_ptr sourceItem = entityData->getItemInstance(DATA_ID_FIREWORKS_ITEM); - CompoundTag *tag = NULL; - if (sourceItem != NULL && sourceItem->hasTag()) + CompoundTag *tag = nullptr; + if (sourceItem != nullptr && sourceItem->hasTag()) { tag = sourceItem->getTag()->getCompound(FireworksItem::TAG_FIREWORKS); } @@ -135,7 +135,7 @@ void FireworksRocketEntity::addAdditonalSaveData(CompoundTag *tag) tag->putInt(L"Life", life); tag->putInt(L"LifeTime", lifetime); shared_ptr itemInstance = entityData->getItemInstance(DATA_ID_FIREWORKS_ITEM); - if (itemInstance != NULL) + if (itemInstance != nullptr) { CompoundTag *itemTag = new CompoundTag(); itemInstance->save(itemTag); @@ -150,10 +150,10 @@ void FireworksRocketEntity::readAdditionalSaveData(CompoundTag *tag) lifetime = tag->getInt(L"LifeTime"); CompoundTag *itemTag = tag->getCompound(L"FireworksItem"); - if (itemTag != NULL) + if (itemTag != nullptr) { shared_ptr fromTag = ItemInstance::fromTag(itemTag); - if (fromTag != NULL) + if (fromTag != nullptr) { entityData->set(DATA_ID_FIREWORKS_ITEM, fromTag); } diff --git a/Minecraft.World/FishingHook.cpp b/Minecraft.World/FishingHook.cpp index 51f37c97d..e567e87b9 100644 --- a/Minecraft.World/FishingHook.cpp +++ b/Minecraft.World/FishingHook.cpp @@ -173,14 +173,14 @@ void FishingHook::tick() if (!level->isClientSide) { shared_ptr selectedItem = owner->getSelectedItem(); - if (owner->removed || !owner->isAlive() || selectedItem == NULL || selectedItem->getItem() != Item::fishingRod || distanceToSqr(owner) > 32 * 32) + if (owner->removed || !owner->isAlive() || selectedItem == nullptr || selectedItem->getItem() != Item::fishingRod || distanceToSqr(owner) > 32 * 32) { remove(); owner->fishing = nullptr; return; } - if (hookedIn != NULL) + if (hookedIn != nullptr) { if (hookedIn->removed) hookedIn = nullptr; else @@ -226,7 +226,7 @@ void FishingHook::tick() from = Vec3::newTemp(x, y, z); to = Vec3::newTemp(x + xd, y + yd, z + zd); - if (res != NULL) + if (res != nullptr) { to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z); } @@ -241,7 +241,7 @@ void FishingHook::tick() float rr = 0.3f; AABB *bb = e->bb->grow(rr, rr, rr); HitResult *p = bb->clip(from, to); - if (p != NULL) + if (p != nullptr) { double dd = from->distanceTo(p->pos); if (dd < nearest || nearest == 0) @@ -253,15 +253,15 @@ void FishingHook::tick() } } - if (hitEntity != NULL) + if (hitEntity != nullptr) { delete res; res = new HitResult(hitEntity); } - if (res != NULL) + if (res != nullptr) { - if (res->entity != NULL) + if (res->entity != nullptr) { // 4J Stu Move fix for : fix for #48587 - CRASH: Code: Gameplay: Hitting another player with the fishing bobber crashes the game. [Fishing pole, line] // Incorrect dynamic_pointer_cast used around the shared_from_this() @@ -405,7 +405,7 @@ int FishingHook::retrieve() if (level->isClientSide) return 0; int dmg = 0; - if (hookedIn != NULL) + if (hookedIn != nullptr) { double xa = owner->x - x; double ya = owner->y - y; @@ -445,5 +445,5 @@ int FishingHook::retrieve() void FishingHook::remove() { Entity::remove(); - if (owner != NULL) owner->fishing = nullptr; + if (owner != nullptr) owner->fishing = nullptr; } \ No newline at end of file diff --git a/Minecraft.World/FishingRodItem.cpp b/Minecraft.World/FishingRodItem.cpp index 883eb2ded..70becf39e 100644 --- a/Minecraft.World/FishingRodItem.cpp +++ b/Minecraft.World/FishingRodItem.cpp @@ -17,7 +17,7 @@ FishingRodItem::FishingRodItem(int id) : Item(id) { setMaxDamage(64); setMaxStackSize(1); - emptyIcon = NULL; + emptyIcon = nullptr; } bool FishingRodItem::isHandEquipped() @@ -32,7 +32,7 @@ bool FishingRodItem::isMirroredArt() shared_ptr FishingRodItem::use(shared_ptr instance, Level *level, shared_ptr player) { - if (player->fishing != NULL) + if (player->fishing != nullptr) { int dmg = player->fishing->retrieve(); instance->hurtAndBreak(dmg, player); diff --git a/Minecraft.World/FixedBiomeSource.cpp b/Minecraft.World/FixedBiomeSource.cpp index 257ec3db9..2657bdb44 100644 --- a/Minecraft.World/FixedBiomeSource.cpp +++ b/Minecraft.World/FixedBiomeSource.cpp @@ -26,9 +26,9 @@ float FixedBiomeSource::getTemperature(int x, int z) void FixedBiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z, int w, int h) const { - if (temperatures.data == NULL || temperatures.length < w * h) + if (temperatures.data == nullptr || temperatures.length < w * h) { - if(temperatures.data != NULL) delete [] temperatures.data; + if(temperatures.data != nullptr) delete [] temperatures.data; temperatures = floatArray(w * h); } @@ -52,9 +52,9 @@ void FixedBiomeSource::getTemperatureBlock(doubleArray& temperatures, int x, int void FixedBiomeSource::getDownfallBlock(floatArray &downfalls, int x, int z, int w, int h) const { - if (downfalls.data == NULL || downfalls.length < w * h) + if (downfalls.data == nullptr || downfalls.length < w * h) { - if(downfalls.data != NULL) delete [] downfalls.data; + if(downfalls.data != nullptr) delete [] downfalls.data; downfalls = floatArray(w * h); } Arrays::fill(downfalls, 0, w * h, downfall); @@ -74,9 +74,9 @@ float FixedBiomeSource::getDownfall(int x, int z) const void FixedBiomeSource::getDownfallBlock(doubleArray downfalls, int x, int z, int w, int h) { - if (downfalls.data == NULL || downfalls.length < w * h) + if (downfalls.data == nullptr || downfalls.length < w * h) { - if(downfalls.data != NULL) delete [] downfalls.data; + if(downfalls.data != nullptr) delete [] downfalls.data; downfalls = doubleArray(w * h); } Arrays::fill(downfalls, 0, w * h, (double) downfall); @@ -129,7 +129,7 @@ TilePos *FixedBiomeSource::findBiome(int x, int z, int r, Biome *toFind, Random return new TilePos(x - r + random->nextInt(r * 2 + 1), 0, z - r + random->nextInt(r * 2 + 1)); } - return NULL; + return nullptr; } TilePos *FixedBiomeSource::findBiome(int x, int z, int r, vector allowed, Random *random) @@ -139,7 +139,7 @@ TilePos *FixedBiomeSource::findBiome(int x, int z, int r, vector allowe return new TilePos(x - r + random->nextInt(r * 2 + 1), 0, z - r + random->nextInt(r * 2 + 1)); } - return NULL; + return nullptr; } bool FixedBiomeSource::containsOnly(int x, int z, int r, Biome *allowed) diff --git a/Minecraft.World/FlatGeneratorInfo.cpp b/Minecraft.World/FlatGeneratorInfo.cpp index dfd4cb667..3dd54453d 100644 --- a/Minecraft.World/FlatGeneratorInfo.cpp +++ b/Minecraft.World/FlatGeneratorInfo.cpp @@ -114,7 +114,7 @@ wstring FlatGeneratorInfo::toString() FlatLayerInfo *FlatGeneratorInfo::getLayerFromString(const wstring &input, int yOffset) { - return NULL; + return nullptr; #if 0 std::vector parts = stringSplit(input, L'x'); @@ -135,7 +135,7 @@ FlatLayerInfo *FlatGeneratorInfo::getLayerFromString(const wstring &input, int y id = _fromString(parts[0]); if (parts.size() > 1) data = _from_String(parts[1]); - if (Tile::tiles[id] == NULL) + if (Tile::tiles[id] == nullptr) { id = 0; data = 0; @@ -151,7 +151,7 @@ FlatLayerInfo *FlatGeneratorInfo::getLayerFromString(const wstring &input, int y vector *FlatGeneratorInfo::getLayersFromString(const wstring &input) { - if (input.empty()) return NULL; + if (input.empty()) return nullptr; vector *result = new vector(); std::vector depths = stringSplit(input, L','); @@ -161,7 +161,7 @@ vector *FlatGeneratorInfo::getLayersFromString(const wstring &i for(auto& depth : depths) { FlatLayerInfo *layer = getLayerFromString(depth, yOffset); - if (layer == NULL) return NULL; + if (layer == nullptr) return nullptr; result->push_back(layer); yOffset += layer->getHeight(); } @@ -184,7 +184,7 @@ FlatGeneratorInfo *FlatGeneratorInfo::fromValue(const wstring &input) int index = parts.size() == 1 ? 0 : 1; vector *layers = getLayersFromString(parts[index++]); - if (layers == NULL || layers->isEmpty()) + if (layers == nullptr || layers->isEmpty()) { delete layers; return getDefault(); diff --git a/Minecraft.World/FlatLevelSource.cpp b/Minecraft.World/FlatLevelSource.cpp index 4713f43ef..ebc1d36c5 100644 --- a/Minecraft.World/FlatLevelSource.cpp +++ b/Minecraft.World/FlatLevelSource.cpp @@ -140,16 +140,16 @@ wstring FlatLevelSource::gatherStats() vector *FlatLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { Biome *biome = level->getBiome(x, z); - if (biome == NULL) + if (biome == nullptr) { - return NULL; + return nullptr; } return biome->getMobs(mobCategory); } TilePos *FlatLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void FlatLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) diff --git a/Minecraft.World/FleeSunGoal.cpp b/Minecraft.World/FleeSunGoal.cpp index 353d1625b..bf1c04ad4 100644 --- a/Minecraft.World/FleeSunGoal.cpp +++ b/Minecraft.World/FleeSunGoal.cpp @@ -21,7 +21,7 @@ bool FleeSunGoal::canUse() if (!level->canSeeSky(Mth::floor(mob->x), static_cast(mob->bb->y0), Mth::floor(mob->z))) return false; Vec3 *pos = getHidePos(); - if (pos == NULL) return false; + if (pos == nullptr) return false; wantedX = pos->x; wantedY = pos->y; wantedZ = pos->z; @@ -48,5 +48,5 @@ Vec3 *FleeSunGoal::getHidePos() int zt = Mth::floor(mob->z + random->nextInt(20) - 10); if (!level->canSeeSky(xt, yt, zt) && mob->getWalkTargetValue(xt, yt, zt) < 0) return Vec3::newTemp(xt, yt, zt); } - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.World/FlowerFeature.cpp b/Minecraft.World/FlowerFeature.cpp index f24d61bfa..c5cd68c62 100644 --- a/Minecraft.World/FlowerFeature.cpp +++ b/Minecraft.World/FlowerFeature.cpp @@ -12,7 +12,7 @@ FlowerFeature::FlowerFeature(int tile) bool FlowerFeature::place(Level *level, Random *random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x - 8, y - 4, z - 8, x + 8, y + 4, z + 8); diff --git a/Minecraft.World/FlowerPotTile.cpp b/Minecraft.World/FlowerPotTile.cpp index 4cdd529c4..57aa8b6d3 100644 --- a/Minecraft.World/FlowerPotTile.cpp +++ b/Minecraft.World/FlowerPotTile.cpp @@ -36,7 +36,7 @@ bool FlowerPotTile::isCubeShaped() bool FlowerPotTile::use(Level *level, int x, int y, int z, shared_ptr player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly) { shared_ptr item = player->inventory->getSelected(); - if (item == NULL) return false; + if (item == nullptr) return false; if (level->getData(x, y, z) != 0) return false; int type = getTypeFromItem(item); @@ -62,7 +62,7 @@ int FlowerPotTile::cloneTileId(Level *level, int x, int y, int z) { shared_ptr item = getItemFromType(level->getData(x, y, z)); - if (item == NULL) + if (item == nullptr) { return Item::flowerPot_Id; } @@ -76,7 +76,7 @@ int FlowerPotTile::cloneTileData(Level *level, int x, int y, int z) { shared_ptr item = getItemFromType(level->getData(x, y, z)); - if (item == NULL) + if (item == nullptr) { return Item::flowerPot_Id; } @@ -113,7 +113,7 @@ void FlowerPotTile::spawnResources(Level *level, int x, int y, int z, int data, if (data > 0) { shared_ptr item = getItemFromType(data); - if (item != NULL) popResource(level, x, y, z, item); + if (item != nullptr) popResource(level, x, y, z, item); } } diff --git a/Minecraft.World/FollowOwnerGoal.cpp b/Minecraft.World/FollowOwnerGoal.cpp index 8565d7827..89ec46437 100644 --- a/Minecraft.World/FollowOwnerGoal.cpp +++ b/Minecraft.World/FollowOwnerGoal.cpp @@ -25,7 +25,7 @@ FollowOwnerGoal::FollowOwnerGoal(TamableAnimal *tamable, double speedModifier, f bool FollowOwnerGoal::canUse() { shared_ptr owner = dynamic_pointer_cast( tamable->getOwner() ); - if (owner == NULL) return false; + if (owner == nullptr) return false; if (tamable->isSitting()) return false; if (tamable->distanceToSqr(owner) < startDistance * startDistance) return false; this->owner = weak_ptr(owner); @@ -34,7 +34,7 @@ bool FollowOwnerGoal::canUse() bool FollowOwnerGoal::canContinueToUse() { - return owner.lock() != NULL && !navigation->isDone() && tamable->distanceToSqr(owner.lock()) > stopDistance * stopDistance && !tamable->isSitting(); + return owner.lock() != nullptr && !navigation->isDone() && tamable->distanceToSqr(owner.lock()) > stopDistance * stopDistance && !tamable->isSitting(); } void FollowOwnerGoal::start() diff --git a/Minecraft.World/FollowParentGoal.cpp b/Minecraft.World/FollowParentGoal.cpp index 8983590ab..d8f3bad9e 100644 --- a/Minecraft.World/FollowParentGoal.cpp +++ b/Minecraft.World/FollowParentGoal.cpp @@ -33,7 +33,7 @@ bool FollowParentGoal::canUse() } delete parents; - if (closest == NULL) return false; + if (closest == nullptr) return false; if (closestDistSqr < 3 * 3) return false; parent = weak_ptr(closest); return true; @@ -41,7 +41,7 @@ bool FollowParentGoal::canUse() bool FollowParentGoal::canContinueToUse() { - if (parent.lock() == NULL || !parent.lock()->isAlive()) return false; + if (parent.lock() == nullptr || !parent.lock()->isAlive()) return false; double distSqr = animal->distanceToSqr(parent.lock()); if (distSqr < 3 * 3 || distSqr > 16 * 16) return false; return true; diff --git a/Minecraft.World/FurnaceMenu.cpp b/Minecraft.World/FurnaceMenu.cpp index f67d63886..2bc2d2bd3 100644 --- a/Minecraft.World/FurnaceMenu.cpp +++ b/Minecraft.World/FurnaceMenu.cpp @@ -86,7 +86,7 @@ shared_ptr FurnaceMenu::quickMoveStack(shared_ptr player, bool charcoalUsed = furnace->wasCharcoalUsed(); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -112,7 +112,7 @@ shared_ptr FurnaceMenu::quickMoveStack(shared_ptr player, return nullptr; } } - else if (FurnaceRecipes::getInstance()->getResult(stack->getItem()->id) != NULL) + else if (FurnaceRecipes::getInstance()->getResult(stack->getItem()->id) != nullptr) { if (!moveItemStackTo(stack, INGREDIENT_SLOT, INGREDIENT_SLOT + 1, false)) { diff --git a/Minecraft.World/FurnaceRecipes.cpp b/Minecraft.World/FurnaceRecipes.cpp index bed4e1b62..f0a4c770e 100644 --- a/Minecraft.World/FurnaceRecipes.cpp +++ b/Minecraft.World/FurnaceRecipes.cpp @@ -3,7 +3,7 @@ #include "Tile.h" #include "FurnaceRecipes.h" -FurnaceRecipes *FurnaceRecipes::instance = NULL; +FurnaceRecipes *FurnaceRecipes::instance = nullptr; void FurnaceRecipes::staticCtor() { @@ -63,7 +63,7 @@ ItemInstance *FurnaceRecipes::getResult(int itemId) { return it->second; } - return NULL; + return nullptr; } unordered_map *FurnaceRecipes::getRecipies() diff --git a/Minecraft.World/FurnaceTile.cpp b/Minecraft.World/FurnaceTile.cpp index 1393a325b..2d8fc9914 100644 --- a/Minecraft.World/FurnaceTile.cpp +++ b/Minecraft.World/FurnaceTile.cpp @@ -17,8 +17,8 @@ FurnaceTile::FurnaceTile(int id, bool lit) : BaseEntityTile(id, Material::stone) random = new Random(); this->lit = lit; - iconTop = NULL; - iconFront = NULL; + iconTop = nullptr; + iconFront = nullptr; } int FurnaceTile::getResource(int data, Random *random, int playerBonusLevel) @@ -117,7 +117,7 @@ bool FurnaceTile::use(Level *level, int x, int y, int z, shared_ptr play return true; } shared_ptr furnace = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (furnace != NULL ) player->openFurnace(furnace); + if (furnace != nullptr ) player->openFurnace(furnace); return true; } @@ -132,7 +132,7 @@ void FurnaceTile::setLit(bool lit, Level *level, int x, int y, int z) noDrop = false; level->setData(x, y, z, data, Tile::UPDATE_CLIENTS); - if( te != NULL ) + if( te != nullptr ) { te->clearRemoved(); level->setTileEntity(x, y, z, te); @@ -164,12 +164,12 @@ void FurnaceTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (!noDrop) { shared_ptr container = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if( container != NULL ) + if( container != nullptr ) { for (unsigned int i = 0; i < container->getContainerSize(); i++) { shared_ptr item = container->getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; diff --git a/Minecraft.World/FurnaceTileEntity.cpp b/Minecraft.World/FurnaceTileEntity.cpp index 70190f4ee..461670db2 100644 --- a/Minecraft.World/FurnaceTileEntity.cpp +++ b/Minecraft.World/FurnaceTileEntity.cpp @@ -53,7 +53,7 @@ shared_ptr FurnaceTileEntity::removeItem(unsigned int slot, int co { m_charcoalUsed = false; - if (items[slot] != NULL) + if (items[slot] != nullptr) { if (items[slot]->count <= count) { @@ -79,7 +79,7 @@ shared_ptr FurnaceTileEntity::removeItemNoUpdate(int slot) { m_charcoalUsed = false; - if (items[slot] != NULL) + if (items[slot] != nullptr) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -92,7 +92,7 @@ shared_ptr FurnaceTileEntity::removeItemNoUpdate(int slot) void FurnaceTileEntity::setItem(unsigned int slot, shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); } @@ -146,7 +146,7 @@ void FurnaceTileEntity::save(CompoundTag *base) for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i)); @@ -194,7 +194,7 @@ void FurnaceTileEntity::tick() litTime--; } - if ( level != NULL && !level->isClientSide) + if ( level != nullptr && !level->isClientSide) { if (litTime == 0 && canBurn()) { @@ -202,7 +202,7 @@ void FurnaceTileEntity::tick() if (litTime > 0) { changed = true; - if (items[SLOT_FUEL] != NULL) + if (items[SLOT_FUEL] != nullptr) { // 4J Added: Keep track of whether charcoal was used in production of current stack. if ( items[SLOT_FUEL]->getItem()->id == Item::coal_Id @@ -215,7 +215,7 @@ void FurnaceTileEntity::tick() if (items[SLOT_FUEL]->count == 0) { Item *remaining = items[SLOT_FUEL]->getItem()->getCraftingRemainingItem(); - items[SLOT_FUEL] = remaining != NULL ? shared_ptr(new ItemInstance(remaining)) : nullptr; + items[SLOT_FUEL] = remaining != nullptr ? shared_ptr(new ItemInstance(remaining)) : nullptr; } } } @@ -249,10 +249,10 @@ void FurnaceTileEntity::tick() bool FurnaceTileEntity::canBurn() { - if (items[SLOT_INPUT] == NULL) return false; + if (items[SLOT_INPUT] == nullptr) return false; const ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id); - if (burnResult == NULL) return false; - if (items[SLOT_RESULT] == NULL) return true; + if (burnResult == nullptr) return false; + if (items[SLOT_RESULT] == nullptr) return true; if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false; if (items[SLOT_RESULT]->count < getMaxStackSize() && items[SLOT_RESULT]->count < items[SLOT_RESULT]->getMaxStackSize()) return true; if (items[SLOT_RESULT]->count < burnResult->getMaxStackSize()) return true; @@ -265,7 +265,7 @@ void FurnaceTileEntity::burn() if (!canBurn()) return; const ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id); - if (items[SLOT_RESULT] == NULL) items[SLOT_RESULT] = result->copy(); + if (items[SLOT_RESULT] == nullptr) items[SLOT_RESULT] = result->copy(); else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++; items[SLOT_INPUT]->count--; @@ -275,12 +275,12 @@ void FurnaceTileEntity::burn() int FurnaceTileEntity::getBurnDuration(shared_ptr itemInstance) { - if (itemInstance == NULL) return 0; + if (itemInstance == nullptr) return 0; int id = itemInstance->getItem()->id; Item *item = itemInstance->getItem(); - if (id < 256 && Tile::tiles[id] != NULL) + if (id < 256 && Tile::tiles[id] != nullptr) { Tile *tile = Tile::tiles[id]; @@ -405,7 +405,7 @@ shared_ptr FurnaceTileEntity::clone() for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { result->items[i] = ItemInstance::clone(items[i]); } diff --git a/Minecraft.World/GameCommandPacket.cpp b/Minecraft.World/GameCommandPacket.cpp index 2f74778fc..17c5316af 100644 --- a/Minecraft.World/GameCommandPacket.cpp +++ b/Minecraft.World/GameCommandPacket.cpp @@ -15,7 +15,7 @@ GameCommandPacket::GameCommandPacket(EGameCommand command, byteArray data) this->data = data; length = 0; - if (data.data != NULL) + if (data.data != nullptr) { length = data.length; @@ -42,7 +42,7 @@ void GameCommandPacket::read(DataInputStream *dis) if (length > 0 && length < Short::MAX_VALUE) { - if(data.data != NULL) + if(data.data != nullptr) { delete [] data.data; } @@ -55,7 +55,7 @@ void GameCommandPacket::write(DataOutputStream *dos) { dos->writeInt(command); dos->writeShort(static_cast(length)); - if (data.data != NULL) + if (data.data != nullptr) { dos->write(data); } diff --git a/Minecraft.World/GameModeCommand.cpp b/Minecraft.World/GameModeCommand.cpp index f8c1ffb6f..6e4cd858a 100644 --- a/Minecraft.World/GameModeCommand.cpp +++ b/Minecraft.World/GameModeCommand.cpp @@ -37,7 +37,7 @@ void GameModeCommand::execute(shared_ptr source, byteArray comman GameType *GameModeCommand::getModeForString(shared_ptr source, const wstring &name) { - return NULL; + return nullptr; //if (name.equalsIgnoreCase(GameType.SURVIVAL.getName()) || name.equalsIgnoreCase("s")) { // return GameType.SURVIVAL; //} else if (name.equalsIgnoreCase(GameType.CREATIVE.getName()) || name.equalsIgnoreCase("c")) { diff --git a/Minecraft.World/GenericStats.cpp b/Minecraft.World/GenericStats.cpp index 1fa901513..d97c182ac 100644 --- a/Minecraft.World/GenericStats.cpp +++ b/Minecraft.World/GenericStats.cpp @@ -4,161 +4,161 @@ #include "GenericStats.h" -GenericStats *GenericStats::instance = NULL; +GenericStats *GenericStats::instance = nullptr; Stat* GenericStats::get_walkOneM() { - return NULL; + return nullptr; } Stat* GenericStats::get_swimOneM() { - return NULL; + return nullptr; } Stat* GenericStats::get_fallOneM() { - return NULL; + return nullptr; } Stat* GenericStats::get_climbOneM() { - return NULL; + return nullptr; } Stat* GenericStats::get_minecartOneM() { - return NULL; + return nullptr; } Stat* GenericStats::get_boatOneM() { - return NULL; + return nullptr; } Stat* GenericStats::get_pigOneM() { - return NULL; + return nullptr; } Stat* GenericStats::get_portalsCreated() { - return NULL; + return nullptr; } Stat* GenericStats::get_cowsMilked() { - return NULL; + return nullptr; } Stat* GenericStats::get_netherLavaCollected() { - return NULL; + return nullptr; } Stat* GenericStats::get_killMob() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsZombie() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsSkeleton() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsCreeper() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsSpider() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsSpiderJockey() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsZombiePigman() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsSlime() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsGhast() { - return NULL; + return nullptr; } Stat* GenericStats::get_killsNetherZombiePigman() { - return NULL; + return nullptr; } Stat* GenericStats::get_breedEntity(eINSTANCEOF entityId) { - return NULL; + return nullptr; } Stat* GenericStats::get_tamedEntity(eINSTANCEOF entityId) { - return NULL; + return nullptr; } Stat* GenericStats::get_curedEntity(eINSTANCEOF entityId) { - return NULL; + return nullptr; } Stat* GenericStats::get_craftedEntity(eINSTANCEOF entityId) { - return NULL; + return nullptr; } Stat* GenericStats::get_shearedEntity(eINSTANCEOF entityId) { - return NULL; + return nullptr; } Stat* GenericStats::get_totalBlocksMined() { - return NULL; + return nullptr; } Stat* GenericStats::get_timePlayed() { - return NULL; + return nullptr; } Stat* GenericStats::get_blocksPlaced(int blockId) { - return NULL; + return nullptr; } Stat* GenericStats::get_blocksMined(int blockId) { - return NULL; + return nullptr; } Stat* GenericStats::get_itemsCollected(int itemId, int itemAux) { - return NULL; + return nullptr; } Stat* GenericStats::get_itemsCrafted(int itemId) { - return NULL; + return nullptr; } Stat* GenericStats::get_itemsSmelted(int itemId) @@ -168,37 +168,37 @@ Stat* GenericStats::get_itemsSmelted(int itemId) Stat* GenericStats::get_itemsUsed(int itemId) { - return NULL; + return nullptr; } Stat *GenericStats::get_itemsBought(int itemId) { - return NULL; + return nullptr; } Stat* GenericStats::get_killsEnderdragon() { - return NULL; + return nullptr; } Stat* GenericStats::get_completeTheEnd() { - return NULL; + return nullptr; } Stat* GenericStats::get_changedDimension(int from, int to) { - return NULL; + return nullptr; } Stat* GenericStats::get_enteredBiome(int biomeId) { - return NULL; + return nullptr; } Stat* GenericStats::get_achievement(eAward achievementId) { - return NULL; + return nullptr; } Stat* GenericStats::openInventory() @@ -286,7 +286,7 @@ Stat* GenericStats::snipeSkeleton() #ifndef _XBOX return instance->get_achievement( eAward_snipeSkeleton ); #else - return NULL; + return nullptr; #endif } @@ -295,7 +295,7 @@ Stat* GenericStats::diamonds() #ifndef _XBOX return instance->get_achievement( eAward_diamonds ); #else - return NULL; + return nullptr; #endif } @@ -304,7 +304,7 @@ Stat* GenericStats::ghast() #ifndef _XBOX return instance->get_achievement( eAward_ghast ); #else - return NULL; + return nullptr; #endif } @@ -313,7 +313,7 @@ Stat* GenericStats::blazeRod() #ifndef _XBOX return instance->get_achievement( eAward_blazeRod ); #else - return NULL; + return nullptr; #endif } @@ -322,7 +322,7 @@ Stat* GenericStats::potion() #ifndef _XBOX return instance->get_achievement( eAward_potion ); #else - return NULL; + return nullptr; #endif } @@ -331,7 +331,7 @@ Stat* GenericStats::theEnd() #ifndef _XBOX return instance->get_achievement( eAward_theEnd ); #else - return NULL; + return nullptr; #endif } @@ -340,7 +340,7 @@ Stat* GenericStats::winGame() #ifndef _XBOX return instance->get_achievement( eAward_winGame ); #else - return NULL; + return nullptr; #endif } @@ -349,7 +349,7 @@ Stat* GenericStats::enchantments() #ifndef _XBOX return instance->get_achievement( eAward_enchantments ); #else - return NULL; + return nullptr; #endif } @@ -358,7 +358,7 @@ Stat* GenericStats::overkill() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement( eAward_overkill ); #else - return NULL; + return nullptr; #endif } @@ -367,7 +367,7 @@ Stat* GenericStats::bookcase() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement( eAward_bookcase ); #else - return NULL; + return nullptr; #endif } @@ -426,7 +426,7 @@ Stat* GenericStats::adventuringTime() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_adventuringTime); #else - return NULL; + return nullptr; #endif } @@ -435,7 +435,7 @@ Stat* GenericStats::repopulation() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_repopulation); #else - return NULL; + return nullptr; #endif } @@ -444,7 +444,7 @@ Stat* GenericStats::porkChop() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_eatPorkChop); #else - return NULL; + return nullptr; #endif } @@ -453,7 +453,7 @@ Stat* GenericStats::diamondsToYou() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_diamondsToYou); #else - return NULL; + return nullptr; #endif } @@ -462,7 +462,7 @@ Stat* GenericStats::passingTheTime() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_play100Days); #else - return NULL; + return nullptr; #endif } @@ -471,7 +471,7 @@ Stat* GenericStats::archer() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_arrowKillCreeper); #else - return NULL; + return nullptr; #endif } @@ -480,7 +480,7 @@ Stat* GenericStats::theHaggler() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_theHaggler); #else - return NULL; + return nullptr; #endif } @@ -489,7 +489,7 @@ Stat* GenericStats::potPlanter() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_potPlanter); #else - return NULL; + return nullptr; #endif } @@ -498,7 +498,7 @@ Stat* GenericStats::itsASign() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_itsASign); #else - return NULL; + return nullptr; #endif } @@ -507,7 +507,7 @@ Stat* GenericStats::ironBelly() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_ironBelly); #else - return NULL; + return nullptr; #endif } @@ -516,7 +516,7 @@ Stat* GenericStats::haveAShearfulDay() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_haveAShearfulDay); #else - return NULL; + return nullptr; #endif } @@ -525,7 +525,7 @@ Stat* GenericStats::rainbowCollection() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_rainbowCollection); #else - return NULL; + return nullptr; #endif } @@ -534,7 +534,7 @@ Stat* GenericStats::stayinFrosty() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_stayinFrosty); #else - return NULL; + return nullptr; #endif } @@ -543,7 +543,7 @@ Stat* GenericStats::chestfulOfCobblestone() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_chestfulOfCobblestone); #else - return NULL; + return nullptr; #endif } @@ -552,7 +552,7 @@ Stat* GenericStats::renewableEnergy() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_renewableEnergy); #else - return NULL; + return nullptr; #endif } @@ -561,7 +561,7 @@ Stat* GenericStats::musicToMyEars() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_musicToMyEars); #else - return NULL; + return nullptr; #endif } @@ -570,7 +570,7 @@ Stat* GenericStats::bodyGuard() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_bodyGuard); #else - return NULL; + return nullptr; #endif } @@ -579,7 +579,7 @@ Stat* GenericStats::ironMan() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_ironMan); #else - return NULL; + return nullptr; #endif } @@ -588,7 +588,7 @@ Stat* GenericStats::zombieDoctor() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_zombieDoctor); #else - return NULL; + return nullptr; #endif } @@ -597,7 +597,7 @@ Stat* GenericStats::lionTamer() #ifdef _EXTENDED_ACHIEVEMENTS return instance->get_achievement(eAward_lionTamer); #else - return NULL; + return nullptr; #endif } @@ -835,7 +835,7 @@ byteArray GenericStats::param_itemsSmelted(int id, int aux, int count) byteArray GenericStats::param_itemsUsed(shared_ptr plr, shared_ptr itm) { - if ( (plr != NULL) && (itm != NULL) ) return instance->getParam_itemsUsed(plr, itm); + if ( (plr != nullptr) && (itm != nullptr) ) return instance->getParam_itemsUsed(plr, itm); else return instance->getParam_noArgs(); } @@ -846,7 +846,7 @@ byteArray GenericStats::param_itemsBought(int id, int aux, int count) byteArray GenericStats::param_mobKill(shared_ptr plr, shared_ptr mob, DamageSource *dmgSrc) { - if ( (plr != NULL) && (mob != NULL) ) return instance->getParam_mobKill(plr, mob, dmgSrc); + if ( (plr != nullptr) && (mob != nullptr) ) return instance->getParam_mobKill(plr, mob, dmgSrc); else return instance->getParam_noArgs(); } diff --git a/Minecraft.World/Ghast.cpp b/Minecraft.World/Ghast.cpp index dc70e9025..b016320f3 100644 --- a/Minecraft.World/Ghast.cpp +++ b/Minecraft.World/Ghast.cpp @@ -56,7 +56,7 @@ bool Ghast::hurt(DamageSource *source, float dmg) if (isInvulnerable()) return false; if (source->getMsgId() == ChatPacket::e_ChatDeathFireball) { - if ( (source->getEntity() != NULL) && source->getEntity()->instanceof(eTYPE_PLAYER) ) + if ( (source->getEntity() != nullptr) && source->getEntity()->instanceof(eTYPE_PLAYER) ) { // reflected fireball, kill the ghast FlyingMob::hurt(source, 1000); @@ -121,18 +121,18 @@ void Ghast::serverAiStep() } } - if (target != NULL && target->removed) target = nullptr; - if (target == NULL || retargetTime-- <= 0) + if (target != nullptr && target->removed) target = nullptr; + if (target == nullptr || retargetTime-- <= 0) { target = level->getNearestAttackablePlayer(shared_from_this(), 100); - if (target != NULL) + if (target != nullptr) { retargetTime = 20; } } double maxDist = 64.0f; - if (target != NULL && target->distanceToSqr(shared_from_this()) < maxDist * maxDist) + if (target != nullptr && target->distanceToSqr(shared_from_this()) < maxDist * maxDist) { double xdd = target->x - x; double ydd = (target->bb->y0 + target->bbHeight / 2) - (y + bbHeight / 2); diff --git a/Minecraft.World/GiveItemCommand.cpp b/Minecraft.World/GiveItemCommand.cpp index b3cbff4f1..e51332666 100644 --- a/Minecraft.World/GiveItemCommand.cpp +++ b/Minecraft.World/GiveItemCommand.cpp @@ -30,7 +30,7 @@ void GiveItemCommand::execute(shared_ptr source, byteArray comman bais.reset(); shared_ptr player = getPlayer(uid); - if(player != NULL && item > 0 && Item::items[item] != NULL) + if(player != nullptr && item > 0 && Item::items[item] != nullptr) { shared_ptr itemInstance = shared_ptr(new ItemInstance(item, amount, aux)); shared_ptr drop = player->drop(itemInstance); @@ -42,7 +42,7 @@ void GiveItemCommand::execute(shared_ptr source, byteArray comman shared_ptr GiveItemCommand::preparePacket(shared_ptr player, int item, int amount, int aux, const wstring &tag) { - if(player == NULL) return nullptr; + if(player == nullptr) return nullptr; ByteArrayOutputStream baos; DataOutputStream dos(&baos); diff --git a/Minecraft.World/GrassTile.cpp b/Minecraft.World/GrassTile.cpp index 68e7c2332..9be44d0eb 100644 --- a/Minecraft.World/GrassTile.cpp +++ b/Minecraft.World/GrassTile.cpp @@ -12,9 +12,9 @@ GrassTile::GrassTile(int id) : Tile(id, Material::grass) { - iconTop = NULL; - iconSnowSide = NULL; - iconSideOverlay = NULL; + iconTop = nullptr; + iconSnowSide = nullptr; + iconSideOverlay = nullptr; setTicking(true); } diff --git a/Minecraft.World/HangingEntity.cpp b/Minecraft.World/HangingEntity.cpp index 3d44b4260..67d531140 100644 --- a/Minecraft.World/HangingEntity.cpp +++ b/Minecraft.World/HangingEntity.cpp @@ -150,7 +150,7 @@ bool HangingEntity::survives() vector > *entities = level->getEntities(shared_from_this(), bb); - if (entities != NULL && entities->size() > 0) + if (entities != nullptr && entities->size() > 0) { for (auto& e : *entities) { @@ -184,11 +184,11 @@ bool HangingEntity::hurt(DamageSource *source, float damage) if (isInvulnerable()) return false; if (!removed && !level->isClientSide) { - if (dynamic_cast(source) != NULL) + if (dynamic_cast(source) != nullptr) { shared_ptr sourceEntity = source->getDirectEntity(); - if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast(sourceEntity)->isAllowedToHurtEntity(shared_from_this()) ) + if ( (sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast(sourceEntity)->isAllowedToHurtEntity(shared_from_this()) ) { return false; } @@ -199,12 +199,12 @@ bool HangingEntity::hurt(DamageSource *source, float damage) shared_ptr player = nullptr; shared_ptr e = source->getEntity(); - if ( (e!=NULL) && e->instanceof(eTYPE_PLAYER) ) // check if it's serverplayer or player + if ( (e!=nullptr) && e->instanceof(eTYPE_PLAYER) ) // check if it's serverplayer or player { player = dynamic_pointer_cast( e ); } - if (player != NULL && player->abilities.instabuild) + if (player != nullptr && player->abilities.instabuild) { return true; } diff --git a/Minecraft.World/HangingEntityItem.cpp b/Minecraft.World/HangingEntityItem.cpp index 9e4e9d5b6..75e9dcff5 100644 --- a/Minecraft.World/HangingEntityItem.cpp +++ b/Minecraft.World/HangingEntityItem.cpp @@ -35,7 +35,7 @@ bool HangingEntityItem::useOn(shared_ptr instance, shared_ptrmayUseItemAt(xt, yt, zt, face, instance)) return false; - if (entity != NULL && entity->survives()) + if (entity != nullptr && entity->survives()) { if (!level->isClientSide) { diff --git a/Minecraft.World/HatchetItem.cpp b/Minecraft.World/HatchetItem.cpp index 7fa204ca9..dd74a2ed9 100644 --- a/Minecraft.World/HatchetItem.cpp +++ b/Minecraft.World/HatchetItem.cpp @@ -2,7 +2,7 @@ #include "net.minecraft.world.level.tile.h" #include "HatchetItem.h" -TileArray *HatchetItem::diggables = NULL; +TileArray *HatchetItem::diggables = nullptr; void HatchetItem::staticCtor() { @@ -25,7 +25,7 @@ HatchetItem::HatchetItem(int id, const Tier *tier) : DiggerItem (id, 3, tier, di // 4J - brought forward from 1.2.3 float HatchetItem::getDestroySpeed(shared_ptr itemInstance, Tile *tile) { - if (tile != NULL && (tile->material == Material::wood || tile->material == Material::plant || tile->material == Material::replaceable_plant)) + if (tile != nullptr && (tile->material == Material::wood || tile->material == Material::plant || tile->material == Material::replaceable_plant)) { return speed; } diff --git a/Minecraft.World/HellFlatLevelSource.cpp b/Minecraft.World/HellFlatLevelSource.cpp index 4c9a77077..305c45ce5 100644 --- a/Minecraft.World/HellFlatLevelSource.cpp +++ b/Minecraft.World/HellFlatLevelSource.cpp @@ -211,16 +211,16 @@ wstring HellFlatLevelSource::gatherStats() vector *HellFlatLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { Biome *biome = level->getBiome(x, z); - if (biome == NULL) + if (biome == nullptr) { - return NULL; + return nullptr; } return biome->getMobs(mobCategory); } TilePos *HellFlatLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void HellFlatLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) diff --git a/Minecraft.World/HellRandomLevelSource.cpp b/Minecraft.World/HellRandomLevelSource.cpp index e92ad2776..06cdd831a 100644 --- a/Minecraft.World/HellRandomLevelSource.cpp +++ b/Minecraft.World/HellRandomLevelSource.cpp @@ -303,7 +303,7 @@ void HellRandomLevelSource::lightChunk(LevelChunk *lc) doubleArray HellRandomLevelSource::getHeights(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize) { - if (buffer.data == NULL) + if (buffer.data == nullptr) { buffer = doubleArray(xSize * ySize * zSize); } @@ -547,19 +547,19 @@ vector *HellRandomLevelSource::getMobsAt(MobCategory *m } Biome *biome = level->getBiome(x, z); - if (biome == NULL) + if (biome == nullptr) { - return NULL; + return nullptr; } return biome->getMobs(mobCategory); } TilePos *HellRandomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void HellRandomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) { - netherBridgeFeature->apply(this, level, chunkX, chunkZ, NULL); + netherBridgeFeature->apply(this, level, chunkX, chunkZ, byteArray()); } \ No newline at end of file diff --git a/Minecraft.World/HopperMenu.cpp b/Minecraft.World/HopperMenu.cpp index afc700c3a..996651c65 100644 --- a/Minecraft.World/HopperMenu.cpp +++ b/Minecraft.World/HopperMenu.cpp @@ -35,7 +35,7 @@ shared_ptr HopperMenu::quickMoveStack(shared_ptr player, i { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/HopperTile.cpp b/Minecraft.World/HopperTile.cpp index 6e41aefc3..dadda9b0f 100644 --- a/Minecraft.World/HopperTile.cpp +++ b/Minecraft.World/HopperTile.cpp @@ -74,7 +74,7 @@ bool HopperTile::use(Level *level, int x, int y, int z, shared_ptr playe return true; } shared_ptr hopper = getHopper(level, x, y, z); - if (hopper != NULL) player->openHopper(hopper); + if (hopper != nullptr) player->openHopper(hopper); return true; } @@ -99,12 +99,12 @@ void HopperTile::checkPoweredState(Level *level, int x, int y, int z) void HopperTile::onRemove(Level *level, int x, int y, int z, int id, int data) { shared_ptr container = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (container != NULL) + if (container != nullptr) { for (int i = 0; i < container->getContainerSize(); i++) { shared_ptr item = container->getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random.nextFloat() * 0.8f + 0.1f; float yo = random.nextFloat() * 0.8f + 0.1f; @@ -197,7 +197,7 @@ Icon *HopperTile::getTexture(const wstring &name) { if (name.compare(TEXTURE_OUTSIDE) == 0) return Tile::hopper->hopperIcon; if (name.compare(TEXTURE_INSIDE) == 0) return Tile::hopper->hopperInnerIcon; - return NULL; + return nullptr; } wstring HopperTile::getTileItemIconName() diff --git a/Minecraft.World/HopperTileEntity.cpp b/Minecraft.World/HopperTileEntity.cpp index efb11bac8..3e0cbe86d 100644 --- a/Minecraft.World/HopperTileEntity.cpp +++ b/Minecraft.World/HopperTileEntity.cpp @@ -46,7 +46,7 @@ void HopperTileEntity::save(CompoundTag *base) for (int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i)); @@ -76,7 +76,7 @@ shared_ptr HopperTileEntity::getItem(unsigned int slot) shared_ptr HopperTileEntity::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { if (items[slot]->count <= count) { @@ -96,7 +96,7 @@ shared_ptr HopperTileEntity::removeItem(unsigned int slot, int cou shared_ptr HopperTileEntity::removeItemNoUpdate(int slot) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -108,7 +108,7 @@ shared_ptr HopperTileEntity::removeItemNoUpdate(int slot) void HopperTileEntity::setItem(unsigned int slot, shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); } wstring HopperTileEntity::getName() @@ -158,7 +158,7 @@ bool HopperTileEntity::canPlaceItem(int slot, shared_ptr item) void HopperTileEntity::tick() { - if (level == NULL || level->isClientSide) return; + if (level == nullptr || level->isClientSide) return; cooldownTime--; @@ -171,7 +171,7 @@ void HopperTileEntity::tick() bool HopperTileEntity::tryMoveItems() { - if (level == NULL || level->isClientSide) return false; + if (level == nullptr || level->isClientSide) return false; if (!isOnCooldown() && HopperTile::isTurnedOn(getData())) { @@ -192,19 +192,19 @@ bool HopperTileEntity::tryMoveItems() bool HopperTileEntity::ejectItems() { shared_ptr container = getAttachedContainer(); - if (container == NULL) + if (container == nullptr) { return false; } for (int slot = 0; slot < getContainerSize(); slot++) { - if (getItem(slot) == NULL) continue; + if (getItem(slot) == nullptr) continue; shared_ptr original = getItem(slot)->copy(); shared_ptr result = addItem(container.get(), removeItem(slot, 1), Facing::OPPOSITE_FACING[HopperTile::getAttachedFace(getData())]); - if (result == NULL || result->count == 0) + if (result == nullptr || result->count == 0) { container->setChanged(); return true; @@ -222,12 +222,12 @@ bool HopperTileEntity::suckInItems(Hopper *hopper) { shared_ptr container = getSourceContainer(hopper); - if (container != NULL) + if (container != nullptr) { int face = Facing::DOWN; shared_ptr worldly = dynamic_pointer_cast(container); - if ( (worldly != NULL) && (face > -1) ) + if ( (worldly != nullptr) && (face > -1) ) { intArray slots = worldly->getSlotsForFace(face); @@ -249,7 +249,7 @@ bool HopperTileEntity::suckInItems(Hopper *hopper) { shared_ptr above = getItemAt(hopper->getLevel(), hopper->getLevelX(), hopper->getLevelY() + 1, hopper->getLevelZ()); - if (above != NULL) + if (above != nullptr) { return addItem(hopper, above); } @@ -262,12 +262,12 @@ bool HopperTileEntity::tryTakeInItemFromSlot(Hopper *hopper, Container *containe { shared_ptr item = container->getItem(slot); - if (item != NULL && canTakeItemFromContainer(container, item, slot, face)) + if (item != nullptr && canTakeItemFromContainer(container, item, slot, face)) { shared_ptr original = item->copy(); shared_ptr result = addItem(hopper, container->removeItem(slot, 1), -1); - if (result == NULL || result->count == 0) + if (result == nullptr || result->count == 0) { container->setChanged(); return true; @@ -284,12 +284,12 @@ bool HopperTileEntity::tryTakeInItemFromSlot(Hopper *hopper, Container *containe bool HopperTileEntity::addItem(Container *container, shared_ptr item) { bool changed = false; - if (item == NULL) return false; + if (item == nullptr) return false; shared_ptr copy = item->getItem()->copy(); shared_ptr result = addItem(container, copy, -1); - if (result == NULL || result->count == 0) + if (result == nullptr || result->count == 0) { changed = true; @@ -305,12 +305,12 @@ bool HopperTileEntity::addItem(Container *container, shared_ptr item shared_ptr HopperTileEntity::addItem(Container *container, shared_ptr item, int face) { - if (dynamic_cast( container ) != NULL && face > -1) + if (dynamic_cast( container ) != nullptr && face > -1) { WorldlyContainer *worldly = static_cast(container); intArray slots = worldly->getSlotsForFace(face); - for (int i = 0; i < slots.length && item != NULL && item->count > 0; i++) + for (int i = 0; i < slots.length && item != nullptr && item->count > 0; i++) { item = tryMoveInItem(container, item, slots[i], face); } @@ -318,13 +318,13 @@ shared_ptr HopperTileEntity::addItem(Container *container, shared_ else { int size = container->getContainerSize(); - for (int i = 0; i < size && item != NULL && item->count > 0; i++) + for (int i = 0; i < size && item != nullptr && item->count > 0; i++) { item = tryMoveInItem(container, item, i, face); } } - if (item != NULL && item->count == 0) + if (item != nullptr && item->count == 0) { item = nullptr; } @@ -335,13 +335,13 @@ shared_ptr HopperTileEntity::addItem(Container *container, shared_ bool HopperTileEntity::canPlaceItemInContainer(Container *container, shared_ptr item, int slot, int face) { if (!container->canPlaceItem(slot, item)) return false; - if ( dynamic_cast( container ) != NULL && !dynamic_cast( container )->canPlaceItemThroughFace(slot, item, face)) return false; + if ( dynamic_cast( container ) != nullptr && !dynamic_cast( container )->canPlaceItemThroughFace(slot, item, face)) return false; return true; } bool HopperTileEntity::canTakeItemFromContainer(Container *container, shared_ptr item, int slot, int face) { - if (dynamic_cast( container ) != NULL && !dynamic_cast( container )->canTakeItemThroughFace(slot, item, face)) return false; + if (dynamic_cast( container ) != nullptr && !dynamic_cast( container )->canTakeItemThroughFace(slot, item, face)) return false; return true; } @@ -352,7 +352,7 @@ shared_ptr HopperTileEntity::tryMoveInItem(Container *container, s if (canPlaceItemInContainer(container, item, slot, face)) { bool success = false; - if (current == NULL) + if (current == nullptr) { container->setItem(slot, item); item = nullptr; @@ -370,7 +370,7 @@ shared_ptr HopperTileEntity::tryMoveInItem(Container *container, s if (success) { HopperTileEntity *hopper = dynamic_cast(container); - if (hopper != NULL) + if (hopper != nullptr) { hopper->setCooldown(MOVE_ITEM_SPEED); container->setChanged(); @@ -420,25 +420,25 @@ shared_ptr HopperTileEntity::getContainerAt(Level *level, double x, d shared_ptr entity = level->getTileEntity(xt, yt, zt); result = dynamic_pointer_cast(entity); - if (result != NULL) + if (result != nullptr) { - if ( dynamic_pointer_cast(result) != NULL ) + if ( dynamic_pointer_cast(result) != nullptr ) { int id = level->getTile(xt, yt, zt); Tile *tile = Tile::tiles[id]; - if ( dynamic_cast( tile ) != NULL ) + if ( dynamic_cast( tile ) != nullptr ) { result = static_cast(tile)->getContainer(level, xt, yt, zt); } } } - if (result == NULL) + if (result == nullptr) { vector > *entities = level->getEntities(nullptr, AABB::newTemp(x, y, z, x + 1, y + 1, z + 1), EntitySelector::CONTAINER_ENTITY_SELECTOR); - if ( (entities != NULL) && (entities->size() > 0) ) + if ( (entities != nullptr) && (entities->size() > 0) ) { result = dynamic_pointer_cast( entities->at( level->random->nextInt(entities->size()) ) ); } @@ -496,7 +496,7 @@ shared_ptr HopperTileEntity::clone() result->cooldownTime = cooldownTime; for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { result->items[i] = ItemInstance::clone(items[i]); } diff --git a/Minecraft.World/HorseInventoryMenu.cpp b/Minecraft.World/HorseInventoryMenu.cpp index 7dba791f8..467b3545d 100644 --- a/Minecraft.World/HorseInventoryMenu.cpp +++ b/Minecraft.World/HorseInventoryMenu.cpp @@ -75,7 +75,7 @@ shared_ptr HorseInventoryMenu::quickMoveStack(shared_ptr p { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/HtmlString.cpp b/Minecraft.World/HtmlString.cpp index ce25740ec..af6436718 100644 --- a/Minecraft.World/HtmlString.cpp +++ b/Minecraft.World/HtmlString.cpp @@ -38,7 +38,7 @@ wstring HtmlString::ToString() wstring HtmlString::Compose(vector *strings) { - if (strings == NULL) return L""; + if (strings == nullptr) return L""; std::wstringstream ss; diff --git a/Minecraft.World/HugeMushroomTile.cpp b/Minecraft.World/HugeMushroomTile.cpp index e96cfd1f1..8d3ef144d 100644 --- a/Minecraft.World/HugeMushroomTile.cpp +++ b/Minecraft.World/HugeMushroomTile.cpp @@ -9,9 +9,9 @@ const wstring HugeMushroomTile::TEXTURE_TYPE[] = {L"skin_brown", L"skin_red"}; HugeMushroomTile::HugeMushroomTile(int id, Material *material, int type) : Tile(id, material) { this->type = type; - icons = NULL; - iconStem = NULL; - iconInside = NULL; + icons = nullptr; + iconStem = nullptr; + iconInside = nullptr; } Icon *HugeMushroomTile::getTexture(int face, int data) diff --git a/Minecraft.World/HurtByTargetGoal.cpp b/Minecraft.World/HurtByTargetGoal.cpp index 076e5b6a5..e70f8628f 100644 --- a/Minecraft.World/HurtByTargetGoal.cpp +++ b/Minecraft.World/HurtByTargetGoal.cpp @@ -30,7 +30,7 @@ void HurtByTargetGoal::start() { shared_ptr other = dynamic_pointer_cast(it); if (this->mob->shared_from_this() == other) continue; - if (other->getTarget() != NULL) continue; + if (other->getTarget() != nullptr) continue; if (other->isAlliedTo(mob->getLastHurtByMob())) continue; // don't target allies other->setTarget(mob->getLastHurtByMob()); } diff --git a/Minecraft.World/IceTile.cpp b/Minecraft.World/IceTile.cpp index 938c098f9..60e162916 100644 --- a/Minecraft.World/IceTile.cpp +++ b/Minecraft.World/IceTile.cpp @@ -30,7 +30,7 @@ void IceTile::playerDestroy(Level *level, shared_ptr player, int x, int if (isSilkTouchable() && EnchantmentHelper::hasSilkTouch(player)) { shared_ptr item = getSilkTouchItemInstance(data); - if (item != NULL) + if (item != nullptr) { popResource(level, x, y, z, item); } diff --git a/Minecraft.World/IndirectEntityDamageSource.cpp b/Minecraft.World/IndirectEntityDamageSource.cpp index c2a67af5b..90c80f6bd 100644 --- a/Minecraft.World/IndirectEntityDamageSource.cpp +++ b/Minecraft.World/IndirectEntityDamageSource.cpp @@ -32,20 +32,20 @@ shared_ptr IndirectEntityDamageSource::getDeathMessagePacket(shared_ shared_ptr held = entity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast(entity)->getCarriedItem() : nullptr; wstring additional = L""; int type; - if(owner != NULL) + if(owner != nullptr) { type = owner->GetType(); if(type == eTYPE_SERVERPLAYER) { shared_ptr sourcePlayer = dynamic_pointer_cast(owner); - if(sourcePlayer != NULL) additional = sourcePlayer->name; + if(sourcePlayer != nullptr) additional = sourcePlayer->name; } } else { type = entity->GetType(); } - if(held != NULL && held->hasCustomHoverName() ) + if(held != nullptr && held->hasCustomHoverName() ) { return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName() ) ); } diff --git a/Minecraft.World/InputStream.cpp b/Minecraft.World/InputStream.cpp index e325db8a3..f31399cf5 100644 --- a/Minecraft.World/InputStream.cpp +++ b/Minecraft.World/InputStream.cpp @@ -7,5 +7,5 @@ InputStream *InputStream::getResourceAsStream(const wstring &fileName) { File file( fileName ); - return file.exists() ? new FileInputStream( file ) : NULL; + return file.exists() ? new FileInputStream( file ) : nullptr; } \ No newline at end of file diff --git a/Minecraft.World/IntArrayTag.h b/Minecraft.World/IntArrayTag.h index 482a5e1a5..61ca59d09 100644 --- a/Minecraft.World/IntArrayTag.h +++ b/Minecraft.World/IntArrayTag.h @@ -58,7 +58,7 @@ class IntArrayTag : public Tag if (Tag::equals(obj)) { IntArrayTag *o = static_cast(obj); - return ((data.data == NULL && o->data.data == NULL) || (data.data != NULL && data.length == o->data.length && memcmp(data.data, o->data.data, data.length * sizeof(int)) == 0) ); + return ((data.data == nullptr && o->data.data == nullptr) || (data.data != nullptr && data.length == o->data.length && memcmp(data.data, o->data.data, data.length * sizeof(int)) == 0) ); } return false; } diff --git a/Minecraft.World/IntCache.cpp b/Minecraft.World/IntCache.cpp index d193285a5..7c8a94df2 100644 --- a/Minecraft.World/IntCache.cpp +++ b/Minecraft.World/IntCache.cpp @@ -50,7 +50,7 @@ intArray IntCache::allocate(int size) { if (tls->tcache.empty()) { - intArray result = intArray(TINY_CUTOFF, true); + intArray result = intArray(static_cast(TINY_CUTOFF), true); tls->tallocated.push_back(result); return result; } @@ -76,7 +76,7 @@ intArray IntCache::allocate(int size) tls->cache.clear(); tls->allocated.clear(); - intArray result = intArray(tls->maxSize, true); + intArray result = intArray(static_cast(tls->maxSize), true); tls->allocated.push_back(result); return result; } @@ -84,7 +84,7 @@ intArray IntCache::allocate(int size) { if (tls->cache.empty()) { - intArray result = intArray(tls->maxSize, true); + intArray result = intArray(static_cast(tls->maxSize), true); tls->allocated.push_back(result); return result; } diff --git a/Minecraft.World/Inventory.cpp b/Minecraft.World/Inventory.cpp index 6ce647b88..d50ff614e 100644 --- a/Minecraft.World/Inventory.cpp +++ b/Minecraft.World/Inventory.cpp @@ -69,7 +69,7 @@ int Inventory::getSlot(int tileId) { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->id == tileId) return i; + if (items[i] != nullptr && items[i]->id == tileId) return i; } return -1; } @@ -78,7 +78,7 @@ int Inventory::getSlot(int tileId, int data) { for (int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->id == tileId && items[i]->getAuxValue() == data) return i; + if (items[i] != nullptr && items[i]->id == tileId && items[i]->getAuxValue() == data) return i; } return -1; } @@ -87,7 +87,7 @@ int Inventory::getSlotWithRemainingSpace(shared_ptr item) { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->id == item->id && items[i]->isStackable() + if (items[i] != nullptr && items[i]->id == item->id && items[i]->isStackable() && items[i]->count < items[i]->getMaxStackSize() && items[i]->count < getMaxStackSize() && (!items[i]->isStackedByData() || items[i]->getAuxValue() == item->getAuxValue()) && ItemInstance::tagMatches(items[i], item)) @@ -102,7 +102,7 @@ int Inventory::getFreeSlot() { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] == NULL) return i; + if (items[i] == nullptr) return i; } return -1; } @@ -160,7 +160,7 @@ int Inventory::clearInventory(int id, int data) for (int i = 0; i < items.length; i++) { shared_ptr item = items[i]; - if (item == NULL) continue; + if (item == nullptr) continue; if (id > -1 && item->id != id) continue; if (data > -1 && item->getAuxValue() != data) continue; @@ -170,7 +170,7 @@ int Inventory::clearInventory(int id, int data) for (int i = 0; i < armor.length; i++) { shared_ptr item = armor[i]; - if (item == NULL) continue; + if (item == nullptr) continue; if (id > -1 && item->id != id) continue; if (data > -1 && item->getAuxValue() != data) continue; @@ -178,7 +178,7 @@ int Inventory::clearInventory(int id, int data) armor[i] = nullptr; } - if (carried != NULL) + if (carried != nullptr) { if (id > -1 && carried->id != id) return count; if (data > -1 && carried->getAuxValue() != data) return count; @@ -192,10 +192,10 @@ int Inventory::clearInventory(int id, int data) void Inventory::replaceSlot(Item *item, int data) { - if (item != NULL) + if (item != nullptr) { // It's too easy to accidentally pick block and lose enchanted items. - if (heldItem != NULL && heldItem->isEnchantable() && getSlot(heldItem->id, heldItem->getDamageValue()) == selected) + if (heldItem != nullptr && heldItem->isEnchantable() && getSlot(heldItem->id, heldItem->getDamageValue()) == selected) { return; } @@ -226,7 +226,7 @@ int Inventory::addResource(shared_ptr itemInstance) { int slot = getFreeSlot(); if (slot < 0) return count; - if (items[slot] == NULL) + if (items[slot] == nullptr) { items[slot] = ItemInstance::clone(itemInstance); player->handleCollectItem(itemInstance); @@ -237,7 +237,7 @@ int Inventory::addResource(shared_ptr itemInstance) int slot = getSlotWithRemainingSpace(itemInstance); if (slot < 0) slot = getFreeSlot(); if (slot < 0) return count; - if (items[slot] == NULL) + if (items[slot] == nullptr) { items[slot] = shared_ptr( new ItemInstance(type, 0, itemInstance->getAuxValue()) ); // 4J Stu - Brought forward from 1.2 @@ -272,7 +272,7 @@ void Inventory::tick() { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { items[i]->inventoryTick(player->level, player->shared_from_this(), i, selected == i); } @@ -299,12 +299,12 @@ bool Inventory::removeResource(int type,int iAuxVal) void Inventory::removeResources(shared_ptr item) { - if(item == NULL) return; + if(item == nullptr) return; int countToRemove = item->count; for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->sameItemWithTags(item)) + if (items[i] != nullptr && items[i]->sameItemWithTags(item)) { int slotCount = items[i]->count; items[i]->count -= countToRemove; @@ -348,7 +348,7 @@ int Inventory::countResource(int type, int auxVal) int count = 0; for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->id == type && + if (items[i] != nullptr && items[i]->id == type && (auxVal == -1 || items[i]->getAuxValue() == auxVal)) count += items[i]->count; } @@ -364,7 +364,7 @@ void Inventory::swapSlots(int from, int to) bool Inventory::add(shared_ptr item) { - if (item == NULL) return false; + if (item == nullptr) return false; if (item->count == 0) return false; if (!item->isDamaged()) @@ -427,7 +427,7 @@ shared_ptr Inventory::removeItem(unsigned int slot, int count) slot -= items.length; } - if (pile[slot] != NULL) + if (pile[slot] != nullptr) { if (pile[slot]->count <= count) { @@ -454,7 +454,7 @@ shared_ptr Inventory::removeItemNoUpdate(int slot) slot -= items.length; } - if (pile[slot] != NULL) + if (pile[slot] != nullptr) { shared_ptr item = pile[slot]; pile[slot] = nullptr; @@ -466,7 +466,7 @@ shared_ptr Inventory::removeItemNoUpdate(int slot) void Inventory::setItem(unsigned int slot, shared_ptr item) { #ifdef _DEBUG - if(item!=NULL) + if(item!=nullptr) { wstring itemstring=item->toString(); app.DebugPrintf("Inventory::setItem - slot = %d,\t item = %d ",slot,item->id); @@ -474,7 +474,7 @@ void Inventory::setItem(unsigned int slot, shared_ptr item) app.DebugPrintf("\n"); } #else - if(item!=NULL) + if(item!=nullptr) { app.DebugPrintf("Inventory::setItem - slot = %d,\t item = %d, aux = %d\n",slot,item->id,item->getAuxValue()); } @@ -504,7 +504,7 @@ void Inventory::setItem(unsigned int slot, shared_ptr item) float Inventory::getDestroySpeed(Tile *tile) { float speed = 1.0f; - if (items[selected] != NULL) speed *= items[selected]->getDestroySpeed(tile); + if (items[selected] != nullptr) speed *= items[selected]->getDestroySpeed(tile); return speed; } @@ -512,7 +512,7 @@ ListTag *Inventory::save(ListTag *listTag) { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i)); @@ -522,7 +522,7 @@ ListTag *Inventory::save(ListTag *listTag) } for (unsigned int i = 0; i < armor.length; i++) { - if (armor[i] != NULL) + if (armor[i] != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i + 100)); @@ -535,15 +535,15 @@ ListTag *Inventory::save(ListTag *listTag) void Inventory::load(ListTag *inventoryList) { - if( items.data != NULL) + if( items.data != nullptr) { delete[] items.data; - items.data = NULL; + items.data = nullptr; } - if( armor.data != NULL) + if( armor.data != nullptr) { delete[] armor.data; - armor.data = NULL; + armor.data = nullptr; } items = ItemInstanceArray( INVENTORY_SIZE ); @@ -553,7 +553,7 @@ void Inventory::load(ListTag *inventoryList) CompoundTag *tag = inventoryList->get(i); unsigned int slot = tag->getByte(L"Slot") & 0xff; shared_ptr item = shared_ptr( ItemInstance::fromTag(tag) ); - if (item != NULL) + if (item != nullptr) { if (slot >= 0 && slot < items.length) items[slot] = item; if (slot >= 100 && slot < armor.length + 100) armor[slot - 100] = item; @@ -614,7 +614,7 @@ bool Inventory::canDestroy(Tile *tile) if (tile->material->isAlwaysDestroyable()) return true; shared_ptr item = getItem(selected); - if (item != NULL) return item->canDestroySpecial(tile); + if (item != nullptr) return item->canDestroySpecial(tile); return false; } @@ -628,7 +628,7 @@ int Inventory::getArmorValue() int val = 0; for (unsigned int i = 0; i < armor.length; i++) { - if (armor[i] != NULL && dynamic_cast( armor[i]->getItem() ) != NULL ) + if (armor[i] != nullptr && dynamic_cast( armor[i]->getItem() ) != nullptr ) { int baseProtection = dynamic_cast(armor[i]->getItem())->defense; @@ -647,7 +647,7 @@ void Inventory::hurtArmor(float dmg) } for (unsigned int i = 0; i < armor.length; i++) { - if (armor[i] != NULL && dynamic_cast( armor[i]->getItem() ) != NULL ) + if (armor[i] != nullptr && dynamic_cast( armor[i]->getItem() ) != nullptr ) { armor[i]->hurtAndBreak( static_cast(dmg), dynamic_pointer_cast( player->shared_from_this() ) ); if (armor[i]->count == 0) @@ -662,7 +662,7 @@ void Inventory::dropAll() { for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { player->drop(items[i], true); items[i] = nullptr; @@ -670,7 +670,7 @@ void Inventory::dropAll() } for (unsigned int i = 0; i < armor.length; i++) { - if (armor[i] != NULL) + if (armor[i] != nullptr) { player->drop(armor[i], true); armor[i] = nullptr; @@ -699,8 +699,8 @@ bool Inventory::isSame(shared_ptr copy) bool Inventory::isSame(shared_ptr a, shared_ptr b) { - if (a == NULL && b == NULL) return true; - if (a == NULL || b == NULL) return false; + if (a == nullptr && b == nullptr) return true; + if (a == nullptr || b == nullptr) return false; return a->id == b->id && a->count == b->count && a->getAuxValue() == b->getAuxValue(); } @@ -708,14 +708,14 @@ bool Inventory::isSame(shared_ptr a, shared_ptr b) shared_ptr Inventory::copy() { - shared_ptr copy = shared_ptr( new Inventory(NULL) ); + shared_ptr copy = shared_ptr( new Inventory(nullptr) ); for (unsigned int i = 0; i < items.length; i++) { - copy->items[i] = items[i] != NULL ? items[i]->copy() : nullptr; + copy->items[i] = items[i] != nullptr ? items[i]->copy() : nullptr; } for (unsigned int i = 0; i < armor.length; i++) { - copy->armor[i] = armor[i] != NULL ? armor[i]->copy() : nullptr; + copy->armor[i] = armor[i] != nullptr ? armor[i]->copy() : nullptr; } return copy; } @@ -742,11 +742,11 @@ bool Inventory::contains(shared_ptr itemInstance) { for (unsigned int i = 0; i < armor.length; i++) { - if (armor[i] != NULL && armor[i]->sameItem(itemInstance)) return true; + if (armor[i] != nullptr && armor[i]->sameItem(itemInstance)) return true; } for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->sameItem(itemInstance)) return true; + if (items[i] != nullptr && items[i]->sameItem(itemInstance)) return true; } return false; } @@ -782,15 +782,15 @@ void Inventory::replaceWith(shared_ptr other) int Inventory::countMatches(shared_ptr itemInstance) { - if(itemInstance == NULL) return 0; + if(itemInstance == nullptr) return 0; int count = 0; //for (unsigned int i = 0; i < armor.length; i++) //{ - // if (armor[i] != NULL && armor[i]->sameItem(itemInstance)) count += items[i]->count; + // if (armor[i] != nullptr && armor[i]->sameItem(itemInstance)) count += items[i]->count; //} for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL && items[i]->sameItemWithTags(itemInstance)) count += items[i]->count; + if (items[i] != nullptr && items[i]->sameItemWithTags(itemInstance)) count += items[i]->count; } return count; } diff --git a/Minecraft.World/InventoryMenu.cpp b/Minecraft.World/InventoryMenu.cpp index ae5d92696..2b0e9e80f 100644 --- a/Minecraft.World/InventoryMenu.cpp +++ b/Minecraft.World/InventoryMenu.cpp @@ -77,7 +77,7 @@ void InventoryMenu::removed(shared_ptr player) for (int i = 0; i < 4; i++) { shared_ptr item = craftSlots->removeItemNoUpdate(i); - if (item != NULL) + if (item != nullptr) { player->drop(item); craftSlots->setItem(i, nullptr); @@ -102,7 +102,7 @@ shared_ptr InventoryMenu::quickMoveStack(shared_ptr player Slot *BootsSlot = slots.at(ARMOR_SLOT_START+3); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -240,7 +240,7 @@ shared_ptr InventoryMenu::clicked(int slotIndex, int buttonNum, in for (int i = ARMOR_SLOT_START; i < ARMOR_SLOT_END; i++) { Slot *slot = slots.at(i); - if ( (slot==NULL) || (!slot->hasItem()) || (slot->getItem()->getItem()->id != ironItems[i-ARMOR_SLOT_START]) ) + if ( (slot==nullptr) || (!slot->hasItem()) || (slot->getItem()->getItem()->id != ironItems[i-ARMOR_SLOT_START]) ) { return out; } diff --git a/Minecraft.World/Item.cpp b/Minecraft.World/Item.cpp index 5b3838dbc..ffb310704 100644 --- a/Minecraft.World/Item.cpp +++ b/Minecraft.World/Item.cpp @@ -32,224 +32,224 @@ Random *Item::random = new Random(); ItemArray Item::items = ItemArray( ITEM_NUM_COUNT ); -Item *Item::shovel_iron = NULL; -Item *Item::pickAxe_iron = NULL; -Item *Item::hatchet_iron = NULL; -Item *Item::flintAndSteel = NULL; -Item *Item::apple = NULL; -BowItem *Item::bow = NULL; -Item *Item::arrow = NULL; -Item *Item::coal = NULL; -Item *Item::diamond = NULL; -Item *Item::ironIngot = NULL; -Item *Item::goldIngot = NULL; -Item *Item::sword_iron = NULL; - -Item *Item::sword_wood = NULL; -Item *Item::shovel_wood = NULL; -Item *Item::pickAxe_wood = NULL; -Item *Item::hatchet_wood = NULL; - -Item *Item::sword_stone = NULL; -Item *Item::shovel_stone = NULL; -Item *Item::pickAxe_stone = NULL; -Item *Item::hatchet_stone = NULL; - -Item *Item::sword_diamond = NULL; -Item *Item::shovel_diamond = NULL; -Item *Item::pickAxe_diamond = NULL; -Item *Item::hatchet_diamond = NULL; - -Item *Item::stick = NULL; -Item *Item::bowl = NULL; -Item *Item::mushroomStew = NULL; - -Item *Item::sword_gold = NULL; -Item *Item::shovel_gold = NULL; -Item *Item::pickAxe_gold = NULL; -Item *Item::hatchet_gold = NULL; - -Item *Item::string = NULL; -Item *Item::feather = NULL; -Item *Item::gunpowder = NULL; - -Item *Item::hoe_wood = NULL; -Item *Item::hoe_stone = NULL; -Item *Item::hoe_iron = NULL; -Item *Item::hoe_diamond = NULL; -Item *Item::hoe_gold = NULL; - -Item *Item::seeds_wheat = NULL; -Item *Item::wheat = NULL; -Item *Item::bread = NULL; - -ArmorItem *Item::helmet_leather = NULL; -ArmorItem *Item::chestplate_leather = NULL; -ArmorItem *Item::leggings_leather = NULL; -ArmorItem *Item::boots_leather = NULL; - -ArmorItem *Item::helmet_chain = NULL; -ArmorItem *Item::chestplate_chain = NULL; -ArmorItem *Item::leggings_chain = NULL; -ArmorItem *Item::boots_chain = NULL; - -ArmorItem *Item::helmet_iron = NULL; -ArmorItem *Item::chestplate_iron = NULL; -ArmorItem *Item::leggings_iron = NULL; -ArmorItem *Item::boots_iron = NULL; - -ArmorItem *Item::helmet_diamond = NULL; -ArmorItem *Item::chestplate_diamond = NULL; -ArmorItem *Item::leggings_diamond = NULL; -ArmorItem *Item::boots_diamond = NULL; - -ArmorItem *Item::helmet_gold = NULL; -ArmorItem *Item::chestplate_gold = NULL; -ArmorItem *Item::leggings_gold = NULL; -ArmorItem *Item::boots_gold = NULL; - -Item *Item::flint = NULL; -Item *Item::porkChop_raw = NULL; -Item *Item::porkChop_cooked = NULL; -Item *Item::painting = NULL; - -Item *Item::apple_gold = NULL; - -Item *Item::sign = NULL; -Item *Item::door_wood = NULL; - -Item *Item::bucket_empty = NULL; -Item *Item::bucket_water = NULL; -Item *Item::bucket_lava = NULL; - -Item *Item::minecart = NULL; -Item *Item::saddle = NULL; -Item *Item::door_iron = NULL; -Item *Item::redStone = NULL; -Item *Item::snowBall = NULL; - -Item *Item::boat = NULL; - -Item *Item::leather = NULL; -Item *Item::bucket_milk = NULL; -Item *Item::brick = NULL; -Item *Item::clay = NULL; -Item *Item::reeds = NULL; -Item *Item::paper = NULL; -Item *Item::book = NULL; -Item *Item::slimeBall = NULL; -Item *Item::minecart_chest = NULL; -Item *Item::minecart_furnace = NULL; -Item *Item::egg = NULL; -Item *Item::compass = NULL; -FishingRodItem *Item::fishingRod = NULL; -Item *Item::clock = NULL; -Item *Item::yellowDust = NULL; -Item *Item::fish_raw = NULL; -Item *Item::fish_cooked = NULL; - -Item *Item::dye_powder = NULL; -Item *Item::bone = NULL; -Item *Item::sugar = NULL; -Item *Item::cake = NULL; - -Item *Item::bed = NULL; - -Item *Item::repeater = NULL; -Item *Item::cookie = NULL; - -MapItem *Item::map = NULL; - -Item *Item::record_01 = NULL; -Item *Item::record_02 = NULL; -Item *Item::record_03 = NULL; -Item *Item::record_04 = NULL; -Item *Item::record_05 = NULL; -Item *Item::record_06 = NULL; -Item *Item::record_07 = NULL; -Item *Item::record_08 = NULL; -Item *Item::record_09 = NULL; -Item *Item::record_10 = NULL; -Item *Item::record_11 = NULL; -Item *Item::record_12 = NULL; - -ShearsItem *Item::shears = NULL; - -Item *Item::melon = NULL; - -Item *Item::seeds_pumpkin = NULL; -Item *Item::seeds_melon = NULL; - -Item *Item::beef_raw = NULL; -Item *Item::beef_cooked = NULL; -Item *Item::chicken_raw = NULL; -Item *Item::chicken_cooked = NULL; -Item *Item::rotten_flesh = NULL; - -Item *Item::enderPearl = NULL; - -Item *Item::blazeRod = NULL; -Item *Item::ghastTear = NULL; -Item *Item::goldNugget = NULL; -Item *Item::netherwart_seeds = NULL; -PotionItem *Item::potion = NULL; -Item *Item::glassBottle = NULL; -Item *Item::spiderEye = NULL; -Item *Item::fermentedSpiderEye = NULL; -Item *Item::blazePowder = NULL; -Item *Item::magmaCream = NULL; -Item *Item::brewingStand = NULL; -Item *Item::cauldron = NULL; -Item *Item::eyeOfEnder = NULL; -Item *Item::speckledMelon = NULL; - -Item *Item::spawnEgg = NULL; - -Item *Item::expBottle = NULL; +Item *Item::shovel_iron = nullptr; +Item *Item::pickAxe_iron = nullptr; +Item *Item::hatchet_iron = nullptr; +Item *Item::flintAndSteel = nullptr; +Item *Item::apple = nullptr; +BowItem *Item::bow = nullptr; +Item *Item::arrow = nullptr; +Item *Item::coal = nullptr; +Item *Item::diamond = nullptr; +Item *Item::ironIngot = nullptr; +Item *Item::goldIngot = nullptr; +Item *Item::sword_iron = nullptr; + +Item *Item::sword_wood = nullptr; +Item *Item::shovel_wood = nullptr; +Item *Item::pickAxe_wood = nullptr; +Item *Item::hatchet_wood = nullptr; + +Item *Item::sword_stone = nullptr; +Item *Item::shovel_stone = nullptr; +Item *Item::pickAxe_stone = nullptr; +Item *Item::hatchet_stone = nullptr; + +Item *Item::sword_diamond = nullptr; +Item *Item::shovel_diamond = nullptr; +Item *Item::pickAxe_diamond = nullptr; +Item *Item::hatchet_diamond = nullptr; + +Item *Item::stick = nullptr; +Item *Item::bowl = nullptr; +Item *Item::mushroomStew = nullptr; + +Item *Item::sword_gold = nullptr; +Item *Item::shovel_gold = nullptr; +Item *Item::pickAxe_gold = nullptr; +Item *Item::hatchet_gold = nullptr; + +Item *Item::string = nullptr; +Item *Item::feather = nullptr; +Item *Item::gunpowder = nullptr; + +Item *Item::hoe_wood = nullptr; +Item *Item::hoe_stone = nullptr; +Item *Item::hoe_iron = nullptr; +Item *Item::hoe_diamond = nullptr; +Item *Item::hoe_gold = nullptr; + +Item *Item::seeds_wheat = nullptr; +Item *Item::wheat = nullptr; +Item *Item::bread = nullptr; + +ArmorItem *Item::helmet_leather = nullptr; +ArmorItem *Item::chestplate_leather = nullptr; +ArmorItem *Item::leggings_leather = nullptr; +ArmorItem *Item::boots_leather = nullptr; + +ArmorItem *Item::helmet_chain = nullptr; +ArmorItem *Item::chestplate_chain = nullptr; +ArmorItem *Item::leggings_chain = nullptr; +ArmorItem *Item::boots_chain = nullptr; + +ArmorItem *Item::helmet_iron = nullptr; +ArmorItem *Item::chestplate_iron = nullptr; +ArmorItem *Item::leggings_iron = nullptr; +ArmorItem *Item::boots_iron = nullptr; + +ArmorItem *Item::helmet_diamond = nullptr; +ArmorItem *Item::chestplate_diamond = nullptr; +ArmorItem *Item::leggings_diamond = nullptr; +ArmorItem *Item::boots_diamond = nullptr; + +ArmorItem *Item::helmet_gold = nullptr; +ArmorItem *Item::chestplate_gold = nullptr; +ArmorItem *Item::leggings_gold = nullptr; +ArmorItem *Item::boots_gold = nullptr; + +Item *Item::flint = nullptr; +Item *Item::porkChop_raw = nullptr; +Item *Item::porkChop_cooked = nullptr; +Item *Item::painting = nullptr; + +Item *Item::apple_gold = nullptr; + +Item *Item::sign = nullptr; +Item *Item::door_wood = nullptr; + +Item *Item::bucket_empty = nullptr; +Item *Item::bucket_water = nullptr; +Item *Item::bucket_lava = nullptr; + +Item *Item::minecart = nullptr; +Item *Item::saddle = nullptr; +Item *Item::door_iron = nullptr; +Item *Item::redStone = nullptr; +Item *Item::snowBall = nullptr; + +Item *Item::boat = nullptr; + +Item *Item::leather = nullptr; +Item *Item::bucket_milk = nullptr; +Item *Item::brick = nullptr; +Item *Item::clay = nullptr; +Item *Item::reeds = nullptr; +Item *Item::paper = nullptr; +Item *Item::book = nullptr; +Item *Item::slimeBall = nullptr; +Item *Item::minecart_chest = nullptr; +Item *Item::minecart_furnace = nullptr; +Item *Item::egg = nullptr; +Item *Item::compass = nullptr; +FishingRodItem *Item::fishingRod = nullptr; +Item *Item::clock = nullptr; +Item *Item::yellowDust = nullptr; +Item *Item::fish_raw = nullptr; +Item *Item::fish_cooked = nullptr; + +Item *Item::dye_powder = nullptr; +Item *Item::bone = nullptr; +Item *Item::sugar = nullptr; +Item *Item::cake = nullptr; + +Item *Item::bed = nullptr; + +Item *Item::repeater = nullptr; +Item *Item::cookie = nullptr; + +MapItem *Item::map = nullptr; + +Item *Item::record_01 = nullptr; +Item *Item::record_02 = nullptr; +Item *Item::record_03 = nullptr; +Item *Item::record_04 = nullptr; +Item *Item::record_05 = nullptr; +Item *Item::record_06 = nullptr; +Item *Item::record_07 = nullptr; +Item *Item::record_08 = nullptr; +Item *Item::record_09 = nullptr; +Item *Item::record_10 = nullptr; +Item *Item::record_11 = nullptr; +Item *Item::record_12 = nullptr; + +ShearsItem *Item::shears = nullptr; + +Item *Item::melon = nullptr; + +Item *Item::seeds_pumpkin = nullptr; +Item *Item::seeds_melon = nullptr; + +Item *Item::beef_raw = nullptr; +Item *Item::beef_cooked = nullptr; +Item *Item::chicken_raw = nullptr; +Item *Item::chicken_cooked = nullptr; +Item *Item::rotten_flesh = nullptr; + +Item *Item::enderPearl = nullptr; + +Item *Item::blazeRod = nullptr; +Item *Item::ghastTear = nullptr; +Item *Item::goldNugget = nullptr; +Item *Item::netherwart_seeds = nullptr; +PotionItem *Item::potion = nullptr; +Item *Item::glassBottle = nullptr; +Item *Item::spiderEye = nullptr; +Item *Item::fermentedSpiderEye = nullptr; +Item *Item::blazePowder = nullptr; +Item *Item::magmaCream = nullptr; +Item *Item::brewingStand = nullptr; +Item *Item::cauldron = nullptr; +Item *Item::eyeOfEnder = nullptr; +Item *Item::speckledMelon = nullptr; + +Item *Item::spawnEgg = nullptr; + +Item *Item::expBottle = nullptr; // TU9 -Item *Item::fireball = NULL; -Item *Item::frame = NULL; +Item *Item::fireball = nullptr; +Item *Item::frame = nullptr; -Item *Item::skull = NULL; +Item *Item::skull = nullptr; // TU14 -//Item *Item::writingBook = NULL; -//Item *Item::writtenBook = NULL; +//Item *Item::writingBook = nullptr; +//Item *Item::writtenBook = nullptr; -Item *Item::emerald = NULL; +Item *Item::emerald = nullptr; -Item *Item::flowerPot = NULL; +Item *Item::flowerPot = nullptr; -Item *Item::carrots = NULL; -Item *Item::potato = NULL; -Item *Item::potatoBaked = NULL; -Item *Item::potatoPoisonous = NULL; +Item *Item::carrots = nullptr; +Item *Item::potato = nullptr; +Item *Item::potatoBaked = nullptr; +Item *Item::potatoPoisonous = nullptr; -EmptyMapItem *Item::emptyMap = NULL; +EmptyMapItem *Item::emptyMap = nullptr; -Item *Item::carrotGolden = NULL; +Item *Item::carrotGolden = nullptr; -Item *Item::carrotOnAStick = NULL; -Item *Item::netherStar = NULL; -Item *Item::pumpkinPie = NULL; -Item *Item::fireworks = NULL; -Item *Item::fireworksCharge = NULL; +Item *Item::carrotOnAStick = nullptr; +Item *Item::netherStar = nullptr; +Item *Item::pumpkinPie = nullptr; +Item *Item::fireworks = nullptr; +Item *Item::fireworksCharge = nullptr; -EnchantedBookItem *Item::enchantedBook = NULL; +EnchantedBookItem *Item::enchantedBook = nullptr; -Item *Item::comparator = NULL; -Item *Item::netherbrick = NULL; -Item *Item::netherQuartz = NULL; -Item *Item::minecart_tnt = NULL; -Item *Item::minecart_hopper = NULL; +Item *Item::comparator = nullptr; +Item *Item::netherbrick = nullptr; +Item *Item::netherQuartz = nullptr; +Item *Item::minecart_tnt = nullptr; +Item *Item::minecart_hopper = nullptr; -Item *Item::horseArmorMetal = NULL; -Item *Item::horseArmorGold = NULL; -Item *Item::horseArmorDiamond = NULL; -Item *Item::lead = NULL; -Item *Item::nameTag = NULL; +Item *Item::horseArmorMetal = nullptr; +Item *Item::horseArmorGold = nullptr; +Item *Item::horseArmorDiamond = nullptr; +Item *Item::lead = nullptr; +Item *Item::nameTag = nullptr; void Item::staticCtor() @@ -568,11 +568,11 @@ Item::Item(int id) : id( 256 + id ) { maxStackSize = Item::MAX_STACK_SIZE; maxDamage = 0; - icon = NULL; + icon = nullptr; m_handEquipped = false; m_isStackedByData = false; - craftingRemainingItem = NULL; + craftingRemainingItem = nullptr; potionBrewingFormula = L""; m_iMaterial=eMaterial_undefined; @@ -583,7 +583,7 @@ Item::Item(int id) : id( 256 + id ) //string descriptionId; //this->id = 256 + id; - if (items[256 + id] != NULL) + if (items[256 + id] != nullptr) { app.DebugPrintf("CONFLICT @ %d" , id); } @@ -837,7 +837,7 @@ Item *Item::getCraftingRemainingItem() bool Item::hasCraftingRemainingItem() { - return craftingRemainingItem != NULL; + return craftingRemainingItem != nullptr; } wstring Item::getName() diff --git a/Minecraft.World/ItemDispenseBehaviors.cpp b/Minecraft.World/ItemDispenseBehaviors.cpp index 8d051c735..0c9563261 100644 --- a/Minecraft.World/ItemDispenseBehaviors.cpp +++ b/Minecraft.World/ItemDispenseBehaviors.cpp @@ -104,7 +104,7 @@ shared_ptr SpawnEggDispenseBehavior::execute(BlockSource *source, shared_ptr entity = SpawnEggItem::spawnMobAt(source->getWorld(), dispensed->getAuxValue(), spawnX, spawnY, spawnZ, &iResult); // 4J-JEV: Added in-case spawn limit is encountered. - if (entity == NULL) + if (entity == nullptr) { outcome = LEFT_ITEM; return dispensed; diff --git a/Minecraft.World/ItemEntity.cpp b/Minecraft.World/ItemEntity.cpp index c012a9123..e1cc92755 100644 --- a/Minecraft.World/ItemEntity.cpp +++ b/Minecraft.World/ItemEntity.cpp @@ -66,7 +66,7 @@ ItemEntity::ItemEntity(Level *level) : Entity( level ) void ItemEntity::defineSynchedData() { - getEntityData()->defineNULL(DATA_ITEM, NULL); + getEntityData()->defineNULL(DATA_ITEM, nullptr); } void ItemEntity::tick() @@ -192,7 +192,7 @@ bool ItemEntity::hurt(DamageSource *source, float damage) if (level->isClientSide ) return false; if (isInvulnerable()) return false; - if (getItem() != NULL && getItem()->id == Item::netherStar_Id && source->isExplosion()) return false; + if (getItem() != nullptr && getItem()->id == Item::netherStar_Id && source->isExplosion()) return false; markHurt(); health -= damage; if (health <= 0) @@ -206,7 +206,7 @@ void ItemEntity::addAdditonalSaveData(CompoundTag *entityTag) { entityTag->putShort(L"Health", static_cast(health)); entityTag->putShort(L"Age", static_cast(age)); - if (getItem() != NULL) entityTag->putCompound(L"Item", getItem()->save(new CompoundTag())); + if (getItem() != nullptr) entityTag->putCompound(L"Item", getItem()->save(new CompoundTag())); } void ItemEntity::readAdditionalSaveData(CompoundTag *tag) @@ -215,7 +215,7 @@ void ItemEntity::readAdditionalSaveData(CompoundTag *tag) age = tag->getShort(L"Age"); CompoundTag *itemTag = tag->getCompound(L"Item"); setItem(ItemInstance::fromTag(itemTag)); - if (getItem() == NULL) remove(); + if (getItem() == nullptr) remove(); } void ItemEntity::playerTouch(shared_ptr player) @@ -280,9 +280,9 @@ shared_ptr ItemEntity::getItem() { shared_ptr result = getEntityData()->getItemInstance(DATA_ITEM); - if (result == NULL) + if (result == nullptr) { - if (level != NULL) + if (level != nullptr) { app.DebugPrintf("Item entity %d has no item?!\n", entityId); //level.getLogger().severe("Item entity " + entityId + " has no item?!"); diff --git a/Minecraft.World/ItemFrame.cpp b/Minecraft.World/ItemFrame.cpp index f8f4731b0..7f1e0dcbc 100644 --- a/Minecraft.World/ItemFrame.cpp +++ b/Minecraft.World/ItemFrame.cpp @@ -37,7 +37,7 @@ ItemFrame::ItemFrame(Level *level, int xTile, int yTile, int zTile, int dir) : H void ItemFrame::defineSynchedData() { - getEntityData()->defineNULL(DATA_ITEM, NULL); + getEntityData()->defineNULL(DATA_ITEM, nullptr); getEntityData()->define(DATA_ROTATION, static_cast(0)); } @@ -52,7 +52,7 @@ void ItemFrame::dropItem(shared_ptr causedBy) { shared_ptr item = getItem(); - if (causedBy != NULL && causedBy->instanceof(eTYPE_PLAYER)) + if (causedBy != nullptr && causedBy->instanceof(eTYPE_PLAYER)) { if (dynamic_pointer_cast(causedBy)->abilities.instabuild) { @@ -62,7 +62,7 @@ void ItemFrame::dropItem(shared_ptr causedBy) } spawnAtLocation( shared_ptr(new ItemInstance(Item::frame) ), 0); - if ( (item != NULL) && (random->nextFloat() < dropChance) ) + if ( (item != nullptr) && (random->nextFloat() < dropChance) ) { item = item->copy(); removeFramedMap(item); @@ -72,7 +72,7 @@ void ItemFrame::dropItem(shared_ptr causedBy) void ItemFrame::removeFramedMap(shared_ptr item) { - if (item == NULL) return; + if (item == nullptr) return; if (item->id == Item::map_Id) { shared_ptr mapItemSavedData = Item::map->getSavedData(item, level); @@ -89,7 +89,7 @@ shared_ptr ItemFrame::getItem() void ItemFrame::setItem(shared_ptr item) { - if(item != NULL) + if(item != nullptr) { item = item->copy(); item->count = 1; @@ -112,7 +112,7 @@ void ItemFrame::setRotation(int rotation) void ItemFrame::addAdditonalSaveData(CompoundTag *tag) { - if (getItem() != NULL) + if (getItem() != nullptr) { tag->putCompound(L"Item", getItem()->save(new CompoundTag())); tag->putByte(L"ItemRotation", static_cast(getRotation())); @@ -124,7 +124,7 @@ void ItemFrame::addAdditonalSaveData(CompoundTag *tag) void ItemFrame::readAdditionalSaveData(CompoundTag *tag) { CompoundTag *itemTag = tag->getCompound(L"Item"); - if (itemTag != NULL && !itemTag->isEmpty()) + if (itemTag != nullptr && !itemTag->isEmpty()) { setItem(ItemInstance::fromTag(itemTag)); setRotation(tag->getByte(L"ItemRotation")); @@ -141,11 +141,11 @@ bool ItemFrame::interact(shared_ptr player) return false; } - if (getItem() == NULL) + if (getItem() == nullptr) { shared_ptr item = player->getCarriedItem(); - if (item != NULL) + if (item != nullptr) { if (!level->isClientSide)//isClientSide) { diff --git a/Minecraft.World/ItemInstance.cpp b/Minecraft.World/ItemInstance.cpp index e344e4cd6..5452b72c5 100644 --- a/Minecraft.World/ItemInstance.cpp +++ b/Minecraft.World/ItemInstance.cpp @@ -25,7 +25,7 @@ void ItemInstance::_init(int id, int count, int auxValue) this->id = id; this->count = count; this->auxValue = auxValue; - this->tag = NULL; + this->tag = nullptr; this->frame = nullptr; // 4J-PB - for trading menu this->m_bForceNumberDisplay=false; @@ -81,18 +81,18 @@ shared_ptr ItemInstance::fromTag(CompoundTag *itemTag) { shared_ptr itemInstance = shared_ptr(new ItemInstance()); itemInstance->load(itemTag); - return itemInstance->getItem() != NULL ? itemInstance : nullptr; + return itemInstance->getItem() != nullptr ? itemInstance : nullptr; } ItemInstance::~ItemInstance() { - if(tag != NULL) delete tag; + if(tag != nullptr) delete tag; } shared_ptr ItemInstance::remove(int count) { shared_ptr ii = shared_ptr( new ItemInstance(id, count, auxValue) ); - if (tag != NULL) ii->tag = static_cast(tag->copy()); + if (tag != nullptr) ii->tag = static_cast(tag->copy()); this->count -= count; // 4J Stu Fix for duplication glitch, make sure that item count is in range @@ -148,7 +148,7 @@ CompoundTag *ItemInstance::save(CompoundTag *compoundTag) compoundTag->putShort(L"id", static_cast(id)); compoundTag->putByte(L"Count", static_cast(count)); compoundTag->putShort(L"Damage", static_cast(auxValue)); - if (tag != NULL) compoundTag->put(L"tag", tag->copy()); + if (tag != nullptr) compoundTag->put(L"tag", tag->copy()); return compoundTag; } @@ -257,7 +257,7 @@ bool ItemInstance::hurt(int dmg, Random *random) void ItemInstance::hurtAndBreak(int dmg, shared_ptr owner) { shared_ptr player = dynamic_pointer_cast(owner); - if (player != NULL && player->abilities.instabuild) return; + if (player != nullptr && player->abilities.instabuild) return; if (!isDamageableItem()) return; if (hurt(dmg, owner->getRandom())) @@ -265,10 +265,10 @@ void ItemInstance::hurtAndBreak(int dmg, shared_ptr owner) owner->breakItem(shared_from_this()); count--; - if (player != NULL) + if (player != nullptr) { //player->awardStat(Stats::itemBroke[id], 1); - if (count == 0 && dynamic_cast( getItem() ) != NULL) + if (count == 0 && dynamic_cast( getItem() ) != nullptr) { player->removeSelectedItem(); } @@ -303,7 +303,7 @@ bool ItemInstance::interactEnemy(shared_ptr player, shared_ptr ItemInstance::copy() const { shared_ptr copy = shared_ptr( new ItemInstance(id, count, auxValue) ); - if (tag != NULL) + if (tag != nullptr) { copy->tag = static_cast(tag->copy()); } @@ -314,7 +314,7 @@ shared_ptr ItemInstance::copy() const ItemInstance *ItemInstance::copy_not_shared() const { ItemInstance *copy = new ItemInstance(id, count, auxValue); - if (tag != NULL) + if (tag != nullptr) { copy->tag = static_cast(tag->copy()); if (!copy->tag->equals(tag)) @@ -328,14 +328,14 @@ ItemInstance *ItemInstance::copy_not_shared() const // 4J Brought forward from 1.2 bool ItemInstance::tagMatches(shared_ptr a, shared_ptr b) { - if (a == NULL && b == NULL) return true; - if (a == NULL || b == NULL) return false; + if (a == nullptr && b == nullptr) return true; + if (a == nullptr || b == nullptr) return false; - if (a->tag == NULL && b->tag != NULL) + if (a->tag == nullptr && b->tag != nullptr) { return false; } - if (a->tag != NULL && !a->tag->equals(b->tag)) + if (a->tag != nullptr && !a->tag->equals(b->tag)) { return false; } @@ -344,8 +344,8 @@ bool ItemInstance::tagMatches(shared_ptr a, shared_ptr a, shared_ptr b) { - if (a == NULL && b == NULL) return true; - if (a == NULL || b == NULL) return false; + if (a == nullptr && b == nullptr) return true; + if (a == nullptr || b == nullptr) return false; return a->matches(b); } @@ -354,11 +354,11 @@ bool ItemInstance::matches(shared_ptr b) if (count != b->count) return false; if (id != b->id) return false; if (auxValue != b->auxValue) return false; - if (tag == NULL && b->tag != NULL) + if (tag == nullptr && b->tag != nullptr) { return false; } - if (tag != NULL && !tag->equals(b->tag)) + if (tag != nullptr && !tag->equals(b->tag)) { return false; } @@ -381,11 +381,11 @@ bool ItemInstance::sameItemWithTags(shared_ptr b) { if (id != b->id) return false; if (auxValue != b->auxValue) return false; - if (tag == NULL && b->tag != NULL) + if (tag == nullptr && b->tag != nullptr) { return false; } - if (tag != NULL && !tag->equals(b->tag)) + if (tag != nullptr && !tag->equals(b->tag)) { return false; } @@ -417,7 +417,7 @@ ItemInstance *ItemInstance::setDescriptionId(unsigned int id) shared_ptr ItemInstance::clone(shared_ptr item) { - return item == NULL ? nullptr : item->copy(); + return item == nullptr ? nullptr : item->copy(); } wstring ItemInstance::toString() @@ -426,9 +426,9 @@ wstring ItemInstance::toString() std::wostringstream oss; // 4J-PB - TODO - temp fix until ore recipe issue is fixed - if(Item::items[id]==NULL) + if(Item::items[id]==nullptr) { - oss << std::dec << count << L"x" << L" Item::items[id] is NULL " << L"@" << auxValue; + oss << std::dec << count << L"x" << L" Item::items[id] is nullptr " << L"@" << auxValue; } else { @@ -479,7 +479,7 @@ void ItemInstance::releaseUsing(Level *level, shared_ptr player, int dur // 4J Stu - Brought forward these functions for enchanting/game rules bool ItemInstance::hasTag() { - return tag != NULL; + return tag != nullptr; } CompoundTag *ItemInstance::getTag() @@ -489,9 +489,9 @@ CompoundTag *ItemInstance::getTag() ListTag *ItemInstance::getEnchantmentTags() { - if (tag == NULL) + if (tag == nullptr) { - return NULL; + return nullptr; } return static_cast *>(tag->get(L"ench")); } @@ -506,7 +506,7 @@ wstring ItemInstance::getHoverName() { wstring title = getItem()->getHoverName(shared_from_this()); - if (tag != NULL && tag->contains(L"display")) + if (tag != nullptr && tag->contains(L"display")) { CompoundTag *display = tag->getCompound(L"display"); @@ -521,14 +521,14 @@ wstring ItemInstance::getHoverName() void ItemInstance::setHoverName(const wstring &name) { - if (tag == NULL) tag = new CompoundTag(); + if (tag == nullptr) tag = new CompoundTag(); if (!tag->contains(L"display")) tag->putCompound(L"display", new CompoundTag()); tag->getCompound(L"display")->putString(L"Name", name); } void ItemInstance::resetHoverName() { - if (tag == NULL) return; + if (tag == nullptr) return; if (!tag->contains(L"display")) return; CompoundTag *display = tag->getCompound(L"display"); display->remove(L"Name"); @@ -539,14 +539,14 @@ void ItemInstance::resetHoverName() if (tag->isEmpty()) { - setTag(NULL); + setTag(nullptr); } } } bool ItemInstance::hasCustomHoverName() { - if (tag == NULL) return false; + if (tag == nullptr) return false; if (!tag->contains(L"display")) return false; return tag->getCompound(L"display")->contains(L"Name"); } @@ -598,14 +598,14 @@ vector *ItemInstance::getHoverText(shared_ptr player, bool a if (hasTag()) { ListTag *list = getEnchantmentTags(); - if (list != NULL) + if (list != nullptr) { for (int i = 0; i < list->size(); i++) { int type = list->get(i)->getShort((wchar_t *)TAG_ENCH_ID); int level = list->get(i)->getShort((wchar_t *)TAG_ENCH_LEVEL); - if (Enchantment::enchantments[type] != NULL) + if (Enchantment::enchantments[type] != nullptr) { wstring unformatted = L""; lines->push_back(Enchantment::enchantments[type]->getFullname(level)); @@ -693,14 +693,14 @@ vector *ItemInstance::getHoverTextOnly(shared_ptr player, bo if (hasTag()) { ListTag *list = getEnchantmentTags(); - if (list != NULL) + if (list != nullptr) { for (int i = 0; i < list->size(); i++) { int type = list->get(i)->getShort((wchar_t *)TAG_ENCH_ID); int level = list->get(i)->getShort((wchar_t *)TAG_ENCH_LEVEL); - if (Enchantment::enchantments[type] != NULL) + if (Enchantment::enchantments[type] != nullptr) { wstring unformatted = L""; lines->push_back(Enchantment::enchantments[type]->getFullname(level)); @@ -730,7 +730,7 @@ bool ItemInstance::isEnchantable() void ItemInstance::enchant(const Enchantment *enchantment, int level) { - if (tag == NULL) this->setTag(new CompoundTag()); + if (tag == nullptr) this->setTag(new CompoundTag()); if (!tag->contains(L"ench")) tag->put(L"ench", new ListTag(L"ench")); ListTag *list = static_cast *>(tag->get(L"ench")); @@ -742,13 +742,13 @@ void ItemInstance::enchant(const Enchantment *enchantment, int level) bool ItemInstance::isEnchanted() { - if (tag != NULL && tag->contains(L"ench")) return true; + if (tag != nullptr && tag->contains(L"ench")) return true; return false; } void ItemInstance::addTagElement(wstring name, Tag *tag) { - if (this->tag == NULL) + if (this->tag == nullptr) { setTag(new CompoundTag()); } @@ -762,7 +762,7 @@ bool ItemInstance::mayBePlacedInAdventureMode() bool ItemInstance::isFramed() { - return frame != NULL; + return frame != nullptr; } void ItemInstance::setFramed(shared_ptr frame) @@ -795,7 +795,7 @@ void ItemInstance::setRepairCost(int cost) attrAttrModMap *ItemInstance::getAttributeModifiers() { - attrAttrModMap *result = NULL; + attrAttrModMap *result = nullptr; if (hasTag() && tag->contains(L"AttributeModifiers")) { @@ -824,8 +824,8 @@ attrAttrModMap *ItemInstance::getAttributeModifiers() void ItemInstance::set4JData(int data) { - if(tag == NULL && data == 0) return; - if (tag == NULL) this->setTag(new CompoundTag()); + if(tag == nullptr && data == 0) return; + if (tag == nullptr) this->setTag(new CompoundTag()); if (tag->contains(L"4jdata")) { @@ -840,7 +840,7 @@ void ItemInstance::set4JData(int data) int ItemInstance::get4JData() { - if(tag == NULL || !tag->contains(L"4jdata")) return 0; + if(tag == nullptr || !tag->contains(L"4jdata")) return 0; else { IntTag *dataTag = static_cast(tag->get(L"4jdata")); diff --git a/Minecraft.World/JukeboxTile.cpp b/Minecraft.World/JukeboxTile.cpp index cf53a751b..387ad9f2e 100644 --- a/Minecraft.World/JukeboxTile.cpp +++ b/Minecraft.World/JukeboxTile.cpp @@ -31,7 +31,7 @@ void JukeboxTile::Entity::save(CompoundTag *tag) { TileEntity::save(tag); - if (getRecord() != NULL) + if (getRecord() != nullptr) { tag->putCompound(L"RecordItem", getRecord()->save(new CompoundTag())); @@ -63,7 +63,7 @@ void JukeboxTile::Entity::setRecord(shared_ptr record) JukeboxTile::JukeboxTile(int id) : BaseEntityTile(id, Material::wood) { - iconTop = NULL; + iconTop = nullptr; } Icon *JukeboxTile::getTexture(int face, int data) @@ -107,10 +107,10 @@ void JukeboxTile::dropRecording(Level *level, int x, int y, int z) if (level->isClientSide) return; shared_ptr rte = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if( rte == NULL ) return; + if( rte == nullptr ) return; shared_ptr oldRecord = rte->getRecord(); - if (oldRecord == NULL) return; + if (oldRecord == nullptr) return; level->levelEvent(LevelEvent::SOUND_PLAY_RECORDING, x, y, z, 0); @@ -163,5 +163,5 @@ bool JukeboxTile::hasAnalogOutputSignal() int JukeboxTile::getAnalogOutputSignal(Level *level, int x, int y, int z, int dir) { shared_ptr record = dynamic_pointer_cast( level->getTileEntity(x, y, z))->getRecord(); - return record == NULL ? Redstone::SIGNAL_NONE : record->id + 1 - Item::record_01_Id; + return record == nullptr ? Redstone::SIGNAL_NONE : record->id + 1 - Item::record_01_Id; } \ No newline at end of file diff --git a/Minecraft.World/LakeFeature.cpp b/Minecraft.World/LakeFeature.cpp index ac240e612..a25a7ece3 100644 --- a/Minecraft.World/LakeFeature.cpp +++ b/Minecraft.World/LakeFeature.cpp @@ -24,8 +24,8 @@ bool LakeFeature::place(Level *level, Random *random, int x, int y, int z) bool grid[16*16*8] = {0}; - LevelGenerationOptions *levelGenOptions = NULL; - if( app.getLevelGenerationOptions() != NULL ) + LevelGenerationOptions *levelGenOptions = nullptr; + if( app.getLevelGenerationOptions() != nullptr ) { levelGenOptions = app.getLevelGenerationOptions(); diff --git a/Minecraft.World/LargeFireball.cpp b/Minecraft.World/LargeFireball.cpp index 9f8da92c7..48f199d9b 100644 --- a/Minecraft.World/LargeFireball.cpp +++ b/Minecraft.World/LargeFireball.cpp @@ -23,7 +23,7 @@ void LargeFireball::onHit(HitResult *res) { if (!level->isClientSide) { - if (res->entity != NULL) + if (res->entity != nullptr) { DamageSource *damageSource = DamageSource::fireball(dynamic_pointer_cast( shared_from_this() ), owner); res->entity->hurt(damageSource, 6); diff --git a/Minecraft.World/Layer.cpp b/Minecraft.World/Layer.cpp index 5187af7e0..b604cabca 100644 --- a/Minecraft.World/Layer.cpp +++ b/Minecraft.World/Layer.cpp @@ -123,7 +123,7 @@ Layer::Layer(__int64 seedMixup) void Layer::init(__int64 seed) { this->seed = seed; - if (parent != NULL) parent->init(seed); + if (parent != nullptr) parent->init(seed); this->seed *= this->seed * 6364136223846793005l + 1442695040888963407l; this->seed += seedMixup; this->seed *= this->seed * 6364136223846793005l + 1442695040888963407l; diff --git a/Minecraft.World/LeafTile.cpp b/Minecraft.World/LeafTile.cpp index 684618a78..d66c9bda3 100644 --- a/Minecraft.World/LeafTile.cpp +++ b/Minecraft.World/LeafTile.cpp @@ -17,7 +17,7 @@ const wstring LeafTile::TEXTURES[2][4] = { {L"leaves", L"leaves_spruce", L"leave LeafTile::LeafTile(int id) : TransparentTile(id, Material::leaves, false, isSolidRender()) { - checkBuffer = NULL; + checkBuffer = nullptr; fancyTextureSet = 0; setTicking(true); } @@ -123,7 +123,7 @@ void LeafTile::tick(Level *level, int x, int y, int z, Random *random) int W = 32; int WW = W * W; int WO = W / 2; - if (checkBuffer == NULL) + if (checkBuffer == nullptr) { checkBuffer = new int[W * W * W]; } @@ -270,7 +270,7 @@ void LeafTile::spawnResources(Level *level, int x, int y, int z, int data, float void LeafTile::playerDestroy(Level *level, shared_ptr player, int x, int y, int z, int data) { - if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears->id) + if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id) { player->awardStat( GenericStats::blocksMined(id), diff --git a/Minecraft.World/LeapAtTargetGoal.cpp b/Minecraft.World/LeapAtTargetGoal.cpp index 6aebc9a83..b559ef7db 100644 --- a/Minecraft.World/LeapAtTargetGoal.cpp +++ b/Minecraft.World/LeapAtTargetGoal.cpp @@ -15,7 +15,7 @@ LeapAtTargetGoal::LeapAtTargetGoal(Mob *mob, float yd) bool LeapAtTargetGoal::canUse() { target = weak_ptr(mob->getTarget()); - if (target.lock() == NULL) return false; + if (target.lock() == nullptr) return false; double d = mob->distanceToSqr(target.lock()); if (d < 2 * 2 || d > 4 * 4) return false; if (!mob->onGround) return false; @@ -25,7 +25,7 @@ bool LeapAtTargetGoal::canUse() bool LeapAtTargetGoal::canContinueToUse() { - return target.lock() != NULL && !mob->onGround; + return target.lock() != nullptr && !mob->onGround; } void LeapAtTargetGoal::start() diff --git a/Minecraft.World/LeashFenceKnotEntity.cpp b/Minecraft.World/LeashFenceKnotEntity.cpp index 55947d045..f952a5abb 100644 --- a/Minecraft.World/LeashFenceKnotEntity.cpp +++ b/Minecraft.World/LeashFenceKnotEntity.cpp @@ -70,14 +70,14 @@ bool LeashFenceKnotEntity::interact(shared_ptr player) shared_ptr item = player->getCarriedItem(); bool attachedMob = false; - if (item != NULL && item->id == Item::lead_Id) + if (item != nullptr && item->id == Item::lead_Id) { if (!level->isClientSide) { // look for entities that can be attached to the fence double range = 7; vector > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range)); - if (mobs != NULL) + if (mobs != nullptr) { for(auto& it : *mobs) { @@ -101,7 +101,7 @@ bool LeashFenceKnotEntity::interact(shared_ptr player) // if the player is in creative mode, attempt to remove all leashed mobs without dropping additional items double range = 7; vector > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range)); - if (mobs != NULL) + if (mobs != nullptr) { for(auto& it : *mobs) { @@ -122,7 +122,7 @@ bool LeashFenceKnotEntity::survives() { // knots are placed on top of fence tiles int tile = level->getTile(xTile, yTile, zTile); - if (Tile::tiles[tile] != NULL && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) + if (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) { return true; } @@ -140,7 +140,7 @@ shared_ptr LeashFenceKnotEntity::createAndAddKnot(Level *l shared_ptr LeashFenceKnotEntity::findKnotAt(Level *level, int x, int y, int z) { vector > *knots = level->getEntitiesOfClass(typeid(LeashFenceKnotEntity), AABB::newTemp(x - 1.0, y - 1.0, z - 1.0, x + 1.0, y + 1.0, z + 1.0)); - if (knots != NULL) + if (knots != nullptr) { for (auto& it : *knots ) { diff --git a/Minecraft.World/LeashItem.cpp b/Minecraft.World/LeashItem.cpp index ddb7878b8..4de74a5cc 100644 --- a/Minecraft.World/LeashItem.cpp +++ b/Minecraft.World/LeashItem.cpp @@ -12,7 +12,7 @@ LeashItem::LeashItem(int id) : Item(id) bool LeashItem::useOn(shared_ptr itemInstance, shared_ptr player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) { int tile = level->getTile(x, y, z); - if (Tile::tiles[tile] != NULL && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) + if (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) { if (bTestUseOnOnly) return bindPlayerMobsTest(player, level, x,y,z); @@ -36,14 +36,14 @@ bool LeashItem::bindPlayerMobs(shared_ptr player, Level *level, int x, i bool foundMobs = false; double range = 7; vector > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range)); - if (mobs != NULL) + if (mobs != nullptr) { for(auto& it : *mobs) { shared_ptr mob = dynamic_pointer_cast(it); if (mob->isLeashed() && mob->getLeashHolder() == player) { - if (activeKnot == NULL) + if (activeKnot == nullptr) { activeKnot = LeashFenceKnotEntity::createAndAddKnot(level, x, y, z); } @@ -62,7 +62,7 @@ bool LeashItem::bindPlayerMobsTest(shared_ptr player, Level *level, int double range = 7; vector > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range)); - if (mobs != NULL) + if (mobs != nullptr) { for(auto& it : *mobs) { diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp index 6b83d0aa8..54bc04353 100644 --- a/Minecraft.World/Level.cpp +++ b/Minecraft.World/Level.cpp @@ -109,7 +109,7 @@ inline int GetIndex(int x, int y, int z) void Level::initCachePartial(lightCache_t *cache, int xc, int yc, int zc) { cachewritten = false; - if( cache == NULL ) return; + if( cache == nullptr ) return; int idx; if( !(yc & 0xffffff00) ) @@ -180,7 +180,7 @@ void Level::initCacheComplete(lightCache_t *cache, int xc, int yc, int zc) // Set a brightness value, going through the cache if enabled for this thread void inline Level::setBrightnessCached(lightCache_t *cache, __uint64 *cacheUse, LightLayer::variety layer, int x, int y, int z, int brightness) { - if( cache == NULL ) + if( cache == nullptr ) { setBrightness(layer, x, y, z, brightness, true); return; @@ -243,7 +243,7 @@ void inline Level::setBrightnessCached(lightCache_t *cache, __uint64 *cacheUse, // Get a brightness value, going through the cache if enabled for this thread inline int Level::getBrightnessCached(lightCache_t *cache, LightLayer::variety layer, int x, int y, int z) { - if( cache == NULL ) return getBrightness(layer, x, y, z); + if( cache == nullptr ) return getBrightness(layer, x, y, z); if( y & 0xffffff00 ) return getBrightness(layer, x, y, z); // Fall back on original method for out-of-bounds y int idx = ( ( x & 15 ) << 8 ) | @@ -311,7 +311,7 @@ inline int Level::getBrightnessCached(lightCache_t *cache, LightLayer::variety l // Get a block emission value, going through the cache if enabled for this thread inline int Level::getEmissionCached(lightCache_t *cache, int ct, int x, int y, int z) { - if( cache == NULL ) return Tile::lightEmission[ct]; + if( cache == nullptr ) return Tile::lightEmission[ct]; int idx = ( ( x & 15 ) << 8 ) | ( ( y & 15 ) << 4 ) | @@ -382,7 +382,7 @@ inline int Level::getEmissionCached(lightCache_t *cache, int ct, int x, int y, i // Get a tile light blocking value, going through cache if enabled for this thread inline int Level::getBlockingCached(lightCache_t *cache, LightLayer::variety layer, int *ct, int x, int y, int z) { - if( cache == NULL ) + if( cache == nullptr ) { int t = getTile(x,y,z); if(ct) *ct = t; @@ -561,17 +561,17 @@ void Level::_init() random = new Random(); isNew = false; - dimension = NULL; + dimension = nullptr; - chunkSource = NULL; + chunkSource = nullptr; levelStorage = nullptr; - levelData = NULL; + levelData = nullptr; isFindingSpawn = false; - savedDataStorage = NULL; + savedDataStorage = nullptr; spawnEnemies = true; @@ -604,9 +604,9 @@ Biome *Level::getBiome(int x, int z) if (hasChunkAt(x, 0, z)) { LevelChunk *lc = getChunkAt(x, z); - if (lc != NULL) + if (lc != nullptr) { - // Water chunks at the edge of the world return NULL for their biome as they can't store it, so should fall back on the normal method below + // Water chunks at the edge of the world return nullptr for their biome as they can't store it, so should fall back on the normal method below Biome *biome = lc->getBiome(x & 0xf, z & 0xf, dimension->biomeSource); if( biome ) return biome; } @@ -630,7 +630,7 @@ Level::Level(shared_ptr levelStorage, const wstring& name, Dimensi savedDataStorage = new SavedDataStorage(levelStorage.get()); shared_ptr savedVillages = dynamic_pointer_cast(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID)); - if (savedVillages == NULL) + if (savedVillages == nullptr) { villages = shared_ptr(new Villages(this)); savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages); @@ -642,7 +642,7 @@ Level::Level(shared_ptr levelStorage, const wstring& name, Dimensi } dimension->init(this); - chunkSource = NULL; // 4J - added flag so chunk source can be called from derived class instead + chunkSource = nullptr; // 4J - added flag so chunk source can be called from derived class instead updateSkyBrightness(); prepareWeather(); @@ -651,7 +651,7 @@ Level::Level(shared_ptr levelStorage, const wstring& name, Dimensi Level::Level(shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings) : seaLevel( constSeaLevel ) { - _init(levelStorage, levelName, levelSettings, NULL, true); + _init(levelStorage, levelName, levelSettings, nullptr, true); } @@ -668,7 +668,7 @@ void Level::_init(shared_ptrlevelStorage, const wstring& levelName savedDataStorage = new SavedDataStorage(levelStorage.get()); shared_ptr savedVillages = dynamic_pointer_cast(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID)); - if (savedVillages == NULL) + if (savedVillages == nullptr) { villages = shared_ptr(new Villages(this)); savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages); @@ -680,14 +680,14 @@ void Level::_init(shared_ptrlevelStorage, const wstring& levelName } levelData = levelStorage->prepareLevel(); - isNew = levelData == NULL; + isNew = levelData == nullptr; - if (fixedDimension != NULL) + if (fixedDimension != nullptr) { dimension = fixedDimension; } // 4J Remove TU9 as getDimensions was never accurate. This path was never used anyway as we always set fixedDimension - //else if (levelData != NULL && levelData->getDimension() != 0) + //else if (levelData != nullptr && levelData->getDimension() != 0) //{ // dimension = Dimension::getNew(levelData->getDimension()); //} @@ -696,7 +696,7 @@ void Level::_init(shared_ptrlevelStorage, const wstring& levelName dimension = Dimension::getNew(0); } - if (levelData == NULL) + if (levelData == nullptr) { levelData = new LevelData(levelSettings, levelName); } @@ -708,7 +708,7 @@ void Level::_init(shared_ptrlevelStorage, const wstring& levelName ((Dimension *) dimension)->init( this ); - chunkSource = doCreateChunkSource ? createChunkSource() : NULL; // 4J - added flag so chunk source can be called from derived class instead + chunkSource = doCreateChunkSource ? createChunkSource() : nullptr; // 4J - added flag so chunk source can be called from derived class instead // 4J Stu- Moved to derived classes //if (!levelData->isInitialized()) @@ -740,7 +740,7 @@ Level::~Level() DeleteCriticalSection(&m_checkLightCS); // 4J-PB - savedDataStorage is shared between overworld and nether levels in the server, so it will already have been deleted on the first level delete - if(savedDataStorage!=NULL) delete savedDataStorage; + if(savedDataStorage!=nullptr) delete savedDataStorage; DeleteCriticalSection(&m_entitiesCS); DeleteCriticalSection(&m_tileEntityListCS); @@ -807,7 +807,7 @@ bool Level::isEmptyTile(int x, int y, int z) bool Level::isEntityTile(int x, int y, int z) { int t = getTile(x, y, z); - if (Tile::tiles[t] != NULL && Tile::tiles[t]->isEntityTile()) + if (Tile::tiles[t] != nullptr && Tile::tiles[t]->isEntityTile()) { return true; } @@ -817,7 +817,7 @@ bool Level::isEntityTile(int x, int y, int z) int Level::getTileRenderShape(int x, int y, int z) { int t = getTile(x, y, z); - if (Tile::tiles[t] != NULL) + if (Tile::tiles[t] != nullptr) { return Tile::tiles[t]->getRenderShape(); } @@ -827,7 +827,7 @@ int Level::getTileRenderShape(int x, int y, int z) // 4J Added to slightly optimise and avoid getTile call if we already know the tile int Level::getTileRenderShape(int t) { - if (Tile::tiles[t] != NULL) + if (Tile::tiles[t] != nullptr) { return Tile::tiles[t]->getRenderShape(); } @@ -954,7 +954,7 @@ bool Level::setTileAndData(int x, int y, int z, int tile, int data, int updateFl { tileUpdated(x, y, z, oldTile); Tile *tobj = Tile::tiles[tile]; - if (tobj != NULL && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile); + if (tobj != nullptr && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile); } } return result; @@ -1011,7 +1011,7 @@ bool Level::setData(int x, int y, int z, int data, int updateFlags, bool forceUp { tileUpdated(x, y, z, tile); Tile *tobj = Tile::tiles[tile]; - if (tobj != NULL && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile); + if (tobj != nullptr && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile); } } return result; @@ -1145,7 +1145,7 @@ void Level::neighborChanged(int x, int y, int z, int type) int id = getTile(x, y, z); Tile *tile = Tile::tiles[id]; - if (tile != NULL) + if (tile != nullptr) { tile->neighborChanged(this, x, y, z, type); } @@ -1336,7 +1336,7 @@ int Level::getBrightness(LightLayer::variety layer, int x, int y, int z) int idx = ix * chunkSourceXZSize + iz; LevelChunk *c = chunkSourceCache[idx]; - if( c == NULL ) return (int)layer; + if( c == nullptr ) return (int)layer; if (y < 0) y = 0; if (y >= maxBuildHeight) y = maxBuildHeight - 1; @@ -1388,7 +1388,7 @@ void Level::getNeighbourBrightnesses(int *brightnesses, LightLayer::variety laye // 4J Stu - The java LightLayer was an enum class type with a member "surrounding" which is what we // were returning here. Surrounding has the same value as the enum value in our C++ code, so just cast // it to an int - if( c == NULL ) + if( c == nullptr ) { for( int i = 0; i < 6; i++ ) { @@ -1497,8 +1497,8 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid) HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly) { - if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z)) return NULL; - if (Double::isNaN(b->x) || Double::isNaN(b->y) || Double::isNaN(b->z)) return NULL; + if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z)) return nullptr; + if (Double::isNaN(b->x) || Double::isNaN(b->y) || Double::isNaN(b->z)) return nullptr; int xTile1 = Mth::floor(b->x); int yTile1 = Mth::floor(b->y); @@ -1512,7 +1512,7 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly) int t = getTile(xTile0, yTile0, zTile0); int data = getData(xTile0, yTile0, zTile0); Tile *tile = Tile::tiles[t]; - if (solidOnly && tile != NULL && tile->getAABB(this, xTile0, yTile0, zTile0) == NULL) + if (solidOnly && tile != nullptr && tile->getAABB(this, xTile0, yTile0, zTile0) == nullptr) { // No collision @@ -1520,15 +1520,15 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly) else if (t > 0 && tile->mayPick(data, liquid)) { HitResult *r = tile->clip(this, xTile0, yTile0, zTile0, a, b); - if (r != NULL) return r; + if (r != nullptr) return r; } } int maxIterations = 200; while (maxIterations-- >= 0) { - if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z)) return NULL; - if (xTile0 == xTile1 && yTile0 == yTile1 && zTile0 == zTile1) return NULL; + if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z)) return nullptr; + if (xTile0 == xTile1 && yTile0 == yTile1 && zTile0 == zTile1) return nullptr; bool xClipped = true; bool yClipped = true; @@ -1614,7 +1614,7 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly) int t = getTile(xTile0, yTile0, zTile0); int data = getData(xTile0, yTile0, zTile0); Tile *tile = Tile::tiles[t]; - if (solidOnly && tile != NULL && tile->getAABB(this, xTile0, yTile0, zTile0) == NULL) + if (solidOnly && tile != nullptr && tile->getAABB(this, xTile0, yTile0, zTile0) == nullptr) { // No collision @@ -1622,16 +1622,16 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly) else if (t > 0 && tile->mayPick(data, liquid)) { HitResult *r = tile->clip(this, xTile0, yTile0, zTile0, a, b); - if (r != NULL) return r; + if (r != nullptr) return r; } } - return NULL; + return nullptr; } void Level::playEntitySound(shared_ptr entity, int iSound, float volume, float pitch) { - if(entity == NULL) return; + if(entity == nullptr) return; for (auto& listener : listeners) { // 4J-PB - if the entity is a local player, don't play the sound @@ -1650,7 +1650,7 @@ void Level::playEntitySound(shared_ptr entity, int iSound, float volume, void Level::playPlayerSound(shared_ptr entity, int iSound, float volume, float pitch) { - if (entity == NULL) return; + if (entity == nullptr) return; for (auto& listener : listeners) { listener->playSoundExceptPlayer(entity, iSound, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch); @@ -1703,7 +1703,7 @@ bool Level::addEntity(shared_ptr e) int xc = Mth::floor(e->x / 16); int zc = Mth::floor(e->z / 16); - if(e == NULL) + if(e == nullptr) { return false; } @@ -1892,7 +1892,7 @@ AABBList *Level::getCubes(shared_ptr source, AABB *box, bool noEntities/ for (int y = y0 - 1; y < y1; y++) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL) + if (tile != nullptr) { tile->addAABBs(this, x, y, z, box, &boxes, source); } @@ -1938,13 +1938,13 @@ AABBList *Level::getCubes(shared_ptr source, AABB *box, bool noEntities/ for (auto& it : *ee) { AABB *collideBox = it->getCollideBox(); - if (collideBox != NULL && collideBox->intersects(box)) + if (collideBox != nullptr && collideBox->intersects(box)) { boxes.push_back(collideBox); } collideBox = source->getCollideAgainstBox(it); - if (collideBox != NULL && collideBox->intersects(box)) + if (collideBox != nullptr && collideBox->intersects(box)) { boxes.push_back(collideBox); } @@ -1975,7 +1975,7 @@ AABBList *Level::getTileCubes(AABB *box, bool blockAtEdge/* = false */) // { // Tile *tile = Tile::tiles[getTile(x, y, z)]; - // if (tile != NULL) + // if (tile != nullptr) // { // tile->addAABBs(this, x, y, z, box, &boxes); // } @@ -2087,7 +2087,7 @@ float Level::getTimeOfDay(float a) * getTimeOfDay and changed it before releasing (without * re-committing)... that should be the only difference // jeb */ - /* if (this != NULL) return 0.5f; */ + /* if (this != nullptr) return 0.5f; */ // 4J Added if so we can override timeOfDay without changing the time that affects ticking of things return dimension->getTimeOfDay(levelData->getDayTime(), a);; @@ -2303,7 +2303,7 @@ void Level::tickEntities() { shared_ptr e = entities.at(i); - if (e->riding != NULL) + if (e->riding != nullptr) { if (e->riding->removed || e->riding->rider.lock() != e) { @@ -2381,7 +2381,7 @@ void Level::tickEntities() if (hasChunk(te->x >> 4, te->z >> 4)) { LevelChunk *lc = getChunk(te->x >> 4, te->z >> 4); - if (lc != NULL) lc->removeTileEntity(te->x & 15, te->y, te->z & 15); + if (lc != nullptr) lc->removeTileEntity(te->x & 15, te->y, te->z & 15); } } else @@ -2437,7 +2437,7 @@ void Level::tickEntities() if (hasChunk(e->x >> 4, e->z >> 4)) { LevelChunk *lc = getChunk(e->x >> 4, e->z >> 4); - if (lc != NULL) lc->setTileEntity(e->x & 15, e->y, e->z & 15, e); + if (lc != nullptr) lc->setTileEntity(e->x & 15, e->y, e->z & 15, e); } sendTileUpdated(e->x, e->y, e->z); @@ -2503,7 +2503,7 @@ void Level::tick(shared_ptr e, bool actual) #endif { e->tickCount++; - if (e->riding != NULL) + if (e->riding != nullptr) { e->rideTick(); } @@ -2550,7 +2550,7 @@ void Level::tick(shared_ptr e, bool actual) if (actual && e->inChunk) { - if (e->rider.lock() != NULL) + if (e->rider.lock() != nullptr) { if (e->rider.lock()->removed || e->rider.lock()->riding != e) { @@ -2600,7 +2600,7 @@ bool Level::containsAnyBlocks(AABB *box) for (int z = z0; z < z1; z++) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL) + if (tile != nullptr) { return true; } @@ -2627,7 +2627,7 @@ bool Level::containsAnyLiquid(AABB *box) for (int z = z0; z < z1; z++) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL && tile->material->isLiquid()) + if (tile != nullptr && tile->material->isLiquid()) { return true; } @@ -2657,7 +2657,7 @@ bool Level::containsAnyLiquid_NoLoad(AABB *box) { if( !hasChunkAt(x,y,z) ) return true; // If we don't have it, it might be liquid... Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL && tile->material->isLiquid()) + if (tile != nullptr && tile->material->isLiquid()) { return true; } @@ -2715,7 +2715,7 @@ bool Level::checkAndHandleWater(AABB *box, Material *material, shared_ptrmaterial == material) + if (tile != nullptr && tile->material == material) { double yt0 = y + 1 - LiquidTile::getHeight(getData(x, y, z)); if (y1 >= yt0) @@ -2755,7 +2755,7 @@ bool Level::containsMaterial(AABB *box, Material *material) for (int z = z0; z < z1; z++) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL && tile->material == material) + if (tile != nullptr && tile->material == material) { return true; } @@ -2782,7 +2782,7 @@ bool Level::containsLiquid(AABB *box, Material *material) for (int z = z0; z < z1; z++) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL && tile->material == material) + if (tile != nullptr && tile->material == material) { int data = getData(x, y, z); double yh1 = y + 1; @@ -2834,7 +2834,7 @@ float Level::getSeenPercent(Vec3 *center, AABB *bb) double y = bb->y0 + (bb->y1 - bb->y0) * yy; double z = bb->z0 + (bb->z1 - bb->z0) * zz; HitResult *res = clip(Vec3::newTemp(x, y, z), center); - if ( res == NULL) hits++; + if ( res == nullptr) hits++; delete res; count++; } @@ -2908,16 +2908,16 @@ shared_ptr Level::getTileEntity(int x, int y, int z) LeaveCriticalSection(&m_tileEntityListCS); } - if (tileEntity == NULL) + if (tileEntity == nullptr) { LevelChunk *lc = getChunk(x >> 4, z >> 4); - if (lc != NULL) + if (lc != nullptr) { tileEntity = lc->getTileEntity(x & 15, y, z & 15); } } - if (tileEntity == NULL) + if (tileEntity == nullptr) { EnterCriticalSection(&m_tileEntityListCS); for(auto& e : pendingTileEntities) @@ -2936,7 +2936,7 @@ shared_ptr Level::getTileEntity(int x, int y, int z) void Level::setTileEntity(int x, int y, int z, shared_ptr tileEntity) { - if (tileEntity != NULL && !tileEntity->isRemoved()) + if (tileEntity != nullptr && !tileEntity->isRemoved()) { EnterCriticalSection(&m_tileEntityListCS); if (updatingTileEntities) @@ -2967,7 +2967,7 @@ void Level::setTileEntity(int x, int y, int z, shared_ptr tileEntity tileEntityList.push_back(tileEntity); LevelChunk *lc = getChunk(x >> 4, z >> 4); - if (lc != NULL) lc->setTileEntity(x & 15, y, z & 15, tileEntity); + if (lc != nullptr) lc->setTileEntity(x & 15, y, z & 15, tileEntity); } LeaveCriticalSection(&m_tileEntityListCS); } @@ -2977,7 +2977,7 @@ void Level::removeTileEntity(int x, int y, int z) { EnterCriticalSection(&m_tileEntityListCS); shared_ptr te = getTileEntity(x, y, z); - if (te != NULL && updatingTileEntities) + if (te != nullptr && updatingTileEntities) { te->setRemoved(); auto it = find(pendingTileEntities.begin(), pendingTileEntities.end(), te); @@ -2988,7 +2988,7 @@ void Level::removeTileEntity(int x, int y, int z) } else { - if (te != NULL) + if (te != nullptr) { auto it = find(pendingTileEntities.begin(), pendingTileEntities.end(), te); if( it != pendingTileEntities.end() ) @@ -3002,7 +3002,7 @@ void Level::removeTileEntity(int x, int y, int z) } } LevelChunk *lc = getChunk(x >> 4, z >> 4); - if (lc != NULL) lc->removeTileEntity(x & 15, y, z & 15); + if (lc != nullptr) lc->removeTileEntity(x & 15, y, z & 15); } LeaveCriticalSection(&m_tileEntityListCS); } @@ -3015,7 +3015,7 @@ void Level::markForRemoval(shared_ptr entity) bool Level::isSolidRenderTile(int x, int y, int z) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile == NULL) return false; + if (tile == nullptr) return false; // 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so // blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by @@ -3031,7 +3031,7 @@ bool Level::isSolidRenderTile(int x, int y, int z) for( int i = 0; i < 6; i++ ) { int t = getTile(x + axo[i], y + ayo[i] , z + azo[i]); - if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) ) + if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == nullptr ) || !Tile::tiles[t]->isSolidRender() ) ) { return false; } @@ -3061,25 +3061,25 @@ bool Level::isSolidBlockingTileInLoadedChunk(int x, int y, int z, bool valueIfNo return valueIfNotLoaded; } LevelChunk *chunk = chunkSource->getChunk(x >> 4, z >> 4); - if (chunk == NULL || chunk->isEmpty()) + if (chunk == nullptr || chunk->isEmpty()) { return valueIfNotLoaded; } Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile == NULL) return false; + if (tile == nullptr) return false; return tile->material->isSolidBlocking() && tile->isCubeShaped(); } bool Level::isFullAABBTile(int x, int y, int z) { int tile = getTile(x, y, z); - if (tile == 0 || Tile::tiles[tile] == NULL) + if (tile == 0 || Tile::tiles[tile] == nullptr) { return false; } AABB *aabb = Tile::tiles[tile]->getAABB(this, x, y, z); - return aabb != NULL && aabb->getSize() >= 1; + return aabb != nullptr && aabb->getSize() >= 1; } bool Level::isTopSolidBlocking(int x, int y, int z) @@ -3091,19 +3091,19 @@ bool Level::isTopSolidBlocking(int x, int y, int z) bool Level::isTopSolidBlocking(Tile *tile, int data) { - if (tile == NULL) return false; + if (tile == nullptr) return false; if (tile->material->isSolidBlocking() && tile->isCubeShaped()) return true; - if (dynamic_cast(tile) != NULL) + if (dynamic_cast(tile) != nullptr) { return (data & StairTile::UPSIDEDOWN_BIT) == StairTile::UPSIDEDOWN_BIT; } - if (dynamic_cast(tile) != NULL) + if (dynamic_cast(tile) != nullptr) { return (data & HalfSlabTile::TOP_SLOT_BIT) == HalfSlabTile::TOP_SLOT_BIT; } - if (dynamic_cast(tile) != NULL) return true; - if (dynamic_cast(tile) != NULL) return (data & TopSnowTile::HEIGHT_MASK) == TopSnowTile::MAX_HEIGHT + 1; + if (dynamic_cast(tile) != nullptr) return true; + if (dynamic_cast(tile) != nullptr) return (data & TopSnowTile::HEIGHT_MASK) == TopSnowTile::MAX_HEIGHT + 1; return false; } @@ -3320,7 +3320,7 @@ void Level::tickClientSideTiles(int xo, int zo, LevelChunk *lc) if (id == 0 && this->getDaytimeRawBrightness(x, y, z) <= random->nextInt(8) && getBrightness(LightLayer::Sky, x, y, z) <= 0) { shared_ptr player = getNearestPlayer(x + 0.5, y + 0.5, z + 0.5, 8); - if (player != NULL && player->distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 2 * 2) + if (player != nullptr && player->distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 2 * 2) { // 4J-PB - Fixed issue with cave audio event having 2 sounds at 192k #ifdef _XBOX @@ -3471,7 +3471,7 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool f // If we're in cached mode, then use memory allocated after the cached data itself for the toCheck array, in an attempt to make both that & the other cached data sit on the CPU L2 cache better. int *toCheck; - if( cache == NULL ) + if( cache == nullptr ) { toCheck = toCheckLevel; } @@ -3551,7 +3551,7 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool f if( ( yy < 0 ) || ( yy >= maxBuildHeight ) ) continue; // 4J - some changes here brought forward from 1.2.3 - int block = max(1, getBlockingCached(cache, layer, NULL, xx, yy, zz) ); + int block = max(1, getBlockingCached(cache, layer, nullptr, xx, yy, zz) ); current = getBrightnessCached(cache, layer, xx, yy, zz); if ((current == expected - block) && (toCheckCount < (32 * 32 * 32))) // 4J - 32 * 32 * 32 was toCheck.length { @@ -3670,13 +3670,13 @@ bool Level::tickPendingTicks(bool force) vector *Level::fetchTicksInChunk(LevelChunk *chunk, bool remove) { - return NULL; + return nullptr; } vector > *Level::getEntities(shared_ptr except, AABB *bb) { - return getEntities(except, bb, NULL); + return getEntities(except, bb, nullptr); } vector > *Level::getEntities(shared_ptr except, AABB *bb, const EntitySelector *selector) @@ -3720,7 +3720,7 @@ vector > *Level::getEntities(shared_ptr except, AABB vector > *Level::getEntitiesOfClass(const type_info& baseClass, AABB *bb) { - return getEntitiesOfClass(baseClass, bb, NULL); + return getEntitiesOfClass(baseClass, bb, nullptr); } vector > *Level::getEntitiesOfClass(const type_info& baseClass, AABB *bb, const EntitySelector *selector) @@ -3814,7 +3814,7 @@ unsigned int Level::countInstanceOf(BaseObject::Class *clas) // 4J - added - more limited (but faster) version of above, used to count water animals, animals, monsters for the mob spawner // singleType flag should be true if we are just trying to match eINSTANCEOF exactly, and false if it is a eINSTANCEOF from a group (eTYPE_WATERANIMAL, eTYPE_ANIMAL, eTYPE_MONSTER) -unsigned int Level::countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount/* = NULL*/, unsigned int *couldWanderCount/* = NULL*/) +unsigned int Level::countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount/* = nullptr*/, unsigned int *couldWanderCount/* = nullptr*/) { unsigned int count = 0; if( protectedCount ) *protectedCount = 0; @@ -3932,16 +3932,16 @@ bool Level::mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int f Tile *tile = Tile::tiles[tileId]; AABB *aabb = tile->getAABB(this, x, y, z); - if (ignoreEntities) aabb = NULL; - if (aabb != NULL && !isUnobstructed(aabb, ignoreEntity)) return false; - if (targetTile != NULL && + if (ignoreEntities) aabb = nullptr; + if (aabb != nullptr && !isUnobstructed(aabb, ignoreEntity)) return false; + if (targetTile != nullptr && (targetTile == Tile::water || targetTile == Tile::calmWater || targetTile == Tile::lava || targetTile == Tile::calmLava || targetTile == Tile::fire || targetTile->material->isReplaceable())) { - targetTile = NULL; + targetTile = nullptr; } - if (targetTile != NULL && targetTile->material == Material::decoration && tile == Tile::anvil) return true; - if (tileId > 0 && targetTile == NULL) + if (targetTile != nullptr && targetTile->material == Material::decoration && tile == Tile::anvil) return true; + if (tileId > 0 && targetTile == nullptr) { if (tile->mayPlace(this, x, y, z, face, item)) { @@ -4519,7 +4519,7 @@ int Level::getHeight() Tickable *Level::makeSoundUpdater(shared_ptr minecart) { - return NULL; + return nullptr; } Random *Level::getRandomFor(int x, int z, int blend) diff --git a/Minecraft.World/Level.h b/Minecraft.World/Level.h index 6e6b28cd5..e147892ca 100644 --- a/Minecraft.World/Level.h +++ b/Minecraft.World/Level.h @@ -438,7 +438,7 @@ class Level : public LevelSource vector > getAllEntities(); void tileEntityChanged(int x, int y, int z, shared_ptr te); // unsigned int countInstanceOf(BaseObject::Class *clas); - unsigned int countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount = NULL, unsigned int *couldWanderCount = NULL); // 4J added + unsigned int countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount = nullptr, unsigned int *couldWanderCount = nullptr); // 4J added unsigned int countInstanceOfInRange(eINSTANCEOF clas, bool singleType, int range, int x, int y, int z); // 4J Added void addEntities(vector > *list); virtual void removeEntities(vector > *list); diff --git a/Minecraft.World/LevelChunk.cpp b/Minecraft.World/LevelChunk.cpp index 9d7e51317..e96ea3d8f 100644 --- a/Minecraft.World/LevelChunk.cpp +++ b/Minecraft.World/LevelChunk.cpp @@ -123,7 +123,7 @@ void LevelChunk::init(Level *level, int x, int z) #ifdef _LARGE_WORLDS m_bUnloaded = false; // 4J Added - m_unloadedEntitiesTag = NULL; + m_unloadedEntitiesTag = nullptr; #endif } @@ -132,10 +132,10 @@ LevelChunk::LevelChunk(Level *level, int x, int z) { init(level, x, z); lowerBlocks = new CompressedTileStorage(); - lowerData = NULL; - lowerSkyLight = NULL; - lowerBlockLight = NULL; - serverTerrainPopulated = NULL; + lowerData = nullptr; + lowerSkyLight = nullptr; + lowerBlockLight = nullptr; + serverTerrainPopulated = nullptr; if(Level::maxBuildHeight > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) { @@ -147,10 +147,10 @@ LevelChunk::LevelChunk(Level *level, int x, int z) } else { - upperBlocks = NULL; - upperData = NULL; - upperSkyLight = NULL; - upperBlockLight = NULL; + upperBlocks = nullptr; + upperData = nullptr; + upperSkyLight = nullptr; + upperBlockLight = nullptr; } #ifdef SHARING_ENABLED @@ -167,7 +167,7 @@ LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z) // We'll be creating this as "empty" when this ctor is called on the client, as a result of a chunk becoming visible (but we don't have the data yet for it). // In this case, we want to keep memory usage down and so create all data as empty/compressed as possible. On the client we get the full data for the chunk as a single // update in a block region update packet, and so there is a single point where it is good to compress the data. - bool createEmpty = ( blocks.data == NULL ); + bool createEmpty = ( blocks.data == nullptr ); if( createEmpty ) { @@ -199,13 +199,13 @@ LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z) } else { - upperBlocks = NULL; - upperData = NULL; - upperSkyLight = NULL; - upperBlockLight = NULL; + upperBlocks = nullptr; + upperData = nullptr; + upperSkyLight = nullptr; + upperBlockLight = nullptr; } - serverTerrainPopulated = NULL; + serverTerrainPopulated = nullptr; #ifdef SHARING_ENABLED sharingTilesAndData = false; #endif @@ -237,7 +237,7 @@ LevelChunk::LevelChunk(Level *level, int x, int z, LevelChunk *lc) this->data = new SparseDataStorage(lc->data); this->skyLight = new SparseLightStorage(lc->skyLight); this->blockLight = new SparseLightStorage(lc->blockLight); - serverTerrainPopulated = NULL; + serverTerrainPopulated = nullptr; #endif } @@ -296,8 +296,8 @@ void LevelChunk::stopSharingTilesAndData() } else { - upperBlocks = NULL; - upperData = NULL; + upperBlocks = nullptr; + upperData = nullptr; } /* @@ -939,7 +939,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) { // 4J Stu - Need to do this here otherwise double chests don't always work correctly shared_ptr te = getTileEntity(x, y, z); - if (te != NULL) + if (te != nullptr) { te->clearCache(); } @@ -1032,17 +1032,17 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) } } // AP - changed the method of EntityTile detection cos it's well slow on Vita mate - // if (_tile > 0 && dynamic_cast(Tile::tiles[_tile]) != NULL) - if (_tile > 0 && Tile::tiles[_tile] != NULL && Tile::tiles[_tile]->isEntityTile()) + // if (_tile > 0 && dynamic_cast(Tile::tiles[_tile]) != nullptr) + if (_tile > 0 && Tile::tiles[_tile] != nullptr && Tile::tiles[_tile]->isEntityTile()) { shared_ptr te = getTileEntity(x, y, z); - if (te == NULL) + if (te == nullptr) { te = dynamic_cast(Tile::tiles[_tile])->newTileEntity(level); //app.DebugPrintf("%s: Setting tile id %d, created tileEntity type %d\n", level->isClientSide?"Client":"Server", _tile, te->GetType()); level->setTileEntity(xOffs, y, zOffs, te); } - if (te != NULL) + if (te != nullptr) { //app.DebugPrintf("%s: Setting tile id %d, found tileEntity type %d\n", level->isClientSide?"Client":"Server", _tile, te->GetType()); te->clearCache(); @@ -1050,11 +1050,11 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) } } // AP - changed the method of EntityTile detection cos it's well slow on Vita mate - // else if (old > 0 && dynamic_cast(Tile::tiles[old]) != NULL) - else if (old > 0 && Tile::tiles[_tile] != NULL && Tile::tiles[_tile]->isEntityTile()) + // else if (old > 0 && dynamic_cast(Tile::tiles[old]) != nullptr) + else if (old > 0 && Tile::tiles[_tile] != nullptr && Tile::tiles[_tile]->isEntityTile()) { shared_ptr te = getTileEntity(x, y, z); - if (te != NULL) + if (te != nullptr) { te->clearCache(); } @@ -1091,10 +1091,10 @@ bool LevelChunk::setData(int x, int y, int z, int val, int mask, bool *maskedBit data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, val); int _tile = getTile(x, y, z); - if (_tile > 0 && dynamic_cast( Tile::tiles[_tile] ) != NULL) + if (_tile > 0 && dynamic_cast( Tile::tiles[_tile] ) != nullptr) { shared_ptr te = getTileEntity(x, y, z); - if (te != NULL) + if (te != nullptr) { te->clearCache(); te->data = val; @@ -1310,7 +1310,7 @@ shared_ptr LevelChunk::getTileEntity(int x, int y, int z) //EntityTile *et = (EntityTile *) Tile::tiles[t]; //et->onPlace(level, this->x * 16 + x, y, this->z * 16 + z); - //if (tileEntity == NULL) + //if (tileEntity == nullptr) //{ tileEntity = dynamic_cast(Tile::tiles[t])->newTileEntity(level); level->setTileEntity(this->x * 16 + x, y, this->z * 16 + z, tileEntity); @@ -1332,7 +1332,7 @@ shared_ptr LevelChunk::getTileEntity(int x, int y, int z) tileEntity = it->second; LeaveCriticalSection(&m_csTileEntities); } - if (tileEntity != NULL && tileEntity->isRemoved()) + if (tileEntity != nullptr && tileEntity->isRemoved()) { EnterCriticalSection(&m_csTileEntities); tileEntities.erase(pos); @@ -1398,7 +1398,7 @@ void LevelChunk::removeTileEntity(int x, int y, int z) { shared_ptr te = tileEntities[pos]; tileEntities.erase(pos); - if( te != NULL ) + if( te != nullptr ) { if(level->isClientSide) { @@ -1421,13 +1421,13 @@ void LevelChunk::load() if(m_bUnloaded && m_unloadedEntitiesTag) { ListTag *entityTags = (ListTag *) m_unloadedEntitiesTag->getList(L"Entities"); - if (entityTags != NULL) + if (entityTags != nullptr) { for (int i = 0; i < entityTags->size(); i++) { CompoundTag *teTag = entityTags->get(i); shared_ptr ent = EntityIO::loadStatic(teTag, level); - if (ent != NULL) + if (ent != nullptr) { ent->onLoadedFromSave(); addEntity(ent); @@ -1436,20 +1436,20 @@ void LevelChunk::load() } ListTag *tileEntityTags = (ListTag *) m_unloadedEntitiesTag->getList(L"TileEntities"); - if (tileEntityTags != NULL) + if (tileEntityTags != nullptr) { for (int i = 0; i < tileEntityTags->size(); i++) { CompoundTag *teTag = tileEntityTags->get(i); shared_ptr te = TileEntity::loadStatic(teTag); - if (te != NULL) + if (te != nullptr) { addTileEntity(te); } } } delete m_unloadedEntitiesTag; - m_unloadedEntitiesTag = NULL; + m_unloadedEntitiesTag = nullptr; m_bUnloaded = false; } #endif @@ -1628,16 +1628,16 @@ void LevelChunk::getEntities(shared_ptr except, AABB *bb, vectorbb->intersects(bb) && (selector == NULL || selector->matches(e))) + if ( e && e != except && e->bb->intersects(bb) && (selector == nullptr || selector->matches(e))) { es.push_back(e); vector > *subs = e->getSubEntities(); - if (subs != NULL) + if (subs != nullptr) { for (const auto& sub : *subs) { e = sub; - if ( e && e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e))) + if ( e && e != except && e->bb->intersects(bb) && (selector == nullptr || selector->matches(e))) { es.push_back(e); } @@ -1693,10 +1693,10 @@ void LevelChunk::getEntitiesOfClass(const type_info& ec, AABB *bb, vectorinstanceof(eTYPE_MINECART); else if ( ec==typeid(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 = true; + else if(e != nullptr && ec == typeid(*(e.get())) ) isAssignableFrom = true; if (isAssignableFrom && e->bb->intersects(bb)) { - if (selector == NULL || selector->matches(e)) + if (selector == nullptr || selector->matches(e)) { es.push_back(e); } @@ -1849,8 +1849,8 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1, int compressedHeight = Level::COMPRESSED_CHUNK_SECTION_HEIGHT; // 4J - replaced block storage as now uses CompressedTileStorage - if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 ); - if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT ); + if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, 0 ); + if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT ); /* for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) @@ -1864,8 +1864,8 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1, recalcHeightmapOnly(); // 4J - replaced data storage as now uses SparseDataStorage - if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 ); - if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT ); + if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, 0 ); + if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT ); if( includeLighting ) { @@ -2061,7 +2061,7 @@ Biome *LevelChunk::getBiome(int x, int z, BiomeSource *biomeSource) value = biome->id; biomes[(z << 4) | x] = static_cast(value & 0xff); } - if (Biome::biomes[value] == NULL) + if (Biome::biomes[value] == nullptr) { return Biome::plains; } @@ -2075,7 +2075,7 @@ byteArray LevelChunk::getBiomes() void LevelChunk::setBiomes(byteArray biomes) { - if(this->biomes.data != NULL) delete[] this->biomes.data; + if(this->biomes.data != nullptr) delete[] this->biomes.data; this->biomes = biomes; } @@ -2156,8 +2156,8 @@ void LevelChunk::getDataData(byteArray data) // Set data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set. void LevelChunk::setDataData(byteArray data) { - if( lowerData == NULL ) lowerData = new SparseDataStorage(); - if( upperData == NULL ) upperData = new SparseDataStorage(true); + if( lowerData == nullptr ) lowerData = new SparseDataStorage(); + if( upperData == nullptr ) upperData = new SparseDataStorage(true); lowerData->setData(data,0); if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperData->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2); } @@ -2179,8 +2179,8 @@ void LevelChunk::getBlockLightData(byteArray data) // Set sky light data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set. void LevelChunk::setSkyLightData(byteArray data) { - if( lowerSkyLight == NULL ) lowerSkyLight = new SparseLightStorage(true); - if( upperSkyLight == NULL ) upperSkyLight = new SparseLightStorage(true,true); + if( lowerSkyLight == nullptr ) lowerSkyLight = new SparseLightStorage(true); + if( upperSkyLight == nullptr ) upperSkyLight = new SparseLightStorage(true,true); lowerSkyLight->setData(data,0); if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperSkyLight->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2); } @@ -2188,8 +2188,8 @@ void LevelChunk::setSkyLightData(byteArray data) // Set block light data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set. void LevelChunk::setBlockLightData(byteArray data) { - if( lowerBlockLight == NULL ) lowerBlockLight = new SparseLightStorage(false); - if( upperBlockLight == NULL ) upperBlockLight = new SparseLightStorage(false, true); + if( lowerBlockLight == nullptr ) lowerBlockLight = new SparseLightStorage(false); + if( upperBlockLight == nullptr ) upperBlockLight = new SparseLightStorage(false, true); lowerBlockLight->setData(data,0); if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperBlockLight->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2); } @@ -2215,8 +2215,8 @@ void LevelChunk::compressLighting() void LevelChunk::compressBlocks() { #ifdef SHARING_ENABLED - CompressedTileStorage *blocksToCompressLower = NULL; - CompressedTileStorage *blocksToCompressUpper = NULL; + CompressedTileStorage *blocksToCompressLower = nullptr; + CompressedTileStorage *blocksToCompressUpper = nullptr; // If we're the host machine, and this is the client level, then we only want to do this if we are sharing data. This means that we will be compressing the data that is shared from the server. // No point trying to compress the local client copy of the data if the data is unshared, since we'll be throwing this data away again anyway once we share with the server again. @@ -2293,24 +2293,24 @@ void LevelChunk::readCompressedBlockData(DataInputStream *dis) void LevelChunk::readCompressedDataData(DataInputStream *dis) { - if( lowerData == NULL ) lowerData = new SparseDataStorage(); - if( upperData == NULL ) upperData = new SparseDataStorage(true); + if( lowerData == nullptr ) lowerData = new SparseDataStorage(); + if( upperData == nullptr ) upperData = new SparseDataStorage(true); lowerData->read(dis); upperData->read(dis); } void LevelChunk::readCompressedSkyLightData(DataInputStream *dis) { - if( lowerSkyLight == NULL ) lowerSkyLight = new SparseLightStorage(true); - if( upperSkyLight == NULL ) upperSkyLight = new SparseLightStorage(true,true); + if( lowerSkyLight == nullptr ) lowerSkyLight = new SparseLightStorage(true); + if( upperSkyLight == nullptr ) upperSkyLight = new SparseLightStorage(true,true); lowerSkyLight->read(dis); upperSkyLight->read(dis); } void LevelChunk::readCompressedBlockLightData(DataInputStream *dis) { - if( lowerBlockLight == NULL ) lowerBlockLight = new SparseLightStorage(false); - if( upperBlockLight == NULL ) upperBlockLight = new SparseLightStorage(false, true); + if( lowerBlockLight == nullptr ) lowerBlockLight = new SparseLightStorage(false); + if( upperBlockLight == nullptr ) upperBlockLight = new SparseLightStorage(false, true); lowerBlockLight->read(dis); upperBlockLight->read(dis); } @@ -2319,8 +2319,8 @@ void LevelChunk::readCompressedBlockLightData(DataInputStream *dis) void LevelChunk::compressData() { #ifdef SHARING_ENABLED - SparseDataStorage *dataToCompressLower = NULL; - SparseDataStorage *dataToCompressUpper = NULL; + SparseDataStorage *dataToCompressLower = nullptr; + SparseDataStorage *dataToCompressUpper = nullptr; // If we're the host machine, and this is the client level, then we only want to do this if we are sharing data. This means that we will be compressing the data that is shared from the server. // No point trying to compress the local client copy of the data if the data is unshared, since we'll be throwing this data away again anyway once we share with the server again. diff --git a/Minecraft.World/LevelData.cpp b/Minecraft.World/LevelData.cpp index a40602573..97f60bbc3 100644 --- a/Minecraft.World/LevelData.cpp +++ b/Minecraft.World/LevelData.cpp @@ -18,7 +18,7 @@ LevelData::LevelData(CompoundTag *tag) { wstring generatorName = tag->getString(L"generatorName"); m_pGenerator = LevelType::getLevelType(generatorName); - if (m_pGenerator == NULL) + if (m_pGenerator == nullptr) { m_pGenerator = LevelType::lvl_normal; } @@ -189,7 +189,7 @@ LevelData::LevelData(CompoundTag *tag) } else { - this->loadedPlayerTag = NULL; + this->loadedPlayerTag = nullptr; } */ dimension = 0; @@ -215,7 +215,7 @@ LevelData::LevelData(LevelSettings *levelSettings, const wstring& levelName) gameTime = -1; lastPlayed = 0; sizeOnDisk = 0; - // this->loadedPlayerTag = NULL; // 4J - we don't store this anymore + // this->loadedPlayerTag = nullptr; // 4J - we don't store this anymore dimension = 0; version = 0; rainTime = 0; @@ -432,7 +432,7 @@ __int64 LevelData::getSizeOnDisk() CompoundTag *LevelData::getLoadedPlayerTag() { - return NULL; // 4J - we don't store this anymore + return nullptr; // 4J - we don't store this anymore } // 4J Removed TU9 as it's never accurate due to the dimension never being set diff --git a/Minecraft.World/LevelSettings.cpp b/Minecraft.World/LevelSettings.cpp index dca8ce618..398e9cf49 100644 --- a/Minecraft.World/LevelSettings.cpp +++ b/Minecraft.World/LevelSettings.cpp @@ -3,10 +3,10 @@ #include "net.minecraft.world.level.storage.h" #include "LevelType.h" -GameType *GameType::NOT_SET = NULL; -GameType *GameType::SURVIVAL= NULL; -GameType *GameType::CREATIVE = NULL; -GameType *GameType::ADVENTURE = NULL; +GameType *GameType::NOT_SET = nullptr; +GameType *GameType::SURVIVAL= nullptr; +GameType *GameType::CREATIVE = nullptr; +GameType *GameType::ADVENTURE = nullptr; void GameType::staticCtor() { diff --git a/Minecraft.World/LevelStorage.h b/Minecraft.World/LevelStorage.h index 25d2aba2c..f0d2ac785 100644 --- a/Minecraft.World/LevelStorage.h +++ b/Minecraft.World/LevelStorage.h @@ -29,7 +29,7 @@ class LevelStorage virtual wstring getLevelId() = 0; public: - virtual ConsoleSaveFile *getSaveFile() { return NULL; } + virtual ConsoleSaveFile *getSaveFile() { return nullptr; } virtual void flushSaveFile(bool autosave) {} // 4J Added diff --git a/Minecraft.World/LevelType.cpp b/Minecraft.World/LevelType.cpp index 30b081329..924c8ab40 100644 --- a/Minecraft.World/LevelType.cpp +++ b/Minecraft.World/LevelType.cpp @@ -14,14 +14,14 @@ // private boolean replacement; LevelType *LevelType::levelTypes[16];// = new LevelType[16]; -LevelType *LevelType::lvl_normal=NULL;// = new LevelType(0, "default", 1).setHasReplacement(); -LevelType *LevelType::lvl_flat=NULL;// = new LevelType(1, "flat"); -LevelType *LevelType::lvl_largeBiomes = NULL;// = new LevelType(2, "largeBiomes"); -LevelType *LevelType::lvl_normal_1_1=NULL;// = new LevelType(8, "default_1_1", 0).setSelectableByUser(false); +LevelType *LevelType::lvl_normal=nullptr;// = new LevelType(0, "default", 1).setHasReplacement(); +LevelType *LevelType::lvl_flat=nullptr;// = new LevelType(1, "flat"); +LevelType *LevelType::lvl_largeBiomes = nullptr;// = new LevelType(2, "largeBiomes"); +LevelType *LevelType::lvl_normal_1_1=nullptr;// = new LevelType(8, "default_1_1", 0).setSelectableByUser(false); void LevelType::staticCtor() { - for(int i=0;i<16;i++) levelTypes[i]=NULL; + for(int i=0;i<16;i++) levelTypes[i]=nullptr; lvl_normal = new LevelType(0, L"default", 1); lvl_normal->setHasReplacement(); lvl_flat = new LevelType(1, L"flat"); @@ -107,13 +107,13 @@ LevelType *LevelType::getLevelType(wstring name) { wstring genname=levelTypes[i]->m_generatorName; - if (levelTypes[i] != NULL && (genname.compare(name)==0)) + if (levelTypes[i] != nullptr && (genname.compare(name)==0)) { return levelTypes[i]; } } } - return NULL; + return nullptr; } int LevelType::getId() diff --git a/Minecraft.World/LeverTile.cpp b/Minecraft.World/LeverTile.cpp index eea9e3d32..7a7cdfd54 100644 --- a/Minecraft.World/LeverTile.cpp +++ b/Minecraft.World/LeverTile.cpp @@ -10,7 +10,7 @@ LeverTile::LeverTile(int id) : Tile(id, Material::decoration,isSolidRender()) AABB *LeverTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool LeverTile::blocksLight() diff --git a/Minecraft.World/LiquidTile.cpp b/Minecraft.World/LiquidTile.cpp index 2e098928d..be6c582d3 100644 --- a/Minecraft.World/LiquidTile.cpp +++ b/Minecraft.World/LiquidTile.cpp @@ -131,7 +131,7 @@ bool LiquidTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int f AABB *LiquidTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } int LiquidTile::getRenderShape() @@ -349,7 +349,7 @@ void LiquidTile::animateTick(Level *level, int x, int y, int z, Random *random) double LiquidTile::getSlopeAngle(LevelSource *level, int x, int y, int z, Material *m) { - Vec3 *flow = NULL; + Vec3 *flow = nullptr; if (m == Material::water) flow = ((LiquidTile *) Tile::water)->getFlow(level, x, y, z); if (m == Material::lava) flow = ((LiquidTile *) Tile::lava)->getFlow(level, x, y, z); if (flow->x == 0 && flow->z == 0) return -1000; @@ -425,5 +425,5 @@ Icon *LiquidTile::getTexture(const wstring &name) if (name.compare(TEXTURE_WATER_FLOW)==0) return Tile::water->icons[1]; if (name.compare(TEXTURE_LAVA_STILL)==0) return Tile::lava->icons[0]; if (name.compare(TEXTURE_LAVA_FLOW)==0) return Tile::lava->icons[1]; - return NULL; + return nullptr; } diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index c12f0a989..814a768c3 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -39,7 +39,7 @@ AttributeModifier *LivingEntity::SPEED_MODIFIER_SPRINTING = (new AttributeModifi void LivingEntity::_init() { - attributes = NULL; + attributes = nullptr; combatTracker = new CombatTracker(this); lastEquipment = ItemInstanceArray(5); @@ -126,7 +126,7 @@ LivingEntity::~LivingEntity() delete attributes; delete combatTracker; - if(lastEquipment.data != NULL) delete [] lastEquipment.data; + if(lastEquipment.data != nullptr) delete [] lastEquipment.data; } void LivingEntity::defineSynchedData() @@ -198,7 +198,7 @@ void LivingEntity::baseTick() if (isFireImmune() || level->isClientSide) clearFire(); shared_ptr thisPlayer = dynamic_pointer_cast(shared_from_this()); - bool isInvulnerable = (thisPlayer != NULL && thisPlayer->abilities.invulnerable); + bool isInvulnerable = (thisPlayer != nullptr && thisPlayer->abilities.invulnerable); if (isAlive() && isUnderLiquid(Material::water)) { @@ -253,13 +253,13 @@ void LivingEntity::baseTick() lastHurtByPlayer.reset(); } } - if (lastHurtMob != NULL && !lastHurtMob->isAlive()) + if (lastHurtMob != nullptr && !lastHurtMob->isAlive()) { lastHurtMob = nullptr; } // If lastHurtByMob is dead, remove it - if (lastHurtByMob != NULL && !lastHurtByMob->isAlive()) + if (lastHurtByMob != nullptr && !lastHurtByMob->isAlive()) { setLastHurtByMob(nullptr); } @@ -401,7 +401,7 @@ void LivingEntity::addAdditonalSaveData(CompoundTag *entityTag) for (unsigned int i = 0; i < items.length; ++i) { shared_ptr item = items[i]; - if (item != NULL) + if (item != nullptr) { attributes->removeItemModifiers(item); } @@ -412,7 +412,7 @@ void LivingEntity::addAdditonalSaveData(CompoundTag *entityTag) for (unsigned int i = 0; i < items.length; ++i) { shared_ptr item = items[i]; - if (item != NULL) + if (item != nullptr) { attributes->addItemModifiers(item); } @@ -435,7 +435,7 @@ void LivingEntity::readAdditionalSaveData(CompoundTag *tag) { setAbsorptionAmount(tag->getFloat(L"AbsorptionAmount")); - if (tag->contains(L"Attributes") && level != NULL && !level->isClientSide) + if (tag->contains(L"Attributes") && level != nullptr && !level->isClientSide) { SharedMonsterAttributes::loadAttributes(getAttributes(), (ListTag *) tag->getList(L"Attributes")); } @@ -458,7 +458,7 @@ void LivingEntity::readAdditionalSaveData(CompoundTag *tag) else { Tag *healthTag = tag->get(L"Health"); - if (healthTag == NULL) + if (healthTag == nullptr) { setHealth(getMaxHealth()); } @@ -611,7 +611,7 @@ bool LivingEntity::hasEffect(MobEffect *effect) MobEffectInstance *LivingEntity::getEffect(MobEffect *effect) { - MobEffectInstance *effectInst = NULL; + MobEffectInstance *effectInst = nullptr; auto it = activeEffects.find(effect->id); if(it != activeEffects.end() ) effectInst = it->second; @@ -685,7 +685,7 @@ void LivingEntity::removeEffectNoUpdate(int effectId) if (it != activeEffects.end()) { MobEffectInstance *effect = it->second; - if(effect != NULL) + if(effect != nullptr) { delete effect; } @@ -699,7 +699,7 @@ void LivingEntity::removeEffect(int effectId) if (it != activeEffects.end()) { MobEffectInstance *effect = it->second; - if(effect != NULL) + if(effect != nullptr) { onEffectRemoved(effect); delete effect; @@ -757,8 +757,8 @@ bool LivingEntity::hurt(DamageSource *source, float dmg) // Fix for #8823 - Gameplay: Confirmation that a monster or animal has taken damage from an attack is highly delayed // 4J Stu - Change to the fix to only show damage when attacked, rather than collision damage // Fix for #10299 - When in corners, passive mobs may show that they are taking damage. - // 4J Stu - Change to the fix for TU6, as source is never NULL due to changes in 1.8.2 to what source actually is - if (level->isClientSide && dynamic_cast(source) == NULL) return false; + // 4J Stu - Change to the fix for TU6, as source is never nullptr due to changes in 1.8.2 to what source actually is + if (level->isClientSide && dynamic_cast(source) == nullptr) return false; noActionTime = 0; if (getHealth() <= 0) return false; @@ -773,7 +773,7 @@ bool LivingEntity::hurt(DamageSource *source, float dmg) return false; } - if ((source == DamageSource::anvil || source == DamageSource::fallingBlock) && getCarried(SLOT_HELM) != NULL) + if ((source == DamageSource::anvil || source == DamageSource::fallingBlock) && getCarried(SLOT_HELM) != nullptr) { getCarried(SLOT_HELM)->hurtAndBreak(static_cast(dmg * 4 + random->nextFloat() * dmg * 2.0f), dynamic_pointer_cast( shared_from_this() )); dmg *= 0.75f; @@ -801,7 +801,7 @@ bool LivingEntity::hurt(DamageSource *source, float dmg) hurtDir = 0; shared_ptr sourceEntity = source->getEntity(); - if (sourceEntity != NULL) + if (sourceEntity != nullptr) { if ( sourceEntity->instanceof(eTYPE_LIVINGENTITY) ) { @@ -833,7 +833,7 @@ bool LivingEntity::hurt(DamageSource *source, float dmg) { level->broadcastEntityEvent(shared_from_this(), EntityEvent::HURT); if (source != DamageSource::drown) markHurt(); - if (sourceEntity != NULL) + if (sourceEntity != nullptr) { double xd = sourceEntity->x - x; double zd = sourceEntity->z - z; @@ -888,9 +888,9 @@ void LivingEntity::die(DamageSource *source) { shared_ptr sourceEntity = source->getEntity(); shared_ptr killer = getKillCredit(); - if (deathScore >= 0 && killer != NULL) killer->awardKillScore(shared_from_this(), deathScore); + if (deathScore >= 0 && killer != nullptr) killer->awardKillScore(shared_from_this(), deathScore); - if (sourceEntity != NULL) sourceEntity->killed( dynamic_pointer_cast( shared_from_this() ) ); + if (sourceEntity != nullptr) sourceEntity->killed( dynamic_pointer_cast( shared_from_this() ) ); dead = true; @@ -899,7 +899,7 @@ void LivingEntity::die(DamageSource *source) int playerBonus = 0; shared_ptr player = nullptr; - if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_PLAYER) ) + if ( (sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_PLAYER) ) { player = dynamic_pointer_cast(sourceEntity); playerBonus = EnchantmentHelper::getKillingLootBonus(dynamic_pointer_cast(player)); @@ -920,7 +920,7 @@ void LivingEntity::die(DamageSource *source) } // 4J-JEV, hook for Durango mobKill event. - if (player != NULL) + if (player != nullptr) { player->awardStat(GenericStats::killMob(),GenericStats::param_mobKill(player, dynamic_pointer_cast(shared_from_this()), source)); } @@ -1005,7 +1005,7 @@ void LivingEntity::causeFallDamage(float distance) { Entity::causeFallDamage(distance); MobEffectInstance *jumpBoost = getEffect(MobEffect::jump); - float padding = jumpBoost != NULL ? jumpBoost->getAmplifier() + 1 : 0; + float padding = jumpBoost != nullptr ? jumpBoost->getAmplifier() + 1 : 0; int dmg = static_cast(ceil(distance - 3 - padding)); if (dmg > 0) @@ -1050,7 +1050,7 @@ int LivingEntity::getArmorValue() for (unsigned int i = 0; i < items.length; ++i) { shared_ptr item = items[i]; - if (item != NULL && dynamic_cast(item->getItem()) != NULL) + if (item != nullptr && dynamic_cast(item->getItem()) != nullptr) { int baseProtection = static_cast(item->getItem())->defense; val += baseProtection; @@ -1131,9 +1131,9 @@ CombatTracker *LivingEntity::getCombatTracker() shared_ptr LivingEntity::getKillCredit() { - if (combatTracker->getKiller() != NULL) return combatTracker->getKiller(); - if (lastHurtByPlayer != NULL) return lastHurtByPlayer; - if (lastHurtByMob != NULL) return lastHurtByMob; + if (combatTracker->getKiller() != nullptr) return combatTracker->getKiller(); + if (lastHurtByPlayer != nullptr) return lastHurtByPlayer; + if (lastHurtByMob != nullptr) return lastHurtByMob; return nullptr; } @@ -1172,7 +1172,7 @@ void LivingEntity::swing() swingTime = -1; swinging = true; - if (dynamic_cast(level) != NULL) + if (dynamic_cast(level) != nullptr) { static_cast(level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::SWING))); } @@ -1250,7 +1250,7 @@ AttributeInstance *LivingEntity::getAttribute(Attribute *attribute) BaseAttributeMap *LivingEntity::getAttributes() { - if (attributes == NULL) + if (attributes == nullptr) { attributes = new ServersideAttributeMap(); } @@ -1268,7 +1268,7 @@ void LivingEntity::setSprinting(bool value) Entity::setSprinting(value); AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); - if (speed->getModifier(eModifierId_MOB_SPRINTING) != NULL) + if (speed->getModifier(eModifierId_MOB_SPRINTING) != nullptr) { speed->removeModifier(eModifierId_MOB_SPRINTING); } @@ -1378,7 +1378,7 @@ void LivingEntity::travel(float xa, float ya) { #ifdef __PSVITA__ // AP - dynamic_pointer_cast is a non-trivial call - Player *thisPlayer = NULL; + Player *thisPlayer = nullptr; if( this->instanceof(eTYPE_PLAYER) ) { thisPlayer = (Player*) this; @@ -1603,9 +1603,9 @@ void LivingEntity::tick() if (!ItemInstance::matches(current, previous)) { static_cast(level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new SetEquippedItemPacket(entityId, i, current))); - if (previous != NULL) attributes->removeItemModifiers(previous); - if (current != NULL) attributes->addItemModifiers(current); - lastEquipment[i] = current == NULL ? nullptr : current->copy(); + if (previous != nullptr) attributes->removeItemModifiers(previous); + if (current != nullptr) attributes->addItemModifiers(current); + lastEquipment[i] = current == nullptr ? nullptr : current->copy(); } } } @@ -1804,7 +1804,7 @@ void LivingEntity::pushEntities() { vector > *entities = level->getEntities(shared_from_this(), this->bb->grow(0.2f, 0, 0.2f)); - if (entities != NULL && !entities->empty()) + if (entities != nullptr && !entities->empty()) { for (auto& e : *entities) { @@ -1876,7 +1876,7 @@ void LivingEntity::take(shared_ptr e, int orgCount) bool LivingEntity::canSee(shared_ptr target) { HitResult *hres = level->clip(Vec3::newTemp(x, y + getHeadHeight(), z), Vec3::newTemp(target->x, target->y + target->getHeadHeight(), target->z)); - bool retVal = (hres == NULL); + bool retVal = (hres == nullptr); delete hres; return retVal; } @@ -1984,7 +1984,7 @@ void LivingEntity::setAbsorptionAmount(float absorptionAmount) Team *LivingEntity::getTeam() { - return NULL; + return nullptr; } bool LivingEntity::isAlliedTo(shared_ptr other) @@ -1994,7 +1994,7 @@ bool LivingEntity::isAlliedTo(shared_ptr other) bool LivingEntity::isAlliedTo(Team *other) { - if (getTeam() != NULL) + if (getTeam() != nullptr) { return getTeam()->isAlliedTo(other); } diff --git a/Minecraft.World/LivingEntity.h b/Minecraft.World/LivingEntity.h index 5869eeb29..ecc819df9 100644 --- a/Minecraft.World/LivingEntity.h +++ b/Minecraft.World/LivingEntity.h @@ -26,7 +26,7 @@ class LivingEntity : public Entity public: // 4J-PB - added to replace (e instanceof Type), avoiding dynamic casts eINSTANCEOF GetType() { return eTYPE_LIVINGENTITY;} - static Entity *create(Level *level) { return NULL; } + static Entity *create(Level *level) { return nullptr; } private: static AttributeModifier *SPEED_MODIFIER_SPRINTING; diff --git a/Minecraft.World/LoginPacket.cpp b/Minecraft.World/LoginPacket.cpp index 97f25a677..3ae5fe46f 100644 --- a/Minecraft.World/LoginPacket.cpp +++ b/Minecraft.World/LoginPacket.cpp @@ -30,7 +30,7 @@ LoginPacket::LoginPacket() m_playerCapeId = 0; m_isGuest = false; m_newSeaLevel = false; - m_pLevelType = NULL; + m_pLevelType = nullptr; m_uiGamePrivileges = 0; m_xzSize = LEVEL_MAX_WIDTH; m_hellScale = HELL_LEVEL_MAX_SCALE; @@ -59,7 +59,7 @@ LoginPacket::LoginPacket(const wstring& userName, int clientVersion, PlayerUID o m_playerCapeId = capeId; m_isGuest = isGuest; m_newSeaLevel = false; - m_pLevelType = NULL; + m_pLevelType = nullptr; m_uiGamePrivileges = 0; m_xzSize = LEVEL_MAX_WIDTH; m_hellScale = HELL_LEVEL_MAX_SCALE; @@ -100,7 +100,7 @@ void LoginPacket::read(DataInputStream *dis) //throws IOException userName = readUtf(dis, Player::MAX_NAME_LENGTH); wstring typeName = readUtf(dis, 16); m_pLevelType = LevelType::getLevelType(typeName); - if (m_pLevelType == NULL) + if (m_pLevelType == nullptr) { m_pLevelType = LevelType::lvl_normal; } @@ -135,7 +135,7 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException { dos->writeInt(clientVersion); writeUtf(userName, dos); - if (m_pLevelType == NULL) + if (m_pLevelType == nullptr) { writeUtf(L"", dos); } @@ -174,7 +174,7 @@ void LoginPacket::handle(PacketListener *listener) int LoginPacket::getEstimatedSize() { int length=0; - if (m_pLevelType != NULL) + if (m_pLevelType != nullptr) { length = static_cast(m_pLevelType->getGeneratorName().length()); } diff --git a/Minecraft.World/LookAtPlayerGoal.cpp b/Minecraft.World/LookAtPlayerGoal.cpp index dcf1ea4fa..a2e4786a5 100644 --- a/Minecraft.World/LookAtPlayerGoal.cpp +++ b/Minecraft.World/LookAtPlayerGoal.cpp @@ -29,7 +29,7 @@ bool LookAtPlayerGoal::canUse() { if (mob->getRandom()->nextFloat() >= probability) return false; - if (mob->getTarget() != NULL) + if (mob->getTarget() != nullptr) { lookAt = mob->getTarget(); } @@ -41,12 +41,12 @@ bool LookAtPlayerGoal::canUse() { lookAt = weak_ptr(mob->level->getClosestEntityOfClass(lookAtType, mob->bb->grow(lookDistance, 3, lookDistance), mob->shared_from_this())); } - return lookAt.lock() != NULL; + return lookAt.lock() != nullptr; } bool LookAtPlayerGoal::canContinueToUse() { - if (lookAt.lock() == NULL || !lookAt.lock()->isAlive()) return false; + if (lookAt.lock() == nullptr || !lookAt.lock()->isAlive()) return false; if (mob->distanceToSqr(lookAt.lock()) > lookDistance * lookDistance) return false; return lookTime > 0; } diff --git a/Minecraft.World/MakeLoveGoal.cpp b/Minecraft.World/MakeLoveGoal.cpp index d64ee9b13..c308e33cc 100644 --- a/Minecraft.World/MakeLoveGoal.cpp +++ b/Minecraft.World/MakeLoveGoal.cpp @@ -26,11 +26,11 @@ bool MakeLoveGoal::canUse() if (villager->getRandom()->nextInt(500) != 0) return false; village = level->villages->getClosestVillage(Mth::floor(villager->x), Mth::floor(villager->y), Mth::floor(villager->z), 0); - if (village.lock() == NULL) return false; + if (village.lock() == nullptr) return false; if (!villageNeedsMoreVillagers()) return false; shared_ptr mate = level->getClosestEntityOfClass(typeid(Villager), villager->bb->grow(8, 3, 8), villager->shared_from_this()); - if (mate == NULL) return false; + if (mate == nullptr) return false; partner = weak_ptr(dynamic_pointer_cast(mate)); if (partner.lock()->getAge() != 0) return false; @@ -53,7 +53,7 @@ void MakeLoveGoal::stop() bool MakeLoveGoal::canContinueToUse() { - return partner.lock() != NULL && loveMakingTime >= 0 && villageNeedsMoreVillagers() && villager->getAge() == 0; + return partner.lock() != nullptr && loveMakingTime >= 0 && villageNeedsMoreVillagers() && villager->getAge() == 0; } void MakeLoveGoal::tick() @@ -76,7 +76,7 @@ void MakeLoveGoal::tick() bool MakeLoveGoal::villageNeedsMoreVillagers() { shared_ptr _village = village.lock(); - if( _village == NULL ) return false; + if( _village == nullptr ) return false; if (!_village->isBreedTimerOk()) { diff --git a/Minecraft.World/MapItem.cpp b/Minecraft.World/MapItem.cpp index c02a8716e..af9792afb 100644 --- a/Minecraft.World/MapItem.cpp +++ b/Minecraft.World/MapItem.cpp @@ -24,7 +24,7 @@ shared_ptr MapItem::getSavedData(short idNum, Level *level) std::wstring id = wstring( L"map_" ) + std::to_wstring(idNum); shared_ptr mapItemSavedData = dynamic_pointer_cast(level->getSavedData(typeid(MapItemSavedData), id)); - if (mapItemSavedData == NULL) + if (mapItemSavedData == nullptr) { // 4J Stu - This call comes from ClientConnection, but i don't see why we should be trying to work out // the id again when it's passed as a param. In any case that won't work with the new map setup @@ -48,7 +48,7 @@ shared_ptr MapItem::getSavedData(shared_ptr item shared_ptr mapItemSavedData = dynamic_pointer_cast( level->getSavedData(typeid(MapItemSavedData), id ) ); bool newData = false; - if (mapItemSavedData == NULL) + if (mapItemSavedData == nullptr) { // 4J Stu - I don't see why we should be trying to work out the id again when it's passed as a param. // In any case that won't work with the new map setup @@ -295,7 +295,7 @@ shared_ptr MapItem::getUpdatePacket(shared_ptr itemInstanc { charArray data = MapItem::getSavedData(itemInstance, level)->getUpdatePacket(itemInstance, level, player); - if (data.data == NULL || data.length == 0) return nullptr; + if (data.data == nullptr || data.length == 0) return nullptr; shared_ptr retval = shared_ptr(new ComplexItemDataPacket(static_cast(Item::map->id), static_cast(itemInstance->getAuxValue()), data)); delete data.data; @@ -325,7 +325,7 @@ void MapItem::onCraftedBy(shared_ptr itemInstance, Level *level, s shared_ptr data = getSavedData(itemInstance->getAuxValue(), level); // 4J Stu - We only have one map per player per dimension, so don't reset the one that they have // when a new one is created - if( data == NULL ) + if( data == nullptr ) { data = shared_ptr( new MapItemSavedData(id) ); } diff --git a/Minecraft.World/MapItemSavedData.cpp b/Minecraft.World/MapItemSavedData.cpp index 7bbc9f0b6..2495b4551 100644 --- a/Minecraft.World/MapItemSavedData.cpp +++ b/Minecraft.World/MapItemSavedData.cpp @@ -107,7 +107,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptrisFramed(); - if (lastSentDecorations.data == NULL || lastSentDecorations.length != data.length) + if (lastSentDecorations.data == nullptr || lastSentDecorations.length != data.length) { thesame = false; } @@ -125,7 +125,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptrgetByteArray(L"colors"); //4J - if(colors.data != NULL) + if(colors.data != nullptr) { delete[] colors.data; } @@ -399,7 +399,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr player, shared_ptrgetPlayerList(); for(auto& decorationPlayer : players->players) { - if(decorationPlayer!=NULL && decorationPlayer->dimension == this->dimension) + if(decorationPlayer!=nullptr && decorationPlayer->dimension == this->dimension) { float xd = static_cast(decorationPlayer->x - x) / (1 << scale); float yd = static_cast(decorationPlayer->z - z) / (1 << scale); diff --git a/Minecraft.World/Material.cpp b/Minecraft.World/Material.cpp index 9e201ad54..d17965dfb 100644 --- a/Minecraft.World/Material.cpp +++ b/Minecraft.World/Material.cpp @@ -6,39 +6,39 @@ #include "PortalMaterial.h" #include "WebMaterial.h"// 4J added, Java version just does a local alteration when instantiating the Material for webs to get the same thing -Material *Material::air = NULL; -Material *Material::grass = NULL; -Material *Material::dirt = NULL; -Material *Material::wood = NULL; -Material *Material::stone = NULL; -Material *Material::metal = NULL; -Material *Material::heavyMetal = NULL; -Material *Material::water = NULL; -Material *Material::lava = NULL; -Material *Material::leaves = NULL; -Material *Material::plant = NULL; -Material *Material::replaceable_plant = NULL; -Material *Material::sponge = NULL; -Material *Material::cloth = NULL; -Material *Material::fire = NULL; -Material *Material::sand = NULL; -Material *Material::decoration = NULL; -Material *Material::clothDecoration = NULL; -Material *Material::glass = NULL; -Material *Material::buildable_glass = NULL; -Material *Material::explosive = NULL; -Material *Material::coral = NULL; -Material *Material::ice = NULL; -Material *Material::topSnow = NULL; -Material *Material::snow = NULL; -Material *Material::cactus = NULL; -Material *Material::clay = NULL; -Material *Material::vegetable = NULL; -Material *Material::egg = NULL; -Material *Material::portal = NULL; -Material *Material::cake = NULL; -Material *Material::piston = NULL; -Material *Material::web = NULL; +Material *Material::air = nullptr; +Material *Material::grass = nullptr; +Material *Material::dirt = nullptr; +Material *Material::wood = nullptr; +Material *Material::stone = nullptr; +Material *Material::metal = nullptr; +Material *Material::heavyMetal = nullptr; +Material *Material::water = nullptr; +Material *Material::lava = nullptr; +Material *Material::leaves = nullptr; +Material *Material::plant = nullptr; +Material *Material::replaceable_plant = nullptr; +Material *Material::sponge = nullptr; +Material *Material::cloth = nullptr; +Material *Material::fire = nullptr; +Material *Material::sand = nullptr; +Material *Material::decoration = nullptr; +Material *Material::clothDecoration = nullptr; +Material *Material::glass = nullptr; +Material *Material::buildable_glass = nullptr; +Material *Material::explosive = nullptr; +Material *Material::coral = nullptr; +Material *Material::ice = nullptr; +Material *Material::topSnow = nullptr; +Material *Material::snow = nullptr; +Material *Material::cactus = nullptr; +Material *Material::clay = nullptr; +Material *Material::vegetable = nullptr; +Material *Material::egg = nullptr; +Material *Material::portal = nullptr; +Material *Material::cake = nullptr; +Material *Material::piston = nullptr; +Material *Material::web = nullptr; void Material::staticCtor() { diff --git a/Minecraft.World/MaterialColor.cpp b/Minecraft.World/MaterialColor.cpp index d14748b2a..5c4fa9d78 100644 --- a/Minecraft.World/MaterialColor.cpp +++ b/Minecraft.World/MaterialColor.cpp @@ -3,20 +3,20 @@ MaterialColor **MaterialColor::colors; -MaterialColor *MaterialColor::none = NULL; -MaterialColor *MaterialColor::grass = NULL; -MaterialColor *MaterialColor::sand = NULL; -MaterialColor *MaterialColor::cloth = NULL; -MaterialColor *MaterialColor::fire = NULL; -MaterialColor *MaterialColor::ice = NULL; -MaterialColor *MaterialColor::metal = NULL; -MaterialColor *MaterialColor::plant = NULL; -MaterialColor *MaterialColor::snow = NULL; -MaterialColor *MaterialColor::clay = NULL; -MaterialColor *MaterialColor::dirt = NULL; -MaterialColor *MaterialColor::stone = NULL; -MaterialColor *MaterialColor::water = NULL; -MaterialColor *MaterialColor::wood = NULL; +MaterialColor *MaterialColor::none = nullptr; +MaterialColor *MaterialColor::grass = nullptr; +MaterialColor *MaterialColor::sand = nullptr; +MaterialColor *MaterialColor::cloth = nullptr; +MaterialColor *MaterialColor::fire = nullptr; +MaterialColor *MaterialColor::ice = nullptr; +MaterialColor *MaterialColor::metal = nullptr; +MaterialColor *MaterialColor::plant = nullptr; +MaterialColor *MaterialColor::snow = nullptr; +MaterialColor *MaterialColor::clay = nullptr; +MaterialColor *MaterialColor::dirt = nullptr; +MaterialColor *MaterialColor::stone = nullptr; +MaterialColor *MaterialColor::water = nullptr; +MaterialColor *MaterialColor::wood = nullptr; void MaterialColor::staticCtor() { diff --git a/Minecraft.World/McRegionChunkStorage.cpp b/Minecraft.World/McRegionChunkStorage.cpp index 344ff6c7c..4b543de57 100644 --- a/Minecraft.World/McRegionChunkStorage.cpp +++ b/Minecraft.World/McRegionChunkStorage.cpp @@ -76,7 +76,7 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z) #ifdef SPLIT_SAVES // If we can't find the chunk in the save file, then we should remove any entities we might have for that chunk - if(regionChunkInputStream == NULL) + if(regionChunkInputStream == nullptr) { __int64 index = ((__int64)(x) << 32) | (((__int64)(z))&0x00000000FFFFFFFF); @@ -89,11 +89,11 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z) } #endif - LevelChunk *levelChunk = NULL; + LevelChunk *levelChunk = nullptr; if(m_saveFile->getOriginalSaveVersion() >= SAVE_FILE_VERSION_COMPRESSED_CHUNK_STORAGE) { - if (regionChunkInputStream != NULL) + if (regionChunkInputStream != nullptr) { MemSect(9); levelChunk = OldChunkStorage::load(level, regionChunkInputStream); @@ -106,14 +106,14 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z) else { CompoundTag *chunkData; - if (regionChunkInputStream != NULL) + if (regionChunkInputStream != nullptr) { MemSect(8); chunkData = NbtIo::read((DataInput *)regionChunkInputStream); MemSect(0); } else { - return NULL; + return nullptr; } regionChunkInputStream->deleteChildStream(); @@ -125,7 +125,7 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z) sprintf(buf,"Chunk file at %d, %d is missing level data, skipping\n",x, z); app.DebugPrintf(buf); delete chunkData; - return NULL; + return nullptr; } if (!chunkData->getCompound(L"Level")->contains(L"Blocks")) { @@ -133,7 +133,7 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z) sprintf(buf,"Chunk file at %d, %d is missing block data, skipping\n",x, z); app.DebugPrintf(buf); delete chunkData; - return NULL; + return nullptr; } MemSect(9); levelChunk = OldChunkStorage::load(level, chunkData->getCompound(L"Level")); @@ -146,7 +146,7 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z) app.DebugPrintf(buf); delete levelChunk; delete chunkData; - return NULL; + return nullptr; // 4J Stu - We delete the data within OldChunkStorage::load, so we can never reload from it //chunkData->putInt(L"xPos", x); @@ -330,8 +330,8 @@ void McRegionChunkStorage::staticCtor() sprintf(threadName,"McRegion Save thread %d\n",i); SetThreadName(0, threadName); - //saveThreads[j] = CreateThread(NULL,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]); - s_saveThreads[i] = new C4JThread(runSaveThreadProc,NULL,threadName); + //saveThreads[j] = CreateThread(nullptr,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]); + s_saveThreads[i] = new C4JThread(runSaveThreadProc,nullptr,threadName); //app.DebugPrintf("Created new thread: %s\n",threadName); @@ -359,7 +359,7 @@ int McRegionChunkStorage::runSaveThreadProc(LPVOID lpParam) bool running = true; size_t lastQueueSize = 0; - DataOutputStream *dos = NULL; + DataOutputStream *dos = nullptr; while(running) { if( TryEnterCriticalSection(&cs_memory) ) @@ -382,7 +382,7 @@ int McRegionChunkStorage::runSaveThreadProc(LPVOID lpParam) PIXEndNamedEvent(); } delete dos; - dos = NULL; + dos = nullptr; EnterCriticalSection(&cs_memory); s_runningThreadCount--; diff --git a/Minecraft.World/McRegionLevelStorage.cpp b/Minecraft.World/McRegionLevelStorage.cpp index daf6a7ef2..ec472fad7 100644 --- a/Minecraft.World/McRegionLevelStorage.cpp +++ b/Minecraft.World/McRegionLevelStorage.cpp @@ -24,14 +24,14 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension) { //File folder = getFolder(); - if (dynamic_cast(dimension) != NULL) + if (dynamic_cast(dimension) != nullptr) { if(app.GetResetNether()) { #ifdef SPLIT_SAVES vector *netherFiles = m_saveFile->getRegionFilesByDimension(1); - if(netherFiles!=NULL) + if(netherFiles!=nullptr) { DWORD bytesWritten = 0; for(auto& netherFile : *netherFiles) @@ -42,7 +42,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension) } #else vector *netherFiles = m_saveFile->getFilesWithPrefix(LevelStorage::NETHER_FOLDER); - if(netherFiles!=NULL) + if(netherFiles!=nullptr) { for(auto& netherFile : *netherFiles) { @@ -74,7 +74,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension) vector *endFiles = m_saveFile->getFilesWithPrefix(LevelStorage::ENDER_FOLDER); // 4J-PB - There will be no End in early saves - if(endFiles!=NULL) + if(endFiles!=nullptr) { for(auto& endFile : *endFiles) { diff --git a/Minecraft.World/McRegionLevelStorageSource.cpp b/Minecraft.World/McRegionLevelStorageSource.cpp index d0aef97a4..d36706ead 100644 --- a/Minecraft.World/McRegionLevelStorageSource.cpp +++ b/Minecraft.World/McRegionLevelStorageSource.cpp @@ -51,12 +51,12 @@ vector *McRegionLevelStorageSource::getLevelList() wstring levelId = file->getName(); LevelData *levelData = getDataTagFor(levelId); - if (levelData != NULL) + if (levelData != nullptr) { bool requiresConversion = levelData->getVersion() != McRegionLevelStorage::MCREGION_VERSION_ID; wstring levelName = levelData->getLevelName(); - if (levelName.empty()) // 4J Jev TODO: levelName can't be NULL? if (levelName == NULL || isEmpty(levelName)) + if (levelName.empty()) // 4J Jev TODO: levelName can't be nullptr? if (levelName == nullptr || isEmpty(levelName)) { levelName = levelId; } @@ -83,7 +83,7 @@ bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const { // check if there is old file format level data LevelData *levelData = getDataTagFor(saveFile, levelId); - if (levelData == NULL || levelData->getVersion() != 0) + if (levelData == nullptr || levelData->getVersion() != 0) { delete levelData; return false; @@ -96,7 +96,7 @@ bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const bool McRegionLevelStorageSource::requiresConversion(ConsoleSaveFile *saveFile, const wstring& levelId) { LevelData *levelData = getDataTagFor(saveFile, levelId); - if (levelData == NULL || levelData->getVersion() != 0) + if (levelData == nullptr || levelData->getVersion() != 0) { delete levelData; return false; diff --git a/Minecraft.World/MegaTreeFeature.cpp b/Minecraft.World/MegaTreeFeature.cpp index 0d01130f6..db4a336ac 100644 --- a/Minecraft.World/MegaTreeFeature.cpp +++ b/Minecraft.World/MegaTreeFeature.cpp @@ -15,7 +15,7 @@ bool MegaTreeFeature::place(Level *level, Random *random, int x, int y, int z) if (y < 1 || y + treeHeight + 1 > Level::maxBuildHeight) return false; // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { PIXBeginNamedEvent(0, "MegaTreeFeature Checking intersects"); LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); diff --git a/Minecraft.World/MeleeAttackGoal.cpp b/Minecraft.World/MeleeAttackGoal.cpp index 7003609e2..5b7b01799 100644 --- a/Minecraft.World/MeleeAttackGoal.cpp +++ b/Minecraft.World/MeleeAttackGoal.cpp @@ -19,7 +19,7 @@ void MeleeAttackGoal::_init(PathfinderMob *mob, double speedModifier, bool track attackTime = 0; - path = NULL; + path = nullptr; timeToRecalcPath = 0; } @@ -36,24 +36,24 @@ MeleeAttackGoal::MeleeAttackGoal(PathfinderMob *mob, double speedModifier, bool MeleeAttackGoal::~MeleeAttackGoal() { - if(path != NULL) delete path; + if(path != nullptr) delete path; } bool MeleeAttackGoal::canUse() { shared_ptr target = mob->getTarget(); - if (target == NULL) return false; + if (target == nullptr) return false; if (!target->isAlive()) return false; - if (attackType != NULL && !target->instanceof(attackType)) return false; + if (attackType != eTYPE_NOTSET && !target->instanceof(attackType)) return false; delete path; path = mob->getNavigation()->createPath(target); - return path != NULL; + return path != nullptr; } bool MeleeAttackGoal::canContinueToUse() { shared_ptr target = mob->getTarget(); - if (target == NULL) return false; + if (target == nullptr) return false; if (!target->isAlive()) return false; if (!trackTarget) return !mob->getNavigation()->isDone(); if (!mob->isWithinRestriction(Mth::floor(target->x), Mth::floor(target->y), Mth::floor(target->z))) return false; @@ -63,7 +63,7 @@ bool MeleeAttackGoal::canContinueToUse() void MeleeAttackGoal::start() { mob->getNavigation()->moveTo(path, speedModifier); - path = NULL; + path = nullptr; timeToRecalcPath = 0; } @@ -91,6 +91,6 @@ void MeleeAttackGoal::tick() if (mob->distanceToSqr(target->x, target->bb->y0, target->z) > meleeRadiusSqr) return; if (attackTime > 0) return; attackTime = 20; - if (mob->getCarriedItem() != NULL) mob->swing(); + if (mob->getCarriedItem() != nullptr) mob->swing(); mob->doHurtTarget(target); } diff --git a/Minecraft.World/MelonTile.cpp b/Minecraft.World/MelonTile.cpp index 298ae61f0..be7cd98b8 100644 --- a/Minecraft.World/MelonTile.cpp +++ b/Minecraft.World/MelonTile.cpp @@ -6,7 +6,7 @@ MelonTile::MelonTile(int id) : Tile(id, Material::vegetable) { - iconTop = NULL; + iconTop = nullptr; } Icon *MelonTile::getTexture(int face, int data) diff --git a/Minecraft.World/MemoryChunkStorage.cpp b/Minecraft.World/MemoryChunkStorage.cpp index 249efdd9a..9ce5305dc 100644 --- a/Minecraft.World/MemoryChunkStorage.cpp +++ b/Minecraft.World/MemoryChunkStorage.cpp @@ -5,7 +5,7 @@ LevelChunk *MemoryChunkStorage::load(Level *level, int x, int z) //throws IOException { - return NULL; + return nullptr; } void MemoryChunkStorage::save(Level *level, LevelChunk *levelChunk) //throws IOException diff --git a/Minecraft.World/MemoryLevelStorage.cpp b/Minecraft.World/MemoryLevelStorage.cpp index 5a1d43bb5..5c5fe53d6 100644 --- a/Minecraft.World/MemoryLevelStorage.cpp +++ b/Minecraft.World/MemoryLevelStorage.cpp @@ -14,7 +14,7 @@ MemoryLevelStorage::MemoryLevelStorage() LevelData *MemoryLevelStorage::prepareLevel() { - return NULL; + return nullptr; } void MemoryLevelStorage::checkSession() @@ -54,7 +54,7 @@ bool MemoryLevelStorage::load(shared_ptr player) CompoundTag *MemoryLevelStorage::loadPlayerDataTag(const wstring& playerName) { - return NULL; + return nullptr; } ConsoleSavePath MemoryLevelStorage::getDataFile(const wstring& id) diff --git a/Minecraft.World/MemoryLevelStorageSource.cpp b/Minecraft.World/MemoryLevelStorageSource.cpp index db0cfa583..3028b3b19 100644 --- a/Minecraft.World/MemoryLevelStorageSource.cpp +++ b/Minecraft.World/MemoryLevelStorageSource.cpp @@ -29,7 +29,7 @@ void MemoryLevelStorageSource::clearAll() LevelData *MemoryLevelStorageSource::getDataTagFor(const wstring& levelId) { - return NULL; + return nullptr; } bool MemoryLevelStorageSource::isNewLevelIdAcceptable(const wstring& levelId) diff --git a/Minecraft.World/MerchantContainer.cpp b/Minecraft.World/MerchantContainer.cpp index 7ceb47455..b9c9bb529 100644 --- a/Minecraft.World/MerchantContainer.cpp +++ b/Minecraft.World/MerchantContainer.cpp @@ -11,7 +11,7 @@ MerchantContainer::MerchantContainer(shared_ptr player, shared_ptr MerchantContainer::getItem(unsigned int slot) shared_ptr MerchantContainer::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { if (slot == MerchantMenu::RESULT_SLOT) { @@ -71,7 +71,7 @@ bool MerchantContainer::isPaymentSlot(int slot) shared_ptr MerchantContainer::removeItemNoUpdate(int slot) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -83,7 +83,7 @@ shared_ptr MerchantContainer::removeItemNoUpdate(int slot) void MerchantContainer::setItem(unsigned int slot, shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); if (isPaymentSlot(slot)) { updateSellItem(); @@ -135,37 +135,37 @@ void MerchantContainer::setChanged() void MerchantContainer::updateSellItem() { - activeRecipe = NULL; + activeRecipe = nullptr; shared_ptr buyItem1 = items[MerchantMenu::PAYMENT1_SLOT]; shared_ptr buyItem2 = items[MerchantMenu::PAYMENT2_SLOT]; - if (buyItem1 == NULL) + if (buyItem1 == nullptr) { buyItem1 = buyItem2; buyItem2 = nullptr; } - if (buyItem1 == NULL) + if (buyItem1 == nullptr) { setItem(MerchantMenu::RESULT_SLOT, nullptr); } else { MerchantRecipeList *offers = merchant->getOffers(player); - if (offers != NULL) + if (offers != nullptr) { MerchantRecipe *recipeFor = offers->getRecipeFor(buyItem1, buyItem2, selectionHint); - if (recipeFor != NULL && !recipeFor->isDeprecated()) + if (recipeFor != nullptr && !recipeFor->isDeprecated()) { activeRecipe = recipeFor; setItem(MerchantMenu::RESULT_SLOT, recipeFor->getSellItem()->copy()); } - else if (buyItem2 != NULL) + else if (buyItem2 != nullptr) { // try to switch recipeFor = offers->getRecipeFor(buyItem2, buyItem1, selectionHint); - if (recipeFor != NULL && !recipeFor->isDeprecated()) + if (recipeFor != nullptr && !recipeFor->isDeprecated()) { activeRecipe = recipeFor; setItem(MerchantMenu::RESULT_SLOT, recipeFor->getSellItem()->copy()); diff --git a/Minecraft.World/MerchantMenu.cpp b/Minecraft.World/MerchantMenu.cpp index 52ce34f9d..2fe9cf6aa 100644 --- a/Minecraft.World/MerchantMenu.cpp +++ b/Minecraft.World/MerchantMenu.cpp @@ -67,10 +67,10 @@ bool MerchantMenu::stillValid(shared_ptr player) shared_ptr MerchantMenu::quickMoveStack(shared_ptr player, int slotIndex) { shared_ptr clicked = nullptr; - Slot *slot = NULL; + Slot *slot = nullptr; if(slotIndex < slots.size()) slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); @@ -138,7 +138,7 @@ void MerchantMenu::removed(shared_ptr player) player->drop(item); } item = tradeContainer->removeItemNoUpdate(PAYMENT2_SLOT); - if (item != NULL) + if (item != nullptr) { player->drop(item); } diff --git a/Minecraft.World/MerchantRecipe.cpp b/Minecraft.World/MerchantRecipe.cpp index b772b0c71..9c30c36bb 100644 --- a/Minecraft.World/MerchantRecipe.cpp +++ b/Minecraft.World/MerchantRecipe.cpp @@ -54,7 +54,7 @@ shared_ptr MerchantRecipe::getBuyBItem() bool MerchantRecipe::hasSecondaryBuyItem() { - return buyB != NULL; + return buyB != nullptr; } shared_ptr MerchantRecipe::getSellItem() @@ -68,13 +68,13 @@ bool MerchantRecipe::isSame(MerchantRecipe *other) { return false; } - return (buyB == NULL && other->buyB == NULL) || (buyB != NULL && other->buyB != NULL && buyB->id == other->buyB->id); + return (buyB == nullptr && other->buyB == nullptr) || (buyB != nullptr && other->buyB != nullptr && buyB->id == other->buyB->id); } bool MerchantRecipe::isSameSameButBetter(MerchantRecipe *other) { // same deal, but cheaper - return isSame(other) && (buyA->count < other->buyA->count || (buyB != NULL && buyB->count < other->buyB->count)); + return isSame(other) && (buyA->count < other->buyA->count || (buyB != nullptr && buyB->count < other->buyB->count)); } int MerchantRecipe::getUses() @@ -136,7 +136,7 @@ CompoundTag *MerchantRecipe::createTag() CompoundTag *tag = new CompoundTag(); tag->putCompound(L"buy", buyA->save(new CompoundTag(L"buy"))); tag->putCompound(L"sell", sell->save(new CompoundTag(L"sell"))); - if (buyB != NULL) + if (buyB != nullptr) { tag->putCompound(L"buyB", buyB->save(new CompoundTag(L"buyB"))); } diff --git a/Minecraft.World/MerchantRecipeList.cpp b/Minecraft.World/MerchantRecipeList.cpp index d8f37c7f2..2a88da16d 100644 --- a/Minecraft.World/MerchantRecipeList.cpp +++ b/Minecraft.World/MerchantRecipeList.cpp @@ -25,25 +25,25 @@ MerchantRecipe *MerchantRecipeList::getRecipeFor(shared_ptr buyA, { // attempt to match vs the hint MerchantRecipe *r = m_recipes.at(selectionHint); - if (buyA->id == r->getBuyAItem()->id && ((buyB == NULL && !r->hasSecondaryBuyItem()) || (r->hasSecondaryBuyItem() && buyB != NULL && r->getBuyBItem()->id == buyB->id))) + if (buyA->id == r->getBuyAItem()->id && ((buyB == nullptr && !r->hasSecondaryBuyItem()) || (r->hasSecondaryBuyItem() && buyB != nullptr && r->getBuyBItem()->id == buyB->id))) { if (buyA->count >= r->getBuyAItem()->count && (!r->hasSecondaryBuyItem() || buyB->count >= r->getBuyBItem()->count)) { return r; } } - return NULL; + return nullptr; } for (int i = 0; i < m_recipes.size(); i++) { MerchantRecipe *r = m_recipes.at(i); if (buyA->id == r->getBuyAItem()->id && buyA->count >= r->getBuyAItem()->count - && ((!r->hasSecondaryBuyItem() && buyB == NULL) || (r->hasSecondaryBuyItem() && buyB != NULL && r->getBuyBItem()->id == buyB->id && buyB->count >= r->getBuyBItem()->count))) + && ((!r->hasSecondaryBuyItem() && buyB == nullptr) || (r->hasSecondaryBuyItem() && buyB != nullptr && r->getBuyBItem()->id == buyB->id && buyB->count >= r->getBuyBItem()->count))) { return r; } } - return NULL; + return nullptr; } bool MerchantRecipeList::addIfNewOrBetter(MerchantRecipe *recipe) @@ -74,13 +74,13 @@ MerchantRecipe *MerchantRecipeList::getMatchingRecipeFor(shared_ptrid == r->getBuyAItem()->id && buy->count >= r->getBuyAItem()->count && sell->id == r->getSellItem()->id) { - if (!r->hasSecondaryBuyItem() || (buyB != NULL && buyB->id == r->getBuyBItem()->id && buyB->count >= r->getBuyBItem()->count)) + if (!r->hasSecondaryBuyItem() || (buyB != nullptr && buyB->id == r->getBuyBItem()->id && buyB->count >= r->getBuyBItem()->count)) { return r; } } } - return NULL; + return nullptr; } void MerchantRecipeList::writeToStream(DataOutputStream *stream) @@ -93,8 +93,8 @@ void MerchantRecipeList::writeToStream(DataOutputStream *stream) Packet::writeItem(r->getSellItem(), stream); shared_ptr buyBItem = r->getBuyBItem(); - stream->writeBoolean(buyBItem != NULL); - if (buyBItem != NULL) + stream->writeBoolean(buyBItem != nullptr); + if (buyBItem != nullptr) { Packet::writeItem(buyBItem, stream); } diff --git a/Minecraft.World/MerchantResultSlot.cpp b/Minecraft.World/MerchantResultSlot.cpp index fedbcc4ad..7a09d069a 100644 --- a/Minecraft.World/MerchantResultSlot.cpp +++ b/Minecraft.World/MerchantResultSlot.cpp @@ -42,7 +42,7 @@ void MerchantResultSlot::onTake(shared_ptr player, shared_ptrgetActiveRecipe(); - if (activeRecipe != NULL) + if (activeRecipe != nullptr) { shared_ptr item1 = slots->getItem(MerchantMenu::PAYMENT1_SLOT); shared_ptr item2 = slots->getItem(MerchantMenu::PAYMENT2_SLOT); @@ -76,15 +76,15 @@ bool MerchantResultSlot::removePaymentItemsIfMatching(MerchantRecipe *activeReci shared_ptr buyA = activeRecipe->getBuyAItem(); shared_ptr buyB = activeRecipe->getBuyBItem(); - if (a != NULL && a->id == buyA->id) + if (a != nullptr && a->id == buyA->id) { - if (buyB != NULL && b != NULL && buyB->id == b->id) + if (buyB != nullptr && b != nullptr && buyB->id == b->id) { a->count -= buyA->count; b->count -= buyB->count; return true; } - else if (buyB == NULL && b == NULL) + else if (buyB == nullptr && b == nullptr) { a->count -= buyA->count; return true; diff --git a/Minecraft.World/MineShaftFeature.cpp b/Minecraft.World/MineShaftFeature.cpp index d32af346a..ebf59025d 100644 --- a/Minecraft.World/MineShaftFeature.cpp +++ b/Minecraft.World/MineShaftFeature.cpp @@ -32,7 +32,7 @@ bool MineShaftFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { bool forcePlacement = false; LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); - if( levelGenOptions != NULL ) + if( levelGenOptions != nullptr ) { forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Mineshaft); } diff --git a/Minecraft.World/MineShaftPieces.cpp b/Minecraft.World/MineShaftPieces.cpp index 3fda1bfcd..6f1d9adbd 100644 --- a/Minecraft.World/MineShaftPieces.cpp +++ b/Minecraft.World/MineShaftPieces.cpp @@ -44,7 +44,7 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list * if (randomSelection >= 80) { BoundingBox *crossingBox = MineShaftCrossing::findCrossing(pieces, random, footX, footY, footZ, direction); - if (crossingBox != NULL) + if (crossingBox != nullptr) { return new MineShaftCrossing(genDepth, random, crossingBox, direction); } @@ -52,7 +52,7 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list * else if (randomSelection >= 70) { BoundingBox *stairsBox = MineShaftStairs::findStairs(pieces, random, footX, footY, footZ, direction); - if (stairsBox != NULL) + if (stairsBox != nullptr) { return new MineShaftPieces::MineShaftStairs(genDepth, random, stairsBox, direction); } @@ -60,28 +60,28 @@ StructurePiece *MineShaftPieces::createRandomShaftPiece(list * else { BoundingBox *corridorBox = MineShaftCorridor::findCorridorSize(pieces, random, footX, footY, footZ, direction); - if (corridorBox != NULL) + if (corridorBox != nullptr) { return new MineShaftCorridor(genDepth, random, corridorBox, direction); } } - return NULL; + return nullptr; } StructurePiece *MineShaftPieces::generateAndAddPiece(StructurePiece *startPiece, list *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { if (depth > MAX_DEPTH) { - return NULL; + return nullptr; } if (abs(footX - startPiece->getBoundingBox()->x0) > 5 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 5 * 16) { - return NULL; + return nullptr; } StructurePiece *newPiece = createRandomShaftPiece(pieces, random, footX, footY, footZ, direction, depth + 1); - if (newPiece != NULL) + if (newPiece != nullptr) { MemSect(50); pieces->push_back(newPiece); @@ -132,7 +132,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis break; } StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + pos, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 - 1, Direction::NORTH, depth); - if (child != NULL) + if (child != nullptr) { BoundingBox *childBox = child->getBoundingBox(); childEntranceBoxes.push_back(new BoundingBox(childBox->x0, childBox->y0, boundingBox->z0, childBox->x1, childBox->y1, boundingBox->z0 + 1)); @@ -149,7 +149,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis break; } StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + pos, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z1 + 1, Direction::SOUTH, depth); - if (child != NULL) + if (child != nullptr) { BoundingBox *childBox = child->getBoundingBox(); childEntranceBoxes.push_back(new BoundingBox(childBox->x0, childBox->y0, boundingBox->z1 - 1, childBox->x1, childBox->y1, boundingBox->z1)); @@ -166,7 +166,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis break; } StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 + pos, Direction::WEST, depth); - if (child != NULL) + if (child != nullptr) { BoundingBox *childBox = child->getBoundingBox(); childEntranceBoxes.push_back(new BoundingBox(boundingBox->x0, childBox->y0, childBox->z0, boundingBox->x0 + 1, childBox->y1, childBox->z1)); @@ -183,7 +183,7 @@ void MineShaftPieces::MineShaftRoom::addChildren(StructurePiece *startPiece, lis break; } StructurePiece *child = generateAndAddPiece(startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0 + random->nextInt(heightSpace) + 1, boundingBox->z0 + pos, Direction::EAST, depth); - if (child != NULL) + if (child != nullptr) { BoundingBox *childBox = child->getBoundingBox(); childEntranceBoxes.push_back(new BoundingBox(boundingBox->x1 - 1, childBox->y0, childBox->z0, boundingBox->x1, childBox->y1, childBox->z1)); @@ -304,7 +304,7 @@ BoundingBox *MineShaftPieces::MineShaftCorridor::findCorridorSize(list *pieces, Random *random) @@ -515,7 +515,7 @@ bool MineShaftPieces::MineShaftCorridor::postProcess(Level *level, Random *rando hasPlacedSpider = true; level->setTileAndData(x, y, newZ, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS); shared_ptr entity = dynamic_pointer_cast( level->getTileEntity(x, y, newZ) ); - if (entity != NULL) entity->getSpawner()->setEntityId(L"CaveSpider"); + if (entity != nullptr) entity->getSpawner()->setEntityId(L"CaveSpider"); } } } @@ -605,10 +605,10 @@ BoundingBox *MineShaftPieces::MineShaftCrossing::findCrossing(list break; } - if (StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return box; diff --git a/Minecraft.World/Minecart.cpp b/Minecraft.World/Minecart.cpp index 43caf0a23..34076b126 100644 --- a/Minecraft.World/Minecart.cpp +++ b/Minecraft.World/Minecart.cpp @@ -44,7 +44,7 @@ void Minecart::_init() blocksBuilding = true; setSize(0.98f, 0.7f); heightOffset = bbHeight / 2.0f; - soundUpdater = NULL; + soundUpdater = nullptr; name = L""; // @@ -56,7 +56,7 @@ Minecart::Minecart(Level *level) : Entity( level ) { _init(); - //soundUpdater = level != NULL ? level->makeSoundUpdater(this) : NULL; + //soundUpdater = level != nullptr ? level->makeSoundUpdater(this) : nullptr; } Minecart::~Minecart() @@ -105,12 +105,12 @@ AABB *Minecart::getCollideAgainstBox(shared_ptr entity) { return entity->bb; } - return NULL; + return nullptr; } AABB *Minecart::getCollideBox() { - return NULL; + return nullptr; } bool Minecart::isPushable() @@ -145,7 +145,7 @@ bool Minecart::hurt(DamageSource *source, float hurtDamage) // 4J-JEV: Fix for #88212, // Untrusted players shouldn't be able to damage minecarts or boats. - if (dynamic_cast(source) != NULL) + if (dynamic_cast(source) != nullptr) { shared_ptr attacker = source->getDirectEntity(); @@ -163,14 +163,14 @@ bool Minecart::hurt(DamageSource *source, float hurtDamage) // 4J Stu - If someone is riding in this, then it can tick multiple times which causes the damage to // decrease too quickly. So just make the damage a bit higher to start with for similar behaviour // to an unridden one. Only do this change if the riding player is attacking it. - if( rider.lock() != NULL && rider.lock() == source->getEntity() ) hurtDamage += 1; + if( rider.lock() != nullptr && rider.lock() == source->getEntity() ) hurtDamage += 1; - bool creativePlayer = source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) && dynamic_pointer_cast(source->getEntity())->abilities.instabuild; + bool creativePlayer = source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) && dynamic_pointer_cast(source->getEntity())->abilities.instabuild; if (creativePlayer || getDamage() > 20 * 2) { // 4J HEG - Fixed issue with player falling through the ground on destroying a minecart while riding (issue #160607) - if (rider.lock() != NULL) rider.lock()->ride(nullptr); + if (rider.lock() != nullptr) rider.lock()->ride(nullptr); if (!creativePlayer || hasCustomName()) { @@ -207,12 +207,12 @@ bool Minecart::isPickable() void Minecart::remove() { Entity::remove(); - //if (soundUpdater != NULL) soundUpdater->tick(); + //if (soundUpdater != nullptr) soundUpdater->tick(); } void Minecart::tick() { - //if (soundUpdater != NULL) soundUpdater->tick(); + //if (soundUpdater != nullptr) soundUpdater->tick(); // 4J - make minecarts (server-side) tick twice, to put things back to how they were when we were accidently ticking them twice for( int i = 0; i < 2; i++ ) { @@ -223,7 +223,7 @@ void Minecart::tick() outOfWorld(); } - if (!level->isClientSide && dynamic_cast(level) != NULL) + if (!level->isClientSide && dynamic_cast(level) != nullptr) { MinecraftServer *server = static_cast(level)->getServer(); int waitTime = getPortalWaitTime(); @@ -232,7 +232,7 @@ void Minecart::tick() { if (server->isNetherEnabled()) { - if (riding == NULL) + if (riding == nullptr) { if (portalTime++ >= waitTime) { @@ -344,7 +344,7 @@ void Minecart::tick() setRot(yRot, xRot); vector > *entities = level->getEntities(shared_from_this(), bb->grow(0.2f, 0, 0.2f)); - if (entities != NULL && !entities->empty()) + if (entities != nullptr && !entities->empty()) { for (auto& e : *entities) { @@ -361,7 +361,7 @@ void Minecart::tick() } } - if (rider.lock() != NULL) + if (rider.lock() != nullptr) { if (rider.lock()->removed) { @@ -454,7 +454,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl zd = pow * zD / dd; - if ( rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY) ) + if ( rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_LIVINGENTITY) ) { shared_ptr living = dynamic_pointer_cast(rider.lock()); @@ -530,7 +530,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl double xdd = xd; double zdd = zd; - if (rider.lock() != NULL) + if (rider.lock() != nullptr) { xdd *= 0.75; zdd *= 0.75; @@ -554,7 +554,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl applyNaturalSlowdown(); Vec3 *newPos = getPos(x, y, z); - if (newPos != NULL && oldPos != NULL) + if (newPos != nullptr && oldPos != nullptr) { double speed = (oldPos->y - newPos->y) * 0.05; @@ -619,7 +619,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl void Minecart::applyNaturalSlowdown() { - if (rider.lock() != NULL) + if (rider.lock() != nullptr) { xd *= 0.997f; yd *= 0; @@ -684,7 +684,7 @@ Vec3 *Minecart::getPosOffs(double x, double y, double z, double offs) return getPos(x, y, z); } - return NULL; + return nullptr; } Vec3 *Minecart::getPos(double x, double y, double z) @@ -756,7 +756,7 @@ Vec3 *Minecart::getPos(double x, double y, double z) if (yD > 0) y += 0.5; return Vec3::newTemp(x, y, z); } - return NULL; + return nullptr; } void Minecart::readAdditionalSaveData(CompoundTag *tag) @@ -776,7 +776,7 @@ void Minecart::addAdditonalSaveData(CompoundTag *tag) if (hasCustomDisplay()) { tag->putBoolean(L"CustomDisplayTile", true); - tag->putInt(L"DisplayTile", getDisplayTile() == NULL ? 0 : getDisplayTile()->id); + tag->putInt(L"DisplayTile", getDisplayTile() == nullptr ? 0 : getDisplayTile()->id); tag->putInt(L"DisplayData", getDisplayData()); tag->putInt(L"DisplayOffset", getDisplayOffset()); } @@ -796,7 +796,7 @@ void Minecart::push(shared_ptr e) 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 ( (rider.lock() == NULL) && (e->riding == NULL) ) + if ( (rider.lock() == nullptr) && (e->riding == nullptr) ) { e->ride( shared_from_this() ); } @@ -844,7 +844,7 @@ void Minecart::push(shared_ptr e) double zdd = (e->zd + zd); shared_ptr cart = dynamic_pointer_cast(e); - if (cart != NULL && cart->getType() == TYPE_FURNACE && getType() != TYPE_FURNACE) + if (cart != nullptr && cart->getType() == TYPE_FURNACE && getType() != TYPE_FURNACE) { xd *= 0.2f; zd *= 0.2f; @@ -853,7 +853,7 @@ void Minecart::push(shared_ptr e) e->zd *= 0.95f; m_bHasPushedCartThisTick = true; } - else if (cart != NULL && cart->getType() != TYPE_FURNACE && getType() == TYPE_FURNACE) + else if (cart != nullptr && cart->getType() != TYPE_FURNACE && getType() == TYPE_FURNACE) { e->xd *= 0.2f; e->zd *= 0.2f; @@ -957,12 +957,12 @@ Tile *Minecart::getDisplayTile() { if (!hasCustomDisplay()) return getDefaultDisplayTile(); int id = getEntityData()->getInteger(DATA_ID_DISPLAY_TILE) & 0xFFFF; - return id > 0 && id < Tile::TILE_NUM_COUNT ? Tile::tiles[id] : NULL; + return id > 0 && id < Tile::TILE_NUM_COUNT ? Tile::tiles[id] : nullptr; } Tile *Minecart::getDefaultDisplayTile() { - return NULL; + return nullptr; } int Minecart::getDisplayData() @@ -996,7 +996,7 @@ void Minecart::setDisplayTile(int id) void Minecart::setDisplayData(int data) { Tile *tile = getDisplayTile(); - int id = tile == NULL ? 0 : tile->id; + int id = tile == nullptr ? 0 : tile->id; getEntityData()->set(DATA_ID_DISPLAY_TILE, (id & 0xFFFF) | (data << 16)); setCustomDisplay(true); diff --git a/Minecraft.World/MinecartContainer.cpp b/Minecraft.World/MinecartContainer.cpp index 54883281c..e1a7e002a 100644 --- a/Minecraft.World/MinecartContainer.cpp +++ b/Minecraft.World/MinecartContainer.cpp @@ -33,7 +33,7 @@ void MinecartContainer::destroy(DamageSource *source) for (int i = 0; i < getContainerSize(); i++) { shared_ptr item = getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; @@ -63,7 +63,7 @@ shared_ptr MinecartContainer::getItem(unsigned int slot) shared_ptr MinecartContainer::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { if (items[slot]->count <= count) { @@ -83,7 +83,7 @@ shared_ptr MinecartContainer::removeItem(unsigned int slot, int co shared_ptr MinecartContainer::removeItemNoUpdate(int slot) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -95,7 +95,7 @@ shared_ptr MinecartContainer::removeItemNoUpdate(int slot) void MinecartContainer::setItem(unsigned int slot, shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); } void MinecartContainer::setChanged() @@ -145,7 +145,7 @@ void MinecartContainer::remove() for (int i = 0; i < getContainerSize(); i++) { shared_ptr item = getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; @@ -185,7 +185,7 @@ void MinecartContainer::addAdditonalSaveData(CompoundTag *base) for (int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i)); diff --git a/Minecraft.World/MinecartFurnace.cpp b/Minecraft.World/MinecartFurnace.cpp index 838d8a272..b2ced6ed3 100644 --- a/Minecraft.World/MinecartFurnace.cpp +++ b/Minecraft.World/MinecartFurnace.cpp @@ -123,7 +123,7 @@ void MinecartFurnace::applyNaturalSlowdown() bool MinecartFurnace::interact(shared_ptr player) { shared_ptr selected = player->inventory->getSelected(); - if (selected != NULL && selected->id == Item::coal_Id) + if (selected != nullptr && selected->id == Item::coal_Id) { if (!player->abilities.instabuild && --selected->count == 0) player->inventory->setItem(player->inventory->selected, nullptr); fuel += SharedConstants::TICKS_PER_SECOND * 180; diff --git a/Minecraft.World/MinecartRideable.cpp b/Minecraft.World/MinecartRideable.cpp index a006a2bc1..5578fe3f4 100644 --- a/Minecraft.World/MinecartRideable.cpp +++ b/Minecraft.World/MinecartRideable.cpp @@ -23,8 +23,8 @@ MinecartRideable::MinecartRideable(Level *level, double x, double y, double z) : bool MinecartRideable::interact(shared_ptr player) { - if (rider.lock() != NULL && rider.lock()->instanceof(eTYPE_PLAYER) && rider.lock() != player) return true; - if (rider.lock() != NULL && rider.lock() != player) return false; + if (rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_PLAYER) && rider.lock() != player) return true; + if (rider.lock() != nullptr && rider.lock() != player) return false; if (!level->isClientSide) { player->ride(shared_from_this()); diff --git a/Minecraft.World/Mob.cpp b/Minecraft.World/Mob.cpp index 2d363c0b0..af49499ae 100644 --- a/Minecraft.World/Mob.cpp +++ b/Minecraft.World/Mob.cpp @@ -43,7 +43,7 @@ void Mob::_init() lookingAt = nullptr; lookTime = 0; target = nullptr; - sensing = NULL; + sensing = nullptr; equipment = ItemInstanceArray(5); dropChances = floatArray(5); @@ -58,7 +58,7 @@ void Mob::_init() _isLeashed = false; leashHolder = nullptr; - leashInfoTag = NULL; + leashInfoTag = nullptr; } Mob::Mob( Level* level) : LivingEntity(level) @@ -87,16 +87,16 @@ Mob::Mob( Level* level) : LivingEntity(level) Mob::~Mob() { - if(lookControl != NULL) delete lookControl; - if(moveControl != NULL) delete moveControl; - if(jumpControl != NULL) delete jumpControl; - if(bodyControl != NULL) delete bodyControl; - if(navigation != NULL) delete navigation; - if(sensing != NULL) delete sensing; + if(lookControl != nullptr) delete lookControl; + if(moveControl != nullptr) delete moveControl; + if(jumpControl != nullptr) delete jumpControl; + if(bodyControl != nullptr) delete bodyControl; + if(navigation != nullptr) delete navigation; + if(sensing != nullptr) delete sensing; - if(leashInfoTag != NULL) delete leashInfoTag; + if(leashInfoTag != nullptr) delete leashInfoTag; - if(equipment.data != NULL) delete [] equipment.data; + if(equipment.data != nullptr) delete [] equipment.data; delete [] dropChances.data; } @@ -196,7 +196,7 @@ int Mob::getExperienceReward(shared_ptr killedBy) ItemInstanceArray slots = getEquipmentSlots(); for (int i = 0; i < slots.length; i++) { - if (slots[i] != NULL && dropChances[i] <= 1) + if (slots[i] != nullptr && dropChances[i] <= 1) { result += 1 + random->nextInt(3); } @@ -280,7 +280,7 @@ void Mob::addAdditonalSaveData(CompoundTag *entityTag) for (int i = 0; i < equipment.length; i++) { CompoundTag *tag = new CompoundTag(); - if (equipment[i] != NULL) equipment[i]->save(tag); + if (equipment[i] != nullptr) equipment[i]->save(tag); gear->add(tag); } entityTag->put(L"Equipment", gear); @@ -296,7 +296,7 @@ void Mob::addAdditonalSaveData(CompoundTag *entityTag) // leash info entityTag->putBoolean(L"Leashed", _isLeashed); - if (leashHolder != NULL) + if (leashHolder != nullptr) { CompoundTag *leashTag = new CompoundTag(L"Leash"); if ( leashHolder->instanceof(eTYPE_LIVINGENTITY) ) @@ -372,7 +372,7 @@ void Mob::aiStep() for (auto& it : *entities) { shared_ptr entity = dynamic_pointer_cast(it); - if (entity->removed || entity->getItem() == NULL) continue; + if (entity->removed || entity->getItem() == nullptr) continue; shared_ptr item = entity->getItem(); int slot = getEquipmentSlotForItem(item); @@ -381,17 +381,17 @@ void Mob::aiStep() bool replace = true; shared_ptr current = getCarried(slot); - if (current != NULL) + if (current != nullptr) { if (slot == SLOT_WEAPON) { WeaponItem *newWeapon = dynamic_cast(item->getItem()); WeaponItem *oldWeapon = dynamic_cast(current->getItem()); - if ( newWeapon != NULL && oldWeapon == NULL) + if ( newWeapon != nullptr && oldWeapon == nullptr) { replace = true; } - else if (newWeapon != NULL && oldWeapon != NULL) + else if (newWeapon != nullptr && oldWeapon != nullptr) { if (newWeapon->getTierDamage() == oldWeapon->getTierDamage()) { @@ -411,11 +411,11 @@ void Mob::aiStep() { ArmorItem *newArmor = dynamic_cast(item->getItem()); ArmorItem *oldArmor = dynamic_cast(current->getItem()); - if (newArmor != NULL && oldArmor == NULL) + if (newArmor != nullptr && oldArmor == nullptr) { replace = true; } - else if (newArmor != NULL && oldArmor != NULL) + else if (newArmor != nullptr && oldArmor != nullptr) { if (newArmor->defense == oldArmor->defense) { @@ -435,7 +435,7 @@ void Mob::aiStep() if (replace) { - if (current != NULL && random->nextFloat() - 0.1f < dropChances[slot]) + if (current != nullptr && random->nextFloat() - 0.1f < dropChances[slot]) { spawnAtLocation(current, 0); } @@ -470,7 +470,7 @@ void Mob::checkDespawn() return; } shared_ptr player = level->getNearestPlayer(shared_from_this(), -1); - if (player != NULL) + if (player != nullptr) { double xd = player->x - x; double yd = player->y - y; @@ -547,7 +547,7 @@ void Mob::serverAiStep() if (random->nextFloat() < 0.02f) { shared_ptr player = level->getNearestPlayer(shared_from_this(), lookDistance); - if (player != NULL) + if (player != nullptr) { lookingAt = player; lookTime = 10 + random->nextInt(20); @@ -558,7 +558,7 @@ void Mob::serverAiStep() } } - if (lookingAt != NULL) + if (lookingAt != nullptr) { lookAt(lookingAt, 10.0f, static_cast(getMaxHeadXRot())); if (lookTime-- <= 0 || lookingAt->removed || lookingAt->distanceToSqr(shared_from_this()) > lookDistance * lookDistance) @@ -613,7 +613,7 @@ void Mob::lookAt(shared_ptr e, float yMax, float xMax) bool Mob::isLookingAtAnEntity() { - return lookingAt != NULL; + return lookingAt != nullptr; } shared_ptr Mob::getLookingAt() @@ -658,7 +658,7 @@ int Mob::getMaxSpawnClusterSize() int Mob::getMaxFallDistance() { - if (getTarget() == NULL) return 3; + if (getTarget() == nullptr) return 3; int sacrifice = static_cast(getHealth() - (getMaxHealth() * 0.33f)); sacrifice -= (3 - level->difficulty) * 4; if (sacrifice < 0) sacrifice = 0; @@ -697,7 +697,7 @@ void Mob::dropEquipment(bool byPlayer, int playerBonusLevel) shared_ptr item = getCarried(slot); bool preserve = dropChances[slot] > 1; - if (item != NULL && (byPlayer || preserve) && random->nextFloat() - playerBonusLevel * 0.01f < dropChances[slot]) + if (item != nullptr && (byPlayer || preserve) && random->nextFloat() - playerBonusLevel * 0.01f < dropChances[slot]) { if (!preserve && item->isDamageableItem()) { @@ -726,10 +726,10 @@ void Mob::populateDefaultEquipmentSlots() { shared_ptr item = getArmor(i); if (i < 3 && random->nextFloat() < partialChance) break; - if (item == NULL) + if (item == nullptr) { Item *equip = getEquipmentForSlot(i + 1, armorType); - if (equip != NULL) setEquippedSlot(i + 1, shared_ptr(new ItemInstance(equip))); + if (equip != nullptr) setEquippedSlot(i + 1, shared_ptr(new ItemInstance(equip))); } } } @@ -743,7 +743,7 @@ int Mob::getEquipmentSlotForItem(shared_ptr item) } ArmorItem *armorItem = dynamic_cast(item->getItem()); - if (armorItem != NULL) + if (armorItem != nullptr) { switch (armorItem->slot) { @@ -791,21 +791,21 @@ Item *Mob::getEquipmentForSlot(int slot, int type) if (type == 4) return Item::boots_diamond; } - return NULL; + return nullptr; } void Mob::populateDefaultEquipmentEnchantments() { float difficulty = level->getDifficulty(x, y, z); - if (getCarriedItem() != NULL && random->nextFloat() < MAX_ENCHANTED_WEAPON_CHANCE * difficulty) { + if (getCarriedItem() != nullptr && random->nextFloat() < MAX_ENCHANTED_WEAPON_CHANCE * difficulty) { EnchantmentHelper::enchantItem(random, getCarriedItem(), static_cast(5 + difficulty * random->nextInt(18))); } for (int i = 0; i < 4; i++) { shared_ptr item = getArmor(i); - if (item != NULL && random->nextFloat() < MAX_ENCHANTED_ARMOR_CHANCE * difficulty) + if (item != nullptr && random->nextFloat() < MAX_ENCHANTED_ARMOR_CHANCE * difficulty) { EnchantmentHelper::enchantItem(random, item, static_cast(5 + difficulty * random->nextInt(18))); } @@ -908,7 +908,7 @@ bool Mob::interact(shared_ptr player) } shared_ptr itemstack = player->inventory->getSelected(); - if (itemstack != NULL) + if (itemstack != nullptr) { // it's inconvenient to have the leash code here, but it's because // the mob.interact(player) method has priority over @@ -953,7 +953,7 @@ bool Mob::mobInteract(shared_ptr player) void Mob::tickLeash() { - if (leashInfoTag != NULL) + if (leashInfoTag != nullptr) { restoreLeashFromSave(); } @@ -962,7 +962,7 @@ void Mob::tickLeash() return; } - if (leashHolder == NULL || leashHolder->removed) + if (leashHolder == nullptr || leashHolder->removed) { dropLeash(true, true); return; @@ -981,7 +981,7 @@ void Mob::dropLeash(bool synch, bool createItemDrop) } ServerLevel *serverLevel = dynamic_cast(level); - if (!level->isClientSide && synch && serverLevel != NULL) + if (!level->isClientSide && synch && serverLevel != nullptr) { serverLevel->getTracker()->broadcast(shared_from_this(), shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, shared_from_this(), nullptr))); } @@ -1018,7 +1018,7 @@ void Mob::setLeashedTo(shared_ptr holder, bool synch) void Mob::restoreLeashFromSave() { // after being added to the world, attempt to recreate leash bond - if (_isLeashed && leashInfoTag != NULL) + if (_isLeashed && leashInfoTag != nullptr) { if (leashInfoTag->contains(L"UUID")) { @@ -1043,7 +1043,7 @@ void Mob::restoreLeashFromSave() int z = leashInfoTag->getInt(L"Z"); shared_ptr activeKnot = LeashFenceKnotEntity::findKnotAt(level, x, y, z); - if (activeKnot == NULL) + if (activeKnot == nullptr) { activeKnot = LeashFenceKnotEntity::createAndAddKnot(level, x, y, z); } @@ -1055,7 +1055,7 @@ void Mob::restoreLeashFromSave() dropLeash(false, true); } } - leashInfoTag = NULL; + leashInfoTag = nullptr; } // 4J added so we can not render mobs before their chunks are loaded - to resolve bug 10327 :Gameplay: NPCs can spawn over chunks that have not yet been streamed and display jitter. diff --git a/Minecraft.World/Mob.h b/Minecraft.World/Mob.h index 113105098..e070e3695 100644 --- a/Minecraft.World/Mob.h +++ b/Minecraft.World/Mob.h @@ -27,7 +27,7 @@ class Mob : public LivingEntity public: // 4J-PB - added to replace (e instanceof Type), avoiding dynamic casts eINSTANCEOF GetType() { return eTYPE_MOB;} - static Entity *create(Level *level) { return NULL; } + static Entity *create(Level *level) { return nullptr; } public: static const float MAX_WEARING_ARMOR_CHANCE; diff --git a/Minecraft.World/MobCategory.cpp b/Minecraft.World/MobCategory.cpp index 507be6eda..8c6d3b444 100644 --- a/Minecraft.World/MobCategory.cpp +++ b/Minecraft.World/MobCategory.cpp @@ -5,14 +5,14 @@ #include "Material.h" #include "MobCategory.h" -MobCategory *MobCategory::monster = NULL; -MobCategory *MobCategory::creature = NULL; -MobCategory *MobCategory::ambient = NULL; -MobCategory *MobCategory::waterCreature = NULL; +MobCategory *MobCategory::monster = nullptr; +MobCategory *MobCategory::creature = nullptr; +MobCategory *MobCategory::ambient = nullptr; +MobCategory *MobCategory::waterCreature = nullptr; // 4J - added these extra categories -MobCategory *MobCategory::creature_wolf = NULL; -MobCategory *MobCategory::creature_chicken = NULL; -MobCategory *MobCategory::creature_mushroomcow = NULL; +MobCategory *MobCategory::creature_wolf = nullptr; +MobCategory *MobCategory::creature_chicken = nullptr; +MobCategory *MobCategory::creature_mushroomcow = nullptr; MobCategoryArray MobCategory::values = MobCategoryArray(7); diff --git a/Minecraft.World/MobEffect.cpp b/Minecraft.World/MobEffect.cpp index f9978ca7d..4ded9c41a 100644 --- a/Minecraft.World/MobEffect.cpp +++ b/Minecraft.World/MobEffect.cpp @@ -46,7 +46,7 @@ MobEffect *MobEffect::reserved_31; void MobEffect::staticCtor() { - voidEffect = NULL; + voidEffect = nullptr; movementSpeed = (new MobEffect(1, false, eMinecraftColour_Effect_MovementSpeed)) ->setDescriptionId(IDS_POTION_MOVESPEED) ->setPostfixDescriptionId(IDS_POTION_MOVESPEED_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Speed)->addAttributeModifier(SharedMonsterAttributes::MOVEMENT_SPEED, eModifierId_POTION_MOVESPEED, 0.2f, AttributeModifier::OPERATION_MULTIPLY_TOTAL); //setIcon(0, 0); movementSlowdown = (new MobEffect(2, true, eMinecraftColour_Effect_MovementSlowDown)) ->setDescriptionId(IDS_POTION_MOVESLOWDOWN) ->setPostfixDescriptionId(IDS_POTION_MOVESLOWDOWN_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Slowness)->addAttributeModifier(SharedMonsterAttributes::MOVEMENT_SPEED, eModifierId_POTION_MOVESLOWDOWN, -0.15f, AttributeModifier::OPERATION_MULTIPLY_TOTAL); //->setIcon(1, 0); digSpeed = (new MobEffect(3, false, eMinecraftColour_Effect_DigSpeed)) ->setDescriptionId(IDS_POTION_DIGSPEED) ->setPostfixDescriptionId(IDS_POTION_DIGSPEED_POSTFIX)->setDurationModifier(1.5)->setIcon(MobEffect::e_MobEffectIcon_Haste); //->setIcon(2, 0); @@ -70,14 +70,14 @@ void MobEffect::staticCtor() healthBoost = (new HealthBoostMobEffect(21, false, eMinecraftColour_Effect_HealthBoost)) ->setDescriptionId(IDS_POTION_HEALTHBOOST) ->setPostfixDescriptionId(IDS_POTION_HEALTHBOOST_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_HealthBoost)->addAttributeModifier(SharedMonsterAttributes::MAX_HEALTH, eModifierId_POTION_HEALTHBOOST, 4, AttributeModifier::OPERATION_ADDITION); absorption = (new AbsoptionMobEffect(22, false, eMinecraftColour_Effect_Absoprtion)) ->setDescriptionId(IDS_POTION_ABSORPTION) ->setPostfixDescriptionId(IDS_POTION_ABSORPTION_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Absorption); saturation = (new InstantenousMobEffect(23, false, eMinecraftColour_Effect_Saturation)) ->setDescriptionId(IDS_POTION_SATURATION) ->setPostfixDescriptionId(IDS_POTION_SATURATION_POSTFIX); - reserved_24 = NULL; - reserved_25 = NULL; - reserved_26 = NULL; - reserved_27 = NULL; - reserved_28 = NULL; - reserved_29 = NULL; - reserved_30 = NULL; - reserved_31 = NULL; + reserved_24 = nullptr; + reserved_25 = nullptr; + reserved_26 = nullptr; + reserved_27 = nullptr; + reserved_28 = nullptr; + reserved_29 = nullptr; + reserved_30 = nullptr; + reserved_31 = nullptr; } MobEffect::MobEffect(int id, bool isHarmful, eMinecraftColour color) : id(id), _isHarmful(isHarmful), color(color) @@ -179,7 +179,7 @@ void MobEffect::applyInstantenousEffect(shared_ptr source, shared_ else if ((id == harm->id && !mob->isInvertedHealAndHarm()) || (id == heal->id && mob->isInvertedHealAndHarm())) { int amount = static_cast(scale * (double)(6 << amplification) + .5); - if (source == NULL) + if (source == nullptr) { mob->hurt(DamageSource::magic, amount); } @@ -359,7 +359,7 @@ void MobEffect::removeAttributeModifiers(shared_ptr entity, BaseAt { AttributeInstance *attribute = attributes->getInstance(it.first); - if (attribute != NULL) + if (attribute != nullptr) { attribute->removeModifier(it.second); } @@ -372,7 +372,7 @@ void MobEffect::addAttributeModifiers(shared_ptr entity, BaseAttri { AttributeInstance *attribute = attributes->getInstance(it.first); - if (attribute != NULL) + if (attribute != nullptr) { AttributeModifier *original = it.second; attribute->removeModifier(original); diff --git a/Minecraft.World/MobSpawner.cpp b/Minecraft.World/MobSpawner.cpp index 233cc28ff..35b24721b 100644 --- a/Minecraft.World/MobSpawner.cpp +++ b/Minecraft.World/MobSpawner.cpp @@ -251,8 +251,8 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie int z = zStart; int ss = 6; - Biome::MobSpawnerData *currentMobType = NULL; - MobGroupData *groupData = NULL; + Biome::MobSpawnerData *currentMobType = nullptr; + MobGroupData *groupData = nullptr; for (int ll = 0; ll < 4; ll++) { @@ -269,7 +269,7 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie float xx = x + 0.5f; float yy = static_cast(y); float zz = z + 0.5f; - if (level->getNearestPlayer(xx, yy, zz, MIN_SPAWN_DISTANCE) != NULL) + if (level->getNearestPlayer(xx, yy, zz, MIN_SPAWN_DISTANCE) != nullptr) { continue; } @@ -285,10 +285,10 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie } } - if (currentMobType == NULL) + if (currentMobType == nullptr) { currentMobType = level->getRandomMobSpawnAt(mobCategory, x, y, z); - if (currentMobType == NULL) + if (currentMobType == nullptr) { break; } @@ -440,7 +440,7 @@ void MobSpawner::postProcessSpawnMobs(Level *level, Biome *biome, int xo, int zo while (random->nextFloat() < biome->getCreatureProbability()) { Biome::MobSpawnerData *type = (Biome::MobSpawnerData *) WeighedRandom::getRandomItem(level->random, ((vector *)mobs)); - MobGroupData *groupData = NULL; + MobGroupData *groupData = nullptr; int count = type->minCount + random->nextInt(1 + type->maxCount - type->minCount); int x = xo + random->nextInt(cellWidth); diff --git a/Minecraft.World/MobSpawnerTileEntity.cpp b/Minecraft.World/MobSpawnerTileEntity.cpp index 013503b60..028ad3e44 100644 --- a/Minecraft.World/MobSpawnerTileEntity.cpp +++ b/Minecraft.World/MobSpawnerTileEntity.cpp @@ -37,7 +37,7 @@ int MobSpawnerTileEntity::TileEntityMobSpawner::getZ() void MobSpawnerTileEntity::TileEntityMobSpawner::setNextSpawnData(BaseMobSpawner::SpawnData *nextSpawnData) { BaseMobSpawner::setNextSpawnData(nextSpawnData); - if (getLevel() != NULL) getLevel()->sendTileUpdated(m_parent->x, m_parent->y, m_parent->z); + if (getLevel() != nullptr) getLevel()->sendTileUpdated(m_parent->x, m_parent->y, m_parent->z); } MobSpawnerTileEntity::MobSpawnerTileEntity() diff --git a/Minecraft.World/MockedLevelStorage.cpp b/Minecraft.World/MockedLevelStorage.cpp index 9a7a63c04..56910e3ec 100644 --- a/Minecraft.World/MockedLevelStorage.cpp +++ b/Minecraft.World/MockedLevelStorage.cpp @@ -9,7 +9,7 @@ LevelData *MockedLevelStorage::prepareLevel() { - return NULL; + return nullptr; } void MockedLevelStorage::checkSession() @@ -18,7 +18,7 @@ void MockedLevelStorage::checkSession() ChunkStorage *MockedLevelStorage::createChunkStorage(Dimension *dimension) { - return NULL; + return nullptr; } void MockedLevelStorage::saveLevelData(LevelData *levelData, vector > *players) @@ -31,7 +31,7 @@ void MockedLevelStorage::saveLevelData(LevelData *levelData) PlayerIO *MockedLevelStorage::getPlayerIO() { - return NULL; + return nullptr; } void MockedLevelStorage::closeAll() diff --git a/Minecraft.World/MockedLevelStorage.h b/Minecraft.World/MockedLevelStorage.h index 6a9eed70b..faa50582b 100644 --- a/Minecraft.World/MockedLevelStorage.h +++ b/Minecraft.World/MockedLevelStorage.h @@ -18,5 +18,5 @@ class MockedLevelStorage : public LevelStorage virtual ConsoleSavePath getDataFile(const wstring& id); virtual wstring getLevelId(); public: - virtual ConsoleSaveFile *getSaveFile() { return NULL; } + virtual ConsoleSaveFile *getSaveFile() { return nullptr; } }; \ No newline at end of file diff --git a/Minecraft.World/ModifiableAttributeInstance.cpp b/Minecraft.World/ModifiableAttributeInstance.cpp index 3108df4d5..216e5719c 100644 --- a/Minecraft.World/ModifiableAttributeInstance.cpp +++ b/Minecraft.World/ModifiableAttributeInstance.cpp @@ -62,7 +62,7 @@ void ModifiableAttributeInstance::getModifiers(unordered_setgetId() != eModifierId_ANONYMOUS && getModifier(modifier->getId()) != NULL) + if (modifier->getId() != eModifierId_ANONYMOUS && getModifier(modifier->getId()) != nullptr) { assert(0); // throw new IllegalArgumentException("Modifier is already applied on this attribute!"); @@ -126,7 +126,7 @@ void ModifiableAttributeInstance::removeModifier(AttributeModifier *modifier) void ModifiableAttributeInstance::removeModifier(eMODIFIER_ID id) { AttributeModifier *modifier = getModifier(id); - if (modifier != NULL) removeModifier(modifier); + if (modifier != nullptr) removeModifier(modifier); } void ModifiableAttributeInstance::removeModifiers() diff --git a/Minecraft.World/Monster.cpp b/Minecraft.World/Monster.cpp index 254a5a6c6..2de453153 100644 --- a/Minecraft.World/Monster.cpp +++ b/Minecraft.World/Monster.cpp @@ -46,7 +46,7 @@ shared_ptr Monster::findAttackTarget() #endif shared_ptr player = level->getNearestAttackablePlayer(shared_from_this(), 16); - if (player != NULL && canSee(player) ) return player; + if (player != nullptr && canSee(player) ) return player; return shared_ptr(); } diff --git a/Minecraft.World/Monster.h b/Minecraft.World/Monster.h index 33f72b0e1..2c21b1d28 100644 --- a/Minecraft.World/Monster.h +++ b/Minecraft.World/Monster.h @@ -12,7 +12,7 @@ class Monster : public PathfinderMob, public Enemy { public: eINSTANCEOF GetType() { return eTYPE_MONSTER; } - static Entity *create(Level *level) { return NULL; } + static Entity *create(Level *level) { return nullptr; } public: Monster(Level *level); diff --git a/Minecraft.World/MonsterRoomFeature.cpp b/Minecraft.World/MonsterRoomFeature.cpp index 17ac55aec..e11ebcb29 100644 --- a/Minecraft.World/MonsterRoomFeature.cpp +++ b/Minecraft.World/MonsterRoomFeature.cpp @@ -110,7 +110,7 @@ bool MonsterRoomFeature::place(Level *level, Random *random, int x, int y, int z WeighedTreasureArray wrapperArray(monsterRoomTreasure, TREASURE_ITEMS_COUNT); WeighedTreasureArray treasure = WeighedTreasure::addToTreasure(wrapperArray, Item::enchantedBook->createForRandomTreasure(random)); shared_ptr chest = dynamic_pointer_cast( level->getTileEntity(xc, yc, zc) ); - if (chest != NULL ) + if (chest != nullptr ) { WeighedTreasure::addChestItems(random, treasure, chest, 8); } @@ -122,7 +122,7 @@ bool MonsterRoomFeature::place(Level *level, Random *random, int x, int y, int z level->setTileAndData(x, y, z, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS); shared_ptr entity = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if( entity != NULL ) + if( entity != nullptr ) { entity->getSpawner()->setEntityId(randomEntityId(random)); } diff --git a/Minecraft.World/MoveEntityPacket.cpp b/Minecraft.World/MoveEntityPacket.cpp index e897c6f48..cae28e912 100644 --- a/Minecraft.World/MoveEntityPacket.cpp +++ b/Minecraft.World/MoveEntityPacket.cpp @@ -61,7 +61,7 @@ bool MoveEntityPacket::canBeInvalidated() bool MoveEntityPacket::isInvalidatedBy(shared_ptr packet) { shared_ptr target = dynamic_pointer_cast(packet); - return target != NULL && target->id == id; + return target != nullptr && target->id == id; } MoveEntityPacket::PosRot::PosRot() diff --git a/Minecraft.World/MoveEntityPacketSmall.cpp b/Minecraft.World/MoveEntityPacketSmall.cpp index 89f5e13ec..ec67f37f2 100644 --- a/Minecraft.World/MoveEntityPacketSmall.cpp +++ b/Minecraft.World/MoveEntityPacketSmall.cpp @@ -68,7 +68,7 @@ bool MoveEntityPacketSmall::canBeInvalidated() bool MoveEntityPacketSmall::isInvalidatedBy(shared_ptr packet) { shared_ptr target = dynamic_pointer_cast(packet); - return target != NULL && target->id == id; + return target != nullptr && target->id == id; } MoveEntityPacketSmall::PosRot::PosRot() diff --git a/Minecraft.World/MoveIndoorsGoal.cpp b/Minecraft.World/MoveIndoorsGoal.cpp index 395fe5789..f329a6bb3 100644 --- a/Minecraft.World/MoveIndoorsGoal.cpp +++ b/Minecraft.World/MoveIndoorsGoal.cpp @@ -22,10 +22,10 @@ bool MoveIndoorsGoal::canUse() if (mob->getRandom()->nextInt(50) != 0) return false; if (insideX != -1 && mob->distanceToSqr(insideX, mob->y, insideZ) < 2 * 2) return false; shared_ptr village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 14); - if (village == NULL) return false; + if (village == nullptr) return false; shared_ptr _doorInfo = village->getBestDoorInfo(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)); doorInfo = _doorInfo; - return _doorInfo != NULL; + return _doorInfo != nullptr; } bool MoveIndoorsGoal::canContinueToUse() @@ -37,7 +37,7 @@ void MoveIndoorsGoal::start() { insideX = -1; shared_ptr _doorInfo = doorInfo.lock(); - if( _doorInfo == NULL ) + if( _doorInfo == nullptr ) { doorInfo = weak_ptr(); return; @@ -45,7 +45,7 @@ void MoveIndoorsGoal::start() if (mob->distanceToSqr(_doorInfo->getIndoorX(), _doorInfo->y, _doorInfo->getIndoorZ()) > 16 * 16) { Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast(mob->shared_from_this()), 14, 3, Vec3::newTemp(_doorInfo->getIndoorX() + 0.5, _doorInfo->getIndoorY(), _doorInfo->getIndoorZ() + 0.5)); - if (pos != NULL) mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, 1.0f); + if (pos != nullptr) mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, 1.0f); } else mob->getNavigation()->moveTo(_doorInfo->getIndoorX() + 0.5, _doorInfo->getIndoorY(), _doorInfo->getIndoorZ() + 0.5, 1.0f); } @@ -53,7 +53,7 @@ void MoveIndoorsGoal::start() void MoveIndoorsGoal::stop() { shared_ptr _doorInfo = doorInfo.lock(); - if( _doorInfo == NULL ) + if( _doorInfo == nullptr ) { doorInfo = weak_ptr(); return; diff --git a/Minecraft.World/MoveThroughVillageGoal.cpp b/Minecraft.World/MoveThroughVillageGoal.cpp index f112c109f..81476aeca 100644 --- a/Minecraft.World/MoveThroughVillageGoal.cpp +++ b/Minecraft.World/MoveThroughVillageGoal.cpp @@ -11,7 +11,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, double speedModifier, bool onlyAtNight) { - path = NULL; + path = nullptr; doorInfo = weak_ptr(); this->mob = mob; @@ -22,7 +22,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, double speedM MoveThroughVillageGoal::~MoveThroughVillageGoal() { - if(path != NULL) delete path; + if(path != nullptr) delete path; } bool MoveThroughVillageGoal::canUse() @@ -32,10 +32,10 @@ bool MoveThroughVillageGoal::canUse() if (onlyAtNight && mob->level->isDay()) return false; shared_ptr village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 0); - if (village == NULL) return false; + if (village == nullptr) return false; shared_ptr _doorInfo = getNextDoorInfo(village); - if (_doorInfo == NULL) return false; + if (_doorInfo == nullptr) return false; doorInfo = _doorInfo; bool oldCanOpenDoors = mob->getNavigation()->canOpenDoors(); @@ -44,15 +44,15 @@ bool MoveThroughVillageGoal::canUse() path = mob->getNavigation()->createPath(_doorInfo->x, _doorInfo->y, _doorInfo->z); mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors); - if (path != NULL) return true; + if (path != nullptr) return true; Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast(mob->shared_from_this()), 10, 7, Vec3::newTemp(_doorInfo->x, _doorInfo->y, _doorInfo->z)); - if (pos == NULL) return false; + if (pos == nullptr) return false; mob->getNavigation()->setCanOpenDoors(false); delete path; path = mob->getNavigation()->createPath(pos->x, pos->y, pos->z); mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors); - return path != NULL; + return path != nullptr; } bool MoveThroughVillageGoal::canContinueToUse() @@ -60,7 +60,7 @@ bool MoveThroughVillageGoal::canContinueToUse() if (mob->getNavigation()->isDone()) return false; float dist = mob->bbWidth + 4.f; shared_ptr _doorInfo = doorInfo.lock(); - if( _doorInfo == NULL ) return false; + if( _doorInfo == nullptr ) return false; return mob->distanceToSqr(_doorInfo->x, _doorInfo->y, _doorInfo->z) > dist * dist; } @@ -68,13 +68,13 @@ bool MoveThroughVillageGoal::canContinueToUse() void MoveThroughVillageGoal::start() { mob->getNavigation()->moveTo(path, speedModifier); - path = NULL; + path = nullptr; } void MoveThroughVillageGoal::stop() { shared_ptr _doorInfo = doorInfo.lock(); - if( _doorInfo == NULL ) return; + if( _doorInfo == nullptr ) return; if (mob->getNavigation()->isDone() || mob->distanceToSqr(_doorInfo->x, _doorInfo->y, _doorInfo->z) < 4 * 4) { diff --git a/Minecraft.World/MoveTowardsRestrictionGoal.cpp b/Minecraft.World/MoveTowardsRestrictionGoal.cpp index 2c3900b62..1d54f9352 100644 --- a/Minecraft.World/MoveTowardsRestrictionGoal.cpp +++ b/Minecraft.World/MoveTowardsRestrictionGoal.cpp @@ -20,7 +20,7 @@ bool MoveTowardsRestrictionGoal::canUse() if (mob->isWithinRestriction()) return false; Pos *towards = mob->getRestrictCenter(); Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast(mob->shared_from_this()), 16, 7, Vec3::newTemp(towards->x, towards->y, towards->z)); - if (pos == NULL) return false; + if (pos == nullptr) return false; wantedX = pos->x; wantedY = pos->y; wantedZ = pos->z; diff --git a/Minecraft.World/MoveTowardsTargetGoal.cpp b/Minecraft.World/MoveTowardsTargetGoal.cpp index c0537d1f2..a0e18115a 100644 --- a/Minecraft.World/MoveTowardsTargetGoal.cpp +++ b/Minecraft.World/MoveTowardsTargetGoal.cpp @@ -17,10 +17,10 @@ MoveTowardsTargetGoal::MoveTowardsTargetGoal(PathfinderMob *mob, double speedMod bool MoveTowardsTargetGoal::canUse() { target = weak_ptr(mob->getTarget()); - if (target.lock() == NULL) return false; + if (target.lock() == nullptr) return false; if (target.lock()->distanceToSqr(mob->shared_from_this()) > within * within) return false; Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast(mob->shared_from_this()), 16, 7, Vec3::newTemp(target.lock()->x, target.lock()->y, target.lock()->z)); - if (pos == NULL) return false; + if (pos == nullptr) return false; wantedX = pos->x; wantedY = pos->y; wantedZ = pos->z; @@ -29,7 +29,7 @@ bool MoveTowardsTargetGoal::canUse() bool MoveTowardsTargetGoal::canContinueToUse() { - return target.lock() != NULL && !mob->getNavigation()->isDone() && target.lock()->isAlive() && target.lock()->distanceToSqr(mob->shared_from_this()) < within * within; + return target.lock() != nullptr && !mob->getNavigation()->isDone() && target.lock()->isAlive() && target.lock()->distanceToSqr(mob->shared_from_this()) < within * within; } void MoveTowardsTargetGoal::stop() diff --git a/Minecraft.World/Mth.cpp b/Minecraft.World/Mth.cpp index 95e8ccbbb..6cf976c38 100644 --- a/Minecraft.World/Mth.cpp +++ b/Minecraft.World/Mth.cpp @@ -9,7 +9,7 @@ const float Mth::DEGRAD = PI / 180.0f; const float Mth::RADDEG = 180.0f / PI; const float Mth::RAD_TO_GRAD = PI / 180.0f; -float *Mth::_sin = NULL; +float *Mth::_sin = nullptr; const float Mth::sinScale = 65536.0f / (float) (PI * 2); @@ -25,13 +25,13 @@ void Mth::init() float Mth::sin(float i) { - if(_sin == NULL) init(); // 4J - added + if(_sin == nullptr) init(); // 4J - added return _sin[static_cast(i * sinScale) & 65535]; } float Mth::cos(float i) { - if(_sin == NULL) init(); // 4J - added + if(_sin == nullptr) init(); // 4J - added return _sin[static_cast(i * sinScale + 65536 / 4) & 65535]; } diff --git a/Minecraft.World/Mushroom.cpp b/Minecraft.World/Mushroom.cpp index 6b20e0d19..ca8a85546 100644 --- a/Minecraft.World/Mushroom.cpp +++ b/Minecraft.World/Mushroom.cpp @@ -77,7 +77,7 @@ bool Mushroom::growTree(Level *level, int x, int y, int z, Random *random) int data = level->getData(x, y, z); level->removeTile(x, y, z); - Feature *f = NULL; + Feature *f = nullptr; if (id == Tile::mushroom_brown_Id) { @@ -88,14 +88,14 @@ bool Mushroom::growTree(Level *level, int x, int y, int z, Random *random) f = new HugeMushroomFeature(1); } - if (f == NULL || !f->place(level, random, x, y, z)) + if (f == nullptr || !f->place(level, random, x, y, z)) { level->setTileAndData(x, y, z, id, data, Tile::UPDATE_ALL); - if( f != NULL ) + if( f != nullptr ) delete f; return false; } - if( f != NULL ) + if( f != nullptr ) delete f; return true; } \ No newline at end of file diff --git a/Minecraft.World/MushroomCow.cpp b/Minecraft.World/MushroomCow.cpp index 0f88c8435..66969a00f 100644 --- a/Minecraft.World/MushroomCow.cpp +++ b/Minecraft.World/MushroomCow.cpp @@ -24,7 +24,7 @@ MushroomCow::MushroomCow(Level *level) : Cow(level) bool MushroomCow::mobInteract(shared_ptr player) { shared_ptr item = player->inventory->getSelected(); - if (item != NULL && item->id == Item::bowl_Id && getAge() >= 0) + if (item != nullptr && item->id == Item::bowl_Id && getAge() >= 0) { if (item->count == 1) { @@ -39,7 +39,7 @@ bool MushroomCow::mobInteract(shared_ptr player) } } // 4J: Do not allow shearing if we can't create more cows - if (item != NULL && item->id == Item::shears_Id && getAge() >= 0 && level->canCreateMore(eTYPE_COW, Level::eSpawnType_Breed)) + if (item != nullptr && item->id == Item::shears_Id && getAge() >= 0 && level->canCreateMore(eTYPE_COW, Level::eSpawnType_Breed)) { remove(); level->addParticle(eParticleType_largeexplode, x, y + bbHeight / 2, z, 0, 0, 0); diff --git a/Minecraft.World/MycelTile.cpp b/Minecraft.World/MycelTile.cpp index 875a598d2..76b742e34 100644 --- a/Minecraft.World/MycelTile.cpp +++ b/Minecraft.World/MycelTile.cpp @@ -6,8 +6,8 @@ MycelTile::MycelTile(int id) : Tile(id, Material::grass) { - iconTop = NULL; - iconSnowSide = NULL; + iconTop = nullptr; + iconSnowSide = nullptr; setTicking(true); } diff --git a/Minecraft.World/NameTagItem.cpp b/Minecraft.World/NameTagItem.cpp index 9c11f2af0..fc9b80b4a 100644 --- a/Minecraft.World/NameTagItem.cpp +++ b/Minecraft.World/NameTagItem.cpp @@ -10,7 +10,7 @@ bool NameTagItem::interactEnemy(shared_ptr itemInstance, shared_pt { if (!itemInstance->hasCustomHoverName()) return false; - if ( (target != NULL) && target->instanceof(eTYPE_MOB) ) + if ( (target != nullptr) && target->instanceof(eTYPE_MOB) ) { shared_ptr mob = dynamic_pointer_cast(target); mob->setCustomName(itemInstance->getHoverName()); diff --git a/Minecraft.World/NbtIo.cpp b/Minecraft.World/NbtIo.cpp index 12b710163..7e566114d 100644 --- a/Minecraft.World/NbtIo.cpp +++ b/Minecraft.World/NbtIo.cpp @@ -54,9 +54,9 @@ CompoundTag *NbtIo::read(DataInput *dis) if( tag->getId() == Tag::TAG_Compound ) return static_cast(tag); - if(tag!=NULL) delete tag; + if(tag!=nullptr) delete tag; // Root tag must be a named compound tag - return NULL; + return nullptr; } void NbtIo::write(CompoundTag *tag, DataOutput *dos) diff --git a/Minecraft.World/NbtSlotFile.cpp b/Minecraft.World/NbtSlotFile.cpp index 8bae14c64..f6c9be2a9 100644 --- a/Minecraft.World/NbtSlotFile.cpp +++ b/Minecraft.World/NbtSlotFile.cpp @@ -14,12 +14,12 @@ NbtSlotFile::NbtSlotFile(File file) if ( !file.exists() || file.length() ) { - raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); writeHeader(); } else { - raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); } readHeader(); @@ -34,7 +34,7 @@ NbtSlotFile::NbtSlotFile(File file) { seekSlotHeader(fileSlot); short slot; - ReadFile(raf,&slot,2,&numberofBytesRead,NULL); + ReadFile(raf,&slot,2,&numberofBytesRead,nullptr); if (slot == 0) { freeFileSlots.push_back(fileSlot); @@ -52,12 +52,12 @@ void NbtSlotFile::readHeader() DWORD numberOfBytesRead; SetFilePointer(raf,0,0,FILE_BEGIN); int magic; - ReadFile(raf,&magic,4,&numberOfBytesRead,NULL); + ReadFile(raf,&magic,4,&numberOfBytesRead,nullptr); // if (magic != MAGIC_NUMBER) throw new IOException("Bad magic number: " + magic); // 4J - TODO short version; - ReadFile(raf,&version,2,&numberOfBytesRead,NULL); + ReadFile(raf,&version,2,&numberOfBytesRead,nullptr); // if (version != 0) throw new IOException("Bad version number: " + version); // 4J - TODO - ReadFile(raf,&totalFileSlots,4,&numberOfBytesRead,NULL); + ReadFile(raf,&totalFileSlots,4,&numberOfBytesRead,nullptr); } void NbtSlotFile::writeHeader() @@ -65,9 +65,9 @@ void NbtSlotFile::writeHeader() DWORD numberOfBytesWritten; short version = 0; SetFilePointer(raf,0,0,FILE_BEGIN); - WriteFile(raf,&MAGIC_NUMBER,4,&numberOfBytesWritten,NULL); - WriteFile(raf,&version,2,&numberOfBytesWritten,NULL); - WriteFile(raf,&totalFileSlots,4,&numberOfBytesWritten,NULL); + WriteFile(raf,&MAGIC_NUMBER,4,&numberOfBytesWritten,nullptr); + WriteFile(raf,&version,2,&numberOfBytesWritten,nullptr); + WriteFile(raf,&totalFileSlots,4,&numberOfBytesWritten,nullptr); } void NbtSlotFile::seekSlotHeader(int fileSlot) @@ -98,12 +98,12 @@ vector *NbtSlotFile::readAll(int slot) { seekSlotHeader(c); short oldSlot; - ReadFile(raf,&oldSlot,2,&numberOfBytesRead,NULL); + ReadFile(raf,&oldSlot,2,&numberOfBytesRead,nullptr); short size; - ReadFile(raf,&size,2,&numberOfBytesRead,NULL); - ReadFile(raf,&continuesAt,4,&numberOfBytesRead,NULL); + ReadFile(raf,&size,2,&numberOfBytesRead,nullptr); + ReadFile(raf,&continuesAt,4,&numberOfBytesRead,nullptr); int lastSlot; - ReadFile(raf,&lastSlot,4,&numberOfBytesRead,NULL); + ReadFile(raf,&lastSlot,4,&numberOfBytesRead,nullptr); seekSlot(c); if (expectedSlot > 0 && oldSlot == -expectedSlot) @@ -112,7 +112,7 @@ vector *NbtSlotFile::readAll(int slot) goto fileSlotLoop; // 4J - used to be continue fileSlotLoop, with for loop labelled as fileSlotLoop } - ReadFile(raf,READ_BUFFER.data + pos,size,&numberOfBytesRead,NULL); + ReadFile(raf,READ_BUFFER.data + pos,size,&numberOfBytesRead,nullptr); if (continuesAt >= 0) { @@ -203,13 +203,13 @@ void NbtSlotFile::replaceSlot(int slot, vector *tags) } seekSlotHeader(fileSlot); - WriteFile(raf,¤tSlot,2,&numberOfBytesWritten,NULL); - WriteFile(raf,&toWrite,2,&numberOfBytesWritten,NULL); - WriteFile(raf,&nextFileSlot,4,&numberOfBytesWritten,NULL); - WriteFile(raf,&lastFileSlot,4,&numberOfBytesWritten,NULL); + WriteFile(raf,¤tSlot,2,&numberOfBytesWritten,nullptr); + WriteFile(raf,&toWrite,2,&numberOfBytesWritten,nullptr); + WriteFile(raf,&nextFileSlot,4,&numberOfBytesWritten,nullptr); + WriteFile(raf,&lastFileSlot,4,&numberOfBytesWritten,nullptr); seekSlot(fileSlot); - WriteFile(raf,compressed.data+pos,toWrite,&numberOfBytesWritten,NULL); + WriteFile(raf,compressed.data+pos,toWrite,&numberOfBytesWritten,nullptr); if (remaining > 0) { @@ -227,7 +227,7 @@ void NbtSlotFile::replaceSlot(int slot, vector *tags) seekSlotHeader(c); short zero = 0; - WriteFile(raf,&zero,2,&numberOfBytesWritten,NULL); + WriteFile(raf,&zero,2,&numberOfBytesWritten,nullptr); } toReplace->clear(); diff --git a/Minecraft.World/NearestAttackableTargetGoal.cpp b/Minecraft.World/NearestAttackableTargetGoal.cpp index 7ddd88950..c6b75481d 100644 --- a/Minecraft.World/NearestAttackableTargetGoal.cpp +++ b/Minecraft.World/NearestAttackableTargetGoal.cpp @@ -18,7 +18,7 @@ SubselectEntitySelector::~SubselectEntitySelector() bool SubselectEntitySelector::matches(shared_ptr entity) const { if (!entity->instanceof(eTYPE_LIVINGENTITY)) return false; - if (m_subselector != NULL && !m_subselector->matches(entity)) return false; + if (m_subselector != nullptr && !m_subselector->matches(entity)) return false; return m_parent->canAttack(dynamic_pointer_cast(entity), false); } @@ -37,7 +37,7 @@ bool NearestAttackableTargetGoal::DistComp::operator() (shared_ptr e1, s return false; } -NearestAttackableTargetGoal::NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach /*= false*/, EntitySelector *entitySelector /* =NULL */) +NearestAttackableTargetGoal::NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach /*= false*/, EntitySelector *entitySelector /* =nullptr */) : TargetGoal(mob, mustSee, mustReach), targetType(targetType) { this->randomInterval = randomInterval; @@ -61,7 +61,7 @@ bool NearestAttackableTargetGoal::canUse() vector > *entities = mob->level->getEntitiesOfClass(targetType, mob->bb->grow(within, 4, within), selector); bool result = false; - if(entities != NULL && !entities->empty() ) + if(entities != nullptr && !entities->empty() ) { std::sort(entities->begin(), entities->end(), *distComp); target = weak_ptr(dynamic_pointer_cast(entities->at(0))); diff --git a/Minecraft.World/NearestAttackableTargetGoal.h b/Minecraft.World/NearestAttackableTargetGoal.h index 1ba6c519d..2bdb81ec1 100644 --- a/Minecraft.World/NearestAttackableTargetGoal.h +++ b/Minecraft.World/NearestAttackableTargetGoal.h @@ -41,7 +41,7 @@ class NearestAttackableTargetGoal : public TargetGoal weak_ptr target; public: - NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach = false, EntitySelector *entitySelector = NULL); + NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach = false, EntitySelector *entitySelector = nullptr); virtual ~NearestAttackableTargetGoal(); diff --git a/Minecraft.World/NetherBridgeFeature.cpp b/Minecraft.World/NetherBridgeFeature.cpp index 42cdfac94..e78002ec7 100644 --- a/Minecraft.World/NetherBridgeFeature.cpp +++ b/Minecraft.World/NetherBridgeFeature.cpp @@ -15,13 +15,13 @@ NetherBridgeFeature::NetherBridgeFeature() : StructureFeature() bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_SKELETON, 10, 4, 4)); bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_LAVASLIME, 3, 4, 4)); isSpotSelected=false; - netherFortressPos = NULL; + netherFortressPos = nullptr; } NetherBridgeFeature::~NetherBridgeFeature() { - if( netherFortressPos != NULL ) delete netherFortressPos; + if( netherFortressPos != nullptr ) delete netherFortressPos; } wstring NetherBridgeFeature::getFeatureName() @@ -57,7 +57,7 @@ bool NetherBridgeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) bool forcePlacement = false; LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); - if( levelGenOptions != NULL ) + if( levelGenOptions != nullptr ) { forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_NetherBridge); } diff --git a/Minecraft.World/NetherBridgePieces.cpp b/Minecraft.World/NetherBridgePieces.cpp index de102da54..d9fbbf35b 100644 --- a/Minecraft.World/NetherBridgePieces.cpp +++ b/Minecraft.World/NetherBridgePieces.cpp @@ -79,7 +79,7 @@ NetherBridgePieces::PieceWeight *NetherBridgePieces::castlePieceWeights[NetherBr NetherBridgePieces::NetherBridgePiece *NetherBridgePieces::findAndCreateBridgePieceFactory(NetherBridgePieces::PieceWeight *piece, list *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { EPieceClass pieceClass = piece->pieceClass; - NetherBridgePiece *structurePiece = NULL; + NetherBridgePiece *structurePiece = nullptr; if (pieceClass == EPieceClass_BridgeStraight) { @@ -204,7 +204,7 @@ NetherBridgePieces::NetherBridgePiece *NetherBridgePieces::NetherBridgePiece::ge } NetherBridgePiece *structurePiece = findAndCreateBridgePieceFactory(piece, pieces, random, footX, footY, footZ, direction, depth); - if (structurePiece != NULL) + if (structurePiece != nullptr) { piece->placeCount++; startPiece->previousPiece = piece; @@ -236,7 +236,7 @@ StructurePiece *NetherBridgePieces::NetherBridgePiece::generateAndAddPiece(Start availablePieces = &startPiece->availableCastlePieces; } StructurePiece *newPiece = generatePiece(startPiece, availablePieces, pieces, random, footX, footY, footZ, direction, depth + 1); - if (newPiece != NULL) + if (newPiece != nullptr) { pieces->push_back(newPiece); startPiece->pendingChildren.push_back(newPiece); @@ -257,7 +257,7 @@ StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildForward(Star case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0 + yOff, boundingBox->z0 + xOff, orientation, getGenDepth(), isCastle); } - return NULL; + return nullptr; } StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildLeft(StartPiece *startPiece, list *pieces, Random *random, int yOff, int zOff, bool isCastle) @@ -273,7 +273,7 @@ StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildLeft(StartPi case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth(), isCastle); } - return NULL; + return nullptr; } StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildRight(StartPiece *startPiece, list *pieces, Random *random, int yOff, int zOff, bool isCastle) @@ -289,14 +289,14 @@ StructurePiece *NetherBridgePieces::NetherBridgePiece::generateChildRight(StartP case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth(), isCastle); } - return NULL; + return nullptr; } bool NetherBridgePieces::NetherBridgePiece::isOkBox(BoundingBox *box, StartPiece *startPiece) { bool bIsOk = false; - if(box != NULL) + if(box != nullptr) { if( box->y0 > LOWEST_Y_POSITION ) bIsOk = true; int xzSize = (startPiece->m_level->getLevelData()->getXZSize() / startPiece->m_level->getLevelData()->getHellScale()); //HellRandomLevelSource::XZSIZE; @@ -375,13 +375,13 @@ NetherBridgePieces::BridgeStraight *NetherBridgePieces::BridgeStraight::createPi { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new BridgeStraight(genDepth, random, box, direction); @@ -441,13 +441,13 @@ NetherBridgePieces::BridgeEndFiller *NetherBridgePieces::BridgeEndFiller::create { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new BridgeEndFiller(genDepth, random, box, direction); @@ -549,13 +549,13 @@ NetherBridgePieces::BridgeCrossing *NetherBridgePieces::BridgeCrossing::createPi { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -8, -3, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new BridgeCrossing(genDepth, random, box, direction); @@ -612,12 +612,12 @@ bool NetherBridgePieces::BridgeCrossing::postProcess(Level *level, Random *rando NetherBridgePieces::StartPiece::StartPiece() { // for reflection - previousPiece = NULL; + previousPiece = nullptr; } NetherBridgePieces::StartPiece::StartPiece(Random *random, int west, int north, Level *level) : BridgeCrossing(random, west, north) { - previousPiece = NULL; + previousPiece = nullptr; m_level = level; for( int i = 0; i < BRIDGE_PIECEWEIGHTS_COUNT; i++ ) @@ -668,13 +668,13 @@ NetherBridgePieces::RoomCrossing *NetherBridgePieces::RoomCrossing::createPiece( { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new RoomCrossing(genDepth, random, box, direction); @@ -738,13 +738,13 @@ NetherBridgePieces::StairsRoom *NetherBridgePieces::StairsRoom::createPiece(list { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new StairsRoom(genDepth, random, box, direction); @@ -812,13 +812,13 @@ NetherBridgePieces::MonsterThrone *NetherBridgePieces::MonsterThrone::createPiec { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new MonsterThrone(genDepth, random, box, direction); @@ -873,7 +873,7 @@ bool NetherBridgePieces::MonsterThrone::postProcess(Level *level, Random *random hasPlacedMobSpawner = true; level->setTileAndData(x, y, z, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS); shared_ptr entity = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (entity != NULL) entity->getSpawner()->setEntityId(L"Blaze"); + if (entity != nullptr) entity->getSpawner()->setEntityId(L"Blaze"); } } @@ -908,13 +908,13 @@ NetherBridgePieces::CastleEntrance *NetherBridgePieces::CastleEntrance::createPi { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleEntrance(genDepth, random, box, direction); @@ -1038,13 +1038,13 @@ NetherBridgePieces::CastleStalkRoom *NetherBridgePieces::CastleStalkRoom::create { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleStalkRoom(genDepth, random, box, direction); @@ -1204,13 +1204,13 @@ NetherBridgePieces::CastleSmallCorridorPiece *NetherBridgePieces::CastleSmallCor BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleSmallCorridorPiece(genDepth, random, box, direction); @@ -1268,13 +1268,13 @@ NetherBridgePieces::CastleSmallCorridorCrossingPiece *NetherBridgePieces::Castle { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleSmallCorridorCrossingPiece(genDepth, random, box, direction); @@ -1344,13 +1344,13 @@ NetherBridgePieces::CastleSmallCorridorRightTurnPiece *NetherBridgePieces::Castl { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleSmallCorridorRightTurnPiece(genDepth, random, box, direction); @@ -1436,13 +1436,13 @@ NetherBridgePieces::CastleSmallCorridorLeftTurnPiece *NetherBridgePieces::Castle { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleSmallCorridorLeftTurnPiece(genDepth, random, box, direction); @@ -1512,13 +1512,13 @@ NetherBridgePieces::CastleCorridorStairsPiece *NetherBridgePieces::CastleCorrido { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -7, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleCorridorStairsPiece(genDepth, random, box, direction); @@ -1594,13 +1594,13 @@ NetherBridgePieces::CastleCorridorTBalconyPiece *NetherBridgePieces::CastleCorri { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -3, 0, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new CastleCorridorTBalconyPiece(genDepth, random, box, direction); diff --git a/Minecraft.World/Node.cpp b/Minecraft.World/Node.cpp index a8988091c..408370a06 100644 --- a/Minecraft.World/Node.cpp +++ b/Minecraft.World/Node.cpp @@ -10,7 +10,7 @@ void Node::_init() closed = false; - cameFrom = NULL; + cameFrom = nullptr; } Node::Node(const int x, const int y, const int z) : @@ -52,7 +52,7 @@ float Node::distanceToSqr(Node *to) bool Node::equals(Node *o) { //4J Jev, never used anything other than a node. - //if (dynamic_cast((Node *) o) != NULL) + //if (dynamic_cast((Node *) o) != nullptr) //{ return hash == o->hash && x == o->x && y == o->y && z == o->z; //} diff --git a/Minecraft.World/NotGateTile.cpp b/Minecraft.World/NotGateTile.cpp index 3aa9aee1f..e6c5fd063 100644 --- a/Minecraft.World/NotGateTile.cpp +++ b/Minecraft.World/NotGateTile.cpp @@ -233,7 +233,7 @@ void NotGateTile::levelTimeChanged(Level *level, __int64 delta, __int64 newTime) { deque *toggles = recentToggles[level]; - if (toggles != NULL) + if (toggles != nullptr) { for (auto& toggle : *toggles) { diff --git a/Minecraft.World/NoteBlockTile.cpp b/Minecraft.World/NoteBlockTile.cpp index 504ed511e..4c58ec8b1 100644 --- a/Minecraft.World/NoteBlockTile.cpp +++ b/Minecraft.World/NoteBlockTile.cpp @@ -14,7 +14,7 @@ void NoteBlockTile::neighborChanged(Level *level, int x, int y, int z, int type) bool signal = level->hasNeighborSignal(x, y, z); shared_ptr mte = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); app.DebugPrintf("-------- Signal is %s, tile is currently %s\n",signal?"TRUE":"FALSE", mte->on?"ON":"OFF"); - if (mte != NULL && mte->on != signal) + if (mte != nullptr && mte->on != signal) { if (signal) { @@ -35,7 +35,7 @@ bool NoteBlockTile::use(Level *level, int x, int y, int z, shared_ptr pl if (soundOnly) return false; if (level->isClientSide) return true; shared_ptr mte = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (mte != NULL ) + if (mte != nullptr ) { mte->tune(); mte->playNote(level, x, y, z); @@ -47,7 +47,7 @@ void NoteBlockTile::attack(Level *level, int x, int y, int z, shared_ptr { if (level->isClientSide) return; shared_ptr mte = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if( mte != NULL ) mte->playNote(level, x, y, z); + if( mte != nullptr ) mte->playNote(level, x, y, z); } shared_ptr NoteBlockTile::newTileEntity(Level *level) diff --git a/Minecraft.World/Ocelot.cpp b/Minecraft.World/Ocelot.cpp index 53ee27299..474fcd71e 100644 --- a/Minecraft.World/Ocelot.cpp +++ b/Minecraft.World/Ocelot.cpp @@ -199,7 +199,7 @@ bool Ocelot::mobInteract(shared_ptr player) } else { - if (temptGoal->isRunning() && item != NULL && item->id == Item::fish_raw_Id && player->distanceToSqr(shared_from_this()) < 3 * 3) + if (temptGoal->isRunning() && item != nullptr && item->id == Item::fish_raw_Id && player->distanceToSqr(shared_from_this()) < 3 * 3) { // 4J-PB - don't lose the fish in creative mode if (!player->abilities.instabuild) item->count--; @@ -257,7 +257,7 @@ shared_ptr Ocelot::getBreedOffspring(shared_ptr target) bool Ocelot::isFood(shared_ptr itemInstance) { - return itemInstance != NULL && itemInstance->id == Item::fish_raw_Id; + return itemInstance != nullptr && itemInstance->id == Item::fish_raw_Id; } bool Ocelot::canMate(shared_ptr animal) @@ -266,7 +266,7 @@ bool Ocelot::canMate(shared_ptr animal) if (!isTame()) return false; shared_ptr partner = dynamic_pointer_cast(animal); - if (partner == NULL) return false; + if (partner == nullptr) return false; if (!partner->isTame()) return false; return isInLove() && partner->isInLove(); diff --git a/Minecraft.World/OcelotAttackGoal.cpp b/Minecraft.World/OcelotAttackGoal.cpp index d9e0f29b5..9871de2f0 100644 --- a/Minecraft.World/OcelotAttackGoal.cpp +++ b/Minecraft.World/OcelotAttackGoal.cpp @@ -21,14 +21,14 @@ OcelotAttackGoal::OcelotAttackGoal(Mob *mob) bool OcelotAttackGoal::canUse() { shared_ptr bestTarget = mob->getTarget(); - if (bestTarget == NULL) return false; + if (bestTarget == nullptr) return false; target = weak_ptr(bestTarget); return true; } bool OcelotAttackGoal::canContinueToUse() { - if (target.lock() == NULL || !target.lock()->isAlive()) return false; + if (target.lock() == nullptr || !target.lock()->isAlive()) return false; if (mob->distanceToSqr(target.lock()) > 15 * 15) return false; return !mob->getNavigation()->isDone() || canUse(); } diff --git a/Minecraft.World/OfferFlowerGoal.cpp b/Minecraft.World/OfferFlowerGoal.cpp index b604ea84c..2951b5fff 100644 --- a/Minecraft.World/OfferFlowerGoal.cpp +++ b/Minecraft.World/OfferFlowerGoal.cpp @@ -17,12 +17,12 @@ bool OfferFlowerGoal::canUse() if (!golem->level->isDay()) return false; if (golem->getRandom()->nextInt(8000) != 0) return false; villager = weak_ptr(dynamic_pointer_cast( golem->level->getClosestEntityOfClass(typeid(Villager), golem->bb->grow(6, 2, 6), golem->shared_from_this()) )); - return villager.lock() != NULL; + return villager.lock() != nullptr; } bool OfferFlowerGoal::canContinueToUse() { - return _tick > 0 && villager.lock() != NULL; + return _tick > 0 && villager.lock() != nullptr; } void OfferFlowerGoal::start() diff --git a/Minecraft.World/OldChunkStorage.cpp b/Minecraft.World/OldChunkStorage.cpp index c3e6f4aea..cec355bf2 100644 --- a/Minecraft.World/OldChunkStorage.cpp +++ b/Minecraft.World/OldChunkStorage.cpp @@ -9,7 +9,7 @@ #include "FileHeader.h" #include "OldChunkStorage.h" DWORD OldChunkStorage::tlsIdx = 0; -OldChunkStorage::ThreadStorage *OldChunkStorage::tlsDefault = NULL; +OldChunkStorage::ThreadStorage *OldChunkStorage::tlsDefault = nullptr; OldChunkStorage::ThreadStorage::ThreadStorage() { @@ -30,7 +30,7 @@ OldChunkStorage::ThreadStorage::~ThreadStorage() void OldChunkStorage::CreateNewThreadStorage() { ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == NULL ) + if(tlsDefault == nullptr ) { tlsIdx = TlsAlloc(); tlsDefault = tls; @@ -126,14 +126,14 @@ LevelChunk *OldChunkStorage::load(Level *level, int x, int z) char buf[256]; sprintf(buf,"Chunk file at %d, %d is missing level data, skipping\n",x,z); app.DebugPrintf(buf); - return NULL; + return nullptr; } if (!tag->getCompound(L"Level")->contains(L"Blocks")) { char buf[256]; sprintf(buf,"Chunk file at %d, %d is missing block data, skipping\n",x,z); app.DebugPrintf(buf); - return NULL; + return nullptr; } LevelChunk *levelChunk = OldChunkStorage::load(level, tag->getCompound(L"Level")); if (!levelChunk->isAt(x, z)) @@ -152,7 +152,7 @@ LevelChunk *OldChunkStorage::load(Level *level, int x, int z) // e.printStackTrace(); // } } - return NULL; + return nullptr; } void OldChunkStorage::save(Level *level, LevelChunk *levelChunk) @@ -277,7 +277,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos) PIXBeginNamedEvent(0,"Saving tile tick data"); vector *ticksInChunk = level->fetchTicksInChunk(lc, false); - if (ticksInChunk != NULL) + if (ticksInChunk != nullptr) { __int64 levelTime = level->getGameTime(); @@ -365,7 +365,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) PIXBeginNamedEvent(0,"Saving tile tick data"); vector *ticksInChunk = level->fetchTicksInChunk(lc, false); - if (ticksInChunk != NULL) + if (ticksInChunk != nullptr) { __int64 levelTime = level->getGameTime(); @@ -393,14 +393,14 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *tag) { ListTag *entityTags = (ListTag *) tag->getList(L"Entities"); - if (entityTags != NULL) + if (entityTags != nullptr) { for (int i = 0; i < entityTags->size(); i++) { CompoundTag *teTag = entityTags->get(i); shared_ptr te = EntityIO::loadStatic(teTag, level); lc->lastSaveHadEntities = true; - if (te != NULL) + if (te != nullptr) { lc->addEntity(te); } @@ -408,13 +408,13 @@ void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *ta } ListTag *tileEntityTags = (ListTag *) tag->getList(L"TileEntities"); - if (tileEntityTags != NULL) + if (tileEntityTags != nullptr) { for (int i = 0; i < tileEntityTags->size(); i++) { CompoundTag *teTag = tileEntityTags->get(i); shared_ptr te = TileEntity::loadStatic(teTag); - if (te != NULL) + if (te != nullptr) { lc->addTileEntity(te); } @@ -476,7 +476,7 @@ LevelChunk *OldChunkStorage::load(Level *level, DataInputStream *dis) PIXBeginNamedEvent(0,"Loading TileTicks"); ListTag *tileTicks = (ListTag *) tag->getList(L"TileTicks"); - if (tileTicks != NULL) + if (tileTicks != nullptr) { for (int i = 0; i < tileTicks->size(); i++) { @@ -556,7 +556,7 @@ LevelChunk *OldChunkStorage::load(Level *level, CompoundTag *tag) // 4J removed - we shouldn't need this any more #if 0 - if (levelChunk->heightmap.data == NULL || !levelChunk->skyLight->isValid()) + if (levelChunk->heightmap.data == nullptr || !levelChunk->skyLight->isValid()) { static int chunksUpdated = 0; delete [] levelChunk->heightmap.data; @@ -594,7 +594,7 @@ LevelChunk *OldChunkStorage::load(Level *level, CompoundTag *tag) { ListTag *tileTicks = (ListTag *) tag->getList(L"TileTicks"); - if (tileTicks != NULL) + if (tileTicks != nullptr) { for (int i = 0; i < tileTicks->size(); i++) { diff --git a/Minecraft.World/OreFeature.cpp b/Minecraft.World/OreFeature.cpp index c057511bf..cea881aad 100644 --- a/Minecraft.World/OreFeature.cpp +++ b/Minecraft.World/OreFeature.cpp @@ -35,8 +35,8 @@ bool OreFeature::place(Level *level, Random *random, int x, int y, int z) bool collisionsExpected = false; - LevelGenerationOptions *levelGenOptions = NULL; - if( app.getLevelGenerationOptions() != NULL ) + LevelGenerationOptions *levelGenOptions = nullptr; + if( app.getLevelGenerationOptions() != nullptr ) { levelGenOptions = app.getLevelGenerationOptions(); @@ -83,7 +83,7 @@ bool OreFeature::place(Level *level, Random *random, int x, int y, int z) int zt1 = Mth::floor(zz + halfR); // 4J Stu Added to stop ore features generating areas previously place by game rule generation - if(collisionsExpected && levelGenOptions != NULL) + if(collisionsExpected && levelGenOptions != nullptr) { bool intersects = levelGenOptions->checkIntersects(xt0, yt0, zt0, xt1, yt1, zt1); if(intersects) diff --git a/Minecraft.World/OwnerHurtByTargetGoal.cpp b/Minecraft.World/OwnerHurtByTargetGoal.cpp index 8250dc184..787eb2aec 100644 --- a/Minecraft.World/OwnerHurtByTargetGoal.cpp +++ b/Minecraft.World/OwnerHurtByTargetGoal.cpp @@ -14,7 +14,7 @@ bool OwnerHurtByTargetGoal::canUse() { if (!tameAnimal->isTame()) return false; shared_ptr owner = dynamic_pointer_cast( tameAnimal->getOwner() ); - if (owner == NULL) return false; + if (owner == nullptr) return false; ownerLastHurtBy = weak_ptr(owner->getLastHurtByMob()); int ts = owner->getLastHurtByMobTimestamp(); @@ -27,7 +27,7 @@ void OwnerHurtByTargetGoal::start() mob->setTarget(ownerLastHurtBy.lock()); shared_ptr owner = dynamic_pointer_cast( tameAnimal->getOwner() ); - if (owner != NULL) + if (owner != nullptr) { timestamp = owner->getLastHurtByMobTimestamp(); } diff --git a/Minecraft.World/OwnerHurtTargetGoal.cpp b/Minecraft.World/OwnerHurtTargetGoal.cpp index b7e745051..a63e17846 100644 --- a/Minecraft.World/OwnerHurtTargetGoal.cpp +++ b/Minecraft.World/OwnerHurtTargetGoal.cpp @@ -14,7 +14,7 @@ bool OwnerHurtTargetGoal::canUse() { if (!tameAnimal->isTame()) return false; shared_ptr owner = dynamic_pointer_cast( tameAnimal->getOwner() ); - if (owner == NULL) return false; + if (owner == nullptr) return false; ownerLastHurt = weak_ptr(owner->getLastHurtMob()); int ts = owner->getLastHurtMobTimestamp(); shared_ptr locked = ownerLastHurt.lock(); @@ -26,7 +26,7 @@ void OwnerHurtTargetGoal::start() mob->setTarget(ownerLastHurt.lock()); shared_ptr owner = dynamic_pointer_cast( tameAnimal->getOwner() ); - if (owner != NULL) + if (owner != nullptr) { timestamp = owner->getLastHurtMobTimestamp(); diff --git a/Minecraft.World/Packet.cpp b/Minecraft.World/Packet.cpp index 44081a586..417df48f3 100644 --- a/Minecraft.World/Packet.cpp +++ b/Minecraft.World/Packet.cpp @@ -336,7 +336,7 @@ shared_ptr Packet::readPacket(DataInputStream *dis, bool isServer) // th } packet = getPacket(id); - if (packet == NULL) assert(false);//throw new IOException(wstring(L"Bad packet id ") + std::to_wstring(id)); + if (packet == nullptr) assert(false);//throw new IOException(wstring(L"Bad packet id ") + std::to_wstring(id)); //app.DebugPrintf("%s reading packet %d\n", isServer ? "Server" : "Client", packet->getId()); packet->read(dis); @@ -345,7 +345,7 @@ shared_ptr Packet::readPacket(DataInputStream *dis, bool isServer) // th // { // // reached end of stream // OutputDebugString("Reached end of stream"); - // return NULL; + // return nullptr; // } // 4J - Don't bother tracking stats in a content package @@ -525,7 +525,7 @@ shared_ptr Packet::readItem(DataInputStream *dis) void Packet::writeItem(shared_ptr item, DataOutputStream *dos) { - if (item == NULL) + if (item == nullptr) { dos->writeShort(-1); } @@ -545,7 +545,7 @@ void Packet::writeItem(shared_ptr item, DataOutputStream *dos) CompoundTag *Packet::readNbt(DataInputStream *dis) { int size = dis->readShort(); - if (size < 0) return NULL; + if (size < 0) return nullptr; byteArray buff(size); dis->readFully(buff); CompoundTag *result = (CompoundTag *) NbtIo::decompress(buff); @@ -555,7 +555,7 @@ CompoundTag *Packet::readNbt(DataInputStream *dis) void Packet::writeNbt(CompoundTag *tag, DataOutputStream *dos) { - if (tag == NULL) + if (tag == nullptr) { dos->writeShort(-1); } diff --git a/Minecraft.World/Painting.cpp b/Minecraft.World/Painting.cpp index 4d79f6f44..e1232809b 100644 --- a/Minecraft.World/Painting.cpp +++ b/Minecraft.World/Painting.cpp @@ -54,7 +54,7 @@ const int Painting::Motive::MAX_MOTIVE_NAME_LENGTH = 13; //JAVA: "SkullAndRoses // 4J - added for common ctor code void Painting::_init( Level *level ) { - motive = NULL; + motive = nullptr; }; Painting::Painting(Level *level) : HangingEntity( level ) @@ -138,7 +138,7 @@ void Painting::readAdditionalSaveData(CompoundTag *tag) this->motive = (Motive *)Motive::values[i]; } } - if (this->motive == NULL) motive = (Motive *)Motive::values[ Kebab ]; + if (this->motive == nullptr) motive = (Motive *)Motive::values[ Kebab ]; HangingEntity::readAdditionalSaveData(tag); } @@ -155,7 +155,7 @@ int Painting::getHeight() void Painting::dropItem(shared_ptr causedBy) { - if ( (causedBy != NULL) && causedBy->instanceof(eTYPE_PLAYER) ) + if ( (causedBy != nullptr) && causedBy->instanceof(eTYPE_PLAYER) ) { shared_ptr player = dynamic_pointer_cast(causedBy); if (player->abilities.instabuild) diff --git a/Minecraft.World/Path.cpp b/Minecraft.World/Path.cpp index 0006ce095..afea4a176 100644 --- a/Minecraft.World/Path.cpp +++ b/Minecraft.World/Path.cpp @@ -46,7 +46,7 @@ Node *Path::last() { return nodes[length - 1]; } - return NULL; + return nullptr; } Node *Path::get(int i) @@ -94,7 +94,7 @@ Vec3 *Path::currentPos() bool Path::sameAs(Path *path) { - if (path == NULL) return false; + if (path == nullptr) return false; if (path->nodes.length != nodes.length) return false; for (int i = 0; i < nodes.length; ++i) if (nodes[i]->x != path->nodes[i]->x || nodes[i]->y != path->nodes[i]->y || nodes[i]->z != path->nodes[i]->z) return false; @@ -104,13 +104,13 @@ bool Path::sameAs(Path *path) bool Path::endsIn(Vec3 *pos) { Node *lastNode = last(); - if (lastNode == NULL) return false; + if (lastNode == nullptr) return false; return lastNode->x == static_cast(pos->x) && lastNode->y == static_cast(pos->y) && lastNode->z == static_cast(pos->z); } bool Path::endsInXZ(Vec3 *pos) { Node *lastNode = last(); - if (lastNode == NULL) return false; + if (lastNode == nullptr) return false; return lastNode->x == static_cast(pos->x) && lastNode->z == static_cast(pos->z); } \ No newline at end of file diff --git a/Minecraft.World/PathFinder.cpp b/Minecraft.World/PathFinder.cpp index dc8a9882c..eb3bd45e7 100644 --- a/Minecraft.World/PathFinder.cpp +++ b/Minecraft.World/PathFinder.cpp @@ -124,7 +124,7 @@ Path *PathFinder::findPath(Entity *e, Node *from, Node *to, Node *size, float ma } } - if (closest == from) return NULL; + if (closest == from) return nullptr; return reconstruct_path(from, closest); } @@ -140,44 +140,44 @@ int PathFinder::getNeighbors(Entity *entity, Node *pos, Node *size, Node *target Node *e = getNode(entity, pos->x + 1, pos->y, pos->z, size, jumpSize); Node *s = getNode(entity, pos->x, pos->y, pos->z - 1, size, jumpSize); - if (n != NULL && !n->closed && n->distanceTo(target) < maxDist) neighbors->data[p++] = n; - if (w != NULL && !w->closed && w->distanceTo(target) < maxDist) neighbors->data[p++] = w; - if (e != NULL && !e->closed && e->distanceTo(target) < maxDist) neighbors->data[p++] = e; - if (s != NULL && !s->closed && s->distanceTo(target) < maxDist) neighbors->data[p++] = s; + if (n != nullptr && !n->closed && n->distanceTo(target) < maxDist) neighbors->data[p++] = n; + if (w != nullptr && !w->closed && w->distanceTo(target) < maxDist) neighbors->data[p++] = w; + if (e != nullptr && !e->closed && e->distanceTo(target) < maxDist) neighbors->data[p++] = e; + if (s != nullptr && !s->closed && s->distanceTo(target) < maxDist) neighbors->data[p++] = s; return p; } Node *PathFinder::getNode(Entity *entity, int x, int y, int z, Node *size, int jumpSize) { - Node *best = NULL; + Node *best = nullptr; int pathType = isFree(entity, x, y, z, size); if (pathType == TYPE_WALKABLE) return getNode(x, y, z); if (pathType == TYPE_OPEN) best = getNode(x, y, z); - if (best == NULL && jumpSize > 0 && pathType != TYPE_FENCE && pathType != TYPE_TRAP && isFree(entity, x, y + jumpSize, z, size) == TYPE_OPEN) + if (best == nullptr && jumpSize > 0 && pathType != TYPE_FENCE && pathType != TYPE_TRAP && isFree(entity, x, y + jumpSize, z, size) == TYPE_OPEN) { best = getNode(x, y + jumpSize, z); y += jumpSize; } - if (best != NULL) + if (best != nullptr) { int drop = 0; int cost = 0; while (y > 0) { cost = isFree(entity, x, y - 1, z, size); - if (avoidWater && cost == TYPE_WATER) return NULL; + if (avoidWater && cost == TYPE_WATER) return nullptr; if (cost != TYPE_OPEN) break; // fell too far? - if (++drop >= 4) return NULL; // 4J - rolling this back to pre-java 1.6.4 version as we're suspicious of the performance implications of this -// if (drop++ >= entity->getMaxFallDistance()) return NULL; + if (++drop >= 4) return nullptr; // 4J - rolling this back to pre-java 1.6.4 version as we're suspicious of the performance implications of this +// if (drop++ >= entity->getMaxFallDistance()) return nullptr; y--; if (y > 0) best = getNode(x, y, z); } // fell into lava? - if (cost == TYPE_LAVA) return NULL; + if (cost == TYPE_LAVA) return nullptr; } return best; @@ -269,7 +269,7 @@ Path *PathFinder::reconstruct_path(Node *from, Node *to) { int count = 1; Node *n = to; - while (n->cameFrom != NULL) + while (n->cameFrom != nullptr) { count++; n = n->cameFrom; @@ -278,7 +278,7 @@ Path *PathFinder::reconstruct_path(Node *from, Node *to) NodeArray nodes = NodeArray(count); n = to; nodes.data[--count] = n; - while (n->cameFrom != NULL) + while (n->cameFrom != nullptr) { n = n->cameFrom; nodes.data[--count] = n; diff --git a/Minecraft.World/PathNavigation.cpp b/Minecraft.World/PathNavigation.cpp index 4a9f6d0c0..51d08d1eb 100644 --- a/Minecraft.World/PathNavigation.cpp +++ b/Minecraft.World/PathNavigation.cpp @@ -16,7 +16,7 @@ PathNavigation::PathNavigation(Mob *mob, Level *level) this->level = level; dist = mob->getAttribute(SharedMonsterAttributes::FOLLOW_RANGE); - path = NULL; + path = nullptr; speedModifier = 0.0; avoidSun = false; _tick = 0; @@ -30,7 +30,7 @@ PathNavigation::PathNavigation(Mob *mob, Level *level) PathNavigation::~PathNavigation() { - if(path != NULL) delete path; + if(path != nullptr) delete path; delete lastStuckCheckPos; } @@ -86,7 +86,7 @@ float PathNavigation::getMaxDist() Path *PathNavigation::createPath(double x, double y, double z) { - if (!canUpdatePath()) return NULL; + if (!canUpdatePath()) return nullptr; return level->findPath(mob->shared_from_this(), Mth::floor(x), static_cast(y), Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat); } @@ -101,7 +101,7 @@ bool PathNavigation::moveTo(double x, double y, double z, double speedModifier) Path *PathNavigation::createPath(shared_ptr target) { - if (!canUpdatePath()) return NULL; + if (!canUpdatePath()) return nullptr; return level->findPath(mob->shared_from_this(), target, getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat); } @@ -111,21 +111,21 @@ bool PathNavigation::moveTo(shared_ptr target, double speedModifier) Path *newPath = createPath(target); MemSect(0); // No need to delete newPath here as this will be copied into the member variable path and the class can assume responsibility for it - if (newPath != NULL) return moveTo(newPath, speedModifier); + if (newPath != nullptr) return moveTo(newPath, speedModifier); else return false; } bool PathNavigation::moveTo(Path *newPath, double speedModifier) { - if(newPath == NULL) + if(newPath == nullptr) { - if(path != NULL) delete path; - path = NULL; + if(path != nullptr) delete path; + path = nullptr; return false; } if(!newPath->sameAs(path)) { - if(path != NULL) delete path; + if(path != nullptr) delete path; path = newPath; } else @@ -158,7 +158,7 @@ void PathNavigation::tick() if (isDone()) return; Vec3 *target = path->currentPos(mob->shared_from_this()); - if (target == NULL) return; + if (target == nullptr) return; mob->getMoveControl()->setWantedPosition(target->x, target->y, target->z, speedModifier); } @@ -169,7 +169,7 @@ void PathNavigation::updatePath() // find first elevations in path int firstElevation = path->getSize(); - for (int i = path->getIndex(); path != NULL && i < path->getSize(); ++i) + for (int i = path->getIndex(); path != nullptr && i < path->getSize(); ++i) { if (static_cast(path->get(i)->y) != static_cast(mobPos->y)) { @@ -216,13 +216,13 @@ void PathNavigation::updatePath() bool PathNavigation::isDone() { - return path == NULL || path->isDone(); + return path == nullptr || path->isDone(); } void PathNavigation::stop() { - if(path != NULL) delete path; - path = NULL; + if(path != nullptr) delete path; + path = nullptr; } Vec3 *PathNavigation::getTempMobPos() diff --git a/Minecraft.World/PathfinderMob.cpp b/Minecraft.World/PathfinderMob.cpp index 9942445c9..840a60208 100644 --- a/Minecraft.World/PathfinderMob.cpp +++ b/Minecraft.World/PathfinderMob.cpp @@ -15,7 +15,7 @@ AttributeModifier *PathfinderMob::SPEED_MODIFIER_FLEEING = (new AttributeModifie PathfinderMob::PathfinderMob(Level *level) : Mob( level ) { - path = NULL; + path = nullptr; attackTarget = nullptr; holdGround = false; fleeTime = 0; @@ -51,10 +51,10 @@ void PathfinderMob::serverAiStep() holdGround = shouldHoldGround(); float maxDist = 16; - if (attackTarget == NULL) + if (attackTarget == nullptr) { attackTarget = findAttackTarget(); - if (attackTarget != NULL) + if (attackTarget != nullptr) { setPath(level->findPath(shared_from_this(), attackTarget, maxDist, true, false, false, true)); // 4J - changed to setPath from path = } @@ -84,18 +84,18 @@ void PathfinderMob::serverAiStep() // they aren't enclosed. We don't want the extra network overhead of just having Everything wandering round all the time, so have put a management system in place // that selects a subset of entities which have had their flag set through the considerForExtraWandering method so that these can keep doing random strolling. - if (!holdGround && (attackTarget != NULL && (path == NULL || random->nextInt(20) == 0))) + if (!holdGround && (attackTarget != nullptr && (path == nullptr || random->nextInt(20) == 0))) { setPath(level->findPath(shared_from_this(), attackTarget, maxDist, true, false, false, true));// 4J - changed to setPath from path = } - else if (!holdGround && ((path == NULL && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0))) + else if (!holdGround && ((path == nullptr && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0))) { if(noActionTime < SharedConstants::TICKS_PER_SECOND * 5) { findRandomStrollLocation(); } } - else if (!holdGround && (path == NULL ) ) + else if (!holdGround && (path == nullptr ) ) { if( ( noActionTime >= SharedConstants::TICKS_PER_SECOND * 5 ) && isExtraWanderingEnabled() ) { @@ -115,28 +115,28 @@ void PathfinderMob::serverAiStep() bool inWater = isInWater(); bool inLava = isInLava(); xRot = 0; - if (path == NULL || random->nextInt(100) == 0) + if (path == nullptr || random->nextInt(100) == 0) { this->Mob::serverAiStep(); - setPath(NULL);// 4J - changed to setPath from path = + setPath(nullptr);// 4J - changed to setPath from path = return; } Vec3 *target = path->currentPos(shared_from_this()); double r = bbWidth * 2; - while (target != NULL && target->distanceToSqr(x, target->y, z) < r * r) + while (target != nullptr && target->distanceToSqr(x, target->y, z) < r * r) { path->next(); if (path->isDone()) { - target = NULL; - setPath(NULL); // 4J - changed to setPath from path = + target = nullptr; + setPath(nullptr); // 4J - changed to setPath from path = } else target = path->currentPos(shared_from_this()); } jumping = false; - if (target != NULL) + if (target != nullptr) { double xd = target->x - x; double zd = target->z - z; @@ -156,7 +156,7 @@ void PathfinderMob::serverAiStep() if (holdGround) { - if (attackTarget != NULL) + if (attackTarget != nullptr) { double xd2 = attackTarget->x - x; double zd2 = attackTarget->z - z; @@ -175,7 +175,7 @@ void PathfinderMob::serverAiStep() } } - if (attackTarget != NULL) + if (attackTarget != nullptr) { lookAt(attackTarget, 30, 30); } @@ -250,7 +250,7 @@ bool PathfinderMob::canSpawn() bool PathfinderMob::isPathFinding() { - return path != NULL; + return path != nullptr; } void PathfinderMob::setPath(Path *path) @@ -311,7 +311,7 @@ void PathfinderMob::tickLeash() { Mob::tickLeash(); - if (isLeashed() && getLeashHolder() != NULL && getLeashHolder()->level == this->level) + if (isLeashed() && getLeashHolder() != nullptr && getLeashHolder()->level == this->level) { // soft restriction shared_ptr leashHolder = getLeashHolder(); @@ -320,7 +320,7 @@ void PathfinderMob::tickLeash() float _distanceTo = distanceTo(leashHolder); shared_ptr tamabaleAnimal = shared_from_this()->instanceof(eTYPE_TAMABLE_ANIMAL) ? dynamic_pointer_cast(shared_from_this()) : nullptr; - if ( (tamabaleAnimal != NULL) && tamabaleAnimal->isSitting() ) + if ( (tamabaleAnimal != nullptr) && tamabaleAnimal->isSitting() ) { if (_distanceTo > 10) { diff --git a/Minecraft.World/PerlinNoise.cpp b/Minecraft.World/PerlinNoise.cpp index b4fd8004d..bb0ce8613 100644 --- a/Minecraft.World/PerlinNoise.cpp +++ b/Minecraft.World/PerlinNoise.cpp @@ -64,7 +64,7 @@ double PerlinNoise::getValue(double x, double y, double z) doubleArray PerlinNoise::getRegion(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize, double xScale, double yScale, double zScale) { - if (buffer.data == NULL) buffer = doubleArray(xSize * ySize * zSize); + if (buffer.data == nullptr) buffer = doubleArray(xSize * ySize * zSize); else for (unsigned int i = 0; i < buffer.length; i++) buffer[i] = 0; diff --git a/Minecraft.World/PerlinSimplexNoise.cpp b/Minecraft.World/PerlinSimplexNoise.cpp index a8f6101c7..97d114485 100644 --- a/Minecraft.World/PerlinSimplexNoise.cpp +++ b/Minecraft.World/PerlinSimplexNoise.cpp @@ -72,7 +72,7 @@ doubleArray PerlinSimplexNoise::getRegion(doubleArray buffer, double x, double y xScale/=1.5; yScale/=1.5; - if (buffer.data == NULL || static_cast(buffer.length) < xSize * ySize) + if (buffer.data == nullptr || static_cast(buffer.length) < xSize * ySize) { if( buffer.data ) delete [] buffer.data; buffer = doubleArray(xSize * ySize); @@ -98,7 +98,7 @@ doubleArray PerlinSimplexNoise::getRegion(doubleArray buffer, double x, double y xScale/=1.5; yScale/=1.5; - if (buffer.data == NULL) buffer = doubleArray(xSize * ySize * zSize); + if (buffer.data == nullptr) buffer = doubleArray(xSize * ySize * zSize); else for (unsigned int i = 0; i < buffer.length; i++) buffer[i] = 0; diff --git a/Minecraft.World/PickaxeItem.cpp b/Minecraft.World/PickaxeItem.cpp index 05177e7bc..1bcee6e03 100644 --- a/Minecraft.World/PickaxeItem.cpp +++ b/Minecraft.World/PickaxeItem.cpp @@ -54,7 +54,7 @@ bool PickaxeItem::canDestroySpecial(Tile *tile) // 4J - brought forward from 1.2.3 float PickaxeItem::getDestroySpeed(shared_ptr itemInstance, Tile *tile) { - if (tile != NULL && (tile->material == Material::metal || tile->material == Material::heavyMetal || tile->material == Material::stone)) + if (tile != nullptr && (tile->material == Material::metal || tile->material == Material::heavyMetal || tile->material == Material::stone)) { return speed; } diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp index 54d82ad85..6ac1243af 100644 --- a/Minecraft.World/Pig.cpp +++ b/Minecraft.World/Pig.cpp @@ -64,7 +64,7 @@ bool Pig::canBeControlledByRider() { shared_ptr item = dynamic_pointer_cast(rider.lock())->getCarriedItem(); - return item != NULL && item->id == Item::carrotOnAStick_Id; + return item != nullptr && item->id == Item::carrotOnAStick_Id; } void Pig::defineSynchedData() @@ -109,7 +109,7 @@ bool Pig::mobInteract(shared_ptr player) { if(!Animal::mobInteract(player)) { - if (hasSaddle() && !level->isClientSide && (rider.lock() == NULL || rider.lock() == player)) + if (hasSaddle() && !level->isClientSide && (rider.lock() == nullptr || rider.lock() == player)) { // 4J HEG - Fixed issue with player not being able to dismount pig (issue #4479) player->ride( rider.lock() == player ? nullptr : shared_from_this() ); @@ -173,7 +173,7 @@ void Pig::thunderHit(const LightningBolt *lightningBolt) void Pig::causeFallDamage(float distance) { Animal::causeFallDamage(distance); - if ( (distance > 5) && rider.lock() != NULL && rider.lock()->instanceof(eTYPE_PLAYER) ) + if ( (distance > 5) && rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_PLAYER) ) { (dynamic_pointer_cast(rider.lock()))->awardStat(GenericStats::flyPig(),GenericStats::param_flyPig()); } @@ -194,7 +194,7 @@ shared_ptr Pig::getBreedOffspring(shared_ptr target) bool Pig::isFood(shared_ptr itemInstance) { - return itemInstance != NULL && itemInstance->id == Item::carrots_Id; + return itemInstance != nullptr && itemInstance->id == Item::carrots_Id; } ControlledByPlayerGoal *Pig::getControlGoal() diff --git a/Minecraft.World/PigZombie.cpp b/Minecraft.World/PigZombie.cpp index 6c5457c8a..16f00213c 100644 --- a/Minecraft.World/PigZombie.cpp +++ b/Minecraft.World/PigZombie.cpp @@ -53,7 +53,7 @@ void PigZombie::tick() AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); speed->removeModifier(SPEED_MODIFIER_ATTACKING); - if (attackTarget != NULL) + if (attackTarget != nullptr) { speed->addModifier(new AttributeModifier(*SPEED_MODIFIER_ATTACKING)); } @@ -105,7 +105,7 @@ shared_ptr PigZombie::findAttackTarget() bool PigZombie::hurt(DamageSource *source, float dmg) { shared_ptr sourceEntity = source->getEntity(); - if ( sourceEntity != NULL && sourceEntity->instanceof(eTYPE_PLAYER) ) + if ( sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER) ) { vector > *nearby = level->getEntities( shared_from_this(), bb->grow(32, 32, 32)); for (auto& e : *nearby) diff --git a/Minecraft.World/PineFeature.cpp b/Minecraft.World/PineFeature.cpp index 685f1e48c..bbe424aa0 100644 --- a/Minecraft.World/PineFeature.cpp +++ b/Minecraft.World/PineFeature.cpp @@ -19,7 +19,7 @@ bool PineFeature::place(Level *level, Random *random, int x, int y, int z) } // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x - topRadius, y - 1, z - topRadius, x + topRadius, y + treeHeight, z + topRadius); diff --git a/Minecraft.World/PistonBaseTile.cpp b/Minecraft.World/PistonBaseTile.cpp index 7cd4d1200..e8e2a7138 100644 --- a/Minecraft.World/PistonBaseTile.cpp +++ b/Minecraft.World/PistonBaseTile.cpp @@ -28,7 +28,7 @@ DWORD PistonBaseTile::tlsIdx = TlsAlloc(); // 4J - ignoreUpdate is a static in java, implementing as TLS here to make thread safe bool PistonBaseTile::ignoreUpdate() { - return (TlsGetValue(tlsIdx) != NULL); + return (TlsGetValue(tlsIdx) != nullptr); } void PistonBaseTile::ignoreUpdate(bool set) @@ -45,9 +45,9 @@ PistonBaseTile::PistonBaseTile(int id, bool isSticky) : Tile(id, Material::pisto setSoundType(SOUND_STONE); setDestroyTime(0.5f); - iconInside = NULL; - iconBack = NULL; - iconPlatform = NULL; + iconInside = nullptr; + iconBack = nullptr; + iconPlatform = nullptr; } Icon *PistonBaseTile::getPlatformTexture() @@ -97,7 +97,7 @@ Icon *PistonBaseTile::getTexture(const wstring &name) if (name.compare(PLATFORM_STICKY_TEX) == 0) return Tile::pistonStickyBase->iconPlatform; if (name.compare(INSIDE_TEX) == 0) return Tile::pistonBase->iconInside; - return NULL; + return nullptr; } //@Override @@ -144,7 +144,7 @@ void PistonBaseTile::neighborChanged(Level *level, int x, int y, int z, int type void PistonBaseTile::onPlace(Level *level, int x, int y, int z) { - if (!level->isClientSide && level->getTileEntity(x, y, z) == NULL && !ignoreUpdate()) + if (!level->isClientSide && level->getTileEntity(x, y, z) == nullptr && !ignoreUpdate()) { checkIfExtend(level, x, y, z); } @@ -255,7 +255,7 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1, { PIXBeginNamedEvent(0,"Contract phase A\n"); shared_ptr prevTileEntity = level->getTileEntity(x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]); - if (prevTileEntity != NULL && dynamic_pointer_cast(prevTileEntity) != NULL) + if (prevTileEntity != nullptr && dynamic_pointer_cast(prevTileEntity) != nullptr) { dynamic_pointer_cast(prevTileEntity)->finalTick(); } @@ -285,7 +285,7 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1, // the block two steps away is a moving piston block piece, so replace it with the real data, // since it's probably this piston which is changing too fast shared_ptr tileEntity = level->getTileEntity(twoX, twoY, twoZ); - if (tileEntity != NULL && dynamic_pointer_cast(tileEntity) != NULL ) + if (tileEntity != nullptr && dynamic_pointer_cast(tileEntity) != nullptr ) { shared_ptr ppe = dynamic_pointer_cast(tileEntity); diff --git a/Minecraft.World/PistonExtensionTile.cpp b/Minecraft.World/PistonExtensionTile.cpp index 25c5adb95..bf5e6e602 100644 --- a/Minecraft.World/PistonExtensionTile.cpp +++ b/Minecraft.World/PistonExtensionTile.cpp @@ -7,7 +7,7 @@ PistonExtensionTile::PistonExtensionTile(int id) : Tile(id, Material::piston,isSolidRender() ) { // 4J added initialiser - overrideTopTexture = NULL; + overrideTopTexture = nullptr; setSoundType(SOUND_STONE); setDestroyTime(0.5f); @@ -20,7 +20,7 @@ void PistonExtensionTile::setOverrideTopTexture(Icon *overrideTopTexture) void PistonExtensionTile::clearOverrideTopTexture() { - this->overrideTopTexture = NULL; + this->overrideTopTexture = nullptr; } void PistonExtensionTile::playerWillDestroy(Level *level, int x, int y, int z, int data, shared_ptr player) @@ -65,7 +65,7 @@ Icon *PistonExtensionTile::getTexture(int face, int data) if (face == facing) { - if (overrideTopTexture != NULL) + if (overrideTopTexture != nullptr) { return overrideTopTexture; } diff --git a/Minecraft.World/PistonMovingPiece.cpp b/Minecraft.World/PistonMovingPiece.cpp index ed0bfeba3..a1fe1c957 100644 --- a/Minecraft.World/PistonMovingPiece.cpp +++ b/Minecraft.World/PistonMovingPiece.cpp @@ -23,7 +23,7 @@ void PistonMovingPiece::onPlace(Level *level, int x, int y, int z) void PistonMovingPiece::onRemove(Level *level, int x, int y, int z, int id, int data) { shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && dynamic_pointer_cast(tileEntity) != NULL) + if (tileEntity != nullptr && dynamic_pointer_cast(tileEntity) != nullptr) { dynamic_pointer_cast(tileEntity)->finalTick(); } @@ -62,7 +62,7 @@ bool PistonMovingPiece::use(Level *level, int x, int y, int z, shared_ptrisClientSide && level->getTileEntity(x, y, z) == NULL) + if (!level->isClientSide && level->getTileEntity(x, y, z) == nullptr) { // this block is no longer valid level->removeTile(x, y, z); @@ -81,7 +81,7 @@ void PistonMovingPiece::spawnResources(Level *level, int x, int y, int z, int da if (level->isClientSide) return; shared_ptr entity = getEntity(level, x, y, z); - if (entity == NULL) + if (entity == nullptr) { return; } @@ -93,7 +93,7 @@ void PistonMovingPiece::neighborChanged(Level *level, int x, int y, int z, int t { if (!level->isClientSide) { - level->getTileEntity(x, y, z) == NULL; + level->getTileEntity(x, y, z) == nullptr; } } @@ -105,9 +105,9 @@ shared_ptr PistonMovingPiece::newMovingPieceEntity(int block, int da AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z) { shared_ptr entity = getEntity(level, x, y, z); - if (entity == NULL) + if (entity == nullptr) { - return NULL; + return nullptr; } // move the aabb depending on the animation @@ -122,11 +122,11 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z) void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr forceEntity) // 4J added forceData, forceEntity param { shared_ptr entity = dynamic_pointer_cast(forceEntity); - if( entity == NULL ) entity = getEntity(level, x, y, z); - if (entity != NULL) + if( entity == nullptr ) entity = getEntity(level, x, y, z); + if (entity != nullptr) { Tile *tile = Tile::tiles[entity->getId()]; - if (tile == NULL || tile == this) + if (tile == nullptr || tile == this) { return; } @@ -152,13 +152,13 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z, int tile, fl { if (tile == 0 || tile == id) { - return NULL; + return nullptr; } AABB *aabb = Tile::tiles[tile]->getAABB(level, x, y, z); - if (aabb == NULL) + if (aabb == nullptr) { - return NULL; + return nullptr; } // move the aabb depending on the animation @@ -192,7 +192,7 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z, int tile, fl shared_ptr PistonMovingPiece::getEntity(LevelSource *level, int x, int y, int z) { shared_ptr tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && dynamic_pointer_cast(tileEntity) != NULL) + if (tileEntity != nullptr && dynamic_pointer_cast(tileEntity) != nullptr) { return dynamic_pointer_cast(tileEntity); } diff --git a/Minecraft.World/PistonPieceEntity.cpp b/Minecraft.World/PistonPieceEntity.cpp index a915c2ff4..dc946a2bd 100644 --- a/Minecraft.World/PistonPieceEntity.cpp +++ b/Minecraft.World/PistonPieceEntity.cpp @@ -117,7 +117,7 @@ void PistonPieceEntity::moveCollidedEntities(float progress, float amount) } AABB *aabb = Tile::pistonMovingPiece->getAABB(level, x, y, z, id, progress, facing); - if (aabb != NULL) + if (aabb != nullptr) { vector > *entities = level->getEntities(nullptr, aabb); if (!entities->empty()) @@ -140,7 +140,7 @@ void PistonPieceEntity::moveCollidedEntities(float progress, float amount) void PistonPieceEntity::finalTick() { - if (progressO < 1 && level != NULL) + if (progressO < 1 && level != nullptr) { progressO = progress = 1; level->removeTileEntity(x, y, z); diff --git a/Minecraft.World/PlayGoal.cpp b/Minecraft.World/PlayGoal.cpp index 72ee69d46..6ce3af232 100644 --- a/Minecraft.World/PlayGoal.cpp +++ b/Minecraft.World/PlayGoal.cpp @@ -40,22 +40,22 @@ bool PlayGoal::canUse() } delete children; - if (followFriend.lock() == NULL) + if (followFriend.lock() == nullptr) { Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast(mob->shared_from_this()), 16, 3); - if (pos == NULL) return false; + if (pos == nullptr) return false; } return true; } bool PlayGoal::canContinueToUse() { - return playTime > 0 && followFriend.lock() != NULL; + return playTime > 0 && followFriend.lock() != nullptr; } void PlayGoal::start() { - if (followFriend.lock() != NULL) mob->setChasing(true); + if (followFriend.lock() != nullptr) mob->setChasing(true); playTime = 1000; } @@ -68,7 +68,7 @@ void PlayGoal::stop() void PlayGoal::tick() { --playTime; - if (followFriend.lock() != NULL) + if (followFriend.lock() != nullptr) { if (mob->distanceToSqr(followFriend.lock()) > 2 * 2) mob->getNavigation()->moveTo(followFriend.lock(), speedModifier); } @@ -77,7 +77,7 @@ void PlayGoal::tick() if (mob->getNavigation()->isDone()) { Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast(mob->shared_from_this()), 16, 3); - if (pos == NULL) return; + if (pos == nullptr) return; mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, speedModifier); } } diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index b7c659bb3..4d5d55fbc 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -64,17 +64,17 @@ void Player::_init() customTextureUrl2 = L""; m_uiPlayerCurrentSkin=0; - bedPosition = NULL; + bedPosition = nullptr; sleepCounter = 0; deathFadeCounter=0; bedOffsetX = bedOffsetY = bedOffsetZ = 0.0f; - stats = NULL; + stats = nullptr; - respawnPosition = NULL; + respawnPosition = nullptr; respawnForced = false; - minecartAchievementPos = NULL; + minecartAchievementPos = nullptr; fishing = nullptr; @@ -97,7 +97,7 @@ void Player::_init() m_uiGamePrivileges = 0; - m_ppAdditionalModelParts=NULL; + m_ppAdditionalModelParts=nullptr; m_bCheckedForModelParts=false; m_bCheckedDLCForModelParts=false; @@ -192,7 +192,7 @@ int Player::getUseItemDuration() bool Player::isUsingItem() { - return useItem != NULL; + return useItem != nullptr; } int Player::getTicksUsingItem() @@ -206,7 +206,7 @@ int Player::getTicksUsingItem() void Player::releaseUsingItem() { - if (useItem != NULL) + if (useItem != nullptr) { useItem->releaseUsing(level, dynamic_pointer_cast( shared_from_this() ), useItemDuration); @@ -237,13 +237,13 @@ bool Player::isBlocking() // 4J Stu - Added for things that should only be ticked once per simulation frame void Player::updateFrameTick() { - if (useItem != NULL) + if (useItem != nullptr) { shared_ptr item = inventory->getSelected(); // 4J Stu - Fix for #45508 - TU5: Gameplay: Eating one piece of food will result in a second piece being eaten as well - // Original code was item != useItem. Changed this now to use the equals function, and add the NULL check as well for the other possible not equals (useItem is not NULL if we are here) + // Original code was item != useItem. Changed this now to use the equals function, and add the nullptr check as well for the other possible not equals (useItem is not nullptr if we are here) // This is because the useItem and item could be different objects due to an inventory update from the server, but still be the same item (with the same id,count and auxvalue) - if (item == NULL || !item->equals(useItem) ) + if (item == nullptr || !item->equals(useItem) ) { stopUsingItem(); } @@ -316,7 +316,7 @@ void Player::tick() if (!level->isClientSide) { - if (containerMenu != NULL && !containerMenu->stillValid( dynamic_pointer_cast( shared_from_this() ) )) + if (containerMenu != nullptr && !containerMenu->stillValid( dynamic_pointer_cast( shared_from_this() ) )) { closeContainer(); containerMenu = inventoryMenu; @@ -348,12 +348,12 @@ void Player::tick() zCloak += zca * 0.25; yCloak += yca * 0.25; - if (riding == NULL) + if (riding == nullptr) { - if( minecartAchievementPos != NULL ) + if( minecartAchievementPos != nullptr ) { delete minecartAchievementPos; - minecartAchievementPos = NULL; + minecartAchievementPos = nullptr; } } @@ -573,13 +573,13 @@ void Player::spawnEatParticles(shared_ptr useItem, int count) void Player::completeUsingItem() { - if (useItem != NULL) + if (useItem != nullptr) { spawnEatParticles(useItem, 16); int oldCount = useItem->count; shared_ptr itemInstance = useItem->useTimeDepleted(level, dynamic_pointer_cast(shared_from_this())); - if (itemInstance != useItem || (itemInstance != NULL && itemInstance->count != oldCount)) + if (itemInstance != useItem || (itemInstance != nullptr && itemInstance->count != oldCount)) { inventory->items[inventory->selected] = itemInstance; if (itemInstance->count == 0) @@ -615,11 +615,11 @@ void Player::closeContainer() void Player::ride(shared_ptr e) { - if (riding != NULL && e == NULL) + if (riding != nullptr && e == nullptr) { if (!level->isClientSide) findStandUpPosition(riding); - if (riding != NULL) + if (riding != nullptr) { riding->rider = weak_ptr(); } @@ -675,7 +675,7 @@ void Player::setCustomSkin(DWORD skinId) // set the new player additional boxes /*vector *pvModelParts=app.GetAdditionalModelParts(m_dwSkinId); - if(pvModelParts==NULL) + if(pvModelParts==nullptr) { // we don't have the data from the dlc skin yet app.DebugPrintf("Couldn't get model parts for skin %X\n",m_dwSkinId); @@ -683,7 +683,7 @@ void Player::setCustomSkin(DWORD skinId) // do we have it from the DLC pack? DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(this->customTextureUrl); - if(pDLCSkinFile!=NULL) + if(pDLCSkinFile!=nullptr) { DWORD dwBoxC=pDLCSkinFile->getAdditionalBoxesCount(); if(dwBoxC!=0) @@ -694,13 +694,13 @@ void Player::setCustomSkin(DWORD skinId) } else { - this->SetAdditionalModelParts(NULL); + this->SetAdditionalModelParts(nullptr); } app.SetAnimOverrideBitmask(pDLCSkinFile->getSkinID(),pDLCSkinFile->getAnimOverrideBitmask()); } else { - this->SetAdditionalModelParts(NULL); + this->SetAdditionalModelParts(nullptr); } } else @@ -713,7 +713,7 @@ void Player::setCustomSkin(DWORD skinId) // reset the check for model parts m_bCheckedForModelParts=false; m_bCheckedDLCForModelParts=false; - this->SetAdditionalModelParts(NULL); + this->SetAdditionalModelParts(nullptr); } @@ -964,7 +964,7 @@ void Player::rideTick() checkRidingStatistiscs(x - preX, y - preY, z - preZ); // riding can be set to null inside 'Entity::rideTick()'. - if ( riding != NULL && (riding->GetType() & eTYPE_PIG) == eTYPE_PIG ) + if ( riding != nullptr && (riding->GetType() & eTYPE_PIG) == eTYPE_PIG ) { // 4J Stu - I don't know why we would want to do this, but it means that the players head is locked in position and can't move around //xRot = preXRot; @@ -1039,8 +1039,8 @@ void Player::aiStep() if (getHealth() > 0) { - AABB *pickupArea = NULL; - if (riding != NULL && !riding->removed) + AABB *pickupArea = nullptr; + if (riding != nullptr && !riding->removed) { // if the player is riding, also touch entities under the // pig/horse @@ -1052,7 +1052,7 @@ void Player::aiStep() } vector > *entities = level->getEntities(shared_from_this(), pickupArea); - if (entities != NULL) + if (entities != nullptr) { for (auto& e : *entities) { @@ -1104,7 +1104,7 @@ void Player::die(DamageSource *source) inventory->dropAll(); } - if (source != NULL) + if (source != nullptr) { xd = -Mth::cos((hurtDir + yRot) * PI / 180) * 0.1f; zd = -Mth::sin((hurtDir + yRot) * PI / 180) * 0.1f; @@ -1157,7 +1157,7 @@ bool Player::isCreativeModeAllowed() shared_ptr Player::drop(bool all) { - return drop(inventory->removeItem(inventory->selected, all && inventory->getSelected() != NULL ? inventory->getSelected()->count : 1), false); + return drop(inventory->removeItem(inventory->selected, all && inventory->getSelected() != nullptr ? inventory->getSelected()->count : 1), false); } shared_ptr Player::drop(shared_ptr item) @@ -1167,7 +1167,7 @@ shared_ptr Player::drop(shared_ptr item) shared_ptr Player::drop(shared_ptr item, bool randomly) { - if (item == NULL) return nullptr; + if (item == nullptr) return nullptr; if (item->count == 0) return nullptr; shared_ptr thrownItem = shared_ptr( new ItemEntity(level, x, y - 0.3f + getHeadHeight(), z, item) ); @@ -1221,7 +1221,7 @@ float Player::getDestroySpeed(Tile *tile, bool hasProperTool) int efficiency = EnchantmentHelper::getDiggingBonus(dynamic_pointer_cast(shared_from_this())); shared_ptr item = inventory->getSelected(); - if (efficiency > 0 && item != NULL) + if (efficiency > 0 && item != nullptr) { float boost = efficiency * efficiency + 1; @@ -1312,7 +1312,7 @@ void Player::addAdditonalSaveData(CompoundTag *entityTag) entityTag->putInt(L"XpTotal", totalExperience); entityTag->putInt(L"Score", getScore()); - if (respawnPosition != NULL) + if (respawnPosition != nullptr) { entityTag->putInt(L"SpawnX", respawnPosition->x); entityTag->putInt(L"SpawnY", respawnPosition->y); @@ -1407,10 +1407,10 @@ bool Player::hurt(DamageSource *source, float dmg) if (dmg == 0) return false; shared_ptr attacker = source->getEntity(); - if ( attacker != NULL && attacker->instanceof(eTYPE_ARROW) ) + if ( attacker != nullptr && attacker->instanceof(eTYPE_ARROW) ) { shared_ptr arrow = dynamic_pointer_cast(attacker); - if ( arrow->owner != NULL) + if ( arrow->owner != nullptr) { attacker = arrow->owner; } @@ -1424,7 +1424,7 @@ bool Player::canHarmPlayer(shared_ptr target) Team *team = getTeam(); Team *otherTeam = target->getTeam(); - if (team == NULL) + if (team == nullptr) { return true; } @@ -1455,7 +1455,7 @@ float Player::getArmorCoverPercentage() int count = 0; for (int i = 0; i < inventory->armor.length; i++) { - if (inventory->armor[i] != NULL) { + if (inventory->armor[i] != nullptr) { count++; } } @@ -1526,13 +1526,13 @@ bool Player::interact(shared_ptr entity) shared_ptr thisPlayer = dynamic_pointer_cast(shared_from_this()); shared_ptr item = getSelectedItem(); - shared_ptr itemClone = (item != NULL) ? item->copy() : nullptr; + shared_ptr itemClone = (item != nullptr) ? item->copy() : nullptr; if ( entity->interact(thisPlayer) ) { // [EB]: Added rude check to see if we're still talking about the // same item; this code caused bucket->milkbucket to be deleted because // the milkbuckets' stack got decremented to 0. - if (item != NULL && item == getSelectedItem()) + if (item != nullptr && item == getSelectedItem()) { if (item->count <= 0 && !abilities.instabuild) { @@ -1546,7 +1546,7 @@ bool Player::interact(shared_ptr entity) return true; } - if ( (item != NULL) && entity->instanceof(eTYPE_LIVINGENTITY) ) + if ( (item != nullptr) && entity->instanceof(eTYPE_LIVINGENTITY) ) { // 4J - PC Comments // Hack to prevent item stacks from decrementing if the player has @@ -1613,7 +1613,7 @@ void Player::attack(shared_ptr entity) if (dmg > 0 || magicBoost > 0) { - bool bCrit = fallDistance > 0 && !onGround && !onLadder() && !isInWater() && !hasEffect(MobEffect::blindness) && (riding == NULL) && entity->instanceof(eTYPE_LIVINGENTITY); + bool bCrit = fallDistance > 0 && !onGround && !onLadder() && !isInWater() && !hasEffect(MobEffect::blindness) && (riding == nullptr) && entity->instanceof(eTYPE_LIVINGENTITY); if (bCrit && dmg > 0) { dmg *= 1.5f; @@ -1671,12 +1671,12 @@ void Player::attack(shared_ptr entity) if ( entity->instanceof(eTYPE_MULTIENTITY_MOB_PART) ) { shared_ptr multiMob = dynamic_pointer_cast((dynamic_pointer_cast(entity))->parentMob.lock()); - if ( (multiMob != NULL) && multiMob->instanceof(eTYPE_LIVINGENTITY) ) + if ( (multiMob != nullptr) && multiMob->instanceof(eTYPE_LIVINGENTITY) ) { hurtTarget = dynamic_pointer_cast( multiMob ); } } - if ( (item != NULL) && hurtTarget->instanceof(eTYPE_LIVINGENTITY) ) + if ( (item != nullptr) && hurtTarget->instanceof(eTYPE_LIVINGENTITY) ) { item->hurtEnemy(dynamic_pointer_cast(hurtTarget), dynamic_pointer_cast( shared_from_this() ) ); if (item->count <= 0) @@ -1737,14 +1737,14 @@ void Player::animateRespawn(shared_ptr player, Level *level) Slot *Player::getInventorySlot(int slotId) { - return NULL; + return nullptr; } void Player::remove() { LivingEntity::remove(); inventoryMenu->removed( dynamic_pointer_cast( shared_from_this() ) ); - if (containerMenu != NULL) + if (containerMenu != nullptr) { containerMenu->removed( dynamic_pointer_cast( shared_from_this() ) ); } @@ -1909,12 +1909,12 @@ void Player::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool save Pos *pos = bedPosition; Pos *standUp = bedPosition; - if (pos != NULL && level->getTile(pos->x, pos->y, pos->z) == Tile::bed_Id) + if (pos != nullptr && level->getTile(pos->x, pos->y, pos->z) == Tile::bed_Id) { BedTile::setOccupied(level, pos->x, pos->y, pos->z, false); standUp = BedTile::findStandUpPosition(level, pos->x, pos->y, pos->z, 0); - if (standUp == NULL) + if (standUp == nullptr) { standUp = new Pos(pos->x, pos->y + 1, pos->z); } @@ -1968,7 +1968,7 @@ Pos *Player::checkBedValidRespawnPosition(Level *level, Pos *pos, bool forced) { return pos; } - return NULL; + return nullptr; } // make sure the bed still has a stand-up position Pos *standUp = BedTile::findStandUpPosition(level, pos->x, pos->y, pos->z, 0); @@ -1977,7 +1977,7 @@ Pos *Player::checkBedValidRespawnPosition(Level *level, Pos *pos, bool forced) float Player::getSleepRotation() { - if (bedPosition != NULL) + if (bedPosition != nullptr) { int data = level->getData(bedPosition->x, bedPosition->y, bedPosition->z); int direction = BedTile::getDirection(data); @@ -2059,21 +2059,21 @@ bool Player::isRespawnForced() void Player::setRespawnPosition(Pos *respawnPosition, bool forced) { - if (respawnPosition != NULL) + if (respawnPosition != nullptr) { this->respawnPosition = new Pos(*respawnPosition); respawnForced = forced; } else { - this->respawnPosition = NULL; + this->respawnPosition = nullptr; respawnForced = false; } } void Player::awardStat(Stat *stat, byteArray paramBlob) { - if (paramBlob.data != NULL) + if (paramBlob.data != nullptr) { delete [] paramBlob.data; } @@ -2102,7 +2102,7 @@ void Player::travel(float xa, float ya) { double preX = x, preY = y, preZ = z; - if (abilities.flying && riding == NULL) + if (abilities.flying && riding == nullptr) { double ydo = yd; float ofs = flyingSpeed; @@ -2127,7 +2127,7 @@ float Player::getSpeed() void Player::checkMovementStatistiscs(double dx, double dy, double dz) { - if (riding != NULL) + if (riding != nullptr) { return; } @@ -2195,7 +2195,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz) void Player::checkRidingStatistiscs(double dx, double dy, double dz) { - if (riding != NULL) + if (riding != nullptr) { int distance = static_cast(Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f)); if (distance > 0) @@ -2211,7 +2211,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) } int dist = 0; - if (minecartAchievementPos == NULL) + if (minecartAchievementPos == nullptr) { minecartAchievementPos = new Pos(Mth::floor(x), Mth::floor(y), Mth::floor(z)); } @@ -2309,7 +2309,7 @@ void Player::killed(shared_ptr mob) awardStat(GenericStats::killsSkeleton(), GenericStats::param_noArgs()); break; case eTYPE_SPIDER: - if( mob->rider.lock() != NULL && mob->rider.lock()->GetType() == eTYPE_SKELETON ) + if( mob->rider.lock() != nullptr && mob->rider.lock()->GetType() == eTYPE_SKELETON ) awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs()); else awardStat(GenericStats::killsSpider(), GenericStats::param_noArgs()); @@ -2348,7 +2348,7 @@ void Player::makeStuckInWeb() Icon *Player::getItemInHandIcon(shared_ptr item, int layer) { Icon *icon = LivingEntity::getItemInHandIcon(item, layer); - if (item->id == Item::fishingRod->id && fishing != NULL) + if (item->id == Item::fishingRod->id && fishing != nullptr) { icon = Item::fishingRod->getEmptyIcon(); } @@ -2356,7 +2356,7 @@ Icon *Player::getItemInHandIcon(shared_ptr item, int layer) { return item->getItem()->getLayerIcon(item->getAuxValue(), layer); } - else if (useItem != NULL && item->id == Item::bow_Id) + else if (useItem != nullptr && item->id == Item::bow_Id) { int ticksHeld = (item->getUseDuration() - useItemDuration); if (ticksHeld >= BowItem::MAX_DRAW_DURATION - 2) @@ -2502,7 +2502,7 @@ bool Player::mayDestroyBlockAt(int x, int y, int z) { return true; } - else if (getSelectedItem() != NULL) + else if (getSelectedItem() != nullptr) { shared_ptr carried = getSelectedItem(); @@ -2521,7 +2521,7 @@ bool Player::mayUseItemAt(int x, int y, int z, int face, shared_ptrmayBePlacedInAdventureMode(); } @@ -2806,7 +2806,7 @@ void Player::setPlayerGamePrivilege(unsigned int &uiGamePrivileges, EPlayerGameP bool Player::isAllowedToUse(Tile *tile) { bool allowed = true; - if(tile != NULL && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) + if(tile != nullptr && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { allowed = false; @@ -2877,7 +2877,7 @@ bool Player::isAllowedToUse(Tile *tile) bool Player::isAllowedToUse(shared_ptr item) { bool allowed = true; - if(item != NULL && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) + if(item != nullptr && app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { if(getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0) { @@ -3085,7 +3085,7 @@ bool Player::canCreateParticles() vector *Player::GetAdditionalModelParts() { - if(m_ppAdditionalModelParts==NULL && !m_bCheckedForModelParts) + if(m_ppAdditionalModelParts==nullptr && !m_bCheckedForModelParts) { bool hasCustomTexture = !customTextureUrl.empty(); bool customTextureIsDefaultSkin = customTextureUrl.substr(0,3).compare(L"def") == 0; @@ -3094,11 +3094,11 @@ vector *Player::GetAdditionalModelParts() m_ppAdditionalModelParts=app.GetAdditionalModelParts(m_dwSkinId); // If it's a default texture (which has no parts), we have the parts, or we already have the texture (in which case we should have parts if there are any) then we are done - if(!hasCustomTexture || customTextureIsDefaultSkin || m_ppAdditionalModelParts != NULL || app.IsFileInMemoryTextures(customTextureUrl)) + if(!hasCustomTexture || customTextureIsDefaultSkin || m_ppAdditionalModelParts != nullptr || app.IsFileInMemoryTextures(customTextureUrl)) { m_bCheckedForModelParts=true; } - if(m_ppAdditionalModelParts == NULL && !m_bCheckedDLCForModelParts) + if(m_ppAdditionalModelParts == nullptr && !m_bCheckedDLCForModelParts) { m_bCheckedDLCForModelParts = true; @@ -3108,7 +3108,7 @@ vector *Player::GetAdditionalModelParts() // do we have it from the DLC pack? DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(this->customTextureUrl); - if(pDLCSkinFile!=NULL) + if(pDLCSkinFile!=nullptr) { DWORD dwBoxC=pDLCSkinFile->getAdditionalBoxesCount(); if(dwBoxC!=0) diff --git a/Minecraft.World/PlayerEnderChestContainer.cpp b/Minecraft.World/PlayerEnderChestContainer.cpp index e84e59207..33ebcbd40 100644 --- a/Minecraft.World/PlayerEnderChestContainer.cpp +++ b/Minecraft.World/PlayerEnderChestContainer.cpp @@ -38,7 +38,7 @@ ListTag *PlayerEnderChestContainer::createTag() for (int i = 0; i < getContainerSize(); i++) { shared_ptr item = getItem(i); - if (item != NULL) + if (item != nullptr) { CompoundTag *tag = new CompoundTag(); tag->putByte(L"Slot", static_cast(i)); @@ -51,7 +51,7 @@ ListTag *PlayerEnderChestContainer::createTag() bool PlayerEnderChestContainer::stillValid(shared_ptr player) { - if (activeChest != NULL && !activeChest->stillValid(player)) + if (activeChest != nullptr && !activeChest->stillValid(player)) { return false; } @@ -60,7 +60,7 @@ bool PlayerEnderChestContainer::stillValid(shared_ptr player) void PlayerEnderChestContainer::startOpen() { - if (activeChest != NULL) + if (activeChest != nullptr) { activeChest->startOpen(); } diff --git a/Minecraft.World/PlayerInfoPacket.cpp b/Minecraft.World/PlayerInfoPacket.cpp index 9cbe5f7cc..d0ad8d2af 100644 --- a/Minecraft.World/PlayerInfoPacket.cpp +++ b/Minecraft.World/PlayerInfoPacket.cpp @@ -28,7 +28,7 @@ PlayerInfoPacket::PlayerInfoPacket(BYTE networkSmallId, short playerColourIndex, PlayerInfoPacket::PlayerInfoPacket(shared_ptr player) { m_networkSmallId = 0; - if(player->connection != NULL && player->connection->getNetworkPlayer() != NULL) m_networkSmallId = player->connection->getNetworkPlayer()->GetSmallId(); + if(player->connection != nullptr && player->connection->getNetworkPlayer() != nullptr) m_networkSmallId = player->connection->getNetworkPlayer()->GetSmallId(); m_playerColourIndex = player->getPlayerIndex(); m_playerPrivileges = player->getAllPlayerGamePrivileges(); m_entityId = player->entityId; diff --git a/Minecraft.World/PlayerTeam.cpp b/Minecraft.World/PlayerTeam.cpp index 3e159af45..608cb36b0 100644 --- a/Minecraft.World/PlayerTeam.cpp +++ b/Minecraft.World/PlayerTeam.cpp @@ -77,7 +77,7 @@ wstring PlayerTeam::formatNameForTeam(PlayerTeam *team) wstring PlayerTeam::formatNameForTeam(Team *team, const wstring &name) { - if (team == NULL) return name; + if (team == nullptr) return name; return team->getFormattedName(name); } diff --git a/Minecraft.World/PortalForcer.cpp b/Minecraft.World/PortalForcer.cpp index b38508076..13a4778ac 100644 --- a/Minecraft.World/PortalForcer.cpp +++ b/Minecraft.World/PortalForcer.cpp @@ -513,7 +513,7 @@ void PortalForcer::tick(__int64 time) __int64 key = *it; PortalPosition *pos = cachedPortals[key]; - if (pos == NULL || pos->lastUsed < cutoff) + if (pos == nullptr || pos->lastUsed < cutoff) { delete pos; it = cachedPortalKeys.erase(it); diff --git a/Minecraft.World/PortalTile.cpp b/Minecraft.World/PortalTile.cpp index 5e891e536..5e664e656 100644 --- a/Minecraft.World/PortalTile.cpp +++ b/Minecraft.World/PortalTile.cpp @@ -28,7 +28,7 @@ void PortalTile::tick(Level *level, int x, int y, int z, Random *random) // spawn a pig man here int iResult = 0; shared_ptr entity = SpawnEggItem::spawnMobAt(level, 57, x + .5, y0 + 1.1, z + .5, &iResult); - if (entity != NULL) + if (entity != nullptr) { entity->changingDimensionDelay = entity->getDimensionChangingDelay(); } @@ -38,7 +38,7 @@ void PortalTile::tick(Level *level, int x, int y, int z, Random *random) AABB *PortalTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } void PortalTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr forceEntity) // 4J added forceData, forceEntity param @@ -201,7 +201,7 @@ void PortalTile::entityInside(Level *level, int x, int y, int z, shared_ptrGetType() == eTYPE_EXPERIENCEORB ) return; // 4J added - if (entity->riding == NULL && entity->rider.lock() == NULL) entity->handleInsidePortal(); + if (entity->riding == nullptr && entity->rider.lock() == nullptr) entity->handleInsidePortal(); } void PortalTile::animateTick(Level *level, int xt, int yt, int zt, Random *random) diff --git a/Minecraft.World/Pos.cpp b/Minecraft.World/Pos.cpp index b7695a35a..d2f25defd 100644 --- a/Minecraft.World/Pos.cpp +++ b/Minecraft.World/Pos.cpp @@ -28,8 +28,8 @@ Pos::Pos(Pos *position) bool Pos::equals(void *other) { // TODO 4J Stu I cannot do a dynamic_cast from a void pointer - // If I cast it to a Pos then do a dynamic_cast will it still return NULL if it wasn't originally a Pos? - if (!( dynamic_cast( static_cast(other) ) != NULL )) + // If I cast it to a Pos then do a dynamic_cast will it still return nullptr if it wasn't originally a Pos? + if (!( dynamic_cast( static_cast(other) ) != nullptr )) { return false; } diff --git a/Minecraft.World/PotionBrewing.cpp b/Minecraft.World/PotionBrewing.cpp index 3ec38ef94..469c40715 100644 --- a/Minecraft.World/PotionBrewing.cpp +++ b/Minecraft.World/PotionBrewing.cpp @@ -186,7 +186,7 @@ int PotionBrewing::getColorValue(vector *effects) int baseColor = colourTable->getColor( eMinecraftColour_Potion_BaseColour ); - if (effects == NULL || effects->empty()) + if (effects == nullptr || effects->empty()) { return baseColor; } @@ -238,7 +238,7 @@ int PotionBrewing::getColorValue(int brew, bool includeDisabledEffects) } vector *effects = getEffects(brew, false); int color = getColorValue(effects); - if(effects != NULL) + if(effects != nullptr) { for(auto& effect : *effects) { @@ -552,13 +552,13 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, vector *PotionBrewing::getEffects(int brew, bool includeDisabledEffects) { - vector *list = NULL; + vector *list = nullptr; //for (MobEffect effect : MobEffect.effects) for(unsigned int i = 0; i < MobEffect::NUM_EFFECTS; ++i) { MobEffect *effect = MobEffect::effects[i]; - if (effect == NULL || (effect->isDisabled() && !includeDisabledEffects)) + if (effect == nullptr || (effect->isDisabled() && !includeDisabledEffects)) { continue; } @@ -602,7 +602,7 @@ vector *PotionBrewing::getEffects(int brew, bool includeDis } } - if (list == NULL) + if (list == nullptr) { list = new vector(); } diff --git a/Minecraft.World/PotionItem.cpp b/Minecraft.World/PotionItem.cpp index fd8937bf8..3438cb854 100644 --- a/Minecraft.World/PotionItem.cpp +++ b/Minecraft.World/PotionItem.cpp @@ -26,26 +26,26 @@ PotionItem::PotionItem(int id) : Item(id) setStackedByData(true); setMaxDamage(0); - iconThrowable = NULL; - iconDrinkable = NULL; - iconOverlay = NULL; + iconThrowable = nullptr; + iconDrinkable = nullptr; + iconOverlay = nullptr; } vector *PotionItem::getMobEffects(shared_ptr potion) { if (!potion->hasTag() || !potion->getTag()->contains(L"CustomPotionEffects")) { - vector *effects = NULL; + vector *effects = nullptr; auto it = cachedMobEffects.find(potion->getAuxValue()); if(it != cachedMobEffects.end()) effects = it->second; - if (effects == NULL) + if (effects == nullptr) { effects = PotionBrewing::getEffects(potion->getAuxValue(), false); cachedMobEffects[potion->getAuxValue()] = effects; } // Result should be a new (unmanaged) vector, so create a new one - return effects == NULL ? NULL : new vector(*effects); + return effects == nullptr ? nullptr : new vector(*effects); } else { @@ -64,13 +64,13 @@ vector *PotionItem::getMobEffects(shared_ptr vector *PotionItem::getMobEffects(int auxValue) { - vector *effects = NULL; + vector *effects = nullptr; auto it = cachedMobEffects.find(auxValue); if(it != cachedMobEffects.end()) effects = it->second; - if (effects == NULL) + if (effects == nullptr) { effects = PotionBrewing::getEffects(auxValue, false); - if(effects != NULL) cachedMobEffects.insert( std::pair *>(auxValue, effects) ); + if(effects != nullptr) cachedMobEffects.insert( std::pair *>(auxValue, effects) ); } return effects; } @@ -82,7 +82,7 @@ shared_ptr PotionItem::useTimeDepleted(shared_ptr in if (!level->isClientSide) { vector *effects = getMobEffects(instance); - if (effects != NULL) + if (effects != nullptr) { for(auto& effect : *effects) { @@ -183,7 +183,7 @@ bool PotionItem::hasMultipleSpriteLayers() bool PotionItem::hasInstantenousEffects(int itemAuxValue) { vector *mobEffects = getMobEffects(itemAuxValue); - if (mobEffects == NULL || mobEffects->empty()) + if (mobEffects == nullptr || mobEffects->empty()) { return false; } @@ -216,7 +216,7 @@ wstring PotionItem::getHoverName(shared_ptr itemInstance) } vector *effects = ((PotionItem *) Item::potion)->getMobEffects(itemInstance); - if (effects != NULL && !effects->empty()) + if (effects != nullptr && !effects->empty()) { //String postfixString = effects.get(0).getDescriptionId(); //postfixString += ".postfix"; @@ -244,7 +244,7 @@ void PotionItem::appendHoverText(shared_ptr itemInstance, shared_p } vector *effects = ((PotionItem *) Item::potion)->getMobEffects(itemInstance); attrAttrModMap modifiers; - if (effects != NULL && !effects->empty()) + if (effects != nullptr && !effects->empty()) { //for (MobEffectInstance effect : effects) for(auto& effect : *effects) @@ -254,7 +254,7 @@ void PotionItem::appendHoverText(shared_ptr itemInstance, shared_p MobEffect *mobEffect = MobEffect::effects[effect->getId()]; unordered_map *effectModifiers = mobEffect->getAttributeModifiers(); - if (effectModifiers != NULL && effectModifiers->size() > 0) + if (effectModifiers != nullptr && effectModifiers->size() > 0) { for(auto& it : *effectModifiers) { @@ -335,7 +335,7 @@ void PotionItem::appendHoverText(shared_ptr itemInstance, shared_p bool PotionItem::isFoil(shared_ptr itemInstance) { vector *mobEffects = getMobEffects(itemInstance); - return mobEffects != NULL && !mobEffects->empty(); + return mobEffects != nullptr && !mobEffects->empty(); } unsigned int PotionItem::getUseDescriptionId(shared_ptr instance) @@ -368,7 +368,7 @@ Icon *PotionItem::getTexture(const wstring &name) if (name.compare(DEFAULT_ICON) == 0) return Item::potion->iconDrinkable; if (name.compare(THROWABLE_ICON) == 0) return Item::potion->iconThrowable; if (name.compare(CONTENTS_ICON) == 0) return Item::potion->iconOverlay; - return NULL; + return nullptr; } @@ -381,7 +381,7 @@ vector > *PotionItem::getUniquePotionValues() { vector *effects = PotionBrewing::getEffects(brew, false); - if (effects != NULL) + if (effects != nullptr) { if(!effects->empty()) { diff --git a/Minecraft.World/PreLoginPacket.cpp b/Minecraft.World/PreLoginPacket.cpp index 5be50ea79..aa6832cad 100644 --- a/Minecraft.World/PreLoginPacket.cpp +++ b/Minecraft.World/PreLoginPacket.cpp @@ -9,7 +9,7 @@ PreLoginPacket::PreLoginPacket() { loginKey = L""; - m_playerXuids = NULL; + m_playerXuids = nullptr; m_dwPlayerCount = 0; m_friendsOnlyBits = 0; m_ugcPlayersVersion = 0; @@ -23,7 +23,7 @@ PreLoginPacket::PreLoginPacket() PreLoginPacket::PreLoginPacket(wstring userName) { this->loginKey = userName; - m_playerXuids = NULL; + m_playerXuids = nullptr; m_dwPlayerCount = 0; m_friendsOnlyBits = 0; m_ugcPlayersVersion = 0; @@ -50,7 +50,7 @@ PreLoginPacket::PreLoginPacket(wstring userName, PlayerUID *playerXuids, DWORD p PreLoginPacket::~PreLoginPacket() { - if( m_playerXuids != NULL ) delete [] m_playerXuids; + if( m_playerXuids != nullptr ) delete [] m_playerXuids; } void PreLoginPacket::read(DataInputStream *dis) //throws IOException diff --git a/Minecraft.World/PressurePlateTile.cpp b/Minecraft.World/PressurePlateTile.cpp index beed308ac..650fbf9f8 100644 --- a/Minecraft.World/PressurePlateTile.cpp +++ b/Minecraft.World/PressurePlateTile.cpp @@ -23,14 +23,14 @@ int PressurePlateTile::getSignalForData(int data) int PressurePlateTile::getSignalStrength(Level *level, int x, int y, int z) { - vector< shared_ptr > *entities = NULL; + vector< shared_ptr > *entities = nullptr; if (sensitivity == everything) entities = level->getEntities(nullptr, getSensitiveAABB(x, y, z)); else if (sensitivity == mobs) entities = level->getEntitiesOfClass(typeid(LivingEntity), getSensitiveAABB(x, y, z)); else if (sensitivity == players) entities = level->getEntitiesOfClass(typeid(Player), getSensitiveAABB(x, y, z)); else __debugbreak(); // 4J-JEV: We're going to delete something at a random location. - if (entities != NULL && !entities->empty()) + if (entities != nullptr && !entities->empty()) { for (auto& e : *entities) { diff --git a/Minecraft.World/ProtectionEnchantment.cpp b/Minecraft.World/ProtectionEnchantment.cpp index 8304529b0..13a6836cc 100644 --- a/Minecraft.World/ProtectionEnchantment.cpp +++ b/Minecraft.World/ProtectionEnchantment.cpp @@ -54,7 +54,7 @@ int ProtectionEnchantment::getDescriptionId() bool ProtectionEnchantment::isCompatibleWith(Enchantment *other) const { ProtectionEnchantment *pe = dynamic_cast( other ); - if (pe != NULL) + if (pe != nullptr) { if (pe->type == type) { diff --git a/Minecraft.World/PumpkinTile.cpp b/Minecraft.World/PumpkinTile.cpp index 2bc369721..f7bfe218c 100644 --- a/Minecraft.World/PumpkinTile.cpp +++ b/Minecraft.World/PumpkinTile.cpp @@ -13,8 +13,8 @@ const wstring PumpkinTile::TEXTURE_LANTERN = L"pumpkin_jack"; PumpkinTile::PumpkinTile(int id, bool lit) : DirectionalTile(id, Material::vegetable, isSolidRender() ) { - iconTop = NULL; - iconFace = NULL; + iconTop = nullptr; + iconFace = nullptr; setTicking(true); this->lit = lit; } diff --git a/Minecraft.World/RandomLevelSource.cpp b/Minecraft.World/RandomLevelSource.cpp index 3e6994f77..1946e44e6 100644 --- a/Minecraft.World/RandomLevelSource.cpp +++ b/Minecraft.World/RandomLevelSource.cpp @@ -58,8 +58,8 @@ RandomLevelSource::RandomLevelSource(Level *level, __int64 seed, bool generateSt } else { - floatingIslandScale = NULL; - floatingIslandNoise = NULL; + floatingIslandScale = nullptr; + floatingIslandNoise = nullptr; } forestNoise = new PerlinNoise(random, 8); @@ -93,7 +93,7 @@ RandomLevelSource::~RandomLevelSource() delete forestNoise; - if( pows.data != NULL ) delete [] pows.data; + if( pows.data != nullptr ) delete [] pows.data; } @@ -385,7 +385,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi byte material = b->material; LevelGenerationOptions *lgo = app.getLevelGenerationOptions(); - if(lgo != NULL) + if(lgo != nullptr) { lgo->getBiomeOverride(b->id,material,top); } @@ -420,7 +420,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi { top = b->topMaterial; material = b->material; - if(lgo != NULL) + if(lgo != nullptr) { lgo->getBiomeOverride(b->id,material,top); } @@ -525,11 +525,11 @@ void RandomLevelSource::lightChunk(LevelChunk *lc) doubleArray RandomLevelSource::getHeights(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize, BiomeArray& biomes) { - if (buffer.data == NULL) + if (buffer.data == nullptr) { buffer = doubleArray(xSize * ySize * zSize); } - if (pows.data == NULL) + if (pows.data == nullptr) { pows = floatArray(5 * 5); for (int xb = -2; xb <= 2; xb++) @@ -882,9 +882,9 @@ wstring RandomLevelSource::gatherStats() vector *RandomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { Biome *biome = level->getBiome(x, z); - if (biome == NULL) + if (biome == nullptr) { - return NULL; + return nullptr; } if (mobCategory == MobCategory::monster && scatteredFeature->isSwamphut(x, y, z)) { @@ -895,20 +895,20 @@ vector *RandomLevelSource::getMobsAt(MobCategory *mobCa TilePos *RandomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) { - if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != NULL) + if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != nullptr) { return strongholdFeature->getNearestGeneratedFeature(level, x, y, z); } - return NULL; + return nullptr; } 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/RandomPos.cpp b/Minecraft.World/RandomPos.cpp index c2cfd9080..1a86800e9 100644 --- a/Minecraft.World/RandomPos.cpp +++ b/Minecraft.World/RandomPos.cpp @@ -7,7 +7,7 @@ Vec3 *RandomPos::tempDir = Vec3::newPermanent(0, 0, 0); Vec3 *RandomPos::getPos(shared_ptr mob, int xzDist, int yDist, int quadrant/*=-1*/) // 4J - added quadrant { - return generateRandomPos(mob, xzDist, yDist, NULL, quadrant); + return generateRandomPos(mob, xzDist, yDist, nullptr, quadrant); } Vec3 *RandomPos::getPosTowards(shared_ptr mob, int xzDist, int yDist, Vec3 *towardsPos) @@ -62,7 +62,7 @@ Vec3 *RandomPos::generateRandomPos(shared_ptr mob, int xzDist, in } yt = random->nextInt(2 * yDist) - yDist; - if (dir != NULL && xt * dir->x + zt * dir->z < 0) continue; + if (dir != nullptr && xt * dir->x + zt * dir->z < 0) continue; xt += Mth::floor(mob->x); yt += Mth::floor(mob->y); @@ -84,5 +84,5 @@ Vec3 *RandomPos::generateRandomPos(shared_ptr mob, int xzDist, in return Vec3::newTemp(xBest, yBest, zBest); } - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.World/RandomScatteredLargeFeature.cpp b/Minecraft.World/RandomScatteredLargeFeature.cpp index bd0b70bb0..3b03dba62 100644 --- a/Minecraft.World/RandomScatteredLargeFeature.cpp +++ b/Minecraft.World/RandomScatteredLargeFeature.cpp @@ -67,7 +67,7 @@ bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat bool forcePlacement = false; LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); - if( levelGenOptions != NULL ) + if( levelGenOptions != nullptr ) { forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Temples); } @@ -123,14 +123,14 @@ RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart(Level bool RandomScatteredLargeFeature::isSwamphut(int cellX, int cellY, int cellZ) { StructureStart *structureAt = getStructureAt(cellX, cellY, cellZ); - if (structureAt == NULL || !( dynamic_cast( structureAt ) ) || structureAt->pieces.empty()) + if (structureAt == nullptr || !( dynamic_cast( structureAt ) ) || structureAt->pieces.empty()) { return false; } - StructurePiece *first = NULL; + StructurePiece *first = nullptr; auto it = structureAt->pieces.begin(); if(it != structureAt->pieces.end() ) first = *it; - return dynamic_cast(first) != NULL; + return dynamic_cast(first) != nullptr; } vector *RandomScatteredLargeFeature::getSwamphutEnemies() diff --git a/Minecraft.World/RandomStrollGoal.cpp b/Minecraft.World/RandomStrollGoal.cpp index 15957ab38..4eb5815da 100644 --- a/Minecraft.World/RandomStrollGoal.cpp +++ b/Minecraft.World/RandomStrollGoal.cpp @@ -22,7 +22,7 @@ bool RandomStrollGoal::canUse() if (mob->getRandom()->nextInt(120) == 0) { Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast(mob->shared_from_this()), 10, 7); - if (pos == NULL) return false; + if (pos == nullptr) return false; wantedX = pos->x; wantedY = pos->y; wantedZ = pos->z; @@ -38,7 +38,7 @@ bool RandomStrollGoal::canUse() if( mob->isExtraWanderingEnabled() ) { Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast(mob->shared_from_this()), 10, 7,mob->getWanderingQuadrant()); - if (pos == NULL) return false; + if (pos == nullptr) return false; wantedX = pos->x; wantedY = pos->y; wantedZ = pos->z; diff --git a/Minecraft.World/RangedAttackGoal.cpp b/Minecraft.World/RangedAttackGoal.cpp index 2923e0111..72178d9d5 100644 --- a/Minecraft.World/RangedAttackGoal.cpp +++ b/Minecraft.World/RangedAttackGoal.cpp @@ -40,7 +40,7 @@ RangedAttackGoal::RangedAttackGoal(RangedAttackMob *rangedMob, Mob *mob, double bool RangedAttackGoal::canUse() { shared_ptr bestTarget = mob->getTarget(); - if (bestTarget == NULL) return false; + if (bestTarget == nullptr) return false; target = weak_ptr(bestTarget); return true; } @@ -60,7 +60,7 @@ void RangedAttackGoal::stop() void RangedAttackGoal::tick() { // 4J: It's possible the target has gone since canUse selected it, don't do tick if target is null - if (target.lock() == NULL) return; + if (target.lock() == nullptr) return; double targetDistSqr = mob->distanceToSqr(target.lock()->x, target.lock()->bb->y0, target.lock()->z); bool canSee = mob->getSensing()->canSee(target.lock()); diff --git a/Minecraft.World/ReadOnlyChunkCache.cpp b/Minecraft.World/ReadOnlyChunkCache.cpp index fdab13dc1..dfafdf2d5 100644 --- a/Minecraft.World/ReadOnlyChunkCache.cpp +++ b/Minecraft.World/ReadOnlyChunkCache.cpp @@ -25,7 +25,7 @@ ReadOnlyChunkCache::~ReadOnlyChunkCache() bool ReadOnlyChunkCache::hasChunk(int x, int z) { int slot = (x & LEN_MASK) | ((z & LEN_MASK) * LEN); - return chunks[slot] != NULL && (chunks[slot]->isAt(x, z)); + return chunks[slot] != nullptr && (chunks[slot]->isAt(x, z)); } LevelChunk *ReadOnlyChunkCache::create(int x, int z) @@ -41,7 +41,7 @@ LevelChunk *ReadOnlyChunkCache::getChunk(int x, int z) if (!hasChunk(x, z)) { LevelChunk *newChunk = load(x, z); - if (newChunk == NULL) + if (newChunk == nullptr) { newChunk = new EmptyLevelChunk(level, emptyPixels, x, z); } @@ -91,10 +91,10 @@ wstring ReadOnlyChunkCache::gatherStats() vector *ReadOnlyChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { - return NULL; + return nullptr; } TilePos *ReadOnlyChunkCache::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } diff --git a/Minecraft.World/Recipes.cpp b/Minecraft.World/Recipes.cpp index eca5951f2..94ee30ac7 100644 --- a/Minecraft.World/Recipes.cpp +++ b/Minecraft.World/Recipes.cpp @@ -8,15 +8,15 @@ #include "net.minecraft.world.level.tile.h" #include "net.minecraft.world.item.crafting.h" -Recipes *Recipes::instance = NULL; -ArmorRecipes *Recipes::pArmorRecipes=NULL; -ClothDyeRecipes *Recipes::pClothDyeRecipes=NULL; -FoodRecipies *Recipes::pFoodRecipies=NULL; -OreRecipies *Recipes::pOreRecipies=NULL; -StructureRecipies *Recipes::pStructureRecipies=NULL; -ToolRecipies *Recipes::pToolRecipies=NULL; -WeaponRecipies *Recipes::pWeaponRecipies=NULL; -FireworksRecipe *Recipes::pFireworksRecipes=NULL; +Recipes *Recipes::instance = nullptr; +ArmorRecipes *Recipes::pArmorRecipes=nullptr; +ClothDyeRecipes *Recipes::pClothDyeRecipes=nullptr; +FoodRecipies *Recipes::pFoodRecipies=nullptr; +OreRecipies *Recipes::pOreRecipies=nullptr; +StructureRecipies *Recipes::pStructureRecipies=nullptr; +ToolRecipies *Recipes::pToolRecipies=nullptr; +WeaponRecipies *Recipes::pWeaponRecipies=nullptr; +FireworksRecipe *Recipes::pFireworksRecipes=nullptr; void Recipes::staticCtor() { @@ -1042,7 +1042,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...) Item *pItem; wchar_t wchFrom; int iCount; - ItemInstance **ids = NULL; + ItemInstance **ids = nullptr; myMap *mappings = new unordered_map(); @@ -1163,7 +1163,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...) } else { - ids[j] = NULL; + ids[j] = nullptr; } } } @@ -1248,7 +1248,7 @@ void Recipes::addShapelessRecipy(ItemInstance *result,... ) recipies->push_back(new ShapelessRecipy(result, ingredients, group)); } -shared_ptr Recipes::getItemFor(shared_ptr craftSlots, Level *level, Recipy *recipesClass /*= NULL*/) +shared_ptr Recipes::getItemFor(shared_ptr craftSlots, Level *level, Recipy *recipesClass /*= nullptr*/) { int count = 0; shared_ptr first = nullptr; @@ -1256,7 +1256,7 @@ shared_ptr Recipes::getItemFor(shared_ptr craft for (int i = 0; i < craftSlots->getContainerSize(); i++) { shared_ptr item = craftSlots->getItem(i); - if (item != NULL) + if (item != nullptr) { if (count == 0) first = item; if (count == 1) second = item; @@ -1275,7 +1275,7 @@ shared_ptr Recipes::getItemFor(shared_ptr craft return shared_ptr( new ItemInstance(first->id, 1, resultDamage) ); } - if(recipesClass != NULL) + if(recipesClass != nullptr) { if (recipesClass->matches(craftSlots, level)) return recipesClass->assemble(craftSlots); } diff --git a/Minecraft.World/Recipes.h b/Minecraft.World/Recipes.h index aacdac305..d6e508a89 100644 --- a/Minecraft.World/Recipes.h +++ b/Minecraft.World/Recipes.h @@ -90,7 +90,7 @@ class Recipes ShapedRecipy *addShapedRecipy(ItemInstance *, ... ); void addShapelessRecipy(ItemInstance *result,... ); - shared_ptr getItemFor(shared_ptr craftSlots, Level *level, Recipy *recipesClass = NULL); // 4J Added recipesClass param + shared_ptr getItemFor(shared_ptr craftSlots, Level *level, Recipy *recipesClass = nullptr); // 4J Added recipesClass param vector *getRecipies(); // 4J-PB - Added all below for new Xbox 'crafting' diff --git a/Minecraft.World/RecordingItem.cpp b/Minecraft.World/RecordingItem.cpp index 8e0de1156..3475263f5 100644 --- a/Minecraft.World/RecordingItem.cpp +++ b/Minecraft.World/RecordingItem.cpp @@ -73,6 +73,6 @@ RecordingItem *RecordingItem::getByName(const wstring &name) } else { - return NULL; + return nullptr; } } \ No newline at end of file diff --git a/Minecraft.World/RedStoneDustTile.cpp b/Minecraft.World/RedStoneDustTile.cpp index a4577bd32..e348406b9 100644 --- a/Minecraft.World/RedStoneDustTile.cpp +++ b/Minecraft.World/RedStoneDustTile.cpp @@ -25,10 +25,10 @@ RedStoneDustTile::RedStoneDustTile(int id) : Tile(id, Material::decoration,isSol updateDefaultShape(); - iconCross = NULL; - iconLine = NULL; - iconCrossOver = NULL; - iconLineOver = NULL; + iconCross = nullptr; + iconLine = nullptr; + iconCrossOver = nullptr; + iconLineOver = nullptr; } // 4J Added override @@ -39,7 +39,7 @@ void RedStoneDustTile::updateDefaultShape() AABB *RedStoneDustTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool RedStoneDustTile::isSolidRender(bool isServerLevel) @@ -409,5 +409,5 @@ Icon *RedStoneDustTile::getTexture(const wstring &name) if (name.compare(TEXTURE_LINE) == 0) return Tile::redStoneDust->iconLine; if (name.compare(TEXTURE_CROSS_OVERLAY) == 0) return Tile::redStoneDust->iconCrossOver; if (name.compare(TEXTURE_LINE_OVERLAY) == 0) return Tile::redStoneDust->iconLineOver; - return NULL; + return nullptr; } diff --git a/Minecraft.World/ReedTile.cpp b/Minecraft.World/ReedTile.cpp index c01eb7646..dc60bfba6 100644 --- a/Minecraft.World/ReedTile.cpp +++ b/Minecraft.World/ReedTile.cpp @@ -78,7 +78,7 @@ bool ReedTile::canSurvive(Level *level, int x, int y, int z) AABB *ReedTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } int ReedTile::getResource(int data, Random *random, int playerBonusLevel) diff --git a/Minecraft.World/ReedsFeature.cpp b/Minecraft.World/ReedsFeature.cpp index 2792b21bd..ec46f0538 100644 --- a/Minecraft.World/ReedsFeature.cpp +++ b/Minecraft.World/ReedsFeature.cpp @@ -12,7 +12,7 @@ bool ReedsFeature::place(Level *level, Random *random, int x, int y, int z) int z2 = z + random->nextInt(4) - random->nextInt(4); // 4J Stu Added to stop reed features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x2, y2, z2, x2, y2, z2); diff --git a/Minecraft.World/Region.cpp b/Minecraft.World/Region.cpp index e4edce166..1e8acaf36 100644 --- a/Minecraft.World/Region.cpp +++ b/Minecraft.World/Region.cpp @@ -45,7 +45,7 @@ Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2, int for (int zc = zc1; zc <= zc2; zc++) { LevelChunk *chunk = level->getChunk(xc, zc); - if(chunk != NULL) + if(chunk != nullptr) { LevelChunkArray *lca = (*chunks)[xc - xc1]; lca->data[zc - zc1] = chunk; @@ -58,7 +58,7 @@ Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2, int { LevelChunkArray *lca = (*chunks)[xc - xc1]; LevelChunk *chunk = lca->data[zc - zc1]; - if (chunk != NULL) + if (chunk != nullptr) { if (!chunk->isYSpaceEmpty(y1, y2)) { @@ -71,7 +71,7 @@ Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2, int // AP - added a caching system for Chunk::rebuild to take advantage of xcCached = -1; zcCached = -1; - CachedTiles = NULL; + CachedTiles = nullptr; } bool Region::isAllEmpty() @@ -111,7 +111,7 @@ int Region::getTile(int x, int y, int z) } LevelChunk *lc = (*chunks)[xc]->data[zc]; - if (lc == NULL) return 0; + if (lc == nullptr) return 0; return lc->getTile(x & 15, y, z & 15); } @@ -122,7 +122,7 @@ void Region::setCachedTiles(unsigned char *tiles, int xc, int zc) xcCached = xc; zcCached = zc; int size = 16 * 16 * Level::maxBuildHeight; - if( CachedTiles == NULL ) + if( CachedTiles == nullptr ) { CachedTiles = static_cast(malloc(size)); } @@ -132,14 +132,14 @@ void Region::setCachedTiles(unsigned char *tiles, int xc, int zc) LevelChunk* Region::getLevelChunk(int x, int y, int z) { if (y < 0) return 0; - if (y >= Level::maxBuildHeight) return NULL; + if (y >= Level::maxBuildHeight) return nullptr; int xc = (x >> 4) - xc1; int zc = (z >> 4) - zc1; if (xc < 0 || xc >= static_cast(chunks->length) || zc < 0 || zc >= static_cast((*chunks)[xc]->length)) { - return NULL; + return nullptr; } LevelChunk *lc = (*chunks)[xc]->data[zc]; @@ -263,7 +263,7 @@ Biome *Region::getBiome(int x, int z) bool Region::isSolidRenderTile(int x, int y, int z) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile == NULL) return false; + if (tile == nullptr) return false; // 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so // blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by @@ -278,7 +278,7 @@ bool Region::isSolidRenderTile(int x, int y, int z) for( int i = 0; i < 6; i++ ) { int t = getTile(x + axo[i], y + ayo[i] , z + azo[i]); - if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) ) + if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == nullptr ) || !Tile::tiles[t]->isSolidRender() ) ) { return false; } @@ -294,7 +294,7 @@ bool Region::isSolidRenderTile(int x, int y, int z) bool Region::isSolidBlockingTile(int x, int y, int z) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - if (tile == NULL) return false; + if (tile == nullptr) return false; return tile->material->blocksMotion() && tile->isCubeShaped(); } @@ -307,7 +307,7 @@ bool Region::isTopSolidBlocking(int x, int y, int z) bool Region::isEmptyTile(int x, int y, int z) { Tile *tile = Tile::tiles[getTile(x, y, z)]; - return (tile == NULL); + return (tile == nullptr); } diff --git a/Minecraft.World/RegionFile.cpp b/Minecraft.World/RegionFile.cpp index 10efc2fa2..ddbeb6554 100644 --- a/Minecraft.World/RegionFile.cpp +++ b/Minecraft.World/RegionFile.cpp @@ -39,7 +39,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) */ fileEntry = m_saveFile->createFile( fileName->getName() ); - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END ); + m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_END ); if ( fileEntry->getFileSize() < SECTOR_BYTES) { @@ -54,7 +54,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) m_bIsEmpty = false; } - //if ((GetFileSize(file,NULL) & 0xfff) != 0) + //if ((GetFileSize(file,nullptr) & 0xfff) != 0) if ((fileEntry->getFileSize() & 0xfff) != 0) { //byte zero = 0; @@ -91,7 +91,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) sectorFree->at(0) = false; // chunk offset table sectorFree->at(1) = false; // for the last modified info - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_BEGIN ); for (int i = 0; i < SECTOR_INTS; ++i) { unsigned int offset = 0; @@ -139,11 +139,11 @@ void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile conversi m_saveFile->LockSaveAccess(); DWORD numberOfBytesWritten = 0; - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_BEGIN ); m_saveFile->writeFile(fileEntry,offsets, SECTOR_BYTES ,&numberOfBytesWritten); numberOfBytesWritten = 0; - m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES, nullptr, FILE_BEGIN ); m_saveFile->writeFile(fileEntry, chunkTimestamps, SECTOR_BYTES, &numberOfBytesWritten); m_saveFile->ReleaseSaveAccess(); @@ -175,7 +175,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was if (outOfBounds(x, z)) { // debugln("READ", x, z, "out of bounds"); - return NULL; + return nullptr; } // 4J - removed try/catch @@ -184,7 +184,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was if (offset == 0) { // debugln("READ", x, z, "miss"); - return NULL; + return nullptr; } unsigned int sectorNumber = offset >> 8; @@ -193,13 +193,13 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was if (sectorNumber + numSectors > sectorFree->size()) { // debugln("READ", x, z, "invalid sector"); - return NULL; + return nullptr; } m_saveFile->LockSaveAccess(); //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN); + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN); unsigned int length; unsigned int decompLength; @@ -229,7 +229,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was // debugln("READ", x, z, "invalid length: " + length + " > 4096 * " + numSectors); m_saveFile->ReleaseSaveAccess(); - return NULL; + return nullptr; } MemSect(50); @@ -373,7 +373,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync */ // debug("SAVE", x, z, length, "grow"); //SetFilePointer(file,0,0,FILE_END); - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END ); + m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_END ); sectorNumber = static_cast(sectorFree->size()); #ifndef _CONTENT_PACAKGE @@ -382,7 +382,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync DWORD numberOfBytesWritten = 0; for (int i = 0; i < sectorsNeeded; ++i) { - //WriteFile(file,emptySector.data,SECTOR_BYTES,&numberOfBytesWritten,NULL); + //WriteFile(file,emptySector.data,SECTOR_BYTES,&numberOfBytesWritten,nullptr); m_saveFile->writeFile(fileEntry,emptySector.data,SECTOR_BYTES,&numberOfBytesWritten); sectorFree->push_back(false); } @@ -407,7 +407,7 @@ void RegionFile::write(int sectorNumber, byte *data, int length, unsigned int co { DWORD numberOfBytesWritten = 0; //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN ); // 4J - this differs a bit from the java file format. Java has length stored as an int, then a type as a byte, then length-1 bytes of data // We store length and decompression length as ints, then length bytes of xbox LZX compressed data @@ -426,7 +426,7 @@ void RegionFile::zero(int sectorNumber, int length) { DWORD numberOfBytesWritten = 0; //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN ); m_saveFile->zeroFile( fileEntry, length, &numberOfBytesWritten ); } @@ -449,7 +449,7 @@ bool RegionFile::hasChunk(int x, int z) // 4J added - write the initial two sectors that used to be written in the ctor when the file was empty void RegionFile::insertInitialSectors() { - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_BEGIN ); DWORD numberOfBytesWritten = 0; byte zeroBytes[ SECTOR_BYTES ]; ZeroMemory(zeroBytes, SECTOR_BYTES); @@ -472,7 +472,7 @@ void RegionFile::setOffset(int x, int z, int offset) DWORD numberOfBytesWritten = 0; offsets[x + z * 32] = offset; - m_saveFile->setFilePointer( fileEntry, (x + z * 32) * 4, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, (x + z * 32) * 4, nullptr, FILE_BEGIN ); m_saveFile->writeFile(fileEntry,&offset,4,&numberOfBytesWritten); } @@ -486,7 +486,7 @@ void RegionFile::setTimestamp(int x, int z, int value) DWORD numberOfBytesWritten = 0; chunkTimestamps[x + z * 32] = value; - m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES + (x + z * 32) * 4, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES + (x + z * 32) * 4, nullptr, FILE_BEGIN ); m_saveFile->writeFile(fileEntry,&value,4,&numberOfBytesWritten); } diff --git a/Minecraft.World/RegionFileCache.cpp b/Minecraft.World/RegionFileCache.cpp index 2bb370a8a..ab0492b48 100644 --- a/Minecraft.World/RegionFileCache.cpp +++ b/Minecraft.World/RegionFileCache.cpp @@ -38,13 +38,13 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst } MemSect(0); - RegionFile *ref = NULL; + RegionFile *ref = nullptr; auto it = cache.find(file); if( it != cache.end() ) ref = it->second; // 4J Jev, put back in. - if (ref != NULL) + if (ref != nullptr) { return ref; } @@ -72,7 +72,7 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized for(auto& it : cache) { RegionFile *regionFile = it.second; - if (regionFile != NULL) + if (regionFile != nullptr) { regionFile->close(); } diff --git a/Minecraft.World/RepairResultSlot.cpp b/Minecraft.World/RepairResultSlot.cpp index 51e95b424..87d2aab6e 100644 --- a/Minecraft.World/RepairResultSlot.cpp +++ b/Minecraft.World/RepairResultSlot.cpp @@ -30,7 +30,7 @@ void RepairResultSlot::onTake(shared_ptr player, shared_ptrrepairItemCountCost > 0) { shared_ptr addition = m_menu->repairSlots->getItem(AnvilMenu::ADDITIONAL_SLOT); - if (addition != NULL && addition->count > m_menu->repairItemCountCost) + if (addition != nullptr && addition->count > m_menu->repairItemCountCost) { addition->count -= m_menu->repairItemCountCost; m_menu->repairSlots->setItem(AnvilMenu::ADDITIONAL_SLOT, addition); diff --git a/Minecraft.World/RespawnPacket.cpp b/Minecraft.World/RespawnPacket.cpp index d9e37dca5..2e91b8f5a 100644 --- a/Minecraft.World/RespawnPacket.cpp +++ b/Minecraft.World/RespawnPacket.cpp @@ -11,9 +11,9 @@ RespawnPacket::RespawnPacket() this->difficulty = 1; this->mapSeed = 0; this->mapHeight = 0; - this->playerGameType = NULL; + this->playerGameType = nullptr; this->m_newSeaLevel = false; - m_pLevelType = NULL; + m_pLevelType = nullptr; m_newEntityId = 0; m_xzSize = LEVEL_MAX_WIDTH; m_hellScale = HELL_LEVEL_MAX_SCALE; @@ -47,7 +47,7 @@ void RespawnPacket::read(DataInputStream *dis) //throws IOException mapHeight = dis->readShort(); wstring typeName = readUtf(dis, 16); m_pLevelType = LevelType::getLevelType(typeName); - if (m_pLevelType == NULL) + if (m_pLevelType == nullptr) { m_pLevelType = LevelType::lvl_normal; } @@ -68,7 +68,7 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException dos->writeByte(dimension); dos->writeByte(playerGameType->getId()); dos->writeShort(mapHeight); - if (m_pLevelType == NULL) + if (m_pLevelType == nullptr) { writeUtf(L"", dos); } @@ -89,7 +89,7 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException int RespawnPacket::getEstimatedSize() { int length=0; - if (m_pLevelType != NULL) + if (m_pLevelType != nullptr) { length = static_cast(m_pLevelType->getGeneratorName().length()); } diff --git a/Minecraft.World/RestrictOpenDoorGoal.cpp b/Minecraft.World/RestrictOpenDoorGoal.cpp index e8620a71d..3f7e2ed98 100644 --- a/Minecraft.World/RestrictOpenDoorGoal.cpp +++ b/Minecraft.World/RestrictOpenDoorGoal.cpp @@ -14,9 +14,9 @@ bool RestrictOpenDoorGoal::canUse() { if (mob->level->isDay()) return false; shared_ptr village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 16); - if (village == NULL) return false; + if (village == nullptr) return false; shared_ptr _doorInfo = village->getClosestDoorInfo(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)); - if (_doorInfo == NULL) return false; + if (_doorInfo == nullptr) return false; doorInfo = _doorInfo; return _doorInfo->distanceToInsideSqr(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)) < 1.5 * 1.5; } @@ -25,7 +25,7 @@ bool RestrictOpenDoorGoal::canContinueToUse() { if (mob->level->isDay()) return false; shared_ptr _doorInfo = doorInfo.lock(); - if ( _doorInfo == NULL ) return false; + if ( _doorInfo == nullptr ) return false; return !_doorInfo->removed && _doorInfo->isInsideSide(Mth::floor(mob->x), Mth::floor(mob->z)); } diff --git a/Minecraft.World/ResultContainer.cpp b/Minecraft.World/ResultContainer.cpp index 8c85d0c32..7c8dd1c18 100644 --- a/Minecraft.World/ResultContainer.cpp +++ b/Minecraft.World/ResultContainer.cpp @@ -33,7 +33,7 @@ bool ResultContainer::hasCustomName() shared_ptr ResultContainer::removeItem(unsigned int slot, int count) { - if (items[0] != NULL) + if (items[0] != nullptr) { shared_ptr item = items[0]; items[0] = nullptr; @@ -44,7 +44,7 @@ shared_ptr ResultContainer::removeItem(unsigned int slot, int coun shared_ptr ResultContainer::removeItemNoUpdate(int slot) { - if (items[0] != NULL) + if (items[0] != nullptr) { shared_ptr item = items[0]; items[0] = nullptr; diff --git a/Minecraft.World/ResultSlot.cpp b/Minecraft.World/ResultSlot.cpp index 08ffe714a..87318d66b 100644 --- a/Minecraft.World/ResultSlot.cpp +++ b/Minecraft.World/ResultSlot.cpp @@ -60,7 +60,7 @@ void ResultSlot::onTake(shared_ptr player, shared_ptr carr for (unsigned int i = 0; i < craftSlots->getContainerSize(); i++) { shared_ptr item = craftSlots->getItem(i); - if (item != NULL) + if (item != nullptr) { craftSlots->removeItem(i, 1); @@ -77,7 +77,7 @@ void ResultSlot::onTake(shared_ptr player, shared_ptr carr } // If this slot is now empty, place it there (current behavior) - if (craftSlots->getItem(i) == NULL) + if (craftSlots->getItem(i) == nullptr) { craftSlots->setItem(i, craftResult); } diff --git a/Minecraft.World/RunAroundLikeCrazyGoal.cpp b/Minecraft.World/RunAroundLikeCrazyGoal.cpp index 118b09f92..40138d739 100644 --- a/Minecraft.World/RunAroundLikeCrazyGoal.cpp +++ b/Minecraft.World/RunAroundLikeCrazyGoal.cpp @@ -17,9 +17,9 @@ RunAroundLikeCrazyGoal::RunAroundLikeCrazyGoal(EntityHorse *mob, double speedMod bool RunAroundLikeCrazyGoal::canUse() { - if (horse->isTamed() || horse->rider.lock() == NULL) return false; + if (horse->isTamed() || horse->rider.lock() == nullptr) return false; Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast(horse->shared_from_this()), 5, 4); - if (pos == NULL) return false; + if (pos == nullptr) return false; posX = pos->x; posY = pos->y; posZ = pos->z; @@ -33,7 +33,7 @@ void RunAroundLikeCrazyGoal::start() bool RunAroundLikeCrazyGoal::canContinueToUse() { - return !horse->getNavigation()->isDone() && horse->rider.lock() != NULL; + return !horse->getNavigation()->isDone() && horse->rider.lock() != nullptr; } void RunAroundLikeCrazyGoal::tick() diff --git a/Minecraft.World/SaddleItem.cpp b/Minecraft.World/SaddleItem.cpp index f982b7517..638730609 100644 --- a/Minecraft.World/SaddleItem.cpp +++ b/Minecraft.World/SaddleItem.cpp @@ -11,7 +11,7 @@ SaddleItem::SaddleItem(int id) : Item(id) bool SaddleItem::interactEnemy(shared_ptr itemInstance, shared_ptr player, shared_ptr mob) { - if ( (mob != NULL) && mob->instanceof(eTYPE_PIG) ) + if ( (mob != nullptr) && mob->instanceof(eTYPE_PIG) ) { shared_ptr pig = dynamic_pointer_cast(mob); if (!pig->hasSaddle() && !pig->isBaby()) diff --git a/Minecraft.World/SandFeature.cpp b/Minecraft.World/SandFeature.cpp index 122264fff..9c0dc67c0 100644 --- a/Minecraft.World/SandFeature.cpp +++ b/Minecraft.World/SandFeature.cpp @@ -22,7 +22,7 @@ bool SandFeature::place(Level *level, Random *random, int x, int y, int z) int yr = 2; // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x - r, y - yr, z - r, x + r, y + yr, z + r); diff --git a/Minecraft.World/SandStoneTile.cpp b/Minecraft.World/SandStoneTile.cpp index daf42db86..bd7309b9d 100644 --- a/Minecraft.World/SandStoneTile.cpp +++ b/Minecraft.World/SandStoneTile.cpp @@ -14,9 +14,9 @@ int SandStoneTile::SANDSTONE_NAMES[SANDSTONE_BLOCK_NAMES] = { SandStoneTile::SandStoneTile(int id) : Tile(id, Material::stone) { - icons = NULL; - iconTop = NULL; - iconBottom = NULL; + icons = nullptr; + iconTop = nullptr; + iconBottom = nullptr; } Icon *SandStoneTile::getTexture(int face, int data) diff --git a/Minecraft.World/Sapling.cpp b/Minecraft.World/Sapling.cpp index 85fcea986..c169a6082 100644 --- a/Minecraft.World/Sapling.cpp +++ b/Minecraft.World/Sapling.cpp @@ -17,7 +17,7 @@ const wstring Sapling::TEXTURE_NAMES[] = {L"sapling", L"sapling_spruce", L"sapli Sapling::Sapling(int id) : Bush( id ) { this->updateDefaultShape(); - icons = NULL; + icons = nullptr; } // 4J Added override @@ -65,7 +65,7 @@ void Sapling::growTree(Level *level, int x, int y, int z, Random *random) { int data = level->getData(x, y, z) & TYPE_MASK; - Feature *f = NULL; + Feature *f = nullptr; int ox = 0, oz = 0; bool multiblock = false; @@ -93,12 +93,12 @@ void Sapling::growTree(Level *level, int x, int y, int z, Random *random) break; } } - if (f != NULL) + if (f != nullptr) { break; } } - if (f == NULL) + if (f == nullptr) { ox = oz = 0; f = new TreeFeature(true, 4 + random->nextInt(7), TreeTile::JUNGLE_TRUNK, LeafTile::JUNGLE_LEAF, false); @@ -138,7 +138,7 @@ void Sapling::growTree(Level *level, int x, int y, int z, Random *random) level->setTileAndData(x, y, z, id, data, Tile::UPDATE_NONE); } } - if( f != NULL ) + if( f != nullptr ) delete f; } diff --git a/Minecraft.World/SavedDataStorage.cpp b/Minecraft.World/SavedDataStorage.cpp index 422b66dca..d882b2053 100644 --- a/Minecraft.World/SavedDataStorage.cpp +++ b/Minecraft.World/SavedDataStorage.cpp @@ -26,7 +26,7 @@ shared_ptr SavedDataStorage::get(const type_info& clazz, const wstrin if (it != cache.end()) return (*it).second; shared_ptr data = nullptr; - if (levelStorage != NULL) + if (levelStorage != nullptr) { //File file = levelStorage->getDataFile(id); ConsoleSavePath file = levelStorage->getDataFile(id); @@ -61,7 +61,7 @@ shared_ptr SavedDataStorage::get(const type_info& clazz, const wstrin } } - if (data != NULL) + if (data != nullptr) { cache.insert( unordered_map >::value_type( id , data ) ); savedDatas.push_back(data); @@ -71,7 +71,7 @@ shared_ptr SavedDataStorage::get(const type_info& clazz, const wstrin void SavedDataStorage::set(const wstring& id, shared_ptr data) { - if (data == NULL) + if (data == nullptr) { // TODO 4J Stu - throw new RuntimeException("Can't set null data"); assert( false ); @@ -104,7 +104,7 @@ void SavedDataStorage::save() void SavedDataStorage::save(shared_ptr data) { - if (levelStorage == NULL) return; + if (levelStorage == nullptr) return; //File file = levelStorage->getDataFile(data->id); ConsoleSavePath file = levelStorage->getDataFile(data->id); if (!file.getName().empty()) @@ -127,7 +127,7 @@ void SavedDataStorage::loadAuxValues() { usedAuxIds.clear(); - if (levelStorage == NULL) return; + if (levelStorage == nullptr) return; //File file = levelStorage->getDataFile(L"idcounts"); ConsoleSavePath file = levelStorage->getDataFile(L"idcounts"); if (!file.getName().empty() && levelStorage->getSaveFile()->doesFileExist( file ) ) @@ -163,7 +163,7 @@ int SavedDataStorage::getFreeAuxValueFor(const wstring& id) } usedAuxIds[id] = val; - if (levelStorage == NULL) return val; + if (levelStorage == nullptr) return val; //File file = levelStorage->getDataFile(L"idcounts"); ConsoleSavePath file = levelStorage->getDataFile(L"idcounts"); if (!file.getName().empty()) @@ -188,7 +188,7 @@ int SavedDataStorage::getFreeAuxValueFor(const wstring& id) // 4J Added int SavedDataStorage::getAuxValueForMap(PlayerUID xuid, int dimension, int centreXC, int centreZC, int scale) { - if( levelStorage == NULL ) + if( levelStorage == nullptr ) { switch(dimension) { diff --git a/Minecraft.World/ScatteredFeaturePieces.cpp b/Minecraft.World/ScatteredFeaturePieces.cpp index 317d6d9ef..a623f9727 100644 --- a/Minecraft.World/ScatteredFeaturePieces.cpp +++ b/Minecraft.World/ScatteredFeaturePieces.cpp @@ -35,7 +35,7 @@ ScatteredFeaturePieces::ScatteredFeaturePiece::ScatteredFeaturePiece(Random *ran orientation = random->nextInt(4); LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); - if( levelGenOptions != NULL ) + if( levelGenOptions != nullptr ) { int tempOrientation = 0; if(levelGenOptions->isFeatureChunk(west>>4,north>>4,StructureFeature::eFeature_Temples, &tempOrientation) ) @@ -739,7 +739,7 @@ bool ScatteredFeaturePieces::SwamplandHut::postProcess(Level *level, Random *ran shared_ptr witch = shared_ptr( new Witch(level) ); witch->moveTo(wx + .5, wy, wz + .5, 0, 0); - witch->finalizeMobSpawn(NULL); + witch->finalizeMobSpawn(nullptr); level->addEntity(witch); } } diff --git a/Minecraft.World/Scoreboard.cpp b/Minecraft.World/Scoreboard.cpp index 5c6f2ebd7..bab0b213e 100644 --- a/Minecraft.World/Scoreboard.cpp +++ b/Minecraft.World/Scoreboard.cpp @@ -4,15 +4,15 @@ Objective *Scoreboard::getObjective(const wstring &name) { - return NULL; + return nullptr; //return objectivesByName.find(name)->second; } Objective *Scoreboard::addObjective(const wstring &name, ObjectiveCriteria *criteria) { - return NULL; + return nullptr; // Objective *objective = getObjective(name); -// if (objective != NULL) +// if (objective != nullptr) // { //#indef _CONTENT_PACKAGE // __debugbreak(); @@ -24,7 +24,7 @@ Objective *Scoreboard::addObjective(const wstring &name, ObjectiveCriteria *crit // // vector *criteriaList = objectivesByCriteria.find(criteria)->second; // -// if (criteriaList == NULL) +// if (criteriaList == nullptr) // { // criteriaList = new vector(); // objectivesByCriteria[criteria] = criteriaList; @@ -39,18 +39,18 @@ Objective *Scoreboard::addObjective(const wstring &name, ObjectiveCriteria *crit vector *Scoreboard::findObjectiveFor(ObjectiveCriteria *criteria) { - return NULL; + return nullptr; //vector *objectives = objectivesByCriteria.find(criteria)->second; - //return objectives == NULL ? new vector() : new vector(objectives); + //return objectives == nullptr ? new vector() : new vector(objectives); } Score *Scoreboard::getPlayerScore(const wstring &name, Objective *objective) { - return NULL; + return nullptr; //unordered_map *scores = playerScores.find(name)->it; - //if (scores == NULL) + //if (scores == nullptr) //{ // scores = new unordered_map(); // playerScores.put(name, scores); @@ -58,7 +58,7 @@ Score *Scoreboard::getPlayerScore(const wstring &name, Objective *objective) //Score *score = scores->get(objective); - //if (score == NULL) + //if (score == nullptr) //{ // score = new Score(this, objective, name); // scores->put(objective, score); @@ -69,7 +69,7 @@ Score *Scoreboard::getPlayerScore(const wstring &name, Objective *objective) vector *Scoreboard::getPlayerScores(Objective *objective) { - return NULL; + return nullptr; //vector *result = new vector(); //for (Map scores : playerScores.values()) @@ -85,13 +85,13 @@ vector *Scoreboard::getPlayerScores(Objective *objective) vector *Scoreboard::getObjectives() { - return NULL; + return nullptr; //return objectivesByName.values(); } vector *Scoreboard::getTrackedPlayers() { - return NULL; + return nullptr; //return playerScores.keySet(); } @@ -99,7 +99,7 @@ void Scoreboard::resetPlayerScore(const wstring &player) { //unordered_map *removed = playerScores.remove(player); - //if (removed != NULL) + //if (removed != nullptr) //{ // onPlayerRemoved(player); //} @@ -107,7 +107,7 @@ void Scoreboard::resetPlayerScore(const wstring &player) vector *Scoreboard::getScores() { - return NULL; + return nullptr; //Collection> values = playerScores.values(); //List result = new ArrayList(); @@ -121,7 +121,7 @@ vector *Scoreboard::getScores() vector *Scoreboard::getScores(Objective *objective) { - return NULL; + return nullptr; //Collection> values = playerScores.values(); //List result = new ArrayList(); @@ -135,7 +135,7 @@ vector *Scoreboard::getScores(Objective *objective) unordered_map *Scoreboard::getPlayerScores(const wstring &player) { - return NULL; + return nullptr; //Map result = playerScores.get(player); //if (result == null) result = new HashMap(); //return result; @@ -166,19 +166,19 @@ void Scoreboard::setDisplayObjective(int slot, Objective *objective) Objective *Scoreboard::getDisplayObjective(int slot) { - return NULL; + return nullptr; //return displayObjectives[slot]; } PlayerTeam *Scoreboard::getPlayerTeam(const wstring &name) { - return NULL; + return nullptr; //return teamsByName.get(name); } PlayerTeam *Scoreboard::addPlayerTeam(const wstring &name) { - return NULL; + return nullptr; //PlayerTeam team = getPlayerTeam(name); //if (team != null) throw new IllegalArgumentException("An objective with the name '" + name + "' already exists!"); @@ -237,13 +237,13 @@ void Scoreboard::removePlayerFromTeam(const wstring &player, PlayerTeam *team) vector *Scoreboard::getTeamNames() { - return NULL; + return nullptr; //return teamsByName.keySet(); } vector *Scoreboard::getPlayerTeams() { - return NULL; + return nullptr; //return teamsByName.values(); } @@ -255,7 +255,7 @@ shared_ptr Scoreboard::getPlayer(const wstring &name) PlayerTeam *Scoreboard::getPlayersTeam(const wstring &name) { - return NULL; + return nullptr; //return teamsByPlayer.get(name); } diff --git a/Minecraft.World/ServersideAttributeMap.cpp b/Minecraft.World/ServersideAttributeMap.cpp index 901854cca..5da807123 100644 --- a/Minecraft.World/ServersideAttributeMap.cpp +++ b/Minecraft.World/ServersideAttributeMap.cpp @@ -17,7 +17,7 @@ AttributeInstance *ServersideAttributeMap::getInstance(eATTRIBUTE_ID id) // 4J: Removed legacy name // If we didn't find it, search by legacy name - /*if (result == NULL) + /*if (result == nullptr) { auto it = attributesByLegacy.find(name); if(it != attributesByLegacy.end()) @@ -43,7 +43,7 @@ AttributeInstance *ServersideAttributeMap::registerAttribute(Attribute *attribut // 4J: Removed legacy name // If this is a ranged attribute also add to legacy name map /*RangedAttribute *rangedAttribute = dynamic_cast(attribute); - if (rangedAttribute != NULL && rangedAttribute->getImportLegacyName() != L"") + if (rangedAttribute != nullptr && rangedAttribute->getImportLegacyName() != L"") { attributesByLegacy.insert(std::pair(rangedAttribute->getImportLegacyName(), instance)); }*/ diff --git a/Minecraft.World/SetDisplayObjectivePacket.cpp b/Minecraft.World/SetDisplayObjectivePacket.cpp index f1cffa4b2..9908d15ec 100644 --- a/Minecraft.World/SetDisplayObjectivePacket.cpp +++ b/Minecraft.World/SetDisplayObjectivePacket.cpp @@ -13,7 +13,7 @@ SetDisplayObjectivePacket::SetDisplayObjectivePacket(int slot, Objective *object { this->slot = slot; - if (objective == NULL) + if (objective == nullptr) { objectiveName = L""; } diff --git a/Minecraft.World/SetEntityDataPacket.cpp b/Minecraft.World/SetEntityDataPacket.cpp index 9947c1630..a49ba9d90 100644 --- a/Minecraft.World/SetEntityDataPacket.cpp +++ b/Minecraft.World/SetEntityDataPacket.cpp @@ -10,7 +10,7 @@ SetEntityDataPacket::SetEntityDataPacket() { id = -1; - packedItems = NULL; + packedItems = nullptr; } SetEntityDataPacket::~SetEntityDataPacket() diff --git a/Minecraft.World/SetEntityLinkPacket.cpp b/Minecraft.World/SetEntityLinkPacket.cpp index cae35e485..3ad0f45b9 100644 --- a/Minecraft.World/SetEntityLinkPacket.cpp +++ b/Minecraft.World/SetEntityLinkPacket.cpp @@ -18,7 +18,7 @@ SetEntityLinkPacket::SetEntityLinkPacket(int linkType, shared_ptr source { type = linkType; this->sourceId = sourceEntity->entityId; - this->destId = destEntity != NULL ? destEntity->entityId : -1; + this->destId = destEntity != nullptr ? destEntity->entityId : -1; } int SetEntityLinkPacket::getEstimatedSize() diff --git a/Minecraft.World/SetEquippedItemPacket.cpp b/Minecraft.World/SetEquippedItemPacket.cpp index 1da93b840..ac9d22b26 100644 --- a/Minecraft.World/SetEquippedItemPacket.cpp +++ b/Minecraft.World/SetEquippedItemPacket.cpp @@ -20,7 +20,7 @@ SetEquippedItemPacket::SetEquippedItemPacket(int entity, int slot, shared_ptrslot = slot; // 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game - this->item = item == NULL ? nullptr : item->copy(); + this->item = item == nullptr ? nullptr : item->copy(); } void SetEquippedItemPacket::read(DataInputStream *dis) //throws IOException diff --git a/Minecraft.World/SetPlayerTeamPacket.cpp b/Minecraft.World/SetPlayerTeamPacket.cpp index fe36bfff5..a574067dd 100644 --- a/Minecraft.World/SetPlayerTeamPacket.cpp +++ b/Minecraft.World/SetPlayerTeamPacket.cpp @@ -42,7 +42,7 @@ SetPlayerTeamPacket::SetPlayerTeamPacket(PlayerTeam *team, vector *play __debugbreak(); #endif } - if (playerNames == NULL || playerNames->empty()) + if (playerNames == nullptr || playerNames->empty()) { app.DebugPrintf("Players cannot be null/empty"); #ifndef _CONTENT_PACKAGE diff --git a/Minecraft.World/ShapedRecipy.cpp b/Minecraft.World/ShapedRecipy.cpp index be1adb0b7..ac3c82ad6 100644 --- a/Minecraft.World/ShapedRecipy.cpp +++ b/Minecraft.World/ShapedRecipy.cpp @@ -52,18 +52,18 @@ bool ShapedRecipy::matches(shared_ptr craftSlots, int xOffs, for (int y = 0; y < 3; y++) { int xs = x - xOffs; int ys = y - yOffs; - ItemInstance *expected = NULL; + ItemInstance *expected = nullptr; if (xs >= 0 && ys >= 0 && xs < width && ys < height) { if (xFlip) expected = recipeItems[(width - xs - 1) + ys * width]; else expected = recipeItems[xs + ys * width]; } shared_ptr item = craftSlots->getItem(x, y); - if (item == NULL && expected == NULL) + if (item == nullptr && expected == nullptr) { continue; } - if ((item == NULL && expected != NULL) || (item != NULL && expected == NULL)) + if ((item == nullptr && expected != nullptr) || (item != nullptr && expected == nullptr)) { return false; } @@ -84,13 +84,13 @@ shared_ptr ShapedRecipy::assemble(shared_ptr cr { shared_ptr result = getResultItem()->copy(); - if (_keepTag && craftSlots != NULL) + if (_keepTag && craftSlots != nullptr) { for (int i = 0; i < craftSlots->getContainerSize(); i++) { shared_ptr item = craftSlots->getItem(i); - if (item != NULL && item->hasTag()) + if (item != nullptr && item->hasTag()) { result->setTag(static_cast(item->tag->copy())); } @@ -117,7 +117,7 @@ bool ShapedRecipy::requires(int iRecipe) if (x < width && y < height) { ItemInstance *expected = recipeItems[x+y*width]; - if (expected!=NULL) + if (expected!=nullptr) { //printf("\tIngredient %d is %d\n",iCount++,expected->id); } @@ -159,7 +159,7 @@ void ShapedRecipy::requires(INGREDIENTS_REQUIRED *pIngReq) { ItemInstance *expected = recipeItems[x+y*width]; - if (expected!=NULL) + if (expected!=nullptr) { int iAuxVal = expected->getAuxValue(); TempIngReq.uiGridA[x+y*3]=expected->id | iAuxVal<<24; diff --git a/Minecraft.World/SharedMonsterAttributes.cpp b/Minecraft.World/SharedMonsterAttributes.cpp index 12d467f2f..53c050083 100644 --- a/Minecraft.World/SharedMonsterAttributes.cpp +++ b/Minecraft.World/SharedMonsterAttributes.cpp @@ -70,7 +70,7 @@ void SharedMonsterAttributes::loadAttributes(BaseAttributeMap *attributes, ListT CompoundTag *tag = list->get(i); AttributeInstance *instance = attributes->getInstance(static_cast(tag->getInt(L"ID"))); - if (instance != NULL) + if (instance != nullptr) { loadAttribute(instance, tag); } @@ -93,7 +93,7 @@ void SharedMonsterAttributes::loadAttribute(AttributeInstance *instance, Compoun { AttributeModifier *modifier = loadAttributeModifier(list->get(i)); AttributeModifier *old = instance->getModifier(modifier->getId()); - if (old != NULL) instance->removeModifier(old); + if (old != nullptr) instance->removeModifier(old); instance->addModifier(modifier); } } diff --git a/Minecraft.World/Sheep.cpp b/Minecraft.World/Sheep.cpp index e865d899a..7343e29c0 100644 --- a/Minecraft.World/Sheep.cpp +++ b/Minecraft.World/Sheep.cpp @@ -169,7 +169,7 @@ bool Sheep::mobInteract(shared_ptr player) if (!player->isAllowedToInteract( shared_from_this() )) return false; //Animal::interact(player); - if (item != NULL && item->id == Item::shears->id && !isSheared() && !isBaby()) + if (item != nullptr && item->id == Item::shears->id && !isSheared() && !isBaby()) { if (!level->isClientSide) { @@ -324,7 +324,7 @@ int Sheep::getOffspringColor(shared_ptr animal, shared_ptr partn shared_ptr instance = Recipes::getInstance()->getItemFor(container, animal->level); int color = 0; - if (instance != NULL && instance->getItem()->id == Item::dye_powder_Id) + if (instance != nullptr && instance->getItem()->id == Item::dye_powder_Id) { color = instance->getAuxValue(); } diff --git a/Minecraft.World/ShovelItem.cpp b/Minecraft.World/ShovelItem.cpp index 8064cbe31..4b75cd852 100644 --- a/Minecraft.World/ShovelItem.cpp +++ b/Minecraft.World/ShovelItem.cpp @@ -3,7 +3,7 @@ #include "net.minecraft.world.level.tile.h" #include "ShovelItem.h" -TileArray *ShovelItem::diggables = NULL; +TileArray *ShovelItem::diggables = nullptr; void ShovelItem::staticCtor() { diff --git a/Minecraft.World/SignItem.cpp b/Minecraft.World/SignItem.cpp index c9cb627e6..a418fd347 100644 --- a/Minecraft.World/SignItem.cpp +++ b/Minecraft.World/SignItem.cpp @@ -49,7 +49,7 @@ bool SignItem::useOn(shared_ptr instance, shared_ptr playe instance->count--; shared_ptr ste = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (ste != NULL) player->openTextEdit(ste); + if (ste != nullptr) player->openTextEdit(ste); // 4J-JEV: Hook for durango 'BlockPlaced' event. player->awardStat( diff --git a/Minecraft.World/SignTile.cpp b/Minecraft.World/SignTile.cpp index 52d62a60c..1f8c6e948 100644 --- a/Minecraft.World/SignTile.cpp +++ b/Minecraft.World/SignTile.cpp @@ -26,7 +26,7 @@ void SignTile::updateDefaultShape() AABB *SignTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } AABB *SignTile::getTileAABB(Level *level, int x, int y, int z) diff --git a/Minecraft.World/Silverfish.cpp b/Minecraft.World/Silverfish.cpp index 5cd4c77ee..98f559c92 100644 --- a/Minecraft.World/Silverfish.cpp +++ b/Minecraft.World/Silverfish.cpp @@ -72,7 +72,7 @@ int Silverfish::getDeathSound() bool Silverfish::hurt(DamageSource *source, float dmg) { if (isInvulnerable()) return false; - if (lookForFriends <= 0 && (dynamic_cast(source) != NULL || source == DamageSource::magic)) + if (lookForFriends <= 0 && (dynamic_cast(source) != nullptr || source == DamageSource::magic)) { // look for friends lookForFriends = 20; @@ -173,7 +173,7 @@ void Silverfish::serverAiStep() } } - if (attackTarget == NULL && !isPathFinding()) + if (attackTarget == nullptr && !isPathFinding()) { // if the silverfish isn't doing anything special, it will merge // with any rock tile it is nearby @@ -193,7 +193,7 @@ void Silverfish::serverAiStep() } } - else if (attackTarget != NULL && !isPathFinding()) + else if (attackTarget != nullptr && !isPathFinding()) { attackTarget = nullptr; } @@ -216,7 +216,7 @@ bool Silverfish::canSpawn() if (Monster::canSpawn()) { shared_ptr nearestPlayer = level->getNearestPlayer(shared_from_this(), 5.0); - return nearestPlayer == NULL; + return nearestPlayer == nullptr; } return false; } diff --git a/Minecraft.World/SimpleContainer.cpp b/Minecraft.World/SimpleContainer.cpp index a5f551e2a..87d11a70d 100644 --- a/Minecraft.World/SimpleContainer.cpp +++ b/Minecraft.World/SimpleContainer.cpp @@ -13,12 +13,12 @@ SimpleContainer::SimpleContainer(int name, wstring stringName, bool customName, this->size = size; items = new ItemInstanceArray( size ); - listeners = NULL; + listeners = nullptr; } void SimpleContainer::addListener(net_minecraft_world::ContainerListener *listener) { - if (listeners == NULL) listeners = new vector(); + if (listeners == nullptr) listeners = new vector(); listeners->push_back(listener); } @@ -43,7 +43,7 @@ shared_ptr SimpleContainer::getItem(unsigned int slot) shared_ptr SimpleContainer::removeItem(unsigned int slot, int count) { - if ((*items)[slot] != NULL) { + if ((*items)[slot] != nullptr) { if ((*items)[slot]->count <= count) { shared_ptr item = (*items)[slot]; @@ -64,7 +64,7 @@ shared_ptr SimpleContainer::removeItem(unsigned int slot, int coun shared_ptr SimpleContainer::removeItemNoUpdate(int slot) { - if ((*items)[slot] != NULL) + if ((*items)[slot] != nullptr) { shared_ptr item = (*items)[slot]; (*items)[slot] = nullptr; @@ -76,7 +76,7 @@ shared_ptr SimpleContainer::removeItemNoUpdate(int slot) void SimpleContainer::setItem(unsigned int slot, shared_ptr item) { (*items)[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); setChanged(); } @@ -113,7 +113,7 @@ int SimpleContainer::getMaxStackSize() const void SimpleContainer::setChanged() { - if (listeners != NULL) for (unsigned int i = 0; i < listeners->size(); i++) + if (listeners != nullptr) for (unsigned int i = 0; i < listeners->size(); i++) { listeners->at(i)->containerChanged();//shared_from_this()); } diff --git a/Minecraft.World/SitGoal.cpp b/Minecraft.World/SitGoal.cpp index b79b2df7e..7b04a5f6c 100644 --- a/Minecraft.World/SitGoal.cpp +++ b/Minecraft.World/SitGoal.cpp @@ -21,9 +21,9 @@ bool SitGoal::canUse() if (!mob->onGround) return false; shared_ptr owner = dynamic_pointer_cast( mob->getOwner() ); - if (owner == NULL) return true; // owner not on level + if (owner == nullptr) return true; // owner not on level - if (mob->distanceToSqr(owner) < FollowOwnerGoal::TeleportDistance * FollowOwnerGoal::TeleportDistance && owner->getLastHurtByMob() != NULL) return false; + if (mob->distanceToSqr(owner) < FollowOwnerGoal::TeleportDistance * FollowOwnerGoal::TeleportDistance && owner->getLastHurtByMob() != nullptr) return false; return _wantToSit; } diff --git a/Minecraft.World/Skeleton.cpp b/Minecraft.World/Skeleton.cpp index e7db69430..d5f59dfe0 100644 --- a/Minecraft.World/Skeleton.cpp +++ b/Minecraft.World/Skeleton.cpp @@ -43,7 +43,7 @@ Skeleton::Skeleton(Level *level) : Monster( level ) targetSelector.addGoal(1, new HurtByTargetGoal(this, false)); targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, typeid(Player), 0, true)); - if (level != NULL && !level->isClientSide) reassessWeaponGoal(); + if (level != nullptr && !level->isClientSide) reassessWeaponGoal(); } Skeleton::~Skeleton() @@ -119,7 +119,7 @@ void Skeleton::aiStep() bool burn = true; shared_ptr helmet = getCarried(SLOT_HELM); - if (helmet != NULL) + if (helmet != nullptr) { if (helmet->isDamageableItem()) { @@ -155,7 +155,7 @@ void Skeleton::rideTick() { Monster::rideTick(); - if ( riding != NULL && riding->instanceof(eTYPE_PATHFINDER_MOB) ) + if ( riding != nullptr && riding->instanceof(eTYPE_PATHFINDER_MOB) ) { yBodyRot = dynamic_pointer_cast(riding)->yBodyRot; } @@ -166,7 +166,7 @@ void Skeleton::die(DamageSource *source) { Monster::die(source); - if ( source->getDirectEntity() != NULL && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) ) + if ( source->getDirectEntity() != nullptr && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) ) { shared_ptr player = dynamic_pointer_cast( source->getEntity() ); @@ -232,7 +232,7 @@ MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData { groupData = Monster::finalizeMobSpawn(groupData); - if ( dynamic_cast(level->dimension) != NULL && getRandom()->nextInt(5) > 0) + if ( dynamic_cast(level->dimension) != nullptr && getRandom()->nextInt(5) > 0) { goalSelector.addGoal(4, meleeGoal, false); @@ -250,7 +250,7 @@ MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData setCanPickUpLoot(random->nextFloat() < MAX_PICKUP_LOOT_CHANCE * level->getDifficulty(x, y, z)); - if (getCarried(SLOT_HELM) == NULL) + if (getCarried(SLOT_HELM) == nullptr) { if (Calendar::GetMonth() + 1 == 10 && Calendar::GetDayOfMonth() == 31 && random->nextFloat() < 0.25f) { @@ -269,7 +269,7 @@ void Skeleton::reassessWeaponGoal() shared_ptr carried = getCarriedItem(); - if (carried != NULL && carried->id == Item::bow_Id) + if (carried != nullptr && carried->id == Item::bow_Id) { goalSelector.addGoal(4, bowGoal, false); } diff --git a/Minecraft.World/SkullItem.cpp b/Minecraft.World/SkullItem.cpp index f0356a965..383f226f4 100644 --- a/Minecraft.World/SkullItem.cpp +++ b/Minecraft.World/SkullItem.cpp @@ -48,7 +48,7 @@ bool SkullItem::useOn(shared_ptr instance, shared_ptr play shared_ptr skullTE = level->getTileEntity(x, y, z); shared_ptr skull = dynamic_pointer_cast(skullTE); - if (skull != NULL) + if (skull != nullptr) { wstring extra = L""; if (instance->hasTag() && instance->getTag()->contains(L"SkullOwner")) diff --git a/Minecraft.World/SkullTile.cpp b/Minecraft.World/SkullTile.cpp index 92ce78070..28699645d 100644 --- a/Minecraft.World/SkullTile.cpp +++ b/Minecraft.World/SkullTile.cpp @@ -79,7 +79,7 @@ int SkullTile::cloneTileData(Level *level, int x, int y, int z) { shared_ptr tileEntity = level->getTileEntity(x, y, z); shared_ptr skull = dynamic_pointer_cast(tileEntity); - if (skull != NULL) + if (skull != nullptr) { return skull->getSkullType(); } @@ -274,7 +274,7 @@ bool SkullTile::isSkullAt(Level *level, int x, int y, int z, int skullType) } shared_ptr te = level->getTileEntity(x, y, z); shared_ptr skull = dynamic_pointer_cast(te); - if (skull == NULL) + if (skull == nullptr) { return false; } diff --git a/Minecraft.World/SkyIslandDimension.cpp b/Minecraft.World/SkyIslandDimension.cpp index 0746c92ca..01df4306b 100644 --- a/Minecraft.World/SkyIslandDimension.cpp +++ b/Minecraft.World/SkyIslandDimension.cpp @@ -23,7 +23,7 @@ float SkyIslandDimension::getTimeOfDay(__int64 time, float a) const float *SkyIslandDimension::getSunriseColor(float td, float a) { - return NULL; + return nullptr; } Vec3 *SkyIslandDimension::getFogColor(float td, float a) const diff --git a/Minecraft.World/Slime.cpp b/Minecraft.World/Slime.cpp index 5f93dbfb2..aefb8ae29 100644 --- a/Minecraft.World/Slime.cpp +++ b/Minecraft.World/Slime.cpp @@ -135,14 +135,14 @@ void Slime::serverAiStep() { checkDespawn(); shared_ptr player = level->getNearestAttackablePlayer(shared_from_this(), 16); - if (player != NULL) + if (player != nullptr) { lookAt(player, 10, 20); } if (onGround && jumpDelay-- <= 0) { jumpDelay = getJumpDelay(); - if (player != NULL) + if (player != nullptr) { jumpDelay /= 3; } diff --git a/Minecraft.World/Slot.cpp b/Minecraft.World/Slot.cpp index a5a53a481..91920b2de 100644 --- a/Minecraft.World/Slot.cpp +++ b/Minecraft.World/Slot.cpp @@ -15,7 +15,7 @@ Slot::Slot(shared_ptr container, int slot, int x, int y) : container( void Slot::onQuickCraft(shared_ptr picked, shared_ptr original) { - if (picked == NULL || original == NULL) + if (picked == nullptr || original == nullptr) { return; } @@ -44,14 +44,14 @@ void Slot::swap(Slot *other) shared_ptr item1 = container->getItem(slot); shared_ptr item2 = other->container->getItem(other->slot); - if (item1 != NULL && item1->count > other->getMaxStackSize()) + if (item1 != nullptr && item1->count > other->getMaxStackSize()) { - if (item2 != NULL) return; + if (item2 != nullptr) return; item2 = item1->remove(item1->count - other->getMaxStackSize()); } - if (item2 != NULL && item2->count > getMaxStackSize()) + if (item2 != nullptr && item2->count > getMaxStackSize()) { - if (item1 != NULL) return; + if (item1 != nullptr) return; item1 = item2->remove(item2->count - getMaxStackSize()); } other->container->setItem(other->slot, item1); @@ -77,7 +77,7 @@ shared_ptr Slot::getItem() bool Slot::hasItem() { - return getItem() != NULL; + return getItem() != nullptr; } void Slot::set(shared_ptr item) @@ -98,7 +98,7 @@ int Slot::getMaxStackSize() const Icon *Slot::getNoItemIcon() { - return NULL; + return nullptr; } shared_ptr Slot::remove(int c) @@ -125,7 +125,7 @@ bool Slot::mayCombine(shared_ptr second) { shared_ptr first = getItem(); - if(first == NULL || second == NULL) return false; + if(first == nullptr || second == nullptr) return false; ArmorItem *thisItem = dynamic_cast(first->getItem()); if(thisItem) @@ -135,7 +135,7 @@ bool Slot::mayCombine(shared_ptr second) return thisIsDyableArmor && itemIsDye; } // 4J Stu - This condition taken from Recipes::getItemFor to repair items, but added the damaged check to skip when the result is pointless - else if (first != NULL && second != NULL && first->id == second->id && first->count == 1 && second->count == 1 && Item::items[first->id]->canBeDepleted() && (first->isDamaged() || second->isDamaged()) ) + else if (first != nullptr && second != nullptr && first->id == second->id && first->count == 1 && second->count == 1 && Item::items[first->id]->canBeDepleted() && (first->isDamaged() || second->isDamaged()) ) { // 4J Stu - Don't allow combinining enchanted items, the enchantment will be lost. They can use the anvil for this return !first->isEnchanted() && !second->isEnchanted(); @@ -148,7 +148,7 @@ shared_ptr Slot::combine(shared_ptr item) shared_ptr result = nullptr; shared_ptr first = getItem(); - shared_ptr craftSlots = shared_ptr( new CraftingContainer(NULL, 2, 2) ); + shared_ptr craftSlots = shared_ptr( new CraftingContainer(nullptr, 2, 2) ); craftSlots->setItem(0, item); craftSlots->setItem(1, first); @@ -159,7 +159,7 @@ shared_ptr Slot::combine(shared_ptr item) } else { - result = Recipes::getInstance()->getItemFor(craftSlots, NULL); + result = Recipes::getInstance()->getItemFor(craftSlots, nullptr); } craftSlots->setItem(0, nullptr); diff --git a/Minecraft.World/SmallFireball.cpp b/Minecraft.World/SmallFireball.cpp index 30f7a0b2b..2475f5dcf 100644 --- a/Minecraft.World/SmallFireball.cpp +++ b/Minecraft.World/SmallFireball.cpp @@ -25,7 +25,7 @@ void SmallFireball::onHit(HitResult *res) { if (!level->isClientSide) { - if (res->entity != NULL) + if (res->entity != nullptr) { DamageSource *damageSource = DamageSource::fireball(dynamic_pointer_cast(shared_from_this()),owner); if (!res->entity->isFireImmune() && res->entity->hurt(damageSource, 5)) diff --git a/Minecraft.World/SmoothStoneBrickTile.cpp b/Minecraft.World/SmoothStoneBrickTile.cpp index 22fb6df5c..a42af97be 100644 --- a/Minecraft.World/SmoothStoneBrickTile.cpp +++ b/Minecraft.World/SmoothStoneBrickTile.cpp @@ -12,7 +12,7 @@ const unsigned int SmoothStoneBrickTile::SMOOTH_STONE_BRICK_NAMES[SMOOTH_STONE_B SmoothStoneBrickTile::SmoothStoneBrickTile(int id) : Tile(id, Material::stone) { - icons = NULL; + icons = nullptr; } Icon *SmoothStoneBrickTile::getTexture(int face, int data) diff --git a/Minecraft.World/Snowball.cpp b/Minecraft.World/Snowball.cpp index 6588ac966..bb873b205 100644 --- a/Minecraft.World/Snowball.cpp +++ b/Minecraft.World/Snowball.cpp @@ -31,7 +31,7 @@ Snowball::Snowball(Level *level, double x, double y, double z) : Throwable(level void Snowball::onHit(HitResult *res) { - if (res->entity != NULL) + if (res->entity != nullptr) { int damage = 0; if ( res->entity->instanceof(eTYPE_BLAZE) ) diff --git a/Minecraft.World/Socket.cpp b/Minecraft.World/Socket.cpp index 1a7d27caa..290b39dca 100644 --- a/Minecraft.World/Socket.cpp +++ b/Minecraft.World/Socket.cpp @@ -14,7 +14,7 @@ CRITICAL_SECTION Socket::s_hostQueueLock[2]; std::queue Socket::s_hostQueue[2]; Socket::SocketOutputStreamLocal *Socket::s_hostOutStream[2]; Socket::SocketInputStreamLocal *Socket::s_hostInStream[2]; -ServerConnection *Socket::s_serverConnection = NULL; +ServerConnection *Socket::s_serverConnection = nullptr; void Socket::Initialise(ServerConnection *serverConnection) { @@ -67,7 +67,7 @@ Socket::Socket(bool response) { m_endClosed[i] = false; } - m_socketClosedEvent = NULL; + m_socketClosedEvent = nullptr; createdOk = true; networkPlayerSmallId = g_NetworkManager.GetHostPlayer()->GetSmallId(); } @@ -80,8 +80,8 @@ Socket::Socket(INetworkPlayer *player, bool response /* = false*/, bool hostLoca for( int i = 0; i < 2; i++ ) { InitializeCriticalSection(&m_queueLockNetwork[i]); - m_inputStream[i] = NULL; - m_outputStream[i] = NULL; + m_inputStream[i] = nullptr; + m_outputStream[i] = nullptr; m_endClosed[i] = false; } @@ -105,7 +105,7 @@ Socket::Socket(INetworkPlayer *player, bool response /* = false*/, bool hostLoca SocketAddress *Socket::getRemoteSocketAddress() { - return NULL; + return nullptr; } INetworkPlayer *Socket::getPlayer() @@ -115,7 +115,7 @@ INetworkPlayer *Socket::getPlayer() void Socket::setPlayer(INetworkPlayer *player) { - if(player!=NULL) + if(player!=nullptr) { networkPlayerSmallId = player->GetSmallId(); } @@ -147,7 +147,7 @@ void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHos void Socket::addIncomingSocket(Socket *socket) { - if( s_serverConnection != NULL ) + if( s_serverConnection != nullptr ) { s_serverConnection->NewIncomingSocket(socket); } @@ -240,7 +240,7 @@ bool Socket::close(bool isServerConnection) allClosed = true; m_endClosed[m_end] = true; } - if( allClosed && m_socketClosedEvent != NULL ) + if( allClosed && m_socketClosedEvent != nullptr ) { m_socketClosedEvent->Set(); } @@ -488,15 +488,15 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, unsigned int buffer.dwDataSize = length; INetworkPlayer *hostPlayer = g_NetworkManager.GetHostPlayer(); - if(hostPlayer == NULL) + if(hostPlayer == nullptr) { - app.DebugPrintf("Trying to write to network, but the hostPlayer is NULL\n"); + app.DebugPrintf("Trying to write to network, but the hostPlayer is nullptr\n"); return; } INetworkPlayer *socketPlayer = m_socket->getPlayer(); - if(socketPlayer == NULL) + if(socketPlayer == nullptr) { - app.DebugPrintf("Trying to write to network, but the socketPlayer is NULL\n"); + app.DebugPrintf("Trying to write to network, but the socketPlayer is nullptr\n"); return; } @@ -517,7 +517,7 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, unsigned int hostPlayer->SendData(socketPlayer, buffer.pbyData, buffer.dwDataSize, lowPriority, requireAck); - // DWORD queueSize = hostPlayer->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES ); + // DWORD queueSize = hostPlayer->GetSendQueueSize( nullptr, QNET_GETSENDQUEUESIZE_BYTES ); // if( queueSize > 24000 ) // { // //printf("Queue size is: %d, forcing doWork()\n",queueSize); diff --git a/Minecraft.World/SparseDataStorage.cpp b/Minecraft.World/SparseDataStorage.cpp index 15cd33acd..a499e8331 100644 --- a/Minecraft.World/SparseDataStorage.cpp +++ b/Minecraft.World/SparseDataStorage.cpp @@ -451,7 +451,7 @@ void SparseDataStorage::tick() int freeIndex = ( deleteQueueIndex + 1 ) % 3; // printf("Free queue: %d, %d\n",deleteQueue[freeIndex].GetEntryCount(),deleteQueue[freeIndex].GetAllocated()); - unsigned char *toFree = NULL; + unsigned char *toFree = nullptr; do { toFree = deleteQueue[freeIndex].Pop(); diff --git a/Minecraft.World/SparseLightStorage.cpp b/Minecraft.World/SparseLightStorage.cpp index f0dc9f7ce..5d3288c53 100644 --- a/Minecraft.World/SparseLightStorage.cpp +++ b/Minecraft.World/SparseLightStorage.cpp @@ -457,7 +457,7 @@ void SparseLightStorage::tick() int freeIndex = ( deleteQueueIndex + 1 ) % 3; // printf("Free queue: %d, %d\n",deleteQueue[freeIndex].GetEntryCount(),deleteQueue[freeIndex].GetAllocated()); - unsigned char *toFree = NULL; + unsigned char *toFree = nullptr; do { toFree = deleteQueue[freeIndex].Pop(); diff --git a/Minecraft.World/SpawnEggItem.cpp b/Minecraft.World/SpawnEggItem.cpp index 9c0591262..5124f668c 100644 --- a/Minecraft.World/SpawnEggItem.cpp +++ b/Minecraft.World/SpawnEggItem.cpp @@ -16,7 +16,7 @@ SpawnEggItem::SpawnEggItem(int id) : Item(id) { setMaxStackSize(16); // 4J-PB brought forward. It is 64 on PC, but we'll never be able to place that many setStackedByData(true); - overlay = NULL; + overlay = nullptr; } wstring SpawnEggItem::getHoverName(shared_ptr itemInstance) @@ -69,7 +69,7 @@ Icon *SpawnEggItem::getLayerIcon(int auxValue, int spriteLayer) shared_ptr SpawnEggItem::canSpawn(int iAuxVal, Level *level, int *piResult) { shared_ptr newEntity = EntityIO::newById(iAuxVal, level); - if (newEntity != NULL) + if (newEntity != nullptr) { bool canSpawn = false; @@ -200,7 +200,7 @@ bool SpawnEggItem::useOn(shared_ptr itemInstance, shared_ptrremoveTile(x,y,z); level->setTileAndData(x,y,z,Tile::mobSpawner_Id, 0, Tile::UPDATE_ALL); shared_ptr mste = dynamic_pointer_cast( level->getTileEntity(x,y,z) ); - if(mste != NULL) + if(mste != nullptr) { mste->setEntityId( EntityIO::getEncodeId(itemInstance->getAuxValue()) ); return true; @@ -213,7 +213,7 @@ bool SpawnEggItem::useOn(shared_ptr itemInstance, shared_ptrgetRenderShape() == Tile::SHAPE_FENCE)) + if (face == Facing::UP && (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE)) { // special case yOff = .5; @@ -224,10 +224,10 @@ bool SpawnEggItem::useOn(shared_ptr itemInstance, shared_ptrinstanceof(eTYPE_MOB) && itemInstance->hasCustomHoverName() ) @@ -252,7 +252,7 @@ shared_ptr SpawnEggItem::use(shared_ptr itemInstance if (level->isClientSide) return itemInstance; HitResult *hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) + if (hr == nullptr) { delete hr; return itemInstance; @@ -275,7 +275,7 @@ shared_ptr SpawnEggItem::use(shared_ptr itemInstance { int iResult=0; shared_ptr result = spawnMobAt(level, itemInstance->getAuxValue(), xt, yt, zt, &iResult); - if (result != NULL) + if (result != nullptr) { // 4J-JEV: SetCustomName is a method for Mob not LivingEntity; so change instanceof to check for Mobs. if ( result->instanceof(eTYPE_MOB) && itemInstance->hasCustomHoverName() ) @@ -317,7 +317,7 @@ shared_ptr SpawnEggItem::spawnMobAt(Level *level, int auxVal, double x, newEntity = canSpawn(mobId, level, piResult); // 4J-JEV: DynCasting to Mob not LivingEntity; so change instanceof to check for Mobs. - if ( newEntity != NULL && newEntity->instanceof(eTYPE_MOB) ) + if ( newEntity != nullptr && newEntity->instanceof(eTYPE_MOB) ) { shared_ptr mob = dynamic_pointer_cast(newEntity); newEntity->moveTo(x, y, z, Mth::wrapDegrees(level->random->nextFloat() * 360), 0); @@ -325,7 +325,7 @@ shared_ptr SpawnEggItem::spawnMobAt(Level *level, int auxVal, double x, mob->yHeadRot = mob->yRot; mob->yBodyRot = mob->yRot; - mob->finalizeMobSpawn(NULL, extraData); + mob->finalizeMobSpawn(nullptr, extraData); level->addEntity(newEntity); mob->playAmbientSound(); } diff --git a/Minecraft.World/Spider.cpp b/Minecraft.World/Spider.cpp index ffce490d8..24d737699 100644 --- a/Minecraft.World/Spider.cpp +++ b/Minecraft.World/Spider.cpp @@ -197,12 +197,12 @@ MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /* { shared_ptr skeleton = shared_ptr( new Skeleton(level) ); skeleton->moveTo(x, y, z, yRot, 0); - skeleton->finalizeMobSpawn(NULL); + skeleton->finalizeMobSpawn(nullptr); level->addEntity(skeleton); skeleton->ride(shared_from_this()); } - if (groupData == NULL) + if (groupData == nullptr) { groupData = new SpiderEffectsGroupData(); @@ -211,10 +211,10 @@ MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /* static_cast(groupData)->setRandomEffect(level->random); } } - if ( dynamic_cast( groupData ) != NULL) + if ( dynamic_cast( groupData ) != nullptr) { int effect = static_cast(groupData)->effectId; - if (effect > 0 && MobEffect::effects[effect] != NULL) + if (effect > 0 && MobEffect::effects[effect] != nullptr) { addEffect(new MobEffectInstance(effect, Integer::MAX_VALUE)); } diff --git a/Minecraft.World/SpringFeature.cpp b/Minecraft.World/SpringFeature.cpp index c6fa5e9f4..fdd1cbef1 100644 --- a/Minecraft.World/SpringFeature.cpp +++ b/Minecraft.World/SpringFeature.cpp @@ -11,7 +11,7 @@ SpringFeature::SpringFeature(int tile) bool SpringFeature::place(Level *level, Random *random, int x, int y, int z) { // 4J Stu Added to stop spring features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x, y, z, x, y, z); diff --git a/Minecraft.World/SpruceFeature.cpp b/Minecraft.World/SpruceFeature.cpp index 39d628cf4..d42e46f38 100644 --- a/Minecraft.World/SpruceFeature.cpp +++ b/Minecraft.World/SpruceFeature.cpp @@ -23,7 +23,7 @@ bool SpruceFeature::place(Level *level, Random *random, int x, int y, int z) } // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x - leafRadius, y - 1, z - leafRadius, x + leafRadius, y + treeHeight, z + leafRadius); diff --git a/Minecraft.World/StairTile.cpp b/Minecraft.World/StairTile.cpp index de2cc865c..094ebf6f0 100644 --- a/Minecraft.World/StairTile.cpp +++ b/Minecraft.World/StairTile.cpp @@ -66,7 +66,7 @@ void StairTile::setBaseShape(LevelSource *level, int x, int y, int z) bool StairTile::isStairs(int id) { StairTile *st = dynamic_cast(Tile::tiles[id]); - return id > 0 && st != NULL; //Tile::tiles[id] instanceof StairTile; + return id > 0 && st != nullptr; //Tile::tiles[id] instanceof StairTile; } bool StairTile::isLockAttached(LevelSource *level, int x, int y, int z, int data) @@ -476,7 +476,7 @@ HitResult *StairTile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 * HitResult *results[8]; for(unsigned int i = 0; i < 8; ++i) { - results[i] = NULL; + results[i] = nullptr; } int data = level->getData(xt, yt, zt); int dir = data & 0x3; @@ -498,16 +498,16 @@ HitResult *StairTile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 * for(unsigned int j = 0; j < DEAD_SPACE_COLUMN_COUNT; ++j) { - results[deadSpaces[j]] = NULL; + results[deadSpaces[j]] = nullptr; } - HitResult *closest = NULL; + HitResult *closest = nullptr; double closestDist = 0; for (unsigned int i = 0; i < 8; ++i) { HitResult *result = results[i]; - if (result != NULL) + if (result != nullptr) { double dist = result->pos->distanceToSqr(b); diff --git a/Minecraft.World/Stats.cpp b/Minecraft.World/Stats.cpp index 3d4020b17..43ff486cf 100644 --- a/Minecraft.World/Stats.cpp +++ b/Minecraft.World/Stats.cpp @@ -27,30 +27,30 @@ vector *Stats::itemsCraftedStats = new vector; vector *Stats::blocksPlacedStats = new vector; #endif -Stat *Stats::walkOneM = NULL; -Stat *Stats::swimOneM = NULL; -Stat *Stats::fallOneM = NULL; -Stat *Stats::climbOneM = NULL; -Stat *Stats::minecartOneM = NULL; -Stat *Stats::boatOneM = NULL; -Stat *Stats::pigOneM = NULL; -Stat *Stats::portalsCreated = NULL; -Stat *Stats::cowsMilked = NULL; -Stat *Stats::netherLavaCollected = NULL; -Stat *Stats::killsZombie = NULL; -Stat *Stats::killsSkeleton = NULL; -Stat *Stats::killsCreeper = NULL; -Stat *Stats::killsSpider = NULL; -Stat *Stats::killsSpiderJockey = NULL; -Stat *Stats::killsZombiePigman = NULL; -Stat *Stats::killsSlime = NULL; -Stat *Stats::killsGhast = NULL; -Stat *Stats::killsNetherZombiePigman = NULL; +Stat *Stats::walkOneM = nullptr; +Stat *Stats::swimOneM = nullptr; +Stat *Stats::fallOneM = nullptr; +Stat *Stats::climbOneM = nullptr; +Stat *Stats::minecartOneM = nullptr; +Stat *Stats::boatOneM = nullptr; +Stat *Stats::pigOneM = nullptr; +Stat *Stats::portalsCreated = nullptr; +Stat *Stats::cowsMilked = nullptr; +Stat *Stats::netherLavaCollected = nullptr; +Stat *Stats::killsZombie = nullptr; +Stat *Stats::killsSkeleton = nullptr; +Stat *Stats::killsCreeper = nullptr; +Stat *Stats::killsSpider = nullptr; +Stat *Stats::killsSpiderJockey = nullptr; +Stat *Stats::killsZombiePigman = nullptr; +Stat *Stats::killsSlime = nullptr; +Stat *Stats::killsGhast = nullptr; +Stat *Stats::killsNetherZombiePigman = nullptr; // 4J : WESTY : Added for new achievements. -Stat *Stats::befriendsWolf = NULL; -Stat *Stats::totalBlocksMined = NULL; -Stat *Stats::timePlayed = NULL; +Stat *Stats::befriendsWolf = nullptr; +Stat *Stats::totalBlocksMined = nullptr; +Stat *Stats::timePlayed = nullptr; StatArray Stats::blocksMined; StatArray Stats::itemsCollected; @@ -62,8 +62,8 @@ StatArray Stats::rainbowCollection; StatArray Stats::biomesVisisted; #endif -Stat *Stats::killsEnderdragon = NULL; // The number of times this player has dealt the killing blow to the Enderdragon -Stat *Stats::completeTheEnd = NULL; // The number of times this player has been present when the Enderdragon has died +Stat *Stats::killsEnderdragon = nullptr; // The number of times this player has dealt the killing blow to the Enderdragon +Stat *Stats::completeTheEnd = nullptr; // The number of times this player has been present when the Enderdragon has died void Stats::staticCtor() { @@ -517,7 +517,7 @@ void Stats::buildAdditionalStats() blocksPlaced[itemStat->getItemId()] = itemStat; itemStat->postConstruct(); - GeneralStat *generalStat = NULL; + GeneralStat *generalStat = nullptr; rainbowCollection = StatArray(16); for (unsigned int i = 0; i < 16; i++) diff --git a/Minecraft.World/StemTile.cpp b/Minecraft.World/StemTile.cpp index 69ced0d27..445c88e4a 100644 --- a/Minecraft.World/StemTile.cpp +++ b/Minecraft.World/StemTile.cpp @@ -17,7 +17,7 @@ StemTile::StemTile(int id, Tile *fruit) : Bush(id) float ss = 0.125f; this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, 0.25f, 0.5f + ss); - iconAngled = NULL; + iconAngled = nullptr; } bool StemTile::mayPlaceOn(int tile) @@ -184,7 +184,7 @@ void StemTile::spawnResources(Level *level, int x, int y, int z, int data, float return; } - Item *seed = NULL; + Item *seed = nullptr; if (fruit == Tile::pumpkin) seed = Item::seeds_pumpkin; if (fruit == Tile::melon) seed = Item::seeds_melon; for (int i = 0; i < 3; i++) diff --git a/Minecraft.World/StrongholdFeature.cpp b/Minecraft.World/StrongholdFeature.cpp index 2ce875950..83f05cf3f 100644 --- a/Minecraft.World/StrongholdFeature.cpp +++ b/Minecraft.World/StrongholdFeature.cpp @@ -39,7 +39,7 @@ void StrongholdFeature::_init() // 4J added initialisers for (int i = 0; i < strongholdPos_length; i++) { - strongholdPos[i] = NULL; + strongholdPos[i] = nullptr; } isSpotSelected = false; } @@ -140,7 +140,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat) int selectedZ = static_cast(Math::round(sin(angle) * dist)); TilePos *position = level->getBiomeSource()->findBiome((selectedX << 4) + 8, (selectedZ << 4) + 8, 7 << 4, allowedBiomes, &random); - if (position != NULL) + if (position != nullptr) { selectedX = position->x >> 4; selectedZ = position->z >> 4; @@ -191,7 +191,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z,bool bIsSuperflat) { bool forcePlacement = false; LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); - if( levelGenOptions != NULL ) + if( levelGenOptions != nullptr ) { forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Stronghold); } @@ -211,7 +211,7 @@ vector *StrongholdFeature::getGuesstimatedFeaturePositions() for( int i = 0; i < strongholdPos_length; i++ ) { ChunkPos *chunkPos = strongholdPos[i]; - if (chunkPos != NULL) + if (chunkPos != nullptr) { positions->push_back(chunkPos->getMiddleBlockPosition(64)); } @@ -225,7 +225,7 @@ StructureStart *StrongholdFeature::createStructureStart(int x, int z) StrongholdStart *start = new StrongholdStart(level, random, x, z); // 4J - front() was get(0) - while (start->getPieces()->empty() || static_cast(start->getPieces()->front())->portalRoomPiece == NULL) + while (start->getPieces()->empty() || static_cast(start->getPieces()->front())->portalRoomPiece == nullptr) { delete start; // regenerate stronghold without changing seed diff --git a/Minecraft.World/StrongholdPieces.cpp b/Minecraft.World/StrongholdPieces.cpp index e1f912bc0..d98d94881 100644 --- a/Minecraft.World/StrongholdPieces.cpp +++ b/Minecraft.World/StrongholdPieces.cpp @@ -90,7 +90,7 @@ bool StrongholdPieces::updatePieceWeight() StrongholdPieces::StrongholdPiece *StrongholdPieces::findAndCreatePieceFactory(EPieceClass pieceClass, list *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { - StrongholdPiece *strongholdPiece = NULL; + StrongholdPiece *strongholdPiece = nullptr; if (pieceClass == EPieceClass_Straight) { @@ -145,7 +145,7 @@ StrongholdPieces::StrongholdPiece *StrongholdPieces::generatePieceFromSmallDoor( { if (!updatePieceWeight()) { - return NULL; + return nullptr; } if (imposedPiece != EPieceClass_NULL) @@ -153,7 +153,7 @@ StrongholdPieces::StrongholdPiece *StrongholdPieces::generatePieceFromSmallDoor( StrongholdPiece *strongholdPiece = findAndCreatePieceFactory(imposedPiece, pieces, random, footX, footY, footZ, direction, depth); imposedPiece = EPieceClass_NULL; - if (strongholdPiece != NULL) + if (strongholdPiece != nullptr) { return strongholdPiece; } @@ -176,7 +176,7 @@ StrongholdPieces::StrongholdPiece *StrongholdPieces::generatePieceFromSmallDoor( } StrongholdPiece *strongholdPiece = findAndCreatePieceFactory(piece->pieceClass, pieces, random, footX, footY, footZ, direction, depth); - if (strongholdPiece != NULL) + if (strongholdPiece != nullptr) { piece->placeCount++; startPiece->previousPiece = piece; @@ -192,21 +192,21 @@ StrongholdPieces::StrongholdPiece *StrongholdPieces::generatePieceFromSmallDoor( } { BoundingBox *box = FillerCorridor::findPieceBox(pieces, random, footX, footY, footZ, direction); - if (box != NULL && box->y0 > 1) + if (box != nullptr && box->y0 > 1) { return new FillerCorridor(depth, random, box, direction); } - if(box != NULL) delete box; + if(box != nullptr) delete box; } - return NULL; + return nullptr; } StructurePiece *StrongholdPieces::generateAndAddPiece(StartPiece *startPiece, list *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { if (depth > MAX_DEPTH) { - return NULL; + return nullptr; } if (abs(footX - startPiece->getBoundingBox()->x0) > 3 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 3 * 16) { @@ -221,7 +221,7 @@ StructurePiece *StrongholdPieces::generateAndAddPiece(StartPiece *startPiece, li printf("Portal room forcing attempt\n"); #endif StrongholdPiece *strongholdPiece = PortalRoom::createPiece(pieces, random, footX, footY, footZ, direction, depth); - if (strongholdPiece != NULL) + if (strongholdPiece != nullptr) { piece->placeCount++; startPiece->previousPiece = piece; @@ -237,11 +237,11 @@ StructurePiece *StrongholdPieces::generateAndAddPiece(StartPiece *startPiece, li } } } - return NULL; + return nullptr; } StructurePiece *newPiece = generatePieceFromSmallDoor(startPiece, pieces, random, footX, footY, footZ, direction, depth + 1); - if (newPiece != NULL) + if (newPiece != nullptr) { pieces->push_back(newPiece); startPiece->pendingChildren.push_back(newPiece); @@ -349,7 +349,7 @@ StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildForward case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0 + yOff, boundingBox->z0 + xOff, orientation, getGenDepth()); } - return NULL; + return nullptr; } StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildLeft(StartPiece *startPiece, list *pieces, Random *random, int yOff, int zOff) @@ -365,7 +365,7 @@ StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildLeft(St case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); } - return NULL; + return nullptr; } StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildRight(StartPiece *startPiece, list *pieces, Random *random, int yOff, int zOff) @@ -381,20 +381,20 @@ StructurePiece *StrongholdPieces::StrongholdPiece::generateSmallDoorChildRight(S case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); } - return NULL; + return nullptr; } bool StrongholdPieces::StrongholdPiece::isOkBox(BoundingBox *box, StartPiece *startRoom) { - //return box != NULL && box->y0 > LOWEST_Y_POSITION; + //return box != nullptr && box->y0 > LOWEST_Y_POSITION; bool bIsOk = false; - if(box != NULL) + if(box != nullptr) { if( box->y0 > LOWEST_Y_POSITION ) bIsOk = true; - if( startRoom != NULL && startRoom->m_level->getOriginalSaveVersion() >= SAVE_FILE_VERSION_MOVED_STRONGHOLD ) + if( startRoom != nullptr && startRoom->m_level->getOriginalSaveVersion() >= SAVE_FILE_VERSION_MOVED_STRONGHOLD ) { int xzSize = startRoom->m_level->getLevelData()->getXZSize(); int blockMin = -( (xzSize << 4) / 2) + 1; @@ -442,12 +442,12 @@ BoundingBox *StrongholdPieces::FillerCorridor::findPieceBox(listgetBoundingBox()->y0 == box->y0) @@ -468,7 +468,7 @@ BoundingBox *StrongholdPieces::FillerCorridor::findPieceBox(list(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new StairsDown(genDepth, random, box, direction); @@ -618,15 +618,15 @@ StrongholdPieces::StartPiece::StartPiece(int genDepth, Random *random, int west, { // 4J added initialisers isLibraryAdded = false; - previousPiece = NULL; - portalRoomPiece = NULL; + previousPiece = nullptr; + portalRoomPiece = nullptr; m_level = level; } TilePos *StrongholdPieces::StartPiece::getLocatorPosition() { - if( portalRoomPiece != NULL ) + if( portalRoomPiece != nullptr ) { return portalRoomPiece->getLocatorPosition(); } @@ -672,13 +672,13 @@ StrongholdPieces::Straight *StrongholdPieces::Straight::createPiece(list(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new Straight(genDepth, random, box, direction); @@ -772,13 +772,13 @@ StrongholdPieces::ChestCorridor *StrongholdPieces::ChestCorridor::createPiece(li { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -1, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new ChestCorridor(genDepth, random, box, direction); @@ -844,13 +844,13 @@ StrongholdPieces::StraightStairsDown *StrongholdPieces::StraightStairsDown::crea { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 4 - height, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new StraightStairsDown(genDepth, random, box, direction); @@ -916,13 +916,13 @@ StrongholdPieces::LeftTurn *StrongholdPieces::LeftTurn::createPiece(list(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new LeftTurn(genDepth, random, box, direction); @@ -1032,13 +1032,13 @@ StrongholdPieces::RoomCrossing *StrongholdPieces::RoomCrossing::createPiece(list { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -4, -1, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new RoomCrossing(genDepth, random, box, direction); @@ -1184,13 +1184,13 @@ StrongholdPieces::PrisonHall *StrongholdPieces::PrisonHall::createPiece(list(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new PrisonHall(genDepth, random, box, direction); @@ -1263,19 +1263,19 @@ StrongholdPieces::Library *StrongholdPieces::Library::createPiece(list(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; // make a short library box = BoundingBox::orientBox(footX, footY, footZ, -4, -1, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } } @@ -1476,13 +1476,13 @@ StrongholdPieces::FiveCrossing *StrongholdPieces::FiveCrossing::createPiece(list { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -4, -3, 0, width, height, depth, direction); - StartPiece *startPiece = NULL; - if(pieces != NULL) startPiece = static_cast(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new FiveCrossing(genDepth, random, box, direction); @@ -1561,7 +1561,7 @@ void StrongholdPieces::PortalRoom::readAdditonalSaveData(CompoundTag *tag) void StrongholdPieces::PortalRoom::addChildren(StructurePiece *startPiece, list *pieces, Random *random) { - if (startPiece != NULL) + if (startPiece != nullptr) { static_cast(startPiece)->portalRoomPiece = this; } @@ -1572,13 +1572,13 @@ StrongholdPieces::PortalRoom *StrongholdPieces::PortalRoom::createPiece(list(pieces->front()); + StartPiece *startPiece = nullptr; + if(pieces != nullptr) startPiece = static_cast(pieces->front()); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new PortalRoom(genDepth, random, box, direction); @@ -1688,7 +1688,7 @@ bool StrongholdPieces::PortalRoom::postProcess(Level *level, Random *random, Bou hasPlacedMobSpawner = true; level->setTileAndData(x, y, z, Tile::mobSpawner_Id, 0, Tile::UPDATE_CLIENTS); shared_ptr entity = dynamic_pointer_cast(level->getTileEntity(x, y, z)); - if (entity != NULL) entity->getSpawner()->setEntityId(L"Silverfish"); + if (entity != nullptr) entity->getSpawner()->setEntityId(L"Silverfish"); } } diff --git a/Minecraft.World/StructureFeature.cpp b/Minecraft.World/StructureFeature.cpp index dfb214a54..acc574729 100644 --- a/Minecraft.World/StructureFeature.cpp +++ b/Minecraft.World/StructureFeature.cpp @@ -109,7 +109,7 @@ bool StructureFeature::isIntersection(int cellX, int cellZ) bool StructureFeature::isInsideFeature(int cellX, int cellY, int cellZ) { restoreSavedData(level); - return getStructureAt(cellX, cellY, cellZ) != NULL; + return getStructureAt(cellX, cellY, cellZ) != nullptr; } StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ) @@ -142,7 +142,7 @@ StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ } } } - return NULL; + return nullptr; } bool StructureFeature::isInsideBoundingFeature(int cellX, int cellY, int cellZ) @@ -178,7 +178,7 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i addFeature(level, cellX >> 4, cellZ >> 4, 0, 0, byteArray()); double minDistance = DBL_MAX; - TilePos *selected = NULL; + TilePos *selected = nullptr; for(auto& it : cachedStructures) { @@ -203,14 +203,14 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i } } } - if (selected != NULL) + if (selected != nullptr) { return selected; } else { vector *guesstimatedFeaturePositions = getGuesstimatedFeaturePositions(); - if (guesstimatedFeaturePositions != NULL) + if (guesstimatedFeaturePositions != nullptr) { TilePos *pSelectedPos = new TilePos(0,0,0); @@ -233,22 +233,22 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i return pSelectedPos; } } - return NULL; + return nullptr; } vector *StructureFeature::getGuesstimatedFeaturePositions() { - return NULL; + return nullptr; } void StructureFeature::restoreSavedData(Level *level) { #ifdef ENABLE_STRUCTURE_SAVING - if (savedData == NULL) + if (savedData == nullptr) { savedData = dynamic_pointer_cast( level->getSavedData(typeid(StructureFeatureSavedData), getFeatureName()) ); - if (savedData == NULL) + if (savedData == nullptr) { savedData = shared_ptr( new StructureFeatureSavedData(getFeatureName()) ); level->setSavedData(getFeatureName(), savedData); diff --git a/Minecraft.World/StructureFeatureIO.cpp b/Minecraft.World/StructureFeatureIO.cpp index 3e73b028e..784d14c9f 100644 --- a/Minecraft.World/StructureFeatureIO.cpp +++ b/Minecraft.World/StructureFeatureIO.cpp @@ -63,7 +63,7 @@ wstring StructureFeatureIO::getEncodeId(StructurePiece *piece) StructureStart *StructureFeatureIO::loadStaticStart(CompoundTag *tag, Level *level) { - StructureStart *start = NULL; + StructureStart *start = nullptr; auto it = startIdClassMap.find(tag->getString(L"id")); if(it != startIdClassMap.end()) @@ -71,7 +71,7 @@ StructureStart *StructureFeatureIO::loadStaticStart(CompoundTag *tag, Level *lev start = (it->second)(); } - if (start != NULL) + if (start != nullptr) { start->load(level, tag); } @@ -84,7 +84,7 @@ StructureStart *StructureFeatureIO::loadStaticStart(CompoundTag *tag, Level *lev StructurePiece *StructureFeatureIO::loadStaticPiece(CompoundTag *tag, Level *level) { - StructurePiece *piece = NULL; + StructurePiece *piece = nullptr; auto it = pieceIdClassMap.find(tag->getString(L"id")); if(it != pieceIdClassMap.end()) @@ -92,7 +92,7 @@ StructurePiece *StructureFeatureIO::loadStaticPiece(CompoundTag *tag, Level *lev piece = (it->second)(); } - if (piece != NULL) + if (piece != nullptr) { piece->load(level, tag); } diff --git a/Minecraft.World/StructurePiece.cpp b/Minecraft.World/StructurePiece.cpp index be0822bf5..bb3887c0f 100644 --- a/Minecraft.World/StructurePiece.cpp +++ b/Minecraft.World/StructurePiece.cpp @@ -44,7 +44,7 @@ StructurePiece::StructurePiece() { - boundingBox = NULL; + boundingBox = nullptr; orientation = 0; genDepth = 0; // for reflection @@ -52,14 +52,14 @@ StructurePiece::StructurePiece() StructurePiece::StructurePiece( int genDepth ) { - boundingBox = NULL; + boundingBox = nullptr; this->genDepth = genDepth; orientation = Direction::UNDEFINED; } StructurePiece::~StructurePiece() { - if(boundingBox != NULL) delete boundingBox; + if(boundingBox != nullptr) delete boundingBox; } CompoundTag *StructurePiece::createTag() @@ -120,7 +120,7 @@ StructurePiece* StructurePiece::findCollisionPiece( list< StructurePiece* > *pie return piece; } } - return NULL; + return nullptr; } // 4J-PB - Added from 1.2.3 @@ -437,7 +437,7 @@ int StructurePiece::getOrientationData( int tile, int data ) } } } - else if (tile == Tile::tripWireSource_Id || (Tile::tiles[tile] != NULL && dynamic_cast(Tile::tiles[tile]))) + else if (tile == Tile::tripWireSource_Id || (Tile::tiles[tile] != nullptr && dynamic_cast(Tile::tiles[tile]))) { if (orientation == Direction::SOUTH) { @@ -816,7 +816,7 @@ bool StructurePiece::createChest( Level* level, BoundingBox* chunkBB, Random* ra { level->setTileAndData( worldX, worldY, worldZ, Tile::chest->id, 0, Tile::UPDATE_CLIENTS ); shared_ptr chest = dynamic_pointer_cast(level->getTileEntity( worldX, worldY, worldZ )); - if ( chest != NULL ) WeighedTreasure::addChestItems( random, treasure, chest, numRolls ); + if ( chest != nullptr ) WeighedTreasure::addChestItems( random, treasure, chest, numRolls ); return true; } } @@ -835,7 +835,7 @@ bool StructurePiece::createDispenser(Level *level, BoundingBox *chunkBB, Random { level->setTileAndData(worldX, worldY, worldZ, Tile::dispenser_Id, getOrientationData(Tile::dispenser_Id, facing), Tile::UPDATE_CLIENTS); shared_ptr dispenser = dynamic_pointer_cast(level->getTileEntity(worldX, worldY, worldZ)); - if (dispenser != NULL) WeighedTreasure::addDispenserItems(random, items, dispenser, numRolls); + if (dispenser != nullptr) WeighedTreasure::addDispenserItems(random, items, dispenser, numRolls); return true; } } diff --git a/Minecraft.World/StructureStart.cpp b/Minecraft.World/StructureStart.cpp index 3f22b4a7d..0065160e4 100644 --- a/Minecraft.World/StructureStart.cpp +++ b/Minecraft.World/StructureStart.cpp @@ -9,14 +9,14 @@ StructureStart::StructureStart() { chunkX = chunkZ = 0; - boundingBox = NULL; // 4J added initialiser + boundingBox = nullptr; // 4J added initialiser } StructureStart::StructureStart(int x, int z) { this->chunkX = x; this->chunkZ = z; - boundingBox = NULL; + boundingBox = nullptr; } StructureStart::~StructureStart() diff --git a/Minecraft.World/SwampTreeFeature.cpp b/Minecraft.World/SwampTreeFeature.cpp index 19d3f66a7..5b94767ac 100644 --- a/Minecraft.World/SwampTreeFeature.cpp +++ b/Minecraft.World/SwampTreeFeature.cpp @@ -14,7 +14,7 @@ bool SwampTreeFeature::place(Level *level, Random *random, int x, int y, int z) if (y < 1 || y + treeHeight + 1 > Level::genDepth) return false; // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x - 3, y - 1, z - 3, x + 3, y + treeHeight, z + 3); diff --git a/Minecraft.World/SwellGoal.cpp b/Minecraft.World/SwellGoal.cpp index 040d09c27..0fd3c34a8 100644 --- a/Minecraft.World/SwellGoal.cpp +++ b/Minecraft.World/SwellGoal.cpp @@ -16,7 +16,7 @@ SwellGoal::SwellGoal(Creeper *creeper) bool SwellGoal::canUse() { shared_ptr target = creeper->getTarget(); - return creeper->getSwellDir() > 0 || (target != NULL && (creeper->distanceToSqr(target) < 3 * 3)); + return creeper->getSwellDir() > 0 || (target != nullptr && (creeper->distanceToSqr(target) < 3 * 3)); } void SwellGoal::start() @@ -32,7 +32,7 @@ void SwellGoal::stop() void SwellGoal::tick() { - if (target.lock() == NULL) + if (target.lock() == nullptr) { creeper->setSwellDir(-1); return; diff --git a/Minecraft.World/SynchedEntityData.cpp b/Minecraft.World/SynchedEntityData.cpp index 577063db6..2c126f562 100644 --- a/Minecraft.World/SynchedEntityData.cpp +++ b/Minecraft.World/SynchedEntityData.cpp @@ -128,7 +128,7 @@ shared_ptr SynchedEntityData::getItemInstance(int id) Pos *SynchedEntityData::getPos(int id) { assert(false); // 4J - not currently implemented - return NULL; + return nullptr; } void SynchedEntityData::set(int id, int value) @@ -238,18 +238,18 @@ void SynchedEntityData::pack(vector > *items, DataOutputStr vector > *SynchedEntityData::packDirty() { - vector > *result = NULL; + vector > *result = nullptr; if (m_isDirty) { for( int i = 0; i <= MAX_ID_VALUE; i++ ) { shared_ptr dataItem = itemsById[i]; - if ((dataItem != NULL) && dataItem->isDirty()) + if ((dataItem != nullptr) && dataItem->isDirty()) { dataItem->setDirty(false); - if (result == NULL) + if (result == nullptr) { result = new vector >(); } @@ -267,7 +267,7 @@ void SynchedEntityData::packAll(DataOutputStream *output) // throws IOException for( int i = 0; i <= MAX_ID_VALUE; i++ ) { shared_ptr dataItem = itemsById[i]; - if(dataItem != NULL) + if(dataItem != nullptr) { writeDataItem(output, dataItem); } @@ -279,14 +279,14 @@ void SynchedEntityData::packAll(DataOutputStream *output) // throws IOException vector > *SynchedEntityData::getAll() { - vector > *result = NULL; + vector > *result = nullptr; for( int i = 0; i <= MAX_ID_VALUE; i++ ) { shared_ptr dataItem = itemsById[i]; - if(dataItem != NULL) + if(dataItem != nullptr) { - if (result == NULL) + if (result == nullptr) { result = new vector >(); } @@ -338,14 +338,14 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, shared_ptr > *SynchedEntityData::unpack(DataInputStream *input) //throws IOException { - vector > *result = NULL; + vector > *result = nullptr; int currentHeader = input->readByte(); while (currentHeader != EOF_MARKER) { - if (result == NULL) + if (result == nullptr) { result = new vector >(); } @@ -393,7 +393,7 @@ vector > *SynchedEntityData::unpack(Data default: app.DebugPrintf(" ------ garbage data, or early end of stream due to an incomplete packet\n"); delete result; - return NULL; + return nullptr; break; } result->push_back(item); @@ -415,7 +415,7 @@ void SynchedEntityData::assignValues(vector > *items) for (auto& item : *items) { shared_ptr itemFromId = itemsById[item->getId()]; - if( itemFromId != NULL ) + if( itemFromId != nullptr ) { switch(item->getType()) { @@ -465,7 +465,7 @@ int SynchedEntityData::getSizeInBytes() for( int i = 0; i <= MAX_ID_VALUE; i++ ) { shared_ptr dataItem = itemsById[i]; - if(dataItem != NULL) + if(dataItem != nullptr) { size += 1; diff --git a/Minecraft.World/Tag.cpp b/Minecraft.World/Tag.cpp index adc753608..58332f0c0 100644 --- a/Minecraft.World/Tag.cpp +++ b/Minecraft.World/Tag.cpp @@ -27,7 +27,7 @@ Tag::Tag(const wstring &name) // 4J - Was Object obj bool Tag::equals(Tag *obj) { - if (obj == NULL )// || !(obj instanceof Tag)) + if (obj == nullptr )// || !(obj instanceof Tag)) { return false; } @@ -150,7 +150,7 @@ Tag *Tag::newTag(byte type, const wstring &name) case TAG_Compound: return new CompoundTag(name); } - return NULL; + return nullptr; } wchar_t *Tag::getTagName(byte type) diff --git a/Minecraft.World/TakeFlowerGoal.cpp b/Minecraft.World/TakeFlowerGoal.cpp index 0774374be..71e7c7c6d 100644 --- a/Minecraft.World/TakeFlowerGoal.cpp +++ b/Minecraft.World/TakeFlowerGoal.cpp @@ -53,7 +53,7 @@ bool TakeFlowerGoal::canUse() bool TakeFlowerGoal::canContinueToUse() { - return golem.lock() != NULL && golem.lock()->getOfferFlowerTick() > 0; + return golem.lock() != nullptr && golem.lock()->getOfferFlowerTick() > 0; } void TakeFlowerGoal::start() diff --git a/Minecraft.World/TallGrass.cpp b/Minecraft.World/TallGrass.cpp index 1a89d3edf..bf8899103 100644 --- a/Minecraft.World/TallGrass.cpp +++ b/Minecraft.World/TallGrass.cpp @@ -81,7 +81,7 @@ int TallGrass::getResourceCountForLootBonus(int bonusLevel, Random *random) void TallGrass::playerDestroy(Level *level, shared_ptr player, int x, int y, int z, int data) { - if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears->id) + if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id) { player->awardStat( GenericStats::blocksMined(id), diff --git a/Minecraft.World/TamableAnimal.cpp b/Minecraft.World/TamableAnimal.cpp index a938cc293..1fb41df32 100644 --- a/Minecraft.World/TamableAnimal.cpp +++ b/Minecraft.World/TamableAnimal.cpp @@ -13,7 +13,7 @@ TamableAnimal::TamableAnimal(Level *level) : Animal(level) TamableAnimal::~TamableAnimal() { - if(sitGoal != NULL) delete sitGoal; + if(sitGoal != nullptr) delete sitGoal; } void TamableAnimal::defineSynchedData() @@ -169,7 +169,7 @@ Team *TamableAnimal::getTeam() if (isTame()) { shared_ptr owner = dynamic_pointer_cast(getOwner()); - if (owner != NULL) + if (owner != nullptr) { return owner->getTeam(); } @@ -186,7 +186,7 @@ bool TamableAnimal::isAlliedTo(shared_ptr other) { return true; } - if (owner != NULL) + if (owner != nullptr) { return owner->isAlliedTo(other); } diff --git a/Minecraft.World/TargetGoal.cpp b/Minecraft.World/TargetGoal.cpp index 982acb5e2..0c2b9363f 100644 --- a/Minecraft.World/TargetGoal.cpp +++ b/Minecraft.World/TargetGoal.cpp @@ -34,7 +34,7 @@ TargetGoal::TargetGoal(PathfinderMob *mob, bool mustSee, bool mustReach) bool TargetGoal::canContinueToUse() { shared_ptr target = mob->getTarget(); - if (target == NULL) return false; + if (target == nullptr) return false; if (!target->isAlive()) return false; double within = getFollowDistance(); @@ -56,7 +56,7 @@ bool TargetGoal::canContinueToUse() double TargetGoal::getFollowDistance() { AttributeInstance *followRange = mob->getAttribute(SharedMonsterAttributes::FOLLOW_RANGE); - return followRange == NULL ? 16 : followRange->getValue(); + return followRange == nullptr ? 16 : followRange->getValue(); } void TargetGoal::start() @@ -73,16 +73,16 @@ void TargetGoal::stop() bool TargetGoal::canAttack(shared_ptr target, bool allowInvulnerable) { - if (target == NULL) return false; + if (target == nullptr) return false; if (target == mob->shared_from_this()) return false; if (!target->isAlive()) return false; if (!mob->canAttackType(target->GetType())) return false; OwnableEntity *ownableMob = dynamic_cast(mob); - if (ownableMob != NULL && !ownableMob->getOwnerUUID().empty()) + if (ownableMob != nullptr && !ownableMob->getOwnerUUID().empty()) { shared_ptr ownableTarget = dynamic_pointer_cast(target); - if (ownableTarget != NULL && ownableMob->getOwnerUUID().compare(ownableTarget->getOwnerUUID()) == 0) + if (ownableTarget != nullptr && ownableMob->getOwnerUUID().compare(ownableTarget->getOwnerUUID()) == 0) { // We're attacking something owned by the same person... return false; @@ -117,9 +117,9 @@ bool TargetGoal::canReach(shared_ptr target) { reachCacheTime = 10 + mob->getRandom()->nextInt(5); Path *path = mob->getNavigation()->createPath(target); - if (path == NULL) return false; + if (path == nullptr) return false; Node *last = path->last(); - if (last == NULL) + if (last == nullptr) { delete path; return false; diff --git a/Minecraft.World/Team.cpp b/Minecraft.World/Team.cpp index f3f6e04e6..7c3bde0c5 100644 --- a/Minecraft.World/Team.cpp +++ b/Minecraft.World/Team.cpp @@ -4,7 +4,7 @@ bool Team::isAlliedTo(Team *other) { - if (other == NULL) + if (other == nullptr) { return false; } diff --git a/Minecraft.World/TemptGoal.cpp b/Minecraft.World/TemptGoal.cpp index aebab8fa2..40b3201ca 100644 --- a/Minecraft.World/TemptGoal.cpp +++ b/Minecraft.World/TemptGoal.cpp @@ -29,10 +29,10 @@ bool TemptGoal::canUse() return false; } player = weak_ptr(mob->level->getNearestPlayer(mob->shared_from_this(), 10)); - if (player.lock() == NULL) return false; + if (player.lock() == nullptr) return false; mob->setDespawnProtected(); // If we've got a nearby player, then consider this mob as something we'd miss if it despawned shared_ptr item = player.lock()->getSelectedItem(); - if (item == NULL) return false; + if (item == nullptr) return false; if (item->id != itemId) return false; return true; } @@ -41,7 +41,7 @@ bool TemptGoal::canContinueToUse() { if (canScare) { - if(player.lock() == NULL) return false; + if(player.lock() == nullptr) return false; if (mob->distanceToSqr(player.lock()) < 6 * 6) { if (player.lock()->distanceToSqr(px, py, pz) > 0.1 * 0.1) return false; diff --git a/Minecraft.World/TextureAndGeometryPacket.cpp b/Minecraft.World/TextureAndGeometryPacket.cpp index 5386bd12b..bf5eccdbb 100644 --- a/Minecraft.World/TextureAndGeometryPacket.cpp +++ b/Minecraft.World/TextureAndGeometryPacket.cpp @@ -10,21 +10,21 @@ TextureAndGeometryPacket::TextureAndGeometryPacket() { this->textureName = L""; this->dwTextureBytes = 0; - this->pbData = NULL; + this->pbData = nullptr; this->dwBoxC = 0; - this->BoxDataA = NULL; + this->BoxDataA = nullptr; uiAnimOverrideBitmask=0; } TextureAndGeometryPacket::~TextureAndGeometryPacket() { // can't free these - they're used elsewhere -// if(this->BoxDataA!=NULL) +// if(this->BoxDataA!=nullptr) // { // delete [] this->BoxDataA; // } // -// if(this->pbData!=NULL) +// if(this->pbData!=nullptr) // { // delete [] this->pbData; // } @@ -43,7 +43,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->pbData = pbData; this->dwTextureBytes = dwBytes; this->dwBoxC = 0; - this->BoxDataA=NULL; + this->BoxDataA=nullptr; this->uiAnimOverrideBitmask=0; } @@ -75,7 +75,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P } else { - this->BoxDataA=NULL; + this->BoxDataA=nullptr; } } @@ -93,10 +93,10 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->pbData = pbData; this->dwTextureBytes = dwBytes; this->uiAnimOverrideBitmask = uiAnimOverrideBitmask; - if(pvSkinBoxes==NULL) + if(pvSkinBoxes==nullptr) { this->dwBoxC=0; - this->BoxDataA=NULL; + this->BoxDataA=nullptr; } else { diff --git a/Minecraft.World/TexturePacket.cpp b/Minecraft.World/TexturePacket.cpp index 061c6fc1e..eadcb3edb 100644 --- a/Minecraft.World/TexturePacket.cpp +++ b/Minecraft.World/TexturePacket.cpp @@ -10,13 +10,13 @@ TexturePacket::TexturePacket() { this->textureName = L""; this->dwBytes = 0; - this->pbData = NULL; + this->pbData = nullptr; } TexturePacket::~TexturePacket() { // can't free this - it's used elsewhere -// if(this->pbData!=NULL) +// if(this->pbData!=nullptr) // { // delete [] this->pbData; // } diff --git a/Minecraft.World/TheEndDimension.cpp b/Minecraft.World/TheEndDimension.cpp index ccc8641b4..ef11b1fb6 100644 --- a/Minecraft.World/TheEndDimension.cpp +++ b/Minecraft.World/TheEndDimension.cpp @@ -26,7 +26,7 @@ float TheEndDimension::getTimeOfDay(__int64 time, float a) const float *TheEndDimension::getSunriseColor(float td, float a) { - return NULL; + return nullptr; } Vec3 *TheEndDimension::getFogColor(float td, float a) const diff --git a/Minecraft.World/TheEndLevelRandomLevelSource.cpp b/Minecraft.World/TheEndLevelRandomLevelSource.cpp index 5b965ef79..858e79727 100644 --- a/Minecraft.World/TheEndLevelRandomLevelSource.cpp +++ b/Minecraft.World/TheEndLevelRandomLevelSource.cpp @@ -195,7 +195,7 @@ LevelChunk *TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs) doubleArray TheEndLevelRandomLevelSource::getHeights(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize) { - if (buffer.data == NULL) + if (buffer.data == nullptr) { buffer = doubleArray(xSize * ySize * zSize); } @@ -407,16 +407,16 @@ wstring TheEndLevelRandomLevelSource::gatherStats() vector *TheEndLevelRandomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { Biome *biome = level->getBiome(x, z); - if (biome == NULL) + if (biome == nullptr) { - return NULL; + return nullptr; } return biome->getMobs(mobCategory); } TilePos *TheEndLevelRandomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) { - return NULL; + return nullptr; } void TheEndLevelRandomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) diff --git a/Minecraft.World/TheEndPortal.cpp b/Minecraft.World/TheEndPortal.cpp index f2cb5dadf..0298ca48b 100644 --- a/Minecraft.World/TheEndPortal.cpp +++ b/Minecraft.World/TheEndPortal.cpp @@ -13,7 +13,7 @@ DWORD TheEndPortal::tlsIdx = TlsAlloc(); // 4J - allowAnywhere is a static in java, implementing as TLS here to make thread safe bool TheEndPortal::allowAnywhere() { - return (TlsGetValue(tlsIdx) != NULL); + return (TlsGetValue(tlsIdx) != nullptr); } void TheEndPortal::allowAnywhere(bool set) @@ -66,7 +66,7 @@ void TheEndPortal::entityInside(Level *level, int x, int y, int z, shared_ptrGetType() == eTYPE_EXPERIENCEORB ) return; // 4J added - if (entity->riding == NULL && entity->rider.lock() == NULL) + if (entity->riding == nullptr && entity->rider.lock() == nullptr) { if (!level->isClientSide) { diff --git a/Minecraft.World/TheEndPortalFrameTile.cpp b/Minecraft.World/TheEndPortalFrameTile.cpp index f7b10a05a..80e78f49d 100644 --- a/Minecraft.World/TheEndPortalFrameTile.cpp +++ b/Minecraft.World/TheEndPortalFrameTile.cpp @@ -9,8 +9,8 @@ const wstring TheEndPortalFrameTile::TEXTURE_EYE = L"endframe_eye"; TheEndPortalFrameTile::TheEndPortalFrameTile(int id) : Tile(id, Material::glass, isSolidRender() ) { - iconTop = NULL; - iconEye = NULL; + iconTop = nullptr; + iconEye = nullptr; } Icon *TheEndPortalFrameTile::getTexture(int face, int data) diff --git a/Minecraft.World/ThinFenceTile.cpp b/Minecraft.World/ThinFenceTile.cpp index 3f471ce41..cbfdd2fe0 100644 --- a/Minecraft.World/ThinFenceTile.cpp +++ b/Minecraft.World/ThinFenceTile.cpp @@ -5,7 +5,7 @@ ThinFenceTile::ThinFenceTile(int id, const wstring &tex, const wstring &edgeTex, Material *material, bool dropsResources) : Tile(id, material,isSolidRender()) { - iconSide = NULL; + iconSide = nullptr; edgeTexture = edgeTex; this->dropsResources = dropsResources; this->texture = tex; diff --git a/Minecraft.World/ThornsEnchantment.cpp b/Minecraft.World/ThornsEnchantment.cpp index 536686427..a301907e2 100644 --- a/Minecraft.World/ThornsEnchantment.cpp +++ b/Minecraft.World/ThornsEnchantment.cpp @@ -62,14 +62,14 @@ void ThornsEnchantment::doThornsAfterAttack(shared_ptr source, shared_pt source->hurt(DamageSource::thorns(target), getDamage(level, random)); source->playSound(eSoundType_DAMAGE_THORNS, .5f, 1.0f); - if (item != NULL) + if (item != nullptr) { item->hurtAndBreak(3, target); } } else { - if (item != NULL) + if (item != nullptr) { item->hurtAndBreak(1, target); } diff --git a/Minecraft.World/Throwable.cpp b/Minecraft.World/Throwable.cpp index 4aecacfda..08e40aa6d 100644 --- a/Minecraft.World/Throwable.cpp +++ b/Minecraft.World/Throwable.cpp @@ -166,7 +166,7 @@ void Throwable::tick() from = Vec3::newTemp(x, y, z); to = Vec3::newTemp(x + xd, y + yd, z + zd); - if (res != NULL) + if (res != nullptr) { to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z); } @@ -185,7 +185,7 @@ void Throwable::tick() float rr = 0.3f; AABB *bb = e->bb->grow(rr, rr, rr); HitResult *p = bb->clip(from, to); - if (p != NULL) + if (p != nullptr) { double dd = from->distanceTo(p->pos); delete p; @@ -197,14 +197,14 @@ void Throwable::tick() } } - if (hitEntity != NULL) + if (hitEntity != nullptr) { - if(res != NULL) delete res; + if(res != nullptr) delete res; res = new HitResult(hitEntity); } } - if (res != NULL) + if (res != nullptr) { if ( (res->type == HitResult::TILE) && (level->getTile(res->x, res->y, res->z) == Tile::portalTile_Id) ) { @@ -274,7 +274,7 @@ void Throwable::addAdditonalSaveData(CompoundTag *tag) tag->putByte(L"shake", static_cast(shakeTime)); tag->putByte(L"inGround", static_cast(inGround ? 1 : 0)); - if (ownerName.empty() && (owner != NULL) && owner->instanceof(eTYPE_PLAYER) ) + if (ownerName.empty() && (owner != nullptr) && owner->instanceof(eTYPE_PLAYER) ) { ownerName = owner->getAName(); } @@ -301,7 +301,7 @@ float Throwable::getShadowHeightOffs() shared_ptr Throwable::getOwner() { - if (owner == NULL && !ownerName.empty() ) + if (owner == nullptr && !ownerName.empty() ) { owner = level->getPlayerByName(ownerName); } diff --git a/Minecraft.World/ThrownEgg.cpp b/Minecraft.World/ThrownEgg.cpp index 1378e094b..7bf85d71b 100644 --- a/Minecraft.World/ThrownEgg.cpp +++ b/Minecraft.World/ThrownEgg.cpp @@ -33,7 +33,7 @@ ThrownEgg::ThrownEgg(Level *level, double x, double y, double z) : Throwable(lev void ThrownEgg::onHit(HitResult *res) { - if (res->entity != NULL) + if (res->entity != nullptr) { DamageSource *damageSource = DamageSource::thrown(shared_from_this(), owner); res->entity->hurt(damageSource, 0); diff --git a/Minecraft.World/ThrownEnderpearl.cpp b/Minecraft.World/ThrownEnderpearl.cpp index 1035bffdc..c325f1c91 100644 --- a/Minecraft.World/ThrownEnderpearl.cpp +++ b/Minecraft.World/ThrownEnderpearl.cpp @@ -32,7 +32,7 @@ ThrownEnderpearl::ThrownEnderpearl(Level *level, double x, double y, double z) : void ThrownEnderpearl::onHit(HitResult *res) { - if (res->entity != NULL) + if (res->entity != nullptr) { DamageSource *damageSource = DamageSource::thrown(shared_from_this(), getOwner() ); res->entity->hurt(damageSource, 0); @@ -49,7 +49,7 @@ void ThrownEnderpearl::onHit(HitResult *res) // If the owner has been removed, then ignore // 4J-JEV: Cheap type check first. - if ( (getOwner() != NULL) && getOwner()->instanceof(eTYPE_SERVERPLAYER) ) + if ( (getOwner() != nullptr) && getOwner()->instanceof(eTYPE_SERVERPLAYER) ) { shared_ptr serverPlayer = dynamic_pointer_cast(getOwner() ); if (!serverPlayer->removed) diff --git a/Minecraft.World/ThrownPotion.cpp b/Minecraft.World/ThrownPotion.cpp index fbab11d8f..6e0618582 100644 --- a/Minecraft.World/ThrownPotion.cpp +++ b/Minecraft.World/ThrownPotion.cpp @@ -72,13 +72,13 @@ float ThrownPotion::getThrowUpAngleOffset() void ThrownPotion::setPotionValue(int potionValue) { - if (potionItem == NULL) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); + if (potionItem == nullptr) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); potionItem->setAuxValue(potionValue); } int ThrownPotion::getPotionValue() { - if (potionItem == NULL) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); + if (potionItem == nullptr) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); return potionItem->getAuxValue(); } @@ -88,12 +88,12 @@ void ThrownPotion::onHit(HitResult *res) { vector *mobEffects = Item::potion->getMobEffects(potionItem); - if (mobEffects != NULL && !mobEffects->empty()) + if (mobEffects != nullptr && !mobEffects->empty()) { AABB *aoe = bb->grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE); vector > *entitiesOfClass = level->getEntitiesOfClass(typeid(LivingEntity), aoe); - if (entitiesOfClass != NULL && !entitiesOfClass->empty()) + if (entitiesOfClass != nullptr && !entitiesOfClass->empty()) { for(auto & it : *entitiesOfClass) { @@ -148,12 +148,12 @@ void ThrownPotion::readAdditionalSaveData(CompoundTag *tag) setPotionValue(tag->getInt(L"potionValue")); } - if (potionItem == NULL) remove(); + if (potionItem == nullptr) remove(); } void ThrownPotion::addAdditonalSaveData(CompoundTag *tag) { Throwable::addAdditonalSaveData(tag); - if (potionItem != NULL) tag->putCompound(L"Potion", potionItem->save(new CompoundTag())); + if (potionItem != nullptr) tag->putCompound(L"Potion", potionItem->save(new CompoundTag())); } \ No newline at end of file diff --git a/Minecraft.World/TickNextTickData.cpp b/Minecraft.World/TickNextTickData.cpp index 277be1f8c..95639b044 100644 --- a/Minecraft.World/TickNextTickData.cpp +++ b/Minecraft.World/TickNextTickData.cpp @@ -21,7 +21,7 @@ bool TickNextTickData::equals(const TickNextTickData *o) const { // TODO 4J Is this safe to cast it before we do a dynamic_cast? Will the dynamic_cast still fail? // We cannot dynamic_cast a void* - if ( o != NULL) + if ( o != nullptr) { TickNextTickData *t = (TickNextTickData *) o; return x == t->x && y == t->y && z == t->z && Tile::isMatching(tileId, t->tileId); diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp index ef1b7e358..7ab09928f 100644 --- a/Minecraft.World/Tile.cpp +++ b/Minecraft.World/Tile.cpp @@ -21,18 +21,18 @@ wstring Tile::TILE_DESCRIPTION_PREFIX = L"Tile."; const float Tile::INDESTRUCTIBLE_DESTROY_TIME = -1.0f; -Tile::SoundType *Tile::SOUND_NORMAL = NULL; -Tile::SoundType *Tile::SOUND_WOOD = NULL; -Tile::SoundType *Tile::SOUND_GRAVEL = NULL; -Tile::SoundType *Tile::SOUND_GRASS = NULL; -Tile::SoundType *Tile::SOUND_STONE = NULL; -Tile::SoundType *Tile::SOUND_METAL = NULL; -Tile::SoundType *Tile::SOUND_GLASS = NULL; -Tile::SoundType *Tile::SOUND_CLOTH = NULL; -Tile::SoundType *Tile::SOUND_SAND = NULL; -Tile::SoundType *Tile::SOUND_SNOW = NULL; -Tile::SoundType *Tile::SOUND_LADDER = NULL; -Tile::SoundType *Tile::SOUND_ANVIL = NULL; +Tile::SoundType *Tile::SOUND_NORMAL = nullptr; +Tile::SoundType *Tile::SOUND_WOOD = nullptr; +Tile::SoundType *Tile::SOUND_GRAVEL = nullptr; +Tile::SoundType *Tile::SOUND_GRASS = nullptr; +Tile::SoundType *Tile::SOUND_STONE = nullptr; +Tile::SoundType *Tile::SOUND_METAL = nullptr; +Tile::SoundType *Tile::SOUND_GLASS = nullptr; +Tile::SoundType *Tile::SOUND_CLOTH = nullptr; +Tile::SoundType *Tile::SOUND_SAND = nullptr; +Tile::SoundType *Tile::SOUND_SNOW = nullptr; +Tile::SoundType *Tile::SOUND_LADDER = nullptr; +Tile::SoundType *Tile::SOUND_ANVIL = nullptr; bool Tile::solid[TILE_NUM_COUNT]; int Tile::lightBlock[TILE_NUM_COUNT]; @@ -42,183 +42,183 @@ unsigned char Tile::_sendTileData[TILE_NUM_COUNT]; // 4J changed - was bool, no bool Tile::mipmapEnable[TILE_NUM_COUNT]; bool Tile::propagate[TILE_NUM_COUNT]; -Tile **Tile::tiles = NULL; - -Tile *Tile::stone = NULL; -GrassTile *Tile::grass = NULL; -Tile *Tile::dirt = NULL; -Tile *Tile::cobblestone = NULL; -Tile *Tile::wood = NULL; -Tile *Tile::sapling = NULL; -Tile *Tile::unbreakable = NULL; -LiquidTile *Tile::water = NULL; -Tile *Tile::calmWater = NULL; -LiquidTile *Tile::lava = NULL; -Tile *Tile::calmLava = NULL; -Tile *Tile::sand = NULL; -Tile *Tile::gravel = NULL; -Tile *Tile::goldOre = NULL; -Tile *Tile::ironOre = NULL; -Tile *Tile::coalOre = NULL; -Tile *Tile::treeTrunk = NULL; -LeafTile *Tile::leaves = NULL; -Tile *Tile::sponge = NULL; -Tile *Tile::glass = NULL; -Tile *Tile::lapisOre = NULL; -Tile *Tile::lapisBlock = NULL; -Tile *Tile::dispenser = NULL; -Tile *Tile::sandStone = NULL; -Tile *Tile::noteblock = NULL; -Tile *Tile::bed = NULL; -Tile *Tile::goldenRail = NULL; -Tile *Tile::detectorRail = NULL; -PistonBaseTile *Tile::pistonStickyBase = NULL; -Tile *Tile::web = NULL; -TallGrass *Tile::tallgrass = NULL; -DeadBushTile *Tile::deadBush = NULL; -PistonBaseTile *Tile::pistonBase = NULL; -PistonExtensionTile *Tile::pistonExtension = NULL; -Tile *Tile::wool = NULL; -PistonMovingPiece *Tile::pistonMovingPiece = NULL; -Bush *Tile::flower = NULL; -Bush *Tile::rose = NULL; -Bush *Tile::mushroom_brown = NULL; -Bush *Tile::mushroom_red = NULL; -Tile *Tile::goldBlock = NULL; -Tile *Tile::ironBlock = NULL; -HalfSlabTile *Tile::stoneSlab = NULL; -HalfSlabTile *Tile::stoneSlabHalf = NULL; -Tile *Tile::redBrick = NULL; -Tile *Tile::tnt = NULL; -Tile *Tile::bookshelf = NULL; -Tile *Tile::mossyCobblestone = NULL; -Tile *Tile::obsidian = NULL; -Tile *Tile::torch = NULL; -FireTile *Tile::fire = NULL; -Tile *Tile::mobSpawner = NULL; -Tile *Tile::stairs_wood = NULL; -ChestTile *Tile::chest = NULL; -RedStoneDustTile *Tile::redStoneDust = NULL; -Tile *Tile::diamondOre = NULL; -Tile *Tile::diamondBlock = NULL; -Tile *Tile::workBench = NULL; -Tile *Tile::wheat = NULL; -Tile *Tile::farmland = NULL; -Tile *Tile::furnace = NULL; -Tile *Tile::furnace_lit = NULL; -Tile *Tile::sign = NULL; -Tile *Tile::door_wood = NULL; -Tile *Tile::ladder = NULL; -Tile *Tile::rail = NULL; -Tile *Tile::stairs_stone = NULL; -Tile *Tile::wallSign = NULL; -Tile *Tile::lever = NULL; -Tile *Tile::pressurePlate_stone = NULL; -Tile *Tile::door_iron = NULL; -Tile *Tile::pressurePlate_wood = NULL; -Tile *Tile::redStoneOre = NULL; -Tile *Tile::redStoneOre_lit = NULL; -Tile *Tile::redstoneTorch_off = NULL; -Tile *Tile::redstoneTorch_on = NULL; -Tile *Tile::button = NULL; -Tile *Tile::topSnow = NULL; -Tile *Tile::ice = NULL; -Tile *Tile::snow = NULL; -Tile *Tile::cactus = NULL; -Tile *Tile::clay = NULL; -Tile *Tile::reeds = NULL; -Tile *Tile::jukebox = NULL; -Tile *Tile::fence = NULL; -Tile *Tile::pumpkin = NULL; -Tile *Tile::netherRack = NULL; -Tile *Tile::soulsand = NULL; -Tile *Tile::glowstone = NULL; -PortalTile *Tile::portalTile = NULL; -Tile *Tile::litPumpkin = NULL; -Tile *Tile::cake = NULL; -RepeaterTile *Tile::diode_off = NULL; -RepeaterTile *Tile::diode_on = NULL; -Tile *Tile::stained_glass = NULL; -Tile *Tile::trapdoor = NULL; - -Tile *Tile::monsterStoneEgg = NULL; -Tile *Tile::stoneBrick = NULL; -Tile *Tile::hugeMushroom_brown = NULL; -Tile *Tile::hugeMushroom_red = NULL; -Tile *Tile::ironFence = NULL; -Tile *Tile::thinGlass = NULL; -Tile *Tile::melon = NULL; -Tile *Tile::pumpkinStem = NULL; -Tile *Tile::melonStem = NULL; -Tile *Tile::vine = NULL; -Tile *Tile::fenceGate = NULL; -Tile *Tile::stairs_bricks = NULL; -Tile *Tile::stairs_stoneBrickSmooth = NULL; - -MycelTile *Tile::mycel = NULL; -Tile *Tile::waterLily = NULL; -Tile *Tile::netherBrick = NULL; -Tile *Tile::netherFence = NULL; -Tile *Tile::stairs_netherBricks = NULL; -Tile *Tile::netherStalk = NULL; -Tile *Tile::enchantTable = NULL; -Tile *Tile::brewingStand = NULL; -CauldronTile *Tile::cauldron = NULL; -Tile *Tile::endPortalTile = NULL; -Tile *Tile::endPortalFrameTile = NULL; -Tile *Tile::endStone = NULL; -Tile *Tile::dragonEgg = NULL; -Tile *Tile::redstoneLight = NULL; -Tile *Tile::redstoneLight_lit = NULL; +Tile **Tile::tiles = nullptr; + +Tile *Tile::stone = nullptr; +GrassTile *Tile::grass = nullptr; +Tile *Tile::dirt = nullptr; +Tile *Tile::cobblestone = nullptr; +Tile *Tile::wood = nullptr; +Tile *Tile::sapling = nullptr; +Tile *Tile::unbreakable = nullptr; +LiquidTile *Tile::water = nullptr; +Tile *Tile::calmWater = nullptr; +LiquidTile *Tile::lava = nullptr; +Tile *Tile::calmLava = nullptr; +Tile *Tile::sand = nullptr; +Tile *Tile::gravel = nullptr; +Tile *Tile::goldOre = nullptr; +Tile *Tile::ironOre = nullptr; +Tile *Tile::coalOre = nullptr; +Tile *Tile::treeTrunk = nullptr; +LeafTile *Tile::leaves = nullptr; +Tile *Tile::sponge = nullptr; +Tile *Tile::glass = nullptr; +Tile *Tile::lapisOre = nullptr; +Tile *Tile::lapisBlock = nullptr; +Tile *Tile::dispenser = nullptr; +Tile *Tile::sandStone = nullptr; +Tile *Tile::noteblock = nullptr; +Tile *Tile::bed = nullptr; +Tile *Tile::goldenRail = nullptr; +Tile *Tile::detectorRail = nullptr; +PistonBaseTile *Tile::pistonStickyBase = nullptr; +Tile *Tile::web = nullptr; +TallGrass *Tile::tallgrass = nullptr; +DeadBushTile *Tile::deadBush = nullptr; +PistonBaseTile *Tile::pistonBase = nullptr; +PistonExtensionTile *Tile::pistonExtension = nullptr; +Tile *Tile::wool = nullptr; +PistonMovingPiece *Tile::pistonMovingPiece = nullptr; +Bush *Tile::flower = nullptr; +Bush *Tile::rose = nullptr; +Bush *Tile::mushroom_brown = nullptr; +Bush *Tile::mushroom_red = nullptr; +Tile *Tile::goldBlock = nullptr; +Tile *Tile::ironBlock = nullptr; +HalfSlabTile *Tile::stoneSlab = nullptr; +HalfSlabTile *Tile::stoneSlabHalf = nullptr; +Tile *Tile::redBrick = nullptr; +Tile *Tile::tnt = nullptr; +Tile *Tile::bookshelf = nullptr; +Tile *Tile::mossyCobblestone = nullptr; +Tile *Tile::obsidian = nullptr; +Tile *Tile::torch = nullptr; +FireTile *Tile::fire = nullptr; +Tile *Tile::mobSpawner = nullptr; +Tile *Tile::stairs_wood = nullptr; +ChestTile *Tile::chest = nullptr; +RedStoneDustTile *Tile::redStoneDust = nullptr; +Tile *Tile::diamondOre = nullptr; +Tile *Tile::diamondBlock = nullptr; +Tile *Tile::workBench = nullptr; +Tile *Tile::wheat = nullptr; +Tile *Tile::farmland = nullptr; +Tile *Tile::furnace = nullptr; +Tile *Tile::furnace_lit = nullptr; +Tile *Tile::sign = nullptr; +Tile *Tile::door_wood = nullptr; +Tile *Tile::ladder = nullptr; +Tile *Tile::rail = nullptr; +Tile *Tile::stairs_stone = nullptr; +Tile *Tile::wallSign = nullptr; +Tile *Tile::lever = nullptr; +Tile *Tile::pressurePlate_stone = nullptr; +Tile *Tile::door_iron = nullptr; +Tile *Tile::pressurePlate_wood = nullptr; +Tile *Tile::redStoneOre = nullptr; +Tile *Tile::redStoneOre_lit = nullptr; +Tile *Tile::redstoneTorch_off = nullptr; +Tile *Tile::redstoneTorch_on = nullptr; +Tile *Tile::button = nullptr; +Tile *Tile::topSnow = nullptr; +Tile *Tile::ice = nullptr; +Tile *Tile::snow = nullptr; +Tile *Tile::cactus = nullptr; +Tile *Tile::clay = nullptr; +Tile *Tile::reeds = nullptr; +Tile *Tile::jukebox = nullptr; +Tile *Tile::fence = nullptr; +Tile *Tile::pumpkin = nullptr; +Tile *Tile::netherRack = nullptr; +Tile *Tile::soulsand = nullptr; +Tile *Tile::glowstone = nullptr; +PortalTile *Tile::portalTile = nullptr; +Tile *Tile::litPumpkin = nullptr; +Tile *Tile::cake = nullptr; +RepeaterTile *Tile::diode_off = nullptr; +RepeaterTile *Tile::diode_on = nullptr; +Tile *Tile::stained_glass = nullptr; +Tile *Tile::trapdoor = nullptr; + +Tile *Tile::monsterStoneEgg = nullptr; +Tile *Tile::stoneBrick = nullptr; +Tile *Tile::hugeMushroom_brown = nullptr; +Tile *Tile::hugeMushroom_red = nullptr; +Tile *Tile::ironFence = nullptr; +Tile *Tile::thinGlass = nullptr; +Tile *Tile::melon = nullptr; +Tile *Tile::pumpkinStem = nullptr; +Tile *Tile::melonStem = nullptr; +Tile *Tile::vine = nullptr; +Tile *Tile::fenceGate = nullptr; +Tile *Tile::stairs_bricks = nullptr; +Tile *Tile::stairs_stoneBrickSmooth = nullptr; + +MycelTile *Tile::mycel = nullptr; +Tile *Tile::waterLily = nullptr; +Tile *Tile::netherBrick = nullptr; +Tile *Tile::netherFence = nullptr; +Tile *Tile::stairs_netherBricks = nullptr; +Tile *Tile::netherStalk = nullptr; +Tile *Tile::enchantTable = nullptr; +Tile *Tile::brewingStand = nullptr; +CauldronTile *Tile::cauldron = nullptr; +Tile *Tile::endPortalTile = nullptr; +Tile *Tile::endPortalFrameTile = nullptr; +Tile *Tile::endStone = nullptr; +Tile *Tile::dragonEgg = nullptr; +Tile *Tile::redstoneLight = nullptr; +Tile *Tile::redstoneLight_lit = nullptr; // TU9 -Tile *Tile::stairs_sandstone = NULL; -Tile *Tile::woodStairsDark = NULL; -Tile *Tile::woodStairsBirch = NULL; -Tile *Tile::woodStairsJungle = NULL; -Tile *Tile::commandBlock = NULL; -BeaconTile *Tile::beacon = NULL; -Tile *Tile::button_wood = NULL; -HalfSlabTile *Tile::woodSlab = NULL; -HalfSlabTile *Tile::woodSlabHalf = NULL; - -Tile *Tile::emeraldOre = NULL; -Tile *Tile::enderChest = NULL; -TripWireSourceTile *Tile::tripWireSource = NULL; -Tile *Tile::tripWire = NULL; -Tile *Tile::emeraldBlock = NULL; - - -Tile *Tile::cocoa = NULL; -Tile *Tile::skull = NULL; - -Tile *Tile::cobbleWall = NULL; -Tile *Tile::flowerPot = NULL; -Tile *Tile::carrots = NULL; -Tile *Tile::potatoes = NULL; -Tile *Tile::anvil = NULL; -Tile *Tile::chest_trap = NULL; -Tile *Tile::weightedPlate_light = NULL; -Tile *Tile::weightedPlate_heavy = NULL; -ComparatorTile *Tile::comparator_off = NULL; -ComparatorTile *Tile::comparator_on = NULL; - -DaylightDetectorTile *Tile::daylightDetector = NULL; -Tile *Tile::redstoneBlock = NULL; - -Tile *Tile::netherQuartz = NULL; -HopperTile *Tile::hopper = NULL; -Tile *Tile::quartzBlock = NULL; -Tile *Tile::stairs_quartz = NULL; -Tile *Tile::activatorRail = NULL; -Tile *Tile::dropper = NULL; -Tile *Tile::clayHardened_colored = NULL; -Tile *Tile::stained_glass_pane = NULL; - -Tile *Tile::hayBlock = NULL; -Tile *Tile::woolCarpet = NULL; -Tile *Tile::clayHardened = NULL; -Tile *Tile::coalBlock = NULL; +Tile *Tile::stairs_sandstone = nullptr; +Tile *Tile::woodStairsDark = nullptr; +Tile *Tile::woodStairsBirch = nullptr; +Tile *Tile::woodStairsJungle = nullptr; +Tile *Tile::commandBlock = nullptr; +BeaconTile *Tile::beacon = nullptr; +Tile *Tile::button_wood = nullptr; +HalfSlabTile *Tile::woodSlab = nullptr; +HalfSlabTile *Tile::woodSlabHalf = nullptr; + +Tile *Tile::emeraldOre = nullptr; +Tile *Tile::enderChest = nullptr; +TripWireSourceTile *Tile::tripWireSource = nullptr; +Tile *Tile::tripWire = nullptr; +Tile *Tile::emeraldBlock = nullptr; + + +Tile *Tile::cocoa = nullptr; +Tile *Tile::skull = nullptr; + +Tile *Tile::cobbleWall = nullptr; +Tile *Tile::flowerPot = nullptr; +Tile *Tile::carrots = nullptr; +Tile *Tile::potatoes = nullptr; +Tile *Tile::anvil = nullptr; +Tile *Tile::chest_trap = nullptr; +Tile *Tile::weightedPlate_light = nullptr; +Tile *Tile::weightedPlate_heavy = nullptr; +ComparatorTile *Tile::comparator_off = nullptr; +ComparatorTile *Tile::comparator_on = nullptr; + +DaylightDetectorTile *Tile::daylightDetector = nullptr; +Tile *Tile::redstoneBlock = nullptr; + +Tile *Tile::netherQuartz = nullptr; +HopperTile *Tile::hopper = nullptr; +Tile *Tile::quartzBlock = nullptr; +Tile *Tile::stairs_quartz = nullptr; +Tile *Tile::activatorRail = nullptr; +Tile *Tile::dropper = nullptr; +Tile *Tile::clayHardened_colored = nullptr; +Tile *Tile::stained_glass_pane = nullptr; + +Tile *Tile::hayBlock = nullptr; +Tile *Tile::woolCarpet = nullptr; +Tile *Tile::clayHardened = nullptr; +Tile *Tile::coalBlock = nullptr; DWORD Tile::tlsIdxShape = TlsAlloc(); @@ -475,9 +475,9 @@ void Tile::staticCtor() for (int i = 0; i < 256; i++) { - if ( Tile::tiles[i] != NULL ) + if ( Tile::tiles[i] != nullptr ) { - if( Item::items[i] == NULL) + if( Item::items[i] == nullptr) { Item::items[i] = new TileItem(i - 256); Tile::tiles[i]->init(); @@ -485,7 +485,7 @@ void Tile::staticCtor() bool propagate = false; if (i > 0 && Tile::tiles[i]->getRenderShape() == Tile::SHAPE_STAIRS) propagate = true; - if (i > 0 && dynamic_cast(Tile::tiles[i]) != NULL) + if (i > 0 && dynamic_cast(Tile::tiles[i]) != nullptr) { propagate = true; } @@ -549,7 +549,7 @@ Tile::Tile(int id, Material *material, bool isSolidRender) _init(id,material, isSolidRender); m_iMaterial=Item::eMaterial_undefined; m_iBaseItemType=Item::eBaseItemType_undefined; - icon = NULL; + icon = nullptr; } Tile *Tile::sendTileData(unsigned char importantMask/*=15*/) @@ -610,7 +610,7 @@ Tile *Tile::setExplodeable(float explosionResistance) bool Tile::isSolidBlockingTile(int t) { Tile *tile = Tile::tiles[t]; - if (tile == NULL) return false; + if (tile == nullptr) return false; return tile->material->isSolidBlocking() && tile->isCubeShaped() && !tile->isSignalSource(); } @@ -779,13 +779,13 @@ Icon *Tile::getTexture(LevelSource *level, int x, int y, int z, int face) for( int i = 0; (i < 6) && opaque; i++ ) { int t = level->getTile(x + axo[i], y + ayo[i] , z + azo[i]); - if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) ) + if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == nullptr ) || !Tile::tiles[t]->isSolidRender() ) ) { opaque = false; } } - Icon *icon = NULL; + Icon *icon = nullptr; if(opaque) { Tile::leaves->setFancy(false); @@ -822,7 +822,7 @@ AABB *Tile::getTileAABB(Level *level, int x, int y, int z) void Tile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr source) { AABB *aabb = getAABB(level, x, y, z); - if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb); + if (aabb != nullptr && box->intersects(aabb)) boxes->push_back(aabb); } AABB *Tile::getAABB(Level *level, int x, int y, int z) @@ -975,16 +975,16 @@ HitResult *Tile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b) Vec3 *zh0 = a->clipZ(b, tls->zz0); Vec3 *zh1 = a->clipZ(b, tls->zz1); - Vec3 *closest = NULL; + Vec3 *closest = nullptr; - if (containsX(xh0) && (closest == NULL || a->distanceToSqr(xh0) < a->distanceToSqr(closest))) closest = xh0; - if (containsX(xh1) && (closest == NULL || a->distanceToSqr(xh1) < a->distanceToSqr(closest))) closest = xh1; - if (containsY(yh0) && (closest == NULL || a->distanceToSqr(yh0) < a->distanceToSqr(closest))) closest = yh0; - if (containsY(yh1) && (closest == NULL || a->distanceToSqr(yh1) < a->distanceToSqr(closest))) closest = yh1; - if (containsZ(zh0) && (closest == NULL || a->distanceToSqr(zh0) < a->distanceToSqr(closest))) closest = zh0; - if (containsZ(zh1) && (closest == NULL || a->distanceToSqr(zh1) < a->distanceToSqr(closest))) closest = zh1; + if (containsX(xh0) && (closest == nullptr || a->distanceToSqr(xh0) < a->distanceToSqr(closest))) closest = xh0; + if (containsX(xh1) && (closest == nullptr || a->distanceToSqr(xh1) < a->distanceToSqr(closest))) closest = xh1; + if (containsY(yh0) && (closest == nullptr || a->distanceToSqr(yh0) < a->distanceToSqr(closest))) closest = yh0; + if (containsY(yh1) && (closest == nullptr || a->distanceToSqr(yh1) < a->distanceToSqr(closest))) closest = yh1; + if (containsZ(zh0) && (closest == nullptr || a->distanceToSqr(zh0) < a->distanceToSqr(closest))) closest = zh0; + if (containsZ(zh1) && (closest == nullptr || a->distanceToSqr(zh1) < a->distanceToSqr(closest))) closest = zh1; - if (closest == NULL) return NULL; + if (closest == nullptr) return nullptr; int face = -1; @@ -1000,7 +1000,7 @@ HitResult *Tile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b) bool Tile::containsX(Vec3 *v) { - if( v == NULL) return false; + if( v == nullptr) return false; ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile @@ -1010,7 +1010,7 @@ bool Tile::containsX(Vec3 *v) bool Tile::containsY(Vec3 *v) { - if( v == NULL) return false; + if( v == nullptr) return false; ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile @@ -1020,7 +1020,7 @@ bool Tile::containsY(Vec3 *v) bool Tile::containsZ(Vec3 *v) { - if( v == NULL) return false; + if( v == nullptr) return false; ThreadStorage *tls = static_cast(TlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile @@ -1194,7 +1194,7 @@ void Tile::playerDestroy(Level *level, shared_ptr player, int x, int y, // 4J Stu - Special case - only record a crop destroy if is fully grown if( id==Tile::wheat_Id ) { - if( Tile::wheat->getResource(data, NULL, 0) > 0 ) + if( Tile::wheat->getResource(data, nullptr, 0) > 0 ) player->awardStat( GenericStats::blocksMined(id), GenericStats::param_blocksMined(id,data,1) @@ -1202,7 +1202,7 @@ void Tile::playerDestroy(Level *level, shared_ptr player, int x, int y, } else if (id == Tile::potatoes_Id) { - if (Tile::potatoes->getResource(data, NULL, 0) > 0) + if (Tile::potatoes->getResource(data, nullptr, 0) > 0) player->awardStat( GenericStats::blocksMined(id), GenericStats::param_blocksMined(id,data,1) @@ -1210,7 +1210,7 @@ void Tile::playerDestroy(Level *level, shared_ptr player, int x, int y, } else if (id == Tile::carrots_Id) { - if (Tile::potatoes->getResource(data, NULL, 0) > 0) + if (Tile::potatoes->getResource(data, nullptr, 0) > 0) player->awardStat( GenericStats::blocksMined(id), GenericStats::param_blocksMined(id,data,1) @@ -1233,7 +1233,7 @@ void Tile::playerDestroy(Level *level, shared_ptr player, int x, int y, if (isSilkTouchable() && EnchantmentHelper::hasSilkTouch(player)) { shared_ptr item = getSilkTouchItemInstance(data); - if (item != NULL) + if (item != nullptr) { popResource(level, x, y, z, item); } @@ -1388,7 +1388,7 @@ bool Tile::isMatching(int tileIdA, int tileIdB) { return true; } - if (tileIdA == 0 || tileIdB == 0 || tiles[tileIdA] == NULL || tiles[tileIdB] == NULL) + if (tileIdA == 0 || tileIdB == 0 || tiles[tileIdA] == nullptr || tiles[tileIdB] == nullptr) { return false; } diff --git a/Minecraft.World/TileEntity.cpp b/Minecraft.World/TileEntity.cpp index 1eb9cab2d..1fff44bb3 100644 --- a/Minecraft.World/TileEntity.cpp +++ b/Minecraft.World/TileEntity.cpp @@ -46,11 +46,11 @@ void TileEntity::setId(tileEntityCreateFn createFn, eINSTANCEOF clas, wstring id TileEntity::TileEntity() { - level = NULL; + level = nullptr; x = y = z = 0; remove = false; data = -1; - tile = NULL; + tile = nullptr; renderRemoveStage = e_RenderRemoveStageKeep; } @@ -66,7 +66,7 @@ void TileEntity::setLevel(Level *level) bool TileEntity::hasLevel() { - return level != NULL; + return level != nullptr; } void TileEntity::load(CompoundTag *tag) @@ -101,7 +101,7 @@ shared_ptr TileEntity::loadStatic(CompoundTag *tag) auto it = idCreateMap.find(tag->getString(L"id")); if (it != idCreateMap.end()) entity = shared_ptr(it->second()); - if (entity != NULL) + if (entity != nullptr) { entity->load(tag); } @@ -129,11 +129,11 @@ void TileEntity::setData(int data, int updateFlags) void TileEntity::setChanged() { - if (level != NULL) + if (level != nullptr) { data = level->getData(x, y, z); level->tileEntityChanged(x, y, z, shared_from_this()); - if (getTile() != NULL) level->updateNeighbourForOutputSignal(x, y, z, getTile()->id); + if (getTile() != nullptr) level->updateNeighbourForOutputSignal(x, y, z, getTile()->id); } } @@ -152,7 +152,7 @@ double TileEntity::getViewDistance() Tile *TileEntity::getTile() { - if( tile == NULL ) tile = Tile::tiles[level->getTile(x, y, z)]; + if( tile == nullptr ) tile = Tile::tiles[level->getTile(x, y, z)]; return tile; } @@ -183,7 +183,7 @@ bool TileEntity::triggerEvent(int b0, int b1) void TileEntity::clearCache() { - tile = NULL; + tile = nullptr; data = -1; } diff --git a/Minecraft.World/TileEntityDataPacket.cpp b/Minecraft.World/TileEntityDataPacket.cpp index 10d64bb0a..a30f7873a 100644 --- a/Minecraft.World/TileEntityDataPacket.cpp +++ b/Minecraft.World/TileEntityDataPacket.cpp @@ -10,7 +10,7 @@ void TileEntityDataPacket::_init() { x = y = z = 0; type = TYPE_MOB_SPAWNER; - tag = NULL; + tag = nullptr; } diff --git a/Minecraft.World/TileItem.cpp b/Minecraft.World/TileItem.cpp index ce313dd6c..8d22594db 100644 --- a/Minecraft.World/TileItem.cpp +++ b/Minecraft.World/TileItem.cpp @@ -20,7 +20,7 @@ using namespace std; TileItem::TileItem(int id) : Item(id) { this->tileId = id + 256; - itemIcon = NULL; + itemIcon = nullptr; } int TileItem::getTileId() @@ -39,7 +39,7 @@ int TileItem::getIconType() Icon *TileItem::getIcon(int auxValue) { - if (itemIcon != NULL) + if (itemIcon != nullptr) { return itemIcon; } @@ -128,7 +128,7 @@ bool TileItem::useOn(shared_ptr instance, shared_ptr playe // // if(iPlaceSound==-1) // { - // strcpy(szPlaceSoundName,"NULL"); + // strcpy(szPlaceSoundName,"nullptr"); // } // else // { @@ -136,7 +136,7 @@ bool TileItem::useOn(shared_ptr instance, shared_ptr playe // } // if(iStepSound==-1) // { - // strcpy(szStepSoundName,"NULL"); + // strcpy(szStepSoundName,"nullptr"); // } // else // { diff --git a/Minecraft.World/TntTile.cpp b/Minecraft.World/TntTile.cpp index 430755fc9..1b16a3752 100644 --- a/Minecraft.World/TntTile.cpp +++ b/Minecraft.World/TntTile.cpp @@ -12,8 +12,8 @@ TntTile::TntTile(int id) : Tile(id, Material::explosive) { - iconTop = NULL; - iconBottom = NULL; + iconTop = nullptr; + iconBottom = nullptr; } Icon *TntTile::getTexture(int face, int data) @@ -87,7 +87,7 @@ void TntTile::destroy(Level *level, int x, int y, int z, int data, shared_ptr
  • player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param { if (soundOnly) return false; - if (player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::flintAndSteel_Id) + if (player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::flintAndSteel_Id) { destroy(level, x, y, z, EXPLODE_BIT, player); level->removeTile(x, y, z); diff --git a/Minecraft.World/TorchTile.cpp b/Minecraft.World/TorchTile.cpp index cc3775743..129a3b13b 100644 --- a/Minecraft.World/TorchTile.cpp +++ b/Minecraft.World/TorchTile.cpp @@ -11,7 +11,7 @@ TorchTile::TorchTile(int id) : Tile(id, Material::decoration,isSolidRender()) AABB *TorchTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } AABB *TorchTile::getTileAABB(Level *level, int x, int y, int z) diff --git a/Minecraft.World/TradeWithPlayerGoal.cpp b/Minecraft.World/TradeWithPlayerGoal.cpp index e8b791d13..155525bc4 100644 --- a/Minecraft.World/TradeWithPlayerGoal.cpp +++ b/Minecraft.World/TradeWithPlayerGoal.cpp @@ -19,7 +19,7 @@ bool TradeWithPlayerGoal::canUse() if (mob->hurtMarked) return false; shared_ptr trader = mob->getTradingPlayer(); - if (trader == NULL) + if (trader == nullptr) { // no interaction return false; diff --git a/Minecraft.World/TrapDoorTile.cpp b/Minecraft.World/TrapDoorTile.cpp index 9b668e3fb..6ea64172e 100644 --- a/Minecraft.World/TrapDoorTile.cpp +++ b/Minecraft.World/TrapDoorTile.cpp @@ -212,5 +212,5 @@ bool TrapDoorTile::attachesTo(int id) } Tile *tile = Tile::tiles[id]; - return tile != NULL && (tile->material->isSolidBlocking() && tile->isCubeShaped()) || tile == Tile::glowstone || (dynamic_cast(tile) != NULL) || (dynamic_cast(tile) != NULL); + return tile != nullptr && (tile->material->isSolidBlocking() && tile->isCubeShaped()) || tile == Tile::glowstone || (dynamic_cast(tile) != nullptr) || (dynamic_cast(tile) != nullptr); } \ No newline at end of file diff --git a/Minecraft.World/TrapMenu.cpp b/Minecraft.World/TrapMenu.cpp index 657578398..a89069c7c 100644 --- a/Minecraft.World/TrapMenu.cpp +++ b/Minecraft.World/TrapMenu.cpp @@ -40,7 +40,7 @@ shared_ptr TrapMenu::quickMoveStack(shared_ptr player, int { shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - if (slot != NULL && slot->hasItem()) + if (slot != nullptr && slot->hasItem()) { shared_ptr stack = slot->getItem(); clicked = stack->copy(); diff --git a/Minecraft.World/TreeFeature.cpp b/Minecraft.World/TreeFeature.cpp index f27258af4..2bfec1479 100644 --- a/Minecraft.World/TreeFeature.cpp +++ b/Minecraft.World/TreeFeature.cpp @@ -19,7 +19,7 @@ bool TreeFeature::place(Level *level, Random *random, int x, int y, int z) if (y < 1 || y + treeHeight + 1 > Level::maxBuildHeight) return false; // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != NULL) + if(app.getLevelGenerationOptions() != nullptr) { PIXBeginNamedEvent(0,"TreeFeature checking intersects"); LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); diff --git a/Minecraft.World/TripWireSourceTile.cpp b/Minecraft.World/TripWireSourceTile.cpp index c92713341..fcd7564d3 100644 --- a/Minecraft.World/TripWireSourceTile.cpp +++ b/Minecraft.World/TripWireSourceTile.cpp @@ -12,7 +12,7 @@ TripWireSourceTile::TripWireSourceTile(int id) : Tile(id, Material::decoration, AABB *TripWireSourceTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool TripWireSourceTile::blocksLight() diff --git a/Minecraft.World/TripWireTile.cpp b/Minecraft.World/TripWireTile.cpp index fb3fe150c..ee302af26 100644 --- a/Minecraft.World/TripWireTile.cpp +++ b/Minecraft.World/TripWireTile.cpp @@ -20,7 +20,7 @@ int TripWireTile::getTickDelay(Level *level) AABB *TripWireTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool TripWireTile::blocksLight() @@ -106,7 +106,7 @@ void TripWireTile::playerWillDestroy(Level *level, int x, int y, int z, int data { if (level->isClientSide) return; - if (player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears_Id) + if (player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears_Id) { level->setData(x, y, z, data | MASK_DISARMED, Tile::UPDATE_NONE); } diff --git a/Minecraft.World/Vec3.cpp b/Minecraft.World/Vec3.cpp index 69a332ccf..b513c1499 100644 --- a/Minecraft.World/Vec3.cpp +++ b/Minecraft.World/Vec3.cpp @@ -3,7 +3,7 @@ #include "AABB.h" DWORD Vec3::tlsIdx = 0; -Vec3::ThreadStorage *Vec3::tlsDefault = NULL; +Vec3::ThreadStorage *Vec3::tlsDefault = nullptr; Vec3::ThreadStorage::ThreadStorage() { @@ -19,7 +19,7 @@ Vec3::ThreadStorage::~ThreadStorage() void Vec3::CreateNewThreadStorage() { ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == NULL ) + if(tlsDefault == nullptr ) { tlsIdx = TlsAlloc(); tlsDefault = tls; @@ -157,10 +157,10 @@ Vec3 *Vec3::clipX(Vec3 *b, double xt) double yd = b->y - y; double zd = b->z - z; - if (xd * xd < 0.0000001f) return NULL; + if (xd * xd < 0.0000001f) return nullptr; double d = (xt - x) / xd; - if (d < 0 || d > 1) return NULL; + if (d < 0 || d > 1) return nullptr; return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); } @@ -170,10 +170,10 @@ Vec3 *Vec3::clipY(Vec3 *b, double yt) double yd = b->y - y; double zd = b->z - z; - if (yd * yd < 0.0000001f) return NULL; + if (yd * yd < 0.0000001f) return nullptr; double d = (yt - y) / yd; - if (d < 0 || d > 1) return NULL; + if (d < 0 || d > 1) return nullptr; return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); } @@ -183,10 +183,10 @@ Vec3 *Vec3::clipZ(Vec3 *b, double zt) double yd = b->y - y; double zd = b->z - z; - if (zd * zd < 0.0000001f) return NULL; + if (zd * zd < 0.0000001f) return nullptr; double d = (zt - z) / zd; - if (d < 0 || d > 1) return NULL; + if (d < 0 || d > 1) return nullptr; return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); } diff --git a/Minecraft.World/Village.cpp b/Minecraft.World/Village.cpp index a72319fe9..705815b95 100644 --- a/Minecraft.World/Village.cpp +++ b/Minecraft.World/Village.cpp @@ -25,7 +25,7 @@ Village::Village() golemCount = 0; noBreedTimer = 0; - level = NULL; + level = nullptr; } Village::Village(Level *level) @@ -69,7 +69,7 @@ void Village::tick(int tick) if (golemCount < idealGolemCount && doorInfos.size() > 20 && level->random->nextInt(7000) == 0) { Vec3 *spawnPos = findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2); - if (spawnPos != NULL) + if (spawnPos != nullptr) { shared_ptr vg = shared_ptr( new VillagerGolem(level) ); vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z); @@ -103,7 +103,7 @@ Vec3 *Village::findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz) if (!isInside(xx, yy, zz)) continue; if (canSpawnAt(xx, yy, zz, sx, sy, sz)) return Vec3::newTemp(xx, yy, zz); } - return NULL; + return nullptr; } bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz) @@ -215,7 +215,7 @@ shared_ptrVillage::getBestDoorInfo(int x, int y, int z) bool Village::hasDoorInfo(int x, int y, int z) { - return getDoorInfo(x, y, z) != NULL; + return getDoorInfo(x, y, z) != nullptr; } shared_ptr Village::getDoorInfo(int x, int y, int z) @@ -260,7 +260,7 @@ void Village::addAggressor(shared_ptr mob) shared_ptr Village::getClosestAggressor(shared_ptr from) { double closestSqr = Double::MAX_VALUE; - Aggressor *closest = NULL; + Aggressor *closest = nullptr; for(auto& a : aggressors) { double distSqr = a->mob->distanceToSqr(from); @@ -268,7 +268,7 @@ shared_ptr Village::getClosestAggressor(shared_ptr f closest = a; closestSqr = distSqr; } - return closest != NULL ? closest->mob : nullptr; + return closest != nullptr ? closest->mob : nullptr; } shared_ptr Village::getClosestBadStandingPlayer(shared_ptr from) @@ -282,7 +282,7 @@ shared_ptr Village::getClosestBadStandingPlayer(shared_ptr if (isVeryBadStanding(player)) { shared_ptr mob = level->getPlayerByName(player); - if (mob != NULL) + if (mob != nullptr) { double distSqr = mob->distanceToSqr(from); if (distSqr > closestSqr) continue; diff --git a/Minecraft.World/VillageFeature.cpp b/Minecraft.World/VillageFeature.cpp index e1ad19270..bde8a66c2 100644 --- a/Minecraft.World/VillageFeature.cpp +++ b/Minecraft.World/VillageFeature.cpp @@ -82,7 +82,7 @@ bool VillageFeature::isFeatureChunk(int x, int z,bool bIsSuperflat) bool forcePlacement = false; LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); - if( levelGenOptions != NULL ) + if( levelGenOptions != nullptr ) { forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Village); } diff --git a/Minecraft.World/VillagePieces.cpp b/Minecraft.World/VillagePieces.cpp index cee09e800..fbdf05a7e 100644 --- a/Minecraft.World/VillagePieces.cpp +++ b/Minecraft.World/VillagePieces.cpp @@ -101,7 +101,7 @@ int VillagePieces::updatePieceWeight(list *currentPieces) VillagePieces::VillagePiece *VillagePieces::findAndCreatePieceFactory(StartPiece *startPiece, VillagePieces::PieceWeight *piece, list *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { VillagePieces::EPieceClass pieceClass = piece->pieceClass; - VillagePiece *villagePiece = NULL; + VillagePiece *villagePiece = nullptr; if (pieceClass == VillagePieces::EPieceClass_SimpleHouse) { @@ -148,7 +148,7 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec int totalWeight = updatePieceWeight(startPiece->pieceSet); if (totalWeight <= 0) { - return NULL; + return nullptr; } int numAttempts = 0; @@ -168,7 +168,7 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec } VillagePiece *villagePiece = findAndCreatePieceFactory(startPiece, piece, pieces, random, footX, footY, footZ, direction, depth); - if (villagePiece != NULL) + if (villagePiece != nullptr) { piece->placeCount++; startPiece->previousPiece = piece; @@ -186,29 +186,29 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec // attempt to place a light post instead { BoundingBox *box = LightPost::findPieceBox(startPiece, pieces, random, footX, footY, footZ, direction); - if (box != NULL) + if (box != nullptr) { return new LightPost(startPiece, depth, random, box, direction); } delete box; } - return NULL; + return nullptr; } StructurePiece *VillagePieces::generateAndAddPiece(StartPiece *startPiece, list *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { if (depth > MAX_DEPTH) { - return NULL; + return nullptr; } if (abs(footX - startPiece->getBoundingBox()->x0) > 7 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 7 * 16) { - return NULL; + return nullptr; } StructurePiece *newPiece = generatePieceFromSmallDoor(startPiece, pieces, random, footX, footY, footZ, direction, depth + 1); - if (newPiece != NULL) + if (newPiece != nullptr) { int x = (newPiece->boundingBox->x0 + newPiece->boundingBox->x1) / 2; int z = (newPiece->boundingBox->z0 + newPiece->boundingBox->z1) / 2; @@ -223,22 +223,22 @@ StructurePiece *VillagePieces::generateAndAddPiece(StartPiece *startPiece, list< } delete newPiece; } - return NULL; + return nullptr; } StructurePiece *VillagePieces::generateAndAddRoadPiece(StartPiece *startPiece, list *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { if (depth > BASE_ROAD_DEPTH + startPiece->villageSize) { - return NULL; + return nullptr; } if (abs(footX - startPiece->getBoundingBox()->x0) > 7 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 7 * 16) { - return NULL; + return nullptr; } BoundingBox *box = StraightRoad::findPieceBox(startPiece, pieces, random, footX, footY, footZ, direction); - if (box != NULL && box->y0 > LOWEST_Y_POSITION) + if (box != nullptr && box->y0 > LOWEST_Y_POSITION) { StructurePiece *newPiece = new StraightRoad(startPiece, depth, random, box, direction); int x = (newPiece->boundingBox->x0 + newPiece->boundingBox->x1) / 2; @@ -255,12 +255,12 @@ StructurePiece *VillagePieces::generateAndAddRoadPiece(StartPiece *startPiece, l // 4J Stu - The dtor for newPiece will destroy box delete newPiece; } - else if(box != NULL) + else if(box != nullptr) { delete box; } - return NULL; + return nullptr; } VillagePieces::VillagePiece::VillagePiece() @@ -268,7 +268,7 @@ VillagePieces::VillagePiece::VillagePiece() heightPosition = -1; spawnedVillagerCount = 0; isDesertVillage = false; - startPiece = NULL; + startPiece = nullptr; // for reflection } @@ -278,7 +278,7 @@ VillagePieces::VillagePiece::VillagePiece(StartPiece *startPiece, int genDepth) isDesertVillage = false; spawnedVillagerCount = 0; this->startPiece = startPiece; - if (startPiece != NULL) + if (startPiece != nullptr) { this->isDesertVillage = startPiece->isDesertVillage; } @@ -311,7 +311,7 @@ StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernLeft(StartPiec case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); } - return NULL; + return nullptr; } StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernRight(StartPiece *startPiece, list *pieces, Random *random, int yOff, int zOff) @@ -327,7 +327,7 @@ StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernRight(StartPie case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); } - return NULL; + return nullptr; } int VillagePieces::VillagePiece::getAverageGroundHeight(Level *level, BoundingBox *chunkBB) @@ -357,7 +357,7 @@ bool VillagePieces::VillagePiece::isOkBox(BoundingBox *box, StartPiece *startRoo { bool bIsOk = false; - if(box != NULL) + if(box != nullptr) { if( box->y0 > LOWEST_Y_POSITION ) bIsOk = true; @@ -569,10 +569,10 @@ VillagePieces::StartPiece::StartPiece() // for reflection } -VillagePieces::StartPiece::StartPiece(BiomeSource *biomeSource, int genDepth, Random *random, int west, int north, list *pieceSet, int villageSize, Level *level) : Well(NULL, 0, random, west, north) +VillagePieces::StartPiece::StartPiece(BiomeSource *biomeSource, int genDepth, Random *random, int west, int north, list *pieceSet, int villageSize, Level *level) : Well(nullptr, 0, random, west, north) { isLibraryAdded = false; // 4J - added initialiser - previousPiece = NULL; // 4J - added initialiser + previousPiece = nullptr; // 4J - added initialiser this->biomeSource = biomeSource; this->pieceSet = pieceSet; this->villageSize = villageSize; @@ -629,7 +629,7 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list(startPiece), pieces, random, 0, depth); - if (piece != NULL) + if (piece != nullptr) { depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan()); hasHouses = true; @@ -642,7 +642,7 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list(startPiece), pieces, random, 0, depth); - if (piece != NULL) + if (piece != nullptr) { depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan()); hasHouses = true; @@ -696,7 +696,7 @@ BoundingBox *VillagePieces::StraightRoad::findPieceBox(StartPiece *startPiece, l { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, 3, length, direction); - if (isOkBox(box, startPiece) && StructurePiece::findCollisionPiece(pieces, box) == NULL) + if (isOkBox(box, startPiece) && StructurePiece::findCollisionPiece(pieces, box) == nullptr) { return box; } @@ -704,7 +704,7 @@ BoundingBox *VillagePieces::StraightRoad::findPieceBox(StartPiece *startPiece, l length -= 7; } - return NULL; + return nullptr; } bool VillagePieces::StraightRoad::postProcess(Level *level, Random *random, BoundingBox *chunkBB) @@ -753,10 +753,10 @@ VillagePieces::SimpleHouse *VillagePieces::SimpleHouse::createPiece(StartPiece * { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new SimpleHouse(startPiece, genDepth, random, box, direction); @@ -880,10 +880,10 @@ VillagePieces::SmallTemple *VillagePieces::SmallTemple::createPiece(StartPiece * { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new SmallTemple(startPiece, genDepth, random, box, direction); @@ -1022,10 +1022,10 @@ VillagePieces::BookHouse *VillagePieces::BookHouse::createPiece(StartPiece *star { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new BookHouse(startPiece, genDepth, random, box, direction); @@ -1178,10 +1178,10 @@ VillagePieces::SmallHut *VillagePieces::SmallHut::createPiece(StartPiece *startP { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new SmallHut(startPiece, genDepth, random, box, direction); @@ -1284,10 +1284,10 @@ VillagePieces::PigHouse *VillagePieces::PigHouse::createPiece(StartPiece *startP BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new PigHouse(startPiece, genDepth, random, box, direction); @@ -1429,10 +1429,10 @@ VillagePieces::TwoRoomHouse *VillagePieces::TwoRoomHouse::createPiece(StartPiece { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new TwoRoomHouse(startPiece, genDepth, random, box, direction); @@ -1619,10 +1619,10 @@ VillagePieces::Smithy *VillagePieces::Smithy::createPiece(StartPiece *startPiece { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new Smithy(startPiece, genDepth, random, box, direction); @@ -1790,10 +1790,10 @@ VillagePieces::Farmland *VillagePieces::Farmland::createPiece(StartPiece *startP { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new Farmland(startPiece, genDepth, random, box, direction); @@ -1902,10 +1902,10 @@ VillagePieces::DoubleFarmland *VillagePieces::DoubleFarmland::createPiece(StartP { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return new DoubleFarmland(startPiece, genDepth, random, box, direction); @@ -1983,10 +1983,10 @@ BoundingBox *VillagePieces::LightPost::findPieceBox(StartPiece *startPiece, list { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) { delete box; - return NULL; + return nullptr; } return box; diff --git a/Minecraft.World/VillageSiege.cpp b/Minecraft.World/VillageSiege.cpp index 0ce8a4e12..525b0b36d 100644 --- a/Minecraft.World/VillageSiege.cpp +++ b/Minecraft.World/VillageSiege.cpp @@ -83,7 +83,7 @@ bool VillageSiege::tryToSetupSiege() shared_ptr _village = level->villages->getClosestVillage(static_cast(player->x), static_cast(player->y), static_cast(player->z), 1); village = _village; - if (_village == NULL) continue; + if (_village == nullptr) continue; if (_village->getDoorCount() < 10) continue; if (_village->getStableAge() < 20) continue; if (_village->getPopulationSize() < 20) continue; @@ -115,7 +115,7 @@ bool VillageSiege::tryToSetupSiege() if (overlaps) return false; Vec3 *spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ); - if (spawnPos == NULL) continue; + if (spawnPos == nullptr) continue; nextSpawnTime = 0; siegeCount = 20; @@ -127,17 +127,17 @@ bool VillageSiege::tryToSetupSiege() bool VillageSiege::trySpawn() { Vec3 *spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ); - if (spawnPos == NULL) return false; + if (spawnPos == nullptr) return false; shared_ptr mob; { mob = shared_ptr( new Zombie(level) ); - mob->finalizeMobSpawn(NULL); + mob->finalizeMobSpawn(nullptr); mob->setVillager(false); } mob->moveTo(spawnPos->x, spawnPos->y, spawnPos->z, level->random->nextFloat() * 360, 0); level->addEntity(mob); shared_ptr _village = village.lock(); - if( _village == NULL ) return false; + if( _village == nullptr ) return false; Pos *center = _village->getCenter(); mob->restrictTo(center->x, center->y, center->z, _village->getRadius()); @@ -147,7 +147,7 @@ bool VillageSiege::trySpawn() Vec3 *VillageSiege::findRandomSpawnPos(int x, int y, int z) { shared_ptr _village = village.lock(); - if( _village == NULL ) return NULL; + if( _village == nullptr ) return nullptr; for (int i = 0; i < 10; ++i) { @@ -157,5 +157,5 @@ Vec3 *VillageSiege::findRandomSpawnPos(int x, int y, int z) if (!_village->isInside(xx, yy, zz)) continue; if (MobSpawner::isSpawnPositionOk(MobCategory::monster, level, xx, yy, zz)) return Vec3::newTemp(xx, yy, zz); } - return NULL; + return nullptr; } \ No newline at end of file diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp index 94ec5a529..26f5e5740 100644 --- a/Minecraft.World/Villager.cpp +++ b/Minecraft.World/Villager.cpp @@ -38,7 +38,7 @@ void Villager::_init(int profession) village = weak_ptr(); tradingPlayer = weak_ptr(); - offers = NULL; + offers = nullptr; updateMerchantTimer = 0; addRecipeOnUpdate = false; riches = 0; @@ -102,7 +102,7 @@ void Villager::serverAiMobStep() shared_ptr _village = level->villages->getClosestVillage(Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist); village = _village; - if (_village == NULL) clearRestriction(); + if (_village == nullptr) clearRestriction(); else { Pos *center = _village->getCenter(); @@ -137,7 +137,7 @@ void Villager::serverAiMobStep() addOffers(1); addRecipeOnUpdate = false; - if (village.lock() != NULL && !lastPlayerTradeName.empty()) + if (village.lock() != nullptr && !lastPlayerTradeName.empty()) { level->broadcastEntityEvent(shared_from_this(), EntityEvent::VILLAGER_HAPPY); village.lock()->modifyStanding(lastPlayerTradeName, 1); @@ -154,7 +154,7 @@ bool Villager::mobInteract(shared_ptr player) { // [EB]: Truly dislike this code but I don't see another easy way shared_ptr item = player->inventory->getSelected(); - bool holdingSpawnEgg = item != NULL && item->id == Item::spawnEgg_Id; + bool holdingSpawnEgg = item != nullptr && item->id == Item::spawnEgg_Id; if (!holdingSpawnEgg && isAlive() && !isTrading() && !isBaby()) { @@ -182,7 +182,7 @@ void Villager::addAdditonalSaveData(CompoundTag *tag) AgableMob::addAdditonalSaveData(tag); tag->putInt(L"Profession", getProfession()); tag->putInt(L"Riches", riches); - if (offers != NULL) + if (offers != nullptr) { tag->putCompound(L"Offers", offers->createTag()); } @@ -259,7 +259,7 @@ void Villager::setLastHurtByMob(shared_ptr mob) { AgableMob::setLastHurtByMob(mob); shared_ptr _village = village.lock(); - if (_village != NULL && mob != NULL) + if (_village != nullptr && mob != nullptr) { _village->addAggressor(mob); @@ -282,10 +282,10 @@ void Villager::setLastHurtByMob(shared_ptr mob) void Villager::die(DamageSource *source) { shared_ptr _village = village.lock(); - if (_village != NULL) + if (_village != nullptr) { shared_ptr sourceEntity = source->getEntity(); - if (sourceEntity != NULL) + if (sourceEntity != nullptr) { if ( sourceEntity->instanceof(eTYPE_PLAYER) ) { @@ -296,12 +296,12 @@ void Villager::die(DamageSource *source) _village->resetNoBreedTimer(); } } - else if (sourceEntity == NULL) + else if (sourceEntity == nullptr) { // if the villager was killed by the world (such as lava or falling), blame // the nearest player by not reproducing for a while shared_ptr nearestPlayer = level->getNearestPlayer(shared_from_this(), 16.0f); - if (nearestPlayer != NULL) + if (nearestPlayer != nullptr) { _village->resetNoBreedTimer(); } @@ -335,7 +335,7 @@ shared_ptr Villager::getTradingPlayer() bool Villager::isTrading() { - return tradingPlayer.lock() != NULL; + return tradingPlayer.lock() != nullptr; } void Villager::notifyTrade(MerchantRecipe *activeRecipe) @@ -349,7 +349,7 @@ void Villager::notifyTrade(MerchantRecipe *activeRecipe) { updateMerchantTimer = SharedConstants::TICKS_PER_SECOND * 2; addRecipeOnUpdate = true; - if (tradingPlayer.lock() != NULL) + if (tradingPlayer.lock() != nullptr) { lastPlayerTradeName = tradingPlayer.lock()->getName(); } @@ -370,7 +370,7 @@ void Villager::notifyTradeUpdated(shared_ptr item) if (!level->isClientSide && (ambientSoundTime > (-getAmbientSoundInterval() + SharedConstants::TICKS_PER_SECOND))) { ambientSoundTime = -getAmbientSoundInterval(); - if (item != NULL) + if (item != nullptr) { playSound(eSoundType_MOB_VILLAGER_YES, getSoundVolume(), getVoicePitch()); } @@ -383,7 +383,7 @@ void Villager::notifyTradeUpdated(shared_ptr item) MerchantRecipeList *Villager::getOffers(shared_ptr forPlayer) { - if (offers == NULL) + if (offers == nullptr) { addOffers(1); } @@ -515,7 +515,7 @@ void Villager::addOffers(int addCount) // shuffle the list to make it more interesting std::random_shuffle(newOffers->begin(), newOffers->end()); - if (offers == NULL) + if (offers == nullptr) { offers = new MerchantRecipeList(); } @@ -736,7 +736,7 @@ shared_ptr Villager::getBreedOffspring(shared_ptr target) if(level->canCreateMore(GetType(), Level::eSpawnType_Breed) ) { shared_ptr villager = shared_ptr(new Villager(level)); - villager->finalizeMobSpawn(NULL); + villager->finalizeMobSpawn(nullptr); return villager; } else diff --git a/Minecraft.World/VillagerGolem.cpp b/Minecraft.World/VillagerGolem.cpp index 691bade8e..09508bfc4 100644 --- a/Minecraft.World/VillagerGolem.cpp +++ b/Minecraft.World/VillagerGolem.cpp @@ -68,7 +68,7 @@ void VillagerGolem::serverAiMobStep() villageUpdateInterval = 70 + random->nextInt(50); shared_ptr _village = level->villages->getClosestVillage(Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist); village = _village; - if (_village == NULL) clearRestriction(); + if (_village == nullptr) clearRestriction(); else { Pos *center = _village->getCenter(); @@ -244,7 +244,7 @@ void VillagerGolem::setPlayerCreated(bool value) void VillagerGolem::die(DamageSource *source) { - if (!isPlayerCreated() && lastHurtByPlayer != NULL && village.lock() != NULL) + if (!isPlayerCreated() && lastHurtByPlayer != nullptr && village.lock() != nullptr) { village.lock()->modifyStanding(lastHurtByPlayer->getName(), -5); } @@ -257,7 +257,7 @@ bool VillagerGolem::hurt(DamageSource *source, float dmg) if (isPlayerCreated()) { shared_ptr entity = source->getDirectEntity(); - if (entity != NULL && entity->instanceof(eTYPE_PLAYER)) + if (entity != nullptr && entity->instanceof(eTYPE_PLAYER)) { shared_ptr player = dynamic_pointer_cast(entity); if (!player->isAllowedToAttackPlayers()) return false; diff --git a/Minecraft.World/Villages.cpp b/Minecraft.World/Villages.cpp index b5fb1b471..d73d568d5 100644 --- a/Minecraft.World/Villages.cpp +++ b/Minecraft.World/Villages.cpp @@ -11,7 +11,7 @@ const wstring Villages::VILLAGE_FILE_ID = L"villages"; Villages::Villages(const wstring &id) : SavedData(id) { _tick = 0; - level = NULL; + level = nullptr; } Villages::Villages(Level *level) : SavedData(VILLAGE_FILE_ID) @@ -147,7 +147,7 @@ void Villages::addDoorInfos(Pos *pos) if (isDoor(xx, yy, zz)) { shared_ptr currentDoor = getDoorInfo(xx, yy, zz); - if (currentDoor == NULL) createDoorInfo(xx, yy, zz); + if (currentDoor == nullptr) createDoorInfo(xx, yy, zz); else currentDoor->timeStamp = _tick; } } diff --git a/Minecraft.World/VineTile.cpp b/Minecraft.World/VineTile.cpp index 25600cbd7..2403c69aa 100644 --- a/Minecraft.World/VineTile.cpp +++ b/Minecraft.World/VineTile.cpp @@ -102,7 +102,7 @@ void VineTile::updateShape(LevelSource *level, int x, int y, int z, int forceDat AABB *VineTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } bool VineTile::mayPlace(Level *level, int x, int y, int z, int face) @@ -259,7 +259,7 @@ testLoop: if(noSideSpread) break; int edgeTile = level->getTile(x + Direction::STEP_X[testDirection], y, z + Direction::STEP_Z[testDirection]); - if (edgeTile == 0 || Tile::tiles[edgeTile] == NULL) + if (edgeTile == 0 || Tile::tiles[edgeTile] == nullptr) { // if the edge tile is air, we could possibly cling // to something @@ -371,7 +371,7 @@ int VineTile::getResourceCount(Random *random) void VineTile::playerDestroy(Level *level, shared_ptrplayer, int x, int y, int z, int data) { - if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears->id) + if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id) { player->awardStat( GenericStats::blocksMined(id), diff --git a/Minecraft.World/WallTile.cpp b/Minecraft.World/WallTile.cpp index a95360cec..b7d3f038c 100644 --- a/Minecraft.World/WallTile.cpp +++ b/Minecraft.World/WallTile.cpp @@ -159,7 +159,7 @@ bool WallTile::connectsTo(LevelSource *level, int x, int y, int z) return true; } Tile *tileInstance = Tile::tiles[tile]; - if (tileInstance != NULL) + if (tileInstance != nullptr) { if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped()) { diff --git a/Minecraft.World/WaterLevelChunk.cpp b/Minecraft.World/WaterLevelChunk.cpp index 7727898bb..07d1024c5 100644 --- a/Minecraft.World/WaterLevelChunk.cpp +++ b/Minecraft.World/WaterLevelChunk.cpp @@ -160,5 +160,5 @@ void WaterLevelChunk::setLevelChunkBrightness(LightLayer::variety layer, int x, Biome *WaterLevelChunk::getBiome(int x, int z, BiomeSource *biomeSource) { - return NULL; + return nullptr; } diff --git a/Minecraft.World/WaterLilyTile.cpp b/Minecraft.World/WaterLilyTile.cpp index ec789afc7..71c37874a 100644 --- a/Minecraft.World/WaterLilyTile.cpp +++ b/Minecraft.World/WaterLilyTile.cpp @@ -25,7 +25,7 @@ int WaterlilyTile::getRenderShape() void WaterlilyTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr source) { - if (source == NULL || !source->instanceof(eTYPE_BOAT)) + if (source == nullptr || !source->instanceof(eTYPE_BOAT)) { Bush::addAABBs(level, x, y, z, box, boxes, source); } diff --git a/Minecraft.World/WaterLilyTileItem.cpp b/Minecraft.World/WaterLilyTileItem.cpp index fe523c052..978a611fc 100644 --- a/Minecraft.World/WaterLilyTileItem.cpp +++ b/Minecraft.World/WaterLilyTileItem.cpp @@ -13,7 +13,7 @@ WaterLilyTileItem::WaterLilyTileItem(int id) : ColoredTileItem(id, false) bool WaterLilyTileItem::TestUse(shared_ptr itemInstance, Level *level, shared_ptr player) { HitResult *hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) return false; + if (hr == nullptr) return false; if (hr->type == HitResult::TILE) { @@ -47,7 +47,7 @@ bool WaterLilyTileItem::TestUse(shared_ptr itemInstance, Level *le shared_ptr WaterLilyTileItem::use(shared_ptr itemInstance, Level *level, shared_ptr player) { HitResult *hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) return itemInstance; + if (hr == nullptr) return itemInstance; if (hr->type == HitResult::TILE) { diff --git a/Minecraft.World/WebTile.cpp b/Minecraft.World/WebTile.cpp index a724c36dd..43609e56f 100644 --- a/Minecraft.World/WebTile.cpp +++ b/Minecraft.World/WebTile.cpp @@ -22,7 +22,7 @@ bool WebTile::isSolidRender(bool isServerLevel) AABB *WebTile::getAABB(Level *level, int x, int y, int z) { - return NULL; + return nullptr; } diff --git a/Minecraft.World/WeighedRandom.cpp b/Minecraft.World/WeighedRandom.cpp index 0c27bf32a..777ab92f5 100644 --- a/Minecraft.World/WeighedRandom.cpp +++ b/Minecraft.World/WeighedRandom.cpp @@ -28,7 +28,7 @@ WeighedRandomItem *WeighedRandom::getRandomItem(Random *random, vector *items) @@ -62,7 +62,7 @@ WeighedRandomItem *WeighedRandom::getRandomItem(Random *random, WeighedRandomIte return items[i]; } } - return NULL; + return nullptr; } diff --git a/Minecraft.World/Witch.cpp b/Minecraft.World/Witch.cpp index 592fc5cd8..6f8f4941f 100644 --- a/Minecraft.World/Witch.cpp +++ b/Minecraft.World/Witch.cpp @@ -96,10 +96,10 @@ void Witch::aiStep() shared_ptr item = getCarriedItem(); setEquippedSlot(SLOT_WEAPON, nullptr); - if (item != NULL && item->id == Item::potion_Id) + if (item != nullptr && item->id == Item::potion_Id) { vector *effects = Item::potion->getMobEffects(item); - if (effects != NULL) + if (effects != nullptr) { for(auto& effect : *effects) { @@ -124,11 +124,11 @@ void Witch::aiStep() { potion = PotionBrewing::POTION_ID_HEAL; } - else if (random->nextFloat() < 0.25f && getTarget() != NULL && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11) + else if (random->nextFloat() < 0.25f && getTarget() != nullptr && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11) { potion = PotionBrewing::POTION_ID_SWIFTNESS; } - else if (random->nextFloat() < 0.25f && getTarget() != NULL && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11) + else if (random->nextFloat() < 0.25f && getTarget() != nullptr && !hasEffect(MobEffect::movementSpeed) && getTarget()->distanceToSqr(shared_from_this()) > 11 * 11) { potion = PotionBrewing::POTION_ID_SWIFTNESS; } diff --git a/Minecraft.World/WitherBoss.cpp b/Minecraft.World/WitherBoss.cpp index 8a568b894..ceb64df2f 100644 --- a/Minecraft.World/WitherBoss.cpp +++ b/Minecraft.World/WitherBoss.cpp @@ -124,7 +124,7 @@ void WitherBoss::aiStep() if (!level->isClientSide && getAlternativeTarget(0) > 0) { shared_ptr e = level->getEntity(getAlternativeTarget(0)); - if (e != NULL) + if (e != nullptr) { if ((y < e->y) || (!isPowered() && y < (e->y + 5))) { @@ -167,7 +167,7 @@ void WitherBoss::aiStep() { e = level->getEntity(entityId); } - if (e != NULL) + if (e != nullptr) { double hx = getHeadX(i + 1); double hy = getHeadY(i + 1); @@ -258,7 +258,7 @@ void WitherBoss::newServerAiStep() shared_ptr current = level->getEntity(headTarget); // 4J: Added check for instance of living entity, had a problem with IDs being recycled to other entities - if (current == NULL || !current->instanceof(eTYPE_LIVINGENTITY) || !current->isAlive() || distanceToSqr(current) > 30 * 30 || !canSee(current)) + if (current == nullptr || !current->instanceof(eTYPE_LIVINGENTITY) || !current->isAlive() || distanceToSqr(current) > 30 * 30 || !canSee(current)) { setAlternativeTarget(i, 0); } @@ -303,7 +303,7 @@ void WitherBoss::newServerAiStep() } } } - if (getTarget() != NULL) + if (getTarget() != nullptr) { assert(getTarget()->instanceof(eTYPE_LIVINGENTITY)); setAlternativeTarget(0, getTarget()->entityId); @@ -462,14 +462,14 @@ bool WitherBoss::hurt(DamageSource *source, float dmg) if (isPowered()) { shared_ptr directEntity = source->getDirectEntity(); - if (directEntity != NULL && directEntity->GetType() == eTYPE_ARROW) + if (directEntity != nullptr && directEntity->GetType() == eTYPE_ARROW) { return false; } } shared_ptr sourceEntity = source->getEntity(); - if (sourceEntity != NULL) + if (sourceEntity != nullptr) { if ( sourceEntity->instanceof(eTYPE_PLAYER) ) { diff --git a/Minecraft.World/WitherSkull.cpp b/Minecraft.World/WitherSkull.cpp index 92f810df7..ccde41d42 100644 --- a/Minecraft.World/WitherSkull.cpp +++ b/Minecraft.World/WitherSkull.cpp @@ -55,9 +55,9 @@ void WitherSkull::onHit(HitResult *res) { if (!level->isClientSide) { - if (res->entity != NULL) + if (res->entity != nullptr) { - if (owner != NULL) + if (owner != nullptr) { DamageSource *damageSource = DamageSource::mobAttack(owner); if (res->entity->hurt(damageSource, 8)) diff --git a/Minecraft.World/Wolf.cpp b/Minecraft.World/Wolf.cpp index 2443c6632..55088ffd0 100644 --- a/Minecraft.World/Wolf.cpp +++ b/Minecraft.World/Wolf.cpp @@ -81,7 +81,7 @@ bool Wolf::useNewAi() void Wolf::setTarget(shared_ptr target) { TamableAnimal::setTarget(target); - if ( target == NULL ) + if ( target == nullptr ) { setAngry(false); } @@ -286,7 +286,7 @@ bool Wolf::hurt(DamageSource *source, float dmg) if (isTame()) { shared_ptr entity = source->getDirectEntity(); - if (entity != NULL && entity->instanceof(eTYPE_PLAYER)) + if (entity != nullptr && entity->instanceof(eTYPE_PLAYER)) { shared_ptr attacker = dynamic_pointer_cast(entity); attacker->canHarmPlayer(getOwnerUUID()); @@ -296,7 +296,7 @@ bool Wolf::hurt(DamageSource *source, float dmg) if (isInvulnerable()) return false; shared_ptr sourceEntity = source->getEntity(); sitGoal->wantToSit(false); - if (sourceEntity != NULL && !(sourceEntity->instanceof(eTYPE_PLAYER) || sourceEntity->instanceof(eTYPE_ARROW))) + if (sourceEntity != nullptr && !(sourceEntity->instanceof(eTYPE_PLAYER) || sourceEntity->instanceof(eTYPE_ARROW))) { // Take half damage from non-players and arrows dmg = (dmg + 1) / 2; @@ -327,7 +327,7 @@ void Wolf::setTame(bool value) void Wolf::tame(const wstring &wsOwnerUUID, bool bDisplayTamingParticles, bool bSetSitting) { setTame(true); - setPath(NULL); + setPath(nullptr); setTarget(nullptr); sitGoal->wantToSit(bSetSitting); setHealth(TAME_HEALTH); @@ -344,9 +344,9 @@ bool Wolf::mobInteract(shared_ptr player) if (isTame()) { - if (item != NULL) + if (item != nullptr) { - if(dynamic_cast(Item::items[item->id]) != NULL) + if(dynamic_cast(Item::items[item->id]) != nullptr) { FoodItem *food = dynamic_cast( Item::items[item->id] ); @@ -387,7 +387,7 @@ bool Wolf::mobInteract(shared_ptr player) { sitGoal->wantToSit(!isSitting()); jumping = false; - setPath(NULL); + setPath(nullptr); setAttackTarget(nullptr); setTarget(nullptr); } @@ -395,7 +395,7 @@ bool Wolf::mobInteract(shared_ptr player) } else { - if (item != NULL && item->id == Item::bone->id && !isAngry()) + if (item != nullptr && item->id == Item::bone->id && !isAngry()) { // 4J-PB - don't lose the bone in creative mode if (player->abilities.instabuild==false) @@ -430,7 +430,7 @@ bool Wolf::mobInteract(shared_ptr player) } // 4J-PB - stop wild wolves going in to Love Mode (even though they do on Java, but don't breed) - if((item != NULL) && isFood(item)) + if((item != nullptr) && isFood(item)) { return false; } @@ -467,8 +467,8 @@ float Wolf::getTailAngle() bool Wolf::isFood(shared_ptr item) { - if (item == NULL) return false; - if (dynamic_cast(Item::items[item->id]) == NULL) return false; + if (item == nullptr) return false; + if (dynamic_cast(Item::items[item->id]) == nullptr) return false; return static_cast(Item::items[item->id])->isMeat(); } @@ -552,7 +552,7 @@ bool Wolf::canMate(shared_ptr animal) if (!animal->instanceof(eTYPE_WOLF)) return false; shared_ptr partner = dynamic_pointer_cast(animal); - if (partner == NULL) return false; + if (partner == nullptr) return false; if (!partner->isTame()) return false; if (partner->isSitting()) return false; diff --git a/Minecraft.World/WoodTile.cpp b/Minecraft.World/WoodTile.cpp index c735c581a..239ef61c4 100644 --- a/Minecraft.World/WoodTile.cpp +++ b/Minecraft.World/WoodTile.cpp @@ -21,7 +21,7 @@ const wstring WoodTile::TEXTURE_NAMES[] = {L"oak", L"spruce", L"birch", L"jungle WoodTile::WoodTile(int id) : Tile(id, Material::wood) { - icons = NULL; + icons = nullptr; } unsigned int WoodTile::getDescriptionId(int iData) diff --git a/Minecraft.World/WorkbenchTile.cpp b/Minecraft.World/WorkbenchTile.cpp index 82193b692..cc505fc6a 100644 --- a/Minecraft.World/WorkbenchTile.cpp +++ b/Minecraft.World/WorkbenchTile.cpp @@ -7,8 +7,8 @@ WorkbenchTile::WorkbenchTile(int id) : Tile(id, Material::wood) { - iconTop = NULL; - iconFront = NULL; + iconTop = nullptr; + iconFront = nullptr; } Icon *WorkbenchTile::getTexture(int face, int data) diff --git a/Minecraft.World/Zombie.cpp b/Minecraft.World/Zombie.cpp index d13f18fe1..aba3fb2ab 100644 --- a/Minecraft.World/Zombie.cpp +++ b/Minecraft.World/Zombie.cpp @@ -94,7 +94,7 @@ void Zombie::setBaby(bool baby) { getEntityData()->set(DATA_BABY_ID, static_cast(baby ? 1 : 0)); - if (level != NULL && !level->isClientSide) + if (level != nullptr && !level->isClientSide) { AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); speed->removeModifier(SPEED_MODIFIER_BABY); @@ -125,7 +125,7 @@ void Zombie::aiStep() bool burn = true; shared_ptr helmet = getCarried(SLOT_HELM); - if (helmet != NULL) + if (helmet != nullptr) { if (helmet->isDamageableItem()) { @@ -154,10 +154,10 @@ bool Zombie::hurt(DamageSource *source, float dmg) if (Monster::hurt(source, dmg)) { shared_ptr target = getTarget(); - if ( (target == NULL) && getAttackTarget() != NULL && getAttackTarget()->instanceof(eTYPE_LIVINGENTITY) ) target = dynamic_pointer_cast( getAttackTarget() ); - if ( (target == NULL) && source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_LIVINGENTITY) ) target = dynamic_pointer_cast( source->getEntity() ); + if ( (target == nullptr) && getAttackTarget() != nullptr && getAttackTarget()->instanceof(eTYPE_LIVINGENTITY) ) target = dynamic_pointer_cast( getAttackTarget() ); + if ( (target == nullptr) && source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_LIVINGENTITY) ) target = dynamic_pointer_cast( source->getEntity() ); - if ( (target != NULL) && level->difficulty >= Difficulty::HARD && random->nextFloat() < getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->getValue()) + if ( (target != nullptr) && level->difficulty >= Difficulty::HARD && random->nextFloat() < getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->getValue()) { int x = Mth::floor(this->x); int y = Mth::floor(this->y); @@ -178,7 +178,7 @@ bool Zombie::hurt(DamageSource *source, float dmg) { level->addEntity(reinforcement); reinforcement->setTarget(target); - reinforcement->finalizeMobSpawn(NULL); + reinforcement->finalizeMobSpawn(nullptr); getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->addModifier(new AttributeModifier(-0.05f, AttributeModifier::OPERATION_ADDITION)); reinforcement->getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->addModifier(new AttributeModifier(-0.05f, AttributeModifier::OPERATION_ADDITION)); @@ -217,7 +217,7 @@ bool Zombie::doHurtTarget(shared_ptr target) if (result) { - if (getCarriedItem() == NULL && isOnFire() && random->nextFloat() < level->difficulty * 0.3f) + if (getCarriedItem() == nullptr && isOnFire() && random->nextFloat() < level->difficulty * 0.3f) { target->setOnFire(2 * level->difficulty); } @@ -319,7 +319,7 @@ void Zombie::killed(shared_ptr mob) shared_ptr zombie = shared_ptr(new Zombie(level)); zombie->copyPosition(mob); level->removeEntity(mob); - zombie->finalizeMobSpawn(NULL); + zombie->finalizeMobSpawn(nullptr); zombie->setVillager(true); if (mob->isBaby()) zombie->setBaby(true); level->addEntity(zombie); @@ -335,12 +335,12 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /* setCanPickUpLoot(random->nextFloat() < MAX_PICKUP_LOOT_CHANCE * difficulty); - if (groupData == NULL) + if (groupData == nullptr) { groupData = new ZombieGroupData(level->random->nextFloat() < 0.05f, level->random->nextFloat() < 0.05f); } - if ( dynamic_cast( groupData ) != NULL) + if ( dynamic_cast( groupData ) != nullptr) { ZombieGroupData *zombieData = static_cast(groupData); @@ -358,7 +358,7 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /* populateDefaultEquipmentSlots(); populateDefaultEquipmentEnchantments(); - if (getCarried(SLOT_HELM) == NULL) + if (getCarried(SLOT_HELM) == nullptr) { // [EB]: We have this code in quite some places, shouldn't we set // something like this globally? @@ -389,7 +389,7 @@ bool Zombie::mobInteract(shared_ptr player) { shared_ptr item = player->getSelectedItem(); - if (item != NULL && item->getItem() == Item::apple_gold && item->getAuxValue() == 0 && isVillager() && hasEffect(MobEffect::weakness)) + if (item != nullptr && item->getItem() == Item::apple_gold && item->getAuxValue() == 0 && isVillager() && hasEffect(MobEffect::weakness)) { if (!player->abilities.instabuild) item->count--; if (item->count <= 0) @@ -448,7 +448,7 @@ void Zombie::finishConversion() { shared_ptr villager = shared_ptr(new Villager(level)); villager->copyPosition(shared_from_this()); - villager->finalizeMobSpawn(NULL); + villager->finalizeMobSpawn(nullptr); villager->setRewardPlayersInVillage(); if (isBaby()) villager->setAge(-20 * 60 * 20); level->removeEntity(shared_from_this()); diff --git a/Minecraft.World/ZoneFile.cpp b/Minecraft.World/ZoneFile.cpp index fc1f36bfe..17eddb82b 100644 --- a/Minecraft.World/ZoneFile.cpp +++ b/Minecraft.World/ZoneFile.cpp @@ -23,7 +23,7 @@ ZoneFile::ZoneFile(__int64 key, File file, File entityFile) : slots(slotsLength) // this.entityFile = new NbtSlotFile(entityFile); // } - channel = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + channel = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); // 4J - try/catch removed // try { readHeader(); diff --git a/Minecraft.World/ZoneIo.cpp b/Minecraft.World/ZoneIo.cpp index 5860b10c9..a064317a9 100644 --- a/Minecraft.World/ZoneIo.cpp +++ b/Minecraft.World/ZoneIo.cpp @@ -22,8 +22,8 @@ void ZoneIo::write(byteArray bb, int size) void ZoneIo::write(ByteBuffer *bb, int size) { DWORD numberOfBytesWritten; - SetFilePointer(channel,static_cast(pos),NULL,NULL); - WriteFile(channel,bb->getBuffer(), bb->getSize(),&numberOfBytesWritten,NULL); + SetFilePointer(channel,static_cast(pos),nullptr,nullptr); + WriteFile(channel,bb->getBuffer(), bb->getSize(),&numberOfBytesWritten,nullptr); pos += size; } @@ -31,13 +31,13 @@ ByteBuffer *ZoneIo::read(int size) { DWORD numberOfBytesRead; byteArray bb = byteArray(size); - SetFilePointer(channel,static_cast(pos),NULL,NULL); + SetFilePointer(channel,static_cast(pos),nullptr,nullptr); ByteBuffer *buff = ByteBuffer::wrap(bb); // 4J - to investigate - why is this buffer flipped before anything goes in it? buff->order(ZonedChunkStorage::BYTEORDER); buff->position(size); buff->flip(); - ReadFile(channel, buff->getBuffer(), buff->getSize(), &numberOfBytesRead, NULL); + ReadFile(channel, buff->getBuffer(), buff->getSize(), &numberOfBytesRead, nullptr); pos += size; return buff; } diff --git a/Minecraft.World/ZonedChunkStorage.cpp b/Minecraft.World/ZonedChunkStorage.cpp index 5c6bf192c..7766687b0 100644 --- a/Minecraft.World/ZonedChunkStorage.cpp +++ b/Minecraft.World/ZonedChunkStorage.cpp @@ -62,8 +62,8 @@ ZoneFile *ZonedChunkStorage::getZoneFile(int x, int z, bool create) if ( !file.exists() ) { - if (!create) return NULL; - HANDLE ch = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (!create) return nullptr; + HANDLE ch = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); CloseHandle(ch); } @@ -76,7 +76,7 @@ ZoneFile *ZonedChunkStorage::getZoneFile(int x, int z, bool create) zoneFile->lastUse = tickCount; if (!zoneFile->containsSlot(slot)) { - if (!create) return NULL; + if (!create) return nullptr; } return zoneFile; @@ -85,14 +85,14 @@ ZoneFile *ZonedChunkStorage::getZoneFile(int x, int z, bool create) ZoneIo *ZonedChunkStorage::getBuffer(int x, int z, bool create) { ZoneFile *zoneFile = getZoneFile(x, z, create); - if (zoneFile == NULL) return NULL; + if (zoneFile == nullptr) return nullptr; return zoneFile->getZoneIo(getSlot(x, z)); } LevelChunk *ZonedChunkStorage::load(Level *level, int x, int z) { ZoneIo *zoneIo = getBuffer(x, z, false); - if (zoneIo == NULL) return NULL; + if (zoneIo == nullptr) return nullptr; LevelChunk *lc = new LevelChunk(level, x, z); lc->unsaved = false; diff --git a/Minecraft.World/compression.cpp b/Minecraft.World/compression.cpp index 6a43e112c..2a8f8e0b8 100644 --- a/Minecraft.World/compression.cpp +++ b/Minecraft.World/compression.cpp @@ -12,7 +12,7 @@ DWORD Compression::tlsIdx = 0; -Compression::ThreadStorage *Compression::tlsDefault = NULL; +Compression::ThreadStorage *Compression::tlsDefault = nullptr; Compression::ThreadStorage::ThreadStorage() { @@ -27,7 +27,7 @@ Compression::ThreadStorage::~ThreadStorage() void Compression::CreateNewThreadStorage() { ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == NULL ) + if(tlsDefault == nullptr ) { tlsIdx = TlsAlloc(); tlsDefault = tls; @@ -189,12 +189,12 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz // only use 5% of this buffer // 4J Stu - Changed this again to dynamically allocate a buffer if it's going to be too big - unsigned char *pucIn = NULL; + unsigned char *pucIn = nullptr; //const unsigned int staticRleSize = 1024*200; //static unsigned char rleBuf[staticRleSize]; unsigned int rleSize = staticRleSize; - unsigned char *dynamicRleBuf = NULL; + unsigned char *dynamicRleBuf = nullptr; if(*pDestSize > rleSize) { @@ -246,7 +246,7 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz // printf("Decompressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize); - if(dynamicRleBuf != NULL) delete [] dynamicRleBuf; + if(dynamicRleBuf != nullptr) delete [] dynamicRleBuf; LeaveCriticalSection(&rleDecompressLock); return S_OK; @@ -406,9 +406,9 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS break; case eCompressionType_ZLIBRLE: #if (defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64) - if (pDestination != NULL) + if (pDestination != nullptr) return ::uncompress(static_cast(pDestination), (unsigned long *) pDestSize, static_cast(pSource), SrcSize); // Decompress - else break; // Cannot decompress when destination is NULL + else break; // Cannot decompress when destination is nullptr #else assert(0); break; @@ -417,7 +417,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS #if (defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WIN64) // Note that we're missing the normal zlib header and footer so we'll use inflate to // decompress the payload and skip all the CRC checking, etc - if (pDestination != NULL) + if (pDestination != nullptr) { // Read big-endian srcize from array PBYTE pbDestSize = (PBYTE) pDestSize; @@ -466,7 +466,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS delete uncompr.data; return S_OK; } - else break; // Cannot decompress when destination is NULL + else break; // Cannot decompress when destination is nullptr #else assert(0); #endif diff --git a/Minecraft.World/x64headers/extraX64.h b/Minecraft.World/x64headers/extraX64.h index fa6ee0f99..42cc3b439 100644 --- a/Minecraft.World/x64headers/extraX64.h +++ b/Minecraft.World/x64headers/extraX64.h @@ -120,7 +120,7 @@ template class XLockFreeStack else { LeaveCriticalSection(&m_cs); - return NULL; + return nullptr; } } private: diff --git a/tall cloc b/tall cloc new file mode 100644 index 000000000..74570f663 --- /dev/null +++ b/tall cloc @@ -0,0 +1,324 @@ + + SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS + + Commands marked with * may be preceded by a number, _N. + Notes in parentheses indicate the behavior if _N is given. + A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K. + + h H Display this help. + q :q Q :Q ZZ Exit. + --------------------------------------------------------------------------- + + MMOOVVIINNGG + + e ^E j ^N CR * Forward one line (or _N lines). + y ^Y k ^K ^P * Backward one line (or _N lines). + ESC-j * Forward one file line (or _N file lines). + ESC-k * Backward one file line (or _N file lines). + f ^F ^V SPACE * Forward one window (or _N lines). + b ^B ESC-v * Backward one window (or _N lines). + z * Forward one window (and set window to _N). + w * Backward one window (and set window to _N). + ESC-SPACE * Forward one window, but don't stop at end-of-file. + ESC-b * Backward one window, but don't stop at beginning-of-file. + d ^D * Forward one half-window (and set half-window to _N). + u ^U * Backward one half-window (and set half-window to _N). + ESC-) RightArrow * Right one half screen width (or _N positions). + ESC-( LeftArrow * Left one half screen width (or _N positions). + ESC-} ^RightArrow Right to last column displayed. + ESC-{ ^LeftArrow Left to first column. + F Forward forever; like "tail -f". + ESC-F Like F but stop when search pattern is found. + r ^R ^L Repaint screen. + R Repaint screen, discarding buffered input. + --------------------------------------------------- + Default "window" is the screen height. + Default "half-window" is half of the screen height. + --------------------------------------------------------------------------- + + SSEEAARRCCHHIINNGG + + /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. + ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. + n * Repeat previous search (for _N-th occurrence). + N * Repeat previous search in reverse direction. + ESC-n * Repeat previous search, spanning files. + ESC-N * Repeat previous search, reverse dir. & spanning files. + ^O^N ^On * Search forward for (_N-th) OSC8 hyperlink. + ^O^P ^Op * Search backward for (_N-th) OSC8 hyperlink. + ^O^L ^Ol Jump to the currently selected OSC8 hyperlink. + ESC-u Undo (toggle) search highlighting. + ESC-U Clear search highlighting. + &_p_a_t_t_e_r_n * Display only matching lines. + --------------------------------------------------- + Search is case-sensitive unless changed with -i or -I. + A search pattern may begin with one or more of: + ^N or ! Search for NON-matching lines. + ^E or * Search multiple files (pass thru END OF FILE). + ^F or @ Start search at FIRST file (for /) or last file (for ?). + ^K Highlight matches, but don't move (KEEP position). + ^R Don't use REGULAR EXPRESSIONS. + ^S _n Search for match in _n-th parenthesized subpattern. + ^W WRAP search if no match found. + ^L Enter next character literally into pattern. + --------------------------------------------------------------------------- + + JJUUMMPPIINNGG + + g < ESC-< * Go to first line in file (or line _N). + G > ESC-> * Go to last line in file (or line _N). + p % * Go to beginning of file (or _N percent into file). + t * Go to the (_N-th) next tag. + T * Go to the (_N-th) previous tag. + { ( [ * Find close bracket } ) ]. + } ) ] * Find open bracket { ( [. + ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. + ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>. + --------------------------------------------------- + Each "find close bracket" command goes forward to the close bracket + matching the (_N-th) open bracket in the top line. + Each "find open bracket" command goes backward to the open bracket + matching the (_N-th) close bracket in the bottom line. + + m_<_l_e_t_t_e_r_> Mark the current top line with . + M_<_l_e_t_t_e_r_> Mark the current bottom line with . + '_<_l_e_t_t_e_r_> Go to a previously marked position. + '' Go to the previous position. + ^X^X Same as '. + ESC-m_<_l_e_t_t_e_r_> Clear a mark. + --------------------------------------------------- + A mark is any upper-case or lower-case letter. + Certain marks are predefined: + ^ means beginning of the file + $ means end of the file + --------------------------------------------------------------------------- + + CCHHAANNGGIINNGG FFIILLEESS + + :e [_f_i_l_e] Examine a new file. + ^X^V Same as :e. + :n * Examine the (_N-th) next file from the command line. + :p * Examine the (_N-th) previous file from the command line. + :x * Examine the first (or _N-th) file from the command line. + ^O^O Open the currently selected OSC8 hyperlink. + :d Delete the current file from the command line list. + = ^G :f Print current file name. + --------------------------------------------------------------------------- + + MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS + + -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. + --_<_n_a_m_e_> Toggle a command line option, by name. + __<_f_l_a_g_> Display the setting of a command line option. + ___<_n_a_m_e_> Display the setting of an option, by name. + +_c_m_d Execute the less cmd each time a new file is examined. + + !_c_o_m_m_a_n_d Execute the shell command with $SHELL. + #_c_o_m_m_a_n_d Execute the shell command, expanded like a prompt. + |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. + s _f_i_l_e Save input to a file. + v Edit the current file with $VISUAL or $EDITOR. + V Print version number of "less". + --------------------------------------------------------------------------- + + OOPPTTIIOONNSS + + Most options may be changed either on the command line, + or from within less by using the - or -- command. + Options may be given in one of two forms: either a single + character preceded by a -, or a name preceded by --. + + -? ........ --help + Display help (from command line). + -a ........ --search-skip-screen + Search skips current screen. + -A ........ --SEARCH-SKIP-SCREEN + Search starts just after target line. + -b [_N] .... --buffers=[_N] + Number of buffers. + -B ........ --auto-buffers + Don't automatically allocate buffers for pipes. + -c ........ --clear-screen + Repaint by clearing rather than scrolling. + -d ........ --dumb + Dumb terminal. + -D xx_c_o_l_o_r . --color=xx_c_o_l_o_r + Set screen colors. + -e -E .... --quit-at-eof --QUIT-AT-EOF + Quit at end of file. + -f ........ --force + Force open non-regular files. + -F ........ --quit-if-one-screen + Quit if entire file fits on first screen. + -g ........ --hilite-search + Highlight only last match for searches. + -G ........ --HILITE-SEARCH + Don't highlight any matches for searches. + -h [_N] .... --max-back-scroll=[_N] + Backward scroll limit. + -i ........ --ignore-case + Ignore case in searches that do not contain uppercase. + -I ........ --IGNORE-CASE + Ignore case in all searches. + -j [_N] .... --jump-target=[_N] + Screen position of target lines. + -J ........ --status-column + Display a status column at left edge of screen. + -k _f_i_l_e ... --lesskey-file=_f_i_l_e + Use a compiled lesskey file. + -K ........ --quit-on-intr + Exit less in response to ctrl-C. + -L ........ --no-lessopen + Ignore the LESSOPEN environment variable. + -m -M .... --long-prompt --LONG-PROMPT + Set prompt style. + -n ......... --line-numbers + Suppress line numbers in prompts and messages. + -N ......... --LINE-NUMBERS + Display line number at start of each line. + -o [_f_i_l_e] .. --log-file=[_f_i_l_e] + Copy to log file (standard input only). + -O [_f_i_l_e] .. --LOG-FILE=[_f_i_l_e] + Copy to log file (unconditionally overwrite). + -p _p_a_t_t_e_r_n . --pattern=[_p_a_t_t_e_r_n] + Start at pattern (from command line). + -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] + Define new prompt. + -q -Q .... --quiet --QUIET --silent --SILENT + Quiet the terminal bell. + -r -R .... --raw-control-chars --RAW-CONTROL-CHARS + Output "raw" control characters. + -s ........ --squeeze-blank-lines + Squeeze multiple blank lines. + -S ........ --chop-long-lines + Chop (truncate) long lines rather than wrapping. + -t _t_a_g .... --tag=[_t_a_g] + Find a tag. + -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] + Use an alternate tags file. + -u -U .... --underline-special --UNDERLINE-SPECIAL + Change handling of backspaces, tabs and carriage returns. + -V ........ --version + Display the version number of "less". + -w ........ --hilite-unread + Highlight first new line after forward-screen. + -W ........ --HILITE-UNREAD + Highlight first new line after any forward movement. + -x [_N[,...]] --tabs=[_N[,...]] + Set tab stops. + -X ........ --no-init + Don't use termcap init/deinit strings. + -y [_N] .... --max-forw-scroll=[_N] + Forward scroll limit. + -z [_N] .... --window=[_N] + Set size of window. + -" [_c[_c]] . --quotes=[_c[_c]] + Set shell quote characters. + -~ ........ --tilde + Don't display tildes after end of file. + -# [_N] .... --shift=[_N] + Set horizontal scroll amount (0 = one half screen width). + + --exit-follow-on-close + Exit F command on a pipe when writer closes pipe. + --file-size + Automatically determine the size of the input file. + --follow-name + The F command changes files if the input file is renamed. + --form-feed + Stop scrolling when a form feed character is reached. + --header=[_L[,_C[,_N]]] + Use _L lines (starting at line _N) and _C columns as headers. + --incsearch + Search file as each pattern character is typed in. + --intr=[_C] + Use _C instead of ^X to interrupt a read. + --lesskey-context=_t_e_x_t + Use lesskey source file contents. + --lesskey-src=_f_i_l_e + Use a lesskey source file. + --line-num-width=[_N] + Set the width of the -N line number field to _N characters. + --match-shift=[_N] + Show at least _N characters to the left of a search match. + --modelines=[_N] + Read _N lines from the input file and look for vim modelines. + --mouse + Enable mouse input. + --no-edit-warn + Don't warn when using v command on a file opened via LESSOPEN. + --no-keypad + Don't send termcap keypad init/deinit strings. + --no-histdups + Remove duplicates from command history. + --no-number-headers + Don't give line numbers to header lines. + --no-paste + Ignore pasted input. + --no-search-header-lines + Searches do not include header lines. + --no-search-header-columns + Searches do not include header columns. + --no-search-headers + Searches do not include header lines or columns. + --no-vbell + Disable the terminal's visual bell. + --redraw-on-quit + Redraw final screen when quitting. + --rscroll=[_C] + Set the character used to mark truncated lines. + --save-marks + Retain marks across invocations of less. + --search-options=[EFKNRW-] + Set default options for every search. + --show-preproc-errors + Display a message if preprocessor exits with an error status. + --proc-backspace + Process backspaces for bold/underline. + --PROC-BACKSPACE + Treat backspaces as control characters. + --proc-return + Delete carriage returns before newline. + --PROC-RETURN + Treat carriage returns as control characters. + --proc-tab + Expand tabs to spaces. + --PROC-TAB + Treat tabs as control characters. + --status-col-width=[_N] + Set the width of the -J status column to _N characters. + --status-line + Highlight or color the entire line containing a mark. + --use-backslash + Subsequent options use backslash as escape char. + --use-color + Enables colored text. + --wheel-lines=[_N] + Each click of the mouse wheel moves _N lines. + --wordwrap + Wrap lines at spaces. + + + --------------------------------------------------------------------------- + + LLIINNEE EEDDIITTIINNGG + + These keys can be used to edit text being entered + on the "command line" at the bottom of the screen. + + RightArrow ..................... ESC-l ... Move cursor right one character. + LeftArrow ...................... ESC-h ... Move cursor left one character. + ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word. + ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word. + HOME ........................... ESC-0 ... Move cursor to start of line. + END ............................ ESC-$ ... Move cursor to end of line. + BACKSPACE ................................ Delete char to left of cursor. + DELETE ......................... ESC-x ... Delete char under cursor. + ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor. + ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor. + ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line. + UpArrow ........................ ESC-k ... Retrieve previous command line. + DownArrow ...................... ESC-j ... Retrieve next command line. + TAB ...................................... Complete filename & cycle. + SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle. + ctrl-L ................................... Complete filename, list all. From 50a606f9cd9d67751ca4b610c03166fe21cecc4f Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Fri, 6 Mar 2026 17:33:22 -0500 Subject: [PATCH 6/9] Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. --- Minecraft.Client/AbstractTexturePack.cpp | 1 + Minecraft.Client/ClientConnection.cpp | 133 +++++++++-------- Minecraft.Client/Common/Audio/miniaudio.h | 5 - Minecraft.Client/Common/DLC/DLCManager.cpp | 1 + .../GameRules/AddItemRuleDefinition.cpp | 2 +- .../GameRules/CollectItemRuleDefinition.cpp | 22 ++- .../GameRules/CompleteAllRuleDefinition.cpp | 2 +- .../Common/Network/GameNetworkManager.cpp | 6 +- .../Common/Tutorial/ChangeStateConstraint.cpp | 6 +- .../Common/Tutorial/ChoiceTask.cpp | 5 +- Minecraft.Client/Common/Tutorial/InfoTask.cpp | 3 +- Minecraft.Client/Common/Tutorial/Tutorial.cpp | 1 + .../UI/IUIScene_AbstractContainerMenu.cpp | 1 + .../Common/UI/IUIScene_AnvilMenu.cpp | 2 +- .../Common/UI/IUIScene_BeaconMenu.cpp | 2 +- .../Common/UI/IUIScene_CommandBlockMenu.cpp | 2 +- .../Common/UI/IUIScene_CraftingMenu.cpp | 8 +- .../Common/UI/IUIScene_CreativeMenu.cpp | 6 +- Minecraft.Client/Common/UI/IUIScene_HUD.cpp | 2 + .../Common/UI/IUIScene_TradingMenu.cpp | 8 +- Minecraft.Client/Common/UI/UI.h | 4 +- .../Common/UI/UIComponent_TutorialPopup.cpp | 36 ++--- Minecraft.Client/Common/UI/UIGroup.cpp | 2 + Minecraft.Client/Common/UI/UIScene.cpp | 33 ++--- .../Common/UI/UIScene_BeaconMenu.cpp | 8 +- .../Common/UI/UIScene_CreativeMenu.cpp | 2 +- .../Common/UI/UIScene_DebugOverlay.cpp | 2 +- .../Common/UI/UIScene_FullscreenProgress.cpp | 1 - .../UI/UIScene_InGameHostOptionsMenu.cpp | 2 +- .../Common/UI/UIScene_InGameInfoMenu.cpp | 2 +- .../UI/UIScene_InGamePlayerOptionsMenu.cpp | 5 +- .../Common/UI/UIScene_LeaderboardsMenu.cpp | 12 +- .../Common/UI/UIScene_SignEntryMenu.cpp | 2 +- .../Common/XUI/XUI_Ctrl_MinecraftSlot.cpp | 2 +- .../Common/XUI/XUI_DebugItemEditor.cpp | 4 +- .../Common/XUI/XUI_InGameHostOptions.cpp | 2 +- .../Common/XUI/XUI_InGameInfo.cpp | 2 +- .../Common/XUI/XUI_InGamePlayerOptions.cpp | 4 +- .../XUI/XUI_Scene_Inventory_Creative.cpp | 2 +- Minecraft.Client/Common/XUI/XUI_SignEntry.cpp | 2 +- .../Common/XUI/XUI_TutorialPopup.cpp | 4 +- Minecraft.Client/ConnectScreen.cpp | 2 +- Minecraft.Client/DLCTexturePack.cpp | 1 + Minecraft.Client/EntityTileRenderer.cpp | 6 +- Minecraft.Client/EntityTracker.cpp | 2 +- Minecraft.Client/FireworksParticles.cpp | 6 +- Minecraft.Client/GameRenderer.cpp | 19 +-- Minecraft.Client/Gui.cpp | 1 + Minecraft.Client/ItemFrameRenderer.cpp | 2 +- Minecraft.Client/LevelRenderer.cpp | 74 +++++----- Minecraft.Client/LivingEntityRenderer.cpp | 2 +- Minecraft.Client/LocalPlayer.cpp | 8 +- Minecraft.Client/Minecraft.cpp | 6 +- Minecraft.Client/MinecraftServer.cpp | 24 ++-- Minecraft.Client/MultiPlayerGameMode.cpp | 38 ++--- Minecraft.Client/MultiPlayerLevel.cpp | 8 +- Minecraft.Client/MultiPlayerLocalPlayer.cpp | 48 +++---- Minecraft.Client/ParticleEngine.cpp | 4 +- Minecraft.Client/PendingConnection.cpp | 6 +- Minecraft.Client/PlayerChunkMap.cpp | 12 +- Minecraft.Client/PlayerConnection.cpp | 80 ++++++----- Minecraft.Client/PlayerList.cpp | 80 ++++++----- Minecraft.Client/PlayerRenderer.cpp | 2 +- Minecraft.Client/ReceivingLevelScreen.cpp | 2 +- Minecraft.Client/ServerLevel.cpp | 16 +-- Minecraft.Client/ServerPlayer.cpp | 134 +++++++++--------- Minecraft.Client/ServerPlayerGameMode.cpp | 2 +- Minecraft.Client/SnowManRenderer.cpp | 2 +- Minecraft.Client/TeleportCommand.cpp | 2 +- Minecraft.Client/TextEditScreen.cpp | 2 +- Minecraft.Client/TexturePackRepository.cpp | 1 + Minecraft.Client/TrackedEntity.cpp | 94 ++++++------ .../Windows64/Windows64_Minecraft.cpp | 2 +- .../Windows64/Windows64_UIController.h | 2 - Minecraft.World/AbstractContainerMenu.cpp | 8 +- Minecraft.World/AbstractContainerMenu.h | 2 +- Minecraft.World/AddEntityPacket.h | 2 +- Minecraft.World/AddExperienceOrbPacket.h | 2 +- Minecraft.World/AddGlobalEntityPacket.h | 2 +- Minecraft.World/AddMobPacket.h | 2 +- Minecraft.World/AddPaintingPacket.h | 2 +- Minecraft.World/AddPlayerPacket.h | 2 +- Minecraft.World/Animal.cpp | 2 +- Minecraft.World/AnimatePacket.h | 2 +- Minecraft.World/AnvilMenu.cpp | 4 +- Minecraft.World/Arrow.cpp | 4 +- Minecraft.World/AwardStatPacket.h | 2 +- Minecraft.World/BeaconTile.cpp | 2 +- Minecraft.World/BeaconTileEntity.cpp | 6 +- Minecraft.World/Blaze.cpp | 2 +- Minecraft.World/BlockRegionUpdatePacket.h | 2 +- Minecraft.World/BoatItem.cpp | 2 +- Minecraft.World/BottleItem.cpp | 6 +- Minecraft.World/BowItem.cpp | 2 +- Minecraft.World/BowlFoodItem.cpp | 2 +- Minecraft.World/BreedGoal.cpp | 2 +- Minecraft.World/BrewingStandTile.cpp | 4 +- Minecraft.World/BrewingStandTileEntity.cpp | 6 +- Minecraft.World/BucketItem.cpp | 18 +-- Minecraft.World/CarrotOnAStickItem.cpp | 2 +- Minecraft.World/CauldronTile.cpp | 6 +- Minecraft.World/ChatPacket.h | 2 +- Minecraft.World/ChestTile.cpp | 14 +- Minecraft.World/ChestTileEntity.cpp | 2 +- Minecraft.World/Chicken.cpp | 2 +- Minecraft.World/ChunkTilesUpdatePacket.h | 2 +- Minecraft.World/ChunkVisibilityAreaPacket.h | 2 +- Minecraft.World/ChunkVisibilityPacket.h | 2 +- Minecraft.World/ClientCommandPacket.h | 2 +- Minecraft.World/CocoaTile.cpp | 2 +- Minecraft.World/CombatTracker.cpp | 14 +- Minecraft.World/CommandBlock.cpp | 2 +- Minecraft.World/CommandBlockEntity.cpp | 4 +- Minecraft.World/ComparatorTile.cpp | 2 +- Minecraft.World/ComparatorTileEntity.cpp | 2 +- Minecraft.World/ComplexItemDataPacket.h | 2 +- Minecraft.World/Connection.cpp | 2 +- Minecraft.World/ContainerAckPacket.h | 2 +- Minecraft.World/ContainerButtonClickPacket.h | 2 +- Minecraft.World/ContainerClickPacket.h | 2 +- Minecraft.World/ContainerClosePacket.h | 2 +- Minecraft.World/ContainerOpenPacket.h | 2 +- Minecraft.World/ContainerSetContentPacket.h | 2 +- Minecraft.World/ContainerSetDataPacket.h | 2 +- Minecraft.World/ContainerSetSlotPacket.h | 2 +- Minecraft.World/ControlledByPlayerGoal.cpp | 2 +- Minecraft.World/Cow.cpp | 8 +- Minecraft.World/CraftItemPacket.h | 2 +- Minecraft.World/CraftingMenu.cpp | 4 +- Minecraft.World/CropTile.cpp | 2 +- Minecraft.World/CustomPayloadPacket.h | 2 +- Minecraft.World/DamageSource.cpp | 4 +- Minecraft.World/DaylightDetectorTile.cpp | 2 +- .../DaylightDetectorTileEntity.cpp | 2 +- Minecraft.World/DeadBushTile.cpp | 2 +- Minecraft.World/DebugOptionsPacket.h | 2 +- .../DefaultDispenseItemBehavior.cpp | 2 +- .../DirectoryLevelStorageSource.cpp | 2 +- Minecraft.World/DisconnectPacket.h | 2 +- Minecraft.World/DispenserTile.cpp | 6 +- Minecraft.World/DispenserTileEntity.cpp | 2 +- Minecraft.World/DropperTile.cpp | 2 +- Minecraft.World/DropperTileEntity.cpp | 2 +- Minecraft.World/EggItem.cpp | 2 +- Minecraft.World/EggTile.cpp | 2 +- Minecraft.World/EmptyMapItem.cpp | 2 +- Minecraft.World/EnchantItemCommand.cpp | 2 +- Minecraft.World/EnchantedBookItem.cpp | 6 +- Minecraft.World/EnchantmentMenu.cpp | 2 +- Minecraft.World/EnchantmentTableEntity.cpp | 2 +- Minecraft.World/EnchantmentTableTile.cpp | 2 +- Minecraft.World/EnderChestTile.cpp | 2 +- Minecraft.World/EnderChestTileEntity.cpp | 2 +- Minecraft.World/EnderDragon.cpp | 22 +-- Minecraft.World/EnderEyeItem.cpp | 2 +- Minecraft.World/EnderpearlItem.cpp | 2 +- Minecraft.World/Entity.cpp | 6 +- .../EntityActionAtPositionPacket.h | 2 +- Minecraft.World/EntityDamageSource.cpp | 4 +- Minecraft.World/EntityEventPacket.h | 2 +- Minecraft.World/EntityHorse.cpp | 6 +- Minecraft.World/ExperienceItem.cpp | 2 +- Minecraft.World/ExplodePacket.h | 2 +- Minecraft.World/EyeOfEnderSignal.cpp | 2 +- Minecraft.World/FallingTile.cpp | 4 +- Minecraft.World/FireworksItem.cpp | 2 +- Minecraft.World/FireworksMenu.cpp | 4 +- Minecraft.World/FireworksRecipe.cpp | 4 +- Minecraft.World/FishingHook.cpp | 4 +- Minecraft.World/FishingRodItem.cpp | 2 +- Minecraft.World/FlowerPotTile.cpp | 22 +-- Minecraft.World/FurnaceResultSlot.cpp | 2 +- Minecraft.World/FurnaceTile.cpp | 6 +- Minecraft.World/FurnaceTileEntity.cpp | 4 +- Minecraft.World/FuzzyZoomLayer.cpp | 2 +- Minecraft.World/GameCommandPacket.h | 2 +- Minecraft.World/GameEventPacket.h | 2 +- Minecraft.World/GetInfoPacket.h | 2 +- Minecraft.World/Ghast.cpp | 2 +- Minecraft.World/GiveItemCommand.cpp | 4 +- Minecraft.World/HangingEntityItem.cpp | 4 +- Minecraft.World/HeavyTile.cpp | 2 +- Minecraft.World/HopperTile.cpp | 4 +- Minecraft.World/HopperTileEntity.cpp | 2 +- Minecraft.World/HouseFeature.cpp | 2 +- .../IndirectEntityDamageSource.cpp | 4 +- Minecraft.World/InteractPacket.h | 2 +- Minecraft.World/Inventory.cpp | 8 +- Minecraft.World/InventoryMenu.cpp | 4 +- Minecraft.World/ItemDispenseBehaviors.cpp | 22 +-- Minecraft.World/ItemEntity.cpp | 2 +- Minecraft.World/ItemFrame.cpp | 2 +- Minecraft.World/ItemInstance.cpp | 4 +- Minecraft.World/JukeboxTile.cpp | 8 +- Minecraft.World/KeepAlivePacket.h | 2 +- Minecraft.World/KickPlayerPacket.h | 2 +- Minecraft.World/LavaSlime.cpp | 2 +- Minecraft.World/Layer.cpp | 50 +++---- Minecraft.World/LeafTile.cpp | 8 +- Minecraft.World/LeashFenceKnotEntity.cpp | 2 +- Minecraft.World/Level.cpp | 6 +- Minecraft.World/LevelEventPacket.h | 2 +- Minecraft.World/LevelParticlesPacket.h | 2 +- Minecraft.World/LevelSoundPacket.h | 2 +- Minecraft.World/LivingEntity.cpp | 12 +- Minecraft.World/LoginPacket.h | 2 +- Minecraft.World/MapItem.cpp | 8 +- Minecraft.World/MapItemSavedData.cpp | 4 +- .../McRegionLevelStorageSource.cpp | 2 +- Minecraft.World/MerchantMenu.cpp | 2 +- Minecraft.World/MerchantRecipe.cpp | 4 +- Minecraft.World/MilkBucketItem.cpp | 2 +- Minecraft.World/MineShaftPieces.cpp | 2 +- Minecraft.World/Minecart.cpp | 14 +- Minecraft.World/MinecartContainer.cpp | 4 +- Minecraft.World/MinecartFurnace.cpp | 2 +- Minecraft.World/MinecartTNT.cpp | 2 +- Minecraft.World/Mob.cpp | 6 +- Minecraft.World/MobSpawnerTile.cpp | 2 +- Minecraft.World/MobSpawnerTileEntity.cpp | 4 +- Minecraft.World/MoveEntityPacket.h | 8 +- Minecraft.World/MoveEntityPacketSmall.h | 8 +- Minecraft.World/MovePlayerPacket.h | 8 +- Minecraft.World/MushroomCow.cpp | 10 +- Minecraft.World/MusicTileEntity.cpp | 2 +- Minecraft.World/NetherWartTile.cpp | 2 +- Minecraft.World/NoteBlockTile.cpp | 2 +- Minecraft.World/Ocelot.cpp | 4 +- Minecraft.World/Packet.cpp | 2 +- Minecraft.World/Painting.cpp | 2 +- Minecraft.World/Pig.cpp | 4 +- Minecraft.World/PigZombie.cpp | 2 +- Minecraft.World/PistonMovingPiece.cpp | 2 +- Minecraft.World/PistonPieceEntity.cpp | 2 +- Minecraft.World/Player.cpp | 8 +- Minecraft.World/PlayerAbilitiesPacket.h | 2 +- Minecraft.World/PlayerActionPacket.h | 2 +- Minecraft.World/PlayerCommandPacket.h | 2 +- Minecraft.World/PlayerInfoPacket.h | 2 +- Minecraft.World/PlayerInputPacket.h | 2 +- Minecraft.World/PotatoTile.cpp | 2 +- Minecraft.World/PotionItem.cpp | 6 +- Minecraft.World/PreLoginPacket.h | 2 +- Minecraft.World/PumpkinTile.cpp | 4 +- Minecraft.World/QuartzBlockTile.cpp | 2 +- Minecraft.World/Recipes.cpp | 2 +- Minecraft.World/RedStoneOreTile.cpp | 2 +- Minecraft.World/RemoveEntitiesPacket.h | 2 +- Minecraft.World/RemoveMobEffectPacket.h | 2 +- Minecraft.World/RespawnPacket.h | 2 +- Minecraft.World/ResultSlot.cpp | 2 +- Minecraft.World/RotateHeadPacket.h | 2 +- Minecraft.World/RotatedPillarTile.cpp | 2 +- Minecraft.World/SavedDataStorage.cpp | 6 +- Minecraft.World/ScatteredFeaturePieces.cpp | 2 +- Minecraft.World/ServerSettingsChangedPacket.h | 2 +- Minecraft.World/SetCarriedItemPacket.h | 2 +- Minecraft.World/SetCreativeModeSlotPacket.h | 2 +- Minecraft.World/SetDisplayObjectivePacket.h | 2 +- Minecraft.World/SetEntityDataPacket.h | 2 +- Minecraft.World/SetEntityLinkPacket.h | 2 +- Minecraft.World/SetEntityMotionPacket.h | 2 +- Minecraft.World/SetEquippedItemPacket.h | 2 +- Minecraft.World/SetExperiencePacket.h | 2 +- Minecraft.World/SetHealthPacket.h | 2 +- Minecraft.World/SetObjectivePacket.h | 2 +- Minecraft.World/SetPlayerTeamPacket.h | 2 +- Minecraft.World/SetScorePacket.h | 2 +- Minecraft.World/SetSpawnPositionPacket.h | 2 +- Minecraft.World/SetTimePacket.h | 2 +- Minecraft.World/Sheep.cpp | 12 +- Minecraft.World/SignTile.cpp | 2 +- Minecraft.World/SignTileEntity.cpp | 4 +- Minecraft.World/SignUpdatePacket.h | 2 +- Minecraft.World/Skeleton.cpp | 10 +- Minecraft.World/SkullTile.cpp | 16 +-- Minecraft.World/SkullTileEntity.cpp | 4 +- Minecraft.World/Slime.cpp | 2 +- Minecraft.World/Slot.cpp | 2 +- Minecraft.World/SmoothZoomLayer.cpp | 2 +- Minecraft.World/SnowMan.cpp | 2 +- Minecraft.World/SnowballItem.cpp | 2 +- Minecraft.World/Spider.cpp | 2 +- Minecraft.World/SpikeFeature.cpp | 4 +- Minecraft.World/Squid.cpp | 2 +- Minecraft.World/StemTile.cpp | 2 +- Minecraft.World/StoneMonsterTile.cpp | 4 +- Minecraft.World/StoneSlabTile.cpp | 2 +- Minecraft.World/SynchedEntityData.cpp | 24 ++-- Minecraft.World/TakeItemEntityPacket.h | 2 +- Minecraft.World/TallGrass.cpp | 2 +- Minecraft.World/TeleportEntityPacket.h | 2 +- .../TextureAndGeometryChangePacket.h | 2 +- Minecraft.World/TextureChangePacket.h | 2 +- Minecraft.World/TheEndBiomeDecorator.cpp | 2 +- Minecraft.World/TheEndPortal.cpp | 2 +- Minecraft.World/TheEndPortalTileEntity.cpp | 2 +- Minecraft.World/ThinFenceTile.cpp | 2 +- Minecraft.World/ThrownEgg.cpp | 2 +- Minecraft.World/ThrownExpBottle.cpp | 2 +- Minecraft.World/ThrownPotion.cpp | 8 +- Minecraft.World/Tile.cpp | 8 +- Minecraft.World/TileDestructionPacket.h | 2 +- Minecraft.World/TileEditorOpenPacket.h | 2 +- Minecraft.World/TileEntityDataPacket.h | 2 +- Minecraft.World/TileEventPacket.h | 2 +- Minecraft.World/TileUpdatePacket.h | 2 +- Minecraft.World/TimeCommand.cpp | 2 +- Minecraft.World/TntTile.cpp | 4 +- Minecraft.World/ToggleDownfallCommand.cpp | 2 +- Minecraft.World/TopSnowTile.cpp | 2 +- Minecraft.World/TradeItemPacket.h | 2 +- Minecraft.World/TreeTile.cpp | 2 +- Minecraft.World/UpdateAttributesPacket.h | 2 +- .../UpdateGameRuleProgressPacket.cpp | 8 +- Minecraft.World/UpdateMobEffectPacket.h | 2 +- Minecraft.World/UpdateProgressPacket.h | 2 +- Minecraft.World/UseItemPacket.h | 2 +- Minecraft.World/Village.cpp | 4 +- Minecraft.World/VillagePieces.cpp | 2 +- Minecraft.World/VillageSiege.cpp | 2 +- Minecraft.World/Villager.cpp | 22 +-- Minecraft.World/Villages.cpp | 8 +- Minecraft.World/VineTile.cpp | 2 +- Minecraft.World/WeighedTreasure.cpp | 2 +- Minecraft.World/Witch.cpp | 4 +- Minecraft.World/WitherBoss.cpp | 2 +- Minecraft.World/Wolf.cpp | 2 +- Minecraft.World/WoodSlabTile.cpp | 2 +- Minecraft.World/XZPacket.h | 2 +- Minecraft.World/Zombie.cpp | 12 +- Minecraft.World/ZoomLayer.cpp | 2 +- 332 files changed, 1033 insertions(+), 986 deletions(-) diff --git a/Minecraft.Client/AbstractTexturePack.cpp b/Minecraft.Client/AbstractTexturePack.cpp index 16d1b14e6..a3c677272 100644 --- a/Minecraft.Client/AbstractTexturePack.cpp +++ b/Minecraft.Client/AbstractTexturePack.cpp @@ -3,6 +3,7 @@ #include "AbstractTexturePack.h" #include "..\Minecraft.World\InputOutputStream.h" #include "..\Minecraft.World\StringHelpers.h" +#include "Common/UI/UI.h" AbstractTexturePack::AbstractTexturePack(DWORD id, File *file, const wstring &name, TexturePack *fallback) : id(id), name(name) { diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index 09a57759e..05a7f8aa3 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -452,7 +452,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) if (owner != nullptr && owner->instanceof(eTYPE_PLAYER)) { shared_ptr player = dynamic_pointer_cast(owner); - shared_ptr hook = shared_ptr( new FishingHook(level, x, y, z, player) ); + shared_ptr hook = std::make_shared(level, x, y, z, player); e = hook; // 4J Stu - Move the player->fishing out of the ctor as we cannot reference 'this' player->fishing = hook; @@ -461,10 +461,10 @@ void ClientConnection::handleAddEntity(shared_ptr packet) } break; case AddEntityPacket::ARROW: - e = shared_ptr( new Arrow(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::SNOWBALL: - e = shared_ptr( new Snowball(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::ITEM_FRAME: { @@ -473,64 +473,64 @@ void ClientConnection::handleAddEntity(shared_ptr packet) int iz = (int) z; app.DebugPrintf("ClientConnection ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); } - e = shared_ptr(new ItemFrame(level, (int) x, (int) y, (int) z, packet->data)); + e = std::make_shared(level, (int)x, (int)y, (int)z, packet->data); packet->data = 0; setRot = false; break; case AddEntityPacket::THROWN_ENDERPEARL: - e = shared_ptr( new ThrownEnderpearl(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::EYEOFENDERSIGNAL: - e = shared_ptr( new EyeOfEnderSignal(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::FIREBALL: - e = shared_ptr( new LargeFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); + e = std::make_shared(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); packet->data = 0; break; case AddEntityPacket::SMALL_FIREBALL: - e = shared_ptr( new SmallFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); + e = std::make_shared(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); packet->data = 0; break; case AddEntityPacket::DRAGON_FIRE_BALL: - e = shared_ptr( new DragonFireball(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0) ); + e = std::make_shared(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); packet->data = 0; break; case AddEntityPacket::EGG: - e = shared_ptr( new ThrownEgg(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::THROWN_POTION: - e = shared_ptr( new ThrownPotion(level, x, y, z, packet->data) ); + e = std::make_shared(level, x, y, z, packet->data); packet->data = 0; break; case AddEntityPacket::THROWN_EXPBOTTLE: - e = shared_ptr( new ThrownExpBottle(level, x, y, z) ); + e = std::make_shared(level, x, y, z); packet->data = 0; break; case AddEntityPacket::BOAT: - e = shared_ptr( new Boat(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::PRIMED_TNT: - e = shared_ptr( new PrimedTnt(level, x, y, z, nullptr) ); + e = std::make_shared(level, x, y, z, std::shared_ptr()); break; case AddEntityPacket::ENDER_CRYSTAL: - e = shared_ptr( new EnderCrystal(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::ITEM: - e = shared_ptr( new ItemEntity(level, x, y, z) ); + e = std::make_shared(level, x, y, z); break; case AddEntityPacket::FALLING: - e = shared_ptr( new FallingTile(level, x, y, z, packet->data & 0xFFFF, packet->data >> 16) ); + e = std::make_shared(level, x, y, z, packet->data & 0xFFFF, packet->data >> 16); packet->data = 0; break; case AddEntityPacket::WITHER_SKULL: - e = shared_ptr(new WitherSkull(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0)); + e = std::make_shared(level, x, y, z, packet->xa / 8000.0, packet->ya / 8000.0, packet->za / 8000.0); packet->data = 0; break; case AddEntityPacket::FIREWORKS: - e = shared_ptr(new FireworksRocketEntity(level, x, y, z, nullptr)); + e = std::make_shared(level, x, y, z, std::shared_ptr()); break; case AddEntityPacket::LEASH_KNOT: - e = shared_ptr(new LeashFenceKnotEntity(level, (int) x, (int) y, (int) z)); + e = std::make_shared(level, (int)x, (int)y, (int)z); packet->data = 0; break; #ifndef _FINAL_BUILD @@ -692,7 +692,7 @@ void ClientConnection::handleAddEntity(shared_ptr packet) void ClientConnection::handleAddExperienceOrb(shared_ptr packet) { - shared_ptr e = shared_ptr( new ExperienceOrb(level, packet->x / 32.0, packet->y / 32.0, packet->z / 32.0, packet->value) ); + shared_ptr e = std::make_shared(level, packet->x / 32.0, packet->y / 32.0, packet->z / 32.0, packet->value); e->xp = packet->x; e->yp = packet->y; e->zp = packet->z; @@ -708,7 +708,7 @@ void ClientConnection::handleAddGlobalEntity(shared_ptr p double y = packet->y / 32.0; double z = packet->z / 32.0; shared_ptr e;// = nullptr; - if (packet->type == AddGlobalEntityPacket::LIGHTNING) e = shared_ptr( new LightningBolt(level, x, y, z) ); + if (packet->type == AddGlobalEntityPacket::LIGHTNING) e = std::make_shared(level, x, y, z); if (e != nullptr) { e->xp = packet->x; @@ -723,7 +723,7 @@ void ClientConnection::handleAddGlobalEntity(shared_ptr p void ClientConnection::handleAddPainting(shared_ptr packet) { - shared_ptr painting = shared_ptr( new Painting(level, packet->x, packet->y, packet->z, packet->dir, packet->motive) ); + shared_ptr painting = std::make_shared(level, packet->x, packet->y, packet->z, packet->dir, packet->motive); level->putEntity(packet->id, painting); } @@ -792,7 +792,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) double z = packet->z / 32.0; float yRot = packet->yRot * 360 / 256.0f; float xRot = packet->xRot * 360 / 256.0f; - shared_ptr player = shared_ptr( new RemotePlayer(minecraft->level, packet->name) ); + shared_ptr player = std::make_shared(minecraft->level, packet->name); player->xo = player->xOld = player->xp = packet->x; player->yo = player->yOld = player->yp = packet->y; player->zo = player->zOld = player->zp = packet->z; @@ -868,7 +868,7 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) } else { - player->inventory->items[player->inventory->selected] = shared_ptr( new ItemInstance(item, 1, 0) ); + player->inventory->items[player->inventory->selected] = std::make_shared(item, 1, 0); } player->absMoveTo(x, y, z, yRot, xRot); @@ -877,15 +877,18 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) player->setCustomCape( packet->m_capeId ); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All, packet->m_uiGamePrivileges); - if(!player->customTextureUrl.empty() && player->customTextureUrl.substr(0,3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl)) - { - if( minecraft->addPendingClientTextureRequest(player->customTextureUrl) ) - { - app.DebugPrintf("Client sending TextureAndGeometryPacket to get custom skin %ls for player %ls\n",player->customTextureUrl.c_str(), player->name.c_str()); - - send(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,nullptr,0) ) ); - } - } + if (!player->customTextureUrl.empty() && player->customTextureUrl.substr(0, 3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl)) + { + if (minecraft->addPendingClientTextureRequest(player->customTextureUrl)) + { + app.DebugPrintf("Client sending TextureAndGeometryPacket to get custom skin %ls for player %ls\n", player->customTextureUrl.c_str(), player->name.c_str()); + + send(std::make_shared( + player->customTextureUrl, + nullptr, + static_cast(0))); + } + } else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl)) { // Update the ref count on the memory texture data @@ -899,7 +902,11 @@ void ClientConnection::handleAddPlayer(shared_ptr packet) if( minecraft->addPendingClientTextureRequest(player->customTextureUrl2) ) { app.DebugPrintf("Client sending texture packet to get custom cape %ls for player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str()); - send(shared_ptr( new TexturePacket(player->customTextureUrl2,nullptr,0) ) ); + send(std::make_shared( + player->customTextureUrl2, + nullptr, + static_cast(0) + )); } } else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2)) @@ -1402,7 +1409,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr pac level->playSound(from, eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f); } - minecraft->particleEngine->add( shared_ptr( new TakeAnimationParticle(minecraft->level, from, to, -0.5f) ) ); + minecraft->particleEngine->add(std::make_shared(minecraft->level, from, to, -0.5f)); level->removeEntity(packet->itemId); } else @@ -1415,7 +1422,7 @@ void ClientConnection::handleTakeItemEntity(shared_ptr pac else { level->playSound(from, eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f); - minecraft->particleEngine->add( shared_ptr( new TakeAnimationParticle(minecraft->level, from, to, -0.5f) ) ); + minecraft->particleEngine->add(std::make_shared(minecraft->level, from, to, -0.5f)); level->removeEntity(packet->itemId); } } @@ -1848,13 +1855,13 @@ void ClientConnection::handleAnimate(shared_ptr packet) } else if (packet->action == AnimatePacket::CRITICAL_HIT) { - shared_ptr critParticle = shared_ptr( new CritParticle(minecraft->level, e) ); + shared_ptr critParticle = std::make_shared(minecraft->level, e); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add( critParticle ); } else if (packet->action == AnimatePacket::MAGIC_CRITICAL_HIT) { - shared_ptr critParticle = shared_ptr( new CritParticle(minecraft->level, e, eParticleType_magicCrit) ); + shared_ptr critParticle = std::make_shared(minecraft->level, e, eParticleType_magicCrit); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add(critParticle); } @@ -2326,8 +2333,8 @@ void ClientConnection::handlePreLogin(shared_ptr packet) } BOOL allAllowed, friendsAllowed; ProfileManager.AllowedPlayerCreatedContent(m_userIndex,true,&allAllowed,&friendsAllowed); - send( shared_ptr( new LoginPacket(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed!=TRUE && friendsAllowed==TRUE), - packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), app.GetPlayerCapeId(m_userIndex), ProfileManager.IsGuest( m_userIndex )))); + send(std::make_shared(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed != TRUE && friendsAllowed == TRUE), + packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), app.GetPlayerCapeId(m_userIndex), ProfileManager.IsGuest(m_userIndex))); if(!g_NetworkManager.IsHost() ) { @@ -2550,7 +2557,7 @@ void ClientConnection::handleTexture(shared_ptr packet) if(dwBytes!=0) { - send( shared_ptr( new TexturePacket(packet->textureName,pbData,dwBytes) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes)); } } else @@ -2587,18 +2594,18 @@ void ClientConnection::handleTextureAndGeometry(shared_ptrgetAdditionalBoxesCount()!=0) { - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes,pDLCSkinFile) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes, pDLCSkinFile)); } else { - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes)); } } else { unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwBytes,app.GetAdditionalSkinBoxes(packet->dwSkinID),uiAnimOverrideBitmask) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes, app.GetAdditionalSkinBoxes(packet->dwSkinID), uiAnimOverrideBitmask)); } } } @@ -2667,7 +2674,10 @@ void ClientConnection::handleTextureChange(shared_ptr packe #ifndef _CONTENT_PACKAGE wprintf(L"handleTextureChange - Client sending texture packet to get custom skin %ls for player %ls\n",packet->path.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TexturePacket(packet->path,nullptr,0) ) ); + send(std::make_shared( + player->customTextureUrl, + nullptr, + static_cast(0))); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) @@ -2712,7 +2722,10 @@ void ClientConnection::handleTextureAndGeometryChange(shared_ptrpath.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TextureAndGeometryPacket(packet->path,nullptr,0) ) ); + send(std::make_shared( + packet->path, + nullptr, + static_cast(0))); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) @@ -2895,7 +2908,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe default: assert(false); chestString = -1; break; } - if( player->openContainer(shared_ptr( new SimpleContainer(chestString, packet->title, packet->customName, packet->size) ))) + if( player->openContainer(std::make_shared(chestString, packet->title, packet->customName, packet->size))) { player->containerMenu->containerId = packet->containerId; } @@ -2907,7 +2920,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::HOPPER: { - shared_ptr hopper = shared_ptr(new HopperTileEntity()); + shared_ptr hopper = std::make_shared(); if (packet->customName) hopper->setCustomName(packet->title); if(player->openHopper(hopper)) { @@ -2921,7 +2934,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::FURNACE: { - shared_ptr furnace = shared_ptr(new FurnaceTileEntity()); + shared_ptr furnace = std::make_shared(); if (packet->customName) furnace->setCustomName(packet->title); if(player->openFurnace(furnace)) { @@ -2935,7 +2948,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::BREWING_STAND: { - shared_ptr brewingStand = shared_ptr(new BrewingStandTileEntity()); + shared_ptr brewingStand = std::make_shared(); if (packet->customName) brewingStand->setCustomName(packet->title); if( player->openBrewingStand(brewingStand)) @@ -2950,7 +2963,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::DROPPER: { - shared_ptr dropper = shared_ptr(new DropperTileEntity()); + shared_ptr dropper = std::make_shared(); if (packet->customName) dropper->setCustomName(packet->title); if( player->openTrap(dropper)) @@ -2965,7 +2978,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::TRAP: { - shared_ptr dispenser = shared_ptr(new DispenserTileEntity()); + shared_ptr dispenser = std::make_shared(); if (packet->customName) dispenser->setCustomName(packet->title); if( player->openTrap(dispenser)) @@ -3004,7 +3017,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::TRADER_NPC: { - shared_ptr csm = shared_ptr(new ClientSideMerchant(player, packet->title)); + shared_ptr csm = std::make_shared(player, packet->title); csm->createContainer(); if(player->openTrading(csm, packet->customName ? packet->title : L"")) { @@ -3018,7 +3031,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe break; case ContainerOpenPacket::BEACON: { - shared_ptr beacon = shared_ptr(new BeaconTileEntity()); + shared_ptr beacon = std::make_shared(); if (packet->customName) beacon->setCustomName(packet->title); if(player->openBeacon(beacon)) @@ -3056,7 +3069,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe iTitle = IDS_MULE; break; }; - if(player->openHorseInventory(dynamic_pointer_cast(entity), shared_ptr(new AnimalChest(iTitle, packet->title, packet->customName, packet->size)))) + if(player->openHorseInventory(dynamic_pointer_cast(entity), std::make_shared(iTitle, packet->title, packet->customName, packet->size))) { player->containerMenu->containerId = packet->containerId; } @@ -3091,7 +3104,7 @@ void ClientConnection::handleContainerOpen(shared_ptr packe } else { - send(shared_ptr(new ContainerClosePacket(packet->containerId))); + send(std::make_shared(packet->containerId)); } } } @@ -3144,7 +3157,7 @@ void ClientConnection::handleContainerAck(shared_ptr packet) { if (!packet->accepted) { - send( shared_ptr( new ContainerAckPacket(packet->containerId, packet->uid, true) )); + send(std::make_shared(packet->containerId, packet->uid, true)); } } } @@ -3171,7 +3184,7 @@ void ClientConnection::handleTileEditorOpen(shared_ptr pac } else if (packet->editorType == TileEditorOpenPacket::SIGN) { - shared_ptr localSignDummy = shared_ptr(new SignTileEntity()); + shared_ptr localSignDummy = std::make_shared(); localSignDummy->setLevel(level); localSignDummy->x = packet->x; localSignDummy->y = packet->y; @@ -3576,7 +3589,7 @@ void ClientConnection::displayPrivilegeChanges(shared_ptr packet) { - send(shared_ptr(new KeepAlivePacket(packet->id))); + send(std::make_shared(packet->id)); } void ClientConnection::handlePlayerAbilities(shared_ptr playerAbilitiesPacket) diff --git a/Minecraft.Client/Common/Audio/miniaudio.h b/Minecraft.Client/Common/Audio/miniaudio.h index f5997a42b..87cb06bec 100644 --- a/Minecraft.Client/Common/Audio/miniaudio.h +++ b/Minecraft.Client/Common/Audio/miniaudio.h @@ -3843,11 +3843,6 @@ typedef void* ma_proc; typedef ma_uint16 wchar_t; #endif -/* Define nullptr for some compilers. */ -#ifndef nullptr -#define nullptr 0 -#endif - #if defined(SIZE_MAX) #define MA_SIZE_MAX SIZE_MAX #else diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index 5fc5f3704..4a2dc2c72 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -6,6 +6,7 @@ #include "..\..\..\Minecraft.World\StringHelpers.h" #include "..\..\Minecraft.h" #include "..\..\TexturePackRepository.h" +#include "Common/UI/UI.h" WCHAR *DLCManager::wchTypeNamesA[]= { diff --git a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp index 270909ecd..49809d0c5 100644 --- a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp @@ -100,7 +100,7 @@ bool AddItemRuleDefinition::addItemToContainer(shared_ptr container, if(Item::items[m_itemId] != nullptr) { int quantity = std::min(m_quantity, Item::items[m_itemId]->getMaxStackSize()); - shared_ptr newItem = shared_ptr(new ItemInstance(m_itemId,quantity,m_auxValue) ); + shared_ptr newItem = std::make_shared(m_itemId, quantity, m_auxValue); newItem->set4JData(m_dataTag); for( auto& it : m_enchantments ) diff --git a/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp index 85d382192..7f03a0fef 100644 --- a/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp @@ -90,13 +90,21 @@ bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr= m_quantity) { setComplete(rule, true); - app.DebugPrintf("Completed CollectItemRule with info - itemId:%d, auxValue:%d, quantity:%d, dataTag:%d\n", m_itemId,m_auxValue,m_quantity,m_4JDataValue); - - if(rule->getConnection() != nullptr) - { - rule->getConnection()->send( shared_ptr( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId, m_itemId, m_auxValue, this->m_4JDataValue,nullptr,0))); - } - } + app.DebugPrintf("Completed CollectItemRule with info - itemId:%d, auxValue:%d, quantity:%d, dataTag:%d\n", m_itemId, m_auxValue, m_quantity, m_4JDataValue); + + if (rule->getConnection() != nullptr) + { + rule->getConnection()->send(std::make_shared( + getActionType(), + this->m_descriptionId, + m_itemId, + m_auxValue, + this->m_4JDataValue, + nullptr, + static_cast(0) + )); + } + } } } return statusChanged; diff --git a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp index ef83b32c0..cd23cd504 100644 --- a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp +++ b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp @@ -51,7 +51,7 @@ void CompleteAllRuleDefinition::updateStatus(GameRule *rule) auxValue = m_lastRuleStatusChanged->getAuxValue(); m_lastRuleStatusChanged = nullptr; } - rule->getConnection()->send( shared_ptr( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId,icon, auxValue, 0,&data,sizeof(PacketData)))); + rule->getConnection()->send(std::make_shared(getActionType(), this->m_descriptionId, icon, auxValue, 0, &data, sizeof(PacketData))); } app.DebugPrintf("Updated CompleteAllRule - Completed %d of %d\n", progress, goal); } diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp index 7d282db5d..133a2dfcf 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp @@ -394,7 +394,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame return false; } - connection->send( shared_ptr( new PreLoginPacket(minecraft->user->name) ) ); + connection->send(std::make_shared(minecraft->user->name)); // Tick connection until we're ready to go. The stages involved in this are: // (1) Creating the ClientConnection sends a prelogin packet to the server @@ -481,7 +481,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame // Open the socket on the server end to accept incoming data Socket::addIncomingSocket(socket); - connection->send( shared_ptr( new PreLoginPacket(convStringToWstring( ProfileManager.GetGamertag(idx) )) ) ); + connection->send(std::make_shared(convStringToWstring(ProfileManager.GetGamertag(idx)))); createdConnections.push_back( connection ); @@ -1523,7 +1523,7 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc if( connection->createdOk ) { - connection->send( shared_ptr( new PreLoginPacket( pNetworkPlayer->GetOnlineName() ) ) ); + connection->send(std::make_shared(pNetworkPlayer->GetOnlineName())); pMinecraft->addPendingLocalConnection(idx, connection); } else diff --git a/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp b/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp index df2f5b2b2..06e73d6f7 100644 --- a/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp +++ b/Minecraft.Client/Common/Tutorial/ChangeStateConstraint.cpp @@ -63,7 +63,7 @@ void ChangeStateConstraint::tick(int iPad) shared_ptr player = minecraft->localplayers[iPad]; if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { - player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); + player->connection->send(std::make_shared(player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs)); } } } @@ -104,7 +104,7 @@ void ChangeStateConstraint::tick(int iPad) shared_ptr player = minecraft->localplayers[iPad]; if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { - player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); + player->connection->send(std::make_shared(player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs)); } } } @@ -128,7 +128,7 @@ void ChangeStateConstraint::tick(int iPad) shared_ptr player = minecraft->localplayers[iPad]; if(player != nullptr && player->connection && player->connection->getNetworkPlayer() != nullptr) { - player->connection->send( shared_ptr( new PlayerInfoPacket( player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs) ) ); + player->connection->send(std::make_shared(player->connection->getNetworkPlayer()->GetSmallId(), -1, playerPrivs)); } } } diff --git a/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp b/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp index 987ad6eb1..023e4b22c 100644 --- a/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp +++ b/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp @@ -8,10 +8,11 @@ #include "ChoiceTask.h" #include "..\..\..\Minecraft.World\Material.h" #include "..\..\Windows64\KeyboardMouseInput.h" +#include "Common/UI/UI.h" ChoiceTask::ChoiceTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, - int iConfirmMapping /*= 0*/, int iCancelMapping /*= 0*/, - eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) + int iConfirmMapping /*= 0*/, int iCancelMapping /*= 0*/, + eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) : TutorialTask( tutorial, descriptionId, false, nullptr, true, false, false ) { if(requiresUserInput == true) diff --git a/Minecraft.Client/Common/Tutorial/InfoTask.cpp b/Minecraft.Client/Common/Tutorial/InfoTask.cpp index 340ea5187..2e4818047 100644 --- a/Minecraft.Client/Common/Tutorial/InfoTask.cpp +++ b/Minecraft.Client/Common/Tutorial/InfoTask.cpp @@ -8,9 +8,10 @@ #include "InfoTask.h" #include "..\..\..\Minecraft.World\Material.h" #include "..\..\Windows64\KeyboardMouseInput.h" +#include "Common/UI/UI.h" InfoTask::InfoTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, - int iMapping /*= 0*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) + int iMapping /*= 0*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) : TutorialTask( tutorial, descriptionId, false, nullptr, true, false, false ) { if(requiresUserInput == true) diff --git a/Minecraft.Client/Common/Tutorial/Tutorial.cpp b/Minecraft.Client/Common/Tutorial/Tutorial.cpp index 0e6bf3468..c985ef491 100644 --- a/Minecraft.Client/Common/Tutorial/Tutorial.cpp +++ b/Minecraft.Client/Common/Tutorial/Tutorial.cpp @@ -17,6 +17,7 @@ #include "TutorialTasks.h" #include "TutorialConstraints.h" #include "TutorialHints.h" +#include "Common/UI/UI.h" vector Tutorial::s_completableTasks; diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp index 6df5571a8..d607d8754 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -2,6 +2,7 @@ #include "IUIScene_AbstractContainerMenu.h" +#include "UI.h" #include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" #include "..\..\..\Minecraft.World\net.minecraft.world.item.h" #include "..\..\..\Minecraft.World\net.minecraft.world.item.crafting.h" diff --git a/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp index 2c1469bcd..1e6fa6fa0 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AnvilMenu.cpp @@ -245,7 +245,7 @@ void IUIScene_AnvilMenu::updateItemName() ByteArrayOutputStream baos; DataOutputStream dos(&baos); dos.writeUTF(m_itemName); - Minecraft::GetInstance()->localplayers[getPad()]->connection->send(shared_ptr(new CustomPayloadPacket(CustomPayloadPacket::SET_ITEM_NAME_PACKET, baos.toByteArray()))); + Minecraft::GetInstance()->localplayers[getPad()]->connection->send(std::make_shared(CustomPayloadPacket::SET_ITEM_NAME_PACKET, baos.toByteArray())); } void IUIScene_AnvilMenu::refreshContainer(AbstractContainerMenu *container, vector > *items) diff --git a/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp index efe4c2e11..3dede3d94 100644 --- a/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_BeaconMenu.cpp @@ -222,7 +222,7 @@ void IUIScene_BeaconMenu::handleOtherClicked(int iPad, ESceneSection eSection, i dos.writeInt(m_beacon->getPrimaryPower()); dos.writeInt(m_beacon->getSecondaryPower()); - Minecraft::GetInstance()->localplayers[getPad()]->connection->send(shared_ptr(new CustomPayloadPacket(CustomPayloadPacket::SET_BEACON_PACKET, baos.toByteArray()))); + Minecraft::GetInstance()->localplayers[getPad()]->connection->send(std::make_shared(CustomPayloadPacket::SET_BEACON_PACKET, baos.toByteArray())); if (m_beacon->getPrimaryPower() > 0) { diff --git a/Minecraft.Client/Common/UI/IUIScene_CommandBlockMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CommandBlockMenu.cpp index 4371b4e58..3af01678e 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CommandBlockMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CommandBlockMenu.cpp @@ -20,6 +20,6 @@ void IUIScene_CommandBlockMenu::ConfirmButtonClicked() dos.writeInt(m_commandBlock->z); dos.writeUTF(GetCommand()); - Minecraft::GetInstance()->localplayers[GetPad()]->connection->send(shared_ptr(new CustomPayloadPacket(CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET, baos.toByteArray()))); + Minecraft::GetInstance()->localplayers[GetPad()]->connection->send(std::make_shared(CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET, baos.toByteArray())); } diff --git a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp index e056fd68b..6fddece9c 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp @@ -6,6 +6,8 @@ #include "..\..\LocalPlayer.h" #include "IUIScene_CraftingMenu.h" +#include "UI.h" + Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping4GridA[IUIScene_CraftingMenu::m_iMaxGroup2x2]= { Recipy::eGroupType_Structure, @@ -293,7 +295,7 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) if (ingItemInst->getItem()->hasCraftingRemainingItem()) { // replace item with remaining result - m_pPlayer->inventory->add( shared_ptr( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) ); + m_pPlayer->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); } } @@ -1071,7 +1073,7 @@ void IUIScene_CraftingMenu::DisplayIngredients() int iAuxVal=pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]; Item *item = Item::items[id]; - shared_ptr itemInst= shared_ptr(new ItemInstance(item,pRecipeIngredientsRequired[iRecipe].iIngValA[i],iAuxVal)); + shared_ptr itemInst= std::make_shared(item, pRecipeIngredientsRequired[iRecipe].iIngValA[i], iAuxVal); // 4J-PB - a very special case - the bed can use any kind of wool, so we can't use the item description // and the same goes for the painting @@ -1156,7 +1158,7 @@ void IUIScene_CraftingMenu::DisplayIngredients() { iAuxVal = 1; } - shared_ptr itemInst= shared_ptr(new ItemInstance(id,1,iAuxVal)); + shared_ptr itemInst= std::make_shared(id, 1, iAuxVal); setIngredientSlotItem(getPad(),index,itemInst); // show the ingredients we don't have if we can't make the recipe if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L< > IUIScene_CreativeMenu::categoryGroups[eCreati #define ITEM_AUX(id, aux) list->push_back( shared_ptr(new ItemInstance(id, 1, aux)) ); #define DEF(index) list = &categoryGroups[index]; - void IUIScene_CreativeMenu::staticCtor() { vector< shared_ptr > *list; @@ -495,7 +495,7 @@ void IUIScene_CreativeMenu::staticCtor() #ifndef _CONTENT_PACKAGE if(app.DebugSettingsOn()) { - shared_ptr debugSword = shared_ptr(new ItemInstance(Item::sword_diamond_Id, 1, 0)); + shared_ptr debugSword = std::make_shared(Item::sword_diamond_Id, 1, 0); debugSword->enchant( Enchantment::damageBonus, 50 ); debugSword->setHoverName(L"Sword of Debug"); list->push_back(debugSword); @@ -1362,7 +1362,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector > *lis shared_ptr firework; { - firework = shared_ptr( new ItemInstance(Item::fireworks) ); + firework = std::make_shared(Item::fireworks); CompoundTag *itemTag = new CompoundTag(); CompoundTag *fireTag = new CompoundTag(FireworksItem::TAG_FIREWORKS); ListTag *expTags = new ListTag(FireworksItem::TAG_EXPLOSIONS); diff --git a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp index 27c62a13e..fd9779665 100644 --- a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp @@ -7,6 +7,8 @@ #include "..\..\..\Minecraft.World\net.minecraft.world.entity.monster.h" #include "IUIScene_HUD.h" +#include "UI.h" + IUIScene_HUD::IUIScene_HUD() { m_lastActiveSlot = -1; diff --git a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp index 1f9cf7bd9..f45a00430 100644 --- a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp @@ -8,6 +8,8 @@ #include "..\..\ClientConnection.h" #include "IUIScene_TradingMenu.h" +#include "UI.h" + IUIScene_TradingMenu::IUIScene_TradingMenu() { m_validOffersCount = 0; @@ -95,7 +97,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) } // Send a packet to the server - player->connection->send( shared_ptr( new TradeItemPacket(m_menu->containerId, actualShopItem) ) ); + player->connection->send(std::make_shared(m_menu->containerId, actualShopItem)); updateDisplay(); } @@ -152,7 +154,7 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) ByteArrayOutputStream rawOutput; DataOutputStream output(&rawOutput); output.writeInt(actualShopItem); - Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()))); + Minecraft::GetInstance()->getConnection(getPad())->send(std::make_shared(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())); } } return handled; @@ -205,7 +207,7 @@ void IUIScene_TradingMenu::updateDisplay() ByteArrayOutputStream rawOutput; DataOutputStream output(&rawOutput); output.writeInt(firstValidTrade); - Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray()))); + Minecraft::GetInstance()->getConnection(getPad())->send(std::make_shared(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())); } } diff --git a/Minecraft.Client/Common/UI/UI.h b/Minecraft.Client/Common/UI/UI.h index 428b3b904..a7c416f8e 100644 --- a/Minecraft.Client/Common/UI/UI.h +++ b/Minecraft.Client/Common/UI/UI.h @@ -123,4 +123,6 @@ #include "UIScene_TeleportMenu.h" #include "UIScene_EndPoem.h" #include "UIScene_EULA.h" -#include "UIScene_NewUpdateMessage.h" \ No newline at end of file +#include "UIScene_NewUpdateMessage.h" + +extern ConsoleUIController ui; \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp index 06dcd64ca..c1381c44c 100644 --- a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp @@ -212,7 +212,7 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, if( icon != TUTORIAL_NO_ICON ) { m_iconIsFoil = false; - m_iconItem = shared_ptr(new ItemInstance(icon,1,iAuxVal)); + m_iconItem = std::make_shared(icon, 1, iAuxVal); } else { @@ -241,7 +241,7 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, { iAuxVal = 0; } - m_iconItem = shared_ptr(new ItemInstance(iconId,1,iAuxVal)); + m_iconItem = std::make_shared(iconId, 1, iAuxVal); temp.replace(iconTagStartPos, iconEndPos - iconTagStartPos + closeTag.length(), L""); } @@ -250,63 +250,63 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, // remove any icon text else if(temp.find(L"{*CraftingTableIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::workBench_Id,1,0)); + m_iconItem = std::make_shared(Tile::workBench_Id, 1, 0); } else if(temp.find(L"{*SticksIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::stick_Id,1,0)); + m_iconItem = std::make_shared(Item::stick_Id, 1, 0); } else if(temp.find(L"{*PlanksIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::wood_Id,1,0)); + m_iconItem = std::make_shared(Tile::wood_Id, 1, 0); } else if(temp.find(L"{*WoodenShovelIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::shovel_wood_Id,1,0)); + m_iconItem = std::make_shared(Item::shovel_wood_Id, 1, 0); } else if(temp.find(L"{*WoodenHatchetIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::hatchet_wood_Id,1,0)); + m_iconItem = std::make_shared(Item::hatchet_wood_Id, 1, 0); } else if(temp.find(L"{*WoodenPickaxeIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::pickAxe_wood_Id,1,0)); + m_iconItem = std::make_shared(Item::pickAxe_wood_Id, 1, 0); } else if(temp.find(L"{*FurnaceIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::furnace_Id,1,0)); + m_iconItem = std::make_shared(Tile::furnace_Id, 1, 0); } else if(temp.find(L"{*WoodenDoorIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::door_wood,1,0)); + m_iconItem = std::make_shared(Item::door_wood, 1, 0); } else if(temp.find(L"{*TorchIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::torch_Id,1,0)); + m_iconItem = std::make_shared(Tile::torch_Id, 1, 0); } else if(temp.find(L"{*BoatIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::boat_Id,1,0)); + m_iconItem = std::make_shared(Item::boat_Id, 1, 0); } else if(temp.find(L"{*FishingRodIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::fishingRod_Id,1,0)); + m_iconItem = std::make_shared(Item::fishingRod_Id, 1, 0); } else if(temp.find(L"{*FishIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::fish_raw_Id,1,0)); + m_iconItem = std::make_shared(Item::fish_raw_Id, 1, 0); } else if(temp.find(L"{*MinecartIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Item::minecart_Id,1,0)); + m_iconItem = std::make_shared(Item::minecart_Id, 1, 0); } else if(temp.find(L"{*RailIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::rail_Id,1,0)); + m_iconItem = std::make_shared(Tile::rail_Id, 1, 0); } else if(temp.find(L"{*PoweredRailIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::goldenRail_Id,1,0)); + m_iconItem = std::make_shared(Tile::goldenRail_Id, 1, 0); } else if(temp.find(L"{*StructuresIcon*}")!=wstring::npos) { @@ -320,7 +320,7 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, } else if(temp.find(L"{*StoneIcon*}")!=wstring::npos) { - m_iconItem = shared_ptr(new ItemInstance(Tile::stone_Id,1,0)); + m_iconItem = std::make_shared(Tile::stone_Id, 1, 0); } else { diff --git a/Minecraft.Client/Common/UI/UIGroup.cpp b/Minecraft.Client/Common/UI/UIGroup.cpp index be9054c99..ab62e4c46 100644 --- a/Minecraft.Client/Common/UI/UIGroup.cpp +++ b/Minecraft.Client/Common/UI/UIGroup.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "UIGroup.h" +#include "UI.h" + UIGroup::UIGroup(EUIGroup group, int iPad) { m_group = group; diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp index 9029e9ffc..d3b79c3f2 100644 --- a/Minecraft.Client/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Common/UI/UIScene.cpp @@ -389,21 +389,22 @@ void UIScene::loadMovie() void UIScene::getDebugMemoryUseRecursive(const wstring &moviePath, IggyMemoryUseInfo &memoryInfo) { - rrbool res; - IggyMemoryUseInfo internalMemoryInfo; - int internalIteration = 0; - while(res = IggyDebugGetMemoryUseInfo ( swf , - nullptr , - 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, internalMemoryInfo.subcategory, - internalMemoryInfo.static_allocation_bytes, internalMemoryInfo.static_allocation_count, internalMemoryInfo.dynamic_allocation_bytes, internalMemoryInfo.dynamic_allocation_count); - ++internalIteration; - if(internalMemoryInfo.subcategory_stringlen > memoryInfo.subcategory_stringlen) getDebugMemoryUseRecursive(moviePath, internalMemoryInfo); - } + rrbool res; + IggyMemoryUseInfo internalMemoryInfo; + int internalIteration = 0; + 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, internalMemoryInfo.subcategory, + internalMemoryInfo.static_allocation_bytes, internalMemoryInfo.static_allocation_count, internalMemoryInfo.dynamic_allocation_bytes, internalMemoryInfo.dynamic_allocation_count); + ++internalIteration; + if (internalMemoryInfo.subcategory_stringlen > memoryInfo.subcategory_stringlen) + getDebugMemoryUseRecursive(moviePath, internalMemoryInfo); + } } void UIScene::PrintTotalMemoryUsage(__int64 &totalStatic, __int64 &totalDynamic) @@ -416,7 +417,7 @@ void UIScene::PrintTotalMemoryUsage(__int64 &totalStatic, __int64 &totalDynamic) __int64 sceneStatic = 0; __int64 sceneDynamic = 0; while(res = IggyDebugGetMemoryUseInfo ( swf , - nullptr , + 0 , "" , 0 , iteration , diff --git a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp index cf1ff7f33..64e123736 100644 --- a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp @@ -336,16 +336,16 @@ void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion *region) switch(icon) { case 0: - item = shared_ptr(new ItemInstance(Item::emerald) ); + item = std::make_shared(Item::emerald); break; case 1: - item = shared_ptr(new ItemInstance(Item::diamond) ); + item = std::make_shared(Item::diamond); break; case 2: - item = shared_ptr(new ItemInstance(Item::goldIngot) ); + item = std::make_shared(Item::goldIngot); break; case 3: - item = shared_ptr(new ItemInstance(Item::ironIngot) ); + item = std::make_shared(Item::ironIngot); break; default: assert(false); diff --git a/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp index 1ac0c91a0..ba2cd8452 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreativeMenu.cpp @@ -21,7 +21,7 @@ UIScene_CreativeMenu::UIScene_CreativeMenu(int iPad, void *_initData, UILayer *p InventoryScreenInput *initData = static_cast(_initData); - shared_ptr creativeContainer = shared_ptr(new SimpleContainer( 0, L"", false, TabSpec::MAX_SIZE )); + shared_ptr creativeContainer = std::make_shared(0, L"", false, TabSpec::MAX_SIZE); itemPickerMenu = new ItemPickerMenu(creativeContainer, initData->player->inventory); Initialize( initData->iPad, itemPickerMenu, false, -1, eSectionInventoryCreativeUsing, eSectionInventoryCreativeMax, initData->bNavigateBack); diff --git a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp index eed4bbe1b..d6381dd0a 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp @@ -147,7 +147,7 @@ void UIScene_DebugOverlay::customDraw(IggyCustomDrawCallbackRegion *region) } else { - shared_ptr item = shared_ptr( new ItemInstance(itemId,1,0) ); + shared_ptr item = std::make_shared(itemId, 1, 0); if(item != nullptr) customDrawSlotControl(region,m_iPad,item,1.0f,false,false); } } diff --git a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp index 0dfde06d6..e89c06261 100644 --- a/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp +++ b/Minecraft.Client/Common/UI/UIScene_FullscreenProgress.cpp @@ -4,7 +4,6 @@ #include "..\..\Minecraft.h" #include "..\..\ProgressRenderer.h" - UIScene_FullscreenProgress::UIScene_FullscreenProgress(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { // Setup all the Iggy references we need for this scene diff --git a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp index 72f9e4fd2..51992e322 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp @@ -126,7 +126,7 @@ void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player->connection) { - player->connection->send( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions) ) ); + player->connection->send(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions)); } } diff --git a/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp index dc11b524d..7fc3d0357 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameInfoMenu.cpp @@ -448,7 +448,7 @@ int UIScene_InGameInfoMenu::KickPlayerReturned(void *pParam,int iPad,C4JStorage: shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer->connection) { - localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); + localPlayer->connection->send(std::make_shared(smallId)); } } diff --git a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp index fb570fdc4..ca28cb7ef 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp @@ -6,7 +6,6 @@ #include "..\..\ClientConnection.h" #include "..\..\..\Minecraft.World\net.minecraft.network.packet.h" - #define CHECKBOXES_TIMER_ID 0 #define CHECKBOXES_TIMER_TIME 100 @@ -405,7 +404,7 @@ void UIScene_InGamePlayerOptionsMenu::handleInput(int iPad, int key, bool repeat shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player->connection) { - player->connection->send( shared_ptr( new PlayerInfoPacket( m_networkSmallId, -1, m_playerPrivileges) ) ); + player->connection->send(std::make_shared(m_networkSmallId, -1, m_playerPrivileges)); } } navigateBack(); @@ -455,7 +454,7 @@ int UIScene_InGamePlayerOptionsMenu::KickPlayerReturned(void *pParam,int iPad,C4 shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer->connection) { - localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); + localPlayer->connection->send(std::make_shared(smallId)); } // Fix for #61494 - [CRASH]: TU7: Code: Multiplayer: Title may crash while kicking a player from an online game. diff --git a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp index a5b8947b3..ed0b3151f 100644 --- a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp @@ -9,12 +9,12 @@ #define PLAYER_ONLINE_TIMER_TIME 100 // if the value is greater than 32000, it's an xzp icon that needs displayed, rather than the game icon -const int UIScene_LeaderboardsMenu::TitleIcons[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][7] = +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, nullptr }, - { 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, nullptr }, - { UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDERJOKEY, UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIEPIGMAN, UIControl_LeaderboardList::e_ICON_TYPE_SLIME }, + {UIControl_LeaderboardList::e_ICON_TYPE_WALKED, UIControl_LeaderboardList::e_ICON_TYPE_FALLEN, Item::minecart_Id, Item::boat_Id, -1}, + {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, -1}, + {UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDERJOKEY, UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIEPIGMAN, UIControl_LeaderboardList::e_ICON_TYPE_SLIME}, }; const UIScene_LeaderboardsMenu::LeaderboardDescriptor UIScene_LeaderboardsMenu::LEADERBOARD_DESCRIPTORS[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][4] = { { @@ -971,7 +971,7 @@ void UIScene_LeaderboardsMenu::customDraw(IggyCustomDrawCallbackRegion *region) } else { - shared_ptr item = shared_ptr( new ItemInstance(TitleIcons[m_currentLeaderboard][slotId], 1, 0) ); + shared_ptr item = std::make_shared(TitleIcons[m_currentLeaderboard][slotId], 1, 0); customDrawSlotControl(region,m_iPad,item,1.0f,false,false); } } diff --git a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp index 679daff1e..72e30a339 100644 --- a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp @@ -97,7 +97,7 @@ void UIScene_SignEntryMenu::tick() shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player != nullptr && player->connection && player->connection->isStarted()) { - player->connection->send( shared_ptr( new SignUpdatePacket(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages()) ) ); + player->connection->send(std::make_shared(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages())); } } ui.CloseUIScenes(m_iPad); diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp index 49217c5cd..9b64dbcb5 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp @@ -188,7 +188,7 @@ HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHa { HXUIDC hDC = pRenderData->hDC; CXuiControl xuiControl(m_hObj); - if(m_item == nullptr) m_item = shared_ptr( new ItemInstance(m_iID, m_iCount, m_iAuxVal) ); + if(m_item == nullptr) m_item = std::make_shared(m_iID, m_iCount, m_iAuxVal); // build and render with the game call diff --git a/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp b/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp index 01a4b573b..d8c06ae14 100644 --- a/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp +++ b/Minecraft.Client/Common/XUI/XUI_DebugItemEditor.cpp @@ -60,7 +60,7 @@ HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfH Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player != nullptr && player->connection) player->connection->send( shared_ptr( new ContainerSetSlotPacket(m_menu->containerId, m_slot->index, m_item) ) ); + if(player != nullptr && player->connection) player->connection->send(std::make_shared(m_menu->containerId, m_slot->index, m_item)); } // kill the crafting xui app.NavigateBack(m_iPad); @@ -76,7 +76,7 @@ HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfH HRESULT CScene_DebugItemEditor::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled) { - if(m_item == nullptr) m_item = shared_ptr( new ItemInstance(0,1,0) ); + if(m_item == nullptr) m_item = std::make_shared(0, 1, 0); if(hObjSource == m_itemId) { int id = 0; diff --git a/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp b/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp index 64f1f22c6..5030a7923 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGameHostOptions.cpp @@ -78,7 +78,7 @@ HRESULT CScene_InGameHostOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& r shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player != nullptr && player->connection) { - player->connection->send( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions) ) ); + player->connection->send(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions)); } } diff --git a/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp b/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp index d22230a91..35e083396 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGameInfo.cpp @@ -529,7 +529,7 @@ int CScene_InGameInfo::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMes shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer != nullptr && localPlayer->connection) { - localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); + localPlayer->connection->send(std::make_shared(smallId)); } } diff --git a/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp b/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp index 7903ff8eb..4ab2a54a2 100644 --- a/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp +++ b/Minecraft.Client/Common/XUI/XUI_InGamePlayerOptions.cpp @@ -280,7 +280,7 @@ HRESULT CScene_InGamePlayerOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& shared_ptr player = pMinecraft->localplayers[m_iPad]; if(player != nullptr && player->connection) { - player->connection->send( shared_ptr( new PlayerInfoPacket( m_networkSmallId, -1, m_playerPrivileges) ) ); + player->connection->send(std::make_shared(m_networkSmallId, -1, m_playerPrivileges)); } } @@ -339,7 +339,7 @@ int CScene_InGamePlayerOptions::KickPlayerReturned(void *pParam,int iPad,C4JStor shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer != nullptr && localPlayer->connection) { - localPlayer->connection->send( shared_ptr( new KickPlayerPacket(smallId) ) ); + localPlayer->connection->send(std::make_shared(smallId)); } // Fix for #61494 - [CRASH]: TU7: Code: Multiplayer: Title may crash while kicking a player from an online game. diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp index 345d426dd..0fa3e7803 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Inventory_Creative.cpp @@ -60,7 +60,7 @@ HRESULT CXuiSceneInventoryCreative::OnInit( XUIMessageInit *pInitData, BOOL &bHa initData->player->awardStat(GenericStats::openInventory(), GenericStats::param_noArgs()); // 4J JEV - Item Picker Menu - shared_ptr creativeContainer = shared_ptr(new SimpleContainer( 0, TabSpec::MAX_SIZE + 9 )); + shared_ptr creativeContainer = std::make_shared(0, TabSpec::MAX_SIZE + 9); itemPickerMenu = new ItemPickerMenu(creativeContainer, initData->player->inventory); // 4J JEV - InitDataAssociations. diff --git a/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp b/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp index 6c54c3e31..963d8f103 100644 --- a/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp +++ b/Minecraft.Client/Common/XUI/XUI_SignEntry.cpp @@ -77,7 +77,7 @@ HRESULT CScene_SignEntry::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* p shared_ptr player = pMinecraft->localplayers[pNotifyPressData->UserIndex]; if(player != nullptr && player->connection && player->connection->isStarted()) { - player->connection->send( shared_ptr( new SignUpdatePacket(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages()) ) ); + player->connection->send(std::make_shared(m_sign->x, m_sign->y, m_sign->z, m_sign->IsVerified(), m_sign->IsCensored(), m_sign->GetMessages())); } } app.CloseXuiScenes(pNotifyPressData->UserIndex); diff --git a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp index 02b7d9db2..3c9c936eb 100644 --- a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp @@ -289,7 +289,7 @@ wstring CScene_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWS if( icon != TUTORIAL_NO_ICON ) { bool itemIsFoil = false; - itemIsFoil = (shared_ptr(new ItemInstance(icon,1,iAuxVal)))->isFoil(); + itemIsFoil = (std::make_shared(icon, 1, iAuxVal))->isFoil(); if(!itemIsFoil) itemIsFoil = isFoil; m_pCraftingPic->SetIcon(m_iPad, icon,iAuxVal,1,10,31,false,itemIsFoil); @@ -322,7 +322,7 @@ wstring CScene_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWS } bool itemIsFoil = false; - itemIsFoil = (shared_ptr(new ItemInstance(iconId,1,iAuxVal)))->isFoil(); + itemIsFoil = (std::make_shared(iconId, 1, iAuxVal))->isFoil(); if(!itemIsFoil) itemIsFoil = isFoil; m_pCraftingPic->SetIcon(m_iPad, iconId,iAuxVal,1,10,31,false,itemIsFoil); diff --git a/Minecraft.Client/ConnectScreen.cpp b/Minecraft.Client/ConnectScreen.cpp index c34a219e0..18d50a527 100644 --- a/Minecraft.Client/ConnectScreen.cpp +++ b/Minecraft.Client/ConnectScreen.cpp @@ -17,7 +17,7 @@ ConnectScreen::ConnectScreen(Minecraft *minecraft, const wstring& ip, int port) // 4J - removed from separate thread, but need to investigate what we actually need here connection = new ClientConnection(minecraft, ip, port); if (aborted) return; - connection->send( shared_ptr( new PreLoginPacket(minecraft->user->name) ) ); + connection->send(std::make_shared(minecraft->user->name)); #else new Thread() { diff --git a/Minecraft.Client/DLCTexturePack.cpp b/Minecraft.Client/DLCTexturePack.cpp index 1e72bb260..f1304a9ef 100644 --- a/Minecraft.Client/DLCTexturePack.cpp +++ b/Minecraft.Client/DLCTexturePack.cpp @@ -9,6 +9,7 @@ #include "Common\DLC\DLCLocalisationFile.h" #include "..\Minecraft.World\StringHelpers.h" #include "StringTable.h" +#include "Common/UI/UI.h" #include "Common\DLC\DLCAudioFile.h" #if defined _XBOX || defined _WINDOWS64 diff --git a/Minecraft.Client/EntityTileRenderer.cpp b/Minecraft.Client/EntityTileRenderer.cpp index deed369e8..6a84e3a3a 100644 --- a/Minecraft.Client/EntityTileRenderer.cpp +++ b/Minecraft.Client/EntityTileRenderer.cpp @@ -8,9 +8,9 @@ EntityTileRenderer *EntityTileRenderer::instance = new EntityTileRenderer; EntityTileRenderer::EntityTileRenderer() { - chest = shared_ptr(new ChestTileEntity()); - trappedChest = shared_ptr(new ChestTileEntity(ChestTile::TYPE_TRAP)); - enderChest = shared_ptr(new EnderChestTileEntity()); + chest = std::make_shared(); + trappedChest = std::make_shared(ChestTile::TYPE_TRAP); + enderChest = std::make_shared(); } void EntityTileRenderer::render(Tile *tile, int data, float brightness, float alpha, bool setColor, bool useCompiled) diff --git a/Minecraft.Client/EntityTracker.cpp b/Minecraft.Client/EntityTracker.cpp index 8171e50d4..087227e77 100644 --- a/Minecraft.Client/EntityTracker.cpp +++ b/Minecraft.Client/EntityTracker.cpp @@ -85,7 +85,7 @@ void EntityTracker::addEntity(shared_ptr e, int range, int updateInterva { __debugbreak(); } - shared_ptr te = shared_ptr( new TrackedEntity(e, range, updateInterval, trackDeltas) ); + shared_ptr te = std::make_shared(e, range, updateInterval, trackDeltas); entities.insert(te); entityMap[e->entityId] = te; te->updatePlayers(this, &level->players); diff --git a/Minecraft.Client/FireworksParticles.cpp b/Minecraft.Client/FireworksParticles.cpp index c8a109c4b..c17283ac4 100644 --- a/Minecraft.Client/FireworksParticles.cpp +++ b/Minecraft.Client/FireworksParticles.cpp @@ -189,7 +189,7 @@ void FireworksParticles::FireworksStarter::tick() float r = static_cast((rgb & 0xff0000) >> 16) / 255.0f; float g = static_cast((rgb & 0x00ff00) >> 8) / 255.0f; float b = static_cast((rgb & 0x0000ff) >> 0) / 255.0f; - shared_ptr fireworksOverlayParticle = shared_ptr(new FireworksParticles::FireworksOverlayParticle(level, x, y, z)); + shared_ptr fireworksOverlayParticle = std::make_shared(level, x, y, z); fireworksOverlayParticle->setColor(r, g, b); fireworksOverlayParticle->setAlpha(0.99f); // 4J added engine->add(fireworksOverlayParticle); @@ -224,7 +224,7 @@ bool FireworksParticles::FireworksStarter::isFarAwayFromCamera() void FireworksParticles::FireworksStarter::createParticle(double x, double y, double z, double xa, double ya, double za, intArray rgbColors, intArray fadeColors, bool trail, bool flicker) { - shared_ptr fireworksSparkParticle = shared_ptr(new FireworksSparkParticle(level, x, y, z, xa, ya, za, engine)); + shared_ptr fireworksSparkParticle = std::make_shared(level, x, y, z, xa, ya, za, engine); fireworksSparkParticle->setAlpha(0.99f); fireworksSparkParticle->setTrail(trail); fireworksSparkParticle->setFlicker(flicker); @@ -433,7 +433,7 @@ void FireworksParticles::FireworksSparkParticle::tick() if (trail && (age < lifetime / 2) && ((age + lifetime) % 2) == 0) { - shared_ptr fireworksSparkParticle = shared_ptr(new FireworksParticles::FireworksSparkParticle(level, x, y, z, 0, 0, 0, engine)); + shared_ptr fireworksSparkParticle = std::make_shared(level, x, y, z, 0, 0, 0, engine); fireworksSparkParticle->setAlpha(0.99f); fireworksSparkParticle->setColor(rCol, gCol, bCol); fireworksSparkParticle->age = fireworksSparkParticle->lifetime / 2; diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index 3c11db1f6..9758fc166 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -327,13 +327,14 @@ void GameRenderer::pick(float a) else if (p != nullptr) { double dd = from->distanceTo(p->pos); - if (e == mc->cameraTargetPlayer->riding != nullptr) - { - if (nearest == 0) - { - hovered = e; - } - } + auto const riding = mc->cameraTargetPlayer->riding; + if (riding != nullptr && e == riding) + { + if (nearest == 0) + { + hovered = e; + } + } else { hovered = e; @@ -1672,7 +1673,7 @@ void GameRenderer::tickRain() { if (Tile::tiles[t]->material == Material::lava) { - mc->particleEngine->add( shared_ptr( new SmokeParticle(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za, 0, 0, 0) ) ); + mc->particleEngine->add(std::make_shared(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za, 0, 0, 0)); } else { @@ -1682,7 +1683,7 @@ void GameRenderer::tickRain() rainPosY = y + 0.1f - Tile::tiles[t]->getShapeY0(); rainPosZ = z + za; } - mc->particleEngine->add( shared_ptr( new WaterDropParticle(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za) ) ); + mc->particleEngine->add(std::make_shared(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za)); } } } diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index 921472f20..24c186e0f 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -28,6 +28,7 @@ #include "..\Minecraft.World\net.minecraft.world.h" #include "..\Minecraft.World\LevelChunk.h" #include "..\Minecraft.World\Biome.h" +#include "Common/UI/UI.h" ResourceLocation Gui::PUMPKIN_BLUR_LOCATION = ResourceLocation(TN__BLUR__MISC_PUMPKINBLUR); diff --git a/Minecraft.Client/ItemFrameRenderer.cpp b/Minecraft.Client/ItemFrameRenderer.cpp index 33c4cd8ac..55354aac8 100644 --- a/Minecraft.Client/ItemFrameRenderer.cpp +++ b/Minecraft.Client/ItemFrameRenderer.cpp @@ -112,7 +112,7 @@ void ItemFrameRenderer::drawItem(shared_ptr entity) shared_ptr instance = entity->getItem(); if (instance == nullptr) return; - shared_ptr itemEntity = shared_ptr(new ItemEntity(entity->level, 0, 0, 0, instance)); + shared_ptr itemEntity = std::make_shared(entity->level, 0, 0, 0, instance); itemEntity->getItem()->count = 1; itemEntity->bobOffs = 0; diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index dc7b8987d..eab39c4e9 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -2736,32 +2736,32 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle switch(eParticleType) { case eParticleType_hugeexplosion: - particle = shared_ptr(new HugeExplosionSeedParticle(lev, x, y, z, xa, ya, za)); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_largeexplode: - particle = shared_ptr(new HugeExplosionParticle(textures, lev, x, y, z, xa, ya, za)); + particle = std::make_shared(textures, lev, x, y, z, xa, ya, za); break; case eParticleType_fireworksspark: - particle = shared_ptr(new FireworksParticles::FireworksSparkParticle(lev, x, y, z, xa, ya, za, mc->particleEngine)); + particle = std::make_shared(lev, x, y, z, xa, ya, za, mc->particleEngine); particle->setAlpha(0.99f); break; case eParticleType_bubble: - particle = shared_ptr( new BubbleParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_suspended: - particle = shared_ptr( new SuspendedParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_depthsuspend: - particle = shared_ptr( new SuspendedTownParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_townaura: - particle = shared_ptr( new SuspendedTownParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_crit: { - shared_ptr critParticle2 = shared_ptr(new CritParticle2(lev, x, y, z, xa, ya, za)); + shared_ptr critParticle2 = std::make_shared(lev, x, y, z, xa, ya, za); critParticle2->CritParticle2PostConstructor(); particle = shared_ptr( critParticle2 ); // request from 343 to set pink for the needler in the Halo Texture Pack @@ -2787,7 +2787,7 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle break; case eParticleType_magicCrit: { - shared_ptr critParticle2 = shared_ptr(new CritParticle2(lev, x, y, z, xa, ya, za)); + shared_ptr critParticle2 = std::make_shared(lev, x, y, z, xa, ya, za); critParticle2->CritParticle2PostConstructor(); particle = shared_ptr(critParticle2); particle->setColor(particle->getRedCol() * 0.3f, particle->getGreenCol() * 0.8f, particle->getBlueCol()); @@ -2795,7 +2795,7 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle } break; case eParticleType_smoke: - particle = shared_ptr( new SmokeParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_endportal: // 4J - Added. { @@ -2809,103 +2809,103 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle } break; case eParticleType_mobSpell: - particle = shared_ptr(new SpellParticle(lev, x, y, z, 0, 0, 0)); + particle = std::make_shared(lev, x, y, z, 0, 0, 0); particle->setColor(static_cast(xa), static_cast(ya), static_cast(za)); break; case eParticleType_mobSpellAmbient: - particle = shared_ptr(new SpellParticle(lev, x, y, z, 0, 0, 0)); + particle = std::make_shared(lev, x, y, z, 0, 0, 0); particle->setAlpha(0.15f); particle->setColor(static_cast(xa), static_cast(ya), static_cast(za)); break; case eParticleType_spell: - particle = shared_ptr( new SpellParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_witchMagic: { - particle = shared_ptr(new SpellParticle(lev, x, y, z, xa, ya, za)); + particle = std::make_shared(lev, x, y, z, xa, ya, za); dynamic_pointer_cast(particle)->setBaseTex(9 * 16); float randBrightness = lev->random->nextFloat() * 0.5f + 0.35f; particle->setColor(1 * randBrightness, 0 * randBrightness, 1 * randBrightness); } break; case eParticleType_instantSpell: - particle = shared_ptr(new SpellParticle(lev, x, y, z, xa, ya, za)); + particle = std::make_shared(lev, x, y, z, xa, ya, za); dynamic_pointer_cast(particle)->setBaseTex(9 * 16); break; case eParticleType_note: - particle = shared_ptr( new NoteParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_netherportal: - particle = shared_ptr( new NetherPortalParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_ender: - particle = shared_ptr( new EnderParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_enchantmenttable: - particle = shared_ptr(new EchantmentTableParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_explode: - particle = shared_ptr( new ExplodeParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_flame: - particle = shared_ptr( new FlameParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_lava: - particle = shared_ptr( new LavaParticle(lev, x, y, z) ); + particle = std::make_shared(lev, x, y, z); break; case eParticleType_footstep: - particle = shared_ptr( new FootstepParticle(textures, lev, x, y, z) ); + particle = std::make_shared(textures, lev, x, y, z); break; case eParticleType_splash: - particle = shared_ptr( new SplashParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_largesmoke: - particle = shared_ptr( new SmokeParticle(lev, x, y, z, xa, ya, za, 2.5f) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za, 2.5f); break; case eParticleType_reddust: - particle = shared_ptr( new RedDustParticle(lev, x, y, z, static_cast(xa), static_cast(ya), static_cast(za)) ); + particle = std::make_shared(lev, x, y, z, static_cast(xa), static_cast(ya), static_cast(za)); break; case eParticleType_snowballpoof: - particle = shared_ptr( new BreakingItemParticle(lev, x, y, z, Item::snowBall, textures) ); + particle = std::make_shared(lev, x, y, z, Item::snowBall, textures); break; case eParticleType_dripWater: - particle = shared_ptr( new DripParticle(lev, x, y, z, Material::water) ); + particle = std::make_shared(lev, x, y, z, Material::water); break; case eParticleType_dripLava: - particle = shared_ptr( new DripParticle(lev, x, y, z, Material::lava) ); + particle = std::make_shared(lev, x, y, z, Material::lava); break; case eParticleType_snowshovel: - particle = shared_ptr( new SnowShovelParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_slime: - particle = shared_ptr( new BreakingItemParticle(lev, x, y, z, Item::slimeBall, textures)); + particle = std::make_shared(lev, x, y, z, Item::slimeBall, textures); break; case eParticleType_heart: - particle = shared_ptr( new HeartParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; case eParticleType_angryVillager: - particle = shared_ptr( new HeartParticle(lev, x, y + 0.5f, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y + 0.5f, z, xa, ya, za); particle->setMiscTex(1 + 16 * 5); particle->setColor(1, 1, 1); break; case eParticleType_happyVillager: - particle = shared_ptr( new SuspendedTownParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); particle->setMiscTex(2 + 16 * 5); particle->setColor(1, 1, 1); break; case eParticleType_dragonbreath: - particle = shared_ptr( new DragonBreathParticle(lev, x, y, z, xa, ya, za) ); + particle = std::make_shared(lev, x, y, z, xa, ya, za); break; default: if( ( eParticleType >= eParticleType_iconcrack_base ) && ( eParticleType <= eParticleType_iconcrack_last ) ) { int id = PARTICLE_CRACK_ID(eParticleType), data = PARTICLE_CRACK_DATA(eParticleType); - particle = shared_ptr(new BreakingItemParticle(lev, x, y, z, xa, ya, za, Item::items[id], textures, data)); + particle = std::make_shared(lev, x, y, z, xa, ya, za, Item::items[id], textures, data); } else if( ( eParticleType >= eParticleType_tilecrack_base ) && ( eParticleType <= eParticleType_tilecrack_last ) ) { int id = PARTICLE_CRACK_ID(eParticleType), data = PARTICLE_CRACK_DATA(eParticleType); - particle = dynamic_pointer_cast( shared_ptr(new TerrainParticle(lev, x, y, z, xa, ya, za, Tile::tiles[id], 0, data, textures))->init(data) ); + particle = dynamic_pointer_cast(std::make_shared(lev, x, y, z, xa, ya, za, Tile::tiles[id], 0, data, textures)->init(data) ); } } diff --git a/Minecraft.Client/LivingEntityRenderer.cpp b/Minecraft.Client/LivingEntityRenderer.cpp index 7e99f0ba6..600a66554 100644 --- a/Minecraft.Client/LivingEntityRenderer.cpp +++ b/Minecraft.Client/LivingEntityRenderer.cpp @@ -306,7 +306,7 @@ void LivingEntityRenderer::renderArrows(shared_ptr mob, float a) int arrowCount = mob->getArrowCount(); if (arrowCount > 0) { - shared_ptr arrow = shared_ptr(new Arrow(mob->level, mob->x, mob->y, mob->z)); + shared_ptr arrow = std::make_shared(mob->level, mob->x, mob->y, mob->z); Random random = Random(mob->entityId); Lighting::turnOff(); for (int i = 0; i < arrowCount; i++) diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index 6e06f9ef6..f7b90f240 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -56,7 +56,7 @@ #ifndef _DURANGO #include "..\Minecraft.World\CommonStats.h" #endif - +extern ConsoleUIController ui; LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dimension) : Player(level, user->name) @@ -705,21 +705,21 @@ bool LocalPlayer::openTrading(shared_ptr traderTarget, const wstring & void LocalPlayer::crit(shared_ptr e) { - shared_ptr critParticle = shared_ptr( new CritParticle((Level *)minecraft->level, e) ); + shared_ptr critParticle = std::make_shared(reinterpret_cast(minecraft->level), e); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add(critParticle); } void LocalPlayer::magicCrit(shared_ptr e) { - shared_ptr critParticle = shared_ptr( new CritParticle((Level *)minecraft->level, e, eParticleType_magicCrit) ); + shared_ptr critParticle = std::make_shared(reinterpret_cast(minecraft->level), e, eParticleType_magicCrit); critParticle->CritParticlePostConstructor(); minecraft->particleEngine->add(critParticle); } void LocalPlayer::take(shared_ptr e, int orgCount) { - minecraft->particleEngine->add( shared_ptr( new TakeAnimationParticle((Level *)minecraft->level, e, shared_from_this(), -0.5f) ) ); + minecraft->particleEngine->add(std::make_shared(reinterpret_cast(minecraft->level), e, shared_from_this(), -0.5f)); } void LocalPlayer::chat(const wstring& message) diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 7048c8d01..3762034db 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -91,6 +91,8 @@ int Minecraft::frameTimePos = 0; __int64 Minecraft::warezTime = 0; File Minecraft::workDir = File(L""); +extern ConsoleUIController ui; + #ifdef __PSVITA__ TOUCHSCREENRECT QuickSelectRect[3]= @@ -932,7 +934,7 @@ bool Minecraft::addLocalPlayer(int idx) if(success) { app.DebugPrintf("Adding temp local player on pad %d\n", idx); - localplayers[idx] = shared_ptr( new MultiplayerLocalPlayer(this, level, user, nullptr ) ); + localplayers[idx] = shared_ptr(new MultiplayerLocalPlayer(this, level, user, nullptr)); localgameModes[idx] = nullptr; updatePlayerViewportAssignments(); @@ -1131,7 +1133,7 @@ void Minecraft::removeLocalPlayerIdx(int idx) } else if( m_pendingLocalConnections[idx] != nullptr ) { - m_pendingLocalConnections[idx]->sendAndDisconnect( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );; + m_pendingLocalConnections[idx]->sendAndDisconnect(std::make_shared(DisconnectPacket::eDisconnect_Quitting));; delete m_pendingLocalConnections[idx]; m_pendingLocalConnections[idx] = nullptr; g_NetworkManager.RemoveLocalPlayerByUserIndex(idx); diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index ad68b47fd..6a38ded24 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -226,7 +226,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom wstring message = L"[Server] " + JoinConsoleCommandTokens(tokens, 1); if (playerList != nullptr) { - playerList->broadcastAll(shared_ptr(new ChatPacket(message))); + playerList->broadcastAll(std::make_shared(message)); } server->info(message); return true; @@ -904,7 +904,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring levelChunksNeedConverted = true; pSave->ConvertToLocalPlatform(); // check if we need to convert this file from PS3->PS4 - storage = shared_ptr(new McRegionLevelStorage(pSave, File(L"."), name, true)); + storage = std::make_shared(pSave, File(L"."), name, true); } else { @@ -931,7 +931,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring storage = shared_ptr(new McRegionLevelStorage(newFormatSave, File(L"."), name, true)); #else - storage = shared_ptr(new McRegionLevelStorage(new ConsoleSaveFileOriginal( L"" ), File(L"."), name, true)); + storage = std::make_shared(new ConsoleSaveFileOriginal(L""), File(L"."), name, true); #endif } @@ -1885,7 +1885,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) players->saveAll(Minecraft::GetInstance()->progressRenderer); } - players->broadcastAll( shared_ptr( new UpdateProgressPacket(20) ) ); + players->broadcastAll(std::make_shared(20)); for (unsigned int j = 0; j < levels.length; j++) { @@ -1896,7 +1896,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) ServerLevel *level = levels[levels.length - 1 - j]; level->save(true, Minecraft::GetInstance()->progressRenderer, (eAction==eXuiServerAction_AutoSaveGame)); - players->broadcastAll( shared_ptr( new UpdateProgressPacket(33 + (j*33) ) ) ); + players->broadcastAll(std::make_shared(33 + (j * 33))); } if( !s_bServerHalted ) { @@ -1911,7 +1911,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) { shared_ptr player = players->players.at(0); size_t id = (size_t) param; - player->drop( shared_ptr( new ItemInstance(id, 1, 0 ) ) ); + player->drop(std::make_shared(id, 1, 0)); } break; case eXuiServerAction_SpawnMob: @@ -1946,14 +1946,14 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) } break; case eXuiServerAction_ServerSettingChanged_Gamertags: - players->broadcastAll( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_OPTIONS, app.GetGameHostOption(eGameHostOption_Gamertags)) ) ); + players->broadcastAll(std::make_shared(ServerSettingsChangedPacket::HOST_OPTIONS, app.GetGameHostOption(eGameHostOption_Gamertags))); break; case eXuiServerAction_ServerSettingChanged_BedrockFog: - players->broadcastAll( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All)) ) ); + players->broadcastAll(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All))); break; case eXuiServerAction_ServerSettingChanged_Difficulty: - players->broadcastAll( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, Minecraft::GetInstance()->options->difficulty) ) ); + players->broadcastAll(std::make_shared(ServerSettingsChangedPacket::HOST_DIFFICULTY, Minecraft::GetInstance()->options->difficulty)); break; case eXuiServerAction_ExportSchematic: #ifndef _CONTENT_PACKAGE @@ -2054,14 +2054,14 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) void MinecraftServer::broadcastStartSavingPacket() { - players->broadcastAll( shared_ptr( new GameEventPacket(GameEventPacket::START_SAVING, 0) ) );; + players->broadcastAll(std::make_shared(GameEventPacket::START_SAVING, 0));; } void MinecraftServer::broadcastStopSavingPacket() { if( !s_bServerHalted ) { - players->broadcastAll( shared_ptr( new GameEventPacket(GameEventPacket::STOP_SAVING, 0) ) );; + players->broadcastAll(std::make_shared(GameEventPacket::STOP_SAVING, 0));; } } @@ -2116,7 +2116,7 @@ void MinecraftServer::tick() if (tickCount % 20 == 0) { - players->broadcastAll( shared_ptr( new SetTimePacket(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT) ) ), level->dimension->id); + players->broadcastAll(std::make_shared(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)), level->dimension->id); } // #ifndef __PS3__ static __int64 stc = 0; diff --git a/Minecraft.Client/MultiPlayerGameMode.cpp b/Minecraft.Client/MultiPlayerGameMode.cpp index 50e3080d7..66fc22a6b 100644 --- a/Minecraft.Client/MultiPlayerGameMode.cpp +++ b/Minecraft.Client/MultiPlayerGameMode.cpp @@ -129,7 +129,7 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) // Skip if we just broke a block — prevents double-break on single clicks if (destroyDelay > 0) return; - connection->send(shared_ptr( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) )); + connection->send(std::make_shared(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); creativeDestroyBlock(minecraft, this, x, y, z, face); destroyDelay = 5; } @@ -137,9 +137,9 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) { if (isDestroying) { - connection->send(shared_ptr(new PlayerActionPacket(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, face))); + connection->send(std::make_shared(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, face)); } - connection->send( shared_ptr( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) ); + connection->send(std::make_shared(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); int t = minecraft->level->getTile(x, y, z); if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player); if (t > 0 && @@ -169,7 +169,7 @@ void MultiPlayerGameMode::stopDestroyBlock() { if (isDestroying) { - connection->send(shared_ptr(new PlayerActionPacket(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1))); + connection->send(std::make_shared(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1)); } isDestroying = false; @@ -193,7 +193,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) if (localPlayerMode->isCreative()) { destroyDelay = 5; - connection->send(shared_ptr( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) ); + connection->send(std::make_shared(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); creativeDestroyBlock(minecraft, this, x, y, z, face); return; } @@ -225,7 +225,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) if (destroyProgress >= 1) { isDestroying = false; - connection->send( shared_ptr( new PlayerActionPacket(PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face) ) ); + connection->send(std::make_shared(PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face)); destroyBlock(x, y, z, face); destroyProgress = 0; destroyTicks = 0; @@ -276,7 +276,7 @@ void MultiPlayerGameMode::ensureHasSentCarriedItem() if (newItem != carriedItem) { carriedItem = newItem; - connection->send( shared_ptr( new SetCarriedItemPacket(carriedItem) ) ); + connection->send(std::make_shared(carriedItem)); } } @@ -379,7 +379,7 @@ bool MultiPlayerGameMode::useItemOn(shared_ptr player, Level *level, sha // Fix for #7904 - Gameplay: Players can dupe torches by throwing them repeatedly into water. if(!bTestUseOnly) { - connection->send( shared_ptr( new UseItemPacket(x, y, z, face, player->inventory->getSelected(), clickX, clickY, clickZ) ) ); + connection->send(std::make_shared(x, y, z, face, player->inventory->getSelected(), clickX, clickY, clickZ)); } return didSomething; } @@ -421,27 +421,27 @@ bool MultiPlayerGameMode::useItem(shared_ptr player, Level *level, share if(!bTestUseOnly) { - connection->send( shared_ptr( new UseItemPacket(-1, -1, -1, 255, player->inventory->getSelected(), 0, 0, 0) ) ); + connection->send(std::make_shared(-1, -1, -1, 255, player->inventory->getSelected(), 0, 0, 0)); } return result; } shared_ptr MultiPlayerGameMode::createPlayer(Level *level) { - return shared_ptr( new MultiplayerLocalPlayer(minecraft, level, minecraft->user, connection) ); + return std::make_shared(minecraft, level, minecraft->user, connection); } void MultiPlayerGameMode::attack(shared_ptr player, shared_ptr entity) { ensureHasSentCarriedItem(); - connection->send( shared_ptr( new InteractPacket(player->entityId, entity->entityId, InteractPacket::ATTACK) ) ); + connection->send(std::make_shared(player->entityId, entity->entityId, InteractPacket::ATTACK)); player->attack(entity); } bool MultiPlayerGameMode::interact(shared_ptr player, shared_ptr entity) { ensureHasSentCarriedItem(); - connection->send(shared_ptr( new InteractPacket(player->entityId, entity->entityId, InteractPacket::INTERACT) ) ); + connection->send(std::make_shared(player->entityId, entity->entityId, InteractPacket::INTERACT)); return player->interact(entity); } @@ -450,21 +450,21 @@ shared_ptr MultiPlayerGameMode::handleInventoryMouseClick(int cont short changeUid = player->containerMenu->backup(player->inventory); shared_ptr clicked = player->containerMenu->clicked(slotNum, buttonNum, quickKeyHeld?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player); - connection->send( shared_ptr( new ContainerClickPacket(containerId, slotNum, buttonNum, quickKeyHeld, clicked, changeUid) ) ); + connection->send(std::make_shared(containerId, slotNum, buttonNum, quickKeyHeld, clicked, changeUid)); return clicked; } void MultiPlayerGameMode::handleInventoryButtonClick(int containerId, int buttonId) { - connection->send(shared_ptr( new ContainerButtonClickPacket(containerId, buttonId) )); + connection->send(std::make_shared(containerId, buttonId)); } void MultiPlayerGameMode::handleCreativeModeItemAdd(shared_ptr clicked, int slot) { if (localPlayerMode->isCreative()) { - connection->send(shared_ptr( new SetCreativeModeSlotPacket(slot, clicked) ) ); + connection->send(std::make_shared(slot, clicked)); } } @@ -472,14 +472,14 @@ void MultiPlayerGameMode::handleCreativeModeItemDrop(shared_ptr cl { if (localPlayerMode->isCreative() && clicked != nullptr) { - connection->send(shared_ptr( new SetCreativeModeSlotPacket(-1, clicked) ) ); + connection->send(std::make_shared(-1, clicked)); } } void MultiPlayerGameMode::releaseUsingItem(shared_ptr player) { ensureHasSentCarriedItem(); - connection->send(shared_ptr( new PlayerActionPacket(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 255) ) ); + connection->send(std::make_shared(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 255)); player->releaseUsingItem(); } @@ -514,7 +514,7 @@ bool MultiPlayerGameMode::handleCraftItem(int recipe, shared_ptr player) { short changeUid = player->containerMenu->backup(player->inventory); - connection->send( shared_ptr( new CraftItemPacket(recipe, changeUid) ) ); + connection->send(std::make_shared(recipe, changeUid)); return true; } @@ -522,5 +522,5 @@ bool MultiPlayerGameMode::handleCraftItem(int recipe, shared_ptr player) void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal, shared_ptr player) { player->SetDebugOptions(uiVal); - connection->send( shared_ptr( new DebugOptionsPacket(uiVal) ) ); + connection->send(std::make_shared(uiVal)); } diff --git a/Minecraft.Client/MultiPlayerLevel.cpp b/Minecraft.Client/MultiPlayerLevel.cpp index d91a1affc..188189be1 100644 --- a/Minecraft.Client/MultiPlayerLevel.cpp +++ b/Minecraft.Client/MultiPlayerLevel.cpp @@ -26,7 +26,7 @@ MultiPlayerLevel::ResetInfo::ResetInfo(int x, int y, int z, int tile, int data) } MultiPlayerLevel::MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty) - : Level(shared_ptr(new MockedLevelStorage()), L"MpServer", Dimension::getNew(dimension), levelSettings, false) + : Level(std::make_shared(), L"MpServer", Dimension::getNew(dimension), levelSettings, false) { minecraft = Minecraft::GetInstance(); @@ -618,7 +618,7 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/) for (auto& it : connections ) { if ( it ) - it->sendAndDisconnect( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) ); + it->sendAndDisconnect(std::make_shared(DisconnectPacket::eDisconnect_Quitting)); } } else @@ -781,7 +781,7 @@ void MultiPlayerLevel::playLocalSound(double x, double y, double z, int iSound, void MultiPlayerLevel::createFireworks(double x, double y, double z, double xd, double yd, double zd, CompoundTag *infoTag) { - minecraft->particleEngine->add(shared_ptr(new FireworksParticles::FireworksStarter(this, x, y, z, xd, yd, zd, minecraft->particleEngine, infoTag))); + minecraft->particleEngine->add(std::make_shared(this, x, y, z, xd, yd, zd, minecraft->particleEngine, infoTag)); } void MultiPlayerLevel::setScoreboard(Scoreboard *scoreboard) @@ -899,7 +899,7 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection *c, bool sendDisc { if( sendDisconnect ) { - c->sendAndDisconnect( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) ); + c->sendAndDisconnect(std::make_shared(DisconnectPacket::eDisconnect_Quitting)); } auto it = find(connections.begin(), connections.end(), c); diff --git a/Minecraft.Client/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/MultiPlayerLocalPlayer.cpp index 57ffb2906..aef7898f2 100644 --- a/Minecraft.Client/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/MultiPlayerLocalPlayer.cpp @@ -76,8 +76,8 @@ void MultiplayerLocalPlayer::tick() { if (isRiding()) { - connection->send(shared_ptr(new MovePlayerPacket::Rot(yRot, xRot, onGround, abilities.flying))); - connection->send(shared_ptr(new PlayerInputPacket(xxa, yya, input->jumping, input->sneaking))); + connection->send(std::make_shared(yRot, xRot, onGround, abilities.flying)); + connection->send(std::make_shared(xxa, yya, input->jumping, input->sneaking)); } else { @@ -96,8 +96,8 @@ void MultiplayerLocalPlayer::sendPosition() bool sprinting = isSprinting(); if (sprinting != lastSprinting) { - if (sprinting) connection->send(shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SPRINTING))); - else connection->send(shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SPRINTING))); + if (sprinting) connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::START_SPRINTING)); + else connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::STOP_SPRINTING)); lastSprinting = sprinting; } @@ -105,8 +105,8 @@ void MultiplayerLocalPlayer::sendPosition() bool sneaking = isSneaking(); if (sneaking != lastSneaked) { - if (sneaking) connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SNEAKING) ) ); - else connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SNEAKING) ) ); + if (sneaking) connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::START_SNEAKING)); + else connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::STOP_SNEAKING)); lastSneaked = sneaking; } @@ -114,8 +114,8 @@ void MultiplayerLocalPlayer::sendPosition() bool idle = isIdle(); if (idle != lastIdle) { - if (idle) connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_IDLEANIM) ) ); - else connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM) ) ); + if (idle) connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::START_IDLEANIM)); + else connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM)); lastIdle = idle; } @@ -131,26 +131,26 @@ void MultiplayerLocalPlayer::sendPosition() bool rot = rydd != 0 || rxdd != 0; if (riding != nullptr) { - connection->send( shared_ptr( new MovePlayerPacket::PosRot(xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying) ) ); + connection->send(std::make_shared(xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying)); move = false; } else { if (move && rot) { - connection->send( shared_ptr( new MovePlayerPacket::PosRot(x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying) ) ); + connection->send(std::make_shared(x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying)); } else if (move) { - connection->send( shared_ptr( new MovePlayerPacket::Pos(x, bb->y0, y, z, onGround, abilities.flying) ) ); + connection->send(std::make_shared(x, bb->y0, y, z, onGround, abilities.flying)); } else if (rot) { - connection->send( shared_ptr( new MovePlayerPacket::Rot(yRot, xRot, onGround, abilities.flying) ) ); + connection->send(std::make_shared(yRot, xRot, onGround, abilities.flying)); } else { - connection->send( shared_ptr( new MovePlayerPacket(onGround, abilities.flying) ) ); + connection->send(std::make_shared(onGround, abilities.flying)); } } @@ -175,7 +175,7 @@ void MultiplayerLocalPlayer::sendPosition() shared_ptr MultiplayerLocalPlayer::drop() { - connection->send( shared_ptr( new PlayerActionPacket(PlayerActionPacket::DROP_ITEM, 0, 0, 0, 0) ) ); + connection->send(std::make_shared(PlayerActionPacket::DROP_ITEM, 0, 0, 0, 0)); return nullptr; } @@ -185,19 +185,19 @@ void MultiplayerLocalPlayer::reallyDrop(shared_ptr itemEntity) void MultiplayerLocalPlayer::chat(const wstring& message) { - connection->send( shared_ptr( new ChatPacket(message) ) ); + connection->send(std::make_shared(message)); } void MultiplayerLocalPlayer::swing() { LocalPlayer::swing(); - connection->send( shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::SWING) ) ); + connection->send(std::make_shared(shared_from_this(), AnimatePacket::SWING)); } void MultiplayerLocalPlayer::respawn() { - connection->send( shared_ptr( new ClientCommandPacket(ClientCommandPacket::PERFORM_RESPAWN))); + connection->send(std::make_shared(ClientCommandPacket::PERFORM_RESPAWN)); } @@ -260,7 +260,7 @@ void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance *effect) void MultiplayerLocalPlayer::closeContainer() { - connection->send( shared_ptr( new ContainerClosePacket(containerMenu->containerId) ) ); + connection->send(std::make_shared(containerMenu->containerId)); clientSideCloseContainer(); } @@ -314,7 +314,7 @@ void MultiplayerLocalPlayer::awardStatFromServer(Stat *stat, byteArray param) void MultiplayerLocalPlayer::onUpdateAbilities() { - connection->send(shared_ptr(new PlayerAbilitiesPacket(&abilities))); + connection->send(std::make_shared(&abilities)); } bool MultiplayerLocalPlayer::isLocalPlayer() @@ -324,12 +324,12 @@ bool MultiplayerLocalPlayer::isLocalPlayer() void MultiplayerLocalPlayer::sendRidingJump() { - connection->send(shared_ptr(new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::RIDING_JUMP, static_cast(getJumpRidingScale() * 100.0f)))); + connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::RIDING_JUMP, static_cast(getJumpRidingScale() * 100.0f))); } void MultiplayerLocalPlayer::sendOpenInventory() { - connection->send(shared_ptr(new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY))); + connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY)); } void MultiplayerLocalPlayer::ride(shared_ptr e) @@ -386,7 +386,7 @@ void MultiplayerLocalPlayer::ride(shared_ptr e) void MultiplayerLocalPlayer::StopSleeping() { - connection->send( shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SLEEPING) ) ); + connection->send(std::make_shared(shared_from_this(), PlayerCommandPacket::STOP_SLEEPING)); } // 4J Added @@ -397,7 +397,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(DWORD skinId) #ifndef _CONTENT_PACKAGE wprintf(L"Skin for local player %ls has changed to %ls (%d)\n", name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin() ); #endif - if(getCustomSkin() != oldSkinIndex) connection->send( shared_ptr( new TextureAndGeometryChangePacket( shared_from_this(), app.GetPlayerSkinName(GetXboxPad()) ) ) ); + if(getCustomSkin() != oldSkinIndex) connection->send(std::make_shared(shared_from_this(), app.GetPlayerSkinName(GetXboxPad()))); } void MultiplayerLocalPlayer::setAndBroadcastCustomCape(DWORD capeId) @@ -407,7 +407,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(DWORD capeId) #ifndef _CONTENT_PACKAGE wprintf(L"Cape for local player %ls has changed to %ls\n", name.c_str(), customTextureUrl2.c_str()); #endif - if(getCustomCape() != oldCapeIndex) connection->send( shared_ptr( new TextureChangePacket( shared_from_this(), TextureChangePacket::e_TextureChange_Cape, app.GetPlayerCapeName(GetXboxPad()) ) ) ); + if(getCustomCape() != oldCapeIndex) connection->send(std::make_shared(shared_from_this(), TextureChangePacket::e_TextureChange_Cape, app.GetPlayerCapeName(GetXboxPad()))); } // 4J added for testing. This moves the player in a repeated sequence of 2 modes: diff --git a/Minecraft.Client/ParticleEngine.cpp b/Minecraft.Client/ParticleEngine.cpp index 82dd4ce1c..efc09c9ad 100644 --- a/Minecraft.Client/ParticleEngine.cpp +++ b/Minecraft.Client/ParticleEngine.cpp @@ -218,7 +218,7 @@ void ParticleEngine::destroy(int x, int y, int z, int tid, int data) double yp = y + (yy + 0.5) / SD; double zp = z + (zz + 0.5) / SD; int face = random->nextInt(6); - add(( shared_ptr(new TerrainParticle(level, xp, yp, zp, xp - x - 0.5f, yp - y - 0.5f, zp - z - 0.5f, tile, face, data, textures) ) )->init(x, y, z, data)); + add((std::make_shared(level, xp, yp, zp, xp - x - 0.5f, yp - y - 0.5f, zp - z - 0.5f, tile, face, data, textures))->init(x, y, z, data)); } } @@ -237,7 +237,7 @@ void ParticleEngine::crack(int x, int y, int z, int face) if (face == 3) zp = z + tile->getShapeZ1() + r; if (face == 4) xp = x + tile->getShapeX0() - r; if (face == 5) xp = x + tile->getShapeX1() + r; - add(( shared_ptr(new TerrainParticle(level, xp, yp, zp, 0, 0, 0, tile, face, level->getData(x, y, z), textures) ) )->init(x, y, z, level->getData(x, y, z))->setPower(0.2f)->scale(0.6f)); + add((std::make_shared(level, xp, yp, zp, 0, 0, 0, tile, face, level->getData(x, y, z), textures))->init(x, y, z, level->getData(x, y, z))->setPower(0.2f)->scale(0.6f)); } diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp index 2adc1bb1e..5c11d41df 100644 --- a/Minecraft.Client/PendingConnection.cpp +++ b/Minecraft.Client/PendingConnection.cpp @@ -65,7 +65,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) // try { // 4J - removed try/catch // logger.info("Disconnecting " + getName() + ": " + reason); app.DebugPrintf("Pending connection disconnect: %d\n", reason ); - connection->send( shared_ptr( new DisconnectPacket(reason) ) ); + connection->send(std::make_shared(reason)); connection->sendAndQuit(); done = true; // } catch (Exception e) { @@ -136,7 +136,7 @@ void PendingConnection::sendPreLoginResponse() else #endif { - connection->send( shared_ptr( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) ); + connection->send(std::make_shared(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName, app.GetGameHostOption(eGameHostOption_All), hostIndex, server->m_texturePackId)); } } @@ -282,7 +282,7 @@ void PendingConnection::handleGetInfo(shared_ptr packet) //try { //String message = server->motd + "�" + server->players->getPlayerCount() + "�" + server->players->getMaxPlayers(); //connection->send(new DisconnectPacket(message)); - connection->send(shared_ptr(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) ); + connection->send(std::make_shared(DisconnectPacket::eDisconnect_ServerFull)); connection->sendAndQuit(); server->connection->removeSpamProtection(connection->getSocket()); done = true; diff --git a/Minecraft.Client/PlayerChunkMap.cpp b/Minecraft.Client/PlayerChunkMap.cpp index 2078093ed..e407bad29 100644 --- a/Minecraft.Client/PlayerChunkMap.cpp +++ b/Minecraft.Client/PlayerChunkMap.cpp @@ -64,7 +64,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr player, bool send player->seenChunks.insert(pos); // 4J Added the sendPacket check. See PlayerChunkMap::add for the usage - if( sendPacket ) player->connection->send( shared_ptr( new ChunkVisibilityPacket(pos.x, pos.z, true) ) ); + if( sendPacket ) player->connection->send(std::make_shared(pos.x, pos.z, true)); if (players.empty()) { @@ -143,7 +143,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr player) if(noOtherPlayersFound) { //wprintf(L"Sending ChunkVisiblity packet false for chunk (%d,%d) to player %ls\n", x, z, player->name.c_str() ); - player->connection->send( shared_ptr( new ChunkVisibilityPacket(pos.x, pos.z, false) ) ); + player->connection->send(std::make_shared(pos.x, pos.z, false)); } } else @@ -322,7 +322,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) int x = pos.x * 16 + xChangeMin; int y = yChangeMin; int z = pos.z * 16 + zChangeMin; - broadcast( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + broadcast(std::make_shared(x, y, z, level)); if (level->isEntityTile(x, y, z)) { broadcast(level->getTileEntity(x, y, z)); @@ -352,7 +352,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) // Block region update packets can only encode ys in a range of 1 - 256 if( ys > 256 ) ys = 256; - broadcast( shared_ptr( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) ); + broadcast(std::make_shared(xp, yp, zp, xs, ys, zs, level)); vector > *tes = level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys, zp + zs); for (unsigned int i = 0; i < tes->size(); i++) { @@ -365,7 +365,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) else { // 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet - broadcast( shared_ptr( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, static_cast(changes), level) ) ); + broadcast(std::make_shared(pos.x, pos.z, changedTiles, static_cast(changes), level)); for (int i = 0; i < changes; i++) { int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15); @@ -712,7 +712,7 @@ void PlayerChunkMap::add(shared_ptr player) } // CraftBukkit end - player->connection->send( shared_ptr( new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ) ) ); + player->connection->send(std::make_shared(minX, maxX, minZ, maxZ)); #ifdef _LARGE_WORLDS getLevel()->cache->dontDrop(xc,zc); diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index 48fd4e08d..752ed4a26 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -94,7 +94,7 @@ void PlayerConnection::tick() lastKeepAliveTick = tickCount; lastKeepAliveTime = System::nanoTime() / 1000000; lastKeepAliveId = random.nextInt(); - send( shared_ptr( new KeepAlivePacket(lastKeepAliveId) ) ); + send(std::make_shared(lastKeepAliveId)); } if (chatSpamTickCount > 0) @@ -121,17 +121,17 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason) // 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system server->getPlayers()->removePlayerFromReceiving( player ); - send( shared_ptr( new DisconnectPacket(reason) )); + send(std::make_shared(reason)); connection->sendAndQuit(); // 4J-PB - removed, since it needs to be localised in the language the client is in //server->players->broadcastAll( shared_ptr( new ChatPacket(L"�e" + player->name + L" left the game.") ) ); if(getWasKicked()) { - server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) ); + server->getPlayers()->broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerKickedFromGame)); } else { - server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) ); + server->getPlayers()->broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerLeftGame)); } server->getPlayers()->remove(player); @@ -376,7 +376,7 @@ void PlayerConnection::teleport(double x, double y, double z, float yRot, float player->absMoveTo(x, y, z, yRot, xRot); // 4J - note that 1.62 is added to the height here as the client connection that receives this will presume it represents y + heightOffset at that end // This is different to the way that height is sent back to the server, where it represents the bottom of the player bounding volume - if(sendPacket) player->connection->send( shared_ptr( new MovePlayerPacket::PosRot(x, y + 1.62f, y, z, yRot, xRot, false, false) ) ); + if(sendPacket) player->connection->send(std::make_shared(x, y + 1.62f, y, z, yRot, xRot, false, false)); } void PlayerConnection::handlePlayerAction(shared_ptr packet) @@ -429,19 +429,19 @@ void PlayerConnection::handlePlayerAction(shared_ptr packet) if (packet->action == PlayerActionPacket::START_DESTROY_BLOCK) { if (true) player->gameMode->startDestroyBlock(x, y, z, packet->face); // 4J - condition was !server->isUnderSpawnProtection(level, x, y, z, player) (from Java 1.6.4) but putting back to old behaviour - else player->connection->send( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + else player->connection->send(std::make_shared(x, y, z, level)); } else if (packet->action == PlayerActionPacket::STOP_DESTROY_BLOCK) { player->gameMode->stopDestroyBlock(x, y, z); server->getPlayers()->prioritiseTileChanges(x, y, z, level->dimension->id); // 4J added - make sure that the update packets for this get prioritised over other general world updates - if (level->getTile(x, y, z) != 0) player->connection->send( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + if (level->getTile(x, y, z) != 0) player->connection->send(std::make_shared(x, y, z, level)); } else if (packet->action == PlayerActionPacket::ABORT_DESTROY_BLOCK) { player->gameMode->abortDestroyBlock(x, y, z); - if (level->getTile(x, y, z) != 0) player->connection->send(shared_ptr( new TileUpdatePacket(x, y, z, level))); + if (level->getTile(x, y, z) != 0) player->connection->send(std::make_shared(x, y, z, level)); } } @@ -484,7 +484,7 @@ void PlayerConnection::handleUseItem(shared_ptr packet) if (informClient) { - player->connection->send( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + player->connection->send(std::make_shared(x, y, z, level)); if (face == 0) y--; if (face == 1) y++; @@ -500,7 +500,7 @@ void PlayerConnection::handleUseItem(shared_ptr packet) // isn't what it is expecting. if( level->getTile(x,y,z) != Tile::pistonMovingPiece_Id ) { - player->connection->send( shared_ptr( new TileUpdatePacket(x, y, z, level) ) ); + player->connection->send(std::make_shared(x, y, z, level)); } } @@ -528,7 +528,7 @@ void PlayerConnection::handleUseItem(shared_ptr packet) if (forceClientUpdate || !ItemInstance::matches(player->inventory->getSelected(), packet->getItem())) { - send( shared_ptr( new ContainerSetSlotPacket(player->containerMenu->containerId, s->index, player->inventory->getSelected()) ) ); + send(std::make_shared(player->containerMenu->containerId, s->index, player->inventory->getSelected())); } } } @@ -542,11 +542,11 @@ void PlayerConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, //server->players->broadcastAll( shared_ptr( new ChatPacket(L"�e" + player->name + L" left the game.") ) ); if(getWasKicked()) { - server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) ); + server->getPlayers()->broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerKickedFromGame)); } else { - server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) ); + server->getPlayers()->broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerLeftGame)); } server->getPlayers()->remove(player); done = true; @@ -803,7 +803,7 @@ void PlayerConnection::handleTexture(shared_ptr packet) if(dwBytes!=0) { - send( shared_ptr( new TexturePacket(packet->textureName,pbData,dwBytes) ) ); + send(std::make_shared(packet->textureName, pbData, dwBytes)); } else { @@ -843,11 +843,11 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptrgetAdditionalBoxesCount()!=0) { - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pDLCSkinFile) ) ); + send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pDLCSkinFile)); } else { - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes) ) ); + send(std::make_shared(packet->textureName, pbData, dwTextureBytes)); } } else @@ -856,7 +856,7 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptr *pvSkinBoxes = app.GetAdditionalSkinBoxes(packet->dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); - send( shared_ptr( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pvSkinBoxes,uiAnimOverrideBitmask) ) ); + send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask)); } } else @@ -901,7 +901,7 @@ void PlayerConnection::handleTextureReceived(const wstring &textureName) if(dwBytes!=0) { - send( shared_ptr( new TexturePacket(textureName,pbData,dwBytes) ) ); + send(std::make_shared(textureName, pbData, dwBytes)); m_texturesRequested.erase(it); } } @@ -922,7 +922,7 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa { if(pDLCSkinFile && (pDLCSkinFile->getAdditionalBoxesCount()!=0)) { - send( shared_ptr( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes,pDLCSkinFile) ) ); + send(std::make_shared(textureName, pbData, dwTextureBytes, pDLCSkinFile)); } else { @@ -931,7 +931,7 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa vector *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID); - send( shared_ptr( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask) ) ); + send(std::make_shared(textureName, pbData, dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask)); } m_texturesRequested.erase(it); } @@ -958,20 +958,25 @@ void PlayerConnection::handleTextureChange(shared_ptr packe } if(!packet->path.empty() && packet->path.substr(0,3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(packet->path)) { - if( server->connection->addPendingTextureRequest(packet->path)) - { + if (server->connection->addPendingTextureRequest(packet->path)) + { #ifndef _CONTENT_PACKAGE - wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str()); + wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n", packet->path.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TexturePacket(packet->path,nullptr,0) ) ); - } - } + send(std::make_shared( + packet->path, + nullptr, + static_cast(0) + )); + + } + } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data app.AddMemoryTextureFile(packet->path,nullptr,0); } - server->getPlayers()->broadcastAll( shared_ptr( new TextureChangePacket(player,packet->action,packet->path) ), player->dimension ); + server->getPlayers()->broadcastAll(std::make_shared(player, packet->action, packet->path), player->dimension ); } void PlayerConnection::handleTextureAndGeometryChange(shared_ptr packet) @@ -990,7 +995,10 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptrpath.c_str(), player->name.c_str()); #endif - send(shared_ptr( new TextureAndGeometryPacket(packet->path,nullptr,0) ) ); + send(std::make_shared( + packet->path, + nullptr, + static_cast(0))); } } else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) @@ -1004,7 +1012,7 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptrdwSkinID,) //DebugBreak(); } - server->getPlayers()->broadcastAll( shared_ptr( new TextureAndGeometryChangePacket(player,packet->path) ), player->dimension ); + server->getPlayers()->broadcastAll(std::make_shared(player, packet->path), player->dimension ); } void PlayerConnection::handleServerSettingsChanged(shared_ptr packet) @@ -1026,7 +1034,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptrdata, eGameHostOption_DoDaylightCycle)); app.SetGameHostOption(eGameHostOption_NaturalRegeneration, app.GetGameHostOption(packet->data, eGameHostOption_NaturalRegeneration)); - server->getPlayers()->broadcastAll( shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS,app.GetGameHostOption(eGameHostOption_All) ) ) ); + server->getPlayers()->broadcastAll(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All))); // Update the QoS data g_NetworkManager.UpdateAndSetGameSessionData(); @@ -1141,7 +1149,7 @@ void PlayerConnection::handleContainerClick(shared_ptr pac if (ItemInstance::matches(packet->item, clicked)) { // Yep, you sure did click what you claimed to click! - player->connection->send( shared_ptr( new ContainerAckPacket(packet->containerId, packet->uid, true) ) ); + player->connection->send(std::make_shared(packet->containerId, packet->uid, true)); player->ignoreSlotUpdateHack = true; player->containerMenu->broadcastChanges(); player->broadcastCarriedItem(); @@ -1151,7 +1159,7 @@ void PlayerConnection::handleContainerClick(shared_ptr pac { // No, you clicked the wrong thing! expectedAcks[player->containerMenu->containerId] = packet->uid; - player->connection->send( shared_ptr( new ContainerAckPacket(packet->containerId, packet->uid, false) ) ); + player->connection->send(std::make_shared(packet->containerId, packet->uid, false)); player->containerMenu->setSynched(player, false); vector > items; @@ -1206,7 +1214,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr( new MapItemSavedData(id) ); + data = std::make_shared(id); } player->level->setSavedData(id, (shared_ptr ) data); @@ -1357,7 +1365,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr packet) #endif serverPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,Player::getPlayerGamePrivilege(packet->m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) ); serverPlayer->gameMode->setGameModeForPlayer(gameType); - serverPlayer->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, gameType->getId()) )); + serverPlayer->connection->send(std::make_shared(GameEventPacket::CHANGE_GAME_MODE, gameType->getId())); } else { @@ -1409,7 +1417,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr packet) } } - server->getPlayers()->broadcastAll( shared_ptr( new PlayerInfoPacket( serverPlayer ) ) ); + server->getPlayers()->broadcastAll(std::make_shared(serverPlayer)); } } } @@ -1656,7 +1664,7 @@ void PlayerConnection::handleCraftItem(shared_ptr packet) if (ingItemInst->getItem()->hasCraftingRemainingItem()) { // replace item with remaining result - player->inventory->add( shared_ptr( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) ); + player->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); } } diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp index 24457bee8..bd3bf3ddc 100644 --- a/Minecraft.Client/PlayerList.cpp +++ b/Minecraft.Client/PlayerList.cpp @@ -151,7 +151,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr player->setCustomCape( packet->m_playerCapeId ); // 4J-JEV: Moved this here so we can send player-model texture and geometry data. - shared_ptr playerConnection = shared_ptr(new PlayerConnection(server, connection, player)); + shared_ptr playerConnection = std::make_shared(server, connection, player); //player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr if(newPlayer) @@ -167,7 +167,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr int centreZC = 0; #endif // 4J Added - Give every player a map the first time they join a server - player->inventory->setItem( 9, shared_ptr( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) ); + player->inventory->setItem( 9, std::make_shared(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(), 0, centreXC, centreZC, mapScale))); if(app.getGameRuleDefinitions() != nullptr) { app.getGameRuleDefinitions()->postProcessPlayer(player); @@ -175,13 +175,17 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr } if(!player->customTextureUrl.empty() && player->customTextureUrl.substr(0,3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(player->customTextureUrl)) - { - if( server->getConnection()->addPendingTextureRequest(player->customTextureUrl)) - { + { + if (server->getConnection()->addPendingTextureRequest(player->customTextureUrl)) + { #ifndef _CONTENT_PACKAGE - wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl.c_str(), player->name.c_str()); + wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n", player->customTextureUrl.c_str(), player->name.c_str()); #endif - playerConnection->send(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,nullptr,0) ) ); + playerConnection->send(std::make_shared( + player->customTextureUrl, + nullptr, + static_cast(0))); + } } else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl)) @@ -197,7 +201,11 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr #ifndef _CONTENT_PACKAGE wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str()); #endif - playerConnection->send(shared_ptr( new TexturePacket(player->customTextureUrl2,nullptr,0) ) ); + playerConnection->send(std::make_shared( + player->customTextureUrl, + nullptr, + static_cast(0) + )); } } else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2)) @@ -233,13 +241,13 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr addPlayerToReceiving( player ); - playerConnection->send( shared_ptr( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(), - static_cast(level->dimension->id), static_cast(level->getMaxBuildHeight()), static_cast(getMaxPlayers()), - level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), static_cast(playerIndex), level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), - level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) ); - playerConnection->send( shared_ptr( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) ); - playerConnection->send( shared_ptr( new PlayerAbilitiesPacket(&player->abilities)) ); - playerConnection->send( shared_ptr( new SetCarriedItemPacket(player->inventory->selected))); + playerConnection->send(std::make_shared(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(), + static_cast(level->dimension->id), static_cast(level->getMaxBuildHeight()), static_cast(getMaxPlayers()), + level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), static_cast(playerIndex), level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), + level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale())); + playerConnection->send(std::make_shared(spawnPos->x, spawnPos->y, spawnPos->z)); + playerConnection->send(std::make_shared(&player->abilities)); + playerConnection->send(std::make_shared(player->inventory->selected)); delete spawnPos; updateEntireScoreboard((ServerScoreboard *) level->getScoreboard(), player); @@ -248,7 +256,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr // 4J-PB - removed, since it needs to be localised in the language the client is in //server->players->broadcastAll( shared_ptr( new ChatPacket(L"�e" + playerEntity->name + L" joined the game.") ) ); - broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) ); + broadcastAll(std::make_shared(player->name, ChatPacket::e_ChatPlayerJoinedGame)); MemSect(14); add(player); @@ -258,12 +266,12 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr playerConnection->teleport(player->x, player->y, player->z, player->yRot, player->xRot); server->getConnection()->addPlayerConnection(playerConnection); - playerConnection->send( shared_ptr( new SetTimePacket(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) ) ); + playerConnection->send(std::make_shared(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT))); auto activeEffects = player->getActiveEffects(); for(MobEffectInstance *effect : *player->getActiveEffects()) { - playerConnection->send(shared_ptr( new UpdateMobEffectPacket(player->entityId, effect) ) ); + playerConnection->send(std::make_shared(player->entityId, effect)); } player->initMenu(); @@ -430,7 +438,7 @@ void PlayerList::add(shared_ptr player) //broadcastAll(shared_ptr( new PlayerInfoPacket(player->name, true, 1000) ) ); if( player->connection->getNetworkPlayer() ) { - broadcastAll(shared_ptr( new PlayerInfoPacket( player ) ) ); + broadcastAll(std::make_shared(player)); } players.push_back(player); @@ -456,7 +464,7 @@ void PlayerList::add(shared_ptr player) //player->connection->send(shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); if( op->connection->getNetworkPlayer() ) { - player->connection->send(shared_ptr( new PlayerInfoPacket( op ) ) ); + player->connection->send(std::make_shared(op)); } } @@ -469,10 +477,10 @@ void PlayerList::add(shared_ptr player) if(thisPlayer->isSleeping()) { if(firstSleepingPlayer == nullptr) firstSleepingPlayer = thisPlayer; - thisPlayer->connection->send(shared_ptr( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep))); + thisPlayer->connection->send(std::make_shared(thisPlayer->name, ChatPacket::e_ChatBedMeSleep)); } } - player->connection->send(shared_ptr( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep))); + player->connection->send(std::make_shared(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep)); } } @@ -522,7 +530,7 @@ shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendin pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull); return shared_ptr(); } - shared_ptr player = shared_ptr(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) )); + shared_ptr player = std::make_shared(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0))); player->gameMode->player = player; // 4J added as had to remove this assignment from ServerPlayer ctor player->setXuid( xuid ); // 4J Added player->setOnlineXuid( onlineXuid ); // 4J Added @@ -634,7 +642,7 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay PlayerUID playerXuid = serverPlayer->getXuid(); PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid(); - shared_ptr player = shared_ptr(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->getName(), new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension)))); + shared_ptr player = std::make_shared(server, server->getLevel(serverPlayer->dimension), serverPlayer->getName(), new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension))); player->connection = serverPlayer->connection; player->restoreFrom(serverPlayer, keepAllPlayerData); if (keepAllPlayerData) @@ -692,7 +700,7 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay } else { - player->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) ); + player->connection->send(std::make_shared(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0)); } delete bedPosition; } @@ -822,9 +830,9 @@ void PlayerList::toggleDimension(shared_ptr player, int targetDime // 4J Stu Added so that we remove entities from the correct level, after the respawn packet we will be in the wrong level player->flushEntitiesToRemove(); - player->connection->send( shared_ptr( new RespawnPacket(static_cast(player->dimension), newLevel->getSeed(), newLevel->getMaxBuildHeight(), - player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(), - newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale()) ) ); + player->connection->send(std::make_shared(static_cast(player->dimension), newLevel->getSeed(), newLevel->getMaxBuildHeight(), + player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(), + newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale())); oldLevel->removeEntityImmediately(player); player->removed = false; @@ -951,7 +959,7 @@ void PlayerList::tick() //broadcastAll(shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); if( op->connection->getNetworkPlayer() ) { - broadcastAll(shared_ptr( new PlayerInfoPacket( op ) ) ); + broadcastAll(std::make_shared(op)); } } @@ -1013,7 +1021,7 @@ void PlayerList::tick() // 4J Stu - If we have kicked a player, make sure that they have no privileges if they later try to join the world when trust players is off player->enableAllPlayerPrivileges( false ); player->connection->setWasKicked(); - player->connection->send( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) )); + player->connection->send(std::make_shared(DisconnectPacket::eDisconnect_Kicked)); } //#endif } @@ -1240,7 +1248,7 @@ void PlayerList::sendMessage(const wstring& name, const wstring& message) shared_ptr player = getPlayer(name); if (player != nullptr) { - player->connection->send( shared_ptr( new ChatPacket(message) ) ); + player->connection->send(std::make_shared(message)); } } @@ -1351,22 +1359,22 @@ void PlayerList::reloadWhitelist() void PlayerList::sendLevelInfo(shared_ptr player, ServerLevel *level) { - player->connection->send( shared_ptr( new SetTimePacket(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) ) ); + player->connection->send(std::make_shared(level->getGameTime(), level->getDayTime(), level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT))); if (level->isRaining()) { - player->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) ); + player->connection->send(std::make_shared(GameEventPacket::START_RAINING, 0)); } else { // 4J Stu - Fix for #44836 - Customer Encountered: Out of Sync Weather [A-10] // If it was raining when the player left the level, and is now not raining we need to make sure that state is updated - player->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) ); + player->connection->send(std::make_shared(GameEventPacket::STOP_RAINING, 0)); } // send the stronghold position if there is one if((level->dimension->id==0) && level->getLevelData()->getHasStronghold()) { - player->connection->send( shared_ptr( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) ); + player->connection->send(std::make_shared(XZPacket::STRONGHOLD, level->getLevelData()->getXStronghold(), level->getLevelData()->getZStronghold())); } } @@ -1374,7 +1382,7 @@ void PlayerList::sendAllPlayerInfo(shared_ptr player) { player->refreshContainer(player->inventoryMenu); player->resetSentInfo(); - player->connection->send( shared_ptr( new SetCarriedItemPacket(player->inventory->selected)) ); + player->connection->send(std::make_shared(player->inventory->selected)); } int PlayerList::getPlayerCount() diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index f4803eaee..ccc532f3c 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -353,7 +353,7 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) if (mob->fishing != nullptr) { - item = shared_ptr( new ItemInstance(Item::stick) ); + item = std::make_shared(Item::stick); } UseAnim anim = UseAnim_none;//null; diff --git a/Minecraft.Client/ReceivingLevelScreen.cpp b/Minecraft.Client/ReceivingLevelScreen.cpp index fda24773e..2969b0539 100644 --- a/Minecraft.Client/ReceivingLevelScreen.cpp +++ b/Minecraft.Client/ReceivingLevelScreen.cpp @@ -23,7 +23,7 @@ void ReceivingLevelScreen::tick() tickCount++; if (tickCount % 20 == 0) { - connection->send( shared_ptr( new KeepAlivePacket() ) ); + connection->send(std::make_shared()); } if (connection != nullptr) { diff --git a/Minecraft.Client/ServerLevel.cpp b/Minecraft.Client/ServerLevel.cpp index 89fe12a4b..090ec3466 100644 --- a/Minecraft.Client/ServerLevel.cpp +++ b/Minecraft.Client/ServerLevel.cpp @@ -497,7 +497,7 @@ void ServerLevel::tickTiles() if (isRainingAt(x, y, z)) { - addGlobalEntity( shared_ptr( new LightningBolt(this, x, y, z) ) ); + addGlobalEntity(std::make_shared(this, x, y, z)); } } @@ -1085,7 +1085,7 @@ bool ServerLevel::addGlobalEntity(shared_ptr e) { if (Level::addGlobalEntity(e)) { - server->getPlayers()->broadcast(e->x, e->y, e->z, 512, dimension->id, shared_ptr( new AddGlobalEntityPacket(e) ) ); + server->getPlayers()->broadcast(e->x, e->y, e->z, 512, dimension->id, std::make_shared(e)); return true; } return false; @@ -1093,7 +1093,7 @@ bool ServerLevel::addGlobalEntity(shared_ptr e) void ServerLevel::broadcastEntityEvent(shared_ptr e, byte event) { - shared_ptr p = shared_ptr( new EntityEventPacket(e->entityId, event) ); + shared_ptr p = std::make_shared(e->entityId, event); server->getLevel(dimension->id)->getTracker()->broadcastAndSend(e, p); } @@ -1101,7 +1101,7 @@ shared_ptr ServerLevel::explode(shared_ptr source, double x, { // instead of calling super, we run the same explosion code here except // we don't generate any particles - shared_ptr explosion = shared_ptr( new Explosion(this, source, x, y, z, r) ); + shared_ptr explosion = std::make_shared(this, source, x, y, z, r); explosion->fire = fire; explosion->destroyBlocks = destroyBlocks; explosion->explode(); @@ -1144,7 +1144,7 @@ shared_ptr ServerLevel::explode(shared_ptr source, double x, Vec3 *knockbackVec = explosion->getHitPlayerKnockback(player); //app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n", knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z); // If the player is not the primary on the system, then we only want to send info for the knockback - player->connection->send( shared_ptr( new ExplodePacket(x, y, z, r, &explosion->toBlow, knockbackVec, knockbackOnly))); + player->connection->send(std::make_shared(x, y, z, r, &explosion->toBlow, knockbackVec, knockbackOnly)); sentTo.push_back( player ); } } @@ -1182,7 +1182,7 @@ void ServerLevel::runTileEvents() if (doTileEvent(&it)) { TileEventData te = it; - server->getPlayers()->broadcast(te.getX(), te.getY(), te.getZ(), 64, dimension->id, shared_ptr( new TileEventPacket(te.getX(), te.getY(), te.getZ(), te.getTile(), te.getParamA(), te.getParamB()))); + server->getPlayers()->broadcast(te.getX(), te.getY(), te.getZ(), 64, dimension->id, std::make_shared(te.getX(), te.getY(), te.getZ(), te.getTile(), te.getParamA(), te.getParamB())); } } tileEvents[runList].clear(); @@ -1212,11 +1212,11 @@ void ServerLevel::tickWeather() { if (wasRaining) { - server->getPlayers()->broadcastAll( shared_ptr( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) ); + server->getPlayers()->broadcastAll(std::make_shared(GameEventPacket::STOP_RAINING, 0)); } else { - server->getPlayers()->broadcastAll( shared_ptr( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) ); + server->getPlayers()->broadcastAll(std::make_shared(GameEventPacket::START_RAINING, 0)); } } diff --git a/Minecraft.Client/ServerPlayer.cpp b/Minecraft.Client/ServerPlayer.cpp index dc4628ab1..11035438b 100644 --- a/Minecraft.Client/ServerPlayer.cpp +++ b/Minecraft.Client/ServerPlayer.cpp @@ -280,7 +280,7 @@ void ServerPlayer::flushEntitiesToRemove() it = entitiesToRemove.erase(it); } - connection->send(shared_ptr(new RemoveEntitiesPacket(ids))); + connection->send(std::make_shared(ids)); } } @@ -429,7 +429,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) // app.DebugPrintf("Creating BRUP for %d %d\n",nearest.x, nearest.z); PIXBeginNamedEvent(0,"Creation BRUP for sending\n"); __int64 before = System::currentTimeMillis(); - shared_ptr packet = shared_ptr( new BlockRegionUpdatePacket(nearest.x * 16, 0, nearest.z * 16, 16, Level::maxBuildHeight, 16, level) ); + shared_ptr packet = std::make_shared(nearest.x * 16, 0, nearest.z * 16, 16, Level::maxBuildHeight, 16, level); __int64 after = System::currentTimeMillis(); // app.DebugPrintf(">>><<< %d ms\n",after-before); PIXEndNamedEvent(); @@ -523,7 +523,7 @@ void ServerPlayer::doTickB() if (getHealth() != lastSentHealth || lastSentFood != foodData.getFoodLevel() || ((foodData.getSaturationLevel() == 0) != lastFoodSaturationZero)) { // 4J Stu - Added m_lastDamageSource for telemetry - connection->send( shared_ptr( new SetHealthPacket(getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel(), m_lastDamageSource) ) ); + connection->send(std::make_shared(getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel(), m_lastDamageSource)); lastSentHealth = getHealth(); lastSentFood = foodData.getFoodLevel(); lastFoodSaturationZero = foodData.getSaturationLevel() == 0; @@ -550,7 +550,7 @@ void ServerPlayer::doTickB() if (totalExperience != lastSentExp) { lastSentExp = totalExperience; - connection->send( shared_ptr( new SetExperiencePacket(experienceProgress, totalExperience, experienceLevel) ) ); + connection->send(std::make_shared(experienceProgress, totalExperience, experienceLevel)); } } @@ -741,7 +741,7 @@ void ServerPlayer::changeDimension(int i) level->removeEntity(shared_from_this()); wonGame = true; m_enteredEndExitPortal = true; // We only flag this for the player in the portal - connection->send( shared_ptr( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex()) ) ); + connection->send(std::make_shared(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex())); app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex()); } if(thisPlayer) @@ -752,7 +752,7 @@ void ServerPlayer::changeDimension(int i) if(thisPlayer != checkPlayer && checkPlayer != nullptr && thisPlayer->IsSameSystem( checkPlayer ) && !servPlayer->wonGame ) { servPlayer->wonGame = true; - servPlayer->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex() ) ) ); + servPlayer->connection->send(std::make_shared(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex())); app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex()); } } @@ -812,7 +812,7 @@ Player::BedSleepingResult ServerPlayer::startSleepInBed(int x, int y, int z, boo BedSleepingResult result = Player::startSleepInBed(x, y, z, bTestUse); if (result == OK) { - shared_ptr p = shared_ptr( new EntityActionAtPositionPacket(shared_from_this(), EntityActionAtPositionPacket::START_SLEEP, x, y, z) ); + shared_ptr p = std::make_shared(shared_from_this(), EntityActionAtPositionPacket::START_SLEEP, x, y, z); getLevel()->getTracker()->broadcast(shared_from_this(), p); connection->teleport(this->x, this->y, this->z, yRot, xRot); connection->send(p); @@ -824,7 +824,7 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, boo { if (isSleeping()) { - getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::WAKE_UP) ) ); + getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared(shared_from_this(), AnimatePacket::WAKE_UP)); } Player::stopSleepInBed(forcefulWakeUp, updateLevelList, saveRespawnPoint); if (connection != nullptr) connection->teleport(x, y, z, yRot, xRot); @@ -833,7 +833,7 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, boo void ServerPlayer::ride(shared_ptr e) { Player::ride(e); - connection->send( shared_ptr( new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, shared_from_this(), riding) ) ); + connection->send(std::make_shared(SetEntityLinkPacket::RIDING, shared_from_this(), riding)); // 4J Removed this - The act of riding will be handled on the client and will change the position // of the player. If we also teleport it then we can end up with a repeating movements, e.g. bouncing @@ -856,7 +856,7 @@ void ServerPlayer::openTextEdit(shared_ptr sign) if (signTE != nullptr) { signTE->setAllowedPlayerEditor(dynamic_pointer_cast(shared_from_this())); - connection->send( shared_ptr( new TileEditorOpenPacket(TileEditorOpenPacket::SIGN, sign->x, sign->y, sign->z)) ); + connection->send(std::make_shared(TileEditorOpenPacket::SIGN, sign->x, sign->y, sign->z)); } } @@ -870,7 +870,7 @@ bool ServerPlayer::startCrafting(int x, int y, int z) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::WORKBENCH, L"", 9, false) ) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::WORKBENCH, L"", 9, false)); containerMenu = new CraftingMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -888,7 +888,7 @@ bool ServerPlayer::openFireworks(int x, int y, int z) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false) ) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false)); containerMenu = new FireworksMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -898,7 +898,7 @@ bool ServerPlayer::openFireworks(int x, int y, int z) closeContainer(); nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false) ) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false)); containerMenu = new FireworksMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -916,7 +916,7 @@ bool ServerPlayer::startEnchanting(int x, int y, int z, const wstring &name) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send(shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::ENCHANTMENT, name.empty()? L"" : name, 9, !name.empty() ) )); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::ENCHANTMENT, name.empty() ? L"" : name, 9, !name.empty())); containerMenu = new EnchantmentMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -934,7 +934,7 @@ bool ServerPlayer::startRepairing(int x, int y, int z) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send(shared_ptr ( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::REPAIR_TABLE, L"", 9, false)) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::REPAIR_TABLE, L"", 9, false)); containerMenu = new AnvilMenu(inventory, level, x, y, z, dynamic_pointer_cast(shared_from_this())); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -957,7 +957,7 @@ bool ServerPlayer::openContainer(shared_ptr container) int containerType = container->getContainerType(); assert(containerType >= 0); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, containerType, container->getCustomName(), container->getContainerSize(), container->hasCustomName()) ) ); + connection->send(std::make_shared(containerCounter, containerType, container->getCustomName(), container->getContainerSize(), container->hasCustomName())); containerMenu = new ContainerMenu(inventory, container); containerMenu->containerId = containerCounter; @@ -976,7 +976,7 @@ bool ServerPlayer::openHopper(shared_ptr container) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName())) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName())); containerMenu = new HopperMenu(inventory, container); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -994,7 +994,7 @@ bool ServerPlayer::openHopper(shared_ptr container) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName())) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName())); containerMenu = new HopperMenu(inventory, container); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1012,7 +1012,7 @@ bool ServerPlayer::openFurnace(shared_ptr furnace) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::FURNACE, furnace->getCustomName(), furnace->getContainerSize(), furnace->hasCustomName()) ) ); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::FURNACE, furnace->getCustomName(), furnace->getContainerSize(), furnace->hasCustomName())); containerMenu = new FurnaceMenu(inventory, furnace); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1030,7 +1030,7 @@ bool ServerPlayer::openTrap(shared_ptr trap) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( shared_ptr( new ContainerOpenPacket(containerCounter, trap->GetType() == eTYPE_DROPPERTILEENTITY ? ContainerOpenPacket::DROPPER : ContainerOpenPacket::TRAP, trap->getCustomName(), trap->getContainerSize(), trap->hasCustomName() ) ) ); + connection->send(std::make_shared(containerCounter, trap->GetType() == eTYPE_DROPPERTILEENTITY ? ContainerOpenPacket::DROPPER : ContainerOpenPacket::TRAP, trap->getCustomName(), trap->getContainerSize(), trap->hasCustomName())); containerMenu = new TrapMenu(inventory, trap); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1048,7 +1048,7 @@ bool ServerPlayer::openBrewingStand(shared_ptr brewingSt if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send(shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::BREWING_STAND, brewingStand->getCustomName(), brewingStand->getContainerSize(), brewingStand->hasCustomName() ))); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::BREWING_STAND, brewingStand->getCustomName(), brewingStand->getContainerSize(), brewingStand->hasCustomName())); containerMenu = new BrewingStandMenu(inventory, brewingStand); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1066,7 +1066,7 @@ bool ServerPlayer::openBeacon(shared_ptr beacon) if(containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send(shared_ptr( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::BEACON, beacon->getCustomName(), beacon->getContainerSize(), beacon->hasCustomName() ))); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::BEACON, beacon->getCustomName(), beacon->getContainerSize(), beacon->hasCustomName())); containerMenu = new BeaconMenu(inventory, beacon); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1089,7 +1089,7 @@ bool ServerPlayer::openTrading(shared_ptr traderTarget, const wstring containerMenu->addSlotListener(this); shared_ptr container = static_cast(containerMenu)->getTradeContainer(); - connection->send(shared_ptr(new ContainerOpenPacket(containerCounter, ContainerOpenPacket::TRADER_NPC, name.empty()?L"":name, container->getContainerSize(), !name.empty()))); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::TRADER_NPC, name.empty() ? L"" : name, container->getContainerSize(), !name.empty())); MerchantRecipeList *offers = traderTarget->getOffers(dynamic_pointer_cast(shared_from_this())); if (offers != nullptr) @@ -1101,7 +1101,7 @@ bool ServerPlayer::openTrading(shared_ptr traderTarget, const wstring output.writeInt(containerCounter); offers->writeToStream(&output); - connection->send(shared_ptr( new CustomPayloadPacket(CustomPayloadPacket::TRADER_LIST_PACKET, rawOutput.toByteArray()))); + connection->send(std::make_shared(CustomPayloadPacket::TRADER_LIST_PACKET, rawOutput.toByteArray())); } } else @@ -1119,7 +1119,7 @@ bool ServerPlayer::openHorseInventory(shared_ptr horse, shared_ptr< closeContainer(); } nextContainerCounter(); - connection->send(shared_ptr(new ContainerOpenPacket(containerCounter, ContainerOpenPacket::HORSE, horse->getCustomName(), container->getContainerSize(), container->hasCustomName(), horse->entityId ))); + connection->send(std::make_shared(containerCounter, ContainerOpenPacket::HORSE, horse->getCustomName(), container->getContainerSize(), container->hasCustomName(), horse->entityId)); containerMenu = new HorseInventoryMenu(inventory, container, horse); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1144,7 +1144,7 @@ void ServerPlayer::slotChanged(AbstractContainerMenu *container, int slotIndex, return; } - connection->send( shared_ptr( new ContainerSetSlotPacket(container->containerId, slotIndex, item) ) ); + connection->send(std::make_shared(container->containerId, slotIndex, item)); } @@ -1157,8 +1157,8 @@ void ServerPlayer::refreshContainer(AbstractContainerMenu *menu) void ServerPlayer::refreshContainer(AbstractContainerMenu *container, vector > *items) { - connection->send( shared_ptr( new ContainerSetContentPacket(container->containerId, items) ) ); - connection->send( shared_ptr( new ContainerSetSlotPacket(-1, -1, inventory->getCarried()) ) ); + connection->send(std::make_shared(container->containerId, items)); + connection->send(std::make_shared(-1, -1, inventory->getCarried())); } void ServerPlayer::setContainerData(AbstractContainerMenu *container, int id, int value) @@ -1173,12 +1173,12 @@ void ServerPlayer::setContainerData(AbstractContainerMenu *container, int id, in // client again. return; } - connection->send( shared_ptr( new ContainerSetDataPacket(container->containerId, id, value) ) ); + connection->send(std::make_shared(container->containerId, id, value)); } void ServerPlayer::closeContainer() { - connection->send( shared_ptr( new ContainerClosePacket(containerMenu->containerId) ) ); + connection->send(std::make_shared(containerMenu->containerId)); doCloseContainer(); } @@ -1192,7 +1192,7 @@ void ServerPlayer::broadcastCarriedItem() // client again. return; } - connection->send( shared_ptr( new ContainerSetSlotPacket(-1, -1, inventory->getCarried()) ) ); + connection->send(std::make_shared(-1, -1, inventory->getCarried())); } void ServerPlayer::doCloseContainer() @@ -1226,7 +1226,7 @@ void ServerPlayer::awardStat(Stat *stat, byteArray param) int count = *((int*)param.data); delete [] param.data; - connection->send( shared_ptr( new AwardStatPacket(stat->id, count) ) ); + connection->send(std::make_shared(stat->id, count)); #else connection->send( shared_ptr( new AwardStatPacket(stat->id, param) ) ); // byteArray deleted in AwardStatPacket destructor. @@ -1257,19 +1257,19 @@ void ServerPlayer::displayClientMessage(int messageId) { case IDS_TILE_BED_OCCUPIED: messageType = ChatPacket::e_ChatBedOccupied; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NO_SLEEP: messageType = ChatPacket::e_ChatBedNoSleep; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NOT_VALID: messageType = ChatPacket::e_ChatBedNotValid; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NOTSAFE: messageType = ChatPacket::e_ChatBedNotSafe; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_PLAYERSLEEP: messageType = ChatPacket::e_ChatBedPlayerSleep; @@ -1279,11 +1279,11 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()!=player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatBedPlayerSleep))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatBedPlayerSleep)); } else { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatBedMeSleep))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatBedMeSleep)); } } return; @@ -1294,7 +1294,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()!=player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerEnteredEnd))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerEnteredEnd)); } } break; @@ -1304,13 +1304,13 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()!=player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerLeftEnd))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerLeftEnd)); } } break; case IDS_TILE_BED_MESLEEP: messageType = ChatPacket::e_ChatBedMeSleep; - connection->send( shared_ptr( new ChatPacket(L"", messageType) ) ); + connection->send(std::make_shared(L"", messageType)); break; case IDS_MAX_PIGS_SHEEP_COWS_CATS_SPAWNED: @@ -1319,7 +1319,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxPigsSheepCows))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxPigsSheepCows)); } } break; @@ -1329,7 +1329,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxChickens))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxChickens)); } } break; @@ -1339,7 +1339,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxSquid))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxSquid)); } } break; @@ -1349,7 +1349,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBats))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBats)); } } break; @@ -1359,7 +1359,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxWolves))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxWolves)); } } break; @@ -1369,7 +1369,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxMooshrooms))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxMooshrooms)); } } break; @@ -1379,7 +1379,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxEnemies))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxEnemies)); } } break; @@ -1390,7 +1390,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxVillagers))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxVillagers)); } } break; @@ -1400,7 +1400,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredPigsSheepCows))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBredPigsSheepCows)); } } break; @@ -1410,7 +1410,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredChickens))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBredChickens)); } } break; @@ -1420,7 +1420,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredMooshrooms))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBredMooshrooms)); } } break; @@ -1431,7 +1431,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredWolves))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBredWolves)); } } break; @@ -1442,7 +1442,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerCantShearMooshroom))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerCantShearMooshroom)); } } break; @@ -1454,7 +1454,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxHangingEntities))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxHangingEntities)); } } break; @@ -1464,7 +1464,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerCantSpawnInPeaceful))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerCantSpawnInPeaceful)); } } break; @@ -1475,7 +1475,7 @@ void ServerPlayer::displayClientMessage(int messageId) shared_ptr player = server->getPlayers()->players[i]; if(shared_from_this()==player) { - player->connection->send(shared_ptr( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBoats))); + player->connection->send(std::make_shared(name, ChatPacket::e_ChatPlayerMaxBoats)); } } break; @@ -1493,7 +1493,7 @@ void ServerPlayer::displayClientMessage(int messageId) void ServerPlayer::completeUsingItem() { - connection->send(shared_ptr( new EntityEventPacket(entityId, EntityEvent::USE_ITEM_COMPLETE) ) ); + connection->send(std::make_shared(entityId, EntityEvent::USE_ITEM_COMPLETE)); Player::completeUsingItem(); } @@ -1503,7 +1503,7 @@ void ServerPlayer::startUsingItem(shared_ptr instance, int duratio if (instance != nullptr && instance->getItem() != nullptr && instance->getItem()->getUseAnimation(instance) == UseAnim_eat) { - getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::EAT) ) ); + getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared(shared_from_this(), AnimatePacket::EAT)); } } @@ -1519,21 +1519,21 @@ void ServerPlayer::restoreFrom(shared_ptr oldPlayer, bool restoreAll) void ServerPlayer::onEffectAdded(MobEffectInstance *effect) { Player::onEffectAdded(effect); - connection->send(shared_ptr( new UpdateMobEffectPacket(entityId, effect) ) ); + connection->send(std::make_shared(entityId, effect)); } void ServerPlayer::onEffectUpdated(MobEffectInstance *effect, bool doRefreshAttributes) { Player::onEffectUpdated(effect, doRefreshAttributes); - connection->send(shared_ptr( new UpdateMobEffectPacket(entityId, effect) ) ); + connection->send(std::make_shared(entityId, effect)); } void ServerPlayer::onEffectRemoved(MobEffectInstance *effect) { Player::onEffectRemoved(effect); - connection->send(shared_ptr( new RemoveMobEffectPacket(entityId, effect) ) ); + connection->send(std::make_shared(entityId, effect)); } void ServerPlayer::teleportTo(double x, double y, double z) @@ -1543,18 +1543,18 @@ void ServerPlayer::teleportTo(double x, double y, double z) void ServerPlayer::crit(shared_ptr entity) { - getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(entity, AnimatePacket::CRITICAL_HIT) )); + getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared(entity, AnimatePacket::CRITICAL_HIT)); } void ServerPlayer::magicCrit(shared_ptr entity) { - getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr( new AnimatePacket(entity, AnimatePacket::MAGIC_CRITICAL_HIT) )); + getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared(entity, AnimatePacket::MAGIC_CRITICAL_HIT)); } void ServerPlayer::onUpdateAbilities() { if (connection == nullptr) return; - connection->send(shared_ptr(new PlayerAbilitiesPacket(&abilities))); + connection->send(std::make_shared(&abilities)); } ServerLevel *ServerPlayer::getLevel() @@ -1565,12 +1565,12 @@ ServerLevel *ServerPlayer::getLevel() void ServerPlayer::setGameMode(GameType *mode) { gameMode->setGameModeForPlayer(mode); - connection->send(shared_ptr(new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, mode->getId()))); + connection->send(std::make_shared(GameEventPacket::CHANGE_GAME_MODE, mode->getId())); } void ServerPlayer::sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type /*= e_ChatCustom*/, int customData /*= -1*/, const wstring& additionalMessage /*= L""*/) { - connection->send(shared_ptr(new ChatPacket(message,type,customData,additionalMessage))); + connection->send(std::make_shared(message, type, customData, additionalMessage)); } bool ServerPlayer::hasPermission(EGameCommand command) diff --git a/Minecraft.Client/ServerPlayerGameMode.cpp b/Minecraft.Client/ServerPlayerGameMode.cpp index daafc2ca6..d2dcaaf68 100644 --- a/Minecraft.Client/ServerPlayerGameMode.cpp +++ b/Minecraft.Client/ServerPlayerGameMode.cpp @@ -286,7 +286,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) if (isCreative()) { - shared_ptr tup = shared_ptr( new TileUpdatePacket(x, y, z, level) ); + shared_ptr tup = std::make_shared(x, y, z, level); // 4J - a bit of a hack here, but if we want to tell the client that it needs to inform the renderer of a block being destroyed, then send a block 255 instead of a 0. This is handled in ClientConnection::handleTileUpdate if( tup->block == 0 ) { diff --git a/Minecraft.Client/SnowManRenderer.cpp b/Minecraft.Client/SnowManRenderer.cpp index 853127bb7..1ab1d4023 100644 --- a/Minecraft.Client/SnowManRenderer.cpp +++ b/Minecraft.Client/SnowManRenderer.cpp @@ -22,7 +22,7 @@ void SnowManRenderer::additionalRendering(shared_ptr _mob, float a shared_ptr mob = dynamic_pointer_cast(_mob); MobRenderer::additionalRendering(mob, a); - shared_ptr headGear = shared_ptr( new ItemInstance(Tile::pumpkin, 1) ); + shared_ptr headGear = std::make_shared(Tile::pumpkin, 1); if (headGear != nullptr && headGear->getItem()->id < 256) { glPushMatrix(); diff --git a/Minecraft.Client/TeleportCommand.cpp b/Minecraft.Client/TeleportCommand.cpp index 0ee269cd6..9dd29ff08 100644 --- a/Minecraft.Client/TeleportCommand.cpp +++ b/Minecraft.Client/TeleportCommand.cpp @@ -86,5 +86,5 @@ shared_ptr TeleportCommand::preparePacket(PlayerUID subject, dos.writePlayerUID(subject); dos.writePlayerUID(destination); - return shared_ptr( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() )); + return std::make_shared(eGameCommand_Teleport, baos.toByteArray()); } \ No newline at end of file diff --git a/Minecraft.Client/TextEditScreen.cpp b/Minecraft.Client/TextEditScreen.cpp index d9804b92a..4b32d1392 100644 --- a/Minecraft.Client/TextEditScreen.cpp +++ b/Minecraft.Client/TextEditScreen.cpp @@ -35,7 +35,7 @@ void TextEditScreen::removed() Keyboard::enableRepeatEvents(false); if (minecraft->level->isClientSide) { - minecraft->getConnection(0)->send( shared_ptr( new SignUpdatePacket(sign->x, sign->y, sign->z, sign->IsVerified(), sign->IsCensored(), sign->GetMessages()) ) ); + minecraft->getConnection(0)->send(std::make_shared(sign->x, sign->y, sign->z, sign->IsVerified(), sign->IsCensored(), sign->GetMessages())); } } diff --git a/Minecraft.Client/TexturePackRepository.cpp b/Minecraft.Client/TexturePackRepository.cpp index 92032aae0..ef926d78b 100644 --- a/Minecraft.Client/TexturePackRepository.cpp +++ b/Minecraft.Client/TexturePackRepository.cpp @@ -8,6 +8,7 @@ #include "..\Minecraft.World\File.h" #include "..\Minecraft.World\StringHelpers.h" #include "Minimap.h" +#include "Common/UI/UI.h" TexturePack *TexturePackRepository::DEFAULT_TEXTURE_PACK = nullptr; diff --git a/Minecraft.Client/TrackedEntity.cpp b/Minecraft.Client/TrackedEntity.cpp index 386339543..3aa33248d 100644 --- a/Minecraft.Client/TrackedEntity.cpp +++ b/Minecraft.Client/TrackedEntity.cpp @@ -66,7 +66,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (lastRidingEntity != e->riding || (e->riding != nullptr && tickCount % (SharedConstants::TICKS_PER_SECOND * 3) == 0)) { lastRidingEntity = e->riding; - broadcast(shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, e, e->riding))); + broadcast(std::make_shared(SetEntityLinkPacket::RIDING, e, e->riding)); } // Moving forward special case for item frames @@ -94,7 +94,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl shared_ptr entityData = e->getEntityData(); if (entityData->isDirty()) { - broadcastAndSend( shared_ptr( new SetEntityDataPacket(e->entityId, entityData, false) ) ); + broadcastAndSend(std::make_shared(e->entityId, entityData, false)); } } else if (tickCount % updateInterval == 0 || e->hasImpulse || e->getEntityData()->isDirty()) @@ -152,7 +152,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ) { teleportDelay = 0; - packet = shared_ptr( new TeleportEntityPacket(e->entityId, xn, yn, zn, static_cast(yRotn), static_cast(xRotn)) ); + packet = std::make_shared(e->entityId, xn, yn, zn, static_cast(yRotn), static_cast(xRotn)); // printf("%d: New teleport rot %d\n",e->entityId,yRotn); yRotp = yRotn; xRotp = xRotn; @@ -179,12 +179,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl yRotn = yRotp + yRota; } // 5 bits each for x & z, and 6 for y - packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), 0 ) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), 0); c0a++; } else { - packet = shared_ptr( new MoveEntityPacket::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), static_cast(xRota)) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), static_cast(xRota)); // printf("%d: New posrot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); c0b++; } @@ -197,7 +197,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ( ya >= -16 ) && ( ya <= 15 ) ) { // 4 bits each for x & z, and 5 for y - packet = shared_ptr( new MoveEntityPacketSmall::Pos(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)); c1a++; } @@ -206,12 +206,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ( ya >= -32 ) && ( ya <= 31 ) ) { // use the packet with small packet with rotation if we can - 5 bits each for x & z, and 6 for y - still a byte less than the alternative - packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), 0, 0 )); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), 0, 0); c1b++; } else { - packet = shared_ptr( new MoveEntityPacket::Pos(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)); c1c++; } } @@ -231,13 +231,13 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl yRota = 15; yRotn = yRotp + yRota; } - packet = shared_ptr( new MoveEntityPacketSmall::Rot(e->entityId, static_cast(yRota), 0) ); + packet = std::make_shared(e->entityId, static_cast(yRota), 0); c2a++; } else { // printf("%d: New rot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); - packet = shared_ptr( new MoveEntityPacket::Rot(e->entityId, static_cast(yRota), static_cast(xRota)) ); + packet = std::make_shared(e->entityId, static_cast(yRota), static_cast(xRota)); c2b++; } } @@ -259,7 +259,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl xap = e->xd; yap = e->yd; zap = e->zd; - broadcast( shared_ptr( new SetEntityMotionPacket(e->entityId, xap, yap, zap) ) ); + broadcast(std::make_shared(e->entityId, xap, yap, zap)); } } @@ -291,7 +291,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (rot) { // 4J: Changed this to use deltas - broadcast( shared_ptr( new MoveEntityPacket::Rot(e->entityId, static_cast(yRota), static_cast(xRota))) ); + broadcast(std::make_shared(e->entityId, static_cast(yRota), static_cast(xRota))); yRotp = yRotn; xRotp = xRotn; } @@ -308,7 +308,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360); if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL) { - broadcast(shared_ptr( new RotateHeadPacket(e->entityId, static_cast(yHeadRot)))); + broadcast(std::make_shared(e->entityId, static_cast(yHeadRot))); yHeadRotp = yHeadRot; } @@ -320,7 +320,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (e->hurtMarked) { // broadcast(new AnimatePacket(e, AnimatePacket.HURT)); - broadcastAndSend( shared_ptr( new SetEntityMotionPacket(e) ) ); + broadcastAndSend(std::make_shared(e)); e->hurtMarked = false; } @@ -331,7 +331,7 @@ void TrackedEntity::sendDirtyEntityData() shared_ptr entityData = e->getEntityData(); if (entityData->isDirty()) { - broadcastAndSend( shared_ptr( new SetEntityDataPacket(e->entityId, entityData, false)) ); + broadcastAndSend(std::make_shared(e->entityId, entityData, false)); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) @@ -342,7 +342,7 @@ void TrackedEntity::sendDirtyEntityData() if (!attributes->empty()) { - broadcastAndSend(shared_ptr( new UpdateAttributesPacket(e->entityId, attributes)) ); + broadcastAndSend(std::make_shared(e->entityId, attributes)); } attributes->clear(); @@ -539,7 +539,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptrgetEntityData()->isEmpty() && !isAddMobPacket) { - sp->connection->send(shared_ptr( new SetEntityDataPacket(e->entityId, e->getEntityData(), true))); + sp->connection->send(std::make_shared(e->entityId, e->getEntityData(), true)); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) @@ -550,23 +550,23 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptrempty()) { - sp->connection->send(shared_ptr( new UpdateAttributesPacket(e->entityId, attributes)) ); + sp->connection->send(std::make_shared(e->entityId, attributes)); } delete attributes; } if (trackDelta && !isAddMobPacket) { - sp->connection->send( shared_ptr( new SetEntityMotionPacket(e->entityId, e->xd, e->yd, e->zd) ) ); + sp->connection->send(std::make_shared(e->entityId, e->xd, e->yd, e->zd)); } if (e->riding != nullptr) { - sp->connection->send(shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, e, e->riding))); + sp->connection->send(std::make_shared(SetEntityLinkPacket::RIDING, e, e->riding)); } if ( e->instanceof(eTYPE_MOB) && dynamic_pointer_cast(e)->getLeashHolder() != nullptr) { - sp->connection->send( shared_ptr( new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, e, dynamic_pointer_cast(e)->getLeashHolder())) ); + sp->connection->send(std::make_shared(SetEntityLinkPacket::LEASH, e, dynamic_pointer_cast(e)->getLeashHolder())); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) @@ -574,7 +574,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr item = dynamic_pointer_cast(e)->getCarried(i); - if(item != nullptr) sp->connection->send( shared_ptr( new SetEquippedItemPacket(e->entityId, i, item) ) ); + if(item != nullptr) sp->connection->send(std::make_shared(e->entityId, i, item)); } } @@ -583,7 +583,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr spe = dynamic_pointer_cast(e); if (spe->isSleeping()) { - sp->connection->send( shared_ptr( new EntityActionAtPositionPacket(e, EntityActionAtPositionPacket::START_SLEEP, Mth::floor(e->x), Mth::floor(e->y), Mth::floor(e->z)) ) ); + sp->connection->send(std::make_shared(e, EntityActionAtPositionPacket::START_SLEEP, Mth::floor(e->x), Mth::floor(e->y), Mth::floor(e->z))); } } @@ -639,12 +639,12 @@ shared_ptr TrackedEntity::getAddEntityPacket() if (dynamic_pointer_cast(e) != nullptr) { yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); - return shared_ptr( new AddMobPacket(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp) ); + return std::make_shared(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp); } if (e->instanceof(eTYPE_ITEMENTITY)) { - shared_ptr packet = shared_ptr( new AddEntityPacket(e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp) ); + shared_ptr packet = std::make_shared(e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp); return packet; } else if (e->instanceof(eTYPE_SERVERPLAYER)) @@ -659,55 +659,55 @@ shared_ptr TrackedEntity::getAddEntityPacket() OnlineXuid = player->getOnlineXuid(); } // 4J Added yHeadRotp param to fix #102563 - TU12: Content: Gameplay: When one of the Players is idle for a few minutes his head turns 180 degrees. - return shared_ptr( new AddPlayerPacket( player, xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp, yHeadRotp ) ); + return std::make_shared(player, xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp, yHeadRotp); } else if (e->instanceof(eTYPE_MINECART)) { shared_ptr minecart = dynamic_pointer_cast(e); - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::MINECART, minecart->getType(), yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::MINECART, minecart->getType(), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_BOAT)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ENDERDRAGON)) { yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); - return shared_ptr( new AddMobPacket(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp ) ); + return std::make_shared(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp); } else if (e->instanceof(eTYPE_FISHINGHOOK)) { shared_ptr owner = dynamic_pointer_cast(e)->owner; - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FISH_HOOK, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ARROW)) { shared_ptr owner = (dynamic_pointer_cast(e))->owner; - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::ARROW, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_SNOWBALL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNPOTION)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp)); + return std::make_shared(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNEXPBOTTLE)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNENDERPEARL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_EYEOFENDERSIGNAL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FIREWORKS_ROCKET)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FIREWORKS, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FIREWORKS, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FIREBALL)) { @@ -730,11 +730,11 @@ shared_ptr TrackedEntity::getAddEntityPacket() shared_ptr aep = nullptr; if (fb->owner != nullptr) { - aep = shared_ptr( new AddEntityPacket(e, type, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); + aep = std::make_shared(e, type, fb->owner->entityId, yRotp, xRotp, xp, yp, zp); } else { - aep = shared_ptr( new AddEntityPacket(e, type, 0, yRotp, xRotp, xp, yp, zp) ); + aep = std::make_shared(e, type, 0, yRotp, xRotp, xp, yp, zp); } aep->xa = static_cast(fb->xPower * 8000); aep->ya = static_cast(fb->yPower * 8000); @@ -743,24 +743,24 @@ shared_ptr TrackedEntity::getAddEntityPacket() } else if (e->instanceof(eTYPE_THROWNEGG)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_PRIMEDTNT)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ENDER_CRYSTAL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FALLINGTILE)) { shared_ptr ft = dynamic_pointer_cast(e); - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_PAINTING)) { - return shared_ptr( new AddPaintingPacket(dynamic_pointer_cast(e)) ); + return std::make_shared(dynamic_pointer_cast(e)); } else if (e->instanceof(eTYPE_ITEM_FRAME)) { @@ -774,7 +774,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() app.DebugPrintf("eTYPE_ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); } - shared_ptr packet = shared_ptr(new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp)); + shared_ptr packet = std::make_shared(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp); packet->x = Mth::floor(frame->xTile * 32.0f); packet->y = Mth::floor(frame->yTile * 32.0f); packet->z = Mth::floor(frame->zTile * 32.0f); @@ -783,7 +783,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() else if (e->instanceof(eTYPE_LEASHFENCEKNOT)) { shared_ptr knot = dynamic_pointer_cast(e); - shared_ptr packet = shared_ptr(new AddEntityPacket(e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp) ); + shared_ptr packet = std::make_shared(e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp); packet->x = Mth::floor(static_cast(knot->xTile) * 32); packet->y = Mth::floor(static_cast(knot->yTile) * 32); packet->z = Mth::floor(static_cast(knot->zTile) * 32); @@ -791,7 +791,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() } else if (e->instanceof(eTYPE_EXPERIENCEORB)) { - return shared_ptr( new AddExperienceOrbPacket(dynamic_pointer_cast(e)) ); + return std::make_shared(dynamic_pointer_cast(e)); } else { diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 343dbd129..b2e2d2a30 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -43,6 +43,7 @@ #include "Common/PostProcesser.h" #include "Network\WinsockNetLayer.h" #include "Windows64_Xuid.h" +#include "Common/UI/UI.h" #include "Xbox/resource.h" @@ -78,7 +79,6 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= 0,0,0,0,0 #endif }; - //------------------------------------------------------------------------------------- // Time Since fAppTime is a float, we need to keep the quadword app time // as a LARGE_INTEGER so that we don't lose precision after running diff --git a/Minecraft.Client/Windows64/Windows64_UIController.h b/Minecraft.Client/Windows64/Windows64_UIController.h index 2b2ccdbac..066d279fb 100644 --- a/Minecraft.Client/Windows64/Windows64_UIController.h +++ b/Minecraft.Client/Windows64/Windows64_UIController.h @@ -26,5 +26,3 @@ class ConsoleUIController : public UIController public: void shutdown(); }; - -extern ConsoleUIController ui; \ No newline at end of file diff --git a/Minecraft.World/AbstractContainerMenu.cpp b/Minecraft.World/AbstractContainerMenu.cpp index 637d05a68..52d491a6b 100644 --- a/Minecraft.World/AbstractContainerMenu.cpp +++ b/Minecraft.World/AbstractContainerMenu.cpp @@ -276,7 +276,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto if(looped) { // Return a non-null value to indicate that we want to loop more - clickedEntity = shared_ptr(new ItemInstance(0,1,0)); + clickedEntity = std::make_shared(0, 1, 0); } else { @@ -467,20 +467,20 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto player->drop(item); } } - else if (clickType == CLICK_PICKUP_ALL && slotIndex >= 0) + else if (clickType == CLICK_PICKUP_ALL && slotIndex >= 0) { Slot *slot = slots.at(slotIndex); shared_ptr carried = inventory->getCarried(); if (carried != nullptr && (slot == nullptr || !slot->hasItem() || !slot->mayPickup(player))) { - int start = buttonNum == 0 ? 0 : slots.size() - 1; + int start = buttonNum == 0 ? 0 : static_cast(slots.size()) - 1; int step = buttonNum == 0 ? 1 : -1; for (int pass = 0; pass < 2; pass++ ) { // In the first pass, we only get partial stacks. - for (int i = start; i >= 0 && i < slots.size() && carried->count < carried->getMaxStackSize(); i += step) + for (int i = start; i >= 0 && i < static_cast(slots.size()) && carried->count < carried->getMaxStackSize(); i += step) { Slot *target = slots.at(i); diff --git a/Minecraft.World/AbstractContainerMenu.h b/Minecraft.World/AbstractContainerMenu.h index 3365593cf..9c7600ce1 100644 --- a/Minecraft.World/AbstractContainerMenu.h +++ b/Minecraft.World/AbstractContainerMenu.h @@ -35,7 +35,7 @@ class AbstractContainerMenu static const int CONTAINER_ID_INVENTORY = 0; static const int CONTAINER_ID_CREATIVE = -2; - vector > lastSlots; + vector> lastSlots; vector slots; int containerId; diff --git a/Minecraft.World/AddEntityPacket.h b/Minecraft.World/AddEntityPacket.h index 293964796..d40a84379 100644 --- a/Minecraft.World/AddEntityPacket.h +++ b/Minecraft.World/AddEntityPacket.h @@ -52,6 +52,6 @@ class AddEntityPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new AddEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 23; } }; \ No newline at end of file diff --git a/Minecraft.World/AddExperienceOrbPacket.h b/Minecraft.World/AddExperienceOrbPacket.h index 59accfb31..f955a8bdb 100644 --- a/Minecraft.World/AddExperienceOrbPacket.h +++ b/Minecraft.World/AddExperienceOrbPacket.h @@ -19,6 +19,6 @@ class AddExperienceOrbPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new AddExperienceOrbPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 26; } }; \ No newline at end of file diff --git a/Minecraft.World/AddGlobalEntityPacket.h b/Minecraft.World/AddGlobalEntityPacket.h index 80c10db2f..9959dc774 100644 --- a/Minecraft.World/AddGlobalEntityPacket.h +++ b/Minecraft.World/AddGlobalEntityPacket.h @@ -20,6 +20,6 @@ class AddGlobalEntityPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new AddGlobalEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 71; } }; \ No newline at end of file diff --git a/Minecraft.World/AddMobPacket.h b/Minecraft.World/AddMobPacket.h index 6af72655e..9f7c1e1c5 100644 --- a/Minecraft.World/AddMobPacket.h +++ b/Minecraft.World/AddMobPacket.h @@ -32,6 +32,6 @@ class AddMobPacket : public Packet, public enable_shared_from_this vector > *getUnpackedData(); public: - static shared_ptr create() { return shared_ptr(new AddMobPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 24; } }; diff --git a/Minecraft.World/AddPaintingPacket.h b/Minecraft.World/AddPaintingPacket.h index a5694b749..a50c1b771 100644 --- a/Minecraft.World/AddPaintingPacket.h +++ b/Minecraft.World/AddPaintingPacket.h @@ -22,6 +22,6 @@ class AddPaintingPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new AddPaintingPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 25; } }; diff --git a/Minecraft.World/AddPlayerPacket.h b/Minecraft.World/AddPlayerPacket.h index 30f6bcdda..af90c97df 100644 --- a/Minecraft.World/AddPlayerPacket.h +++ b/Minecraft.World/AddPlayerPacket.h @@ -38,6 +38,6 @@ class AddPlayerPacket : public Packet, public enable_shared_from_this > *getUnpackedData(); public: - static shared_ptr create() { return shared_ptr(new AddPlayerPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 20; } }; diff --git a/Minecraft.World/Animal.cpp b/Minecraft.World/Animal.cpp index bd9bc3fad..682781623 100644 --- a/Minecraft.World/Animal.cpp +++ b/Minecraft.World/Animal.cpp @@ -154,7 +154,7 @@ void Animal::breedWith(shared_ptr target) } level->addEntity(offspring); - level->addEntity( shared_ptr( new ExperienceOrb(level, x, y, z, random->nextInt(4) + 1) ) ); + level->addEntity(std::make_shared(level, x, y, z, random->nextInt(4) + 1)); } setDespawnProtected(); diff --git a/Minecraft.World/AnimatePacket.h b/Minecraft.World/AnimatePacket.h index 0287b9a6e..7075ffab6 100644 --- a/Minecraft.World/AnimatePacket.h +++ b/Minecraft.World/AnimatePacket.h @@ -26,6 +26,6 @@ class AnimatePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new AnimatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 18; } }; \ No newline at end of file diff --git a/Minecraft.World/AnvilMenu.cpp b/Minecraft.World/AnvilMenu.cpp index de3315544..78d72daf7 100644 --- a/Minecraft.World/AnvilMenu.cpp +++ b/Minecraft.World/AnvilMenu.cpp @@ -8,8 +8,8 @@ AnvilMenu::AnvilMenu(shared_ptr inventory, Level *level, int xt, int yt, int zt, shared_ptr player) { - resultSlots = shared_ptr( new ResultContainer() ); - repairSlots = shared_ptr( new RepairContainer(this,IDS_REPAIR_AND_NAME, true, 2) ); + resultSlots = std::make_shared(); + repairSlots = std::make_shared(this,IDS_REPAIR_AND_NAME, true, 2); cost = 0; repairItemCountCost = 0; diff --git a/Minecraft.World/Arrow.cpp b/Minecraft.World/Arrow.cpp index 4c5d9ae3b..c433715a5 100644 --- a/Minecraft.World/Arrow.cpp +++ b/Minecraft.World/Arrow.cpp @@ -338,7 +338,7 @@ void Arrow::tick() if (owner != nullptr && res->entity != owner && owner->GetType() == eTYPE_SERVERPLAYER) { - dynamic_pointer_cast(owner)->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::SUCCESSFUL_BOW_HIT, 0)) ); + dynamic_pointer_cast(owner)->connection->send(std::make_shared(GameEventPacket::SUCCESSFUL_BOW_HIT, 0)); } } @@ -499,7 +499,7 @@ void Arrow::playerTouch(shared_ptr player) if (pickup == PICKUP_ALLOWED) { - if (!player->inventory->add( shared_ptr( new ItemInstance(Item::arrow, 1) ) )) + if (!player->inventory->add(std::make_shared(Item::arrow, 1))) { bRemove = false; } diff --git a/Minecraft.World/AwardStatPacket.h b/Minecraft.World/AwardStatPacket.h index 6b79c0234..01cad26d9 100644 --- a/Minecraft.World/AwardStatPacket.h +++ b/Minecraft.World/AwardStatPacket.h @@ -24,7 +24,7 @@ class AwardStatPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new AwardStatPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 200; } public: diff --git a/Minecraft.World/BeaconTile.cpp b/Minecraft.World/BeaconTile.cpp index 998f15e85..04b17d112 100644 --- a/Minecraft.World/BeaconTile.cpp +++ b/Minecraft.World/BeaconTile.cpp @@ -11,7 +11,7 @@ BeaconTile::BeaconTile(int id) : BaseEntityTile(id, Material::glass, isSolidRend shared_ptr BeaconTile::newTileEntity(Level *level) { - return shared_ptr( new BeaconTileEntity() ); + return std::make_shared(); } bool BeaconTile::use(Level *level, int x, int y, int z, shared_ptr player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly) diff --git a/Minecraft.World/BeaconTileEntity.cpp b/Minecraft.World/BeaconTileEntity.cpp index 10e74eee1..633930f4f 100644 --- a/Minecraft.World/BeaconTileEntity.cpp +++ b/Minecraft.World/BeaconTileEntity.cpp @@ -10,7 +10,7 @@ shared_ptr BeaconTileEntity::clone() { - shared_ptr result = shared_ptr( new BeaconTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->primaryPower = primaryPower; @@ -252,7 +252,7 @@ shared_ptr BeaconTileEntity::getUpdatePacket() { CompoundTag *tag = new CompoundTag(); save(tag); - return shared_ptr( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_BEACON, tag) ); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_BEACON, tag); } double BeaconTileEntity::getViewDistance() @@ -306,7 +306,7 @@ shared_ptr BeaconTileEntity::removeItem(unsigned int slot, int cou else { paymentItem->count -= count; - return shared_ptr( new ItemInstance(paymentItem->id, count, paymentItem->getAuxValue()) ); + return std::make_shared(paymentItem->id, count, paymentItem->getAuxValue()); } } return nullptr; diff --git a/Minecraft.World/Blaze.cpp b/Minecraft.World/Blaze.cpp index de74fc758..ec72dfcb7 100644 --- a/Minecraft.World/Blaze.cpp +++ b/Minecraft.World/Blaze.cpp @@ -152,7 +152,7 @@ void Blaze::checkHurtTarget(shared_ptr target, float d) level->levelEvent(nullptr, LevelEvent::SOUND_BLAZE_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); // level.playSound(this, "mob.ghast.fireball", getSoundVolume(), (random.nextFloat() - random.nextFloat()) * 0.2f + 1.0f); for (int i = 0; i < 1; i++) { - shared_ptr ie = shared_ptr( new SmallFireball(level, dynamic_pointer_cast( shared_from_this() ), xd + random->nextGaussian() * sqd, yd, zd + random->nextGaussian() * sqd) ); + shared_ptr ie = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), xd + random->nextGaussian() * sqd, yd, zd + random->nextGaussian() * sqd); // Vec3 v = getViewVector(1); // ie.x = x + v.x * 1.5; ie->y = y + bbHeight / 2 + 0.5f; diff --git a/Minecraft.World/BlockRegionUpdatePacket.h b/Minecraft.World/BlockRegionUpdatePacket.h index 54dfea4eb..d823acafb 100644 --- a/Minecraft.World/BlockRegionUpdatePacket.h +++ b/Minecraft.World/BlockRegionUpdatePacket.h @@ -28,6 +28,6 @@ class BlockRegionUpdatePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new BlockRegionUpdatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 51; } }; diff --git a/Minecraft.World/BoatItem.cpp b/Minecraft.World/BoatItem.cpp index 379e5e448..5cf2cd380 100644 --- a/Minecraft.World/BoatItem.cpp +++ b/Minecraft.World/BoatItem.cpp @@ -107,7 +107,7 @@ shared_ptr BoatItem::use(shared_ptr itemInstance, Le if (level->getTile(xt, yt, zt) == Tile::topSnow_Id) yt--; if( level->countInstanceOf(eTYPE_BOAT, true) < Level::MAX_XBOX_BOATS ) // 4J - added limit { - shared_ptr boat = shared_ptr( new Boat(level, xt + 0.5f, yt + 1.0f, zt + 0.5f) ); + shared_ptr boat = std::make_shared(level, xt + 0.5f, yt + 1.0f, zt + 0.5f); boat->yRot = ((Mth::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) * 90; if (!level->getCubes(boat, boat->bb->grow(-.1, -.1, -.1))->empty()) { diff --git a/Minecraft.World/BottleItem.cpp b/Minecraft.World/BottleItem.cpp index 57fb95cdf..3e526b2a8 100644 --- a/Minecraft.World/BottleItem.cpp +++ b/Minecraft.World/BottleItem.cpp @@ -40,13 +40,13 @@ shared_ptr BottleItem::use(shared_ptr itemInstance, itemInstance->count--; if (itemInstance->count <= 0) { - return shared_ptr( new ItemInstance( static_cast(Item::potion)) ); + return std::make_shared(static_cast(Item::potion)); } else { - if (!player->inventory->add(shared_ptr( new ItemInstance( static_cast(Item::potion)) ))) + if (!player->inventory->add(std::make_shared(static_cast(Item::potion)))) { - player->drop( shared_ptr( new ItemInstance(Item::potion_Id, 1, 0) )); + player->drop(std::make_shared(Item::potion_Id, 1, 0)); } } } diff --git a/Minecraft.World/BowItem.cpp b/Minecraft.World/BowItem.cpp index b2ef08c9e..a2d34b89f 100644 --- a/Minecraft.World/BowItem.cpp +++ b/Minecraft.World/BowItem.cpp @@ -30,7 +30,7 @@ void BowItem::releaseUsing(shared_ptr itemInstance, Level *level, if (pow < 0.1) return; if (pow > 1) pow = 1; - shared_ptr arrow = shared_ptr( new Arrow(level, player, pow * 2.0f) ); + shared_ptr arrow = std::make_shared(level, player, pow * 2.0f); if (pow == 1) arrow->setCritArrow(true); int damageBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowBonus->id, itemInstance); if (damageBonus > 0) diff --git a/Minecraft.World/BowlFoodItem.cpp b/Minecraft.World/BowlFoodItem.cpp index f8ab06054..66e1dbb14 100644 --- a/Minecraft.World/BowlFoodItem.cpp +++ b/Minecraft.World/BowlFoodItem.cpp @@ -12,5 +12,5 @@ shared_ptr BowlFoodItem::useTimeDepleted(shared_ptr { FoodItem::useTimeDepleted(instance, level, player); - return shared_ptr(new ItemInstance(Item::bowl)); + return std::make_shared(Item::bowl); } \ No newline at end of file diff --git a/Minecraft.World/BreedGoal.cpp b/Minecraft.World/BreedGoal.cpp index 11840388c..10aa6844b 100644 --- a/Minecraft.World/BreedGoal.cpp +++ b/Minecraft.World/BreedGoal.cpp @@ -118,5 +118,5 @@ void BreedGoal::breed() * animal->bbWidth * 2 - animal->bbWidth, xa, ya, za); } // 4J-PB - Fix for 106869- Customer Encountered: TU12: Content: Gameplay: Breeding animals does not give any Experience Orbs. - level->addEntity( shared_ptr( new ExperienceOrb(level, animal->x, animal->y, animal->z, random->nextInt(7) + 1) ) ); + level->addEntity(std::make_shared(level, animal->x, animal->y, animal->z, random->nextInt(7) + 1)); } diff --git a/Minecraft.World/BrewingStandTile.cpp b/Minecraft.World/BrewingStandTile.cpp index afdf839aa..ec7242c82 100644 --- a/Minecraft.World/BrewingStandTile.cpp +++ b/Minecraft.World/BrewingStandTile.cpp @@ -30,7 +30,7 @@ int BrewingStandTile::getRenderShape() shared_ptr BrewingStandTile::newTileEntity(Level *level) { - return shared_ptr(new BrewingStandTileEntity()); + return std::make_shared(); } bool BrewingStandTile::isCubeShaped() @@ -104,7 +104,7 @@ void BrewingStandTile::onRemove(Level *level, int x, int y, int z, int id, int d if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue())))); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; diff --git a/Minecraft.World/BrewingStandTileEntity.cpp b/Minecraft.World/BrewingStandTileEntity.cpp index 825149816..3d081baec 100644 --- a/Minecraft.World/BrewingStandTileEntity.cpp +++ b/Minecraft.World/BrewingStandTileEntity.cpp @@ -254,14 +254,14 @@ void BrewingStandTileEntity::doBrew() } else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id) { - items[dest] = shared_ptr(new ItemInstance(Item::potion)); + items[dest] = std::make_shared(Item::potion); } } } if (Item::items[ingredient->id]->hasCraftingRemainingItem()) { - items[INGREDIENT_SLOT] = shared_ptr(new ItemInstance(Item::items[ingredient->id]->getCraftingRemainingItem())); + items[INGREDIENT_SLOT] = std::make_shared(Item::items[ingredient->id]->getCraftingRemainingItem()); } else { @@ -476,7 +476,7 @@ bool BrewingStandTileEntity::canTakeItemThroughFace(int slot, shared_ptr BrewingStandTileEntity::clone() { - shared_ptr result = shared_ptr( new BrewingStandTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->brewTime = brewTime; diff --git a/Minecraft.World/BucketItem.cpp b/Minecraft.World/BucketItem.cpp index b7553c26b..cb9d54b66 100644 --- a/Minecraft.World/BucketItem.cpp +++ b/Minecraft.World/BucketItem.cpp @@ -120,7 +120,7 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, if( servPlayer != nullptr ) { app.DebugPrintf("Sending ChatPacket::e_ChatCannotPlaceLava to player\n"); - servPlayer->connection->send( shared_ptr( new ChatPacket(L"", ChatPacket::e_ChatCannotPlaceLava ) ) ); + servPlayer->connection->send(std::make_shared(L"", ChatPacket::e_ChatCannotPlaceLava)); } delete hr; @@ -141,13 +141,13 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, if (--itemInstance->count <= 0) { - return shared_ptr( new ItemInstance(Item::bucket_water) ); + return std::make_shared(Item::bucket_water); } else { - if (!player->inventory->add(shared_ptr( new ItemInstance(Item::bucket_water)))) + if (!player->inventory->add(std::make_shared(Item::bucket_water))) { - player->drop(shared_ptr(new ItemInstance(Item::bucket_water_Id, 1, 0))); + player->drop(std::make_shared(Item::bucket_water_Id, 1, 0)); } return itemInstance; } @@ -168,13 +168,13 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, } if (--itemInstance->count <= 0) { - return shared_ptr( new ItemInstance(Item::bucket_lava) ); + return std::make_shared(Item::bucket_lava); } else { - if (!player->inventory->add(shared_ptr( new ItemInstance(Item::bucket_lava)))) + if (!player->inventory->add(std::make_shared(Item::bucket_lava))) { - player->drop(shared_ptr(new ItemInstance(Item::bucket_lava_Id, 1, 0))); + player->drop(std::make_shared(Item::bucket_lava_Id, 1, 0)); } return itemInstance; } @@ -183,7 +183,7 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, else if (content < 0) { delete hr; - return shared_ptr( new ItemInstance(Item::bucket_empty) ); + return std::make_shared(Item::bucket_empty); } else { @@ -199,7 +199,7 @@ shared_ptr BucketItem::use(shared_ptr itemInstance, if (emptyBucket(level, xt, yt, zt) && !player->abilities.instabuild) { - return shared_ptr( new ItemInstance(Item::bucket_empty) ); + return std::make_shared(Item::bucket_empty); } } diff --git a/Minecraft.World/CarrotOnAStickItem.cpp b/Minecraft.World/CarrotOnAStickItem.cpp index 3701fce10..cc39196cf 100644 --- a/Minecraft.World/CarrotOnAStickItem.cpp +++ b/Minecraft.World/CarrotOnAStickItem.cpp @@ -35,7 +35,7 @@ shared_ptr CarrotOnAStickItem::use(shared_ptr itemIn if (itemInstance->count == 0) { - shared_ptr replacement = shared_ptr(new ItemInstance(Item::fishingRod)); + shared_ptr replacement = std::make_shared(Item::fishingRod); replacement->setTag(itemInstance->tag); return replacement; } diff --git a/Minecraft.World/CauldronTile.cpp b/Minecraft.World/CauldronTile.cpp index 599a9353e..c77ebd281 100644 --- a/Minecraft.World/CauldronTile.cpp +++ b/Minecraft.World/CauldronTile.cpp @@ -107,7 +107,7 @@ bool CauldronTile::use(Level *level, int x, int y, int z, shared_ptr pla { if (!player->abilities.instabuild) { - player->inventory->setItem(player->inventory->selected, shared_ptr(new ItemInstance(Item::bucket_empty))); + player->inventory->setItem(player->inventory->selected, std::make_shared(Item::bucket_empty)); } level->setData(x, y, z, 3, Tile::UPDATE_CLIENTS); @@ -119,10 +119,10 @@ bool CauldronTile::use(Level *level, int x, int y, int z, shared_ptr pla { if (fillLevel > 0) { - shared_ptr potion = shared_ptr(new ItemInstance(Item::potion, 1, 0)); + shared_ptr potion = std::make_shared(Item::potion, 1, 0); if (!player->inventory->add(potion)) { - level->addEntity(shared_ptr(new ItemEntity(level, x + 0.5, y + 1.5, z + 0.5, potion))); + level->addEntity(std::make_shared(level, x + 0.5, y + 1.5, z + 0.5, potion)); } // 4J Stu - Brought forward change to update inventory when filling bottles with water else if (player->instanceof(eTYPE_SERVERPLAYER)) diff --git a/Minecraft.World/ChatPacket.h b/Minecraft.World/ChatPacket.h index ca9e49557..ea9b38061 100644 --- a/Minecraft.World/ChatPacket.h +++ b/Minecraft.World/ChatPacket.h @@ -119,7 +119,7 @@ class ChatPacket : public Packet, public enable_shared_from_this virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ChatPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 3; } }; diff --git a/Minecraft.World/ChestTile.cpp b/Minecraft.World/ChestTile.cpp index a81497215..ff3c0b406 100644 --- a/Minecraft.World/ChestTile.cpp +++ b/Minecraft.World/ChestTile.cpp @@ -231,9 +231,9 @@ void ChestTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (count > item->count) count = item->count; item->count -= count; - shared_ptr newItem = shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()) ); + shared_ptr newItem = std::make_shared(item->id, count, item->getAuxValue()); newItem->set4JData( item->get4JData() ); - shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, newItem); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; @@ -293,10 +293,10 @@ shared_ptr ChestTile::getContainer(Level *level, int x, int y, int z) if (level->getTile(x, y, z - 1) == id && (level->isSolidBlockingTile(x, y + 1, z - 1) || isCatSittingOnChest(level, x, y, z - 1))) return nullptr; if (level->getTile(x, y, z + 1) == id && (level->isSolidBlockingTile(x, y + 1, z + 1) || isCatSittingOnChest(level, x, y, z + 1))) return nullptr; - if (level->getTile(x - 1, y, z) == id) container = shared_ptr( new CompoundContainer(IDS_CHEST_LARGE, dynamic_pointer_cast( level->getTileEntity(x - 1, y, z) ), container) ); - if (level->getTile(x + 1, y, z) == id) container = shared_ptr( new CompoundContainer(IDS_CHEST_LARGE, container, dynamic_pointer_cast( level->getTileEntity(x + 1, y, z) )) ); - if (level->getTile(x, y, z - 1) == id) container = shared_ptr( new CompoundContainer(IDS_CHEST_LARGE, dynamic_pointer_cast( level->getTileEntity(x, y, z - 1) ), container) ); - if (level->getTile(x, y, z + 1) == id) container = shared_ptr( new CompoundContainer(IDS_CHEST_LARGE, container, dynamic_pointer_cast( level->getTileEntity(x, y, z + 1) )) ); + if (level->getTile(x - 1, y, z) == id) container = std::make_shared(IDS_CHEST_LARGE, dynamic_pointer_cast(level->getTileEntity(x - 1, y, z)), container); + if (level->getTile(x + 1, y, z) == id) container = std::make_shared(IDS_CHEST_LARGE, container, dynamic_pointer_cast(level->getTileEntity(x + 1, y, z))); + if (level->getTile(x, y, z - 1) == id) container = std::make_shared(IDS_CHEST_LARGE, dynamic_pointer_cast(level->getTileEntity(x, y, z - 1)), container); + if (level->getTile(x, y, z + 1) == id) container = std::make_shared(IDS_CHEST_LARGE, container, dynamic_pointer_cast(level->getTileEntity(x, y, z + 1))); return container; } @@ -304,7 +304,7 @@ shared_ptr ChestTile::getContainer(Level *level, int x, int y, int z) shared_ptr ChestTile::newTileEntity(Level *level) { MemSect(50); - shared_ptr retval = shared_ptr( new ChestTileEntity() ); + shared_ptr retval = std::make_shared(); MemSect(0); return retval; } diff --git a/Minecraft.World/ChestTileEntity.cpp b/Minecraft.World/ChestTileEntity.cpp index 966eb5bb5..ba277e243 100644 --- a/Minecraft.World/ChestTileEntity.cpp +++ b/Minecraft.World/ChestTileEntity.cpp @@ -405,7 +405,7 @@ int ChestTileEntity::getType() // 4J Added shared_ptr ChestTileEntity::clone() { - shared_ptr result = shared_ptr( new ChestTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); for (unsigned int i = 0; i < items->length; i++) diff --git a/Minecraft.World/Chicken.cpp b/Minecraft.World/Chicken.cpp index 5f4cf2a73..355d8a256 100644 --- a/Minecraft.World/Chicken.cpp +++ b/Minecraft.World/Chicken.cpp @@ -143,7 +143,7 @@ shared_ptr Chicken::getBreedOffspring(shared_ptr target) // 4J - added limit to chickens that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - return shared_ptr(new Chicken(level)); + return std::make_shared(level); } else { diff --git a/Minecraft.World/ChunkTilesUpdatePacket.h b/Minecraft.World/ChunkTilesUpdatePacket.h index a97f49a39..7cbc3c651 100644 --- a/Minecraft.World/ChunkTilesUpdatePacket.h +++ b/Minecraft.World/ChunkTilesUpdatePacket.h @@ -25,7 +25,7 @@ class ChunkTilesUpdatePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ChunkTilesUpdatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 52; } }; diff --git a/Minecraft.World/ChunkVisibilityAreaPacket.h b/Minecraft.World/ChunkVisibilityAreaPacket.h index 330874970..9442b6f76 100644 --- a/Minecraft.World/ChunkVisibilityAreaPacket.h +++ b/Minecraft.World/ChunkVisibilityAreaPacket.h @@ -25,6 +25,6 @@ class ChunkVisibilityAreaPacket : public Packet, public enable_shared_from_this< virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ChunkVisibilityAreaPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 155; } }; diff --git a/Minecraft.World/ChunkVisibilityPacket.h b/Minecraft.World/ChunkVisibilityPacket.h index 8c5856c74..74af7f4d2 100644 --- a/Minecraft.World/ChunkVisibilityPacket.h +++ b/Minecraft.World/ChunkVisibilityPacket.h @@ -22,7 +22,7 @@ class ChunkVisibilityPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ChunkVisibilityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 50; } }; diff --git a/Minecraft.World/ClientCommandPacket.h b/Minecraft.World/ClientCommandPacket.h index 2f614ddf1..b3578a105 100644 --- a/Minecraft.World/ClientCommandPacket.h +++ b/Minecraft.World/ClientCommandPacket.h @@ -19,6 +19,6 @@ class ClientCommandPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ClientCommandPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 205; } }; \ No newline at end of file diff --git a/Minecraft.World/CocoaTile.cpp b/Minecraft.World/CocoaTile.cpp index 095f9b527..3df58eb84 100644 --- a/Minecraft.World/CocoaTile.cpp +++ b/Minecraft.World/CocoaTile.cpp @@ -151,7 +151,7 @@ void CocoaTile::spawnResources(Level *level, int x, int y, int z, int data, floa } for (int i = 0; i < count; i++) { - popResource(level, x, y, z, shared_ptr( new ItemInstance(Item::dye_powder, 1, DyePowderItem::BROWN) )); + popResource(level, x, y, z, std::make_shared(Item::dye_powder, 1, DyePowderItem::BROWN)); } } diff --git a/Minecraft.World/CombatTracker.cpp b/Minecraft.World/CombatTracker.cpp index 7fe8316fb..7e1aa80c4 100644 --- a/Minecraft.World/CombatTracker.cpp +++ b/Minecraft.World/CombatTracker.cpp @@ -58,7 +58,7 @@ void CombatTracker::recordDamage(DamageSource *source, float health, float damag shared_ptr CombatTracker::getDeathMessagePacket() { - if (entries.size() == 0) return shared_ptr(new ChatPacket(mob->getNetworkName())); + if (entries.size() == 0) return std::make_shared(mob->getNetworkName()); CombatEntry *knockOffEntry = getMostSignificantFall(); CombatEntry *killingBlow = entries[entries.size() - 1]; @@ -91,7 +91,7 @@ shared_ptr CombatTracker::getDeathMessagePacket() break; } - result = shared_ptr(new ChatPacket(mob->getNetworkName(), message)); + result = std::make_shared(mob->getNetworkName(), message); } else if (attackerEntity != nullptr && (killingEntity == nullptr || attackerEntity != killingEntity)) { @@ -99,11 +99,11 @@ shared_ptr CombatTracker::getDeathMessagePacket() if (attackerItem != nullptr && attackerItem->hasCustomHoverName()) { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssistItem, attackerEntity->GetType(), attackerEntity->getNetworkName(), attackerItem->getHoverName())); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssistItem, attackerEntity->GetType(), attackerEntity->getNetworkName(), attackerItem->getHoverName()); } else { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssist, attackerEntity->GetType(), attackerEntity->getNetworkName())); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellAssist, attackerEntity->GetType(), attackerEntity->getNetworkName()); } } else if (killingEntity != nullptr) @@ -111,16 +111,16 @@ shared_ptr CombatTracker::getDeathMessagePacket() shared_ptr killerItem = killingEntity->instanceof(eTYPE_LIVINGENTITY) ? dynamic_pointer_cast(killingEntity)->getCarriedItem() : nullptr; if (killerItem != nullptr && killerItem->hasCustomHoverName()) { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinishItem, killingEntity->GetType(), killingEntity->getNetworkName(), killerItem->getHoverName())); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinishItem, killingEntity->GetType(), killingEntity->getNetworkName(), killerItem->getHoverName()); } else { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinish, killingEntity->GetType(), killingEntity->getNetworkName())); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellFinish, killingEntity->GetType(), killingEntity->getNetworkName()); } } else { - result = shared_ptr(new ChatPacket(mob->getNetworkName(), ChatPacket::e_ChatDeathFellKiller)); + result = std::make_shared(mob->getNetworkName(), ChatPacket::e_ChatDeathFellKiller); } } else diff --git a/Minecraft.World/CommandBlock.cpp b/Minecraft.World/CommandBlock.cpp index 1810ef132..c151172e0 100644 --- a/Minecraft.World/CommandBlock.cpp +++ b/Minecraft.World/CommandBlock.cpp @@ -10,7 +10,7 @@ CommandBlock::CommandBlock(int id) : BaseEntityTile(id, Material::metal, isSolid shared_ptr CommandBlock::newTileEntity(Level *level) { - return shared_ptr( new CommandBlockEntity() ); + return std::make_shared(); } void CommandBlock::neighborChanged(Level *level, int x, int y, int z, int type) diff --git a/Minecraft.World/CommandBlockEntity.cpp b/Minecraft.World/CommandBlockEntity.cpp index b81f8e46b..00870ee48 100644 --- a/Minecraft.World/CommandBlockEntity.cpp +++ b/Minecraft.World/CommandBlockEntity.cpp @@ -94,7 +94,7 @@ shared_ptr CommandBlockEntity::getUpdatePacket() { CompoundTag *tag = new CompoundTag(); save(tag); - return shared_ptr( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_ADV_COMMAND, tag) ); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_ADV_COMMAND, tag); } int CommandBlockEntity::getSuccessCount() @@ -110,7 +110,7 @@ void CommandBlockEntity::setSuccessCount(int successCount) // 4J Added shared_ptr CommandBlockEntity::clone() { - shared_ptr result = shared_ptr( new CommandBlockEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->successCount = successCount; diff --git a/Minecraft.World/ComparatorTile.cpp b/Minecraft.World/ComparatorTile.cpp index 197a936cc..e7d8f1787 100644 --- a/Minecraft.World/ComparatorTile.cpp +++ b/Minecraft.World/ComparatorTile.cpp @@ -244,7 +244,7 @@ bool ComparatorTile::triggerEvent(Level *level, int x, int y, int z, int b0, int shared_ptr ComparatorTile::newTileEntity(Level *level) { - return shared_ptr( new ComparatorTileEntity() ); + return std::make_shared(); } bool ComparatorTile::TestUse() diff --git a/Minecraft.World/ComparatorTileEntity.cpp b/Minecraft.World/ComparatorTileEntity.cpp index 9a58d23c1..7cd1f064e 100644 --- a/Minecraft.World/ComparatorTileEntity.cpp +++ b/Minecraft.World/ComparatorTileEntity.cpp @@ -27,7 +27,7 @@ void ComparatorTileEntity::setOutputSignal(int value) // 4J Added shared_ptr ComparatorTileEntity::clone() { - shared_ptr result = shared_ptr( new ComparatorTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->output = output; diff --git a/Minecraft.World/ComplexItemDataPacket.h b/Minecraft.World/ComplexItemDataPacket.h index 52de8f49d..1e41c3e94 100644 --- a/Minecraft.World/ComplexItemDataPacket.h +++ b/Minecraft.World/ComplexItemDataPacket.h @@ -20,7 +20,7 @@ class ComplexItemDataPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ComplexItemDataPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 131; } }; diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp index 962624b87..c1d3f9c5b 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -473,7 +473,7 @@ void Connection::tick() tickCount++; if (tickCount % 20 == 0) { - send( shared_ptr( new KeepAlivePacket() ) ); + send(std::make_shared()); } // 4J Stu - 1.8.2 changed from 100 to 1000 diff --git a/Minecraft.World/ContainerAckPacket.h b/Minecraft.World/ContainerAckPacket.h index 00f3592e6..be0287745 100644 --- a/Minecraft.World/ContainerAckPacket.h +++ b/Minecraft.World/ContainerAckPacket.h @@ -23,7 +23,7 @@ class ContainerAckPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ContainerAckPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 106; } }; diff --git a/Minecraft.World/ContainerButtonClickPacket.h b/Minecraft.World/ContainerButtonClickPacket.h index 522c5f868..01e8deb88 100644 --- a/Minecraft.World/ContainerButtonClickPacket.h +++ b/Minecraft.World/ContainerButtonClickPacket.h @@ -17,6 +17,6 @@ class ContainerButtonClickPacket : public Packet, public enable_shared_from_this virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerButtonClickPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 108; } }; \ No newline at end of file diff --git a/Minecraft.World/ContainerClickPacket.h b/Minecraft.World/ContainerClickPacket.h index 516861661..dee255b44 100644 --- a/Minecraft.World/ContainerClickPacket.h +++ b/Minecraft.World/ContainerClickPacket.h @@ -23,7 +23,7 @@ class ContainerClickPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ContainerClickPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 102; } }; diff --git a/Minecraft.World/ContainerClosePacket.h b/Minecraft.World/ContainerClosePacket.h index bf032a972..c4b78570b 100644 --- a/Minecraft.World/ContainerClosePacket.h +++ b/Minecraft.World/ContainerClosePacket.h @@ -17,7 +17,7 @@ class ContainerClosePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ContainerClosePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 101; } }; diff --git a/Minecraft.World/ContainerOpenPacket.h b/Minecraft.World/ContainerOpenPacket.h index 896b7dd9a..fac0e981f 100644 --- a/Minecraft.World/ContainerOpenPacket.h +++ b/Minecraft.World/ContainerOpenPacket.h @@ -46,7 +46,7 @@ class ContainerOpenPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ContainerOpenPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 100; } }; diff --git a/Minecraft.World/ContainerSetContentPacket.h b/Minecraft.World/ContainerSetContentPacket.h index 10315f58d..3159085b1 100644 --- a/Minecraft.World/ContainerSetContentPacket.h +++ b/Minecraft.World/ContainerSetContentPacket.h @@ -19,7 +19,7 @@ class ContainerSetContentPacket : public Packet, public enable_shared_from_this< virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ContainerSetContentPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 104; } }; diff --git a/Minecraft.World/ContainerSetDataPacket.h b/Minecraft.World/ContainerSetDataPacket.h index ce075e00e..c5d52a976 100644 --- a/Minecraft.World/ContainerSetDataPacket.h +++ b/Minecraft.World/ContainerSetDataPacket.h @@ -19,6 +19,6 @@ class ContainerSetDataPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ContainerSetDataPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 105; } }; \ No newline at end of file diff --git a/Minecraft.World/ContainerSetSlotPacket.h b/Minecraft.World/ContainerSetSlotPacket.h index 61269df02..86bca334b 100644 --- a/Minecraft.World/ContainerSetSlotPacket.h +++ b/Minecraft.World/ContainerSetSlotPacket.h @@ -23,7 +23,7 @@ class ContainerSetSlotPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ContainerSetSlotPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 103; } }; diff --git a/Minecraft.World/ControlledByPlayerGoal.cpp b/Minecraft.World/ControlledByPlayerGoal.cpp index 3069293d6..c5203e6ea 100644 --- a/Minecraft.World/ControlledByPlayerGoal.cpp +++ b/Minecraft.World/ControlledByPlayerGoal.cpp @@ -123,7 +123,7 @@ void ControlledByPlayerGoal::tick() if (carriedItem->count == 0) { - shared_ptr replacement = shared_ptr(new ItemInstance(Item::fishingRod)); + shared_ptr replacement = std::make_shared(Item::fishingRod); replacement->setTag(carriedItem->tag); player->inventory->items[player->inventory->selected] = replacement; } diff --git a/Minecraft.World/Cow.cpp b/Minecraft.World/Cow.cpp index d80c16a2e..69628d64f 100644 --- a/Minecraft.World/Cow.cpp +++ b/Minecraft.World/Cow.cpp @@ -112,11 +112,11 @@ bool Cow::mobInteract(shared_ptr player) if (item->count-- == 0) { - player->inventory->setItem(player->inventory->selected, shared_ptr( new ItemInstance(Item::bucket_milk) ) ); + player->inventory->setItem(player->inventory->selected, std::make_shared(Item::bucket_milk)); } - else if (!player->inventory->add(shared_ptr( new ItemInstance(Item::bucket_milk) ))) + else if (!player->inventory->add(std::make_shared(Item::bucket_milk))) { - player->drop(shared_ptr( new ItemInstance(Item::bucket_milk) )); + player->drop(std::make_shared(Item::bucket_milk)); } return true; @@ -129,7 +129,7 @@ shared_ptr Cow::getBreedOffspring(shared_ptr target) // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - return shared_ptr( new Cow(level) ); + return std::make_shared(level); } else { diff --git a/Minecraft.World/CraftItemPacket.h b/Minecraft.World/CraftItemPacket.h index 9793d593a..f6cbdd3d8 100644 --- a/Minecraft.World/CraftItemPacket.h +++ b/Minecraft.World/CraftItemPacket.h @@ -22,6 +22,6 @@ class CraftItemPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new CraftItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 150; } }; \ No newline at end of file diff --git a/Minecraft.World/CraftingMenu.cpp b/Minecraft.World/CraftingMenu.cpp index a510e8691..6f24d3108 100644 --- a/Minecraft.World/CraftingMenu.cpp +++ b/Minecraft.World/CraftingMenu.cpp @@ -19,8 +19,8 @@ const int CraftingMenu::USE_ROW_SLOT_END = CraftingMenu::USE_ROW_SLOT_START + 9; CraftingMenu::CraftingMenu(shared_ptr inventory, Level *level, int xt, int yt, int zt) : AbstractContainerMenu() { - craftSlots = shared_ptr( new CraftingContainer(this, 3, 3) ); - resultSlots = shared_ptr( new ResultContainer() ); + craftSlots = std::make_shared(this, 3, 3); + resultSlots = std::make_shared(); this->level = level; x = xt; diff --git a/Minecraft.World/CropTile.cpp b/Minecraft.World/CropTile.cpp index 39753caea..1a1611996 100644 --- a/Minecraft.World/CropTile.cpp +++ b/Minecraft.World/CropTile.cpp @@ -136,7 +136,7 @@ void CropTile::spawnResources(Level *level, int x, int y, int z, int data, float for (int i = 0; i < count; i++) { if (level->random->nextInt(5 * 3) > data) continue; - popResource(level, x, y, z, shared_ptr(new ItemInstance(getBaseSeedId(), 1, 0))); + popResource(level, x, y, z, std::make_shared(getBaseSeedId(), 1, 0)); } } } diff --git a/Minecraft.World/CustomPayloadPacket.h b/Minecraft.World/CustomPayloadPacket.h index 95c5e708d..82a3f6e26 100644 --- a/Minecraft.World/CustomPayloadPacket.h +++ b/Minecraft.World/CustomPayloadPacket.h @@ -30,6 +30,6 @@ class CustomPayloadPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new CustomPayloadPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 250; } }; \ No newline at end of file diff --git a/Minecraft.World/DamageSource.cpp b/Minecraft.World/DamageSource.cpp index 43e236bf4..bc3adc804 100644 --- a/Minecraft.World/DamageSource.cpp +++ b/Minecraft.World/DamageSource.cpp @@ -193,11 +193,11 @@ shared_ptr DamageSource::getDeathMessagePacket(shared_ptr source = player->getKillCredit(); if(source != nullptr) { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId != ChatPacket::e_ChatCustom ? m_msgWithItemId : m_msgId, source->GetType(), source->getNetworkName() ) ); + return std::make_shared(player->getNetworkName(), m_msgWithItemId != ChatPacket::e_ChatCustom ? m_msgWithItemId : m_msgId, source->GetType(), source->getNetworkName()); } else { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgId ) ); + return std::make_shared(player->getNetworkName(), m_msgId); } } diff --git a/Minecraft.World/DaylightDetectorTile.cpp b/Minecraft.World/DaylightDetectorTile.cpp index 396daec6d..0bfc949ba 100644 --- a/Minecraft.World/DaylightDetectorTile.cpp +++ b/Minecraft.World/DaylightDetectorTile.cpp @@ -95,7 +95,7 @@ bool DaylightDetectorTile::isSignalSource() shared_ptr DaylightDetectorTile::newTileEntity(Level *level) { - return shared_ptr( new DaylightDetectorTileEntity() ); + return std::make_shared(); } Icon *DaylightDetectorTile::getTexture(int face, int data) diff --git a/Minecraft.World/DaylightDetectorTileEntity.cpp b/Minecraft.World/DaylightDetectorTileEntity.cpp index 2b72f3c9e..0cf1cec34 100644 --- a/Minecraft.World/DaylightDetectorTileEntity.cpp +++ b/Minecraft.World/DaylightDetectorTileEntity.cpp @@ -22,7 +22,7 @@ void DaylightDetectorTileEntity::tick() // 4J Added shared_ptr DaylightDetectorTileEntity::clone() { - shared_ptr result = shared_ptr( new DaylightDetectorTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); return result; diff --git a/Minecraft.World/DeadBushTile.cpp b/Minecraft.World/DeadBushTile.cpp index 06bd41ee0..7f22f747f 100644 --- a/Minecraft.World/DeadBushTile.cpp +++ b/Minecraft.World/DeadBushTile.cpp @@ -37,7 +37,7 @@ void DeadBushTile::playerDestroy(Level *level, shared_ptr player, int x, ); // drop leaf block instead of sapling - popResource(level, x, y, z, shared_ptr(new ItemInstance(Tile::deadBush, 1, data))); + popResource(level, x, y, z, std::make_shared(Tile::deadBush, 1, data)); } else { diff --git a/Minecraft.World/DebugOptionsPacket.h b/Minecraft.World/DebugOptionsPacket.h index 9ac5ef2f8..09167f8c1 100644 --- a/Minecraft.World/DebugOptionsPacket.h +++ b/Minecraft.World/DebugOptionsPacket.h @@ -21,6 +21,6 @@ class DebugOptionsPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new DebugOptionsPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 152; } }; diff --git a/Minecraft.World/DefaultDispenseItemBehavior.cpp b/Minecraft.World/DefaultDispenseItemBehavior.cpp index 8fd13282d..8563ef56e 100644 --- a/Minecraft.World/DefaultDispenseItemBehavior.cpp +++ b/Minecraft.World/DefaultDispenseItemBehavior.cpp @@ -38,7 +38,7 @@ void DefaultDispenseItemBehavior::spawnItem(Level *world, shared_ptrgetY(); double spawnZ = position->getZ(); - shared_ptr itemEntity = shared_ptr(new ItemEntity(world, spawnX, spawnY - 0.3, spawnZ, item)); + shared_ptr itemEntity = std::make_shared(world, spawnX, spawnY - 0.3, spawnZ, item); double pow = world->random->nextDouble() * 0.1 + 0.2; itemEntity->xd = facing->getStepX() * pow; diff --git a/Minecraft.World/DirectoryLevelStorageSource.cpp b/Minecraft.World/DirectoryLevelStorageSource.cpp index 232d4d443..9176b0d59 100644 --- a/Minecraft.World/DirectoryLevelStorageSource.cpp +++ b/Minecraft.World/DirectoryLevelStorageSource.cpp @@ -121,7 +121,7 @@ void DirectoryLevelStorageSource::deleteRecursive(vector *files) shared_ptr DirectoryLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir) { - return shared_ptr (new DirectoryLevelStorage(saveFile, baseDir, levelId, createPlayerDir)); + return std::make_shared(saveFile, baseDir, levelId, createPlayerDir); } bool DirectoryLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId) diff --git a/Minecraft.World/DisconnectPacket.h b/Minecraft.World/DisconnectPacket.h index 349837549..3c96a429b 100644 --- a/Minecraft.World/DisconnectPacket.h +++ b/Minecraft.World/DisconnectPacket.h @@ -66,7 +66,7 @@ class DisconnectPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new DisconnectPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 255; } }; diff --git a/Minecraft.World/DispenserTile.cpp b/Minecraft.World/DispenserTile.cpp index abbb67d41..5098fe308 100644 --- a/Minecraft.World/DispenserTile.cpp +++ b/Minecraft.World/DispenserTile.cpp @@ -168,7 +168,7 @@ void DispenserTile::tick(Level *level, int x, int y, int z, Random *random) shared_ptr DispenserTile::newTileEntity(Level *level) { - return shared_ptr( new DispenserTileEntity() ); + return std::make_shared(); } void DispenserTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr by, shared_ptr itemInstance) @@ -203,9 +203,9 @@ void DispenserTile::onRemove(Level *level, int x, int y, int z, int id, int data if (count > item->count) count = item->count; item->count -= count; - shared_ptr newItem = shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()) ); + shared_ptr newItem = std::make_shared(item->id, count, item->getAuxValue()); newItem->set4JData( item->get4JData() ); - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, newItem); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; diff --git a/Minecraft.World/DispenserTileEntity.cpp b/Minecraft.World/DispenserTileEntity.cpp index 9129ea5cd..b1d8ecdeb 100644 --- a/Minecraft.World/DispenserTileEntity.cpp +++ b/Minecraft.World/DispenserTileEntity.cpp @@ -231,7 +231,7 @@ bool DispenserTileEntity::canPlaceItem(int slot, shared_ptr item) // 4J Added shared_ptr DispenserTileEntity::clone() { - shared_ptr result = shared_ptr( new DispenserTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); for (unsigned int i = 0; i < items.length; i++) diff --git a/Minecraft.World/DropperTile.cpp b/Minecraft.World/DropperTile.cpp index 098b6338a..180aec2ac 100644 --- a/Minecraft.World/DropperTile.cpp +++ b/Minecraft.World/DropperTile.cpp @@ -27,7 +27,7 @@ DispenseItemBehavior *DropperTile::getDispenseMethod(shared_ptr it shared_ptr DropperTile::newTileEntity(Level *level) { - return shared_ptr( new DropperTileEntity() ); + return std::make_shared(); } void DropperTile::dispenseFrom(Level *level, int x, int y, int z) diff --git a/Minecraft.World/DropperTileEntity.cpp b/Minecraft.World/DropperTileEntity.cpp index 51bf6abf7..ad2a0e83f 100644 --- a/Minecraft.World/DropperTileEntity.cpp +++ b/Minecraft.World/DropperTileEntity.cpp @@ -10,7 +10,7 @@ wstring DropperTileEntity::getName() // 4J Added shared_ptr DropperTileEntity::clone() { - shared_ptr result = shared_ptr( new DropperTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->name = name; diff --git a/Minecraft.World/EggItem.cpp b/Minecraft.World/EggItem.cpp index 0655a2fa3..3f3d123ea 100644 --- a/Minecraft.World/EggItem.cpp +++ b/Minecraft.World/EggItem.cpp @@ -26,6 +26,6 @@ shared_ptr EggItem::use(shared_ptr instance, Level * instance->count--; } level->playEntitySound( player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - if (!level->isClientSide) level->addEntity( shared_ptr(new ThrownEgg(level, player)) ); + if (!level->isClientSide) level->addEntity(std::make_shared(level, player)); return instance; } diff --git a/Minecraft.World/EggTile.cpp b/Minecraft.World/EggTile.cpp index 3a11c0d1e..7052fac9b 100644 --- a/Minecraft.World/EggTile.cpp +++ b/Minecraft.World/EggTile.cpp @@ -40,7 +40,7 @@ void EggTile::checkSlide(Level *level, int x, int y, int z) } else { - shared_ptr e = shared_ptr(new FallingTile(level, x + 0.5f, y + 0.5f, z + 0.5f, id)); + shared_ptr e = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, id); level->addEntity(e); } } diff --git a/Minecraft.World/EmptyMapItem.cpp b/Minecraft.World/EmptyMapItem.cpp index 42adc3048..9c46938a3 100644 --- a/Minecraft.World/EmptyMapItem.cpp +++ b/Minecraft.World/EmptyMapItem.cpp @@ -23,7 +23,7 @@ shared_ptr EmptyMapItem::use(shared_ptr itemInstance //data.setDirty(); - shared_ptr map = shared_ptr( new ItemInstance(Item::map, 1, -1) ); + shared_ptr map = std::make_shared(Item::map, 1, -1); Item::map->onCraftedBy(map, level, player); itemInstance->count--; diff --git a/Minecraft.World/EnchantItemCommand.cpp b/Minecraft.World/EnchantItemCommand.cpp index dec0bf8e4..c84117094 100644 --- a/Minecraft.World/EnchantItemCommand.cpp +++ b/Minecraft.World/EnchantItemCommand.cpp @@ -81,5 +81,5 @@ shared_ptr EnchantItemCommand::preparePacket(shared_ptr( new GameCommandPacket(eGameCommand_EnchantItem, baos.toByteArray() )); + return std::make_shared(eGameCommand_EnchantItem, baos.toByteArray()); } \ No newline at end of file diff --git a/Minecraft.World/EnchantedBookItem.cpp b/Minecraft.World/EnchantedBookItem.cpp index 65153c00b..70b15be46 100644 --- a/Minecraft.World/EnchantedBookItem.cpp +++ b/Minecraft.World/EnchantedBookItem.cpp @@ -102,7 +102,7 @@ void EnchantedBookItem::addEnchantment(shared_ptr item, Enchantmen shared_ptr EnchantedBookItem::createForEnchantment(EnchantmentInstance *enchant) { - shared_ptr item = shared_ptr(new ItemInstance(this)); + shared_ptr item = std::make_shared(this); addEnchantment(item, enchant); return item; } @@ -118,7 +118,7 @@ void EnchantedBookItem::createForEnchantment(Enchantment *enchant, vector EnchantedBookItem::createForRandomLoot(Random *random) { Enchantment *enchantment = Enchantment::validEnchantments[random->nextInt(Enchantment::validEnchantments.size())]; - shared_ptr book = shared_ptr(new ItemInstance(id, 1, 0)); + shared_ptr book = std::make_shared(id, 1, 0); int level = Mth::nextInt(random, enchantment->getMinLevel(), enchantment->getMaxLevel()); addEnchantment(book, new EnchantmentInstance(enchantment, level)); @@ -134,7 +134,7 @@ WeighedTreasure *EnchantedBookItem::createForRandomTreasure(Random *random) WeighedTreasure *EnchantedBookItem::createForRandomTreasure(Random *random, int minCount, int maxCount, int weight) { Enchantment *enchantment = Enchantment::validEnchantments[random->nextInt(Enchantment::validEnchantments.size())]; - shared_ptr book = shared_ptr(new ItemInstance(id, 1, 0)); + shared_ptr book = std::make_shared(id, 1, 0); int level = Mth::nextInt(random, enchantment->getMinLevel(), enchantment->getMaxLevel()); addEnchantment(book, new EnchantmentInstance(enchantment, level)); diff --git a/Minecraft.World/EnchantmentMenu.cpp b/Minecraft.World/EnchantmentMenu.cpp index 08c51c3d0..86c88e88a 100644 --- a/Minecraft.World/EnchantmentMenu.cpp +++ b/Minecraft.World/EnchantmentMenu.cpp @@ -9,7 +9,7 @@ EnchantmentMenu::EnchantmentMenu(shared_ptr inventory, Level *level, int xt, int yt, int zt) { - enchantSlots = shared_ptr( new EnchantmentContainer(this) ); + enchantSlots = std::make_shared(this); for(int i = 0; i < 3; ++i) { diff --git a/Minecraft.World/EnchantmentTableEntity.cpp b/Minecraft.World/EnchantmentTableEntity.cpp index 3e5924d22..dd9b6ad2a 100644 --- a/Minecraft.World/EnchantmentTableEntity.cpp +++ b/Minecraft.World/EnchantmentTableEntity.cpp @@ -124,7 +124,7 @@ void EnchantmentTableEntity::setCustomName(const wstring &name) shared_ptr EnchantmentTableEntity::clone() { - shared_ptr result = shared_ptr( new EnchantmentTableEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->time = time; diff --git a/Minecraft.World/EnchantmentTableTile.cpp b/Minecraft.World/EnchantmentTableTile.cpp index 8e777ea11..a5c518496 100644 --- a/Minecraft.World/EnchantmentTableTile.cpp +++ b/Minecraft.World/EnchantmentTableTile.cpp @@ -69,7 +69,7 @@ Icon *EnchantmentTableTile::getTexture(int face, int data) shared_ptr EnchantmentTableTile::newTileEntity(Level *level) { - return shared_ptr(new EnchantmentTableEntity()); + return std::make_shared(); } bool EnchantmentTableTile::use(Level *level, int x, int y, int z, shared_ptr player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param diff --git a/Minecraft.World/EnderChestTile.cpp b/Minecraft.World/EnderChestTile.cpp index 464c04823..f1b4738fb 100644 --- a/Minecraft.World/EnderChestTile.cpp +++ b/Minecraft.World/EnderChestTile.cpp @@ -82,7 +82,7 @@ bool EnderChestTile::use(Level *level, int x, int y, int z, shared_ptr p shared_ptr EnderChestTile::newTileEntity(Level *level) { - return shared_ptr(new EnderChestTileEntity()); + return std::make_shared(); } void EnderChestTile::animateTick(Level *level, int xt, int yt, int zt, Random *random) diff --git a/Minecraft.World/EnderChestTileEntity.cpp b/Minecraft.World/EnderChestTileEntity.cpp index 8169c0292..1ad682ae9 100644 --- a/Minecraft.World/EnderChestTileEntity.cpp +++ b/Minecraft.World/EnderChestTileEntity.cpp @@ -94,7 +94,7 @@ bool EnderChestTileEntity::stillValid(shared_ptr player) // 4J Added shared_ptr EnderChestTileEntity::clone() { - shared_ptr result = shared_ptr( new EnderChestTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); return result; diff --git a/Minecraft.World/EnderDragon.cpp b/Minecraft.World/EnderDragon.cpp index 9a97b765a..f8e4871f5 100644 --- a/Minecraft.World/EnderDragon.cpp +++ b/Minecraft.World/EnderDragon.cpp @@ -100,14 +100,14 @@ EnderDragon::EnderDragon(Level *level) : Mob(level) // 4J - split off from ctor so we can use shared_from_this() void EnderDragon::AddParts() { - head = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"head", 6, 6) ); - neck = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"neck", 6, 6) ); // 4J Added - body = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"body", 8, 8) ); - tail1 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4) ); - tail2 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4) ); - tail3 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4) ); - wing1 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"wing", 4, 4) ); - wing2 = shared_ptr( new MultiEntityMobPart(dynamic_pointer_cast(shared_from_this()), L"wing", 4, 4) ); + head = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"head", 6, 6); + neck = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"neck", 6, 6); // 4J Added + body = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"body", 8, 8); + tail1 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4); + tail2 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4); + tail3 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"tail", 4, 4); + wing1 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"wing", 4, 4); + wing2 = std::make_shared(dynamic_pointer_cast(shared_from_this()), L"wing", 4, 4); subEntities.push_back(head); subEntities.push_back(neck); // 4J Added @@ -739,7 +739,7 @@ void EnderDragon::aiStep() double zdd = attackTarget->z - startingZ; level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); - shared_ptr ie = shared_ptr( new DragonFireball(level, dynamic_pointer_cast( shared_from_this() ), xdd, ydd, zdd) ); + shared_ptr ie = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), xdd, ydd, zdd); ie->x = startingX; ie->y = startingY; ie->z = startingZ; @@ -1214,7 +1214,7 @@ void EnderDragon::tickDeath() { int newCount = ExperienceOrb::getExperienceValue(xpCount); xpCount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x, y, z, newCount) )); + level->addEntity(std::make_shared(level, x, y, z, newCount)); } } if (dragonDeathTime == 1) @@ -1234,7 +1234,7 @@ void EnderDragon::tickDeath() { int newCount = ExperienceOrb::getExperienceValue(xpCount); xpCount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x, y, z, newCount))); + level->addEntity(std::make_shared(level, x, y, z, newCount)); } int xo = 5 + random->nextInt(2) * 2 - 1; int zo = 5 + random->nextInt(2) * 2 - 1; diff --git a/Minecraft.World/EnderEyeItem.cpp b/Minecraft.World/EnderEyeItem.cpp index 80e5fe984..25b16d05d 100644 --- a/Minecraft.World/EnderEyeItem.cpp +++ b/Minecraft.World/EnderEyeItem.cpp @@ -207,7 +207,7 @@ shared_ptr EnderEyeItem::use(shared_ptr instance, Le { if((level->dimension->id==LevelData::DIMENSION_OVERWORLD) && level->getLevelData()->getHasStronghold()) { - shared_ptr eyeOfEnderSignal = shared_ptr( new EyeOfEnderSignal(level, player->x, player->y + 1.62 - player->heightOffset, player->z) ); + shared_ptr eyeOfEnderSignal = std::make_shared(level, player->x, player->y + 1.62 - player->heightOffset, player->z); eyeOfEnderSignal->signalTo(level->getLevelData()->getXStronghold()<<4, player->y + 1.62 - player->heightOffset, level->getLevelData()->getZStronghold()<<4); level->addEntity(eyeOfEnderSignal); diff --git a/Minecraft.World/EnderpearlItem.cpp b/Minecraft.World/EnderpearlItem.cpp index 4bf641f71..c024190b2 100644 --- a/Minecraft.World/EnderpearlItem.cpp +++ b/Minecraft.World/EnderpearlItem.cpp @@ -28,7 +28,7 @@ shared_ptr EnderpearlItem::use(shared_ptr instance, level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); if (!level->isClientSide) { - level->addEntity( shared_ptr( new ThrownEnderpearl(level, player) ) ); + level->addEntity(std::make_shared(level, player)); } return instance; } \ No newline at end of file diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index acb439b20..d754330b5 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -312,7 +312,7 @@ void Entity::_init(bool useSmallId, Level *level) // values that need to be sent to clients in SMP if( useSmallId ) { - entityData = shared_ptr(new SynchedEntityData()); + entityData = std::make_shared(); } else { @@ -1511,7 +1511,7 @@ shared_ptr Entity::spawnAtLocation(int resource, int count) shared_ptr Entity::spawnAtLocation(int resource, int count, float yOffs) { - return spawnAtLocation(shared_ptr( new ItemInstance(resource, count, 0) ), yOffs); + return spawnAtLocation(std::make_shared(resource, count, 0), yOffs); } shared_ptr Entity::spawnAtLocation(shared_ptr itemInstance, float yOffs) @@ -1520,7 +1520,7 @@ shared_ptr Entity::spawnAtLocation(shared_ptr itemInst { return nullptr; } - shared_ptr ie = shared_ptr( new ItemEntity(level, x, y + yOffs, z, itemInstance) ); + shared_ptr ie = std::make_shared(level, x, y + yOffs, z, itemInstance); ie->throwTime = 10; level->addEntity(ie); return ie; diff --git a/Minecraft.World/EntityActionAtPositionPacket.h b/Minecraft.World/EntityActionAtPositionPacket.h index 352020178..788c764b1 100644 --- a/Minecraft.World/EntityActionAtPositionPacket.h +++ b/Minecraft.World/EntityActionAtPositionPacket.h @@ -18,6 +18,6 @@ class EntityActionAtPositionPacket : public Packet, public enable_shared_from_th virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new EntityActionAtPositionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 17; } }; \ No newline at end of file diff --git a/Minecraft.World/EntityDamageSource.cpp b/Minecraft.World/EntityDamageSource.cpp index 8ff9e328a..8639156d9 100644 --- a/Minecraft.World/EntityDamageSource.cpp +++ b/Minecraft.World/EntityDamageSource.cpp @@ -41,11 +41,11 @@ shared_ptr EntityDamageSource::getDeathMessagePacket(shared_ptrhasCustomHoverName()) { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId, entity->GetType(), additional, held->getHoverName() ) ); + return std::make_shared(player->getNetworkName(), m_msgWithItemId, entity->GetType(), additional, held->getHoverName()); } else { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgId, entity->GetType(), additional ) ); + return std::make_shared(player->getNetworkName(), m_msgId, entity->GetType(), additional); } } diff --git a/Minecraft.World/EntityEventPacket.h b/Minecraft.World/EntityEventPacket.h index a151dbdb4..2b32dc29a 100644 --- a/Minecraft.World/EntityEventPacket.h +++ b/Minecraft.World/EntityEventPacket.h @@ -18,7 +18,7 @@ class EntityEventPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new EntityEventPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 38; } }; diff --git a/Minecraft.World/EntityHorse.cpp b/Minecraft.World/EntityHorse.cpp index 03a70f92b..32c9eb2de 100644 --- a/Minecraft.World/EntityHorse.cpp +++ b/Minecraft.World/EntityHorse.cpp @@ -456,7 +456,7 @@ int EntityHorse::getInventorySize() void EntityHorse::createInventory() { shared_ptr old = inventory; - inventory = shared_ptr( new AnimalChest(L"HorseChest", getInventorySize()) ); + inventory = std::make_shared(L"HorseChest", getInventorySize()); inventory->setCustomName(getAName()); if (old != nullptr) { @@ -1539,7 +1539,7 @@ void EntityHorse::readAdditionalSaveData(CompoundTag *tag) } else if (tag->getBoolean(L"Saddle")) { - inventory->setItem(INV_SLOT_SADDLE, shared_ptr( new ItemInstance(Item::saddle))); + inventory->setItem(INV_SLOT_SADDLE, std::make_shared(Item::saddle)); } updateEquipment(); } @@ -1566,7 +1566,7 @@ bool EntityHorse::canMate(shared_ptr partner) shared_ptr EntityHorse::getBreedOffspring(shared_ptr partner) { shared_ptr horsePartner = dynamic_pointer_cast(partner); - shared_ptr baby = shared_ptr( new EntityHorse(level) ); + shared_ptr baby = std::make_shared(level); int type = getType(); int partnerType = horsePartner->getType(); diff --git a/Minecraft.World/ExperienceItem.cpp b/Minecraft.World/ExperienceItem.cpp index 433c12070..a28a5859e 100644 --- a/Minecraft.World/ExperienceItem.cpp +++ b/Minecraft.World/ExperienceItem.cpp @@ -27,6 +27,6 @@ shared_ptr ExperienceItem::use(shared_ptr itemInstan itemInstance->count--; } level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - if (!level->isClientSide) level->addEntity( shared_ptr( new ThrownExpBottle(level, player) )); + if (!level->isClientSide) level->addEntity(std::make_shared(level, player)); return itemInstance; } \ No newline at end of file diff --git a/Minecraft.World/ExplodePacket.h b/Minecraft.World/ExplodePacket.h index d4d8b3f91..caf77c77a 100644 --- a/Minecraft.World/ExplodePacket.h +++ b/Minecraft.World/ExplodePacket.h @@ -32,6 +32,6 @@ class ExplodePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new ExplodePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 60; } }; \ No newline at end of file diff --git a/Minecraft.World/EyeOfEnderSignal.cpp b/Minecraft.World/EyeOfEnderSignal.cpp index ad2d48fc8..ca76b272d 100644 --- a/Minecraft.World/EyeOfEnderSignal.cpp +++ b/Minecraft.World/EyeOfEnderSignal.cpp @@ -163,7 +163,7 @@ void EyeOfEnderSignal::tick() remove(); if (surviveAfterDeath) { - level->addEntity(shared_ptr( new ItemEntity(level, x, y, z, shared_ptr(new ItemInstance(Item::eyeOfEnder))))); + level->addEntity(std::make_shared(level, x, y, z, shared_ptr(new ItemInstance(Item::eyeOfEnder)))); } else { diff --git a/Minecraft.World/FallingTile.cpp b/Minecraft.World/FallingTile.cpp index cd951681d..0ff776fde 100644 --- a/Minecraft.World/FallingTile.cpp +++ b/Minecraft.World/FallingTile.cpp @@ -161,13 +161,13 @@ void FallingTile::tick() } else { - if(dropItem && !cancelDrop) spawnAtLocation( shared_ptr(new ItemInstance(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data))), 0); + if(dropItem && !cancelDrop) spawnAtLocation(std::make_shared(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data)), 0); } } } else if ( (time > 20 * 5 && !level->isClientSide && (yt < 1 || yt > Level::maxBuildHeight)) || (time > 20 * 30)) { - if(dropItem) spawnAtLocation( shared_ptr( new ItemInstance(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data) )), 0); + if(dropItem) spawnAtLocation(std::make_shared(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data)), 0); remove(); } } diff --git a/Minecraft.World/FireworksItem.cpp b/Minecraft.World/FireworksItem.cpp index c872bc407..155a49617 100644 --- a/Minecraft.World/FireworksItem.cpp +++ b/Minecraft.World/FireworksItem.cpp @@ -26,7 +26,7 @@ bool FireworksItem::useOn(shared_ptr instance, shared_ptr if (!level->isClientSide) { - shared_ptr f = shared_ptr( new FireworksRocketEntity(level, x + clickX, y + clickY, z + clickZ, instance) ); + shared_ptr f(new FireworksRocketEntity(level, x + clickX, y + clickY, z + clickZ, instance)); level->addEntity(f); if (!player->abilities.instabuild) diff --git a/Minecraft.World/FireworksMenu.cpp b/Minecraft.World/FireworksMenu.cpp index 92474e2de..cd9196aff 100644 --- a/Minecraft.World/FireworksMenu.cpp +++ b/Minecraft.World/FireworksMenu.cpp @@ -15,8 +15,8 @@ FireworksMenu::FireworksMenu(shared_ptr inventory, Level *level, int m_canMakeCharge = false; m_canMakeFade = false; - craftSlots = shared_ptr( new CraftingContainer(this, 3, 3) ); - resultSlots = shared_ptr( new ResultContainer() ); + craftSlots = std::make_shared(this, 3, 3); + resultSlots = std::make_shared(); this->level = level; x = xt; diff --git a/Minecraft.World/FireworksRecipe.cpp b/Minecraft.World/FireworksRecipe.cpp index 6c6d3d259..feb1cf573 100644 --- a/Minecraft.World/FireworksRecipe.cpp +++ b/Minecraft.World/FireworksRecipe.cpp @@ -124,7 +124,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l // create fireworks if (sulphurCount >= 1 && paperCount == 1 && chargeComponents == 0) { - resultItem = shared_ptr( new ItemInstance(Item::fireworks) ); + resultItem = std::make_shared(Item::fireworks); if (chargeCount > 0) { CompoundTag *itemTag = new CompoundTag(); @@ -155,7 +155,7 @@ bool FireworksRecipe::matches(shared_ptr craftSlots, Level *l if (sulphurCount == 1 && paperCount == 0 && chargeCount == 0 && colorCount > 0 && typeComponents <= 1) { - resultItem = shared_ptr( new ItemInstance(Item::fireworksCharge) ); + resultItem = std::make_shared(Item::fireworksCharge); CompoundTag *itemTag = new CompoundTag(); CompoundTag *expTag = new CompoundTag(FireworksItem::TAG_EXPLOSION); diff --git a/Minecraft.World/FishingHook.cpp b/Minecraft.World/FishingHook.cpp index e567e87b9..ba0876d92 100644 --- a/Minecraft.World/FishingHook.cpp +++ b/Minecraft.World/FishingHook.cpp @@ -420,7 +420,7 @@ int FishingHook::retrieve() } else if (nibble > 0) { - shared_ptr ie = shared_ptr( new ItemEntity(this->Entity::level, x, y, z, shared_ptr( new ItemInstance(Item::fish_raw) ) ) ); + shared_ptr ie = std::make_shared(this->Entity::level, x, y, z, shared_ptr(new ItemInstance(Item::fish_raw))); double xa = owner->x - x; double ya = owner->y - y; double za = owner->z - z; @@ -431,7 +431,7 @@ int FishingHook::retrieve() ie->Entity::yd = ya * speed + sqrt(dist) * 0.08; ie->Entity::zd = za * speed; level->addEntity(ie); - owner->level->addEntity( shared_ptr( new ExperienceOrb(owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f, random->nextInt(6) + 1) ) ); // 4J Stu brought forward from 1.4 + owner->level->addEntity(std::make_shared(owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f, random->nextInt(6) + 1)); // 4J Stu brought forward from 1.4 dmg = 1; } if (inGround) dmg = 2; diff --git a/Minecraft.World/FishingRodItem.cpp b/Minecraft.World/FishingRodItem.cpp index 70becf39e..b9eafd184 100644 --- a/Minecraft.World/FishingRodItem.cpp +++ b/Minecraft.World/FishingRodItem.cpp @@ -44,7 +44,7 @@ shared_ptr FishingRodItem::use(shared_ptr instance, if (!level->isClientSide) { // 4J Stu - Move the player->fishing out of the ctor as we cannot reference 'this' - shared_ptr hook = shared_ptr( new FishingHook(level, player) ); + shared_ptr hook = std::make_shared(level, player); player->fishing = hook; level->addEntity( shared_ptr( hook ) ); } diff --git a/Minecraft.World/FlowerPotTile.cpp b/Minecraft.World/FlowerPotTile.cpp index 57aa8b6d3..80fdf2e45 100644 --- a/Minecraft.World/FlowerPotTile.cpp +++ b/Minecraft.World/FlowerPotTile.cpp @@ -127,27 +127,27 @@ shared_ptr FlowerPotTile::getItemFromType(int type) switch (type) { case TYPE_FLOWER_RED: - return shared_ptr( new ItemInstance(Tile::rose) ); + return std::make_shared(Tile::rose); case TYPE_FLOWER_YELLOW: - return shared_ptr( new ItemInstance(Tile::flower) ); + return std::make_shared(Tile::flower); case TYPE_CACTUS: - return shared_ptr( new ItemInstance(Tile::cactus) ); + return std::make_shared(Tile::cactus); case TYPE_MUSHROOM_BROWN: - return shared_ptr( new ItemInstance(Tile::mushroom_brown) ); + return std::make_shared(Tile::mushroom_brown); case TYPE_MUSHROOM_RED: - return shared_ptr( new ItemInstance(Tile::mushroom_red) ); + return std::make_shared(Tile::mushroom_red); case TYPE_DEAD_BUSH: - return shared_ptr( new ItemInstance(Tile::deadBush) ); + return std::make_shared(Tile::deadBush); case TYPE_SAPLING_DEFAULT: - return shared_ptr( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_DEFAULT) ); + return std::make_shared(Tile::sapling, 1, Sapling::TYPE_DEFAULT); case TYPE_SAPLING_BIRCH: - return shared_ptr( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_BIRCH) ); + return std::make_shared(Tile::sapling, 1, Sapling::TYPE_BIRCH); case TYPE_SAPLING_EVERGREEN: - return shared_ptr( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_EVERGREEN) ); + return std::make_shared(Tile::sapling, 1, Sapling::TYPE_EVERGREEN); case TYPE_SAPLING_JUNGLE: - return shared_ptr( new ItemInstance(Tile::sapling, 1, Sapling::TYPE_JUNGLE) ); + return std::make_shared(Tile::sapling, 1, Sapling::TYPE_JUNGLE); case TYPE_FERN: - return shared_ptr( new ItemInstance(Tile::tallgrass, 1, TallGrass::FERN) ); + return std::make_shared(Tile::tallgrass, 1, TallGrass::FERN); } return nullptr; diff --git a/Minecraft.World/FurnaceResultSlot.cpp b/Minecraft.World/FurnaceResultSlot.cpp index 8ea4b19f7..48f2f8fbf 100644 --- a/Minecraft.World/FurnaceResultSlot.cpp +++ b/Minecraft.World/FurnaceResultSlot.cpp @@ -73,7 +73,7 @@ void FurnaceResultSlot::checkTakeAchievements(shared_ptr carried) { int newCount = ExperienceOrb::getExperienceValue(amount); amount -= newCount; - player->level->addEntity(shared_ptr( new ExperienceOrb(player->level, player->x, player->y + .5, player->z + .5, newCount) )); + player->level->addEntity(std::make_shared(player->level, player->x, player->y + .5, player->z + .5, newCount)); } } diff --git a/Minecraft.World/FurnaceTile.cpp b/Minecraft.World/FurnaceTile.cpp index 2d8fc9914..d8856f4e3 100644 --- a/Minecraft.World/FurnaceTile.cpp +++ b/Minecraft.World/FurnaceTile.cpp @@ -141,7 +141,7 @@ void FurnaceTile::setLit(bool lit, Level *level, int x, int y, int z) shared_ptr FurnaceTile::newTileEntity(Level *level) { - return shared_ptr( new FurnaceTileEntity() ); + return std::make_shared(); } void FurnaceTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr by, shared_ptr itemInstance) @@ -192,9 +192,9 @@ void FurnaceTile::onRemove(Level *level, int x, int y, int z, int id, int data) } #endif - shared_ptr newItem = shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()) ); + shared_ptr newItem = std::make_shared(item->id, count, item->getAuxValue()); newItem->set4JData( item->get4JData() ); - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, newItem) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, newItem); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; diff --git a/Minecraft.World/FurnaceTileEntity.cpp b/Minecraft.World/FurnaceTileEntity.cpp index 461670db2..901235c03 100644 --- a/Minecraft.World/FurnaceTileEntity.cpp +++ b/Minecraft.World/FurnaceTileEntity.cpp @@ -215,7 +215,7 @@ void FurnaceTileEntity::tick() if (items[SLOT_FUEL]->count == 0) { Item *remaining = items[SLOT_FUEL]->getItem()->getCraftingRemainingItem(); - items[SLOT_FUEL] = remaining != nullptr ? shared_ptr(new ItemInstance(remaining)) : nullptr; + items[SLOT_FUEL] = remaining != nullptr ? std::make_shared(remaining) : nullptr; } } } @@ -396,7 +396,7 @@ bool FurnaceTileEntity::canTakeItemThroughFace(int slot, shared_ptr FurnaceTileEntity::clone() { - shared_ptr result = shared_ptr( new FurnaceTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->litTime = litTime; diff --git a/Minecraft.World/FuzzyZoomLayer.cpp b/Minecraft.World/FuzzyZoomLayer.cpp index 65c6709e9..0da4a992f 100644 --- a/Minecraft.World/FuzzyZoomLayer.cpp +++ b/Minecraft.World/FuzzyZoomLayer.cpp @@ -66,7 +66,7 @@ shared_ptrFuzzyZoomLayer::zoom(__int64 seed, shared_ptrsup, int co shared_ptr result = sup; for (int i = 0; i < count; i++) { - result = shared_ptr(new FuzzyZoomLayer(seed + i, result)); + result = std::make_shared(seed + i, result); } return result; } \ No newline at end of file diff --git a/Minecraft.World/GameCommandPacket.h b/Minecraft.World/GameCommandPacket.h index 1f63e9503..d4827974c 100644 --- a/Minecraft.World/GameCommandPacket.h +++ b/Minecraft.World/GameCommandPacket.h @@ -21,6 +21,6 @@ class GameCommandPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new GameCommandPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 167; } }; \ No newline at end of file diff --git a/Minecraft.World/GameEventPacket.h b/Minecraft.World/GameEventPacket.h index 93ea911c0..c1134e7ff 100644 --- a/Minecraft.World/GameEventPacket.h +++ b/Minecraft.World/GameEventPacket.h @@ -40,6 +40,6 @@ class GameEventPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new GameEventPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 70; } }; \ No newline at end of file diff --git a/Minecraft.World/GetInfoPacket.h b/Minecraft.World/GetInfoPacket.h index 90688f3e0..a7c758ba6 100644 --- a/Minecraft.World/GetInfoPacket.h +++ b/Minecraft.World/GetInfoPacket.h @@ -11,6 +11,6 @@ class GetInfoPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new GetInfoPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 254; } }; \ No newline at end of file diff --git a/Minecraft.World/Ghast.cpp b/Minecraft.World/Ghast.cpp index b016320f3..738a42da2 100644 --- a/Minecraft.World/Ghast.cpp +++ b/Minecraft.World/Ghast.cpp @@ -151,7 +151,7 @@ void Ghast::serverAiStep() { // 4J - change brought forward from 1.2.3 level->levelEvent(nullptr, LevelEvent::SOUND_GHAST_FIREBALL, static_cast(x), static_cast(y), static_cast(z), 0); - shared_ptr ie = shared_ptr( new LargeFireball(level, dynamic_pointer_cast( shared_from_this() ), xdd, ydd, zdd) ); + shared_ptr ie = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), xdd, ydd, zdd); ie->explosionPower = explosionPower; double d = 4; Vec3 *v = getViewVector(1); diff --git a/Minecraft.World/GiveItemCommand.cpp b/Minecraft.World/GiveItemCommand.cpp index e51332666..fa06d80d1 100644 --- a/Minecraft.World/GiveItemCommand.cpp +++ b/Minecraft.World/GiveItemCommand.cpp @@ -32,7 +32,7 @@ void GiveItemCommand::execute(shared_ptr source, byteArray comman shared_ptr player = getPlayer(uid); if(player != nullptr && item > 0 && Item::items[item] != nullptr) { - shared_ptr itemInstance = shared_ptr(new ItemInstance(item, amount, aux)); + shared_ptr itemInstance = std::make_shared(item, amount, aux); shared_ptr drop = player->drop(itemInstance); drop->throwTime = 0; //logAdminAction(source, L"commands.give.success", ChatPacket::e_ChatCustom, Item::items[item]->getName(itemInstance), item, amount, player->getAName()); @@ -53,5 +53,5 @@ shared_ptr GiveItemCommand::preparePacket(shared_ptr dos.writeInt(aux); dos.writeUTF(tag); - return shared_ptr( new GameCommandPacket(eGameCommand_Give, baos.toByteArray() )); + return std::make_shared(eGameCommand_Give, baos.toByteArray()); } \ No newline at end of file diff --git a/Minecraft.World/HangingEntityItem.cpp b/Minecraft.World/HangingEntityItem.cpp index 75e9dcff5..97ddb31d8 100644 --- a/Minecraft.World/HangingEntityItem.cpp +++ b/Minecraft.World/HangingEntityItem.cpp @@ -66,7 +66,7 @@ shared_ptr HangingEntityItem::createEntity(Level *level, int x, i { if (eType == eTYPE_PAINTING) { - shared_ptr painting = shared_ptr(new Painting(level, x, y, z, dir)); + shared_ptr painting = std::make_shared(level, x, y, z, dir); #ifndef _CONTENT_PACKAGE if (app.DebugArtToolsOn() && auxValue > 0) @@ -83,7 +83,7 @@ shared_ptr HangingEntityItem::createEntity(Level *level, int x, i } else if (eType == eTYPE_ITEM_FRAME) { - shared_ptr itemFrame = shared_ptr(new ItemFrame(level, x, y, z, dir)); + shared_ptr itemFrame = std::make_shared(level, x, y, z, dir); return dynamic_pointer_cast (itemFrame); } diff --git a/Minecraft.World/HeavyTile.cpp b/Minecraft.World/HeavyTile.cpp index 6c2b96e64..d4e657967 100644 --- a/Minecraft.World/HeavyTile.cpp +++ b/Minecraft.World/HeavyTile.cpp @@ -60,7 +60,7 @@ void HeavyTile::checkSlide(Level *level, int x, int y, int z) return; } - shared_ptr e = shared_ptr( new FallingTile(level, x + 0.5f, y + 0.5f, z + 0.5f, id, level->getData(x, y, z)) ); + shared_ptr e = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, id, level->getData(x, y, z)); falling(e); level->addEntity(e); } diff --git a/Minecraft.World/HopperTile.cpp b/Minecraft.World/HopperTile.cpp index dadda9b0f..0371712a8 100644 --- a/Minecraft.World/HopperTile.cpp +++ b/Minecraft.World/HopperTile.cpp @@ -47,7 +47,7 @@ int HopperTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int shared_ptr HopperTile::newTileEntity(Level *level) { - return shared_ptr( new HopperTileEntity() ); + return std::make_shared(); } void HopperTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr by, shared_ptr itemInstance) @@ -116,7 +116,7 @@ void HopperTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue())))); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); if (item->hasTag()) { diff --git a/Minecraft.World/HopperTileEntity.cpp b/Minecraft.World/HopperTileEntity.cpp index 3e0cbe86d..e44232dcc 100644 --- a/Minecraft.World/HopperTileEntity.cpp +++ b/Minecraft.World/HopperTileEntity.cpp @@ -489,7 +489,7 @@ bool HopperTileEntity::isOnCooldown() // 4J Added shared_ptr HopperTileEntity::clone() { - shared_ptr result = shared_ptr( new HopperTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->name = name; diff --git a/Minecraft.World/HouseFeature.cpp b/Minecraft.World/HouseFeature.cpp index 40b4e770c..b6bba5a5e 100644 --- a/Minecraft.World/HouseFeature.cpp +++ b/Minecraft.World/HouseFeature.cpp @@ -185,7 +185,7 @@ bool HouseFeature::place(Level *level, Random *random, int x, int y, int z) } } - shared_ptr(pz) = shared_ptr(new PigZombie(level)); + shared_ptr(pz) = std::make_shared(level); pz->moveTo(x0 + w / 2.0 + 0.5, y0 + 0.5, z0 + d / 2.0 + 0.5, 0, 0); level->addEntity(pz); diff --git a/Minecraft.World/IndirectEntityDamageSource.cpp b/Minecraft.World/IndirectEntityDamageSource.cpp index 90c80f6bd..a24ad1a7f 100644 --- a/Minecraft.World/IndirectEntityDamageSource.cpp +++ b/Minecraft.World/IndirectEntityDamageSource.cpp @@ -47,11 +47,11 @@ shared_ptr IndirectEntityDamageSource::getDeathMessagePacket(shared_ } if(held != nullptr && held->hasCustomHoverName() ) { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName() ) ); + return std::make_shared(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName()); } else { - return shared_ptr( new ChatPacket(player->getNetworkName(), m_msgId, type, additional ) ); + return std::make_shared(player->getNetworkName(), m_msgId, type, additional); } } diff --git a/Minecraft.World/InteractPacket.h b/Minecraft.World/InteractPacket.h index 0141038d7..aae163916 100644 --- a/Minecraft.World/InteractPacket.h +++ b/Minecraft.World/InteractPacket.h @@ -20,6 +20,6 @@ class InteractPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new InteractPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 7; } }; \ No newline at end of file diff --git a/Minecraft.World/Inventory.cpp b/Minecraft.World/Inventory.cpp index d50ff614e..ad0fc3ec1 100644 --- a/Minecraft.World/Inventory.cpp +++ b/Minecraft.World/Inventory.cpp @@ -205,11 +205,11 @@ void Inventory::replaceSlot(Item *item, int data) { int oldSlotCount = items[oldSlot]->count; items[oldSlot] = items[selected]; - items[selected] = shared_ptr( new ItemInstance(Item::items[item->id], oldSlotCount, data) ); + items[selected] = std::make_shared(Item::items[item->id], oldSlotCount, data); } else { - items[selected] = shared_ptr(new ItemInstance(Item::items[item->id], 1, data)); + items[selected] = std::make_shared(Item::items[item->id], 1, data); } } } @@ -239,7 +239,7 @@ int Inventory::addResource(shared_ptr itemInstance) if (slot < 0) return count; if (items[slot] == nullptr) { - items[slot] = shared_ptr( new ItemInstance(type, 0, itemInstance->getAuxValue()) ); + items[slot] = std::make_shared(type, 0, itemInstance->getAuxValue()); // 4J Stu - Brought forward from 1.2 if (itemInstance->hasTag()) { @@ -708,7 +708,7 @@ bool Inventory::isSame(shared_ptr a, shared_ptr b) shared_ptr Inventory::copy() { - shared_ptr copy = shared_ptr( new Inventory(nullptr) ); + shared_ptr copy = std::make_shared(nullptr); for (unsigned int i = 0; i < items.length; i++) { copy->items[i] = items[i] != nullptr ? items[i]->copy() : nullptr; diff --git a/Minecraft.World/InventoryMenu.cpp b/Minecraft.World/InventoryMenu.cpp index 2b0e9e80f..9c6c661f0 100644 --- a/Minecraft.World/InventoryMenu.cpp +++ b/Minecraft.World/InventoryMenu.cpp @@ -28,8 +28,8 @@ InventoryMenu::InventoryMenu(shared_ptr inventory, bool active, Playe void InventoryMenu::_init(shared_ptr inventory, bool active) { - craftSlots = shared_ptr( new CraftingContainer(this, 2, 2) ); - resultSlots = shared_ptr( new ResultContainer() ); + craftSlots = std::make_shared(this, 2, 2); + resultSlots = std::make_shared(); this->active = active; addSlot(new ResultSlot( inventory->player, craftSlots, resultSlots, 0, 144, 36)); diff --git a/Minecraft.World/ItemDispenseBehaviors.cpp b/Minecraft.World/ItemDispenseBehaviors.cpp index 0c9563261..8758dcfbb 100644 --- a/Minecraft.World/ItemDispenseBehaviors.cpp +++ b/Minecraft.World/ItemDispenseBehaviors.cpp @@ -11,7 +11,7 @@ shared_ptr ArrowDispenseBehavior::getProjectile(Level *world, Position *position) { - shared_ptr arrow = shared_ptr(new Arrow(world, position->getX(), position->getY(), position->getZ())); + shared_ptr arrow = std::make_shared(world, position->getX(), position->getY(), position->getZ()); arrow->pickup = Arrow::PICKUP_ALLOWED; return arrow; @@ -21,7 +21,7 @@ shared_ptr ArrowDispenseBehavior::getProjectile(Level *world, Positi shared_ptr EggDispenseBehavior::getProjectile(Level *world, Position *position) { - return shared_ptr(new ThrownEgg(world, position->getX(), position->getY(), position->getZ())); + return std::make_shared(world, position->getX(), position->getY(), position->getZ()); } @@ -29,7 +29,7 @@ shared_ptr EggDispenseBehavior::getProjectile(Level *world, Position shared_ptr SnowballDispenseBehavior::getProjectile(Level *world, Position *position) { - return shared_ptr(new Snowball(world, position->getX(), position->getY(), position->getZ())); + return std::make_shared(world, position->getX(), position->getY(), position->getZ()); } @@ -37,7 +37,7 @@ shared_ptr SnowballDispenseBehavior::getProjectile(Level *world, Pos shared_ptr ExpBottleDispenseBehavior::getProjectile(Level *world, Position *position) { - return shared_ptr(new ThrownExpBottle(world, position->getX(), position->getY(), position->getZ())); + return std::make_shared(world, position->getX(), position->getY(), position->getZ()); } float ExpBottleDispenseBehavior::getUncertainty() @@ -60,7 +60,7 @@ ThrownPotionDispenseBehavior::ThrownPotionDispenseBehavior(int potionValue) shared_ptr ThrownPotionDispenseBehavior::getProjectile(Level *world, Position *position) { - return shared_ptr(new ThrownPotion(world, position->getX(), position->getY(), position->getZ(), m_potionValue)); + return std::make_shared(world, position->getX(), position->getY(), position->getZ(), m_potionValue); } float ThrownPotionDispenseBehavior::getUncertainty() @@ -139,7 +139,7 @@ shared_ptr FireworksDispenseBehavior::execute(BlockSource *source, double spawnY = source->getBlockY() + .2f; double spawnZ = source->getZ() + facing->getStepZ(); - shared_ptr firework = shared_ptr(new FireworksRocketEntity(world, spawnX, spawnY, spawnZ, dispensed)); + shared_ptr firework = std::make_shared(world, spawnX, spawnY, spawnZ, dispensed); source->getWorld()->addEntity(firework); outcome = ACTIVATED_ITEM; @@ -183,7 +183,7 @@ shared_ptr FireballDispenseBehavior::execute(BlockSource *source, double dirY = random->nextGaussian() * .05 + facing->getStepY(); double dirZ = random->nextGaussian() * .05 + facing->getStepZ(); - world->addEntity(shared_ptr(new SmallFireball(world, spawnX, spawnY, spawnZ, dirX, dirY, dirZ))); + world->addEntity(std::make_shared(world, spawnX, spawnY, spawnZ, dirX, dirY, dirZ)); outcome = ACTIVATED_ITEM; @@ -254,7 +254,7 @@ shared_ptr BoatDispenseBehavior::execute(BlockSource *source, shar outcome = ACTIVATED_ITEM; - shared_ptr boat = shared_ptr(new Boat(world, spawnX, spawnY + yOffset, spawnZ)); + shared_ptr boat = std::make_shared(world, spawnX, spawnY + yOffset, spawnZ); world->addEntity(boat); dispensed->remove(1); @@ -326,9 +326,9 @@ shared_ptr EmptyBucketDispenseBehavior::execute(BlockSource *sourc dispensed->id = targetType->id; dispensed->count = 1; } - else if (dynamic_pointer_cast(source->getEntity())->addItem(shared_ptr(new ItemInstance(targetType))) < 0) + else if (dynamic_pointer_cast(source->getEntity())->addItem(std::make_shared(targetType)) < 0) { - DefaultDispenseItemBehavior::dispense(source, shared_ptr(new ItemInstance(targetType))); + DefaultDispenseItemBehavior::dispense(source, std::make_shared(targetType)); } outcome = ACTIVATED_ITEM; @@ -442,7 +442,7 @@ shared_ptr TntDispenseBehavior::execute(BlockSource *source, share int targetY = source->getBlockY() + facing->getStepY(); int targetZ = source->getBlockZ() + facing->getStepZ(); - shared_ptr tnt = shared_ptr(new PrimedTnt(world, targetX + 0.5f, targetY + 0.5f, targetZ + 0.5f, nullptr)); + shared_ptr tnt(new PrimedTnt(world, targetX + 0.5, targetY + 0.5, targetZ + 0.5, nullptr)); world->addEntity(tnt); outcome = ACTIVATED_ITEM; diff --git a/Minecraft.World/ItemEntity.cpp b/Minecraft.World/ItemEntity.cpp index e1cc92755..5dc1db6ee 100644 --- a/Minecraft.World/ItemEntity.cpp +++ b/Minecraft.World/ItemEntity.cpp @@ -287,7 +287,7 @@ shared_ptr ItemEntity::getItem() app.DebugPrintf("Item entity %d has no item?!\n", entityId); //level.getLogger().severe("Item entity " + entityId + " has no item?!"); } - return shared_ptr(new ItemInstance(Tile::stone)); + return std::make_shared(Tile::stone); } return result; diff --git a/Minecraft.World/ItemFrame.cpp b/Minecraft.World/ItemFrame.cpp index 7f1e0dcbc..f5988b9fd 100644 --- a/Minecraft.World/ItemFrame.cpp +++ b/Minecraft.World/ItemFrame.cpp @@ -61,7 +61,7 @@ void ItemFrame::dropItem(shared_ptr causedBy) } } - spawnAtLocation( shared_ptr(new ItemInstance(Item::frame) ), 0); + spawnAtLocation(std::make_shared(Item::frame), 0); if ( (item != nullptr) && (random->nextFloat() < dropChance) ) { item = item->copy(); diff --git a/Minecraft.World/ItemInstance.cpp b/Minecraft.World/ItemInstance.cpp index 5452b72c5..4906c22e6 100644 --- a/Minecraft.World/ItemInstance.cpp +++ b/Minecraft.World/ItemInstance.cpp @@ -91,7 +91,7 @@ ItemInstance::~ItemInstance() shared_ptr ItemInstance::remove(int count) { - shared_ptr ii = shared_ptr( new ItemInstance(id, count, auxValue) ); + shared_ptr ii = std::make_shared(id, count, auxValue); if (tag != nullptr) ii->tag = static_cast(tag->copy()); this->count -= count; @@ -302,7 +302,7 @@ bool ItemInstance::interactEnemy(shared_ptr player, shared_ptr ItemInstance::copy() const { - shared_ptr copy = shared_ptr( new ItemInstance(id, count, auxValue) ); + shared_ptr copy = std::make_shared(id, count, auxValue); if (tag != nullptr) { copy->tag = static_cast(tag->copy()); diff --git a/Minecraft.World/JukeboxTile.cpp b/Minecraft.World/JukeboxTile.cpp index 387ad9f2e..74e79e9ed 100644 --- a/Minecraft.World/JukeboxTile.cpp +++ b/Minecraft.World/JukeboxTile.cpp @@ -23,7 +23,7 @@ void JukeboxTile::Entity::load(CompoundTag *tag) } else if (tag->getInt(L"Record") > 0) { - setRecord(shared_ptr( new ItemInstance(tag->getInt(L"Record"), 1, 0))); + setRecord(std::make_shared(tag->getInt(L"Record"), 1, 0)); } } @@ -42,7 +42,7 @@ void JukeboxTile::Entity::save(CompoundTag *tag) // 4J Added shared_ptr JukeboxTile::Entity::clone() { - shared_ptr result = shared_ptr( new JukeboxTile::Entity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->record = record; @@ -127,7 +127,7 @@ void JukeboxTile::dropRecording(Level *level, int x, int y, int z) shared_ptr itemInstance = oldRecord->copy(); - shared_ptr item = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); + shared_ptr item = std::make_shared(level, x + xo, y + yo, z + zo, itemInstance); item->throwTime = 10; level->addEntity(item); } @@ -146,7 +146,7 @@ void JukeboxTile::spawnResources(Level *level, int x, int y, int z, int data, fl shared_ptr JukeboxTile::newTileEntity(Level *level) { - return shared_ptr( new JukeboxTile::Entity() ); + return std::make_shared(); } void JukeboxTile::registerIcons(IconRegister *iconRegister) diff --git a/Minecraft.World/KeepAlivePacket.h b/Minecraft.World/KeepAlivePacket.h index a44d87456..bbf7b0ab3 100644 --- a/Minecraft.World/KeepAlivePacket.h +++ b/Minecraft.World/KeepAlivePacket.h @@ -20,6 +20,6 @@ class KeepAlivePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new KeepAlivePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 0; } }; \ No newline at end of file diff --git a/Minecraft.World/KickPlayerPacket.h b/Minecraft.World/KickPlayerPacket.h index b9a6ce3e0..67fc66fde 100644 --- a/Minecraft.World/KickPlayerPacket.h +++ b/Minecraft.World/KickPlayerPacket.h @@ -17,6 +17,6 @@ class KickPlayerPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new KickPlayerPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 159; } }; \ No newline at end of file diff --git a/Minecraft.World/LavaSlime.cpp b/Minecraft.World/LavaSlime.cpp index 21982995d..f60baf097 100644 --- a/Minecraft.World/LavaSlime.cpp +++ b/Minecraft.World/LavaSlime.cpp @@ -55,7 +55,7 @@ ePARTICLE_TYPE LavaSlime::getParticleName() shared_ptr LavaSlime::createChild() { - return shared_ptr( new LavaSlime(level) ); + return std::make_shared(level); } int LavaSlime::getDeathLoot() diff --git a/Minecraft.World/Layer.cpp b/Minecraft.World/Layer.cpp index b604cabca..0f3b22f2a 100644 --- a/Minecraft.World/Layer.cpp +++ b/Minecraft.World/Layer.cpp @@ -21,16 +21,16 @@ LayerArray Layer::getDefaultLayers(__int64 seed, LevelType *levelType) // 4J - Some changes moved here from 1.2.3. Temperature & downfall layers are no longer created & returned, and a debug layer is isn't. // For reference with regard to future merging, things NOT brought forward from the 1.2.3 version are new layer types that we // don't have yet (shores, swamprivers, region hills etc.) - shared_ptrislandLayer = shared_ptr(new IslandLayer(1)); - islandLayer = shared_ptr(new FuzzyZoomLayer(2000, islandLayer)); - islandLayer = shared_ptr(new AddIslandLayer(1, islandLayer)); - islandLayer = shared_ptr(new ZoomLayer(2001, islandLayer)); - islandLayer = shared_ptr(new AddIslandLayer(2, islandLayer)); - islandLayer = shared_ptr(new AddSnowLayer(2, islandLayer)); - islandLayer = shared_ptr(new ZoomLayer(2002, islandLayer)); - islandLayer = shared_ptr(new AddIslandLayer(3, islandLayer)); - islandLayer = shared_ptr(new ZoomLayer(2003, islandLayer)); - islandLayer = shared_ptr(new AddIslandLayer(4, islandLayer)); + shared_ptrislandLayer = std::make_shared(1); + islandLayer = std::make_shared(2000, islandLayer); + islandLayer = std::make_shared(1, islandLayer); + islandLayer = std::make_shared(2001, islandLayer); + islandLayer = std::make_shared(2, islandLayer); + islandLayer = std::make_shared(2, islandLayer); + islandLayer = std::make_shared(2002, islandLayer); + islandLayer = std::make_shared(3, islandLayer); + islandLayer = std::make_shared(2003, islandLayer); + islandLayer = std::make_shared(4, islandLayer); // islandLayer = shared_ptr(new AddMushroomIslandLayer(5, islandLayer)); // 4J - old position of mushroom island layer int zoomLevel = 4; @@ -41,30 +41,30 @@ LayerArray Layer::getDefaultLayers(__int64 seed, LevelType *levelType) shared_ptr riverLayer = islandLayer; riverLayer = ZoomLayer::zoom(1000, riverLayer, 0); - riverLayer = shared_ptr(new RiverInitLayer(100, riverLayer)); + riverLayer = std::make_shared(100, riverLayer); riverLayer = ZoomLayer::zoom(1000, riverLayer, zoomLevel + 2); - riverLayer = shared_ptr(new RiverLayer(1, riverLayer)); - riverLayer = shared_ptr(new SmoothLayer(1000, riverLayer)); + riverLayer = std::make_shared(1, riverLayer); + riverLayer = std::make_shared(1000, riverLayer); shared_ptr biomeLayer = islandLayer; biomeLayer = ZoomLayer::zoom(1000, biomeLayer, 0); - biomeLayer = shared_ptr(new BiomeInitLayer(200, biomeLayer, levelType)); + biomeLayer = std::make_shared(200, biomeLayer, levelType); biomeLayer = ZoomLayer::zoom(1000, biomeLayer, 2); - biomeLayer = shared_ptr(new RegionHillsLayer(1000, biomeLayer)); + biomeLayer = std::make_shared(1000, biomeLayer); for (int i = 0; i < zoomLevel; i++) { - biomeLayer = shared_ptr(new ZoomLayer(1000 + i, biomeLayer)); + biomeLayer = std::make_shared(1000 + i, biomeLayer); - if (i == 0) biomeLayer = shared_ptr(new AddIslandLayer(3, biomeLayer)); + if (i == 0) biomeLayer = std::make_shared(3, biomeLayer); if (i == 0) { // 4J - moved mushroom islands to here. This skips 3 zooms that the old location of the add was, making them about 1/8 of the original size. Adding // them at this scale actually lets us place them near enough other land, if we add them at the same scale as java then they have to be too far out to see for // the scale of our maps - biomeLayer = shared_ptr(new AddMushroomIslandLayer(5, biomeLayer)); + biomeLayer = std::make_shared(5, biomeLayer); } if (i == 1 ) @@ -72,30 +72,30 @@ LayerArray Layer::getDefaultLayers(__int64 seed, LevelType *levelType) // 4J - now expand mushroom islands up again. This does a simple region grow to add a new mushroom island element when any of the neighbours are also mushroom islands. // This helps make the islands into nice compact shapes of the type that are actually likely to be able to make an island out of the sea in a small space. Also // helps the shore layer from doing too much damage in shrinking the islands we are making - biomeLayer = shared_ptr(new GrowMushroomIslandLayer(5, biomeLayer)); + biomeLayer = std::make_shared(5, biomeLayer); // Note - this reduces the size of mushroom islands by turning their edges into shores. We are doing this at i == 1 rather than i == 0 as the original does - biomeLayer = shared_ptr(new ShoreLayer(1000, biomeLayer)); + biomeLayer = std::make_shared(1000, biomeLayer); - biomeLayer = shared_ptr(new SwampRiversLayer(1000, biomeLayer)); + biomeLayer = std::make_shared(1000, biomeLayer); } } - biomeLayer = shared_ptr(new SmoothLayer(1000, biomeLayer)); + biomeLayer = std::make_shared(1000, biomeLayer); - biomeLayer = shared_ptr(new RiverMixerLayer(100, biomeLayer, riverLayer)); + biomeLayer = std::make_shared(100, biomeLayer, riverLayer); #ifndef _CONTENT_PACKAGE #ifdef _BIOME_OVERRIDE if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<(new BiomeOverrideLayer(1)); + biomeLayer = std::make_shared(1); } #endif #endif shared_ptr debugLayer = biomeLayer; - shared_ptrzoomedLayer = shared_ptr(new VoronoiZoom(10, biomeLayer)); + shared_ptrzoomedLayer = std::make_shared(10, biomeLayer); biomeLayer->init(seed); zoomedLayer->init(seed); diff --git a/Minecraft.World/LeafTile.cpp b/Minecraft.World/LeafTile.cpp index d66c9bda3..f8f5deae4 100644 --- a/Minecraft.World/LeafTile.cpp +++ b/Minecraft.World/LeafTile.cpp @@ -249,7 +249,7 @@ void LeafTile::spawnResources(Level *level, int x, int y, int z, int data, float if (level->random->nextInt(chance) == 0) { int type = getResource(data, level->random,playerBonusLevel); - popResource(level, x, y, z, shared_ptr( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data)))); + popResource(level, x, y, z, std::make_shared(type, 1, getSpawnResourcesAuxValue(data))); } chance = 200; @@ -263,7 +263,7 @@ void LeafTile::spawnResources(Level *level, int x, int y, int z, int data, float } if ((data & LEAF_TYPE_MASK) == NORMAL_LEAF && level->random->nextInt(chance) == 0) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(Item::apple_Id, 1, 0))); + popResource(level, x, y, z, std::make_shared(Item::apple_Id, 1, 0)); } } } @@ -278,7 +278,7 @@ void LeafTile::playerDestroy(Level *level, shared_ptr player, int x, int ); // drop leaf block instead of sapling - popResource(level, x, y, z, shared_ptr(new ItemInstance(Tile::leaves_Id, 1, data & LEAF_TYPE_MASK))); + popResource(level, x, y, z, std::make_shared(Tile::leaves_Id, 1, data & LEAF_TYPE_MASK)); } else { @@ -324,7 +324,7 @@ void LeafTile::setFancy(bool fancyGraphics) shared_ptr LeafTile::getSilkTouchItemInstance(int data) { - return shared_ptr( new ItemInstance(id, 1, data & LEAF_TYPE_MASK) ); + return std::make_shared(id, 1, data & LEAF_TYPE_MASK); } void LeafTile::stepOn(Level *level, int x, int y, int z, shared_ptr entity) diff --git a/Minecraft.World/LeashFenceKnotEntity.cpp b/Minecraft.World/LeashFenceKnotEntity.cpp index f952a5abb..f94bcba70 100644 --- a/Minecraft.World/LeashFenceKnotEntity.cpp +++ b/Minecraft.World/LeashFenceKnotEntity.cpp @@ -131,7 +131,7 @@ bool LeashFenceKnotEntity::survives() shared_ptr LeashFenceKnotEntity::createAndAddKnot(Level *level, int x, int y, int z) { - shared_ptr knot = shared_ptr( new LeashFenceKnotEntity(level, x, y, z) ); + shared_ptr knot = std::make_shared(level, x, y, z); knot->forcedLoading = true; level->addEntity(knot); return knot; diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp index 54bc04353..3ad65d9eb 100644 --- a/Minecraft.World/Level.cpp +++ b/Minecraft.World/Level.cpp @@ -632,7 +632,7 @@ Level::Level(shared_ptr levelStorage, const wstring& name, Dimensi shared_ptr savedVillages = dynamic_pointer_cast(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID)); if (savedVillages == nullptr) { - villages = shared_ptr(new Villages(this)); + villages = std::make_shared(this); savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages); } else @@ -670,7 +670,7 @@ void Level::_init(shared_ptrlevelStorage, const wstring& levelName shared_ptr savedVillages = dynamic_pointer_cast(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID)); if (savedVillages == nullptr) { - villages = shared_ptr(new Villages(this)); + villages = std::make_shared(this); savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages); } else @@ -2810,7 +2810,7 @@ shared_ptr Level::explode(shared_ptr source, double x, double shared_ptr Level::explode(shared_ptr source, double x, double y, double z, float r, bool fire, bool destroyBlocks) { - shared_ptr explosion = shared_ptr( new Explosion(this, source, x, y, z, r) ); + shared_ptr explosion = std::make_shared(this, source, x, y, z, r); explosion->fire = fire; explosion->destroyBlocks = destroyBlocks; explosion->explode(); diff --git a/Minecraft.World/LevelEventPacket.h b/Minecraft.World/LevelEventPacket.h index 1d8c36e28..234f127dd 100644 --- a/Minecraft.World/LevelEventPacket.h +++ b/Minecraft.World/LevelEventPacket.h @@ -21,6 +21,6 @@ class LevelEventPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new LevelEventPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 61; } }; \ No newline at end of file diff --git a/Minecraft.World/LevelParticlesPacket.h b/Minecraft.World/LevelParticlesPacket.h index 7676f771b..c7870a8e1 100644 --- a/Minecraft.World/LevelParticlesPacket.h +++ b/Minecraft.World/LevelParticlesPacket.h @@ -34,6 +34,6 @@ class LevelParticlesPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new LevelParticlesPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 63; } }; \ No newline at end of file diff --git a/Minecraft.World/LevelSoundPacket.h b/Minecraft.World/LevelSoundPacket.h index 403ac092b..e9ce356db 100644 --- a/Minecraft.World/LevelSoundPacket.h +++ b/Minecraft.World/LevelSoundPacket.h @@ -33,6 +33,6 @@ class LevelSoundPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new LevelSoundPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 62; } }; diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index 814a768c3..3ace88068 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -295,7 +295,7 @@ void LivingEntity::tickDeath() { int newCount = ExperienceOrb::getExperienceValue(xpCount); xpCount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x, y, z, newCount) ) ); + level->addEntity(std::make_shared(level, x, y, z, newCount)); } } } @@ -1174,7 +1174,7 @@ void LivingEntity::swing() if (dynamic_cast(level) != nullptr) { - static_cast(level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new AnimatePacket(shared_from_this(), AnimatePacket::SWING))); + static_cast(level)->getTracker()->broadcast(shared_from_this(), std::make_shared(shared_from_this(), AnimatePacket::SWING)); } } } @@ -1602,7 +1602,7 @@ void LivingEntity::tick() if (!ItemInstance::matches(current, previous)) { - static_cast(level)->getTracker()->broadcast(shared_from_this(), shared_ptr( new SetEquippedItemPacket(entityId, i, current))); + static_cast(level)->getTracker()->broadcast(shared_from_this(), std::make_shared(entityId, i, current)); if (previous != nullptr) attributes->removeItemModifiers(previous); if (current != nullptr) attributes->addItemModifiers(current); lastEquipment[i] = current == nullptr ? nullptr : current->copy(); @@ -1860,15 +1860,15 @@ void LivingEntity::take(shared_ptr e, int orgCount) EntityTracker *entityTracker = static_cast(level)->getTracker(); if ( e->instanceof(eTYPE_ITEMENTITY) ) { - entityTracker->broadcast(e, shared_ptr( new TakeItemEntityPacket(e->entityId, entityId))); + entityTracker->broadcast(e, std::make_shared(e->entityId, entityId)); } else if ( e->instanceof(eTYPE_ARROW) ) { - entityTracker->broadcast(e, shared_ptr( new TakeItemEntityPacket(e->entityId, entityId))); + entityTracker->broadcast(e, std::make_shared(e->entityId, entityId)); } else if ( e->instanceof(eTYPE_EXPERIENCEORB) ) { - entityTracker->broadcast(e, shared_ptr( new TakeItemEntityPacket(e->entityId, entityId))); + entityTracker->broadcast(e, std::make_shared(e->entityId, entityId)); } } } diff --git a/Minecraft.World/LoginPacket.h b/Minecraft.World/LoginPacket.h index 090411358..906753e84 100644 --- a/Minecraft.World/LoginPacket.h +++ b/Minecraft.World/LoginPacket.h @@ -40,6 +40,6 @@ class LoginPacket : public Packet, public enable_shared_from_this virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new LoginPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 1; } }; diff --git a/Minecraft.World/MapItem.cpp b/Minecraft.World/MapItem.cpp index af9792afb..61c203e3b 100644 --- a/Minecraft.World/MapItem.cpp +++ b/Minecraft.World/MapItem.cpp @@ -32,7 +32,7 @@ shared_ptr MapItem::getSavedData(short idNum, Level *level) int aux = idNum; id = wstring( L"map_" ) + std::to_wstring(aux); - mapItemSavedData = shared_ptr( new MapItemSavedData(id) ); + mapItemSavedData = std::make_shared(id); level->setSavedData(id, (shared_ptr ) mapItemSavedData); } @@ -55,7 +55,7 @@ shared_ptr MapItem::getSavedData(shared_ptr item //itemInstance->setAuxValue(level->getFreeAuxValueFor(L"map")); id = wstring( L"map_" ) + std::to_wstring(itemInstance->getAuxValue() ); - mapItemSavedData = shared_ptr( new MapItemSavedData(id) ); + mapItemSavedData = std::make_shared(id); newData = true; } @@ -297,7 +297,7 @@ shared_ptr MapItem::getUpdatePacket(shared_ptr itemInstanc if (data.data == nullptr || data.length == 0) return nullptr; - shared_ptr retval = shared_ptr(new ComplexItemDataPacket(static_cast(Item::map->id), static_cast(itemInstance->getAuxValue()), data)); + shared_ptr retval = std::make_shared(static_cast(Item::map->id), static_cast(itemInstance->getAuxValue()), data); delete data.data; return retval; } @@ -327,7 +327,7 @@ void MapItem::onCraftedBy(shared_ptr itemInstance, Level *level, s // when a new one is created if( data == nullptr ) { - data = shared_ptr( new MapItemSavedData(id) ); + data = std::make_shared(id); } level->setSavedData(id, (shared_ptr ) data); diff --git a/Minecraft.World/MapItemSavedData.cpp b/Minecraft.World/MapItemSavedData.cpp index 2495b4551..0a5eb7c40 100644 --- a/Minecraft.World/MapItemSavedData.cpp +++ b/Minecraft.World/MapItemSavedData.cpp @@ -236,7 +236,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr player, shared_ptr hp = shared_ptr( new HoldingPlayer(player, this ) ); + shared_ptr hp = std::make_shared(player, this); carriedByPlayers.insert( playerHoldingPlayerMapType::value_type(player, hp) ); carriedBy.push_back(hp); } @@ -545,7 +545,7 @@ shared_ptr MapItemSavedData::getHoldingPlayer(s if (it == carriedByPlayers.end()) { - hp = shared_ptr( new HoldingPlayer(player, this) ); + hp = std::make_shared(player, this); carriedByPlayers[player] = hp; carriedBy.push_back(hp); } diff --git a/Minecraft.World/McRegionLevelStorageSource.cpp b/Minecraft.World/McRegionLevelStorageSource.cpp index d36706ead..bf60ee0cf 100644 --- a/Minecraft.World/McRegionLevelStorageSource.cpp +++ b/Minecraft.World/McRegionLevelStorageSource.cpp @@ -76,7 +76,7 @@ void McRegionLevelStorageSource::clearAll() shared_ptr McRegionLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir) { // return new LevelStorageProfilerDecorator(new McRegionLevelStorage(baseDir, levelId, createPlayerDir)); - return shared_ptr(new McRegionLevelStorage(saveFile, baseDir, levelId, createPlayerDir)); + return std::make_shared(saveFile, baseDir, levelId, createPlayerDir); } bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId) diff --git a/Minecraft.World/MerchantMenu.cpp b/Minecraft.World/MerchantMenu.cpp index 2fe9cf6aa..f24d24c93 100644 --- a/Minecraft.World/MerchantMenu.cpp +++ b/Minecraft.World/MerchantMenu.cpp @@ -10,7 +10,7 @@ MerchantMenu::MerchantMenu(shared_ptr inventory, shared_ptr trader = merchant; this->level = level; - tradeContainer = shared_ptr( new MerchantContainer(dynamic_pointer_cast(inventory->player->shared_from_this()), merchant) ); + tradeContainer = std::make_shared(dynamic_pointer_cast(inventory->player->shared_from_this()), merchant); addSlot(new Slot(tradeContainer, PAYMENT1_SLOT, SELLSLOT1_X, ROW2_Y)); addSlot(new Slot(tradeContainer, PAYMENT2_SLOT, SELLSLOT2_X, ROW2_Y)); addSlot(new MerchantResultSlot(inventory->player, merchant, tradeContainer, RESULT_SLOT, BUYSLOT_X, ROW2_Y)); diff --git a/Minecraft.World/MerchantRecipe.cpp b/Minecraft.World/MerchantRecipe.cpp index 9c30c36bb..b4eb1b541 100644 --- a/Minecraft.World/MerchantRecipe.cpp +++ b/Minecraft.World/MerchantRecipe.cpp @@ -34,12 +34,12 @@ MerchantRecipe::MerchantRecipe(shared_ptr buy, shared_ptr buy, Item *sell) { - _init(buy, nullptr, shared_ptr(new ItemInstance(sell))); + _init(buy, nullptr, std::make_shared(sell)); } MerchantRecipe::MerchantRecipe(shared_ptr buy, Tile *sell) { - _init(buy, nullptr, shared_ptr(new ItemInstance(sell))); + _init(buy, nullptr, std::make_shared(sell)); } shared_ptr MerchantRecipe::getBuyAItem() diff --git a/Minecraft.World/MilkBucketItem.cpp b/Minecraft.World/MilkBucketItem.cpp index 4a3710788..8c8ea674c 100644 --- a/Minecraft.World/MilkBucketItem.cpp +++ b/Minecraft.World/MilkBucketItem.cpp @@ -19,7 +19,7 @@ shared_ptr MilkBucketItem::useTimeDepleted(shared_ptrcount <= 0) { - return shared_ptr( new ItemInstance(Item::bucket_empty) ); + return std::make_shared(Item::bucket_empty); } return instance; } diff --git a/Minecraft.World/MineShaftPieces.cpp b/Minecraft.World/MineShaftPieces.cpp index 6f1d9adbd..97caf3663 100644 --- a/Minecraft.World/MineShaftPieces.cpp +++ b/Minecraft.World/MineShaftPieces.cpp @@ -434,7 +434,7 @@ bool MineShaftPieces::MineShaftCorridor::createChest(Level *level, BoundingBox * if (level->getTile(worldX, worldY, worldZ) == 0) { level->setTileAndData(worldX, worldY, worldZ, Tile::rail_Id, getOrientationData(Tile::rail_Id, random->nextBoolean() ? RailTile::DIR_FLAT_X : RailTile::DIR_FLAT_Z), Tile::UPDATE_CLIENTS); - shared_ptr chest = shared_ptr( new MinecartChest(level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f) ); + shared_ptr chest = std::make_shared(level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f); WeighedTreasure::addChestItems(random, treasure, chest, numRolls); level->addEntity(chest); return true; diff --git a/Minecraft.World/Minecart.cpp b/Minecraft.World/Minecart.cpp index 34076b126..f6c4bb769 100644 --- a/Minecraft.World/Minecart.cpp +++ b/Minecraft.World/Minecart.cpp @@ -69,17 +69,17 @@ shared_ptr Minecart::createMinecart(Level *level, double x, double y, switch (type) { case TYPE_CHEST: - return shared_ptr( new MinecartChest(level, x, y, z) ); + return std::make_shared(level, x, y, z); case TYPE_FURNACE: - return shared_ptr( new MinecartFurnace(level, x, y, z) ); + return std::make_shared(level, x, y, z); case TYPE_TNT: - return shared_ptr( new MinecartTNT(level, x, y, z) ); + return std::make_shared(level, x, y, z); case TYPE_SPAWNER: - return shared_ptr( new MinecartSpawner(level, x, y, z) ); + return std::make_shared(level, x, y, z); case TYPE_HOPPER: - return shared_ptr( new MinecartHopper(level, x, y, z) ); + return std::make_shared(level, x, y, z); default: - return shared_ptr( new MinecartRideable(level, x, y, z) ); + return std::make_shared(level, x, y, z); } } @@ -187,7 +187,7 @@ bool Minecart::hurt(DamageSource *source, float hurtDamage) void Minecart::destroy(DamageSource *source) { remove(); - shared_ptr item = shared_ptr( new ItemInstance(Item::minecart, 1) ); + shared_ptr item = std::make_shared(Item::minecart, 1); if (!name.empty()) item->setHoverName(name); spawnAtLocation(item, 0); } diff --git a/Minecraft.World/MinecartContainer.cpp b/Minecraft.World/MinecartContainer.cpp index e1a7e002a..0e0fd3ac7 100644 --- a/Minecraft.World/MinecartContainer.cpp +++ b/Minecraft.World/MinecartContainer.cpp @@ -45,7 +45,7 @@ void MinecartContainer::destroy(DamageSource *source) if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()))) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); float pow = 0.05f; itemEntity->xd = static_cast(random->nextGaussian()) * pow; itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; @@ -157,7 +157,7 @@ void MinecartContainer::remove() if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue())))); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); if (item->hasTag()) { diff --git a/Minecraft.World/MinecartFurnace.cpp b/Minecraft.World/MinecartFurnace.cpp index b2ced6ed3..fa005ecaf 100644 --- a/Minecraft.World/MinecartFurnace.cpp +++ b/Minecraft.World/MinecartFurnace.cpp @@ -66,7 +66,7 @@ void MinecartFurnace::destroy(DamageSource *source) if (!source->isExplosion()) { - spawnAtLocation(shared_ptr(new ItemInstance(Tile::furnace, 1)), 0); + spawnAtLocation(std::make_shared(Tile::furnace, 1), 0); } } diff --git a/Minecraft.World/MinecartTNT.cpp b/Minecraft.World/MinecartTNT.cpp index 11a664843..57462e03d 100644 --- a/Minecraft.World/MinecartTNT.cpp +++ b/Minecraft.World/MinecartTNT.cpp @@ -66,7 +66,7 @@ void MinecartTNT::destroy(DamageSource *source) if (!source->isExplosion()) { - spawnAtLocation( shared_ptr( new ItemInstance(Tile::tnt, 1) ), 0); + spawnAtLocation(std::make_shared(Tile::tnt, 1), 0); } if (source->isFire() || source->isExplosion() || speedSqr >= 0.01f) diff --git a/Minecraft.World/Mob.cpp b/Minecraft.World/Mob.cpp index af49499ae..17671112f 100644 --- a/Minecraft.World/Mob.cpp +++ b/Minecraft.World/Mob.cpp @@ -729,7 +729,7 @@ void Mob::populateDefaultEquipmentSlots() if (item == nullptr) { Item *equip = getEquipmentForSlot(i + 1, armorType); - if (equip != nullptr) setEquippedSlot(i + 1, shared_ptr(new ItemInstance(equip))); + if (equip != nullptr) setEquippedSlot(i + 1, std::make_shared(equip)); } } } @@ -983,7 +983,7 @@ void Mob::dropLeash(bool synch, bool createItemDrop) ServerLevel *serverLevel = dynamic_cast(level); if (!level->isClientSide && synch && serverLevel != nullptr) { - serverLevel->getTracker()->broadcast(shared_from_this(), shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, shared_from_this(), nullptr))); + serverLevel->getTracker()->broadcast(shared_from_this(), std::make_shared(SetEntityLinkPacket::LEASH, shared_from_this(), nullptr)); } } } @@ -1011,7 +1011,7 @@ void Mob::setLeashedTo(shared_ptr holder, bool synch) ServerLevel *serverLevel = dynamic_cast(level); if (!level->isClientSide && synch && serverLevel) { - serverLevel->getTracker()->broadcast(shared_from_this(), shared_ptr( new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, shared_from_this(), leashHolder))); + serverLevel->getTracker()->broadcast(shared_from_this(), std::make_shared(SetEntityLinkPacket::LEASH, shared_from_this(), leashHolder)); } } diff --git a/Minecraft.World/MobSpawnerTile.cpp b/Minecraft.World/MobSpawnerTile.cpp index 4665015a6..08c1f87dd 100644 --- a/Minecraft.World/MobSpawnerTile.cpp +++ b/Minecraft.World/MobSpawnerTile.cpp @@ -9,7 +9,7 @@ MobSpawnerTile::MobSpawnerTile(int id) : BaseEntityTile(id, Material::stone, isS shared_ptr MobSpawnerTile::newTileEntity(Level *level) { - return shared_ptr( new MobSpawnerTileEntity() ); + return std::make_shared(); } int MobSpawnerTile::getResource(int data, Random *random, int playerBonusLevel) diff --git a/Minecraft.World/MobSpawnerTileEntity.cpp b/Minecraft.World/MobSpawnerTileEntity.cpp index 028ad3e44..e3ee57d6b 100644 --- a/Minecraft.World/MobSpawnerTileEntity.cpp +++ b/Minecraft.World/MobSpawnerTileEntity.cpp @@ -73,7 +73,7 @@ shared_ptr MobSpawnerTileEntity::getUpdatePacket() CompoundTag *tag = new CompoundTag(); save(tag); tag->remove(L"SpawnPotentials"); - return shared_ptr( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_MOB_SPAWNER, tag) ); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_MOB_SPAWNER, tag); } bool MobSpawnerTileEntity::triggerEvent(int b0, int b1) @@ -90,7 +90,7 @@ BaseMobSpawner *MobSpawnerTileEntity::getSpawner() // 4J Added shared_ptr MobSpawnerTileEntity::clone() { - shared_ptr result = shared_ptr( new MobSpawnerTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); return result; diff --git a/Minecraft.World/MoveEntityPacket.h b/Minecraft.World/MoveEntityPacket.h index ab16ac3a4..dc0f44d57 100644 --- a/Minecraft.World/MoveEntityPacket.h +++ b/Minecraft.World/MoveEntityPacket.h @@ -27,7 +27,7 @@ class MoveEntityPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 30; } }; @@ -42,7 +42,7 @@ class MoveEntityPacket::PosRot : public MoveEntityPacket virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacket::PosRot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 33; } }; @@ -57,7 +57,7 @@ class MoveEntityPacket::Pos : public MoveEntityPacket virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacket::Pos()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 31; } }; @@ -72,7 +72,7 @@ class MoveEntityPacket::Rot : public MoveEntityPacket virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacket::Rot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 32; } }; \ No newline at end of file diff --git a/Minecraft.World/MoveEntityPacketSmall.h b/Minecraft.World/MoveEntityPacketSmall.h index 4218f11b9..c3f357dd7 100644 --- a/Minecraft.World/MoveEntityPacketSmall.h +++ b/Minecraft.World/MoveEntityPacketSmall.h @@ -27,7 +27,7 @@ class MoveEntityPacketSmall : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacketSmall()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 162; } }; @@ -42,7 +42,7 @@ class MoveEntityPacketSmall::PosRot : public MoveEntityPacketSmall virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacketSmall::PosRot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 165; } }; @@ -57,7 +57,7 @@ class MoveEntityPacketSmall::Pos : public MoveEntityPacketSmall virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacketSmall::Pos()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 163; } }; @@ -73,7 +73,7 @@ class MoveEntityPacketSmall::Rot : public MoveEntityPacketSmall virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MoveEntityPacketSmall::Rot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 164; } }; \ No newline at end of file diff --git a/Minecraft.World/MovePlayerPacket.h b/Minecraft.World/MovePlayerPacket.h index 26ae83927..1850c9d3c 100644 --- a/Minecraft.World/MovePlayerPacket.h +++ b/Minecraft.World/MovePlayerPacket.h @@ -27,7 +27,7 @@ class MovePlayerPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new MovePlayerPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 10; } }; @@ -42,7 +42,7 @@ class MovePlayerPacket::PosRot : public MovePlayerPacket virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MovePlayerPacket::PosRot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 13; } }; @@ -57,7 +57,7 @@ class MovePlayerPacket::Pos : public MovePlayerPacket virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MovePlayerPacket::Pos()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 11; } }; @@ -72,7 +72,7 @@ class MovePlayerPacket::Rot : public MovePlayerPacket virtual void write(DataOutputStream *dos); virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new MovePlayerPacket::Rot()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 12; } }; \ No newline at end of file diff --git a/Minecraft.World/MushroomCow.cpp b/Minecraft.World/MushroomCow.cpp index 66969a00f..2b274215e 100644 --- a/Minecraft.World/MushroomCow.cpp +++ b/Minecraft.World/MushroomCow.cpp @@ -28,11 +28,11 @@ bool MushroomCow::mobInteract(shared_ptr player) { if (item->count == 1) { - player->inventory->setItem(player->inventory->selected, shared_ptr( new ItemInstance(Item::mushroomStew) ) ); + player->inventory->setItem(player->inventory->selected, std::make_shared(Item::mushroomStew)); return true; } - if (player->inventory->add(shared_ptr(new ItemInstance(Item::mushroomStew))) && !player->abilities.instabuild) + if (player->inventory->add(std::make_shared(Item::mushroomStew)) && !player->abilities.instabuild) { player->inventory->removeItem(player->inventory->selected, 1); return true; @@ -46,14 +46,14 @@ bool MushroomCow::mobInteract(shared_ptr player) if(!level->isClientSide) { remove(); - shared_ptr cow = shared_ptr( new Cow(level) ); + shared_ptr cow = std::make_shared(level); cow->moveTo(x, y, z, yRot, xRot); cow->setHealth(getHealth()); cow->yBodyRot = yBodyRot; level->addEntity(cow); for (int i = 0; i < 5; i++) { - level->addEntity( shared_ptr( new ItemEntity(level, x, y + bbHeight, z, shared_ptr( new ItemInstance(Tile::mushroom_red))) )); + level->addEntity(std::make_shared(level, x, y + bbHeight, z, shared_ptr(new ItemInstance(Tile::mushroom_red)))); } return true; } @@ -76,7 +76,7 @@ shared_ptr MushroomCow::getBreedOffspring(shared_ptr targe // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - return shared_ptr( new MushroomCow(level) ); + return std::make_shared(level); } else { diff --git a/Minecraft.World/MusicTileEntity.cpp b/Minecraft.World/MusicTileEntity.cpp index ac39758ae..7f2f28889 100644 --- a/Minecraft.World/MusicTileEntity.cpp +++ b/Minecraft.World/MusicTileEntity.cpp @@ -55,7 +55,7 @@ void MusicTileEntity::playNote(Level *level, int x, int y, int z) // 4J Added shared_ptr MusicTileEntity::clone() { - shared_ptr result = shared_ptr( new MusicTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->note = note; diff --git a/Minecraft.World/NetherWartTile.cpp b/Minecraft.World/NetherWartTile.cpp index add3eccf7..afe45aec5 100644 --- a/Minecraft.World/NetherWartTile.cpp +++ b/Minecraft.World/NetherWartTile.cpp @@ -84,7 +84,7 @@ void NetherWartTile::spawnResources(Level *level, int x, int y, int z, int data, } for (int i = 0; i < count; i++) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(Item::netherwart_seeds))); + popResource(level, x, y, z, std::make_shared(Item::netherwart_seeds)); } } diff --git a/Minecraft.World/NoteBlockTile.cpp b/Minecraft.World/NoteBlockTile.cpp index 4c58ec8b1..cafa0c4da 100644 --- a/Minecraft.World/NoteBlockTile.cpp +++ b/Minecraft.World/NoteBlockTile.cpp @@ -52,7 +52,7 @@ void NoteBlockTile::attack(Level *level, int x, int y, int z, shared_ptr shared_ptr NoteBlockTile::newTileEntity(Level *level) { - return shared_ptr( new MusicTileEntity() ); + return std::make_shared(); } bool NoteBlockTile::triggerEvent(Level *level, int x, int y, int z, int i, int note) diff --git a/Minecraft.World/Ocelot.cpp b/Minecraft.World/Ocelot.cpp index 474fcd71e..75c6e0f07 100644 --- a/Minecraft.World/Ocelot.cpp +++ b/Minecraft.World/Ocelot.cpp @@ -240,7 +240,7 @@ shared_ptr Ocelot::getBreedOffspring(shared_ptr target) // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - shared_ptr offspring = shared_ptr( new Ocelot(level) ); + shared_ptr offspring = std::make_shared(level); if (isTame()) { offspring->setOwnerUUID(getOwnerUUID()); @@ -339,7 +339,7 @@ MobGroupData *Ocelot::finalizeMobSpawn(MobGroupData *groupData, int extraData /* { for (int kitten = 0; kitten < 2; kitten++) { - shared_ptr ocelot = shared_ptr( new Ocelot(level) ); + shared_ptr ocelot = std::make_shared(level); ocelot->moveTo(x, y, z, yRot, 0); ocelot->setAge(-20 * 60 * 20); level->addEntity(ocelot); diff --git a/Minecraft.World/Packet.cpp b/Minecraft.World/Packet.cpp index 417df48f3..e0f7603f2 100644 --- a/Minecraft.World/Packet.cpp +++ b/Minecraft.World/Packet.cpp @@ -512,7 +512,7 @@ shared_ptr Packet::readItem(DataInputStream *dis) int count = dis->readByte(); int damage = dis->readShort(); - item = shared_ptr( new ItemInstance(id, count, damage) ); + item = std::make_shared(id, count, damage); // 4J Stu - Always read/write the tag //if (Item.items[id].canBeDepleted() || Item.items[id].shouldOverrideMultiplayerNBT()) { diff --git a/Minecraft.World/Painting.cpp b/Minecraft.World/Painting.cpp index e1232809b..5e56b9cac 100644 --- a/Minecraft.World/Painting.cpp +++ b/Minecraft.World/Painting.cpp @@ -164,5 +164,5 @@ void Painting::dropItem(shared_ptr causedBy) } } - spawnAtLocation(shared_ptr(new ItemInstance(Item::painting)), 0.0f); + spawnAtLocation(std::make_shared(Item::painting), 0.0f); } \ No newline at end of file diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp index 6ac1243af..a99af826c 100644 --- a/Minecraft.World/Pig.cpp +++ b/Minecraft.World/Pig.cpp @@ -164,7 +164,7 @@ void Pig::setSaddle(bool value) void Pig::thunderHit(const LightningBolt *lightningBolt) { if (level->isClientSide) return; - shared_ptr pz = shared_ptr( new PigZombie(level) ); + shared_ptr pz = std::make_shared(level); pz->moveTo(x, y, z, yRot, xRot); level->addEntity(pz); remove(); @@ -184,7 +184,7 @@ shared_ptr Pig::getBreedOffspring(shared_ptr target) // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - return shared_ptr( new Pig(level) ); + return std::make_shared(level); } else { diff --git a/Minecraft.World/PigZombie.cpp b/Minecraft.World/PigZombie.cpp index 16f00213c..1be123d7a 100644 --- a/Minecraft.World/PigZombie.cpp +++ b/Minecraft.World/PigZombie.cpp @@ -174,7 +174,7 @@ int PigZombie::getDeathLoot() void PigZombie::populateDefaultEquipmentSlots() { - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::sword_gold)) ); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::sword_gold)); } MobGroupData *PigZombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /*= 0*/) // 4J Added extraData param diff --git a/Minecraft.World/PistonMovingPiece.cpp b/Minecraft.World/PistonMovingPiece.cpp index a1fe1c957..5ae010070 100644 --- a/Minecraft.World/PistonMovingPiece.cpp +++ b/Minecraft.World/PistonMovingPiece.cpp @@ -99,7 +99,7 @@ void PistonMovingPiece::neighborChanged(Level *level, int x, int y, int z, int t shared_ptr PistonMovingPiece::newMovingPieceEntity(int block, int data, int facing, bool extending, bool isSourcePiston) { - return shared_ptr(new PistonPieceEntity(block, data, facing, extending, isSourcePiston)); + return std::make_shared(block, data, facing, extending, isSourcePiston); } AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z) diff --git a/Minecraft.World/PistonPieceEntity.cpp b/Minecraft.World/PistonPieceEntity.cpp index dc946a2bd..08e18cbbf 100644 --- a/Minecraft.World/PistonPieceEntity.cpp +++ b/Minecraft.World/PistonPieceEntity.cpp @@ -207,7 +207,7 @@ void PistonPieceEntity::save(CompoundTag *tag) // 4J Added shared_ptr PistonPieceEntity::clone() { - shared_ptr result = shared_ptr( new PistonPieceEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->id = id; diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index 4d5d55fbc..00c7148e4 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -50,7 +50,7 @@ void Player::_init() registerAttributes(); setHealth(getMaxHealth()); - inventory = shared_ptr( new Inventory( this ) ); + inventory = std::make_shared(this); userType = 0; oBob = bob = 0.0f; @@ -105,7 +105,7 @@ void Player::_init() m_ePlayerNameValidState=ePlayerNameValid_NotSet; #endif - enderChestInventory = shared_ptr(new PlayerEnderChestContainer()); + enderChestInventory = std::make_shared(); m_bAwardedOnARail=false; } @@ -1097,7 +1097,7 @@ void Player::die(DamageSource *source) // 4J - TODO need to use a xuid if ( app.isXuidNotch( m_xuid ) ) { - drop(shared_ptr( new ItemInstance(Item::apple, 1) ), true); + drop(std::make_shared(Item::apple, 1), true); } if (!level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY)) { @@ -1170,7 +1170,7 @@ shared_ptr Player::drop(shared_ptr item, bool randomly if (item == nullptr) return nullptr; if (item->count == 0) return nullptr; - shared_ptr thrownItem = shared_ptr( new ItemEntity(level, x, y - 0.3f + getHeadHeight(), z, item) ); + shared_ptr thrownItem = std::make_shared(level, x, y - 0.3f + getHeadHeight(), z, item); thrownItem->throwTime = 20 * 2; thrownItem->setThrower(getName()); diff --git a/Minecraft.World/PlayerAbilitiesPacket.h b/Minecraft.World/PlayerAbilitiesPacket.h index 8cd82bf5a..3998c66bc 100644 --- a/Minecraft.World/PlayerAbilitiesPacket.h +++ b/Minecraft.World/PlayerAbilitiesPacket.h @@ -44,6 +44,6 @@ class PlayerAbilitiesPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new PlayerAbilitiesPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 202; } }; \ No newline at end of file diff --git a/Minecraft.World/PlayerActionPacket.h b/Minecraft.World/PlayerActionPacket.h index 45c077d2a..647777cd7 100644 --- a/Minecraft.World/PlayerActionPacket.h +++ b/Minecraft.World/PlayerActionPacket.h @@ -24,7 +24,7 @@ class PlayerActionPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new PlayerActionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 14; } }; diff --git a/Minecraft.World/PlayerCommandPacket.h b/Minecraft.World/PlayerCommandPacket.h index 92ee57eb5..042b32cae 100644 --- a/Minecraft.World/PlayerCommandPacket.h +++ b/Minecraft.World/PlayerCommandPacket.h @@ -36,6 +36,6 @@ class PlayerCommandPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new PlayerCommandPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 19; } }; \ No newline at end of file diff --git a/Minecraft.World/PlayerInfoPacket.h b/Minecraft.World/PlayerInfoPacket.h index 85e2ed648..7044ffbda 100644 --- a/Minecraft.World/PlayerInfoPacket.h +++ b/Minecraft.World/PlayerInfoPacket.h @@ -27,6 +27,6 @@ class PlayerInfoPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new PlayerInfoPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 201; } }; \ No newline at end of file diff --git a/Minecraft.World/PlayerInputPacket.h b/Minecraft.World/PlayerInputPacket.h index bc2d39851..6f1dce47b 100644 --- a/Minecraft.World/PlayerInputPacket.h +++ b/Minecraft.World/PlayerInputPacket.h @@ -27,6 +27,6 @@ class PlayerInputPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new PlayerInputPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 27; } }; \ No newline at end of file diff --git a/Minecraft.World/PotatoTile.cpp b/Minecraft.World/PotatoTile.cpp index 872622ba9..351c8c980 100644 --- a/Minecraft.World/PotatoTile.cpp +++ b/Minecraft.World/PotatoTile.cpp @@ -46,7 +46,7 @@ void PotatoTile::spawnResources(Level *level, int x, int y, int z, int data, flo { if (level->random->nextInt(50) == 0) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(Item::potatoPoisonous))); + popResource(level, x, y, z, std::make_shared(Item::potatoPoisonous)); } } } diff --git a/Minecraft.World/PotionItem.cpp b/Minecraft.World/PotionItem.cpp index 3438cb854..fd156883d 100644 --- a/Minecraft.World/PotionItem.cpp +++ b/Minecraft.World/PotionItem.cpp @@ -94,11 +94,11 @@ shared_ptr PotionItem::useTimeDepleted(shared_ptr in { if (instance->count <= 0) { - return shared_ptr( new ItemInstance(Item::glassBottle) ); + return std::make_shared(Item::glassBottle); } else { - player->inventory->add( shared_ptr( new ItemInstance(Item::glassBottle) ) ); + player->inventory->add(std::make_shared(Item::glassBottle)); } } @@ -126,7 +126,7 @@ shared_ptr PotionItem::use(shared_ptr instance, Leve { if (!player->abilities.instabuild) instance->count--; level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - if (!level->isClientSide) level->addEntity(shared_ptr( new ThrownPotion(level, player, instance->getAuxValue()) )); + if (!level->isClientSide) level->addEntity(std::make_shared(level, player, instance->getAuxValue())); return instance; } player->startUsingItem(instance, getUseDuration(instance)); diff --git a/Minecraft.World/PreLoginPacket.h b/Minecraft.World/PreLoginPacket.h index 243f2f360..b0935d0a5 100644 --- a/Minecraft.World/PreLoginPacket.h +++ b/Minecraft.World/PreLoginPacket.h @@ -34,6 +34,6 @@ class PreLoginPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new PreLoginPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 2; } }; \ No newline at end of file diff --git a/Minecraft.World/PumpkinTile.cpp b/Minecraft.World/PumpkinTile.cpp index f7bfe218c..da11001d8 100644 --- a/Minecraft.World/PumpkinTile.cpp +++ b/Minecraft.World/PumpkinTile.cpp @@ -45,7 +45,7 @@ void PumpkinTile::onPlace(Level *level, int x, int y, int z) level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS); level->setTileAndData(x, y - 1, z, 0, 0, Tile::UPDATE_CLIENTS); level->setTileAndData(x, y - 2, z, 0, 0, Tile::UPDATE_CLIENTS); - shared_ptr snowMan = shared_ptr(new SnowMan(level)); + shared_ptr snowMan = std::make_shared(level); snowMan->moveTo(x + 0.5, y - 1.95, z + 0.5, 0, 0); level->addEntity(snowMan); @@ -94,7 +94,7 @@ void PumpkinTile::onPlace(Level *level, int x, int y, int z) level->setTileAndData(x, y - 1, z + 1, 0, 0, Tile::UPDATE_CLIENTS); } - shared_ptr villagerGolem = shared_ptr(new VillagerGolem(level)); + shared_ptr villagerGolem = std::make_shared(level); villagerGolem->setPlayerCreated(true); villagerGolem->moveTo(x + 0.5, y - 1.95, z + 0.5, 0, 0); level->addEntity(villagerGolem); diff --git a/Minecraft.World/QuartzBlockTile.cpp b/Minecraft.World/QuartzBlockTile.cpp index 709e0c1e9..d0ab02d2a 100644 --- a/Minecraft.World/QuartzBlockTile.cpp +++ b/Minecraft.World/QuartzBlockTile.cpp @@ -91,7 +91,7 @@ int QuartzBlockTile::getSpawnResourcesAuxValue(int data) shared_ptr QuartzBlockTile::getSilkTouchItemInstance(int data) { - if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return shared_ptr(new ItemInstance(id, 1, TYPE_LINES_Y)); + if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return std::make_shared(id, 1, TYPE_LINES_Y); return Tile::getSilkTouchItemInstance(data); } diff --git a/Minecraft.World/Recipes.cpp b/Minecraft.World/Recipes.cpp index 94ee30ac7..c200d1651 100644 --- a/Minecraft.World/Recipes.cpp +++ b/Minecraft.World/Recipes.cpp @@ -1272,7 +1272,7 @@ shared_ptr Recipes::getItemFor(shared_ptr craft int remaining = (remaining1 + remaining2) + item->getMaxDamage() * 5 / 100; int resultDamage = item->getMaxDamage() - remaining; if (resultDamage < 0) resultDamage = 0; - return shared_ptr( new ItemInstance(first->id, 1, resultDamage) ); + return std::make_shared(first->id, 1, resultDamage); } if(recipesClass != nullptr) diff --git a/Minecraft.World/RedStoneOreTile.cpp b/Minecraft.World/RedStoneOreTile.cpp index b7551932f..407da2cc3 100644 --- a/Minecraft.World/RedStoneOreTile.cpp +++ b/Minecraft.World/RedStoneOreTile.cpp @@ -124,5 +124,5 @@ bool RedStoneOreTile::shouldTileTick(Level *level, int x,int y,int z) shared_ptr RedStoneOreTile::getSilkTouchItemInstance(int data) { - return shared_ptr(new ItemInstance(Tile::redStoneOre)); + return std::make_shared(Tile::redStoneOre); } \ No newline at end of file diff --git a/Minecraft.World/RemoveEntitiesPacket.h b/Minecraft.World/RemoveEntitiesPacket.h index 2e734e711..b400b861a 100644 --- a/Minecraft.World/RemoveEntitiesPacket.h +++ b/Minecraft.World/RemoveEntitiesPacket.h @@ -21,7 +21,7 @@ class RemoveEntitiesPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new RemoveEntitiesPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 29; } }; diff --git a/Minecraft.World/RemoveMobEffectPacket.h b/Minecraft.World/RemoveMobEffectPacket.h index d69a4ed4a..140b0a7e0 100644 --- a/Minecraft.World/RemoveMobEffectPacket.h +++ b/Minecraft.World/RemoveMobEffectPacket.h @@ -18,6 +18,6 @@ class RemoveMobEffectPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new RemoveMobEffectPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 42; } }; \ No newline at end of file diff --git a/Minecraft.World/RespawnPacket.h b/Minecraft.World/RespawnPacket.h index dc341ea17..90a5ef0d9 100644 --- a/Minecraft.World/RespawnPacket.h +++ b/Minecraft.World/RespawnPacket.h @@ -29,6 +29,6 @@ class RespawnPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new RespawnPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 9; } }; diff --git a/Minecraft.World/ResultSlot.cpp b/Minecraft.World/ResultSlot.cpp index 87318d66b..89a07ed10 100644 --- a/Minecraft.World/ResultSlot.cpp +++ b/Minecraft.World/ResultSlot.cpp @@ -66,7 +66,7 @@ void ResultSlot::onTake(shared_ptr player, shared_ptr carr if (item->getItem()->hasCraftingRemainingItem()) { - shared_ptr craftResult = shared_ptr(new ItemInstance(item->getItem()->getCraftingRemainingItem())); + shared_ptr craftResult = std::make_shared(item->getItem()->getCraftingRemainingItem()); /* * Try to place this in the player's inventory (See we.java for new method) diff --git a/Minecraft.World/RotateHeadPacket.h b/Minecraft.World/RotateHeadPacket.h index 19ccf97f4..884f48444 100644 --- a/Minecraft.World/RotateHeadPacket.h +++ b/Minecraft.World/RotateHeadPacket.h @@ -22,6 +22,6 @@ class RotateHeadPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new RotateHeadPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 35; } }; \ No newline at end of file diff --git a/Minecraft.World/RotatedPillarTile.cpp b/Minecraft.World/RotatedPillarTile.cpp index a4b7d931e..6475cd727 100644 --- a/Minecraft.World/RotatedPillarTile.cpp +++ b/Minecraft.World/RotatedPillarTile.cpp @@ -73,5 +73,5 @@ int RotatedPillarTile::getType(int data) shared_ptr RotatedPillarTile::getSilkTouchItemInstance(int data) { - return shared_ptr( new ItemInstance(id, 1, getType(data)) ); + return std::make_shared(id, 1, getType(data)); } \ No newline at end of file diff --git a/Minecraft.World/SavedDataStorage.cpp b/Minecraft.World/SavedDataStorage.cpp index d882b2053..049a19fc2 100644 --- a/Minecraft.World/SavedDataStorage.cpp +++ b/Minecraft.World/SavedDataStorage.cpp @@ -37,15 +37,15 @@ shared_ptr SavedDataStorage::get(const type_info& clazz, const wstrin if( clazz == typeid(MapItemSavedData) ) { - data = dynamic_pointer_cast( shared_ptr(new MapItemSavedData(id)) ); + data = dynamic_pointer_cast(std::make_shared(id)); } else if( clazz == typeid(Villages) ) { - data = dynamic_pointer_cast( shared_ptr(new Villages(id) ) ); + data = dynamic_pointer_cast(std::make_shared(id)); } else if( clazz == typeid(StructureFeatureSavedData) ) { - data = dynamic_pointer_cast( shared_ptr( new StructureFeatureSavedData(id) ) ); + data = dynamic_pointer_cast(std::make_shared(id)); } else { diff --git a/Minecraft.World/ScatteredFeaturePieces.cpp b/Minecraft.World/ScatteredFeaturePieces.cpp index a623f9727..07630ef7a 100644 --- a/Minecraft.World/ScatteredFeaturePieces.cpp +++ b/Minecraft.World/ScatteredFeaturePieces.cpp @@ -737,7 +737,7 @@ bool ScatteredFeaturePieces::SwamplandHut::postProcess(Level *level, Random *ran { spawnedWitch = true; - shared_ptr witch = shared_ptr( new Witch(level) ); + shared_ptr witch = std::make_shared(level); witch->moveTo(wx + .5, wy, wz + .5, 0, 0); witch->finalizeMobSpawn(nullptr); level->addEntity(witch); diff --git a/Minecraft.World/ServerSettingsChangedPacket.h b/Minecraft.World/ServerSettingsChangedPacket.h index e6ab73563..c537eca94 100644 --- a/Minecraft.World/ServerSettingsChangedPacket.h +++ b/Minecraft.World/ServerSettingsChangedPacket.h @@ -26,6 +26,6 @@ class ServerSettingsChangedPacket : public Packet, public enable_shared_from_thi virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new ServerSettingsChangedPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 153; } }; \ No newline at end of file diff --git a/Minecraft.World/SetCarriedItemPacket.h b/Minecraft.World/SetCarriedItemPacket.h index 06fb3c306..017314dce 100644 --- a/Minecraft.World/SetCarriedItemPacket.h +++ b/Minecraft.World/SetCarriedItemPacket.h @@ -19,6 +19,6 @@ class SetCarriedItemPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new SetCarriedItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 16; } }; \ No newline at end of file diff --git a/Minecraft.World/SetCreativeModeSlotPacket.h b/Minecraft.World/SetCreativeModeSlotPacket.h index 94ae7807f..3724714e0 100644 --- a/Minecraft.World/SetCreativeModeSlotPacket.h +++ b/Minecraft.World/SetCreativeModeSlotPacket.h @@ -18,6 +18,6 @@ class SetCreativeModeSlotPacket : public Packet, public enable_shared_from_this< public: - static shared_ptr create() { return shared_ptr(new SetCreativeModeSlotPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 107; } }; \ No newline at end of file diff --git a/Minecraft.World/SetDisplayObjectivePacket.h b/Minecraft.World/SetDisplayObjectivePacket.h index f32f63866..5404eab75 100644 --- a/Minecraft.World/SetDisplayObjectivePacket.h +++ b/Minecraft.World/SetDisplayObjectivePacket.h @@ -19,6 +19,6 @@ class SetDisplayObjectivePacket : public Packet, public enable_shared_from_this< int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new SetDisplayObjectivePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 208; } }; \ No newline at end of file diff --git a/Minecraft.World/SetEntityDataPacket.h b/Minecraft.World/SetEntityDataPacket.h index a3bb08609..cd3371dd7 100644 --- a/Minecraft.World/SetEntityDataPacket.h +++ b/Minecraft.World/SetEntityDataPacket.h @@ -25,6 +25,6 @@ class SetEntityDataPacket : public Packet, public enable_shared_from_this > *getUnpackedData(); public: - static shared_ptr create() { return shared_ptr(new SetEntityDataPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 40; } }; \ No newline at end of file diff --git a/Minecraft.World/SetEntityLinkPacket.h b/Minecraft.World/SetEntityLinkPacket.h index aa92206df..04ee0e977 100644 --- a/Minecraft.World/SetEntityLinkPacket.h +++ b/Minecraft.World/SetEntityLinkPacket.h @@ -23,7 +23,7 @@ class SetEntityLinkPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new SetEntityLinkPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 39; } }; \ No newline at end of file diff --git a/Minecraft.World/SetEntityMotionPacket.h b/Minecraft.World/SetEntityMotionPacket.h index 00c019da9..e71240c5c 100644 --- a/Minecraft.World/SetEntityMotionPacket.h +++ b/Minecraft.World/SetEntityMotionPacket.h @@ -26,6 +26,6 @@ class SetEntityMotionPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new SetEntityMotionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 28; } }; \ No newline at end of file diff --git a/Minecraft.World/SetEquippedItemPacket.h b/Minecraft.World/SetEquippedItemPacket.h index def39120b..29df2b028 100644 --- a/Minecraft.World/SetEquippedItemPacket.h +++ b/Minecraft.World/SetEquippedItemPacket.h @@ -28,6 +28,6 @@ class SetEquippedItemPacket : public Packet, public enable_shared_from_this getItem(); public: - static shared_ptr create() { return shared_ptr(new SetEquippedItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 5; } }; \ No newline at end of file diff --git a/Minecraft.World/SetExperiencePacket.h b/Minecraft.World/SetExperiencePacket.h index 01c0ed468..668f44168 100644 --- a/Minecraft.World/SetExperiencePacket.h +++ b/Minecraft.World/SetExperiencePacket.h @@ -20,6 +20,6 @@ class SetExperiencePacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new SetExperiencePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 43; } }; \ No newline at end of file diff --git a/Minecraft.World/SetHealthPacket.h b/Minecraft.World/SetHealthPacket.h index 4704f220b..cc85c4c62 100644 --- a/Minecraft.World/SetHealthPacket.h +++ b/Minecraft.World/SetHealthPacket.h @@ -23,7 +23,7 @@ class SetHealthPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new SetHealthPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 8; } }; diff --git a/Minecraft.World/SetObjectivePacket.h b/Minecraft.World/SetObjectivePacket.h index 5b5dfc6fd..52b67ee02 100644 --- a/Minecraft.World/SetObjectivePacket.h +++ b/Minecraft.World/SetObjectivePacket.h @@ -23,6 +23,6 @@ class SetObjectivePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new SetObjectivePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 206; } }; \ No newline at end of file diff --git a/Minecraft.World/SetPlayerTeamPacket.h b/Minecraft.World/SetPlayerTeamPacket.h index f6df9da2c..60364db55 100644 --- a/Minecraft.World/SetPlayerTeamPacket.h +++ b/Minecraft.World/SetPlayerTeamPacket.h @@ -30,6 +30,6 @@ class SetPlayerTeamPacket : public Packet , public enable_shared_from_this create() { return shared_ptr(new SetPlayerTeamPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 209; } }; \ No newline at end of file diff --git a/Minecraft.World/SetScorePacket.h b/Minecraft.World/SetScorePacket.h index 5f800be6a..245559731 100644 --- a/Minecraft.World/SetScorePacket.h +++ b/Minecraft.World/SetScorePacket.h @@ -25,6 +25,6 @@ class SetScorePacket : public Packet , public enable_shared_from_this create() { return shared_ptr(new SetScorePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 207; } }; \ No newline at end of file diff --git a/Minecraft.World/SetSpawnPositionPacket.h b/Minecraft.World/SetSpawnPositionPacket.h index 3ba66af87..f90d3f5c6 100644 --- a/Minecraft.World/SetSpawnPositionPacket.h +++ b/Minecraft.World/SetSpawnPositionPacket.h @@ -20,6 +20,6 @@ class SetSpawnPositionPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new SetSpawnPositionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 6; } }; \ No newline at end of file diff --git a/Minecraft.World/SetTimePacket.h b/Minecraft.World/SetTimePacket.h index 7ded9ce1f..56cf4922e 100644 --- a/Minecraft.World/SetTimePacket.h +++ b/Minecraft.World/SetTimePacket.h @@ -21,6 +21,6 @@ class SetTimePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new SetTimePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 4; } }; \ No newline at end of file diff --git a/Minecraft.World/Sheep.cpp b/Minecraft.World/Sheep.cpp index 7343e29c0..f06308f49 100644 --- a/Minecraft.World/Sheep.cpp +++ b/Minecraft.World/Sheep.cpp @@ -65,9 +65,9 @@ Sheep::Sheep(Level *level) : Animal( level ) goalSelector.addGoal(7, new LookAtPlayerGoal(this, typeid(Player), 6)); goalSelector.addGoal(8, new RandomLookAroundGoal(this)); - container = shared_ptr(new CraftingContainer(new SheepContainer(), 2, 1)); - container->setItem(0, shared_ptr( new ItemInstance(Item::dye_powder, 1, 0))); - container->setItem(1, shared_ptr( new ItemInstance(Item::dye_powder, 1, 0))); + container = std::make_shared(new SheepContainer(), 2, 1); + container->setItem(0, std::make_shared(Item::dye_powder, 1, 0)); + container->setItem(1, std::make_shared(Item::dye_powder, 1, 0)); } bool Sheep::useNewAi() @@ -108,7 +108,7 @@ void Sheep::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) if(!isSheared()) { // killing a non-sheared sheep will drop a single block of cloth - spawnAtLocation(shared_ptr( new ItemInstance(Tile::wool_Id, 1, getColor()) ), 0.0f); + spawnAtLocation(std::make_shared(Tile::wool_Id, 1, getColor()), 0.0f); } } @@ -177,7 +177,7 @@ bool Sheep::mobInteract(shared_ptr player) int count = 1 + random->nextInt(3); for (int i = 0; i < count; i++) { - shared_ptr ie = spawnAtLocation(shared_ptr( new ItemInstance(Tile::wool_Id, 1, getColor()) ), 1.0f); + shared_ptr ie = spawnAtLocation(std::make_shared(Tile::wool_Id, 1, getColor()), 1.0f); ie->yd += random->nextFloat() * 0.05f; ie->xd += (random->nextFloat() - random->nextFloat()) * 0.1f; ie->zd += (random->nextFloat() - random->nextFloat()) * 0.1f; @@ -284,7 +284,7 @@ shared_ptr Sheep::getBreedOffspring(shared_ptr target) if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { shared_ptr otherSheep = dynamic_pointer_cast( target ); - shared_ptr sheep = shared_ptr( new Sheep(level) ); + shared_ptr sheep = std::make_shared(level); int color = getOffspringColor(dynamic_pointer_cast(shared_from_this()), otherSheep); sheep->setColor(15 - color); return sheep; diff --git a/Minecraft.World/SignTile.cpp b/Minecraft.World/SignTile.cpp index 1f8c6e948..15be23db5 100644 --- a/Minecraft.World/SignTile.cpp +++ b/Minecraft.World/SignTile.cpp @@ -79,7 +79,7 @@ shared_ptr SignTile::newTileEntity(Level *level) { //try { // 4J Stu - For some reason the newInstance wasn't working right, but doing it like the other TileEntities is fine - return shared_ptr( new SignTileEntity() ); + return std::make_shared(); //return dynamic_pointer_cast( clas->newInstance() ); //} catch (Exception e) { // TODO 4J Stu - Exception handling diff --git a/Minecraft.World/SignTileEntity.cpp b/Minecraft.World/SignTileEntity.cpp index a90ca5017..598621eb5 100644 --- a/Minecraft.World/SignTileEntity.cpp +++ b/Minecraft.World/SignTileEntity.cpp @@ -93,7 +93,7 @@ shared_ptr SignTileEntity::getUpdatePacket() { copy[i] = m_wsmessages[i]; } - return shared_ptr( new SignUpdatePacket(x, y, z, m_bVerified, m_bCensored, copy) ); + return std::make_shared(x, y, z, m_bVerified, m_bCensored, copy); } bool SignTileEntity::isEditable() @@ -207,7 +207,7 @@ int SignTileEntity::StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE * // 4J Added shared_ptr SignTileEntity::clone() { - shared_ptr result = shared_ptr( new SignTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->m_wsmessages[0] = m_wsmessages[0]; diff --git a/Minecraft.World/SignUpdatePacket.h b/Minecraft.World/SignUpdatePacket.h index 80cc29681..f44f4dded 100644 --- a/Minecraft.World/SignUpdatePacket.h +++ b/Minecraft.World/SignUpdatePacket.h @@ -21,6 +21,6 @@ class SignUpdatePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new SignUpdatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 130; } }; \ No newline at end of file diff --git a/Minecraft.World/Skeleton.cpp b/Minecraft.World/Skeleton.cpp index d5f59dfe0..cc325b979 100644 --- a/Minecraft.World/Skeleton.cpp +++ b/Minecraft.World/Skeleton.cpp @@ -217,7 +217,7 @@ void Skeleton::dropRareDeathLoot(int rareLootLevel) { if (getSkeletonType() == TYPE_WITHER) { - spawnAtLocation( shared_ptr( new ItemInstance(Item::skull_Id, 1, SkullTileEntity::TYPE_WITHER) ), 0); + spawnAtLocation(std::make_shared(Item::skull_Id, 1, SkullTileEntity::TYPE_WITHER), 0); } } @@ -225,7 +225,7 @@ void Skeleton::populateDefaultEquipmentSlots() { Monster::populateDefaultEquipmentSlots(); - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::bow))); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::bow)); } MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData /*= 0*/) // 4J Added extraData param @@ -237,7 +237,7 @@ MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData goalSelector.addGoal(4, meleeGoal, false); setSkeletonType(TYPE_WITHER); - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::sword_stone))); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::sword_stone)); getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->setBaseValue(4); } else @@ -255,7 +255,7 @@ MobGroupData *Skeleton::finalizeMobSpawn(MobGroupData *groupData, int extraData if (Calendar::GetMonth() + 1 == 10 && Calendar::GetDayOfMonth() == 31 && random->nextFloat() < 0.25f) { // Halloween! OooOOo! 25% of all skeletons/zombies can wear pumpkins on their heads. - setEquippedSlot(SLOT_HELM, shared_ptr( new ItemInstance(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin))); + setEquippedSlot(SLOT_HELM, std::make_shared(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin)); dropChances[SLOT_HELM] = 0; } } @@ -281,7 +281,7 @@ void Skeleton::reassessWeaponGoal() void Skeleton::performRangedAttack(shared_ptr target, float power) { - shared_ptr arrow = shared_ptr( new Arrow(level, dynamic_pointer_cast(shared_from_this()), target, 1.60f, 14 - (level->difficulty * 4)) ); + shared_ptr arrow = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), target, 1.60f, 14 - (level->difficulty * 4)); int damageBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowBonus->id, getCarriedItem()); int knockbackBonus = EnchantmentHelper::getEnchantmentLevel(Enchantment::arrowKnockback->id, getCarriedItem()); diff --git a/Minecraft.World/SkullTile.cpp b/Minecraft.World/SkullTile.cpp index 28699645d..b5eca3732 100644 --- a/Minecraft.World/SkullTile.cpp +++ b/Minecraft.World/SkullTile.cpp @@ -67,7 +67,7 @@ void SkullTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr SkullTile::newTileEntity(Level *level) { - return shared_ptr(new SkullTileEntity()); + return std::make_shared(); } int SkullTile::cloneTileId(Level *level, int x, int y, int z) @@ -113,7 +113,7 @@ void SkullTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (level->isClientSide) return; if ((data & NO_DROP_BIT) == 0) { - shared_ptr item = shared_ptr(new ItemInstance(Item::skull_Id, 1, cloneTileData(level, x, y, z))); + shared_ptr item = std::make_shared(Item::skull_Id, 1, cloneTileData(level, x, y, z)); shared_ptr entity = dynamic_pointer_cast(level->getTileEntity(x, y, z)); if (entity->getSkullType() == SkullTileEntity::TYPE_CHAR && !entity->getExtraType().empty()) @@ -166,7 +166,7 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptrcanCreateMore(eTYPE_WITHERBOSS, Level::eSpawnType_Egg)) { // 4J: Removed !isClientSide check because there's one earlier on - shared_ptr witherBoss = shared_ptr( new WitherBoss(level) ); + shared_ptr witherBoss = std::make_shared(level); witherBoss->moveTo(x + 0.5, y - 1.45, z + zo + 1.5, 90, 0); witherBoss->yBodyRot = 90; witherBoss->makeInvulnerable(); @@ -180,8 +180,8 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptrspawnResources(level, x, y - 2, z + zo + 1, 0, 0); Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x, y - 1, z + zo + 2, 0, 0); - shared_ptr itemInstance = shared_ptr(new ItemInstance(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER)); - shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x, y, z + zo + 1, itemInstance) ); + shared_ptr itemInstance = std::make_shared(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER); + shared_ptr itemEntity = std::make_shared(level, x, y, z + zo + 1, itemInstance); level->addEntity(itemEntity); } @@ -229,7 +229,7 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptrcanCreateMore(eTYPE_WITHERBOSS, Level::eSpawnType_Egg)) { // 4J: Removed !isClientSide check because there's one earlier on - shared_ptr witherBoss = shared_ptr( new WitherBoss(level) ); + shared_ptr witherBoss = std::make_shared(level); witherBoss->moveTo(x + xo + 1.5, y - 1.45, z + .5, 0, 0); witherBoss->makeInvulnerable(); level->addEntity(witherBoss); @@ -242,8 +242,8 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptrspawnResources(level, x + xo + 1, y - 2, z, 0, 0); Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x + xo + 2, y - 1, z, 0, 0); - shared_ptr itemInstance = shared_ptr(new ItemInstance(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER)); - shared_ptr itemEntity = shared_ptr(new ItemEntity(level, x + xo + 1, y, z, itemInstance) ); + shared_ptr itemInstance = std::make_shared(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER); + shared_ptr itemEntity = std::make_shared(level, x + xo + 1, y, z, itemInstance); level->addEntity(itemEntity); } diff --git a/Minecraft.World/SkullTileEntity.cpp b/Minecraft.World/SkullTileEntity.cpp index 404332d46..3937bec45 100644 --- a/Minecraft.World/SkullTileEntity.cpp +++ b/Minecraft.World/SkullTileEntity.cpp @@ -30,7 +30,7 @@ shared_ptr SkullTileEntity::getUpdatePacket() { CompoundTag *tag = new CompoundTag(); save(tag); - return shared_ptr(new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_SKULL, tag)); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_SKULL, tag); } void SkullTileEntity::setSkullType(int skullType, const wstring &extra) @@ -62,7 +62,7 @@ wstring SkullTileEntity::getExtraType() // 4J Added shared_ptr SkullTileEntity::clone() { - shared_ptr result = shared_ptr( new SkullTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->skullType = skullType; diff --git a/Minecraft.World/Slime.cpp b/Minecraft.World/Slime.cpp index aefb8ae29..d91b0a136 100644 --- a/Minecraft.World/Slime.cpp +++ b/Minecraft.World/Slime.cpp @@ -179,7 +179,7 @@ int Slime::getJumpDelay() shared_ptr Slime::createChild() { - return shared_ptr( new Slime(level) ); + return std::make_shared(level); } void Slime::remove() diff --git a/Minecraft.World/Slot.cpp b/Minecraft.World/Slot.cpp index 91920b2de..2f42a27d1 100644 --- a/Minecraft.World/Slot.cpp +++ b/Minecraft.World/Slot.cpp @@ -148,7 +148,7 @@ shared_ptr Slot::combine(shared_ptr item) shared_ptr result = nullptr; shared_ptr first = getItem(); - shared_ptr craftSlots = shared_ptr( new CraftingContainer(nullptr, 2, 2) ); + shared_ptr craftSlots = std::make_shared(nullptr, 2, 2); craftSlots->setItem(0, item); craftSlots->setItem(1, first); diff --git a/Minecraft.World/SmoothZoomLayer.cpp b/Minecraft.World/SmoothZoomLayer.cpp index 3e1c55a18..c8cff40de 100644 --- a/Minecraft.World/SmoothZoomLayer.cpp +++ b/Minecraft.World/SmoothZoomLayer.cpp @@ -55,7 +55,7 @@ shared_ptrSmoothZoomLayer::zoom(__int64 seed, shared_ptrsup, int c shared_ptrresult = sup; for (int i = 0; i < count; i++) { - result = shared_ptr(new SmoothZoomLayer(seed + i, result)); + result = std::make_shared(seed + i, result); } return result; } \ No newline at end of file diff --git a/Minecraft.World/SnowMan.cpp b/Minecraft.World/SnowMan.cpp index 6c78b56f8..05ead6a69 100644 --- a/Minecraft.World/SnowMan.cpp +++ b/Minecraft.World/SnowMan.cpp @@ -100,7 +100,7 @@ void SnowMan::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) void SnowMan::performRangedAttack(shared_ptr target, float power) { - shared_ptr snowball = shared_ptr(new Snowball(level, dynamic_pointer_cast(shared_from_this()))); + shared_ptr snowball = std::make_shared(level, dynamic_pointer_cast(shared_from_this())); double xd = target->x - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - snowball->y; double zd = target->z - z; diff --git a/Minecraft.World/SnowballItem.cpp b/Minecraft.World/SnowballItem.cpp index 0149e68dc..afb190d81 100644 --- a/Minecraft.World/SnowballItem.cpp +++ b/Minecraft.World/SnowballItem.cpp @@ -18,6 +18,6 @@ shared_ptr SnowballItem::use(shared_ptr instance, Le instance->count--; } level->playEntitySound((shared_ptr ) player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); - if (!level->isClientSide) level->addEntity( shared_ptr( new Snowball(level, player) ) ); + if (!level->isClientSide) level->addEntity(std::make_shared(level, player)); return instance; } \ No newline at end of file diff --git a/Minecraft.World/Spider.cpp b/Minecraft.World/Spider.cpp index 24d737699..5d7bdd2c8 100644 --- a/Minecraft.World/Spider.cpp +++ b/Minecraft.World/Spider.cpp @@ -195,7 +195,7 @@ MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /* if (level->random->nextInt(100) == 0) #endif { - shared_ptr skeleton = shared_ptr( new Skeleton(level) ); + shared_ptr skeleton = std::make_shared(level); skeleton->moveTo(x, y, z, yRot, 0); skeleton->finalizeMobSpawn(nullptr); level->addEntity(skeleton); diff --git a/Minecraft.World/SpikeFeature.cpp b/Minecraft.World/SpikeFeature.cpp index 629b3c832..912e3aff4 100644 --- a/Minecraft.World/SpikeFeature.cpp +++ b/Minecraft.World/SpikeFeature.cpp @@ -50,7 +50,7 @@ bool SpikeFeature::place(Level *level, Random *random, int x, int y, int z) } else break; } - shared_ptr enderCrystal = shared_ptr(new EnderCrystal(level)); + shared_ptr enderCrystal = std::make_shared(level); enderCrystal->moveTo(x + 0.5f, y + hh, z + 0.5f, random->nextFloat() * 360, 0); level->addEntity(enderCrystal); level->setTileAndData(x, y + hh, z, Tile::unbreakable_Id, 0, Tile::UPDATE_CLIENTS); @@ -168,7 +168,7 @@ bool SpikeFeature::placeWithIndex(Level *level, Random *random, int x, int y, in } } - shared_ptr enderCrystal = shared_ptr(new EnderCrystal(level)); + shared_ptr enderCrystal = std::make_shared(level); enderCrystal->moveTo(x + 0.5f, y + hh, z + 0.5f, random->nextFloat() * 360, 0); level->addEntity(enderCrystal); placeBlock(level, x, y + hh, z, Tile::unbreakable_Id, 0); diff --git a/Minecraft.World/Squid.cpp b/Minecraft.World/Squid.cpp index 4539d5ee9..f1b660ebe 100644 --- a/Minecraft.World/Squid.cpp +++ b/Minecraft.World/Squid.cpp @@ -81,7 +81,7 @@ void Squid::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) int count = random->nextInt(3 + playerBonusLevel) + 1; for (int i = 0; i < count; i++) { - spawnAtLocation(shared_ptr( new ItemInstance(Item::dye_powder, 1, DyePowderItem::BLACK) ), 0.0f); + spawnAtLocation(std::make_shared(Item::dye_powder, 1, DyePowderItem::BLACK), 0.0f); } } diff --git a/Minecraft.World/StemTile.cpp b/Minecraft.World/StemTile.cpp index 445c88e4a..33bb7c795 100644 --- a/Minecraft.World/StemTile.cpp +++ b/Minecraft.World/StemTile.cpp @@ -189,7 +189,7 @@ void StemTile::spawnResources(Level *level, int x, int y, int z, int data, float if (fruit == Tile::melon) seed = Item::seeds_melon; for (int i = 0; i < 3; i++) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(seed))); + popResource(level, x, y, z, std::make_shared(seed)); } } diff --git a/Minecraft.World/StoneMonsterTile.cpp b/Minecraft.World/StoneMonsterTile.cpp index ec31992ff..fd3f1b90e 100644 --- a/Minecraft.World/StoneMonsterTile.cpp +++ b/Minecraft.World/StoneMonsterTile.cpp @@ -48,7 +48,7 @@ void StoneMonsterTile::destroy(Level *level, int x, int y, int z, int data) // Also limit the amount of silverfish specifically if(level->countInstanceOf( eTYPE_SILVERFISH, true) < 15 ) { - shared_ptr silverfish = shared_ptr(new Silverfish(level)); + shared_ptr silverfish = std::make_shared(level); silverfish->moveTo(x + .5, y, z + .5, 0, 0); level->addEntity(silverfish); @@ -106,7 +106,7 @@ shared_ptr StoneMonsterTile::getSilkTouchItemInstance(int data) { tile = Tile::stoneBrick; } - return shared_ptr(new ItemInstance(tile)); + return std::make_shared(tile); } int StoneMonsterTile::cloneTileData(Level *level, int x, int y, int z) diff --git a/Minecraft.World/StoneSlabTile.cpp b/Minecraft.World/StoneSlabTile.cpp index e4de58dab..10f1ee71c 100644 --- a/Minecraft.World/StoneSlabTile.cpp +++ b/Minecraft.World/StoneSlabTile.cpp @@ -80,5 +80,5 @@ int StoneSlabTile::getAuxName(int auxValue) shared_ptr StoneSlabTile::getSilkTouchItemInstance(int data) { - return shared_ptr(new ItemInstance(Tile::stoneSlabHalf_Id, 2, data & TYPE_MASK)); + return std::make_shared(Tile::stoneSlabHalf_Id, 2, data & TYPE_MASK); } diff --git a/Minecraft.World/SynchedEntityData.cpp b/Minecraft.World/SynchedEntityData.cpp index 2c126f562..69d419b0d 100644 --- a/Minecraft.World/SynchedEntityData.cpp +++ b/Minecraft.World/SynchedEntityData.cpp @@ -19,7 +19,7 @@ void SynchedEntityData::define(int id, int value) MemSect(17); checkId(id); int type = TYPE_INT; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -30,7 +30,7 @@ void SynchedEntityData::define(int id, byte value) MemSect(17); checkId(id); int type = TYPE_BYTE; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -41,7 +41,7 @@ void SynchedEntityData::define(int id, short value) MemSect(17); checkId(id); int type = TYPE_SHORT; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -52,7 +52,7 @@ void SynchedEntityData::define(int id, float value) MemSect(17); checkId(id); int type = TYPE_FLOAT; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -63,7 +63,7 @@ void SynchedEntityData::define(int id, const wstring& value) MemSect(17); checkId(id); int type = TYPE_STRING; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, value) ); + shared_ptr dataItem = std::make_shared(type, id, value); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -74,7 +74,7 @@ void SynchedEntityData::defineNULL(int id, void *pVal) MemSect(17); checkId(id); int type = TYPE_ITEMINSTANCE; - shared_ptr dataItem = shared_ptr( new DataItem(type, id, shared_ptr()) ); + shared_ptr dataItem = std::make_shared(type, id, shared_ptr()); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -360,34 +360,34 @@ vector > *SynchedEntityData::unpack(Data case TYPE_BYTE: { byte dataRead = input->readByte(); - item = shared_ptr( new DataItem(itemType, itemId, dataRead) ); + item = std::make_shared(itemType, itemId, dataRead); } break; case TYPE_SHORT: { short dataRead = input->readShort(); - item = shared_ptr( new DataItem(itemType, itemId, dataRead) ); + item = std::make_shared(itemType, itemId, dataRead); } break; case TYPE_INT: { int dataRead = input->readInt(); - item = shared_ptr( new DataItem(itemType, itemId, dataRead) ); + item = std::make_shared(itemType, itemId, dataRead); } break; case TYPE_FLOAT: { float dataRead = input->readFloat(); - item = shared_ptr( new DataItem(itemType, itemId, dataRead) ); + item = std::make_shared(itemType, itemId, dataRead); } break; case TYPE_STRING: - item = shared_ptr( new DataItem(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)) ); + item = std::make_shared(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)); break; case TYPE_ITEMINSTANCE: { - item = shared_ptr(new DataItem(itemType, itemId, Packet::readItem(input))); + item = std::make_shared(itemType, itemId, Packet::readItem(input)); } break; default: diff --git a/Minecraft.World/TakeItemEntityPacket.h b/Minecraft.World/TakeItemEntityPacket.h index 7c4b45fe9..7acbfdc46 100644 --- a/Minecraft.World/TakeItemEntityPacket.h +++ b/Minecraft.World/TakeItemEntityPacket.h @@ -17,6 +17,6 @@ class TakeItemEntityPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new TakeItemEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 22; } }; \ No newline at end of file diff --git a/Minecraft.World/TallGrass.cpp b/Minecraft.World/TallGrass.cpp index bf8899103..337e343d2 100644 --- a/Minecraft.World/TallGrass.cpp +++ b/Minecraft.World/TallGrass.cpp @@ -89,7 +89,7 @@ void TallGrass::playerDestroy(Level *level, shared_ptr player, int x, in ); // drop leaf block instead of sapling - popResource(level, x, y, z, shared_ptr(new ItemInstance(Tile::tallgrass, 1, data))); + popResource(level, x, y, z, std::make_shared(Tile::tallgrass, 1, data)); } else { diff --git a/Minecraft.World/TeleportEntityPacket.h b/Minecraft.World/TeleportEntityPacket.h index 6fc28732b..38e09286b 100644 --- a/Minecraft.World/TeleportEntityPacket.h +++ b/Minecraft.World/TeleportEntityPacket.h @@ -22,6 +22,6 @@ class TeleportEntityPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new TeleportEntityPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 34; } }; \ No newline at end of file diff --git a/Minecraft.World/TextureAndGeometryChangePacket.h b/Minecraft.World/TextureAndGeometryChangePacket.h index dabe78fae..812222fc1 100644 --- a/Minecraft.World/TextureAndGeometryChangePacket.h +++ b/Minecraft.World/TextureAndGeometryChangePacket.h @@ -20,6 +20,6 @@ class TextureAndGeometryChangePacket : public Packet, public enable_shared_from_ virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new TextureAndGeometryChangePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 161; } }; \ No newline at end of file diff --git a/Minecraft.World/TextureChangePacket.h b/Minecraft.World/TextureChangePacket.h index 959fc4feb..81f45f4ce 100644 --- a/Minecraft.World/TextureChangePacket.h +++ b/Minecraft.World/TextureChangePacket.h @@ -25,6 +25,6 @@ class TextureChangePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new TextureChangePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 157; } }; \ No newline at end of file diff --git a/Minecraft.World/TheEndBiomeDecorator.cpp b/Minecraft.World/TheEndBiomeDecorator.cpp index 0ab1f7669..2b80bcfca 100644 --- a/Minecraft.World/TheEndBiomeDecorator.cpp +++ b/Minecraft.World/TheEndBiomeDecorator.cpp @@ -58,7 +58,7 @@ void TheEndBiomeDecorator::decorate() } if (xo == 0 && zo == 0) { - shared_ptr enderDragon = shared_ptr(new EnderDragon(level)); + shared_ptr enderDragon = std::make_shared(level); enderDragon->AddParts(); // 4J added enderDragon->moveTo(0, 128, 0, random->nextFloat() * 360, 0); level->addEntity(enderDragon); diff --git a/Minecraft.World/TheEndPortal.cpp b/Minecraft.World/TheEndPortal.cpp index 0298ca48b..c3e5cbf56 100644 --- a/Minecraft.World/TheEndPortal.cpp +++ b/Minecraft.World/TheEndPortal.cpp @@ -28,7 +28,7 @@ TheEndPortal::TheEndPortal(int id, Material *material) : BaseEntityTile(id, mate shared_ptr TheEndPortal::newTileEntity(Level *level) { - return shared_ptr(new TheEndPortalTileEntity()); + return std::make_shared(); } void TheEndPortal::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr forceEntity) // 4J added forceData, forceEntity param diff --git a/Minecraft.World/TheEndPortalTileEntity.cpp b/Minecraft.World/TheEndPortalTileEntity.cpp index fa9b35447..63c0af56a 100644 --- a/Minecraft.World/TheEndPortalTileEntity.cpp +++ b/Minecraft.World/TheEndPortalTileEntity.cpp @@ -4,7 +4,7 @@ // 4J Added shared_ptr TheEndPortalTileEntity::clone() { - shared_ptr result = shared_ptr( new TheEndPortalTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); return result; } \ No newline at end of file diff --git a/Minecraft.World/ThinFenceTile.cpp b/Minecraft.World/ThinFenceTile.cpp index cbfdd2fe0..65638ef6e 100644 --- a/Minecraft.World/ThinFenceTile.cpp +++ b/Minecraft.World/ThinFenceTile.cpp @@ -144,7 +144,7 @@ bool ThinFenceTile::isSilkTouchable() shared_ptr ThinFenceTile::getSilkTouchItemInstance(int data) { - return shared_ptr(new ItemInstance(id, 1, data)); + return std::make_shared(id, 1, data); } void ThinFenceTile::registerIcons(IconRegister *iconRegister) diff --git a/Minecraft.World/ThrownEgg.cpp b/Minecraft.World/ThrownEgg.cpp index 7bf85d71b..9bdfae106 100644 --- a/Minecraft.World/ThrownEgg.cpp +++ b/Minecraft.World/ThrownEgg.cpp @@ -47,7 +47,7 @@ void ThrownEgg::onHit(HitResult *res) if (random->nextInt(32) == 0) count = 4; for (int i = 0; i < count; i++) { - shared_ptr chicken = shared_ptr( new Chicken(level) ); + shared_ptr chicken = std::make_shared(level); chicken->setAge(-20 * 60 * 20); chicken->moveTo(x, y, z, yRot, 0); diff --git a/Minecraft.World/ThrownExpBottle.cpp b/Minecraft.World/ThrownExpBottle.cpp index c700bdc56..acab0d055 100644 --- a/Minecraft.World/ThrownExpBottle.cpp +++ b/Minecraft.World/ThrownExpBottle.cpp @@ -47,7 +47,7 @@ void ThrownExpBottle::onHit(HitResult *res) { int newCount = ExperienceOrb::getExperienceValue(xpCount); xpCount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x, y, z, newCount) ) ); + level->addEntity(std::make_shared(level, x, y, z, newCount)); } remove(); diff --git a/Minecraft.World/ThrownPotion.cpp b/Minecraft.World/ThrownPotion.cpp index 6e0618582..170f64745 100644 --- a/Minecraft.World/ThrownPotion.cpp +++ b/Minecraft.World/ThrownPotion.cpp @@ -31,7 +31,7 @@ ThrownPotion::ThrownPotion(Level *level, shared_ptr mob, int potio { _init(); - potionItem = shared_ptr( new ItemInstance(Item::potion, 1, potionValue)); + potionItem = std::make_shared(Item::potion, 1, potionValue); } ThrownPotion::ThrownPotion(Level *level, shared_ptr mob, shared_ptr potion) : Throwable(level, mob) @@ -45,7 +45,7 @@ ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, int potio { _init(); - potionItem = shared_ptr( new ItemInstance(Item::potion, 1, potionValue)); + potionItem = std::make_shared(Item::potion, 1, potionValue); } ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, shared_ptr potion) : Throwable(level, x, y, z) @@ -72,13 +72,13 @@ float ThrownPotion::getThrowUpAngleOffset() void ThrownPotion::setPotionValue(int potionValue) { - if (potionItem == nullptr) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); + if (potionItem == nullptr) potionItem = std::make_shared(Item::potion, 1, 0); potionItem->setAuxValue(potionValue); } int ThrownPotion::getPotionValue() { - if (potionItem == nullptr) potionItem = shared_ptr( new ItemInstance(Item::potion, 1, 0) ); + if (potionItem == nullptr) potionItem = std::make_shared(Item::potion, 1, 0); return potionItem->getAuxValue(); } diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp index 7ab09928f..6abd69ce3 100644 --- a/Minecraft.World/Tile.cpp +++ b/Minecraft.World/Tile.cpp @@ -917,7 +917,7 @@ void Tile::spawnResources(Level *level, int x, int y, int z, int data, float odd int type = getResource(data, level->random, playerBonusLevel); if (type <= 0) continue; - popResource(level, x, y, z, shared_ptr( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) ); + popResource(level, x, y, z, std::make_shared(type, 1, getSpawnResourcesAuxValue(data))); } } @@ -929,7 +929,7 @@ void Tile::popResource(Level *level, int x, int y, int z, shared_ptrrandom->nextFloat() * s + (1 - s) * 0.5; double yo = level->random->nextFloat() * s + (1 - s) * 0.5; double zo = level->random->nextFloat() * s + (1 - s) * 0.5; - shared_ptr item = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); + shared_ptr item = std::make_shared(level, x + xo, y + yo, z + zo, itemInstance); item->throwTime = 10; level->addEntity(item); } @@ -943,7 +943,7 @@ void Tile::popExperience(Level *level, int x, int y, int z, int amount) { int newCount = ExperienceOrb::getExperienceValue(amount); amount -= newCount; - level->addEntity(shared_ptr( new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount))); + level->addEntity(std::make_shared(level, x + .5, y + .5, z + .5, newCount)); } } } @@ -1257,7 +1257,7 @@ shared_ptr Tile::getSilkTouchItemInstance(int data) { popData = data; } - return shared_ptr(new ItemInstance(id, 1, popData)); + return std::make_shared(id, 1, popData); } int Tile::getResourceCountForLootBonus(int bonusLevel, Random *random) diff --git a/Minecraft.World/TileDestructionPacket.h b/Minecraft.World/TileDestructionPacket.h index 20cd7db99..765093490 100644 --- a/Minecraft.World/TileDestructionPacket.h +++ b/Minecraft.World/TileDestructionPacket.h @@ -30,6 +30,6 @@ class TileDestructionPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new TileDestructionPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 55; } }; \ No newline at end of file diff --git a/Minecraft.World/TileEditorOpenPacket.h b/Minecraft.World/TileEditorOpenPacket.h index 20a731bb9..ee68a6cf0 100644 --- a/Minecraft.World/TileEditorOpenPacket.h +++ b/Minecraft.World/TileEditorOpenPacket.h @@ -20,6 +20,6 @@ class TileEditorOpenPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new TileEditorOpenPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 133; } }; \ No newline at end of file diff --git a/Minecraft.World/TileEntityDataPacket.h b/Minecraft.World/TileEntityDataPacket.h index 2ee998f39..6fe3bf899 100644 --- a/Minecraft.World/TileEntityDataPacket.h +++ b/Minecraft.World/TileEntityDataPacket.h @@ -31,6 +31,6 @@ class TileEntityDataPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new TileEntityDataPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 132; } }; \ No newline at end of file diff --git a/Minecraft.World/TileEventPacket.h b/Minecraft.World/TileEventPacket.h index ca2685fae..f587b1fff 100644 --- a/Minecraft.World/TileEventPacket.h +++ b/Minecraft.World/TileEventPacket.h @@ -17,6 +17,6 @@ class TileEventPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new TileEventPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 54; } }; \ No newline at end of file diff --git a/Minecraft.World/TileUpdatePacket.h b/Minecraft.World/TileUpdatePacket.h index fe69c7639..c9bb93ce2 100644 --- a/Minecraft.World/TileUpdatePacket.h +++ b/Minecraft.World/TileUpdatePacket.h @@ -18,6 +18,6 @@ class TileUpdatePacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new TileUpdatePacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 53; } }; \ No newline at end of file diff --git a/Minecraft.World/TimeCommand.cpp b/Minecraft.World/TimeCommand.cpp index 4ac23c947..05147983f 100644 --- a/Minecraft.World/TimeCommand.cpp +++ b/Minecraft.World/TimeCommand.cpp @@ -81,5 +81,5 @@ shared_ptr TimeCommand::preparePacket(bool night) dos.writeBoolean(night); - return shared_ptr( new GameCommandPacket(eGameCommand_Time, baos.toByteArray() )); + return std::make_shared(eGameCommand_Time, baos.toByteArray()); } \ No newline at end of file diff --git a/Minecraft.World/TntTile.cpp b/Minecraft.World/TntTile.cpp index 1b16a3752..eff9efae6 100644 --- a/Minecraft.World/TntTile.cpp +++ b/Minecraft.World/TntTile.cpp @@ -57,7 +57,7 @@ void TntTile::wasExploded(Level *level, int x, int y, int z, Explosion *explosio // 4J-JEV: Fix for #90934 - Customer Encountered: TU11: Content: Gameplay: TNT blocks are triggered by explosions even though "TNT explodes" option is unchecked. if( level->newPrimedTntAllowed() && app.GetGameHostOption(eGameHostOption_TNT) ) { - shared_ptr primed = shared_ptr( new PrimedTnt(level, x + 0.5f, y + 0.5f, z + 0.5f, explosion->getSourceMob()) ); + shared_ptr primed = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, explosion->getSourceMob()); primed->life = level->random->nextInt(primed->life / 4) + primed->life / 8; level->addEntity(primed); } @@ -77,7 +77,7 @@ void TntTile::destroy(Level *level, int x, int y, int z, int data, shared_ptr
  • newPrimedTntAllowed() && app.GetGameHostOption(eGameHostOption_TNT) ) { - shared_ptr tnt = shared_ptr( new PrimedTnt(level, x + 0.5f, y + 0.5f, z + 0.5f, source) ); + shared_ptr tnt = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, source); level->addEntity(tnt); level->playEntitySound(tnt, eSoundType_RANDOM_FUSE, 1, 1.0f); } diff --git a/Minecraft.World/ToggleDownfallCommand.cpp b/Minecraft.World/ToggleDownfallCommand.cpp index 1d0a4d9eb..526be3534 100644 --- a/Minecraft.World/ToggleDownfallCommand.cpp +++ b/Minecraft.World/ToggleDownfallCommand.cpp @@ -31,5 +31,5 @@ void ToggleDownfallCommand::doToggleDownfall() shared_ptr ToggleDownfallCommand::preparePacket() { - return shared_ptr( new GameCommandPacket(eGameCommand_ToggleDownfall, byteArray() )); + return std::make_shared(eGameCommand_ToggleDownfall, byteArray()); } \ No newline at end of file diff --git a/Minecraft.World/TopSnowTile.cpp b/Minecraft.World/TopSnowTile.cpp index d165500cf..7719f8388 100644 --- a/Minecraft.World/TopSnowTile.cpp +++ b/Minecraft.World/TopSnowTile.cpp @@ -100,7 +100,7 @@ void TopSnowTile::playerDestroy(Level *level, shared_ptr player, int x, { int type = Item::snowBall->id; int height = data & HEIGHT_MASK; - popResource(level, x, y, z, shared_ptr( new ItemInstance(type, height + 1, 0))); + popResource(level, x, y, z, std::make_shared(type, height + 1, 0)); level->removeTile(x, y, z); } diff --git a/Minecraft.World/TradeItemPacket.h b/Minecraft.World/TradeItemPacket.h index ecd0f7070..6a23ce7aa 100644 --- a/Minecraft.World/TradeItemPacket.h +++ b/Minecraft.World/TradeItemPacket.h @@ -25,7 +25,7 @@ class TradeItemPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new TradeItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 151; } }; diff --git a/Minecraft.World/TreeTile.cpp b/Minecraft.World/TreeTile.cpp index 642d8fbba..6a5860f3a 100644 --- a/Minecraft.World/TreeTile.cpp +++ b/Minecraft.World/TreeTile.cpp @@ -81,7 +81,7 @@ int TreeTile::getWoodType(int data) shared_ptr TreeTile::getSilkTouchItemInstance(int data) { // fix to avoid getting silktouched sideways logs - return shared_ptr(new ItemInstance(id, 1, getWoodType(data))); + return std::make_shared(id, 1, getWoodType(data)); } void TreeTile::registerIcons(IconRegister *iconRegister) diff --git a/Minecraft.World/UpdateAttributesPacket.h b/Minecraft.World/UpdateAttributesPacket.h index 77ba08be5..4f604e0db 100644 --- a/Minecraft.World/UpdateAttributesPacket.h +++ b/Minecraft.World/UpdateAttributesPacket.h @@ -41,6 +41,6 @@ class UpdateAttributesPacket : public Packet, public enable_shared_from_this getValues(); public: - static shared_ptr create() { return shared_ptr(new UpdateAttributesPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 44; } }; \ No newline at end of file diff --git a/Minecraft.World/UpdateGameRuleProgressPacket.cpp b/Minecraft.World/UpdateGameRuleProgressPacket.cpp index 6f6530d4f..d88560114 100644 --- a/Minecraft.World/UpdateGameRuleProgressPacket.cpp +++ b/Minecraft.World/UpdateGameRuleProgressPacket.cpp @@ -5,13 +5,9 @@ -UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket() +// UpdateGameRuleProgressPacket() default constructor +UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket() : m_icon(0), m_auxValue(0), m_dataTag(0) { - m_messageId = L""; - m_icon = -1; - m_auxValue = 0; - m_definitionType = ConsoleGameRules::eGameRuleType_LevelRules; - m_dataTag = 0; } UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket(ConsoleGameRules::EGameRuleType definitionType, const wstring &messageId, int icon, int auxValue, int dataTag, void *data, int dataLength) diff --git a/Minecraft.World/UpdateMobEffectPacket.h b/Minecraft.World/UpdateMobEffectPacket.h index 39eb98e9b..48462550c 100644 --- a/Minecraft.World/UpdateMobEffectPacket.h +++ b/Minecraft.World/UpdateMobEffectPacket.h @@ -24,6 +24,6 @@ class UpdateMobEffectPacket : public Packet, public enable_shared_from_this packet); public: - static shared_ptr create() { return shared_ptr(new UpdateMobEffectPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 41; } }; \ No newline at end of file diff --git a/Minecraft.World/UpdateProgressPacket.h b/Minecraft.World/UpdateProgressPacket.h index beca65097..1643fb63c 100644 --- a/Minecraft.World/UpdateProgressPacket.h +++ b/Minecraft.World/UpdateProgressPacket.h @@ -20,6 +20,6 @@ class UpdateProgressPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new UpdateProgressPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 156; } }; \ No newline at end of file diff --git a/Minecraft.World/UseItemPacket.h b/Minecraft.World/UseItemPacket.h index 44e20457c..ce4635ba0 100644 --- a/Minecraft.World/UseItemPacket.h +++ b/Minecraft.World/UseItemPacket.h @@ -31,6 +31,6 @@ class UseItemPacket : public Packet, public enable_shared_from_this create() { return shared_ptr(new UseItemPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 15; } }; diff --git a/Minecraft.World/Village.cpp b/Minecraft.World/Village.cpp index 705815b95..b7c82fa4f 100644 --- a/Minecraft.World/Village.cpp +++ b/Minecraft.World/Village.cpp @@ -71,7 +71,7 @@ void Village::tick(int tick) Vec3 *spawnPos = findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2); if (spawnPos != nullptr) { - shared_ptr vg = shared_ptr( new VillagerGolem(level) ); + shared_ptr vg = std::make_shared(level); vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z); level->addEntity(vg); ++golemCount; @@ -422,7 +422,7 @@ void Village::readAdditionalSaveData(CompoundTag *tag) { CompoundTag *dTag = doorTags->get(i); - shared_ptr door = shared_ptr(new DoorInfo(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS"))); + shared_ptr door = std::make_shared(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS")); doorInfos.push_back(door); } diff --git a/Minecraft.World/VillagePieces.cpp b/Minecraft.World/VillagePieces.cpp index fbdf05a7e..dcd765e01 100644 --- a/Minecraft.World/VillagePieces.cpp +++ b/Minecraft.World/VillagePieces.cpp @@ -391,7 +391,7 @@ void VillagePieces::VillagePiece::spawnVillagers(Level *level, BoundingBox *chun { spawnedVillagerCount++; - shared_ptr villager = shared_ptr(new Villager(level, getVillagerProfession(i))); + shared_ptr villager = std::make_shared(level, getVillagerProfession(i)); villager->moveTo(worldX + 0.5, worldY, worldZ + 0.5, 0, 0); level->addEntity(villager); } diff --git a/Minecraft.World/VillageSiege.cpp b/Minecraft.World/VillageSiege.cpp index 525b0b36d..5a39b6ebe 100644 --- a/Minecraft.World/VillageSiege.cpp +++ b/Minecraft.World/VillageSiege.cpp @@ -130,7 +130,7 @@ bool VillageSiege::trySpawn() if (spawnPos == nullptr) return false; shared_ptr mob; { - mob = shared_ptr( new Zombie(level) ); + mob = std::make_shared(level); mob->finalizeMobSpawn(nullptr); mob->setVillager(false); } diff --git a/Minecraft.World/Villager.cpp b/Minecraft.World/Villager.cpp index 26f5e5740..7179f57d7 100644 --- a/Minecraft.World/Villager.cpp +++ b/Minecraft.World/Villager.cpp @@ -420,7 +420,7 @@ void Villager::addOffers(int addCount) addItemForPurchase(newOffers, Item::arrow_Id, random, getRecipeChance(.5f)); if (random->nextFloat() < getRecipeChance(.5f)) { - newOffers->push_back(new MerchantRecipe(shared_ptr( new ItemInstance(Tile::gravel, 10) ), shared_ptr( new ItemInstance(Item::emerald) ), shared_ptr( new ItemInstance(Item::flint_Id, 4 + random->nextInt(2), 0)))); + newOffers->push_back(new MerchantRecipe(std::make_shared(Tile::gravel, 10), std::make_shared(Item::emerald), std::make_shared(Item::flint_Id, 4 + random->nextInt(2), 0))); } break; case PROFESSION_BUTCHER: @@ -480,7 +480,7 @@ void Villager::addOffers(int addCount) shared_ptr book = Item::enchantedBook->createForEnchantment(new EnchantmentInstance(enchantment, level)); int cost = 2 + random->nextInt(5 + (level * 10)) + 3 * level; - newOffers->push_back(new MerchantRecipe(shared_ptr(new ItemInstance(Item::book)), shared_ptr(new ItemInstance(Item::emerald, cost)), book)); + newOffers->push_back(new MerchantRecipe(std::make_shared(Item::book), std::make_shared(Item::emerald, cost), book)); } break; case PROFESSION_PRIEST: @@ -498,9 +498,9 @@ void Villager::addOffers(int addCount) int id = enchantItems[i]; if (random->nextFloat() < getRecipeChance(.05f)) { - newOffers->push_back(new MerchantRecipe(shared_ptr(new ItemInstance(id, 1, 0)), - shared_ptr(new ItemInstance(Item::emerald, 2 + random->nextInt(3), 0)), - EnchantmentHelper::enchantItem(random, shared_ptr(new ItemInstance(id, 1, 0)), 5 + random->nextInt(15)))); + newOffers->push_back(new MerchantRecipe(std::make_shared(id, 1, 0), + std::make_shared(Item::emerald, 2 + random->nextInt(3), 0), + EnchantmentHelper::enchantItem(random, std::make_shared(id, 1, 0), 5 + random->nextInt(15)))); } } } @@ -622,7 +622,7 @@ void Villager::addItemForTradeIn(MerchantRecipeList *list, int itemId, Random *r shared_ptr Villager::getItemTradeInValue(int itemId, Random *random) { - return shared_ptr(new ItemInstance(itemId, getTradeInValue(itemId, random), 0)); + return std::make_shared(itemId, getTradeInValue(itemId, random), 0); } int Villager::getTradeInValue(int itemId, Random *random) @@ -658,13 +658,13 @@ void Villager::addItemForPurchase(MerchantRecipeList *list, int itemId, Random * shared_ptr resultItem; if (purchaseCost < 0) { - rubyItem = shared_ptr( new ItemInstance(Item::emerald_Id, 1, 0) ); - resultItem = shared_ptr( new ItemInstance(itemId, -purchaseCost, 0) ); + rubyItem = std::make_shared(Item::emerald_Id, 1, 0); + resultItem = std::make_shared(itemId, -purchaseCost, 0); } else { - rubyItem = shared_ptr( new ItemInstance(Item::emerald_Id, purchaseCost, 0) ); - resultItem = shared_ptr( new ItemInstance(itemId, 1, 0) ); + rubyItem = std::make_shared(Item::emerald_Id, purchaseCost, 0); + resultItem = std::make_shared(itemId, 1, 0); } list->push_back(new MerchantRecipe(rubyItem, resultItem)); } @@ -735,7 +735,7 @@ shared_ptr Villager::getBreedOffspring(shared_ptr target) // 4J - added limit to villagers that can be bred if(level->canCreateMore(GetType(), Level::eSpawnType_Breed) ) { - shared_ptr villager = shared_ptr(new Villager(level)); + shared_ptr villager = std::make_shared(level); villager->finalizeMobSpawn(nullptr); return villager; } diff --git a/Minecraft.World/Villages.cpp b/Minecraft.World/Villages.cpp index d73d568d5..432a8b6b9 100644 --- a/Minecraft.World/Villages.cpp +++ b/Minecraft.World/Villages.cpp @@ -127,7 +127,7 @@ void Villages::cluster() if (found) continue; // create new Village - shared_ptr village = shared_ptr(new Village(level)); + shared_ptr village = std::make_shared(level); village->addDoorInfo(di); villages.push_back(village); setDirty(); @@ -181,7 +181,7 @@ void Villages::createDoorInfo(int x, int y, int z) if (level->canSeeSky(x + i, y, z)) canSeeX--; for (int i = 1; i <= 5; ++i) if (level->canSeeSky(x + i, y, z)) canSeeX++; - if (canSeeX != 0) unclustered.push_back(shared_ptr(new DoorInfo(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick))); + if (canSeeX != 0) unclustered.push_back(std::make_shared(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick)); } else { @@ -190,7 +190,7 @@ void Villages::createDoorInfo(int x, int y, int z) if (level->canSeeSky(x, y, z + i)) canSeeZ--; for (int i = 1; i <= 5; ++i) if (level->canSeeSky(x, y, z + i)) canSeeZ++; - if (canSeeZ != 0) unclustered.push_back(shared_ptr(new DoorInfo(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick))); + if (canSeeZ != 0) unclustered.push_back(std::make_shared(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick)); } } @@ -218,7 +218,7 @@ void Villages::load(CompoundTag *tag) for (int i = 0; i < villageTags->size(); i++) { CompoundTag *compoundTag = villageTags->get(i); - shared_ptr village = shared_ptr(new Village()); + shared_ptr village = std::make_shared(); village->readAdditionalSaveData(compoundTag); villages.push_back(village); } diff --git a/Minecraft.World/VineTile.cpp b/Minecraft.World/VineTile.cpp index 2403c69aa..8f16a9214 100644 --- a/Minecraft.World/VineTile.cpp +++ b/Minecraft.World/VineTile.cpp @@ -379,7 +379,7 @@ void VineTile::playerDestroy(Level *level, shared_ptrplayer, int x, int ); // drop leaf block instead of sapling - popResource(level, x, y, z, shared_ptr(new ItemInstance(Tile::vine, 1, 0))); + popResource(level, x, y, z, std::make_shared(Tile::vine, 1, 0)); } else { diff --git a/Minecraft.World/WeighedTreasure.cpp b/Minecraft.World/WeighedTreasure.cpp index 37b04fffc..3c20ae666 100644 --- a/Minecraft.World/WeighedTreasure.cpp +++ b/Minecraft.World/WeighedTreasure.cpp @@ -6,7 +6,7 @@ WeighedTreasure::WeighedTreasure(int itemId, int auxValue, int minCount, int maxCount, int weight) : WeighedRandomItem(weight) { - this->item = shared_ptr( new ItemInstance(itemId, 1, auxValue) ); + this->item = std::make_shared(itemId, 1, auxValue); this->minCount = minCount; this->maxCount = maxCount; } diff --git a/Minecraft.World/Witch.cpp b/Minecraft.World/Witch.cpp index 6f8f4941f..375c83886 100644 --- a/Minecraft.World/Witch.cpp +++ b/Minecraft.World/Witch.cpp @@ -135,7 +135,7 @@ void Witch::aiStep() if (potion > -1) { - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::potion, 1, potion)) ); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::potion, 1, potion)); usingTime = getCarriedItem()->getUseDuration(); setUsingItem(true); AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); @@ -198,7 +198,7 @@ void Witch::performRangedAttack(shared_ptr target, float power) { if (isUsingItem()) return; - shared_ptr potion = shared_ptr( new ThrownPotion(level, dynamic_pointer_cast(shared_from_this()), PotionBrewing::POTION_ID_SPLASH_DAMAGE) ); + shared_ptr potion = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), PotionBrewing::POTION_ID_SPLASH_DAMAGE); potion->xRot -= -20; double xd = (target->x + target->xd) - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - y; diff --git a/Minecraft.World/WitherBoss.cpp b/Minecraft.World/WitherBoss.cpp index ceb64df2f..af406a93a 100644 --- a/Minecraft.World/WitherBoss.cpp +++ b/Minecraft.World/WitherBoss.cpp @@ -437,7 +437,7 @@ void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz, double yd = ty - hy; double zd = tz - hz; - shared_ptr ie = shared_ptr( new WitherSkull(level, dynamic_pointer_cast(shared_from_this()), xd, yd, zd) ); + shared_ptr ie = std::make_shared(level, dynamic_pointer_cast(shared_from_this()), xd, yd, zd); if (dangerous) ie->setDangerous(true); ie->y = hy; ie->x = hx; diff --git a/Minecraft.World/Wolf.cpp b/Minecraft.World/Wolf.cpp index 55088ffd0..7588a67b0 100644 --- a/Minecraft.World/Wolf.cpp +++ b/Minecraft.World/Wolf.cpp @@ -517,7 +517,7 @@ shared_ptr Wolf::getBreedOffspring(shared_ptr target) // 4J - added limit to wolves that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - shared_ptr pBabyWolf = shared_ptr( new Wolf(level) ); + shared_ptr pBabyWolf = std::make_shared(level); if(!getOwnerUUID().empty()) { diff --git a/Minecraft.World/WoodSlabTile.cpp b/Minecraft.World/WoodSlabTile.cpp index ba3a98e50..574dab932 100644 --- a/Minecraft.World/WoodSlabTile.cpp +++ b/Minecraft.World/WoodSlabTile.cpp @@ -33,7 +33,7 @@ int WoodSlabTile::getResource(int data, Random *random, int playerBonusLevel) shared_ptr WoodSlabTile::getSilkTouchItemInstance(int data) { - return shared_ptr(new ItemInstance(Tile::woodSlabHalf, 2, data & TYPE_MASK)); + return std::make_shared(Tile::woodSlabHalf, 2, data & TYPE_MASK); } int WoodSlabTile::getAuxName(int auxValue) diff --git a/Minecraft.World/XZPacket.h b/Minecraft.World/XZPacket.h index 0c4115e07..41b6c30d0 100644 --- a/Minecraft.World/XZPacket.h +++ b/Minecraft.World/XZPacket.h @@ -25,6 +25,6 @@ class XZPacket : public Packet, public enable_shared_from_this virtual int getEstimatedSize(); public: - static shared_ptr create() { return shared_ptr(new XZPacket()); } + static shared_ptr create() { return std::make_shared(); } virtual int getId() { return 166; } }; \ No newline at end of file diff --git a/Minecraft.World/Zombie.cpp b/Minecraft.World/Zombie.cpp index aba3fb2ab..76e129639 100644 --- a/Minecraft.World/Zombie.cpp +++ b/Minecraft.World/Zombie.cpp @@ -162,7 +162,7 @@ bool Zombie::hurt(DamageSource *source, float dmg) int x = Mth::floor(this->x); int y = Mth::floor(this->y); int z = Mth::floor(this->z); - shared_ptr reinforcement = shared_ptr( new Zombie(level) ); + shared_ptr reinforcement = std::make_shared(level); for (int i = 0; i < REINFORCEMENT_ATTEMPTS; i++) { @@ -281,11 +281,11 @@ void Zombie::populateDefaultEquipmentSlots() int rand = random->nextInt(3); if (rand == 0) { - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::sword_iron)) ); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::sword_iron)); } else { - setEquippedSlot(SLOT_WEAPON, shared_ptr( new ItemInstance(Item::shovel_iron)) ); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::shovel_iron)); } } } @@ -316,7 +316,7 @@ void Zombie::killed(shared_ptr mob) { if (level->difficulty == Difficulty::NORMAL && random->nextBoolean()) return; - shared_ptr zombie = shared_ptr(new Zombie(level)); + shared_ptr zombie = std::make_shared(level); zombie->copyPosition(mob); level->removeEntity(mob); zombie->finalizeMobSpawn(nullptr); @@ -366,7 +366,7 @@ MobGroupData *Zombie::finalizeMobSpawn(MobGroupData *groupData, int extraData /* { // Halloween! OooOOo! 25% of all skeletons/zombies can wear // pumpkins on their heads. - setEquippedSlot(SLOT_HELM, shared_ptr( new ItemInstance(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin) )); + setEquippedSlot(SLOT_HELM, std::make_shared(random->nextFloat() < 0.1f ? Tile::litPumpkin : Tile::pumpkin)); dropChances[SLOT_HELM] = 0; } } @@ -446,7 +446,7 @@ bool Zombie::isConverting() void Zombie::finishConversion() { - shared_ptr villager = shared_ptr(new Villager(level)); + shared_ptr villager = std::make_shared(level); villager->copyPosition(shared_from_this()); villager->finalizeMobSpawn(nullptr); villager->setRewardPlayersInVillage(); diff --git a/Minecraft.World/ZoomLayer.cpp b/Minecraft.World/ZoomLayer.cpp index bef24709c..f14837dce 100644 --- a/Minecraft.World/ZoomLayer.cpp +++ b/Minecraft.World/ZoomLayer.cpp @@ -86,7 +86,7 @@ shared_ptrZoomLayer::zoom(__int64 seed, shared_ptr sup, int count) shared_ptrresult = sup; for (int i = 0; i < count; i++) { - result = shared_ptr(new ZoomLayer(seed + i, result)); + result = std::make_shared(seed + i, result); } return result; } \ No newline at end of file From 5acd0e1c9f01405f90c814e6c765a101503baefb Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Sat, 7 Mar 2026 16:20:44 -0500 Subject: [PATCH 7/9] Fixing more conflicts --- Minecraft.Client/Common/UI/UIController.cpp | 27 +-- .../Common/UI/UIScene_AnvilMenu.cpp | 9 +- .../Common/UI/UIScene_CreateWorldMenu.cpp | 172 ++++++------------ Minecraft.Client/Extrax64Stubs.cpp | 6 +- .../Xbox/Network/NetworkPlayerXbox.cpp | 7 +- Minecraft.World/CompoundTag.h | 5 - Minecraft.World/ConsoleSaveFileOriginal.cpp | 5 - Minecraft.World/DataInputStream.cpp | 6 +- Minecraft.World/DataOutputStream.cpp | 7 +- Minecraft.World/DirectoryLevelStorage.cpp | 86 ++++----- Minecraft.World/FlatLevelSource.cpp | 6 +- Minecraft.World/HellFlatLevelSource.cpp | 6 +- Minecraft.World/JavaMath.cpp | 6 +- Minecraft.World/Layer.cpp | 17 +- Minecraft.World/Level.cpp | 44 +---- Minecraft.World/LevelData.cpp | 6 +- Minecraft.World/LoginPacket.cpp | 24 +-- Minecraft.World/Mth.cpp | 6 +- Minecraft.World/Random.cpp | 19 +- Minecraft.World/RegionFile.cpp | 40 +--- Minecraft.World/RespawnPacket.cpp | 18 +- Minecraft.World/SparseDataStorage.cpp | 137 ++++++-------- Minecraft.World/SparseLightStorage.cpp | 33 +--- Minecraft.World/StemTile.cpp | 11 +- Minecraft.World/Zombie.cpp | 4 - Minecraft.World/system.cpp | 6 +- Minecraft.World/x64headers/extraX64.h | 8 +- 27 files changed, 204 insertions(+), 517 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 653958d19..3da1b11a5 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -858,27 +858,6 @@ void UIController::tickInput() sceneMouseX = sceneMouseX * ((F32)pScene->getRenderWidth() / (F32)winW); sceneMouseY = sceneMouseY * ((F32)pScene->getRenderHeight() / (F32)winH); } -<<<<<<< HEAD - - if (hitObject != currentFocus) - { - IggyPlayerSetFocusRS(movie, hitObject, 0); - } - } - } - - // Convert mouse to scene/movie coordinates for slider hit testing - F32 sceneMouseX = mouseX; - F32 sceneMouseY = mouseY; - { - S32 displayWidth = 0, displayHeight = 0; - pScene->GetParentLayer()->getRenderDimensions(displayWidth, displayHeight); - if (displayWidth > 0 && displayHeight > 0) - { - sceneMouseX = mouseX * (static_cast(pScene->getRenderWidth()) / static_cast(displayWidth)); - sceneMouseY = mouseY * (static_cast(pScene->getRenderHeight()) / static_cast(displayHeight)); -======= ->>>>>>> origin/main } } @@ -1052,14 +1031,10 @@ void UIController::tickInput() if (!ctrl || ctrl->getControlType() != UIControl::eSlider || !ctrl->getVisible()) continue; -<<<<<<< HEAD - UIControl_Slider *pSlider = static_cast(ctrl); -======= if (pMainPanel && ctrl->getParentPanel() != pMainPanel) continue; - UIControl_Slider *pSlider = (UIControl_Slider *)ctrl; ->>>>>>> origin/main + UIControl_Slider *pSlider = static_cast(ctrl); pSlider->UpdateControl(); S32 cx = pSlider->getXPos() + panelOffsetX; S32 cy = pSlider->getYPos() + panelOffsetY; diff --git a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp index 01de58184..a3fb0d2d7 100644 --- a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp @@ -334,12 +334,7 @@ void UIScene_AnvilMenu::onDirectEditFinished(UIControl_TextInput *input, UIContr int UIScene_AnvilMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) { -<<<<<<< HEAD - // 4J HEG - No reason to set value if keyboard was cancelled UIScene_AnvilMenu *pClass=static_cast(lpParam); -======= - UIScene_AnvilMenu *pClass=(UIScene_AnvilMenu *)lpParam; ->>>>>>> origin/main pClass->setIgnoreInput(false); if (bRes) @@ -348,8 +343,8 @@ int UIScene_AnvilMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) uint16_t pchText[128]; ZeroMemory(pchText, 128 * sizeof(uint16_t)); Win64_GetKeyboardText(pchText, 128); - pClass->setEditNameValue((wchar_t *)pchText); - pClass->m_itemName = (wchar_t *)pchText; + pClass->setEditNameValue(reinterpret_cast(pchText)); + pClass->m_itemName = reinterpret_cast(pchText); pClass->updateItemName(); #else uint16_t pchText[128]; diff --git a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp index 34ae25f80..ef72ec163 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp @@ -287,136 +287,68 @@ void UIScene_CreateWorldMenu::handleDestroy() void UIScene_CreateWorldMenu::tick() { - UIScene::tick(); - -#ifdef _WINDOWS64 - // Cooldown timer to absorb ACTION_MENU_OK immediately after finishing text edit - if (m_iDirectEditCooldown > 0) - m_iDirectEditCooldown--; - - // Direct world name keyboard editing - if (m_bDirectEditing) - { - wchar_t ch; - bool changed = false; - - // Consume UTF‑16 char input - while (g_KBMInput.ConsumeChar(ch)) - { - if (ch == 0x08) // backspace - { - if (!m_worldName.empty()) - { - m_worldName.pop_back(); - changed = true; - } - } - else if (ch == 0x0D) // enter → confirm edit - { - m_bDirectEditing = false; - m_iDirectEditCooldown = 4; // absorb the matching ACTION_MENU_OK - m_editWorldName.setLabel(m_worldName.c_str()); - } - else if (static_cast(m_worldName.length()) < 25) - { - // Append typed character - m_worldName += ch; - changed = true; - } - } - - // Escape = cancel & restore original name - if (m_bDirectEditing && g_KBMInput.IsKeyPressed(VK_ESCAPE)) - { - m_worldName = m_worldNameBeforeEdit; - m_bDirectEditing = false; - m_iDirectEditCooldown = 4; - - m_editWorldName.setLabel(m_worldName.c_str()); - m_buttonCreateWorld.setEnable(!m_worldName.empty()); - } - else if (changed) - { - // Update displayed label while typing - m_editWorldName.setLabel(m_worldName.c_str()); - m_buttonCreateWorld.setEnable(!m_worldName.empty()); - } - } -#endif // _WINDOWS64 + UIScene::tick(); + if(m_iSetTexturePackDescription >= 0 ) + { + UpdateTexturePackDescription( m_iSetTexturePackDescription ); + m_iSetTexturePackDescription = -1; + } + if(m_bShowTexturePackDescription) + { + slideLeft(); + m_texturePackDescDisplayed = true; - // --------------------------------------------------------- - // origin/main logic begins - // --------------------------------------------------------- + m_bShowTexturePackDescription = false; + } - if (m_iSetTexturePackDescription >= 0) - { - UpdateTexturePackDescription(m_iSetTexturePackDescription); - m_iSetTexturePackDescription = -1; - } +#ifdef __ORBIS__ + // check the status of the PSPlus common dialog + switch (sceNpCommerceDialogUpdateStatus()) + { + case SCE_COMMON_DIALOG_STATUS_FINISHED: + { + SceNpCommerceDialogResult Result; + sceNpCommerceDialogGetResult(&Result); + sceNpCommerceDialogTerminate(); - if (m_bShowTexturePackDescription) - { - slideLeft(); - m_texturePackDescDisplayed = true; - m_bShowTexturePackDescription = false; - } + if(Result.authorized) + { + ProfileManager.PsPlusUpdate(ProfileManager.GetPrimaryPad(), &Result); + // they just became a PSPlus member + checkStateAndStartGame(); + } + else + { + // continue offline? + UINT uiIDA[1]; + uiIDA[0]=IDS_PRO_NOTONLINE_DECLINE; -#ifdef __ORBIS__ - // check the status of the PSPlus common dialog - switch (sceNpCommerceDialogUpdateStatus()) - { - case SCE_COMMON_DIALOG_STATUS_FINISHED: - { - SceNpCommerceDialogResult Result; - sceNpCommerceDialogGetResult(&Result); - sceNpCommerceDialogTerminate(); - - if (Result.authorized) - { - ProfileManager.PsPlusUpdate(ProfileManager.GetPrimaryPad(), &Result); - // they just became a PSPlus member - checkStateAndStartGame(); - } - else - { - // continue offline? - UINT uiIDA[1]; - uiIDA[0] = IDS_PRO_NOTONLINE_DECLINE; - - // warning about missing PSPlus - ui.RequestAlertMessage( - IDS_PLAY_OFFLINE, - IDS_NO_PLAYSTATIONPLUS, - uiIDA, - 1, - ProfileManager.GetPrimaryPad(), - &UIScene_CreateWorldMenu::ContinueOffline, - dynamic_cast(this)); - } - } - break; - - default: - break; - } -#endif // __ORBIS__ + // Give the player a warning about the texture pack missing + ui.RequestAlertMessage(IDS_PLAY_OFFLINE,IDS_NO_PLAYSTATIONPLUS, uiIDA, 1, ProfileManager.GetPrimaryPad(),&UIScene_CreateWorldMenu::ContinueOffline,dynamic_cast(this)); + } + } + break; + default: + break; + } +#endif } - #ifdef __ORBIS__ -int UIScene_CreateWorldMenu::ContinueOffline(void* pParam, int iPad, C4JStorage::EMessageResult result) +int UIScene_CreateWorldMenu::ContinueOffline(void *pParam,int iPad,C4JStorage::EMessageResult result) { - UIScene_CreateWorldMenu* pClass = static_cast(pParam); + UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu*)pParam; - // results switched for this dialog - if (result == C4JStorage::EMessage_ResultAccept) - { - pClass->m_MoreOptionsParams.bOnlineGame = false; - pClass->checkStateAndStartGame(); - } - return 0; + // results switched for this dialog + if(result==C4JStorage::EMessage_ResultAccept) + { + pClass->m_MoreOptionsParams.bOnlineGame=false; + pClass->checkStateAndStartGame(); + } + return 0; } + #endif #ifdef _WINDOWS64 @@ -1203,7 +1135,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD if (wSeed.length() != 0) { int64_t value = 0; - const unsigned int len = static_cast(wSeed.length()); + unsigned int len = static_cast(wSeed.length()); //Check if the input string contains a numerical value bool isNumber = true; diff --git a/Minecraft.Client/Extrax64Stubs.cpp b/Minecraft.Client/Extrax64Stubs.cpp index 3a6b5acc8..5d676b290 100644 --- a/Minecraft.Client/Extrax64Stubs.cpp +++ b/Minecraft.Client/Extrax64Stubs.cpp @@ -68,7 +68,7 @@ DWORD XContentGetThumbnail(DWORD dwUserIndex, const XCONTENT_DATA* pContentData, void XShowAchievementsUI(int i) {} DWORD XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE Mode) { return 0; } -#ifndef _DURANGO +#if !defined(_DURANGO) && !defined(_WIN64) void PIXAddNamedCounter(int a, const char* b, ...) {} //#define PS3_USE_PIX_EVENTS //#define PS4_USE_PIX_EVENTS @@ -126,7 +126,9 @@ void PIXEndNamedEvent() #endif } void PIXSetMarkerDeprecated(int a, const char* b, ...) {} -#else +#endif + +#if 0//__PSVITA__ // 4J Stu - Removed this implementation in favour of a macro that will convert our string format // conversion at compile time rather than at runtime //void PIXBeginNamedEvent(int a, char *b, ...) diff --git a/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp b/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp index 9bf346858..edadfac41 100644 --- a/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp +++ b/Minecraft.Client/Xbox/Network/NetworkPlayerXbox.cpp @@ -137,11 +137,6 @@ int NetworkPlayerXbox::GetTimeSinceLastChunkPacket_ms() return INT_MAX; } -<<<<<<< HEAD - __int64 currentTime = System::currentTimeMillis(); + const int64_t currentTime = System::currentTimeMillis(); return static_cast(currentTime - m_lastChunkPacketTime); -======= - int64_t currentTime = System::currentTimeMillis(); - return (int)( currentTime - m_lastChunkPacketTime ); ->>>>>>> origin/main } \ No newline at end of file diff --git a/Minecraft.World/CompoundTag.h b/Minecraft.World/CompoundTag.h index f199adf1e..5eaa2a05d 100644 --- a/Minecraft.World/CompoundTag.h +++ b/Minecraft.World/CompoundTag.h @@ -158,13 +158,8 @@ class CompoundTag : public Tag int64_t getLong(const wstring &name) { -<<<<<<< HEAD - if (tags.find(name) == tags.end()) return (__int64)0; - return static_cast(tags[name])->data; -======= if (tags.find(name) == tags.end()) return (int64_t)0; return ((LongTag *) tags[name])->data; ->>>>>>> origin/main } float getFloat(const wstring &name) diff --git a/Minecraft.World/ConsoleSaveFileOriginal.cpp b/Minecraft.World/ConsoleSaveFileOriginal.cpp index 97ed52eaf..8a7d1f9ec 100644 --- a/Minecraft.World/ConsoleSaveFileOriginal.cpp +++ b/Minecraft.World/ConsoleSaveFileOriginal.cpp @@ -213,13 +213,8 @@ ConsoleSaveFileOriginal::~ConsoleSaveFileOriginal() VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT ); pagesCommitted = 0; // Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway -<<<<<<< HEAD -#if defined _XBOX - app.GetSaveThumbnail(nullptr,nullptr); -======= #if defined _XBOX app.GetSaveThumbnail(NULL,NULL); ->>>>>>> origin/main #elif defined __PS3__ app.GetSaveThumbnail(nullptr,nullptr, nullptr,nullptr); #endif diff --git a/Minecraft.World/DataInputStream.cpp b/Minecraft.World/DataInputStream.cpp index 300e62112..4e4f5cd1b 100644 --- a/Minecraft.World/DataInputStream.cpp +++ b/Minecraft.World/DataInputStream.cpp @@ -110,11 +110,7 @@ wchar_t DataInputStream::readChar() { int a = stream->read(); int b = stream->read(); -<<<<<<< HEAD - return static_cast((a << 8) | (b & 0xff)); -======= - return (wchar_t)((a << 8) | (b & 0xff)); ->>>>>>> origin/main + return static_cast((a << 8) | (b & 0xff)); } //Reads some bytes from an input stream and stores them into the buffer array b. The number of bytes read is equal to the length of b. diff --git a/Minecraft.World/DataOutputStream.cpp b/Minecraft.World/DataOutputStream.cpp index 624dfbdfc..1a3931cfe 100644 --- a/Minecraft.World/DataOutputStream.cpp +++ b/Minecraft.World/DataOutputStream.cpp @@ -227,13 +227,8 @@ void DataOutputStream::writeUTF(const wstring& str) byteArray bytearr(utflen+2); -<<<<<<< HEAD bytearr[count++] = static_cast((utflen >> 8) & 0xFF); - bytearr[count++] = static_cast((utflen >> 0) & 0xFF); -======= - bytearr[count++] = (byte) ((utflen >> 8) & 0xFF); - bytearr[count++] = (byte) ((utflen >> 0) & 0xFF); ->>>>>>> origin/main + bytearr[count++] = static_cast((utflen >> 0) & 0xFF); int i=0; for (i=0; i>2] & (3 << offset))>>offset; + const int offset = (2*(id%4)); + const int val = (dimensions[id>>2] & (3 << offset))>>offset; int returnVal=0; @@ -54,7 +54,7 @@ void _MapDataMappings::setMapping(int id, PlayerUID xuid, int dimension) { xuids[id] = xuid; - int offset = (2*(id%4)); + const int offset = (2*(id%4)); // Reset it first dimensions[id>>2] &= ~( 2 << offset ); @@ -108,11 +108,7 @@ void _MapDataMappings_old::setMapping(int id, PlayerUID xuid, int dimension) #ifdef _LARGE_WORLDS void DirectoryLevelStorage::PlayerMappings::addMapping(int id, int centreX, int centreZ, int dimension, int scale) { -<<<<<<< HEAD - __int64 index = ( static_cast<__int64>(centreZ & 0x1FFFFFFF) << 34) | ( static_cast<__int64>(centreX & 0x1FFFFFFF) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); -======= - int64_t index = ( ((int64_t)(centreZ & 0x1FFFFFFF)) << 34) | ( ((int64_t)(centreX & 0x1FFFFFFF)) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); ->>>>>>> origin/main + const int64_t index = ( static_cast(centreZ & 0x1FFFFFFF) << 34) | ( static_cast(centreX & 0x1FFFFFFF) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); m_mappings[index] = id; //app.DebugPrintf("Adding mapping: %d - (%d,%d)/%d/%d [%I64d - 0x%016llx]\n", id, centreX, centreZ, dimension, scale, index, index); } @@ -124,12 +120,8 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int &id, int centreX, int //int64_t zShifted = zMasked << 34; //int64_t xShifted = xMasked << 5; //app.DebugPrintf("xShifted = %d (0x%016x), zShifted = %I64d (0x%016llx)\n", xShifted, xShifted, zShifted, zShifted); -<<<<<<< HEAD - __int64 index = ( static_cast<__int64>(centreZ & 0x1FFFFFFF) << 34) | ( static_cast<__int64>(centreX & 0x1FFFFFFF) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); -======= - int64_t index = ( ((int64_t)(centreZ & 0x1FFFFFFF)) << 34) | ( ((int64_t)(centreX & 0x1FFFFFFF)) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); ->>>>>>> origin/main - auto it = m_mappings.find(index); + const int64_t index = ( static_cast(centreZ & 0x1FFFFFFF) << 34) | ( static_cast(centreX & 0x1FFFFFFF) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3); + const auto it = m_mappings.find(index); if(it != m_mappings.end()) { id = it->second; @@ -146,7 +138,7 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int &id, int centreX, int void DirectoryLevelStorage::PlayerMappings::writeMappings(DataOutputStream *dos) { dos->writeInt(m_mappings.size()); - for ( auto& it : m_mappings ) + for (const auto& it : m_mappings ) { app.DebugPrintf(" -- %lld (0x%016llx) = %d\n", it.first, it.first, it.second); dos->writeLong(it.first); @@ -156,11 +148,11 @@ void DirectoryLevelStorage::PlayerMappings::writeMappings(DataOutputStream *dos) void DirectoryLevelStorage::PlayerMappings::readMappings(DataInputStream *dis) { - int count = dis->readInt(); + const int count = dis->readInt(); for(unsigned int i = 0; i < count; ++i) { int64_t index = dis->readLong(); - int id = dis->readInt(); + const int id = dis->readInt(); m_mappings[index] = id; app.DebugPrintf(" -- %lld (0x%016llx) = %d\n", index, index, id); } @@ -182,7 +174,7 @@ DirectoryLevelStorage::~DirectoryLevelStorage() { delete m_saveFile; - for( auto& it : m_cachedSaveData ) + for(const auto& it : m_cachedSaveData ) { delete it.second; } @@ -196,7 +188,7 @@ void DirectoryLevelStorage::initiateSession() { // 4J Jev, removed try/catch. - File dataFile = File( dir, wstring(L"session.lock") ); + const File dataFile = File( dir, wstring(L"session.lock") ); FileOutputStream fos = FileOutputStream(dataFile); DataOutputStream dos = DataOutputStream(&fos); dos.writeLong(sessionId); @@ -227,13 +219,13 @@ ChunkStorage *DirectoryLevelStorage::createChunkStorage(Dimension *dimension) if (dynamic_cast(dimension) != nullptr) { - File dir2 = File(dir, LevelStorage::NETHER_FOLDER); + const File dir2 = File(dir, LevelStorage::NETHER_FOLDER); //dir2.mkdirs(); // 4J Removed return new OldChunkStorage(dir2, true); } if (dynamic_cast(dimension) != nullptr) { - File dir2 = File(dir, LevelStorage::ENDER_FOLDER); + const File dir2 = File(dir, LevelStorage::ENDER_FOLDER); //dir2.mkdirs(); // 4J Removed return new OldChunkStorage(dir2, true); } @@ -245,7 +237,7 @@ LevelData *DirectoryLevelStorage::prepareLevel() { // 4J Stu Added #ifdef _LARGE_WORLDS - ConsoleSavePath mapFile = getDataFile(L"largeMapDataMappings"); + const ConsoleSavePath mapFile = getDataFile(L"largeMapDataMappings"); #else ConsoleSavePath mapFile = getDataFile(L"mapDataMappings"); #endif @@ -281,13 +273,13 @@ LevelData *DirectoryLevelStorage::prepareLevel() getSaveFile()->setFilePointer(fileEntry,0,nullptr, FILE_BEGIN); #ifdef _LARGE_WORLDS - byteArray data(fileEntry->getFileSize()); + const byteArray data(fileEntry->getFileSize()); getSaveFile()->readFile( fileEntry, data.data, fileEntry->getFileSize(), &NumberOfBytesRead); assert( NumberOfBytesRead == fileEntry->getFileSize() ); ByteArrayInputStream bais(data); DataInputStream dis(&bais); - int count = dis.readInt(); + const int count = dis.readInt(); app.DebugPrintf("Loading %d mappings\n", count); for(unsigned int i = 0; i < count; ++i) { @@ -340,7 +332,7 @@ LevelData *DirectoryLevelStorage::prepareLevel() // 4J Jev, removed try/catch - ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) ); + const ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) ); if ( m_saveFile->doesFileExist( dataFile ) ) { @@ -364,7 +356,7 @@ void DirectoryLevelStorage::saveLevelData(LevelData *levelData, vectorput(L"Data", dataTag); - ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) ); + const ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) ); ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream( m_saveFile, currentFile ); NbtIo::writeCompressed(root, &fos); @@ -381,7 +373,7 @@ void DirectoryLevelStorage::saveLevelData(LevelData *levelData) CompoundTag *root = new CompoundTag(); root->put(L"Data", dataTag); - ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) ); + const ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) ); ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream( m_saveFile, currentFile ); NbtIo::writeCompressed(root, &fos); @@ -406,7 +398,7 @@ void DirectoryLevelStorage::save(shared_ptr player) #elif defined(_DURANGO) ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + player->getXuid().toString() + L".dat" ); #else - ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( player->getXuid() ) + L".dat" ); + const ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( player->getXuid() ) + L".dat" ); #endif // If saves are disabled (e.g. because we are writing the save buffer to disk) then cache this player data if(StorageManager.GetSaveDisabled()) @@ -414,7 +406,7 @@ void DirectoryLevelStorage::save(shared_ptr player) ByteArrayOutputStream *bos = new ByteArrayOutputStream(); NbtIo::writeCompressed(tag,bos); - auto it = m_cachedSaveData.find(realFile.getName()); + const auto it = m_cachedSaveData.find(realFile.getName()); if(it != m_cachedSaveData.end() ) { delete it->second; @@ -455,9 +447,9 @@ CompoundTag *DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid) #elif defined(_DURANGO) ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + xuid.toString() + L".dat" ); #else - ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( xuid ) + L".dat" ); + const ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( xuid ) + L".dat" ); #endif - auto it = m_cachedSaveData.find(realFile.getName()); + const auto it = m_cachedSaveData.find(realFile.getName()); if(it != m_cachedSaveData.end() ) { ByteArrayOutputStream *bos = it->second; @@ -493,12 +485,12 @@ void DirectoryLevelStorage::clearOldPlayerFiles() { for(unsigned int i = 0; i < playerFiles->size(); ++i ) { - FileEntry *file = playerFiles->at(i); + const FileEntry *file = playerFiles->at(i); wstring xuidStr = replaceAll( replaceAll(file->data.filename,playerDir.getName(),L""),L".dat",L""); #if defined(__PS3__) || defined(__ORBIS__) || defined(_DURANGO) PlayerUID xuid(xuidStr); #else - PlayerUID xuid = _fromString(xuidStr); + const PlayerUID xuid = _fromString(xuidStr); #endif deleteMapFilesForPlayer(xuid); m_saveFile->deleteFile( playerFiles->at(i) ); @@ -512,12 +504,12 @@ void DirectoryLevelStorage::clearOldPlayerFiles() for(unsigned int i = MAX_PLAYER_DATA_SAVES; i < playerFiles->size(); ++i ) { - FileEntry *file = playerFiles->at(i); + const FileEntry *file = playerFiles->at(i); wstring xuidStr = replaceAll( replaceAll(file->data.filename,playerDir.getName(),L""),L".dat",L""); #if defined(__PS3__) || defined(__ORBIS__) || defined(_DURANGO) PlayerUID xuid(xuidStr); #else - PlayerUID xuid = _fromString(xuidStr); + const PlayerUID xuid = _fromString(xuidStr); #endif deleteMapFilesForPlayer(xuid); m_saveFile->deleteFile( playerFiles->at(i) ); @@ -553,7 +545,7 @@ void DirectoryLevelStorage::flushSaveFile(bool autosave) if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<doesFileExist(gameRulesFiles)) { FileEntry *fe = m_saveFile->createFile(gameRulesFiles); @@ -572,7 +564,7 @@ void DirectoryLevelStorage::resetNetherPlayerPositions() #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) vector *playerFiles = m_saveFile->getValidPlayerDatFiles(); #else - vector *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() ); + const vector *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() ); #endif if ( playerFiles ) @@ -607,7 +599,7 @@ int DirectoryLevelStorage::getAuxValueForMap(PlayerUID xuid, int dimension, int bool foundMapping = false; #ifdef _LARGE_WORLDS - auto it = m_playerMappings.find(xuid); + const auto it = m_playerMappings.find(xuid); if(it != m_playerMappings.end()) { foundMapping = it->second.getMapping(mapId, centreXC, centreZC, dimension, scale); @@ -674,7 +666,7 @@ void DirectoryLevelStorage::saveMapIdLookup() if(StorageManager.GetSaveDisabled() ) return; #ifdef _LARGE_WORLDS - ConsoleSavePath file = getDataFile(L"largeMapDataMappings"); + const ConsoleSavePath file = getDataFile(L"largeMapDataMappings"); #else ConsoleSavePath file = getDataFile(L"mapDataMappings"); #endif @@ -720,13 +712,13 @@ void DirectoryLevelStorage::saveMapIdLookup() void DirectoryLevelStorage::dontSaveMapMappingForPlayer(PlayerUID xuid) { #ifdef _LARGE_WORLDS - auto it = m_playerMappings.find(xuid); + const auto it = m_playerMappings.find(xuid); if(it != m_playerMappings.end()) { for (auto itMap = it->second.m_mappings.begin(); itMap != it->second.m_mappings.end(); ++itMap) { - int index = itMap->second / 8; - int offset = itMap->second % 8; + const int index = itMap->second / 8; + const int offset = itMap->second % 8; m_usedMappings[index] &= ~(1< player) { - PlayerUID playerXuid = player->getXuid(); + const PlayerUID playerXuid = player->getXuid(); if(playerXuid != INVALID_XUID) deleteMapFilesForPlayer(playerXuid); } void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid) { #ifdef _LARGE_WORLDS - auto it = m_playerMappings.find(xuid); + const auto it = m_playerMappings.find(xuid); if(it != m_playerMappings.end()) { for (auto itMap = it->second.m_mappings.begin(); itMap != it->second.m_mappings.end(); ++itMap) @@ -766,8 +758,8 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid) else m_saveFile->deleteFile( m_saveFile->createFile(file) ); } - int index = itMap->second / 8; - int offset = itMap->second % 8; + const int index = itMap->second / 8; + const int offset = itMap->second % 8; m_usedMappings[index] &= ~(1< *FlatLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { Biome *biome = level->getBiome(x, z); -<<<<<<< HEAD - if (biome == nullptr) -======= if (biome == NULL) ->>>>>>> origin/main - { + { return nullptr; } return biome->getMobs(mobCategory); diff --git a/Minecraft.World/HellFlatLevelSource.cpp b/Minecraft.World/HellFlatLevelSource.cpp index 9b9d85ed5..c4ba062cc 100644 --- a/Minecraft.World/HellFlatLevelSource.cpp +++ b/Minecraft.World/HellFlatLevelSource.cpp @@ -211,11 +211,7 @@ wstring HellFlatLevelSource::gatherStats() vector *HellFlatLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { Biome *biome = level->getBiome(x, z); -<<<<<<< HEAD - if (biome == nullptr) -======= - if (biome == NULL) ->>>>>>> origin/main + if (biome == nullptr) { return nullptr; } diff --git a/Minecraft.World/JavaMath.cpp b/Minecraft.World/JavaMath.cpp index cda928954..cec2eb3a6 100644 --- a/Minecraft.World/JavaMath.cpp +++ b/Minecraft.World/JavaMath.cpp @@ -36,11 +36,7 @@ double Math::random() //the value of the argument rounded to the nearest long value. int64_t Math::round( double d ) { -<<<<<<< HEAD - return static_cast<__int64>(floor(d + 0.5)); -======= - return (int64_t)floor( d + 0.5 ); ->>>>>>> origin/main + return static_cast(floor(d + 0.5)); } int Math::_max(int a, int b) diff --git a/Minecraft.World/Layer.cpp b/Minecraft.World/Layer.cpp index 3e620db69..a0eda52f7 100644 --- a/Minecraft.World/Layer.cpp +++ b/Minecraft.World/Layer.cpp @@ -57,13 +57,8 @@ LayerArray Layer::getDefaultLayers(int64_t seed, LevelType *levelType) { biomeLayer = std::make_shared(1000 + i, biomeLayer); -<<<<<<< HEAD - if (i == 0) biomeLayer = std::make_shared(3, biomeLayer); - -======= - if (i == 0) biomeLayer = shared_ptr(new AddIslandLayer(3, biomeLayer)); + if (i == 0) biomeLayer = std::make_shared(3, biomeLayer); ->>>>>>> origin/main if (i == 0) { // 4J - moved mushroom islands to here. This skips 3 zooms that the old location of the add was, making them about 1/8 of the original size. Adding @@ -77,15 +72,9 @@ LayerArray Layer::getDefaultLayers(int64_t seed, LevelType *levelType) // 4J - now expand mushroom islands up again. This does a simple region grow to add a new mushroom island element when any of the neighbours are also mushroom islands. // This helps make the islands into nice compact shapes of the type that are actually likely to be able to make an island out of the sea in a small space. Also // helps the shore layer from doing too much damage in shrinking the islands we are making -<<<<<<< HEAD - biomeLayer = std::make_shared(5, biomeLayer); + biomeLayer = std::make_shared(5, biomeLayer); // Note - this reduces the size of mushroom islands by turning their edges into shores. We are doing this at i == 1 rather than i == 0 as the original does - biomeLayer = std::make_shared(1000, biomeLayer); -======= - biomeLayer = shared_ptr(new GrowMushroomIslandLayer(5, biomeLayer)); - // Note - this reduces the size of mushroom islands by turning their edges into shores. We are doing this at i == 1 rather than i == 0 as the original does - biomeLayer = shared_ptr(new ShoreLayer(1000, biomeLayer)); ->>>>>>> origin/main + biomeLayer = std::make_shared(1000, biomeLayer); biomeLayer = std::make_shared(1000, biomeLayer); } diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp index d448801ee..c9670cf30 100644 --- a/Minecraft.World/Level.cpp +++ b/Minecraft.World/Level.cpp @@ -195,13 +195,8 @@ void inline Level::setBrightnessCached(lightCache_t *cache, uint64_t *cacheUse, ( ( z & 0x3f0 ) >> 4 ); #ifdef _LARGE_WORLDS // Add in the higher bits for x and z -<<<<<<< HEAD - posbits |= ( ( static_cast<__uint64>(x) & 0x3FFFC00L) << 38) | - ( ( static_cast<__uint64>(z) & 0x3FFFC00L) << 22); -======= - posbits |= ( ( ((uint64_t)x) & 0x3FFFC00L) << 38) | - ( ( ((uint64_t)z) & 0x3FFFC00L) << 22); ->>>>>>> origin/main + posbits |= ( ( static_cast(x) & 0x3FFFC00L) << 38) | + ( ( static_cast(z) & 0x3FFFC00L) << 22); #endif lightCache_t cacheValue = cache[idx]; @@ -258,14 +253,8 @@ inline int Level::getBrightnessCached(lightCache_t *cache, LightLayer::variety l ( ( y & 0x0f0 ) << 2 ) | ( ( z & 0x3f0 ) >> 4 ); #ifdef _LARGE_WORLDS - // Add in the higher bits for x and z -<<<<<<< HEAD - posbits |= ( ( static_cast<__uint64>(x) & 0x3FFFC00L) << 38) | - ( ( static_cast<__uint64>(z) & 0x3FFFC00L) << 22); -======= - posbits |= ( ( ((uint64_t)x) & 0x3FFFC00L) << 38) | - ( ( ((uint64_t)z) & 0x3FFFC00L) << 22); ->>>>>>> origin/main + posbits |= ( ( static_cast(x) & 0x3FFFC00L) << 38) | + ( ( static_cast(z) & 0x3FFFC00L) << 22); #endif lightCache_t cacheValue = cache[idx]; @@ -331,13 +320,8 @@ inline int Level::getEmissionCached(lightCache_t *cache, int ct, int x, int y, i ( ( z & 0x3f0 ) >> 4 ); #ifdef _LARGE_WORLDS // Add in the higher bits for x and z -<<<<<<< HEAD - posbits |= ( ( static_cast<__uint64>(x) & 0x3FFFC00) << 38) | - ( ( static_cast<__uint64>(z) & 0x3FFFC00) << 22); -======= - posbits |= ( ( ((uint64_t)x) & 0x3FFFC00) << 38) | - ( ( ((uint64_t)z) & 0x3FFFC00) << 22); ->>>>>>> origin/main + posbits |= ( ( static_cast(x) & 0x3FFFC00) << 38) | + ( ( static_cast(z) & 0x3FFFC00) << 22); #endif lightCache_t cacheValue = cache[idx]; @@ -412,13 +396,8 @@ inline int Level::getBlockingCached(lightCache_t *cache, LightLayer::variety lay ( ( z & 0x3f0 ) >> 4 ); #ifdef _LARGE_WORLDS // Add in the higher bits for x and z -<<<<<<< HEAD - posbits |= ( ( static_cast<__uint64>(x) & 0x3FFFC00L) << 38) | - ( ( static_cast<__uint64>(z) & 0x3FFFC00L) << 22); -======= - posbits |= ( ( ((uint64_t)x) & 0x3FFFC00L) << 38) | - ( ( ((uint64_t)z) & 0x3FFFC00L) << 22); ->>>>>>> origin/main + posbits |= ( ( static_cast(x) & 0x3FFFC00L) << 38) | + ( ( static_cast(z) & 0x3FFFC00L) << 22); #endif lightCache_t cacheValue = cache[idx]; @@ -3457,13 +3436,8 @@ int Level::getExpectedLight(lightCache_t *cache, int x, int y, int z, LightLayer // 4J - Made changes here so that lighting goes through a cache, if enabled for this thread void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool force, bool rootOnlyEmissive) { -<<<<<<< HEAD lightCache_t *cache = static_cast(TlsGetValue(tlsIdxLightCache)); - __uint64 cacheUse = 0; -======= - lightCache_t *cache = (lightCache_t *)TlsGetValue(tlsIdxLightCache); uint64_t cacheUse = 0; ->>>>>>> origin/main if( force ) { @@ -3502,7 +3476,7 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool f } else { - toCheck = (int *)(cache + (16*16*16)); + toCheck = reinterpret_cast(cache + (16 * 16 * 16)); } int checkedPosition = 0; diff --git a/Minecraft.World/LevelData.cpp b/Minecraft.World/LevelData.cpp index 58941c831..fbc10ddb1 100644 --- a/Minecraft.World/LevelData.cpp +++ b/Minecraft.World/LevelData.cpp @@ -18,11 +18,7 @@ LevelData::LevelData(CompoundTag *tag) { wstring generatorName = tag->getString(L"generatorName"); m_pGenerator = LevelType::getLevelType(generatorName); -<<<<<<< HEAD - if (m_pGenerator == nullptr) -======= - if (m_pGenerator == NULL) ->>>>>>> origin/main + if (m_pGenerator == nullptr) { m_pGenerator = LevelType::lvl_normal; } diff --git a/Minecraft.World/LoginPacket.cpp b/Minecraft.World/LoginPacket.cpp index e58d77054..79cdfbae1 100644 --- a/Minecraft.World/LoginPacket.cpp +++ b/Minecraft.World/LoginPacket.cpp @@ -100,11 +100,7 @@ void LoginPacket::read(DataInputStream *dis) //throws IOException userName = readUtf(dis, Player::MAX_NAME_LENGTH); wstring typeName = readUtf(dis, 16); m_pLevelType = LevelType::getLevelType(typeName); -<<<<<<< HEAD - if (m_pLevelType == nullptr) -======= - if (m_pLevelType == NULL) ->>>>>>> origin/main + if (m_pLevelType == nullptr) { m_pLevelType = LevelType::lvl_normal; } @@ -139,11 +135,7 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException { dos->writeInt(clientVersion); writeUtf(userName, dos); -<<<<<<< HEAD - if (m_pLevelType == nullptr) -======= - if (m_pLevelType == NULL) ->>>>>>> origin/main + if (m_pLevelType == nullptr) { writeUtf(L"", dos); } @@ -182,18 +174,10 @@ void LoginPacket::handle(PacketListener *listener) int LoginPacket::getEstimatedSize() { int length=0; -<<<<<<< HEAD - if (m_pLevelType != nullptr) -======= - if (m_pLevelType != NULL) ->>>>>>> origin/main + if (m_pLevelType != nullptr) { length = static_cast(m_pLevelType->getGeneratorName().length()); } -<<<<<<< HEAD - return static_cast(sizeof(int) + userName.length() + 4 + 6 + sizeof(__int64) + sizeof(char) + sizeof(int) + (2 * sizeof(PlayerUID)) + 1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int)); -======= - return (int)(sizeof(int) + userName.length() + 4 + 6 + sizeof(int64_t) + sizeof(char) + sizeof(int) + (2*sizeof(PlayerUID)) +1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int)); ->>>>>>> origin/main + return static_cast(sizeof(int) + userName.length() + 4 + 6 + sizeof(int64_t) + sizeof(char) + sizeof(int) + (2 * sizeof(PlayerUID)) + 1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int)); } diff --git a/Minecraft.World/Mth.cpp b/Minecraft.World/Mth.cpp index 10d86a6d3..4ec4f78b1 100644 --- a/Minecraft.World/Mth.cpp +++ b/Minecraft.World/Mth.cpp @@ -53,11 +53,7 @@ int Mth::floor(float v) int64_t Mth::lfloor(double v) { -<<<<<<< HEAD - __int64 i = static_cast<__int64>(v); -======= - int64_t i = (int64_t) v; ->>>>>>> origin/main + int64_t i = static_cast(v); return v < i ? i - 1 : i; } diff --git a/Minecraft.World/Random.cpp b/Minecraft.World/Random.cpp index e0ca6f12c..89903da8c 100644 --- a/Minecraft.World/Random.cpp +++ b/Minecraft.World/Random.cpp @@ -41,13 +41,8 @@ void Random::nextBytes(byte *bytes, unsigned int count) double Random::nextDouble() { -<<<<<<< HEAD - return ((static_cast<__int64>(next(26)) << 27) + next(27)) + return ((static_cast(next(26)) << 27) + next(27)) / static_cast(1LL << 53); -======= - return (((int64_t)next(26) << 27) + next(27)) - / (double)(1LL << 53); ->>>>>>> origin/main } double Random::nextGaussian() @@ -84,11 +79,7 @@ int Random::nextInt(int n) if ((n & -n) == n) // i.e., n is a power of 2 -<<<<<<< HEAD - return static_cast(((__int64)next(31) * n) >> 31); // 4J Stu - Made __int64 instead of long -======= - return (int)(((int64_t)next(31) * n) >> 31); // 4J Stu - Made int64_t instead of long ->>>>>>> origin/main + return static_cast((static_cast(next(31)) * n) >> 31); // 4J Stu - Made int64_t instead of long int bits, val; do @@ -106,11 +97,7 @@ float Random::nextFloat() int64_t Random::nextLong() { -<<<<<<< HEAD - return (static_cast<__int64>(next(32)) << 32) + next(32); -======= - return ((int64_t)next(32) << 32) + next(32); ->>>>>>> origin/main + return (static_cast(next(32)) << 32) + next(32); } bool Random::nextBoolean() diff --git a/Minecraft.World/RegionFile.cpp b/Minecraft.World/RegionFile.cpp index 5a4494380..175ea6c1b 100644 --- a/Minecraft.World/RegionFile.cpp +++ b/Minecraft.World/RegionFile.cpp @@ -198,15 +198,9 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was m_saveFile->LockSaveAccess(); -<<<<<<< HEAD - //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN); - -======= //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN); + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN); ->>>>>>> origin/main unsigned int length; unsigned int decompLength; unsigned int readDecompLength; @@ -378,13 +372,8 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync * file */ // debug("SAVE", x, z, length, "grow"); -<<<<<<< HEAD - //SetFilePointer(file,0,0,FILE_END); - m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_END ); -======= //SetFilePointer(file,0,0,FILE_END); - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END ); ->>>>>>> origin/main + m_saveFile->setFilePointer( fileEntry, 0, nullptr, FILE_END ); sectorNumber = static_cast(sectorFree->size()); #ifndef _CONTENT_PACAKGE @@ -417,13 +406,8 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync void RegionFile::write(int sectorNumber, byte *data, int length, unsigned int compLength) { DWORD numberOfBytesWritten = 0; -<<<<<<< HEAD - //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN ); -======= //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN ); ->>>>>>> origin/main + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN ); // 4J - this differs a bit from the java file format. Java has length stored as an int, then a type as a byte, then length-1 bytes of data // We store length and decompression length as ints, then length bytes of xbox LZX compressed data @@ -441,13 +425,8 @@ void RegionFile::write(int sectorNumber, byte *data, int length, unsigned int co void RegionFile::zero(int sectorNumber, int length) { DWORD numberOfBytesWritten = 0; -<<<<<<< HEAD - //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN ); -======= //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN ); ->>>>>>> origin/main + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, nullptr, FILE_BEGIN ); m_saveFile->zeroFile( fileEntry, length, &numberOfBytesWritten ); } @@ -493,13 +472,9 @@ void RegionFile::setOffset(int x, int z, int offset) DWORD numberOfBytesWritten = 0; offsets[x + z * 32] = offset; -<<<<<<< HEAD + m_saveFile->setFilePointer( fileEntry, (x + z * 32) * 4, nullptr, FILE_BEGIN ); - -======= - m_saveFile->setFilePointer( fileEntry, (x + z * 32) * 4, NULL, FILE_BEGIN ); ->>>>>>> origin/main m_saveFile->writeFile(fileEntry,&offset,4,&numberOfBytesWritten); } @@ -512,13 +487,8 @@ void RegionFile::setTimestamp(int x, int z, int value) DWORD numberOfBytesWritten = 0; chunkTimestamps[x + z * 32] = value; -<<<<<<< HEAD m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES + (x + z * 32) * 4, nullptr, FILE_BEGIN ); - -======= - m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES + (x + z * 32) * 4, NULL, FILE_BEGIN ); ->>>>>>> origin/main m_saveFile->writeFile(fileEntry,&value,4,&numberOfBytesWritten); } diff --git a/Minecraft.World/RespawnPacket.cpp b/Minecraft.World/RespawnPacket.cpp index bf2d24d33..6dbebfacf 100644 --- a/Minecraft.World/RespawnPacket.cpp +++ b/Minecraft.World/RespawnPacket.cpp @@ -47,11 +47,7 @@ void RespawnPacket::read(DataInputStream *dis) //throws IOException mapHeight = dis->readShort(); wstring typeName = readUtf(dis, 16); m_pLevelType = LevelType::getLevelType(typeName); -<<<<<<< HEAD - if (m_pLevelType == nullptr) -======= - if (m_pLevelType == NULL) ->>>>>>> origin/main + if (m_pLevelType == nullptr) { m_pLevelType = LevelType::lvl_normal; } @@ -72,11 +68,7 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException dos->writeByte(dimension); dos->writeByte(playerGameType->getId()); dos->writeShort(mapHeight); -<<<<<<< HEAD - if (m_pLevelType == nullptr) -======= - if (m_pLevelType == NULL) ->>>>>>> origin/main + if (m_pLevelType == nullptr) { writeUtf(L"", dos); } @@ -97,11 +89,7 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException int RespawnPacket::getEstimatedSize() { int length=0; -<<<<<<< HEAD - if (m_pLevelType != nullptr) -======= - if (m_pLevelType != NULL) ->>>>>>> origin/main + if (m_pLevelType != nullptr) { length = static_cast(m_pLevelType->getGeneratorName().length()); } diff --git a/Minecraft.World/SparseDataStorage.cpp b/Minecraft.World/SparseDataStorage.cpp index 05b5ada76..556000fd0 100644 --- a/Minecraft.World/SparseDataStorage.cpp +++ b/Minecraft.World/SparseDataStorage.cpp @@ -87,8 +87,8 @@ SparseDataStorage::~SparseDataStorage() SparseDataStorage::SparseDataStorage(SparseDataStorage *copyFrom) { // Extra details of source storage - int64_t sourceDataAndCount = copyFrom->dataAndCount; - unsigned char *sourceIndicesAndData = (unsigned char *)(sourceDataAndCount & 0x0000ffffffffffff); + const int64_t sourceDataAndCount = copyFrom->dataAndCount; + const unsigned char *sourceIndicesAndData = (unsigned char *)(sourceDataAndCount & 0x0000ffffffffffff); int sourceCount = (sourceDataAndCount >> 48 ) & 0xffff; // Allocate & copy indices ( 128 bytes ) and any allocated planes (128 * count) @@ -129,10 +129,10 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset) for( int xz = 0; xz < 256; xz++ ) // 256 in loop as 16 x 16 separate bytes need checked { - int pos = ( xz << 7 ) | y; - int slot = pos >> 1; - int part = pos & 1; - unsigned char value = ( dataIn[slot + inOffset] >> (part * 4) ) & 15; + const int pos = ( xz << 7 ) | y; + const int slot = pos >> 1; + const int part = pos & 1; + const unsigned char value = ( dataIn[slot + inOffset] >> (part * 4) ) & 15; if( value != 0 ) all0 = false; } if( all0 ) @@ -158,9 +158,9 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset) // we know they were sequentially allocated above. if( planeIndices[y] < 128 ) { - int part = y & 1; + const int part = y & 1; //int shift = 4 * part; - unsigned char *pucIn = &dataIn[ (y >> 1) + inOffset]; + const unsigned char *pucIn = &dataIn[ (y >> 1) + inOffset]; for( int xz = 0; xz < 128; xz++ ) // 128 ( 16 x 16 x 0.5 ) in loop as packing 2 values into each destination byte { @@ -176,13 +176,9 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset) // Get new data and count packed info #pragma warning ( disable : 4826 ) - int64_t newDataAndCount = ((int64_t) planeIndices) & 0x0000ffffffffffffL; + int64_t newDataAndCount = reinterpret_cast(planeIndices) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) -<<<<<<< HEAD - newDataAndCount |= static_cast<__int64>(allocatedPlaneCount) << 48; -======= - newDataAndCount |= ((int64_t)allocatedPlaneCount) << 48; ->>>>>>> origin/main + newDataAndCount |= static_cast(allocatedPlaneCount) << 48; updateDataAndCount( newDataAndCount ); } @@ -209,10 +205,10 @@ void SparseDataStorage::getData(byteArray retArray, unsigned int retOffset) } else { - int part = y & 1; - int shift = 4 * part; + const int part = y & 1; + const int shift = 4 * part; unsigned char *pucOut = &retArray.data[ (y >> 1) + + retOffset]; - unsigned char *pucIn = &data[ planeIndices[ y ] * 128 ]; + const unsigned char *pucIn = &data[ planeIndices[ y ] * 128 ]; for( int xz = 0; xz < 128; xz++ ) // 128 in loop (16 x 16 x 0.5) as input data is being treated in pairs of nybbles that are packed in the same byte { unsigned char value = (*pucIn) & 15; @@ -241,10 +237,10 @@ int SparseDataStorage::get(int x, int y, int z) } else { - int planeIndex = x * 16 + z; // Index within this xz plane - int byteIndex = planeIndex / 2; // Byte index within the plane (2 tiles stored per byte) - int shift = ( planeIndex & 1 ) * 4; // Bit shift within the byte - int retval = ( data[ planeIndices[y] * 128 + byteIndex ] >> shift ) & 15; + const int planeIndex = x * 16 + z; // Index within this xz plane + const int byteIndex = planeIndex / 2; // Byte index within the plane (2 tiles stored per byte) + const int shift = ( planeIndex & 1 ) * 4; // Bit shift within the byte + const int retval = ( data[ planeIndices[y] * 128 + byteIndex ] >> shift ) & 15; return retval; } @@ -274,12 +270,12 @@ void SparseDataStorage::set(int x, int y, int z, int val) // Either data was already allocated, or we've just done that. Now store our value into the right place. - int planeIndex = x * 16 + z; // Index within this xz plane - int byteIndex = planeIndex / 2; // Byte index within the plane (2 tiles stored per byte) - int shift = ( planeIndex & 1 ) * 4; // Bit shift within the byte - int mask = 0xf0 >> shift; + const int planeIndex = x * 16 + z; // Index within this xz plane + const int byteIndex = planeIndex / 2; // Byte index within the plane (2 tiles stored per byte) + const int shift = ( planeIndex & 1 ) * 4; // Bit shift within the byte + const int mask = 0xf0 >> shift; - int idx = planeIndices[y] * 128 + byteIndex; + const int idx = planeIndices[y] * 128 + byteIndex; data[idx] = ( data[idx] & mask ) | ( val << shift ); } @@ -292,7 +288,7 @@ void SparseDataStorage::set(int x, int y, int z, int val) int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, int x1, int y1, int z1, int offset, tileUpdatedCallback callback, void *param, int yparam) { // Actual setting of data happens when calling set method so no need to lock here - unsigned char *pucIn = &dataIn.data[offset]; + const unsigned char *pucIn = &dataIn.data[offset]; if( callback ) { for( int x = x0; x < x1; x++ ) @@ -300,11 +296,11 @@ int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, i for( int z = z0; z < z1; z++ ) { // Emulate how data was extracted from DataLayer... see comment above - int yy0 = y0 & 0xfffffffe; - int len = ( y1 - y0 ) / 2; + const int yy0 = y0 & 0xfffffffe; + const int len = ( y1 - y0 ) / 2; for( int i = 0; i < len; i++ ) { - int y = yy0 + ( i * 2 ); + const int y = yy0 + ( i * 2 ); int toSet = (*pucIn) & 15; if( get(x, y, z) != toSet ) @@ -330,11 +326,11 @@ int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, i for( int z = z0; z < z1; z++ ) { // Emulate how data was extracted from DataLayer... see comment above - int yy0 = y0 & 0xfffffffe; - int len = ( y1 - y0 ) / 2; + const int yy0 = y0 & 0xfffffffe; + const int len = ( y1 - y0 ) / 2; for( int i = 0; i < len; i++ ) { - int y = yy0 + ( i * 2 ); + const int y = yy0 + ( i * 2 ); set(x, y, z, (*pucIn) & 15 ); set(x, y + 1, z, ((*pucIn) >> 4 ) & 15 ); @@ -343,7 +339,7 @@ int SparseDataStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0, i } } } - ptrdiff_t count = pucIn - &dataIn.data[offset]; + const ptrdiff_t count = pucIn - &dataIn.data[offset]; return static_cast(count); } @@ -361,11 +357,11 @@ int SparseDataStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z0 for( int z = z0; z < z1; z++ ) { // Emulate how data was extracted from DataLayer... see comment above - int yy0 = y0 & 0xfffffffe; - int len = ( y1 - y0 ) / 2; + const int yy0 = y0 & 0xfffffffe; + const int len = ( y1 - y0 ) / 2; for( int i = 0; i < len; i++ ) { - int y = yy0 + ( i * 2 ); + const int y = yy0 + ( i * 2 ); *pucOut = get( x, y, z); *pucOut |= get( x, y + 1, z) << 4; @@ -373,14 +369,9 @@ int SparseDataStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z0 } } } - ptrdiff_t count = pucOut - &dataInOut.data[offset]; -<<<<<<< HEAD - - return static_cast(count); -======= + const ptrdiff_t count = pucOut - &dataInOut.data[offset]; - return (int)count; ->>>>>>> origin/main + return static_cast(count); } void SparseDataStorage::addNewPlane(int y) @@ -389,38 +380,34 @@ void SparseDataStorage::addNewPlane(int y) do { // Get last packed data pointer & count - int64_t lastDataAndCount = dataAndCount; + const int64_t lastDataAndCount = dataAndCount; // Unpack count & data pointer - int lastLinesUsed = static_cast((lastDataAndCount >> 48) & 0xffff); + const int lastLinesUsed = static_cast((lastDataAndCount >> 48) & 0xffff); unsigned char *lastDataPointer = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff); // Find out what to prefill the newly allocated line with - unsigned char planeIndex = lastDataPointer[y]; + const unsigned char planeIndex = lastDataPointer[y]; if( planeIndex < ALL_0_INDEX ) return; // Something has already allocated this line - we're done int linesUsed = lastLinesUsed + 1; // Allocate new memory storage, copy over anything from old storage, and initialise remainder - unsigned char *dataPointer = static_cast(malloc(linesUsed * 128 + 128)); + auto dataPointer = static_cast(malloc(linesUsed * 128 + 128)); XMemCpy( dataPointer, lastDataPointer, 128 * lastLinesUsed + 128); XMemSet( dataPointer + ( 128 * lastLinesUsed ) + 128, 0, 128 ); dataPointer[y] = lastLinesUsed; // Get new data and count packed info #pragma warning ( disable : 4826 ) - int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL; + int64_t newDataAndCount = reinterpret_cast(dataPointer) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) -<<<<<<< HEAD - newDataAndCount |= static_cast<__int64>(linesUsed) << 48; -======= - newDataAndCount |= ((int64_t)linesUsed) << 48; ->>>>>>> origin/main + newDataAndCount |= static_cast(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 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount ); + const int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount ); if( lastDataAndCount2 == lastDataAndCount ) { @@ -443,7 +430,7 @@ void SparseDataStorage::addNewPlane(int y) void SparseDataStorage::getPlaneIndicesAndData(unsigned char **planeIndices, unsigned char **data) { - unsigned char *indicesAndData = (unsigned char *)(dataAndCount & 0x0000ffffffffffff); + unsigned char *indicesAndData = reinterpret_cast(dataAndCount & 0x0000ffffffffffff); *planeIndices = indicesAndData; *data = indicesAndData + 128; @@ -461,7 +448,7 @@ void SparseDataStorage::tick() { // We have 3 queues for deleting. Always delete from the next one after where we are writing to, so it should take 2 ticks // before we ever delete something, from when the request to delete it came in - int freeIndex = ( deleteQueueIndex + 1 ) % 3; + const int freeIndex = ( deleteQueueIndex + 1 ) % 3; // printf("Free queue: %d, %d\n",deleteQueue[freeIndex].GetEntryCount(),deleteQueue[freeIndex].GetAllocated()); unsigned char *toFree = nullptr; @@ -493,12 +480,12 @@ void SparseDataStorage::updateDataAndCount(int64_t newDataAndCount) bool success = false; do { - int64_t lastDataAndCount = dataAndCount; - unsigned char *lastDataPointer = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff); + const int64_t lastDataAndCount = dataAndCount; + unsigned char *lastDataPointer = reinterpret_cast(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 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount ); + const int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount ); if( lastDataAndCount2 == lastDataAndCount ) { @@ -521,7 +508,7 @@ int SparseDataStorage::compress() unsigned char _planeIndices[128]; bool needsCompressed = false; - int64_t lastDataAndCount = dataAndCount; + const int64_t lastDataAndCount = dataAndCount; unsigned char *planeIndices = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff); unsigned char *data = planeIndices + 128; @@ -535,7 +522,7 @@ int SparseDataStorage::compress() } else { - unsigned char *pucData = &data[ 128 * planeIndices[i] ]; + const unsigned char *pucData = &data[ 128 * planeIndices[i] ]; bool all0 = true; for( int j = 0; j < 128; j++ ) // 16 x 16 x 4-bits { @@ -573,15 +560,11 @@ int SparseDataStorage::compress() #pragma warning ( disable : 4826 ) int64_t newDataAndCount = ((int64_t) newIndicesAndData) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) -<<<<<<< HEAD - newDataAndCount |= static_cast<__int64>(planesToAlloc) << 48; -======= - newDataAndCount |= ((int64_t)planesToAlloc) << 48; ->>>>>>> origin/main + newDataAndCount |= static_cast(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 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount ); + const int64_t lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount ); if( lastDataAndCount2 != lastDataAndCount ) { @@ -611,7 +594,7 @@ int SparseDataStorage::compress() bool SparseDataStorage::isCompressed() { - int count = ( dataAndCount >> 48 ) & 0xffff; + const int count = ( dataAndCount >> 48 ) & 0xffff; return (count < 127); @@ -619,28 +602,24 @@ bool SparseDataStorage::isCompressed() void SparseDataStorage::write(DataOutputStream *dos) { - int count = ( dataAndCount >> 48 ) & 0xffff; + const int count = ( dataAndCount >> 48 ) & 0xffff; dos->writeInt(count); unsigned char *dataPointer = (unsigned char *)(dataAndCount & 0x0000ffffffffffff); - byteArray wrapper(dataPointer, count * 128 + 128); + const byteArray wrapper(dataPointer, count * 128 + 128); dos->write(wrapper); } void SparseDataStorage::read(DataInputStream *dis) { - int count = dis->readInt(); + const int count = dis->readInt(); unsigned char *dataPointer = static_cast(malloc(count * 128 + 128)); - byteArray wrapper(dataPointer, count * 128 + 128); + const byteArray wrapper(dataPointer, count * 128 + 128); dis->readFully(wrapper); #pragma warning ( disable : 4826 ) - int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL; + int64_t newDataAndCount = reinterpret_cast(dataPointer) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) -<<<<<<< HEAD - newDataAndCount |= static_cast<__int64>(count) << 48; -======= - newDataAndCount |= ((int64_t)count) << 48; ->>>>>>> origin/main + newDataAndCount |= static_cast(count) << 48; updateDataAndCount(newDataAndCount); } diff --git a/Minecraft.World/SparseLightStorage.cpp b/Minecraft.World/SparseLightStorage.cpp index d2f993b95..a80f9c979 100644 --- a/Minecraft.World/SparseLightStorage.cpp +++ b/Minecraft.World/SparseLightStorage.cpp @@ -180,13 +180,9 @@ void SparseLightStorage::setData(byteArray dataIn, unsigned int inOffset) // Get new data and count packed info #pragma warning ( disable : 4826 ) - int64_t newDataAndCount = ((int64_t) planeIndices) & 0x0000ffffffffffffL; + int64_t newDataAndCount = reinterpret_cast(planeIndices) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) -<<<<<<< HEAD - newDataAndCount |= static_cast<__int64>(allocatedPlaneCount) << 48; -======= - newDataAndCount |= ((int64_t)allocatedPlaneCount) << 48; ->>>>>>> origin/main + newDataAndCount |= static_cast(allocatedPlaneCount) << 48; updateDataAndCount( newDataAndCount ); } @@ -379,13 +375,8 @@ int SparseLightStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z } } ptrdiff_t count = pucOut - &dataInOut.data[offset]; -<<<<<<< HEAD - - return static_cast(count); -======= - return (int)count; ->>>>>>> origin/main + return static_cast(count); } void SparseLightStorage::addNewPlane(int y) @@ -418,11 +409,7 @@ void SparseLightStorage::addNewPlane(int y) #pragma warning ( disable : 4826 ) int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) -<<<<<<< HEAD - newDataAndCount |= static_cast<__int64>(linesUsed) << 48; -======= - newDataAndCount |= ((int64_t)linesUsed) << 48; ->>>>>>> origin/main + newDataAndCount |= static_cast(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 @@ -590,11 +577,7 @@ int SparseLightStorage::compress() #pragma warning ( disable : 4826 ) int64_t newDataAndCount = ((int64_t) newIndicesAndData) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) -<<<<<<< HEAD - newDataAndCount |= static_cast<__int64>(planesToAlloc) << 48; -======= - newDataAndCount |= ((int64_t)planesToAlloc) << 48; ->>>>>>> origin/main + newDataAndCount |= static_cast(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 @@ -653,11 +636,7 @@ void SparseLightStorage::read(DataInputStream *dis) #pragma warning ( disable : 4826 ) int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL; #pragma warning ( default : 4826 ) -<<<<<<< HEAD - newDataAndCount |= static_cast<__int64>(count) << 48; -======= - newDataAndCount |= ((int64_t)count) << 48; ->>>>>>> origin/main + newDataAndCount |= static_cast(count) << 48; updateDataAndCount( newDataAndCount ); } diff --git a/Minecraft.World/StemTile.cpp b/Minecraft.World/StemTile.cpp index d3a252248..476b643cf 100644 --- a/Minecraft.World/StemTile.cpp +++ b/Minecraft.World/StemTile.cpp @@ -187,17 +187,10 @@ void StemTile::spawnResources(Level *level, int x, int y, int z, int data, float Item *seed = nullptr; if (fruit == Tile::pumpkin) seed = Item::seeds_pumpkin; if (fruit == Tile::melon) seed = Item::seeds_melon; -<<<<<<< HEAD - for (int i = 0; i < 3; i++) - { - popResource(level, x, y, z, std::make_shared(seed)); - } -======= - if (seed != NULL) + if (seed != nullptr) { - popResource(level, x, y, z, shared_ptr(new ItemInstance(seed))); + popResource(level, x, y, z, std::make_shared(seed)); } ->>>>>>> origin/main } int StemTile::getResource(int data, Random *random, int playerBonusLevel) diff --git a/Minecraft.World/Zombie.cpp b/Minecraft.World/Zombie.cpp index 1a85f3d2d..f982d8475 100644 --- a/Minecraft.World/Zombie.cpp +++ b/Minecraft.World/Zombie.cpp @@ -92,12 +92,8 @@ bool Zombie::isBaby() void Zombie::setBaby(bool baby) { -<<<<<<< HEAD - getEntityData()->set(DATA_BABY_ID, static_cast(baby ? 1 : 0)); -======= getEntityData()->set(DATA_BABY_ID, (byte) (baby ? 1 : 0)); updateSize(baby); ->>>>>>> origin/main if (level != nullptr && !level->isClientSide) { diff --git a/Minecraft.World/system.cpp b/Minecraft.World/system.cpp index 0954ddfea..71d0a85e4 100644 --- a/Minecraft.World/system.cpp +++ b/Minecraft.World/system.cpp @@ -64,11 +64,7 @@ int64_t System::nanoTime() // Using double to avoid 64-bit overflow during multiplication for long uptime // Precision is sufficient for ~100 days of uptime. -<<<<<<< HEAD - return static_cast<__int64>((double)counter.QuadPart * 1000000000.0 / (double)s_frequency.QuadPart); -======= - return (int64_t)((double)counter.QuadPart * 1000000000.0 / (double)s_frequency.QuadPart); ->>>>>>> origin/main + return static_cast(static_cast(counter.QuadPart) * 1000000000.0 / static_cast(s_frequency.QuadPart)); #else return GetTickCount() * 1000000LL; #endif diff --git a/Minecraft.World/x64headers/extraX64.h b/Minecraft.World/x64headers/extraX64.h index de6b8bae6..4af047b5b 100644 --- a/Minecraft.World/x64headers/extraX64.h +++ b/Minecraft.World/x64headers/extraX64.h @@ -332,10 +332,10 @@ class IQNet #define PIXSetMarkerDeprecated(a, b, ...) PIXSetMarker(a, L ## b, __VA_ARGS__) #define PIXAddNamedCounter(a, b) PIXReportCounter( L ## b, a) #else -void PIXAddNamedCounter(int a, const char *b, ...); -void PIXBeginNamedEvent(int a, const char *b, ...); -void PIXEndNamedEvent(); -void PIXSetMarkerDeprecated(int a, const char *b, ...); +inline void PIXAddNamedCounter(int, const char*, ...) {} +inline void PIXBeginNamedEvent(int, const char*, ...) {} +inline void PIXEndNamedEvent() {} +inline void PIXSetMarkerDeprecated(int, const char*, ...) {} #endif void XSetThreadProcessor(HANDLE a, int b); From 98c5325b9099f9cd6b1b70d34f519cb7456afb55 Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Sat, 7 Mar 2026 20:01:30 -0500 Subject: [PATCH 8/9] Replace int loops with size_t and start work on overrides --- Minecraft.Client/Chunk.cpp | 6 +- Minecraft.Client/ClientConnection.cpp | 6 +- Minecraft.Client/Common/Audio/SoundEngine.h | 31 +++---- Minecraft.Client/Common/Consoles_App.cpp | 12 +-- Minecraft.Client/Common/DLC/DLCAudioFile.cpp | 6 +- Minecraft.Client/Common/DLC/DLCAudioFile.h | 10 +-- Minecraft.Client/Common/DLC/DLCCapeFile.h | 2 +- .../Common/DLC/DLCColourTableFile.h | 6 +- Minecraft.Client/Common/DLC/DLCFile.h | 4 +- .../Common/DLC/DLCGameRulesFile.h | 4 +- .../Common/DLC/DLCGameRulesHeader.h | 55 ++++++++---- .../Common/DLC/DLCLocalisationFile.h | 2 +- Minecraft.Client/Common/DLC/DLCManager.cpp | 26 +++--- Minecraft.Client/Common/DLC/DLCSkinFile.cpp | 4 +- Minecraft.Client/Common/DLC/DLCSkinFile.h | 8 +- Minecraft.Client/Common/DLC/DLCTextureFile.h | 10 +-- Minecraft.Client/Common/DLC/DLCUIDataFile.h | 4 +- .../Common/UI/IUIScene_TradingMenu.cpp | 2 +- .../Common/UI/UIComponent_TutorialPopup.cpp | 20 ++--- Minecraft.Client/Common/UI/UILayer.cpp | 8 +- Minecraft.Client/Common/UI/UIScene_EULA.cpp | 4 +- .../Common/UI/UIScene_HowToPlay.cpp | 4 +- .../Common/UI/UIScene_NewUpdateMessage.cpp | 4 +- .../Common/XUI/XUI_Scene_Anvil.cpp | 6 +- Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp | 6 +- .../Common/XUI/XUI_TutorialPopup.cpp | 20 ++--- .../Durango/Network/DQRNetworkManager.cpp | 10 +-- Minecraft.Client/Font.cpp | 2 +- Minecraft.Client/Gui.cpp | 85 ++++++++++--------- Minecraft.Client/JoinMultiplayerScreen.cpp | 2 +- Minecraft.Client/LevelRenderer.cpp | 2 +- Minecraft.Client/MinecraftServer.cpp | 4 +- Minecraft.Client/Options.cpp | 2 +- .../Orbis/Network/SQRNetworkManager_Orbis.cpp | 4 +- Minecraft.Client/Orbis/Orbis_App.cpp | 2 +- Minecraft.Client/Orbis/Orbis_Minecraft.cpp | 2 +- .../PS3/Network/SonyCommerce_PS3.cpp | 4 +- Minecraft.Client/PS3/PS3_App.cpp | 4 +- Minecraft.Client/PS3/PS3_Minecraft.cpp | 2 +- .../Network/SQRNetworkManager_AdHoc_Vita.cpp | 10 +-- .../PSVita/Network/SQRNetworkManager_Vita.cpp | 2 +- .../PSVita/Network/SonyVoiceChat_Vita.cpp | 8 +- Minecraft.Client/PSVita/PSVita_App.cpp | 6 +- Minecraft.Client/PSVita/PSVita_Minecraft.cpp | 2 +- Minecraft.Client/PlayerChunkMap.cpp | 4 +- Minecraft.Client/PlayerList.cpp | 6 +- Minecraft.Client/ServerChunkCache.cpp | 16 ++-- Minecraft.Client/Stitcher.cpp | 2 +- Minecraft.Client/Xbox/Audio/SoundEngine.h | 31 +++---- Minecraft.World/AbstractContainerMenu.cpp | 2 +- Minecraft.World/BaseRailTile.cpp | 4 +- Minecraft.World/C4JThread.cpp | 2 +- Minecraft.World/ChatPacket.cpp | 6 +- Minecraft.World/CombatTracker.cpp | 2 +- Minecraft.World/Connection.cpp | 4 +- Minecraft.World/EnchantmentMenu.cpp | 2 +- Minecraft.World/File.cpp | 2 +- Minecraft.World/FireworksItem.cpp | 2 +- Minecraft.World/FlatGeneratorInfo.cpp | 2 +- Minecraft.World/IntCache.cpp | 12 +-- Minecraft.World/Level.cpp | 2 +- Minecraft.World/MerchantRecipeList.cpp | 10 +-- Minecraft.World/PotionBrewing.cpp | 22 ++--- Minecraft.World/ServersideAttributeMap.cpp | 2 +- Minecraft.World/StringHelpers.cpp | 6 +- 65 files changed, 295 insertions(+), 269 deletions(-) diff --git a/Minecraft.Client/Chunk.cpp b/Minecraft.Client/Chunk.cpp index 265f58701..6f0ad7366 100644 --- a/Minecraft.Client/Chunk.cpp +++ b/Minecraft.Client/Chunk.cpp @@ -521,7 +521,7 @@ void Chunk::rebuild() else { // Easy case - nothing already existing for this chunk. Add them all in. - for( int i = 0; i < renderableTileEntities.size(); i++ ) + for( size_t i = 0; i < renderableTileEntities.size(); i++ ) { (*globalRenderableTileEntities)[key].push_back(renderableTileEntities[i]); } @@ -826,7 +826,7 @@ void Chunk::rebuild_SPU() } // Now go through the current list. If these are already in the list, then unflag the remove flag. If they aren't, then add - for( int i = 0; i < renderableTileEntities.size(); i++ ) + for( size_t i = 0; i < renderableTileEntities.size(); i++ ) { auto it2 = find( it->second.begin(), it->second.end(), renderableTileEntities[i] ); if( it2 == it->second.end() ) @@ -842,7 +842,7 @@ void Chunk::rebuild_SPU() else { // Easy case - nothing already existing for this chunk. Add them all in. - for( int i = 0; i < renderableTileEntities.size(); i++ ) + for( size_t i = 0; i < renderableTileEntities.size(); i++ ) { (*globalRenderableTileEntities)[key].push_back(renderableTileEntities[i]); } diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index c2e5d4762..63ee763a3 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -3898,7 +3898,7 @@ void ClientConnection::handleSetPlayerTeamPacket(shared_ptr if (packet->method == SetPlayerTeamPacket::METHOD_ADD || packet->method == SetPlayerTeamPacket::METHOD_JOIN) { - for (int i = 0; i < packet->players.size(); i++) + for (size_t i = 0; i < packet->players.size(); i++) { scoreboard->addPlayerToTeam(packet->players[i], team); } @@ -3906,7 +3906,7 @@ void ClientConnection::handleSetPlayerTeamPacket(shared_ptr if (packet->method == SetPlayerTeamPacket::METHOD_LEAVE) { - for (int i = 0; i < packet->players.size(); i++) + for (size_t i = 0; i < packet->players.size(); i++) { scoreboard->removePlayerFromTeam(packet->players[i], team); } @@ -3980,7 +3980,7 @@ void ClientConnection::checkDeferredEntityLinkPackets(int newEntityId) { if (deferredEntityLinkPackets.empty()) return; - for (int i = 0; i < deferredEntityLinkPackets.size(); i++) + for (size_t i = 0; i < deferredEntityLinkPackets.size(); i++) { DeferredEntityLinkPacket *deferred = &deferredEntityLinkPackets[i]; diff --git a/Minecraft.Client/Common/Audio/SoundEngine.h b/Minecraft.Client/Common/Audio/SoundEngine.h index 5417dcec9..2134c491c 100644 --- a/Minecraft.Client/Common/Audio/SoundEngine.h +++ b/Minecraft.Client/Common/Audio/SoundEngine.h @@ -108,23 +108,23 @@ class SoundEngine : public ConsoleSoundEngine static const int MAX_SAME_SOUNDS_PLAYING = 8; // 4J added public: SoundEngine(); - virtual void destroy(); + void destroy() override; #ifdef _DEBUG void GetSoundName(char *szSoundName,int iSound); #endif - virtual void play(int iSound, float x, float y, float z, float volume, float pitch); - virtual void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true); - virtual void playUI(int iSound, float volume, float pitch); - virtual void playMusicTick(); - virtual void updateMusicVolume(float fVal); - virtual void updateSystemMusicPlaying(bool isPlaying); - virtual void updateSoundEffectVolume(float fVal); - virtual void init(Options *); - virtual void tick(shared_ptr *players, float a); // 4J - updated to take array of local players rather than single one - virtual void add(const wstring& name, File *file); - virtual void addMusic(const wstring& name, File *file); - virtual void addStreaming(const wstring& name, File *file); - virtual char *ConvertSoundPathToName(const wstring& name, bool bConvertSpaces=false); + void play(int iSound, float x, float y, float z, float volume, float pitch) override; + void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true) override; + void playUI(int iSound, float volume, float pitch) override; + void playMusicTick() override; + void updateMusicVolume(float fVal) override; + void updateSystemMusicPlaying(bool isPlaying) override; + void updateSoundEffectVolume(float fVal) override; + void init(Options *) override; + void tick(shared_ptr *players, float a) override; // 4J - updated to take array of local players rather than single one + void add(const wstring& name, File *file) override; + void addMusic(const wstring& name, File *file) override; + void addStreaming(const wstring& name, File *file) override; + char *ConvertSoundPathToName(const wstring& name, bool bConvertSpaces=false) override; bool isStreamingWavebankReady(); // 4J Added int getMusicID(int iDomain); int getMusicID(const wstring& name); @@ -138,7 +138,8 @@ class SoundEngine : public ConsoleSoundEngine #ifdef __PS3__ int initAudioHardware(int iMinSpeakers); #else - int initAudioHardware(int iMinSpeakers) { return iMinSpeakers;} + int initAudioHardware(int iMinSpeakers) override + { return iMinSpeakers;} #endif int GetRandomishTrack(int iStart,int iEnd); diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 1f393acd8..c3a623d5f 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -5564,7 +5564,7 @@ void CMinecraftApp::HandleDLC(DLCPack *pack) // 4J Stu - I don't know why we handle more than one file here any more, however this doesn't seem to work with the PS4 patches if(dlcFilenames.size() > 0) m_dlcManager.readDLCDataFile(dwFilesProcessed, dlcFilenames[0], pack); #else - for(int i=0; i::iterator it= DLCInfo.begin(); - for(int i=0;isecond)->iConfig==iTPID) { @@ -7392,7 +7392,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForProductName(WCHAR *pwchProductName) unordered_map::iterator it= DLCInfo_Full.begin(); wstring wsProductName=pwchProductName; - for(int i=0;isecond; if(wsProductName==pDLCInfo->wsDisplayName) @@ -7697,8 +7697,8 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha { PBANNEDLISTDATA pBannedList = (BANNEDLISTDATA *)(new BYTE [dwDataBytes]); - int iSize=static_cast(m_vBannedListA[iPad]->size()); - for(int i=0;isize(); + for(size_t i=0;iat(i); @@ -9809,7 +9809,7 @@ void CMinecraftApp::getLocale(vector &vecWstrLocales) locales.push_back(eMCLang_enUS); locales.push_back(eMCLang_null); - for (int i=0; i(creditValue.find_last_of(L" ", i)); + size_t iLast=creditValue.find_last_of(L" ", i); switch(XGetLanguage()) { case XC_LANGUAGE_JAPANESE: @@ -96,7 +96,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype, cons iLast = maximumChars; break; default: - iLast=static_cast(creditValue.find_last_of(L" ", i)); + iLast=creditValue.find_last_of(L" ", i); break; } @@ -198,7 +198,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) return true; } -int DLCAudioFile::GetCountofType(DLCAudioFile::EAudioType eType) +int DLCAudioFile::GetCountofType(EAudioType eType) { return m_parameters[eType].size(); } diff --git a/Minecraft.Client/Common/DLC/DLCAudioFile.h b/Minecraft.Client/Common/DLC/DLCAudioFile.h index f1a356fe9..501317859 100644 --- a/Minecraft.Client/Common/DLC/DLCAudioFile.h +++ b/Minecraft.Client/Common/DLC/DLCAudioFile.h @@ -32,11 +32,11 @@ class DLCAudioFile : public DLCFile DLCAudioFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; + PBYTE getData(DWORD &dwBytes) override; bool processDLCDataFile(PBYTE pbData, DWORD dwLength); - int GetCountofType(DLCAudioFile::EAudioType ptype); + int GetCountofType(EAudioType ptype); wstring &GetSoundName(int iIndex); private: @@ -49,6 +49,6 @@ class DLCAudioFile : public DLCFile vector m_parameters[e_AudioType_Max]; // use the EAudioType to order these - void addParameter(DLCAudioFile::EAudioType type, DLCAudioFile::EAudioParameterType ptype, const wstring &value); - DLCAudioFile::EAudioParameterType getParameterType(const wstring ¶mName); + void addParameter(EAudioType type, EAudioParameterType ptype, const wstring &value); + EAudioParameterType getParameterType(const wstring ¶mName); }; diff --git a/Minecraft.Client/Common/DLC/DLCCapeFile.h b/Minecraft.Client/Common/DLC/DLCCapeFile.h index 8373d340a..9e9466c6e 100644 --- a/Minecraft.Client/Common/DLC/DLCCapeFile.h +++ b/Minecraft.Client/Common/DLC/DLCCapeFile.h @@ -6,5 +6,5 @@ class DLCCapeFile : public DLCFile public: DLCCapeFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCColourTableFile.h b/Minecraft.Client/Common/DLC/DLCColourTableFile.h index 842697391..ded6f515e 100644 --- a/Minecraft.Client/Common/DLC/DLCColourTableFile.h +++ b/Minecraft.Client/Common/DLC/DLCColourTableFile.h @@ -10,9 +10,9 @@ class DLCColourTableFile : public DLCFile public: DLCColourTableFile(const wstring &path); - ~DLCColourTableFile(); + ~DLCColourTableFile() override; - virtual void addData(PBYTE pbData, DWORD dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; - ColourTable *getColourTable() { return m_colourTable; } + ColourTable *getColourTable() const { return m_colourTable; } }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCFile.h b/Minecraft.Client/Common/DLC/DLCFile.h index 5836c509d..31b638ef6 100644 --- a/Minecraft.Client/Common/DLC/DLCFile.h +++ b/Minecraft.Client/Common/DLC/DLCFile.h @@ -12,9 +12,9 @@ class DLCFile DLCFile(DLCManager::EDLCType type, const wstring &path); virtual ~DLCFile() {} - DLCManager::EDLCType getType() { return m_type; } + DLCManager::EDLCType getType() const { return m_type; } wstring getPath() { return m_path; } - DWORD getSkinID() { return m_dwSkinId; } + DWORD getSkinID() const { return m_dwSkinId; } virtual void addData(PBYTE pbData, DWORD dwBytes) {} virtual PBYTE getData(DWORD &dwBytes) { dwBytes = 0; return nullptr; } diff --git a/Minecraft.Client/Common/DLC/DLCGameRulesFile.h b/Minecraft.Client/Common/DLC/DLCGameRulesFile.h index e6456d73a..671cab6a9 100644 --- a/Minecraft.Client/Common/DLC/DLCGameRulesFile.h +++ b/Minecraft.Client/Common/DLC/DLCGameRulesFile.h @@ -10,6 +10,6 @@ class DLCGameRulesFile : public DLCGameRules public: DLCGameRulesFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; + PBYTE getData(DWORD &dwBytes) override; }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCGameRulesHeader.h b/Minecraft.Client/Common/DLC/DLCGameRulesHeader.h index 4521ae110..7409540d1 100644 --- a/Minecraft.Client/Common/DLC/DLCGameRulesHeader.h +++ b/Minecraft.Client/Common/DLC/DLCGameRulesHeader.h @@ -14,29 +14,52 @@ class DLCGameRulesHeader : public DLCGameRules, public JustGrSource bool m_hasData; public: - virtual bool requiresTexturePack() {return m_bRequiresTexturePack;} - virtual UINT getRequiredTexturePackId() {return m_requiredTexturePackId;} - virtual wstring getDefaultSaveName() {return m_defaultSaveName;} - virtual LPCWSTR getWorldName() {return m_worldName.c_str();} - virtual LPCWSTR getDisplayName() {return m_displayName.c_str();} - virtual wstring getGrfPath() {return L"GameRules.grf";} - - virtual void setRequiresTexturePack(bool x) {m_bRequiresTexturePack = x;} - virtual void setRequiredTexturePackId(UINT x) {m_requiredTexturePackId = x;} - virtual void setDefaultSaveName(const wstring &x) {m_defaultSaveName = x;} - virtual void setWorldName(const wstring & x) {m_worldName = x;} - virtual void setDisplayName(const wstring & x) {m_displayName = x;} - virtual void setGrfPath(const wstring & x) {m_grfPath = x;} + bool requiresTexturePack() override + {return m_bRequiresTexturePack;} + + UINT getRequiredTexturePackId() override + {return m_requiredTexturePackId;} + + wstring getDefaultSaveName() override + {return m_defaultSaveName;} + + LPCWSTR getWorldName() override + {return m_worldName.c_str();} + + LPCWSTR getDisplayName() override + {return m_displayName.c_str();} + + wstring getGrfPath() override + {return L"GameRules.grf";} + + void setRequiresTexturePack(bool x) override + {m_bRequiresTexturePack = x;} + + void setRequiredTexturePackId(UINT x) override + {m_requiredTexturePackId = x;} + + void setDefaultSaveName(const wstring &x) override + {m_defaultSaveName = x;} + + void setWorldName(const wstring & x) override + {m_worldName = x;} + + void setDisplayName(const wstring & x) override + {m_displayName = x;} + + void setGrfPath(const wstring & x) override + {m_grfPath = x;} LevelGenerationOptions *lgo; public: DLCGameRulesHeader(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; + PBYTE getData(DWORD &dwBytes) override; void setGrfData(PBYTE fData, DWORD fSize, StringTable *); - virtual bool ready() { return m_hasData; } + bool ready() override + { return m_hasData; } }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCLocalisationFile.h b/Minecraft.Client/Common/DLC/DLCLocalisationFile.h index 083e60d8b..419d714d6 100644 --- a/Minecraft.Client/Common/DLC/DLCLocalisationFile.h +++ b/Minecraft.Client/Common/DLC/DLCLocalisationFile.h @@ -12,7 +12,7 @@ class DLCLocalisationFile : public DLCFile DLCLocalisationFile(const wstring &path); DLCLocalisationFile(PBYTE pbData, DWORD dwBytes); // when we load in a texture pack details file from TMS++ - virtual void addData(PBYTE pbData, DWORD dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; StringTable *getStringTable() { return m_strings; } }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index 90061df6e..931b0e1d9 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -373,7 +373,7 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DL bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack) { - unordered_map parameterMapping; + unordered_map parameterMapping; unsigned int uiCurrentByte=0; // File format defined in the DLC_Creator @@ -405,8 +405,8 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD { // Map DLC strings to application strings, then store the DLC index mapping to application index wstring parameterName(static_cast(pParams->wchData)); - DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); - if( type != DLCManager::e_DLCParamType_Invalid ) + EDLCParameterType type = getParameterType(parameterName); + if( type != e_DLCParamType_Invalid ) { parameterMapping[pParams->dwType] = type; } @@ -430,7 +430,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD for(unsigned int i=0;i(pFile->dwType); + EDLCType type = static_cast(pFile->dwType); DLCFile *dlcFile = nullptr; DLCPack *dlcTexturePack = nullptr; @@ -485,7 +485,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD { pack->addChildPack(dlcTexturePack); - if(dlcTexturePack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0) + if(dlcTexturePack->getDLCItemsCount(e_DLCType_Texture) > 0) { Minecraft::GetInstance()->skins->addTexturePackFromDLC(dlcTexturePack, dlcTexturePack->GetPackId() ); } @@ -500,7 +500,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD // TODO - 4J Stu Remove the need for this vSkinNames vector, or manage it differently switch(pFile->dwType) { - case DLCManager::e_DLCType_Skin: + case e_DLCType_Skin: app.vSkinNames.push_back((WCHAR *)pFile->wchFile); break; } @@ -515,13 +515,13 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; } - if( pack->getDLCItemsCount(DLCManager::e_DLCType_GameRules) > 0 - || pack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader) > 0) + if( pack->getDLCItemsCount(e_DLCType_GameRules) > 0 + || pack->getDLCItemsCount(e_DLCType_GameRulesHeader) > 0) { app.m_gameRules.loadGameRules(pack); } - if(pack->getDLCItemsCount(DLCManager::e_DLCType_Audio) > 0) + if(pack->getDLCItemsCount(e_DLCType_Audio) > 0) { //app.m_Audio.loadAudioDetails(pack); } @@ -580,7 +580,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) { DWORD packId=0; bool bPackIDSet=false; - unordered_map parameterMapping; + unordered_map parameterMapping; unsigned int uiCurrentByte=0; // File format defined in the DLC_Creator @@ -610,8 +610,8 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) { // Map DLC strings to application strings, then store the DLC index mapping to application index wstring parameterName(static_cast(pParams->wchData)); - DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); - if( type != DLCManager::e_DLCParamType_Invalid ) + EDLCParameterType type = getParameterType(parameterName); + if( type != e_DLCParamType_Invalid ) { parameterMapping[pParams->dwType] = type; } @@ -634,7 +634,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) for(unsigned int i=0;i(pFile->dwType); + EDLCType type = static_cast(pFile->dwType); // Params uiParameterCount=*(unsigned int *)pbTemp; diff --git a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp index 2416c9439..f7ef2ad00 100644 --- a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp @@ -79,7 +79,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring { i++; } - int iLast=static_cast(creditValue.find_last_of(L" ", i)); + size_t iLast=creditValue.find_last_of(L" ", i); switch(XGetLanguage()) { case XC_LANGUAGE_JAPANESE: @@ -88,7 +88,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring iLast = maximumChars; break; default: - iLast=static_cast(creditValue.find_last_of(L" ", i)); + iLast=creditValue.find_last_of(L" ", i); break; } diff --git a/Minecraft.Client/Common/DLC/DLCSkinFile.h b/Minecraft.Client/Common/DLC/DLCSkinFile.h index c8dcf0e9c..15a50e717 100644 --- a/Minecraft.Client/Common/DLC/DLCSkinFile.h +++ b/Minecraft.Client/Common/DLC/DLCSkinFile.h @@ -17,11 +17,11 @@ class DLCSkinFile : public DLCFile DLCSkinFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value); + void addData(PBYTE pbData, DWORD dwBytes) override; + void addParameter(DLCManager::EDLCParameterType type, const wstring &value) override; - virtual wstring getParameterAsString(DLCManager::EDLCParameterType type); - virtual bool getParameterAsBool(DLCManager::EDLCParameterType type); + wstring getParameterAsString(DLCManager::EDLCParameterType type) override; + bool getParameterAsBool(DLCManager::EDLCParameterType type) override; vector *getAdditionalBoxes(); int getAdditionalBoxesCount(); unsigned int getAnimOverrideBitmask() { return m_uiAnimOverrideBitmask;} diff --git a/Minecraft.Client/Common/DLC/DLCTextureFile.h b/Minecraft.Client/Common/DLC/DLCTextureFile.h index bc7916867..2b397e8e3 100644 --- a/Minecraft.Client/Common/DLC/DLCTextureFile.h +++ b/Minecraft.Client/Common/DLC/DLCTextureFile.h @@ -14,11 +14,11 @@ class DLCTextureFile : public DLCFile public: DLCTextureFile(const wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + void addData(PBYTE pbData, DWORD dwBytes) override; + PBYTE getData(DWORD &dwBytes) override; - virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value); + void addParameter(DLCManager::EDLCParameterType type, const wstring &value) override; - virtual wstring getParameterAsString(DLCManager::EDLCParameterType type); - virtual bool getParameterAsBool(DLCManager::EDLCParameterType type); + wstring getParameterAsString(DLCManager::EDLCParameterType type) override; + bool getParameterAsBool(DLCManager::EDLCParameterType type) override; }; \ No newline at end of file diff --git a/Minecraft.Client/Common/DLC/DLCUIDataFile.h b/Minecraft.Client/Common/DLC/DLCUIDataFile.h index 105ad0dfd..c858933cc 100644 --- a/Minecraft.Client/Common/DLC/DLCUIDataFile.h +++ b/Minecraft.Client/Common/DLC/DLCUIDataFile.h @@ -10,11 +10,11 @@ class DLCUIDataFile : public DLCFile public: DLCUIDataFile(const wstring &path); - ~DLCUIDataFile(); + ~DLCUIDataFile() override; using DLCFile::addData; using DLCFile::addParameter; virtual void addData(PBYTE pbData, DWORD dwBytes,bool canDeleteData = false); - virtual PBYTE getData(DWORD &dwBytes); + PBYTE getData(DWORD &dwBytes) override; }; diff --git a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp index f45a00430..0b1e0df24 100644 --- a/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_TradingMenu.cpp @@ -243,7 +243,7 @@ void IUIScene_TradingMenu::updateDisplay() // 4J-PB - need to get the villager type here wsTemp = app.GetString(IDS_VILLAGER_OFFERS_ITEM); wsTemp = replaceAll(wsTemp,L"{*VILLAGER_TYPE*}",m_merchant->getDisplayName()); - int iPos=wsTemp.find(L"%s"); + size_t iPos=wsTemp.find(L"%s"); wsTemp.replace(iPos,2,activeRecipe->getSellItem()->getHoverName()); setTitle(wsTemp.c_str()); diff --git a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp index c1381c44c..fcbd17f34 100644 --- a/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_TutorialPopup.cpp @@ -219,13 +219,13 @@ wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, m_iconItem = nullptr; wstring openTag(L"{*ICON*}"); wstring closeTag(L"{*/ICON*}"); - int iconTagStartPos = static_cast(temp.find(openTag)); - int iconStartPos = iconTagStartPos + static_cast(openTag.length()); - if( iconTagStartPos > 0 && iconStartPos < static_cast(temp.length()) ) + size_t iconTagStartPos = temp.find(openTag); + size_t iconStartPos = iconTagStartPos + openTag.length(); + if( iconTagStartPos > 0 && iconStartPos < temp.length() ) { - int iconEndPos = static_cast(temp.find(closeTag, iconStartPos)); + size_t iconEndPos = temp.find(closeTag, iconStartPos); - if(iconEndPos > iconStartPos && iconEndPos < static_cast(temp.length()) ) + if(iconEndPos > iconStartPos && iconEndPos < temp.length() ) { wstring id = temp.substr(iconStartPos, iconEndPos - iconStartPos); @@ -341,13 +341,13 @@ wstring UIComponent_TutorialPopup::_SetImage(wstring &desc) wstring openTag(L"{*IMAGE*}"); wstring closeTag(L"{*/IMAGE*}"); - int imageTagStartPos = (int)desc.find(openTag); - int imageStartPos = imageTagStartPos + (int)openTag.length(); - if( imageTagStartPos > 0 && imageStartPos < (int)desc.length() ) + size_t imageTagStartPos = desc.find(openTag); + size_t imageStartPos = imageTagStartPos + openTag.length(); + if( imageTagStartPos > 0 && imageStartPos < desc.length() ) { - int imageEndPos = (int)desc.find( closeTag, imageStartPos ); + size_t imageEndPos = desc.find( closeTag, imageStartPos ); - if(imageEndPos > imageStartPos && imageEndPos < (int)desc.length() ) + if(imageEndPos > imageStartPos && imageEndPos < desc.length() ) { wstring id = desc.substr(imageStartPos, imageEndPos - imageStartPos); m_image.SetImagePath( id.c_str() ); diff --git a/Minecraft.Client/Common/UI/UILayer.cpp b/Minecraft.Client/Common/UI/UILayer.cpp index 5c9d701b9..bf360c07f 100644 --- a/Minecraft.Client/Common/UI/UILayer.cpp +++ b/Minecraft.Client/Common/UI/UILayer.cpp @@ -102,7 +102,7 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) bool UILayer::IsSceneInStack(EUIScene scene) { bool inStack = false; - for(int i = m_sceneStack.size() - 1;i >= 0; --i) + for(size_t i = (int)m_sceneStack.size() - 1;i >= 0; --i) { if(m_sceneStack[i]->getSceneType() == scene) { @@ -118,7 +118,7 @@ bool UILayer::HasFocus(int iPad) bool hasFocus = false; if(m_hasFocus) { - for(int i = m_sceneStack.size() - 1;i >= 0; --i) + for(size_t i = (int)m_sceneStack.size() - 1;i >= 0; --i) { if(m_sceneStack[i]->stealsFocus() ) { @@ -146,7 +146,7 @@ bool UILayer::hidesLowerScenes() } if(!hidesScenes && !m_sceneStack.empty()) { - for(int i = m_sceneStack.size() - 1;i >= 0; --i) + for(size_t i = (int)m_sceneStack.size() - 1;i >= 0; --i) { if(m_sceneStack[i]->hidesLowerScenes()) { @@ -897,7 +897,7 @@ void UILayer::PrintTotalMemoryUsage(int64_t &totalStatic, int64_t &totalDynamic) // Returns the first scene of given type if it exists, nullptr otherwise UIScene *UILayer::FindScene(EUIScene sceneType) { - for (int i = 0; i < m_sceneStack.size(); i++) + for (size_t i = 0; i < m_sceneStack.size(); i++) { if (m_sceneStack[i]->getSceneType() == sceneType) { diff --git a/Minecraft.Client/Common/UI/UIScene_EULA.cpp b/Minecraft.Client/Common/UI/UIScene_EULA.cpp index 492657b03..411956212 100644 --- a/Minecraft.Client/Common/UI/UIScene_EULA.cpp +++ b/Minecraft.Client/Common/UI/UIScene_EULA.cpp @@ -48,8 +48,8 @@ UIScene_EULA::UIScene_EULA(int iPad, void *initData, UILayer *parentLayer) : UIS #endif vector paragraphs; - int lastIndex = 0; - for ( int index = EULA.find(L"\r\n", lastIndex, 2); + size_t lastIndex = 0; + for ( size_t index = EULA.find(L"\r\n", lastIndex, 2); index != wstring::npos; index = EULA.find(L"\r\n", lastIndex, 2) ) diff --git a/Minecraft.Client/Common/UI/UIScene_HowToPlay.cpp b/Minecraft.Client/Common/UI/UIScene_HowToPlay.cpp index 204c31a48..bc7218027 100644 --- a/Minecraft.Client/Common/UI/UIScene_HowToPlay.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HowToPlay.cpp @@ -300,8 +300,8 @@ void UIScene_HowToPlay::StartPage( EHowToPlayPage ePage ) finalText = startTags + finalText; vector paragraphs; - int lastIndex = 0; - for ( int index = finalText.find(L"\r\n", lastIndex, 2); + size_t lastIndex = 0; + for ( size_t index = finalText.find(L"\r\n", lastIndex, 2); index != wstring::npos; index = finalText.find(L"\r\n", lastIndex, 2) ) diff --git a/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp b/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp index c3136deb9..118712a46 100644 --- a/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp +++ b/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp @@ -19,8 +19,8 @@ UIScene_NewUpdateMessage::UIScene_NewUpdateMessage(int iPad, void *initData, UIL message=app.FormatHTMLString(m_iPad,message); vector paragraphs; - int lastIndex = 0; - for ( int index = message.find(L"\r\n", lastIndex, 2); + size_t lastIndex = 0; + for ( size_t index = message.find(L"\r\n", lastIndex, 2); index != wstring::npos; index = message.find(L"\r\n", lastIndex, 2) ) diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp index bd63d1963..36a12757c 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Anvil.cpp @@ -89,8 +89,8 @@ HRESULT CXuiSceneAnvil::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValue // strip leading spaces wstring b; - int start = static_cast(newValue.find_first_not_of(L" ")); - int end = static_cast(newValue.find_last_not_of(L" ")); + size_t start = newValue.find_first_not_of(L" "); + size_t end = newValue.find_last_not_of(L" "); if( start == wstring::npos ) { @@ -99,7 +99,7 @@ HRESULT CXuiSceneAnvil::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValue } else { - if( end == wstring::npos ) end = static_cast(newValue.size())-1; + if( end == wstring::npos ) end = newValue.size() - 1; b = newValue.substr(start,(end-start)+1); newValue=b; } diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp index e61815d9b..c4c279a61 100644 --- a/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Win.cpp @@ -57,13 +57,13 @@ HRESULT CScene_Win::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) noNoiseString = app.FormatHTMLString(m_iPad, noNoiseString, 0xff000000); Random random(8124371); - int found=static_cast(noNoiseString.find_first_of(L"{")); - int length; + size_t found=noNoiseString.find_first_of(L"{"); + size_t length; while (found!=string::npos) { length = random.nextInt(4) + 3; m_noiseLengths.push_back(length); - found=static_cast(noNoiseString.find_first_of(L"{", found + 1)); + found=noNoiseString.find_first_of(L"{", found + 1); } Minecraft *pMinecraft = Minecraft::GetInstance(); diff --git a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp index 3c9c936eb..29893d041 100644 --- a/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp +++ b/Minecraft.Client/Common/XUI/XUI_TutorialPopup.cpp @@ -298,13 +298,13 @@ wstring CScene_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWS { wstring openTag(L"{*ICON*}"); wstring closeTag(L"{*/ICON*}"); - int iconTagStartPos = static_cast(temp.find(openTag)); - int iconStartPos = iconTagStartPos + static_cast(openTag.length()); - if( iconTagStartPos > 0 && iconStartPos < static_cast(temp.length()) ) + size_t iconTagStartPos = temp.find(openTag); + size_t iconStartPos = iconTagStartPos + openTag.length(); + if( iconTagStartPos > 0 && iconStartPos < temp.length() ) { - int iconEndPos = static_cast(temp.find(closeTag, iconStartPos)); + size_t iconEndPos = temp.find(closeTag, iconStartPos); - if(iconEndPos > iconStartPos && iconEndPos < static_cast(temp.length()) ) + if(iconEndPos > iconStartPos && iconEndPos < temp.length() ) { wstring id = temp.substr(iconStartPos, iconEndPos - iconStartPos); @@ -443,13 +443,13 @@ wstring CScene_TutorialPopup::_SetImage(wstring &desc) wstring openTag(L"{*IMAGE*}"); wstring closeTag(L"{*/IMAGE*}"); - int imageTagStartPos = static_cast(desc.find(openTag)); - int imageStartPos = imageTagStartPos + static_cast(openTag.length()); - if( imageTagStartPos > 0 && imageStartPos < static_cast(desc.length()) ) + size_t imageTagStartPos = desc.find(openTag); + size_t imageStartPos = imageTagStartPos + openTag.length(); + if( imageTagStartPos > 0 && imageStartPos < desc.length() ) { - int imageEndPos = static_cast(desc.find(closeTag, imageStartPos)); + size_t imageEndPos = desc.find(closeTag, imageStartPos); - if(imageEndPos > imageStartPos && imageEndPos < static_cast(desc.length()) ) + if(imageEndPos > imageStartPos && imageEndPos < desc.length() ) { wstring id = desc.substr(imageStartPos, imageEndPos - imageStartPos); m_image.SetImagePath( id.c_str() ); diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp index 3e6652d8a..9e9e78c0c 100644 --- a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp +++ b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp @@ -892,7 +892,7 @@ void DQRNetworkManager::Tick_VoiceChat() #endif // If we have to inform the chat integration layer of any players that have joined, do that now EnterCriticalSection(&m_csVecChatPlayers); - for( int i = 0; i < m_vecChatPlayersJoined.size(); i++ ) + for( size_t i = 0; i < m_vecChatPlayersJoined.size(); i++ ) { int idx = m_vecChatPlayersJoined[i]; if( m_chat ) @@ -1509,12 +1509,12 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData) } memcpy(&m_roomSyncData, pNewSyncData, sizeof(m_roomSyncData)); - for( int i = 0; i < tempPlayers.size(); i++ ) + for( size_t i = 0; i < tempPlayers.size(); i++ ) { m_listener->HandlePlayerLeaving(tempPlayers[i]); delete tempPlayers[i]; } - for( int i = 0; i < newPlayers.size(); i++ ) + for( size_t i = 0; i < newPlayers.size(); i++ ) { m_listener->HandlePlayerJoined(newPlayers[i]); // For clients, this is where we get notified of local and remote players joining } @@ -1592,7 +1592,7 @@ void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int ses } m_roomSyncData.playerCount = iWriteIdx; - for( int i = 0; i < removedPlayers.size(); i++ ) + for( size_t i = 0; i < removedPlayers.size(); i++ ) { m_listener->HandlePlayerLeaving(removedPlayers[i]); delete removedPlayers[i]; @@ -1623,7 +1623,7 @@ void DQRNetworkManager::RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer) } m_roomSyncData.playerCount = iWriteIdx; - for( int i = 0; i < removedPlayers.size(); i++ ) + for( size_t i = 0; i < removedPlayers.size(); i++ ) { m_listener->HandlePlayerLeaving(removedPlayers[i]); delete removedPlayers[i]; diff --git a/Minecraft.Client/Font.cpp b/Minecraft.Client/Font.cpp index e8a7c869d..b6d96e8e7 100644 --- a/Minecraft.Client/Font.cpp +++ b/Minecraft.Client/Font.cpp @@ -602,7 +602,7 @@ bool Font::AllCharactersValid(const wstring &str) continue; } - int index = SharedConstants::acceptableLetters.find(c); + size_t index = SharedConstants::acceptableLetters.find(c); if ((c != ' ') && !(index > 0 && !enforceUnicodeSheet)) { diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index f9810a365..6217bc40c 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -28,6 +28,7 @@ #include "..\Minecraft.World\net.minecraft.world.h" #include "..\Minecraft.World\LevelChunk.h" #include "..\Minecraft.World\Biome.h" +#include ResourceLocation Gui::PUMPKIN_BLUR_LOCATION = ResourceLocation(TN__BLUR__MISC_PUMPKINBLUR); @@ -87,7 +88,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) int quickSelectHeight=22; float fScaleFactorWidth=1.0f,fScaleFactorHeight=1.0f; bool bTwoPlayerSplitscreen=false; - currentGuiScaleFactor = (float) guiScale; // Keep static copy of scale so we know how gui coordinates map to physical pixels - this is also affected by the viewport + currentGuiScaleFactor = static_cast(guiScale); // Keep static copy of scale so we know how gui coordinates map to physical pixels - this is also affected by the viewport switch(guiScale) { @@ -117,7 +118,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) iSafezoneYHalf = splitYOffset; iSafezoneTopYHalf = screenHeight/10; fScaleFactorWidth=0.5f; - iWidthOffset=(int)((float)screenWidth*(1.0f - fScaleFactorWidth)); + iWidthOffset=static_cast((float)screenWidth * (1.0f - fScaleFactorWidth)); iTooltipsYOffset=44; bTwoPlayerSplitscreen=true; currentGuiScaleFactor *= 0.5f; @@ -127,7 +128,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) iSafezoneYHalf = splitYOffset + screenHeight/10;// 5% (need to treat the whole screen is 2x this screen) iSafezoneTopYHalf = 0; fScaleFactorWidth=0.5f; - iWidthOffset=(int)((float)screenWidth*(1.0f - fScaleFactorWidth)); + iWidthOffset=static_cast((float)screenWidth * (1.0f - fScaleFactorWidth)); iTooltipsYOffset=44; bTwoPlayerSplitscreen=true; currentGuiScaleFactor *= 0.5f; @@ -697,7 +698,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) #endif glPushMatrix(); - glTranslatef((float)xo, (float)yo, 50); + glTranslatef(static_cast(xo), static_cast(yo), 50); float ss = 12; glScalef(-ss, ss, ss); glRotatef(180, 0, 0, 1); @@ -806,14 +807,14 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) glDisable(GL_DEPTH_TEST); glDisable(GL_ALPHA_TEST); int timer = minecraft->player->getSleepTimer(); - float amount = (float) timer / (float) Player::SLEEP_DURATION; + float amount = static_cast(timer) / static_cast(Player::SLEEP_DURATION); if (amount > 1) { // waking up - amount = 1.0f - ((float) (timer - Player::SLEEP_DURATION) / (float) Player::WAKE_UP_DURATION); + amount = 1.0f - (static_cast(timer - Player::SLEEP_DURATION) / static_cast(Player::WAKE_UP_DURATION)); } - int color = (int) (220.0f * amount) << 24 | (0x101020); + int color = static_cast(220.0f * amount) << 24 | (0x101020); fill(0, 0, screenWidth/fScaleFactorWidth, screenHeight/fScaleFactorHeight, color); glEnable(GL_ALPHA_TEST); glEnable(GL_DEPTH_TEST); @@ -825,9 +826,9 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) glDisable(GL_DEPTH_TEST); glDisable(GL_ALPHA_TEST); int timer = minecraft->player->getDeathFadeTimer(); - float amount = (float) timer / (float) Player::DEATHFADE_DURATION; + float amount = static_cast(timer) / static_cast(Player::DEATHFADE_DURATION); - int color = (int) (220.0f * amount) << 24 | (0x200000); + int color = static_cast(220.0f * amount) << 24 | (0x200000); fill(0, 0, screenWidth/fScaleFactorWidth, screenHeight/fScaleFactorHeight, color); glEnable(GL_ALPHA_TEST); glEnable(GL_DEPTH_TEST); @@ -850,15 +851,15 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) const int debugTop = 1; const float maxContentWidth = 1200.f; const float maxContentHeight = 420.f; - float scale = (float)(screenWidth - debugLeft - 8) / maxContentWidth; - float scaleV = (float)(screenHeight - debugTop - 80) / maxContentHeight; + float scale = static_cast(screenWidth - debugLeft - 8) / maxContentWidth; + float scaleV = static_cast(screenHeight - debugTop - 80) / maxContentHeight; if (scaleV < scale) scale = scaleV; if (scale > 1.f) scale = 1.f; if (scale < 0.5f) scale = 0.5f; glPushMatrix(); - glTranslatef((float)debugLeft, (float)debugTop, 0.f); + glTranslatef(static_cast(debugLeft), static_cast(debugTop), 0.f); glScalef(scale, scale, 1.f); - glTranslatef((float)-debugLeft, (float)-debugTop, 0.f); + glTranslatef(static_cast(-debugLeft), static_cast(-debugTop), 0.f); vector lines; @@ -984,11 +985,11 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) wfeature[eTerrainFeature_Village] = L"Village: "; wfeature[eTerrainFeature_Ravine] = L"Ravine: "; - float maxW = (float)(screenWidth - debugLeft - 8) / scale; - float maxWForContent = maxW - (float)font->width(L"..."); + float maxW = static_cast(screenWidth - debugLeft - 8) / scale; + float maxWForContent = maxW - static_cast(font->width(L"...")); bool truncated[eTerrainFeature_Count] = {}; - for (int i = 0; i < (int)app.m_vTerrainFeatures.size(); i++) + for (size_t i = 0; i < app.m_vTerrainFeatures.size(); i++) { FEATURE_DATA *pFeatureData = app.m_vTerrainFeatures[i]; int type = pFeatureData->eTerrainFeature; @@ -1014,7 +1015,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) } lines.push_back(L""); // Add a spacer line - for (int i = eTerrainFeature_Stronghold; i <= (int)eTerrainFeature_Ravine; i++) + for (int i = eTerrainFeature_Stronghold; i <= static_cast(eTerrainFeature_Ravine); i++) { lines.push_back(wfeature[i]); } @@ -1241,10 +1242,10 @@ void Gui::renderPumpkin(int w, int h) MemSect(0); Tesselator *t = Tesselator::getInstance(); t->begin(); - t->vertexUV((float)(0), (float)( h), (float)( -90), (float)( 0), (float)( 1)); - t->vertexUV((float)(w), (float)( h), (float)( -90), (float)( 1), (float)( 1)); - t->vertexUV((float)(w), (float)( 0), (float)( -90), (float)( 1), (float)( 0)); - t->vertexUV((float)(0), (float)( 0), (float)( -90), (float)( 0), (float)( 0)); + t->vertexUV(static_cast(0), static_cast(h), static_cast(-90), static_cast(0), static_cast(1)); + t->vertexUV(static_cast(w), static_cast(h), static_cast(-90), static_cast(1), static_cast(1)); + t->vertexUV(static_cast(w), static_cast(0), static_cast(-90), static_cast(1), static_cast(0)); + t->vertexUV(static_cast(0), static_cast(0), static_cast(-90), static_cast(0), static_cast(0)); t->end(); glDepthMask(true); glEnable(GL_DEPTH_TEST); @@ -1305,10 +1306,10 @@ void Gui::renderTp(float br, int w, int h) float v1 = slot->getV1(); Tesselator *t = Tesselator::getInstance(); t->begin(); - t->vertexUV((float)(0), (float)( h), (float)( -90), (float)( u0), (float)( v1)); - t->vertexUV((float)(w), (float)( h), (float)( -90), (float)( u1), (float)( v1)); - t->vertexUV((float)(w), (float)( 0), (float)( -90), (float)( u1), (float)( v0)); - t->vertexUV((float)(0), (float)( 0), (float)( -90), (float)( u0), (float)( v0)); + t->vertexUV(static_cast(0), static_cast(h), static_cast(-90), (float)( u0), (float)( v1)); + t->vertexUV(static_cast(w), static_cast(h), static_cast(-90), (float)( u1), (float)( v1)); + t->vertexUV(static_cast(w), static_cast(0), static_cast(-90), (float)( u1), (float)( v0)); + t->vertexUV(static_cast(0), static_cast(0), static_cast(-90), (float)( u0), (float)( v0)); t->end(); glDepthMask(true); glEnable(GL_DEPTH_TEST); @@ -1326,10 +1327,10 @@ void Gui::renderSlot(int slot, int x, int y, float a) if (pop > 0) { glPushMatrix(); - float squeeze = 1 + pop / (float) Inventory::POP_TIME_DURATION; - glTranslatef((float)(x + 8), (float)(y + 12), 0); + float squeeze = 1 + pop / static_cast(Inventory::POP_TIME_DURATION); + glTranslatef(static_cast(x + 8), static_cast(y + 12), 0); glScalef(1 / squeeze, (squeeze + 1) / 2, 1); - glTranslatef((float)-(x + 8), (float)-(y + 12), 0); + glTranslatef(static_cast(-(x + 8)), static_cast(-(y + 12)), 0); } itemRenderer->renderAndDecorateItem(minecraft->font, minecraft->textures, item, x, y); @@ -1468,7 +1469,7 @@ void Gui::addMessage(const wstring& _string,int iPad,bool bIsDeathMessage) { i++; } - int iLast=(int)string.find_last_of(L" ",i); + size_t iLast=string.find_last_of(L" ",i); switch(XGetLanguage()) { case XC_LANGUAGE_JAPANESE: @@ -1477,7 +1478,7 @@ void Gui::addMessage(const wstring& _string,int iPad,bool bIsDeathMessage) iLast = maximumChars; break; default: - iLast=(int)string.find_last_of(L" ",i); + iLast=string.find_last_of(L" ",i); break; } @@ -1537,7 +1538,7 @@ float Gui::getOpacity(int iPad, DWORD index) float Gui::getJukeboxOpacity(int iPad) { float t = overlayMessageTime - lastTickA; - int alpha = (int) (t * 256 / 20); + int alpha = static_cast(t * 256 / 20); if (alpha > 255) alpha = 255; alpha /= 255; @@ -1571,7 +1572,7 @@ void Gui::renderGraph(int dataLength, int dataPos, int64_t *dataA, float dataASc glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0, (float)minecraft->width, (float)height, 0, 1000, 3000); + glOrtho(0, static_cast(minecraft->width), static_cast(height), 0, 1000, 3000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -2000); @@ -1602,8 +1603,8 @@ void Gui::renderGraph(int dataLength, int dataPos, int64_t *dataA, float dataASc int64_t aVal = dataA[i] / dataAScale; - t->vertex((float)(xScale*i + 0.5f), (float)( height - aVal + 0.5f), (float)( 0)); - t->vertex((float)(xScale*i + 0.5f), (float)( height + 0.5f), (float)( 0)); + t->vertex((float)(xScale*i + 0.5f), (float)( height - aVal + 0.5f), static_cast(0)); + t->vertex((float)(xScale*i + 0.5f), (float)( height + 0.5f), static_cast(0)); } if( dataB != NULL ) @@ -1619,8 +1620,8 @@ void Gui::renderGraph(int dataLength, int dataPos, int64_t *dataA, float dataASc int64_t bVal = dataB[i] / dataBScale; - t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height - bVal + 0.5f), (float)( 0)); - t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height + 0.5f), (float)( 0)); + t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height - bVal + 0.5f), static_cast(0)); + t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height + 0.5f), static_cast(0)); } } t->end(); @@ -1635,7 +1636,7 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, int64 glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0, (float)minecraft->width, (float)height, 0, 1000, 3000); + glOrtho(0, static_cast(minecraft->width), static_cast(height), 0, 1000, 3000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -2000); @@ -1664,15 +1665,15 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, int64 if( thisVal > 0 ) { - float vary = (float)source/dataSources; + float vary = static_cast(source)/dataSources; int fColour = floor(vary * 0xffffff); int colour = 0xff000000 + fColour; //printf("Colour is %x\n", colour); t->color(colour); - t->vertex((float)(i + 0.5f), (float)( height - topVal - thisVal + 0.5f), (float)( 0)); - t->vertex((float)(i + 0.5f), (float)( height - topVal + 0.5f), (float)( 0)); + t->vertex((float)(i + 0.5f), (float)( height - topVal - thisVal + 0.5f), static_cast(0)); + t->vertex((float)(i + 0.5f), (float)( height - topVal + 0.5f), static_cast(0)); topVal += thisVal; } @@ -1683,8 +1684,8 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, int64 { t->color(0xff000000); - t->vertex((float)(0 + 0.5f), (float)( height - (horiz*100) + 0.5f), (float)( 0)); - t->vertex((float)(dataLength + 0.5f), (float)( height - (horiz*100) + 0.5f), (float)( 0)); + t->vertex((float)(0 + 0.5f), (float)( height - (horiz*100) + 0.5f), static_cast(0)); + t->vertex((float)(dataLength + 0.5f), (float)( height - (horiz*100) + 0.5f), static_cast(0)); } } t->end(); diff --git a/Minecraft.Client/JoinMultiplayerScreen.cpp b/Minecraft.Client/JoinMultiplayerScreen.cpp index 2e0c64d9e..f8e13fbbf 100644 --- a/Minecraft.Client/JoinMultiplayerScreen.cpp +++ b/Minecraft.Client/JoinMultiplayerScreen.cpp @@ -55,7 +55,7 @@ void JoinMultiplayerScreen::buttonClicked(Button *button) vector parts = stringSplit(ip,L'L'); if (ip[0]==L'[') { - int pos = static_cast(ip.find(L"]")); + size_t pos = ip.find(L"]"); if (pos != wstring::npos) { wstring path = ip.substr(1, pos); diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index feef3918e..8d61e1b2d 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -389,7 +389,7 @@ void LevelRenderer::setLevel(int playerIndex, MultiPlayerLevel *level) void LevelRenderer::AddDLCSkinsToMemTextures() { - for(int i=0;iaddMemTexture(app.vSkinNames[i], new MobSkinMemTextureProcessor()); } diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index 211c60aed..de9d26b93 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -2178,7 +2178,7 @@ void MinecraftServer::tick() // 4J - removed #if 0 - for (int i = 0; i < tickables.size(); i++) { + for (size_t i = 0; i < tickables.size(); i++) { tickables.get(i)-tick(); } #endif @@ -2275,7 +2275,7 @@ bool MinecraftServer::chunkPacketManagement_CanSendTo(INetworkPlayer *player) if( s_hasSentEnoughPackets ) return false; if( player == nullptr ) return false; - for( int i = 0; i < s_sentTo.size(); i++ ) + for( size_t i = 0; i < s_sentTo.size(); i++ ) { if( s_sentTo[i]->IsSameSystem(player) ) { diff --git a/Minecraft.Client/Options.cpp b/Minecraft.Client/Options.cpp index 8601af721..ebe1295af 100644 --- a/Minecraft.Client/Options.cpp +++ b/Minecraft.Client/Options.cpp @@ -422,7 +422,7 @@ void Options::load() // 4J - removed try/catch // try { wstring cmds[2]; - int splitpos = static_cast(line.find(L":")); + size_t splitpos = line.find(L":"); if( splitpos == wstring::npos ) { cmds[0] = line; diff --git a/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp index 5bc499e09..7c3e1a663 100644 --- a/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp +++ b/Minecraft.Client/Orbis/Network/SQRNetworkManager_Orbis.cpp @@ -685,7 +685,7 @@ bool SQRNetworkManager_Orbis::FriendRoomManagerSearch() } // Free up any external data that we received from the previous search - for( int i = 0; i < m_aFriendSearchResults.size(); i++ ) + for( size_t i = 0; i < m_aFriendSearchResults.size(); i++ ) { if(m_aFriendSearchResults[i].m_RoomExtDataReceived) free(m_aFriendSearchResults[i].m_RoomExtDataReceived); @@ -3358,7 +3358,7 @@ void SQRNetworkManager_Orbis::ProcessSignallingEvent(SceNpMatching2ContextId ctx void SQRNetworkManager_Orbis::SignallingEventsTick() { EnterCriticalSection(&m_signallingEventListCS); - for(int i=0;i* pProductList=&m_ProductListA[i]; for ( SonyCommerce::ProductInfo& : *pProductList ) diff --git a/Minecraft.Client/Orbis/Orbis_Minecraft.cpp b/Minecraft.Client/Orbis/Orbis_Minecraft.cpp index 3c44cf229..7531b25db 100644 --- a/Minecraft.Client/Orbis/Orbis_Minecraft.cpp +++ b/Minecraft.Client/Orbis/Orbis_Minecraft.cpp @@ -1501,7 +1501,7 @@ uint8_t * AddRichPresenceString(int iID) void FreeRichPresenceStrings() { uint8_t *strUtf8; - for(int i=0;i* pProductList=&m_ProductListA[i]; auto itEnd = pProductList->end(); @@ -842,7 +842,7 @@ bool CConsoleMinecraftApp::DLCAlreadyPurchased(char *pchTitle) // find the DLC for(int i=0;i* pProductList=&m_ProductListA[i]; auto itEnd = pProductList->end(); diff --git a/Minecraft.Client/PS3/PS3_Minecraft.cpp b/Minecraft.Client/PS3/PS3_Minecraft.cpp index e80f3ca5e..fb987a9eb 100644 --- a/Minecraft.Client/PS3/PS3_Minecraft.cpp +++ b/Minecraft.Client/PS3/PS3_Minecraft.cpp @@ -1379,7 +1379,7 @@ uint8_t * AddRichPresenceString(int iID) void FreeRichPresenceStrings() { uint8_t *strUtf8; - for(int i=0;im_roomMemberId); } - for(int i=0;im_aFriendSearchResults.size(); i++) + for(size_t i=0; im_aFriendSearchResults.size(); i++) { if(manager->m_aFriendSearchResults[i].m_netAddr.s_addr == peer->s_addr) { @@ -2852,7 +2852,7 @@ int SQRNetworkManager_AdHoc_Vita::GetRemovedMask(int newMask, int oldMask) void SQRNetworkManager_AdHoc_Vita::GetExtDataForRoom( SceNpMatching2RoomId roomId, void *extData, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ) { - for(int i=0;i& connections) { - for(int rIdx=0;rIdxm_bConnected) @@ -668,7 +668,7 @@ void SonyVoiceChat_Vita::tick() EnterCriticalSection(&m_csRemoteConnections); - for(int i=m_remoteConnections.size()-1;i>=0;i--) + for(size_t i=m_remoteConnections.size()-1;i>=0;i--) { if(m_remoteConnections[i]->m_bFlaggedForShutdown) { @@ -998,7 +998,7 @@ void SonyVoiceChat_Vita::disconnectLocalPlayer( int localIdx ) if(m_numLocalDevicesConnected == 0) // no more local players, kill all the remote connections { - for(int i=0;i* pProductList=&m_ProductListA[i]; auto itEnd = pProductList->end(); @@ -617,7 +617,7 @@ void CConsoleMinecraftApp::Checkout(char *pchSkuID) for(int i=0;i* pProductList=&m_ProductListA[i]; auto itEnd = pProductList->end(); @@ -697,7 +697,7 @@ bool CConsoleMinecraftApp::DLCAlreadyPurchased(char *pchTitle) // find the DLC for(int i=0;i* pProductList=&m_ProductListA[i]; auto itEnd = pProductList->end(); diff --git a/Minecraft.Client/PSVita/PSVita_Minecraft.cpp b/Minecraft.Client/PSVita/PSVita_Minecraft.cpp index 63512dbb8..db1e7f0fd 100644 --- a/Minecraft.Client/PSVita/PSVita_Minecraft.cpp +++ b/Minecraft.Client/PSVita/PSVita_Minecraft.cpp @@ -1078,7 +1078,7 @@ uint8_t * AddRichPresenceString(int iID) void FreeRichPresenceStrings() { uint8_t *strUtf8; - for(int i=0;igetServer()->getPlayerList(); - for( int i = 0;i < players->players.size();i += 1 ) + for( size_t i = 0;i < players->players.size();i += 1 ) { shared_ptr player = players->players[i]; if( player->level == level ) diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp index b1cbec869..ee0ba1564 100644 --- a/Minecraft.Client/PlayerList.cpp +++ b/Minecraft.Client/PlayerList.cpp @@ -463,7 +463,7 @@ void PlayerList::add(shared_ptr player) changeDimension(player, nullptr); level->addEntity(player); - for (int i = 0; i < players.size(); i++) + for (size_t i = 0; i < players.size(); i++) { shared_ptr op = players.at(i); //player->connection->send(shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); @@ -1145,7 +1145,7 @@ shared_ptr PlayerList::getNearestPlayer(Pos *position, int range) double dist = -1; int rangeSqr = range * range; - for (int i = 0; i < players.size(); i++) + for (size_t i = 0; i < players.size(); i++) { shared_ptr next = players.at(i); double newDist = position->distSqr(next->getCommandSenderWorldPosition()); @@ -1177,7 +1177,7 @@ vector *PlayerList::getPlayers(Pos *position, int rangeMin, int ra if (playerNameNot) playerName = playerName.substring(1); if (teamNameNot) teamName = teamName.substring(1); - for (int i = 0; i < players.size(); i++) { + for (size_t i = 0; i < players.size(); i++) { ServerPlayer player = players.get(i); if (level != null && player.level != level) continue; diff --git a/Minecraft.Client/ServerChunkCache.cpp b/Minecraft.Client/ServerChunkCache.cpp index f4440200e..c7d70c7d3 100644 --- a/Minecraft.Client/ServerChunkCache.cpp +++ b/Minecraft.Client/ServerChunkCache.cpp @@ -679,19 +679,19 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) vector sortedChunkList; - for( int i = 0; i < m_loadedChunkList.size(); i++ ) + for( size_t i = 0; i < m_loadedChunkList.size(); i++ ) { if( ( m_loadedChunkList[i]->x < 0 ) && ( m_loadedChunkList[i]->z < 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]); } - for( int i = 0; i < m_loadedChunkList.size(); i++ ) + for( size_t i = 0; i < m_loadedChunkList.size(); i++ ) { if( ( m_loadedChunkList[i]->x >= 0 ) && ( m_loadedChunkList[i]->z < 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]); } - for( int i = 0; i < m_loadedChunkList.size(); i++ ) + for( size_t i = 0; i < m_loadedChunkList.size(); i++ ) { if( ( m_loadedChunkList[i]->x >= 0 ) && ( m_loadedChunkList[i]->z >= 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]); } - for( int i = 0; i < m_loadedChunkList.size(); i++ ) + for( size_t i = 0; i < m_loadedChunkList.size(); i++ ) { if( ( m_loadedChunkList[i]->x < 0 ) && ( m_loadedChunkList[i]->z >= 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]); } @@ -764,19 +764,19 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) vector sortedChunkList; - for( int i = 0; i < m_loadedChunkList.size(); i++ ) + for( size_t i = 0; i < m_loadedChunkList.size(); i++ ) { if( ( m_loadedChunkList[i]->x < 0 ) && ( m_loadedChunkList[i]->z < 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]); } - for( int i = 0; i < m_loadedChunkList.size(); i++ ) + for( size_t i = 0; i < m_loadedChunkList.size(); i++ ) { if( ( m_loadedChunkList[i]->x >= 0 ) && ( m_loadedChunkList[i]->z < 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]); } - for( int i = 0; i < m_loadedChunkList.size(); i++ ) + for( size_t i = 0; i < m_loadedChunkList.size(); i++ ) { if( ( m_loadedChunkList[i]->x >= 0 ) && ( m_loadedChunkList[i]->z >= 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]); } - for( int i = 0; i < m_loadedChunkList.size(); i++ ) + for( size_t i = 0; i < m_loadedChunkList.size(); i++ ) { if( ( m_loadedChunkList[i]->x < 0 ) && ( m_loadedChunkList[i]->z >= 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]); } diff --git a/Minecraft.Client/Stitcher.cpp b/Minecraft.Client/Stitcher.cpp index fa206a75c..450c80264 100644 --- a/Minecraft.Client/Stitcher.cpp +++ b/Minecraft.Client/Stitcher.cpp @@ -122,7 +122,7 @@ int Stitcher::smallestEncompassingPowerOfTwo(int input) bool Stitcher::addToStorage(TextureHolder *textureHolder) { - for (int i = 0; i < storage.size(); i++) + for (size_t i = 0; i < storage.size(); i++) { if (storage.at(i)->add(textureHolder)) { diff --git a/Minecraft.Client/Xbox/Audio/SoundEngine.h b/Minecraft.Client/Xbox/Audio/SoundEngine.h index e2f22869b..77998d20c 100644 --- a/Minecraft.Client/Xbox/Audio/SoundEngine.h +++ b/Minecraft.Client/Xbox/Audio/SoundEngine.h @@ -77,31 +77,32 @@ class SoundEngine : public ConsoleSoundEngine #endif public: SoundEngine(); - virtual void destroy(); - virtual void play(int iSound, float x, float y, float z, float volume, float pitch); - virtual void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true); - virtual void playUI(int iSound, float volume, float pitch); - virtual void playMusicTick(); - virtual void updateMusicVolume(float fVal); - virtual void updateSystemMusicPlaying(bool isPlaying); - virtual void updateSoundEffectVolume(float fVal); - virtual void init(Options *); - virtual void tick(shared_ptr *players, float a); // 4J - updated to take array of local players rather than single one - virtual void add(const wstring& name, File *file); - virtual void addMusic(const wstring& name, File *file); - virtual void addStreaming(const wstring& name, File *file); + void destroy() override; + void play(int iSound, float x, float y, float z, float volume, float pitch) override; + void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true) override; + void playUI(int iSound, float volume, float pitch) override; + void playMusicTick() override; + void updateMusicVolume(float fVal) override; + void updateSystemMusicPlaying(bool isPlaying) override; + void updateSoundEffectVolume(float fVal) override; + void init(Options *) override; + void tick(shared_ptr *players, float a) override; // 4J - updated to take array of local players rather than single one + void add(const wstring& name, File *file) override; + void addMusic(const wstring& name, File *file) override; + void addStreaming(const wstring& name, File *file) override; #ifndef __PS3__ static void setXACTEngine( IXACT3Engine *pXACT3Engine); void CreateStreamingWavebank(const char *pchName, IXACT3WaveBank **ppStreamedWaveBank); void CreateSoundbank(const char *pchName, IXACT3SoundBank **ppSoundBank); #endif // __PS3__ - virtual char *ConvertSoundPathToName(const wstring& name, bool bConvertSpaces=false); + char *ConvertSoundPathToName(const wstring& name, bool bConvertSpaces=false) override; bool isStreamingWavebankReady(); // 4J Added #ifdef _XBOX bool isStreamingWavebankReady(IXACT3WaveBank *pWaveBank); #endif - int initAudioHardware(int iMinSpeakers) { return iMinSpeakers;} + int initAudioHardware(int iMinSpeakers) override + { return iMinSpeakers;} private: #ifndef __PS3__ diff --git a/Minecraft.World/AbstractContainerMenu.cpp b/Minecraft.World/AbstractContainerMenu.cpp index 52d491a6b..1fd400e56 100644 --- a/Minecraft.World/AbstractContainerMenu.cpp +++ b/Minecraft.World/AbstractContainerMenu.cpp @@ -480,7 +480,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto for (int pass = 0; pass < 2; pass++ ) { // In the first pass, we only get partial stacks. - for (int i = start; i >= 0 && i < static_cast(slots.size()) && carried->count < carried->getMaxStackSize(); i += step) + for (size_t i = start; i >= 0 && i < static_cast(slots.size()) && carried->count < carried->getMaxStackSize(); i += step) { Slot *target = slots.at(i); diff --git a/Minecraft.World/BaseRailTile.cpp b/Minecraft.World/BaseRailTile.cpp index be14a2643..0494e2660 100644 --- a/Minecraft.World/BaseRailTile.cpp +++ b/Minecraft.World/BaseRailTile.cpp @@ -34,7 +34,7 @@ BaseRailTile::Rail::Rail(Level *level, int x, int y, int z) BaseRailTile::Rail::~Rail() { - for( int i = 0; i < connections.size(); i++ ) + for( size_t i = 0; i < connections.size(); i++ ) { delete connections[i]; } @@ -44,7 +44,7 @@ void BaseRailTile::Rail::updateConnections(int direction) { if(m_bValidRail) { - for( int i = 0; i < connections.size(); i++ ) + for( size_t i = 0; i < connections.size(); i++ ) { delete connections[i]; } diff --git a/Minecraft.World/C4JThread.cpp b/Minecraft.World/C4JThread.cpp index 81aa010be..7993a0f6b 100644 --- a/Minecraft.World/C4JThread.cpp +++ b/Minecraft.World/C4JThread.cpp @@ -439,7 +439,7 @@ C4JThread* C4JThread::getCurrentThread() #endif //__PS3__ EnterCriticalSection(&ms_threadListCS); - for(int i=0;im_threadID) { diff --git a/Minecraft.World/ChatPacket.cpp b/Minecraft.World/ChatPacket.cpp index 44e1fedb7..c4a3ca7cc 100644 --- a/Minecraft.World/ChatPacket.cpp +++ b/Minecraft.World/ChatPacket.cpp @@ -71,12 +71,12 @@ void ChatPacket::write(DataOutputStream *dos) dos->writeShort(packedCounts); - for(int i = 0; i < m_stringArgs.size(); i++) + for(size_t i = 0; i < m_stringArgs.size(); i++) { writeUtf(m_stringArgs[i], dos); } - for(int i = 0; i < m_intArgs.size(); i++) + for(size_t i = 0; i < m_intArgs.size(); i++) { dos->writeInt(m_intArgs[i]); } @@ -92,7 +92,7 @@ void ChatPacket::handle(PacketListener *listener) int ChatPacket::getEstimatedSize() { int stringsSize = 0; - for(int i = 0; i < m_stringArgs.size(); i++) + for(size_t i = 0; i < m_stringArgs.size(); i++) { stringsSize += m_stringArgs[i].length(); } diff --git a/Minecraft.World/CombatTracker.cpp b/Minecraft.World/CombatTracker.cpp index 7e1aa80c4..690291157 100644 --- a/Minecraft.World/CombatTracker.cpp +++ b/Minecraft.World/CombatTracker.cpp @@ -170,7 +170,7 @@ CombatEntry *CombatTracker::getMostSignificantFall() int altDamage = 0; float bestFall = 0; - for (int i = 0; i < entries.size(); i++) + for (size_t i = 0; i < entries.size(); i++) { CombatEntry *entry = entries.at(i); CombatEntry *previous = i > 0 ? entries.at(i - 1) : nullptr; diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp index c1d3f9c5b..4015d8f68 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -341,7 +341,7 @@ bool Connection::readTick() // printf("Con:0x%x readTick close EOS\n",this); // 4J Stu - Remove this line - // Fix for #10410 - UI: If the player is removed from a splitscreened hosts game, the next game that player joins will produce a message stating that the host has left. + // Fix for #10410 - UI: If the player is removed from a splitscreened host�s game, the next game that player joins will produce a message stating that the host has left. //close(DisconnectPacket::eDisconnect_EndOfStream); } @@ -498,7 +498,7 @@ void Connection::tick() LeaveCriticalSection(&incoming_cs); // MGH - moved the packet handling outside of the incoming_cs block, as it was locking up sometimes when disconnecting - for(int i=0; igetId()); packetsToHandle[i]->handle(packetListener); diff --git a/Minecraft.World/EnchantmentMenu.cpp b/Minecraft.World/EnchantmentMenu.cpp index 86c88e88a..f37f336ea 100644 --- a/Minecraft.World/EnchantmentMenu.cpp +++ b/Minecraft.World/EnchantmentMenu.cpp @@ -53,7 +53,7 @@ void EnchantmentMenu::broadcastChanges() // 4J Added m_costsChanged to stop continually sending update packets even when no changes have been made if(m_costsChanged) { - for (int i = 0; i < containerListeners.size(); i++) + for (size_t i = 0; i < containerListeners.size(); i++) { ContainerListener *listener = containerListeners.at(i); listener->setContainerData(this, 0, costs[0]); diff --git a/Minecraft.World/File.cpp b/Minecraft.World/File.cpp index 4b36169f5..11871e426 100644 --- a/Minecraft.World/File.cpp +++ b/Minecraft.World/File.cpp @@ -673,7 +673,7 @@ const std::wstring File::getPath() const std::wstring File::getName() const { - unsigned int sep = static_cast(m_abstractPathName.find_last_of(this->pathSeparator)); + size_t sep = m_abstractPathName.find_last_of(this->pathSeparator); return m_abstractPathName.substr( sep + 1, m_abstractPathName.length() ); } diff --git a/Minecraft.World/FireworksItem.cpp b/Minecraft.World/FireworksItem.cpp index 155a49617..f1cdf309e 100644 --- a/Minecraft.World/FireworksItem.cpp +++ b/Minecraft.World/FireworksItem.cpp @@ -69,7 +69,7 @@ void FireworksItem::appendHoverText(shared_ptr itemInstance, share if (eLines.size() > 0) { // Indent lines after first line - for (int i = 1; i < eLines.size(); i++) + for (size_t i = 1; i < eLines.size(); i++) { eLines[i].indent = true; } diff --git a/Minecraft.World/FlatGeneratorInfo.cpp b/Minecraft.World/FlatGeneratorInfo.cpp index 3dd54453d..c983fd2c4 100644 --- a/Minecraft.World/FlatGeneratorInfo.cpp +++ b/Minecraft.World/FlatGeneratorInfo.cpp @@ -66,7 +66,7 @@ wstring FlatGeneratorInfo::toString() builder.append(SERIALIZATION_VERSION); builder.append(";"); - for (int i = 0; i < layers.size(); i++) + for (size_t i = 0; i < layers.size(); i++) { if (i > 0) builder.append(","); builder.append(layers.get(i).toString()); diff --git a/Minecraft.World/IntCache.cpp b/Minecraft.World/IntCache.cpp index 7c8a94df2..cd980d16f 100644 --- a/Minecraft.World/IntCache.cpp +++ b/Minecraft.World/IntCache.cpp @@ -28,7 +28,7 @@ IntCache::ThreadStorage::~ThreadStorage() { delete [] allocated[i].data; } - for( int i = 0; i < toosmall.size(); i++ ) + for( size_t i = 0; i < toosmall.size(); i++ ) { delete [] toosmall[i].data; } @@ -103,7 +103,7 @@ void IntCache::releaseAll() ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); // 4J - added - we can now remove the vectors that were deemed as too small (see comment in IntCache::allocate) - for( int i = 0; i < tls->toosmall.size(); i++ ) + for( size_t i = 0; i < tls->toosmall.size(); i++ ) { delete [] tls->toosmall[i].data; } @@ -132,25 +132,25 @@ void IntCache::Reset() { ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); tls->maxSize = TINY_CUTOFF; - for( int i = 0; i < tls->allocated.size(); i++ ) + for( size_t i = 0; i < tls->allocated.size(); i++ ) { delete [] tls->allocated[i].data; } tls->allocated.clear(); - for( int i = 0; i < tls->cache.size(); i++ ) + for( size_t i = 0; i < tls->cache.size(); i++ ) { delete [] tls->cache[i].data; } tls->cache.clear(); - for( int i = 0; i < tls->tallocated.size(); i++ ) + for( size_t i = 0; i < tls->tallocated.size(); i++ ) { delete [] tls->tallocated[i].data; } tls->tallocated.clear(); - for( int i = 0; i < tls->tcache.size(); i++ ) + for( size_t i = 0; i < tls->tcache.size(); i++ ) { delete [] tls->tcache[i].data; } diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp index c9670cf30..94e2ecfba 100644 --- a/Minecraft.World/Level.cpp +++ b/Minecraft.World/Level.cpp @@ -2895,7 +2895,7 @@ shared_ptr Level::getTileEntity(int x, int y, int z) if (updatingTileEntities) { EnterCriticalSection(&m_tileEntityListCS); - for (int i = 0; i < pendingTileEntities.size(); i++) + for (size_t i = 0; i < pendingTileEntities.size(); i++) { shared_ptr e = pendingTileEntities.at(i); if (!e->isRemoved() && e->x == x && e->y == y && e->z == z) diff --git a/Minecraft.World/MerchantRecipeList.cpp b/Minecraft.World/MerchantRecipeList.cpp index 2a88da16d..4e1684d45 100644 --- a/Minecraft.World/MerchantRecipeList.cpp +++ b/Minecraft.World/MerchantRecipeList.cpp @@ -34,7 +34,7 @@ MerchantRecipe *MerchantRecipeList::getRecipeFor(shared_ptr buyA, } return nullptr; } - for (int i = 0; i < m_recipes.size(); i++) + for (size_t i = 0; i < m_recipes.size(); i++) { MerchantRecipe *r = m_recipes.at(i); if (buyA->id == r->getBuyAItem()->id && buyA->count >= r->getBuyAItem()->count @@ -49,7 +49,7 @@ MerchantRecipe *MerchantRecipeList::getRecipeFor(shared_ptr buyA, bool MerchantRecipeList::addIfNewOrBetter(MerchantRecipe *recipe) { bool added = false; - for (int i = 0; i < m_recipes.size(); i++) + for (size_t i = 0; i < m_recipes.size(); i++) { MerchantRecipe *r = m_recipes.at(i); if (recipe->isSame(r)) @@ -69,7 +69,7 @@ bool MerchantRecipeList::addIfNewOrBetter(MerchantRecipe *recipe) MerchantRecipe *MerchantRecipeList::getMatchingRecipeFor(shared_ptr buy, shared_ptr buyB, shared_ptr sell) { - for (int i = 0; i < m_recipes.size(); i++) + for (size_t i = 0; i < m_recipes.size(); i++) { MerchantRecipe *r = m_recipes.at(i); if (buy->id == r->getBuyAItem()->id && buy->count >= r->getBuyAItem()->count && sell->id == r->getSellItem()->id) @@ -86,7 +86,7 @@ MerchantRecipe *MerchantRecipeList::getMatchingRecipeFor(shared_ptrwriteByte(static_cast(m_recipes.size() & 0xff)); - for (int i = 0; i < m_recipes.size(); i++) + for (size_t i = 0; i < m_recipes.size(); i++) { MerchantRecipe *r = m_recipes.at(i); Packet::writeItem(r->getBuyAItem(), stream); @@ -149,7 +149,7 @@ CompoundTag *MerchantRecipeList::createTag() CompoundTag *tag = new CompoundTag(); ListTag *list = new ListTag(L"Recipes"); - for (int i = 0; i < m_recipes.size(); i++) + for (size_t i = 0; i < m_recipes.size(); i++) { MerchantRecipe *merchantRecipe = m_recipes.at(i); list->add(merchantRecipe->createTag()); diff --git a/Minecraft.World/PotionBrewing.cpp b/Minecraft.World/PotionBrewing.cpp index 469c40715..bc5fd8c71 100644 --- a/Minecraft.World/PotionBrewing.cpp +++ b/Minecraft.World/PotionBrewing.cpp @@ -325,16 +325,16 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, } // split by and - int andIndex = static_cast(definition.find_first_of(L'&', start)); - if (andIndex >= 0 && andIndex < end) + size_t andIndex = definition.find_first_of(L'&', start); + if (andIndex != wstring::npos && andIndex < static_cast(end)) { - int leftSide = parseEffectFormulaValue(definition, start, andIndex - 1, brew); + int leftSide = parseEffectFormulaValue(definition, start, static_cast(andIndex) - 1, brew); if (leftSide <= 0) { return 0; } - int rightSide = parseEffectFormulaValue(definition, andIndex + 1, end, brew); + int rightSide = parseEffectFormulaValue(definition, static_cast(andIndex) + 1, end, brew); if (rightSide <= 0) { return 0; @@ -413,16 +413,16 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, } // split by or - int orIndex = definition.find_first_of(L'|', start); - if (orIndex >= 0 && orIndex < end) + size_t orIndex = definition.find_first_of(L'|', start); + if (orIndex != wstring::npos && orIndex < static_cast(end)) { - int leftSide = parseEffectFormulaValue(definition, start, orIndex - 1, brew); + int leftSide = parseEffectFormulaValue(definition, start, static_cast(orIndex) - 1, brew); if (leftSide > 0) { return leftSide; } - int rightSide = parseEffectFormulaValue(definition, orIndex + 1, end, brew); + int rightSide = parseEffectFormulaValue(definition, static_cast(orIndex) + 1, end, brew); if (rightSide > 0) { return rightSide; @@ -430,10 +430,10 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, return 0; } // split by and - int andIndex = definition.find_first_of(L'&', start); - if (andIndex >= 0 && andIndex < end) + size_t andIndex = definition.find_first_of(L'&', start); + if (andIndex != wstring::npos && andIndex < static_cast(end)) { - int leftSide = parseEffectFormulaValue(definition, start, andIndex - 1, brew); + int leftSide = parseEffectFormulaValue(definition, start, static_cast(andIndex) - 1, brew); if (leftSide <= 0) { return 0; diff --git a/Minecraft.World/ServersideAttributeMap.cpp b/Minecraft.World/ServersideAttributeMap.cpp index 5da807123..07544e766 100644 --- a/Minecraft.World/ServersideAttributeMap.cpp +++ b/Minecraft.World/ServersideAttributeMap.cpp @@ -69,7 +69,7 @@ unordered_set *ServersideAttributeMap::getSyncableAttribute unordered_set *result = new unordered_set(); vector atts; getAttributes(atts); - for (int i = 0; i < atts.size(); i++) + for (size_t i = 0; i < atts.size(); i++) { AttributeInstance *instance = atts.at(i); diff --git a/Minecraft.World/StringHelpers.cpp b/Minecraft.World/StringHelpers.cpp index 43b4f58b4..b56a85f14 100644 --- a/Minecraft.World/StringHelpers.cpp +++ b/Minecraft.World/StringHelpers.cpp @@ -10,10 +10,10 @@ wstring toLower(const wstring& a) wstring trimString(const wstring& a) { wstring b; - int start = static_cast(a.find_first_not_of(L" \t\n\r")); - int end = static_cast(a.find_last_not_of(L" \t\n\r")); + size_t start = a.find_first_not_of(L" \t\n\r"); + size_t end = a.find_last_not_of(L" \t\n\r"); if( start == wstring::npos ) start = 0; - if( end == wstring::npos ) end = static_cast(a.size())-1; + if( end == wstring::npos ) end = a.size() - 1; b = a.substr(start,(end-start)+1); return b; } From 699d84b70c18e6152ce6a9d0afeb5537c2e45b13 Mon Sep 17 00:00:00 2001 From: Chase Cooper Date: Sat, 7 Mar 2026 23:27:09 -0500 Subject: [PATCH 9/9] Add safety checks and fix a issue with vector going OOR --- Minecraft.Client/Common/UI/UILayer.cpp | 6 +++--- Minecraft.Client/EntityRenderDispatcher.cpp | 5 +++++ Minecraft.Client/GameRenderer.cpp | 5 +++++ Minecraft.Client/Gui.cpp | 8 +++++++- Minecraft.Client/ItemInHandRenderer.cpp | 5 +++++ Minecraft.Client/LevelRenderer.cpp | 18 ++++++++++++++++++ Minecraft.Client/LivingEntityRenderer.cpp | 10 ++++++++++ Minecraft.Client/MobRenderer.cpp | 10 ++++++++++ .../PSVita/Network/SonyVoiceChat_Vita.cpp | 2 +- Minecraft.Client/ParticleEngine.cpp | 5 +++++ Minecraft.Client/PlayerRenderer.cpp | 6 ++++++ Minecraft.World/AbstractContainerMenu.cpp | 14 +++++++++++++- Minecraft.World/EnchantmentMenu.cpp | 11 ++++++++++- Minecraft.World/MerchantRecipeList.cpp | 11 ++++++++++- Minecraft.World/ServersideAttributeMap.cpp | 4 ++++ 15 files changed, 112 insertions(+), 8 deletions(-) diff --git a/Minecraft.Client/Common/UI/UILayer.cpp b/Minecraft.Client/Common/UI/UILayer.cpp index bf360c07f..e1c388f54 100644 --- a/Minecraft.Client/Common/UI/UILayer.cpp +++ b/Minecraft.Client/Common/UI/UILayer.cpp @@ -102,7 +102,7 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) bool UILayer::IsSceneInStack(EUIScene scene) { bool inStack = false; - for(size_t i = (int)m_sceneStack.size() - 1;i >= 0; --i) + for(int i = static_cast(m_sceneStack.size()) - 1; i >= 0; --i) { if(m_sceneStack[i]->getSceneType() == scene) { @@ -118,7 +118,7 @@ bool UILayer::HasFocus(int iPad) bool hasFocus = false; if(m_hasFocus) { - for(size_t i = (int)m_sceneStack.size() - 1;i >= 0; --i) + for(int i = (int)m_sceneStack.size() - 1; i >= 0; --i) { if(m_sceneStack[i]->stealsFocus() ) { @@ -146,7 +146,7 @@ bool UILayer::hidesLowerScenes() } if(!hidesScenes && !m_sceneStack.empty()) { - for(size_t i = (int)m_sceneStack.size() - 1;i >= 0; --i) + for(int i = static_cast(m_sceneStack.size()) - 1; i >= 0; --i) { if(m_sceneStack[i]->hidesLowerScenes()) { diff --git a/Minecraft.Client/EntityRenderDispatcher.cpp b/Minecraft.Client/EntityRenderDispatcher.cpp index cc14558f9..b54967bde 100644 --- a/Minecraft.Client/EntityRenderDispatcher.cpp +++ b/Minecraft.Client/EntityRenderDispatcher.cpp @@ -244,6 +244,11 @@ void EntityRenderDispatcher::prepare(Level *level, Textures *textures, Font *fon void EntityRenderDispatcher::render(shared_ptr entity, float a) { + if (entity == nullptr) + { + return; + } + double x = entity->xOld + (entity->x - entity->xOld) * a; double y = entity->yOld + (entity->y - entity->yOld) * a; double z = entity->zOld + (entity->z - entity->zOld) * a; diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index ecd2f462b..9fe3e26ba 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -1133,6 +1133,11 @@ int GameRenderer::getLightTexture(int iPad, Level *level) void GameRenderer::render(float a, bool bFirst) { + if (mc->player == nullptr) + { + return; + } + if( _updateLightTexture && bFirst) updateLightTexture(a); if (Display::isActive()) { diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index 6217bc40c..8ca65dfed 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -63,6 +63,12 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) // 4J Stu - I have copied this code for XUI_BaseScene. If/when it gets changed it should be broken out // 4J - altered to force full screen mode to 3X scaling, and any split screen modes to 2X scaling. This is so that the further scaling by 0.5 that // happens in split screen modes results in a final scaling of 1 rather than 1.5. + + if (minecraft->player == nullptr) + { + return; + } + int splitYOffset;// = 20; // This offset is applied when doing the 2X scaling above to move the gui out of the way of the tool tips int guiScale;// = ( minecraft->player->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN ? 3 : 2 ); int iPad=minecraft->player->GetXboxPad(); @@ -845,7 +851,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) #ifndef _FINAL_BUILD MemSect(31); - if (minecraft->options->renderDebug) + if (minecraft->options->renderDebug && minecraft->player != nullptr && minecraft->level != nullptr) { const int debugLeft = 1; const int debugTop = 1; diff --git a/Minecraft.Client/ItemInHandRenderer.cpp b/Minecraft.Client/ItemInHandRenderer.cpp index 4cebda2fd..152a56688 100644 --- a/Minecraft.Client/ItemInHandRenderer.cpp +++ b/Minecraft.Client/ItemInHandRenderer.cpp @@ -373,6 +373,11 @@ void ItemInHandRenderer::render(float a) float h = oHeight + (height - oHeight) * a; shared_ptr player = minecraft->player; + if (player == nullptr) + { + return; + } + // 4J - added so we can adjust the position of the hands for horizontal & vertical split screens float fudgeX = 0.0f; float fudgeY = 0.0f; diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index 8d61e1b2d..82fc3e9bc 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -507,6 +507,11 @@ void LevelRenderer::allChanged(int playerIndex) void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a) { + if (mc == nullptr || mc->player == nullptr) + { + return; + } + int playerIndex = mc->player->GetXboxPad(); // 4J added // 4J Stu - Set these up every time, even when not rendering as other things (like particle render) may depend on it for those frames. @@ -524,6 +529,10 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a) culledEntities = 0; shared_ptr player = mc->cameraTargetPlayer; + if (player == nullptr) + { + return; + } EntityRenderDispatcher::xOff = (player->xOld + (player->x - player->xOld) * a); EntityRenderDispatcher::yOff = (player->yOld + (player->y - player->yOld) * a); @@ -758,12 +767,21 @@ int compare (const void * a, const void * b) int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) { + if (mc == nullptr || mc->player == nullptr) + { + return 0; + } + int playerIndex = mc->player->GetXboxPad(); // 4J added #if 1 // 4J - cut down version, we're not using offsetted render lists, or a sorted chunk list, anymore mc->gameRenderer->turnOnLightLayer(alpha); // 4J - brought forward from 1.8.2 shared_ptr player = mc->cameraTargetPlayer; + if (player == nullptr) + { + return 0; + } double xOff = player->xOld + (player->x - player->xOld) * alpha; double yOff = player->yOld + (player->y - player->yOld) * alpha; double zOff = player->zOld + (player->z - player->zOld) * alpha; diff --git a/Minecraft.Client/LivingEntityRenderer.cpp b/Minecraft.Client/LivingEntityRenderer.cpp index 600a66554..b3478ba92 100644 --- a/Minecraft.Client/LivingEntityRenderer.cpp +++ b/Minecraft.Client/LivingEntityRenderer.cpp @@ -37,8 +37,18 @@ float LivingEntityRenderer::rotlerp(float from, float to, float a) void LivingEntityRenderer::render(shared_ptr _mob, double x, double y, double z, float rot, float a) { + if (_mob == nullptr) + { + return; + } + shared_ptr mob = dynamic_pointer_cast(_mob); + if (mob == nullptr) + { + return; + } + glPushMatrix(); glDisable(GL_CULL_FACE); diff --git a/Minecraft.Client/MobRenderer.cpp b/Minecraft.Client/MobRenderer.cpp index 92c89394a..539980702 100644 --- a/Minecraft.Client/MobRenderer.cpp +++ b/Minecraft.Client/MobRenderer.cpp @@ -15,8 +15,18 @@ MobRenderer::MobRenderer(Model *model, float shadow) : LivingEntityRenderer(mode void MobRenderer::render(shared_ptr _mob, double x, double y, double z, float rot, float a) { + if (_mob == nullptr) + { + return; + } + shared_ptr mob = dynamic_pointer_cast(_mob); + if (mob == nullptr) + { + return; + } + LivingEntityRenderer::render(mob, x, y, z, rot, a); renderLeash(mob, x, y, z, rot, a); } diff --git a/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp index cf1ce9ad5..37fea8282 100644 --- a/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp @@ -668,7 +668,7 @@ void SonyVoiceChat_Vita::tick() EnterCriticalSection(&m_csRemoteConnections); - for(size_t i=m_remoteConnections.size()-1;i>=0;i--) + for(int i = (int)m_remoteConnections.size() - 1; i >= 0; i--) { if(m_remoteConnections[i]->m_bFlaggedForShutdown) { diff --git a/Minecraft.Client/ParticleEngine.cpp b/Minecraft.Client/ParticleEngine.cpp index efc09c9ad..f8a8ec230 100644 --- a/Minecraft.Client/ParticleEngine.cpp +++ b/Minecraft.Client/ParticleEngine.cpp @@ -83,6 +83,11 @@ void ParticleEngine::tick() void ParticleEngine::render(shared_ptr player, float a, int list) { + if (player == nullptr) + { + return; + } + // 4J - change brought forward from 1.2.3 float xa = Camera::xa; float za = Camera::za; diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index 68dae2eeb..a9b945440 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -153,9 +153,15 @@ void PlayerRenderer::prepareSecondPassArmor(shared_ptr _player, in void PlayerRenderer::render(shared_ptr _mob, double x, double y, double z, float rot, float a) { + if (_mob == nullptr) + { + return; + } + // 4J - dynamic cast required because we aren't using templates/generics in our version shared_ptr mob = dynamic_pointer_cast(_mob); + if(mob == nullptr) return; if(mob->hasInvisiblePrivilege()) return; shared_ptr item = mob->inventory->getSelected(); diff --git a/Minecraft.World/AbstractContainerMenu.cpp b/Minecraft.World/AbstractContainerMenu.cpp index 1fd400e56..10d8afdcc 100644 --- a/Minecraft.World/AbstractContainerMenu.cpp +++ b/Minecraft.World/AbstractContainerMenu.cpp @@ -131,11 +131,19 @@ Slot *AbstractContainerMenu::getSlotFor(shared_ptr c, int index) Slot *AbstractContainerMenu::getSlot(int index) { + if (index < 0 || index >= static_cast(slots.size())) + { + return nullptr; + } return slots.at(index); } shared_ptr AbstractContainerMenu::quickMoveStack(shared_ptr player, int slotIndex) { + if (slotIndex < 0 || slotIndex >= static_cast(slots.size())) + { + return nullptr; + } Slot *slot = slots.at(slotIndex); if (slot != nullptr) { @@ -251,7 +259,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto } else if (clickType == CLICK_QUICK_MOVE) { - if (slotIndex < 0) return nullptr; + if (slotIndex < 0 || slotIndex >= static_cast(slots.size())) return nullptr; Slot *slot = slots.at(slotIndex); if(slot != nullptr && slot->mayPickup(player)) { @@ -408,6 +416,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto } else if (clickType == CLICK_SWAP && buttonNum >= 0 && buttonNum < 9) { + if (slotIndex < 0 || slotIndex >= static_cast(slots.size())) return nullptr; Slot *slot = slots.at(slotIndex); if (slot->mayPickup(player)) { @@ -449,6 +458,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto } else if (clickType == CLICK_CLONE && player->abilities.instabuild && inventory->getCarried() == nullptr && slotIndex >= 0) { + if (slotIndex >= static_cast(slots.size())) return nullptr; Slot *slot = slots.at(slotIndex); if (slot != nullptr && slot->hasItem()) { @@ -459,6 +469,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto } else if (clickType == CLICK_THROW && inventory->getCarried() == nullptr && slotIndex >= 0) { + if (slotIndex >= static_cast(slots.size())) return nullptr; Slot *slot = slots.at(slotIndex); if (slot != nullptr && slot->hasItem() && slot->mayPickup(player)) { @@ -469,6 +480,7 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto } else if (clickType == CLICK_PICKUP_ALL && slotIndex >= 0) { + if (slotIndex >= static_cast(slots.size())) return nullptr; Slot *slot = slots.at(slotIndex); shared_ptr carried = inventory->getCarried(); diff --git a/Minecraft.World/EnchantmentMenu.cpp b/Minecraft.World/EnchantmentMenu.cpp index f37f336ea..6af7113ac 100644 --- a/Minecraft.World/EnchantmentMenu.cpp +++ b/Minecraft.World/EnchantmentMenu.cpp @@ -215,9 +215,18 @@ bool EnchantmentMenu::stillValid(shared_ptr player) shared_ptr EnchantmentMenu::quickMoveStack(shared_ptr player, int slotIndex) { + if (slotIndex < 0 || slotIndex >= static_cast(slots.size())) + { + return nullptr; + } + shared_ptr clicked = nullptr; Slot *slot = slots.at(slotIndex); - Slot *IngredientSlot = slots.at(INGREDIENT_SLOT); + Slot *IngredientSlot = nullptr; + if (INGREDIENT_SLOT >= 0 && INGREDIENT_SLOT < static_cast(slots.size())) + { + IngredientSlot = slots.at(INGREDIENT_SLOT); + } if (slot != nullptr && slot->hasItem()) { diff --git a/Minecraft.World/MerchantRecipeList.cpp b/Minecraft.World/MerchantRecipeList.cpp index 4e1684d45..b1498389b 100644 --- a/Minecraft.World/MerchantRecipeList.cpp +++ b/Minecraft.World/MerchantRecipeList.cpp @@ -21,7 +21,12 @@ MerchantRecipeList::~MerchantRecipeList() MerchantRecipe *MerchantRecipeList::getRecipeFor(shared_ptr buyA, shared_ptr buyB, int selectionHint) { - if (selectionHint > 0 && selectionHint < m_recipes.size()) + if (buyA == nullptr) + { + return nullptr; + } + + if (selectionHint > 0 && selectionHint < static_cast(m_recipes.size())) { // attempt to match vs the hint MerchantRecipe *r = m_recipes.at(selectionHint); @@ -166,6 +171,10 @@ void MerchantRecipeList::push_back(MerchantRecipe *recipe) MerchantRecipe *MerchantRecipeList::at(size_t index) { + if (index >= m_recipes.size()) + { + return nullptr; + } return m_recipes.at(index); } diff --git a/Minecraft.World/ServersideAttributeMap.cpp b/Minecraft.World/ServersideAttributeMap.cpp index 07544e766..c73086662 100644 --- a/Minecraft.World/ServersideAttributeMap.cpp +++ b/Minecraft.World/ServersideAttributeMap.cpp @@ -72,6 +72,10 @@ unordered_set *ServersideAttributeMap::getSyncableAttribute for (size_t i = 0; i < atts.size(); i++) { AttributeInstance *instance = atts.at(i); + if (instance == nullptr) + { + continue; + } if (instance->getAttribute()->isClientSyncable()) {